#+title: Doom Emacs Config * Main #+PROPERTY: header-args :results silent ** Help #+begin_src emacs-lisp :tangle yes ;; Here are some additional functions/macros that could help you configure Doom: ;; ;; - `load!' for loading external *.el files relative to this one ;; - `use-package!' for configuring packages ;; - `after!' for running code after a package has loaded ;; - `add-load-path!' for adding directories to the `load-path', relative to ;; this file. Emacs searches the `load-path' when you load packages with ;; `require' or `use-package'. ;; - `map!' for binding new keys ;; ;; To get information about any of these functions/macros, move the cursor over ;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k'). ;; This will open documentation for it, including demos of how they are used. ;; ;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how ;; they are implemented. #+end_src ** Overall config #+begin_src emacs-lisp :tangle yes ;; Some functionality uses this to identify you, e.g. GPG configuration, email ;; clients, file templates and snippets. (setq user-full-name "Julian Mutter" user-mail-address "julian.mutter@comumail.de") ;; Doom exposes five (optional) variables for controlling fonts in Doom. Here ;; are the three important ones: ;; ;; + `doom-font' ;; + `doom-variable-pitch-font' ;; + `doom-big-font' -- used for `doom-big-font-mode'; use this for ;; presentations or streaming. ;; ;; They all accept either a font-spec, font string ("Input Mono-12"), or xlfd ;; font string. You generally only need these two: ;; (setq doom-font (font-spec :family "monospace" :size 13 :weight 'semi-light) ;; doom-variable-pitch-font (font-spec :family "sans" :size 13)) (setq doom-font (font-spec :family "Source Code Pro" :size 14)) ;; There are two ways to load a theme. Both assume the theme is installed and ;; available. You can either set `doom-theme' or manually load a theme with the ;; `load-theme' function. This is the default: (setq doom-theme 'doom-one) ;; This determines the style of line numbers in effect. If set to `nil', line ;; numbers are disabled. For relative line numbers, set this to `relative'. (setq display-line-numbers-type 'relative) #+end_src #+begin_src emacs-lisp :tangle yes ;; Open external terminal (map! :leader :desc "Open external terminal" "o t" (cmd! (call-process-shell-command "alacritty &" nil 0))) ;; Remap font scaling keybindings to make more sense (map! :desc "Increase font size" :n "C-+" #'text-scale-increase) (map! :desc "Decrease font size" :n "C--" #'text-scale-decrease) (map! :desc "Reset font size" :n "C-=" #'doom/reset-font-size) (map! :desc "Flycheck next error" :nv "g n" #'flycheck-next-error) (map! :desc "Flycheck previous error" :nv "g N" #'flycheck-previous-error) (map! :desc "Format and save" :g "C-s" #'fd-format-and-save) (map! :leader "w 1" #'delete-other-windows) (map! :leader "r" #'quickrun) (setq-default evil-escape-key-sequence "kj") (defun fd-format-and-save() (interactive) (company-abort) (evil-force-normal-state) (+format/buffer) (save-buffer)) (setq confirm-kill-emacs nil) #+end_src ** Org #+begin_src emacs-lisp :tangle yes ;; If you use `org' and don't want your org files in the default location below, ;; change `org-directory'. It must be set before org loads! (setq org-directory "~/Nextcloud/org" org-roam-directory "~/Nextcloud/org/roam") (setq org-agenda-files (list org-directory)) ;; (custom-set-variables ;; '(org-directory "~/org") ;; '(org-agenda-files (list org-directory))) ;; (add-to-list 'org-agenda-files "~/org/anothertest.org" 'append) ;; Adding my org-agenda files ;; (after! org ;; (setq org-agenda-files (expand-file-name "org-agenda-files" doom-private-dir))) (setq org-export-allow-bind-keywords t) ;; (map! :nv "SPC r" "SPC n r") (map! :map org-mode-map :nvi "C-k" #'org-backward-element) (map! :map org-mode-map :nvi "C-j" #'org-forward-element) (map! :map org-mode-map :nvi "C-h" #'org-up-element) (map! :map org-mode-map :nvi "C-l" #'org-down-element) (map! :map org-mode-map :nvi "M-i" #'org-roam-node-insert) (map! :map doom-leader-notes-map "r r" #'org-roam-node-find) (map! :map doom-leader-notes-map "r t" #'org-roam-buffer-toggle) (setq org-roam-preview-function #'fd-my-org-roam-preview-function) (defun fd-my-org-roam-preview-function () "Return the preview content at point. This function returns the all contents under the current headline, up to the next headline." (let ((beg (save-excursion (org-roam-end-of-meta-data t) (point))) (end (save-excursion (condition-case nil (progn (outline-forward-same-level) (backward-char) (point) ) (error (point-max)))))) (string-trim (buffer-substring-no-properties beg end)))) #+end_src ** TeX #+begin_src emacs-lisp :tangle yes (map! :map TeX-mode-map :nvi "" #'outline-cycle-buffer) ;; (map! :map TeX-mode-map :nvi "" #'outline-cycle) (map! :map TeX-mode-map :nvi "C-k" #'outline-backward-same-level) (map! :map TeX-mode-map :nvi "C-j" #'outline-forward-same-level) (map! :map TeX-mode-map :nvi "C-h" #'outline-up-heading) (map! :map TeX-mode-map :nvi "C-l" #'outline-next-heading) (add-hook 'LaTeX-mode-hook 'langtool-ignore-fonts-minor-mode) (setq langtool-default-language "de-DE") (use-package! langtool-ignore-fonts :config (langtool-ignore-fonts-add 'latex-mode '(font-lock-comment-face ;; font-latex-math-face ;; font-latex-string-face font-lock-keyword-face font-lock-constant-face font-lock-function-name-face font-lock-variable-name-face font-lock-type-face))) ;; figure captions ;; Fixes latexindent not finding perl libraries (setenv "PERL5LIB" "/home/julian/perl5/lib/perl5") ;; (setenv "GOPATH" "/home/julian/go") #+end_src ** Spell Checking #+begin_src emacs-lisp :tangle yes (use-package! langtool :init (setq langtool-language-tool-jar "/home/julian/git/languagetool/languagetool-standalone/target/LanguageTool-6.1-SNAPSHOT/LanguageTool-6.1-SNAPSHOT/languagetool-commandline.jar")) ;; TODO make toggling of spell checking ('SPC t s') use flyspell-mode in text modesm and flyspell-prog-mode in programming modes (see hooks below) ;; Removing hooks for automatic spell checking set here: https://github.com/hlissner/doom-emacs/blob/develop/modules/checkers/spell/config.el (remove-hook! '(org-mode-hook markdown-mode-hook TeX-mode-hook rst-mode-hook mu4e-compose-mode-hook message-mode-hook git-commit-mode-hook) #'flyspell-mode) (remove-hook! '(yaml-mode-hook conf-mode-hook prog-mode-hook) #'flyspell-prog-mode) ;; (setq ispell-dictionary "english") (setq ispell-personal-dictionary "~/ispell-personal-dictionary") (map! :map doom-leader-toggle-map :desc "Toggle dictionary" "d" #'fd-switch-dictionary) (defun fd-switch-dictionary() (interactive) (let* ((dic ispell-current-dictionary) (change (if (string= dic "german") "english" "german"))) (ispell-change-dictionary change) (message "Dictionary switched from %s to %s" dic change) )) (set-flyspell-predicate! '(latex-mode) #'+latex-flyspell-word-p) (defun +latex-flyspell-word-p () "Return t if point is on a word that should be spell checked. Return nil if on a link url, markup, html, or references." (let ((faces (ensure-list (get-text-property (point) 'face)))) (or (and (memq 'font-lock-comment-face faces) (memq 'markdown-code-face faces)) (not (cl-loop with unsafe-faces = '(font-lock-comment-face ;; font-latex-math-face ;; font-latex-string-face font-lock-keyword-face font-lock-constant-face font-lock-function-name-face font-lock-variable-name-face font-lock-type-face ;; figure captions ) for face in faces if (memq face unsafe-faces) return t))))) #+end_src ** Flutter #+begin_src emacs-lisp :tangle yes ;; (setq lsp-dart-flutter-sdk-dir "/home/julian/snap/flutter/common/flutter") (map! :mode dart-mode :leader "r" #'flutter-run-or-hot-reload) #+end_src ** Evil snipe #+begin_src emacs-lisp :tangle yes ;; Make sniping simpler for german keyboard (setq evil-snipe-scope 'visible) (map! :map evil-snipe-override-mode-map :m "," #'evil-snipe-repeat) (map! :map evil-snipe-override-mode-map :m ";" #'evil-snipe-repeat-reverse) (map! :map evil-snipe-parent-transient-map "," #'evil-snipe-repeat) (map! :map evil-snipe-parent-transient-map ";" #'evil-snipe-repeat-reverse) #+end_src ** Matlab #+begin_src emacs-lisp :tangle yes (add-hook 'matlab-mode-hook (lambda () (add-to-list 'quickrun-file-alist '("\\.m\\'" . "octave")))) ;; (assq-delete-all "objc" quickrun-file-alist) (quickrun-add-command "matlab" '((:command . "octave")) :mode #'matlab-mode ) (quickrun-add-command "octave" '((:command . "octave")) :mode #'octave-mode ) ;; (autoload 'matlab-mode "matlab" "Matlab Editing Mode" t) (add-to-list 'auto-mode-alist '("\\.m$" . matlab-mode)) ;; (setq matlab-indent-function t) ;; (setq matlab-shell-command "/urs/local/bin/matlab") #+end_src ** Features *** Toggle word case #+begin_src elisp :tangle yes (map! :desc "Toggle case of word" :nv "g C" #'toggle-word-case) (defun toggle-word-case () "Toggle the case of current word or text selection." (interactive) (let ( (deactivate-mark nil) $p1 $p2) (if (use-region-p) (setq $p1 (region-beginning) $p2 (region-end)) (save-excursion (skip-chars-backward "[:alpha:]") (setq $p1 (point)) (skip-chars-forward "[:alpha:]") (setq $p2 (point)))) (let ((first-char-prop (get-char-code-property (char-after $p1) 'general-category))) (cond ((string= "Ll" first-char-prop) ; Lower case (upcase-region $p1 (+ $p1 1))) ((string= "Lu" first-char-prop) ; Upper case (downcase-region $p1 (+ $p1 1))) (t (message "Word does not start with a alphabetic character")))))) #+end_src *** Tetris #+begin_src emacs-lisp :tangle yes (add-hook 'tetris-mode-hook #'turn-off-evil-mode) #+end_src ** Company #+begin_src emacs-lisp :tangle yes ;; Add company-quickhelp ;; Now already included ;; (company-quickhelp-mode) ;; (map! :map company-active-map "TAB" nil) ;; (map! :map company-active-map "" nil) #+end_src ** Projectile #+begin_src emacs-lisp :tangle yes (map! :map 'doom-leader-project-map :desc "Repeat last command" "SPC" #'projectile-repeat-last-command) #+end_src ** More #+begin_src emacs-lisp :tangle yes (defun fd-pretty-print-dirty-json() (interactive) (let ((new-buffer-contents (shell-command-to-string (format "echo '%s' | newliner" (buffer-string))))) (erase-buffer) (insert new-buffer-contents) (evil-indent (buffer-end -1) (buffer-end +1))) ) ;; (autoload 'matlab-mode "matlab" "Matlab Editing Mode" t) ;; (add-to-list ;; 'auto-mode-alist ;; '("\\.m$" . matlab-mode)) ;; (setq matlab-indent-function t) ;; (setq matlab-shell-command "matlab") #+end_src ** Python #+begin_src emacs-lisp :tangle yes ;; Python settings ;; (add-hook 'python-mode-hook (lambda () ;; (setq flycheck-checker 'python-pylint))) ;; (add-hook 'pyhon-mode-local-vars-hook ;; (lambda () ;; (when (flycheck-may-enable-checker 'lsp) ;; (flycheck-select-checker 'python-pylint)))) (defun fd-python-to-latex(regionBegin regionEnd) (interactive (if (use-region-p) (list (region-beginning) (region-end)) (list (point-min) (point-max)))) (shell-command-on-region regionBegin regionEnd "python2latex")) #+end_src ** Haskell #+begin_src emacs-lisp :tangle yes (set-docsets! 'haskell-mode "Haskell") #+end_src ** Rss #+begin_src emacs-lisp :tangle yes (setq elfeed-feeds '(("https://heise.de/rss/heise-atom.xml" tech) ("https://blog.fefe.de/rss.xml?html" news) ("https://itsfoss.com/feed" news)) ) #+end_src ** Citations #+begin_src emacs-lisp :tangle yes (setq! citar-bibliography '("~/Nextcloud/jhome/studium/vorlesungen/WS22/raumfahrtsysteme-und-anwendungen/bericht/Quellen/DART-Hera.bib")) #+end_src