From da18e189eba2b5d2451649dcd0b158aab97197ea Mon Sep 17 00:00:00 2001 From: Marc Pohling Date: Sat, 5 May 2018 19:46:16 +0200 Subject: [PATCH] More structural changes, looks less messy now. --- config.org | 1137 +++++++++++++++++++++++++--------------------------- 1 file changed, 550 insertions(+), 587 deletions(-) diff --git a/config.org b/config.org index 9974b6e..494f735 100644 --- a/config.org +++ b/config.org @@ -2,11 +2,11 @@ #+AUTHOR: Marc Pohling * Personal Information - -#+begin_src emacs-lisp + + #+begin_src emacs-lisp (setq user-full-name "Marc Pohling" user-mail-address "marc.pohling@googlemail.com") -#+end_src + #+end_src * Stuff to add / to fix - smartparens @@ -21,65 +21,80 @@ add hooks for certain file extensions, maybe add a smart way to start gfm-mode if markdown-file is in a git-project - move package dependend configurations inside the package configuration itself, like keymaps for magit - * Update config in a running config -Two options: + Two options: - reload the open file: M-x load-file, then press twice to accept the default filename, which is the currently opened - Point at the end of any sexp and press C-x C-e - - * Customize default settings + Keep the .emacs.d clean by moving user files into separate directories. + - user-local: directory for machine specific files + - user-global: directory for files which work on any machine + - the backup and auto-save files go right to /tmp -Keep the .emacs.d clean by moving user files into separate directories. -- user-local: directory for machine specific files -- user-global: directory for files which work on any machine -- the backup and auto-save files go right to /tmp - -#+BEGIN_SRC emacs-lisp -(defvar PATH_USER_LOCAL (expand-file-name "~/.emacs.d/user-local/")) -(defvar PATH_USER_GLOBAL (expand-file-name "~/.emacs.d/user-global/")) -(setq bookmark-default-file (concat PATH_USER_LOCAL "bookmarks")) -(setq recentf-save-file (concat PATH_USER_LOCAL "recentf")) -(setq custom-file (concat PATH_USER_LOCAL "custom.el")) ;don't spam init.el with saved customize settings -(setq abbrev-file-name (concat PATH_USER_GLOBAL "abbrev_defs")) -(setq backup-directory-alist `((".*" . ,temporary-file-directory))) -(setq auto-save-file-name-transforms `((".*" ,temporary-file-directory))) - -(setq save-abbrevs 'silently) ; don't bother me with asking if new abbrevs should be saved -#+END_SRC - -These functions are useful. Activate them. -#+begin_src emacs-lisp - (put 'downcase-region 'disabled nil) - (put 'upcase-region 'disabled nil) - (put 'narrow-to-region 'disabled nil) - (put 'dired-find-alternate-file 'disabled nil) -#+end_src + #+BEGIN_SRC emacs-lisp + (defvar PATH_USER_LOCAL (expand-file-name "~/.emacs.d/user-local/")) + (defvar PATH_USER_GLOBAL (expand-file-name "~/.emacs.d/user-global/")) + (setq bookmark-default-file (concat PATH_USER_LOCAL "bookmarks")) + (setq recentf-save-file (concat PATH_USER_LOCAL "recentf")) + (setq custom-file (concat PATH_USER_LOCAL "custom.el")) ;don't spam init.el with saved customize settings + (setq abbrev-file-name (concat PATH_USER_GLOBAL "abbrev_defs")) + (setq backup-directory-alist `((".*" . ,temporary-file-directory))) + (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory))) + + (setq save-abbrevs 'silently) ; don't bother me with asking if new abbrevs should be saved + #+END_SRC -Answering just 'y' or 'n' should be enough. -#+begin_src emacs-lisp - (defalias 'yes-or-no-p 'y-or-n-p) -#+end_src + These functions are useful. Activate them. + #+begin_src emacs-lisp + (put 'downcase-region 'disabled nil) + (put 'upcase-region 'disabled nil) + (put 'narrow-to-region 'disabled nil) + (put 'dired-find-alternate-file 'disabled nil) + #+end_src -Don't count two spaces after a period as the end of a sentence. -Just one space is needed -#+begin_src emacs-lisp - (setq sentence-end-double-space nil) -#+end_src + Answering just 'y' or 'n' should be enough. + #+begin_src emacs-lisp + (defalias 'yes-or-no-p 'y-or-n-p) + #+end_src -Delete the region when typing, just like as we expect nowadays. -#+begin_src emacs-lisp - (delete-selection-mode t) -#+end_src + Don't count two spaces after a period as the end of a sentence. + Just one space is needed + #+begin_src emacs-lisp + (setq sentence-end-double-space nil) + #+end_src -Auto-indent when pressing RET, just new-line when C-j -#+begin_src emacs-lisp - (define-key global-map (kbd "RET") 'newline-and-indent) - (define-key global-map (kbd "C-j") 'newline) + Delete the region when typing, just like as we expect nowadays. + #+begin_src emacs-lisp + (delete-selection-mode t) + #+end_src -#+end_src + Auto-indent when pressing RET, just new-line when C-j + #+begin_src emacs-lisp + (define-key global-map (kbd "RET") 'newline-and-indent) + (define-key global-map (kbd "C-j") 'newline) + #+end_src + Set the default window size depending on the system emacs is running on. + ;; TODO: + ;; This size is only reasonable for linux@home + ;; hyperv is way smaller, use fullscreen here + ;; pm should be fullscreen, too + + #+BEGIN_SRC emacs-lisp + (if (display-graphic-p) + (progn + (setq initial-frame-alist + '( + (width . 165) + (height . 70))) + (setq default-frame-alist + '( + (width . 165) + (height . 70)))) + ) + #+END_SRC + * Visuals ** Theme *** Font @@ -165,6 +180,13 @@ Auto-indent when pressing RET, just new-line when C-j (sml/setup)) #+END_SRC +** Line numbers + #+BEGIN_SRC emacs-lisp + (use-package linum + :ensure t + :init + (add-hook 'prog-mode-hook 'linum-mode)) + #+END_SRC ** Misc UTF-8 please @@ -204,191 +226,243 @@ Smooth scrolling. Emacs tends to be jumpy, this should change it. scroll-step 1) #+END_SRC -* Usability - Activate and configure recentf +* Usability +** which-key + Greatly increases discovery of functions! + Click [[https://github.com/justbur/emacs-which-key][here]] for source and more info. + Info in Emacs: M-x customize-group which-key - #+BEGIN_SRC emacs-lisp - (recentf-mode t) - (setq recentf-max-saved-items 200) - #+END_SRC -** Hydra - Hydra allows grouping of commands + #+begin_src emacs-lisp + (use-package which-key + :ensure t + :diminish which-key-mode + :config + (which-key-mode) + (which-key-setup-side-window-right-bottom) + (which-key-setup-minibuffer) + (setq which-key-idle-delay 0.5) + ) + #+end_src +** Recentf + Activate and configure recentf - #+begin_src emacs-lisp - (use-package hydra - :ensure t - :bind - ("C-c f" . hydra-flycheck/body) - ("C-c g" . hydra-git-gutter/body) - :config - (setq-default hydra-default-hint nil) - ) - #+end_src + #+BEGIN_SRC emacs-lisp + (recentf-mode t) + (setq recentf-max-saved-items 200) + #+END_SRC +** Hydra + Hydra allows grouping of commands + #+begin_src emacs-lisp + (use-package hydra + :ensure t + :bind + ("C-c f" . hydra-flycheck/body) + ("C-c g" . hydra-git-gutter/body) + :config + (setq-default hydra-default-hint nil) + ) + #+end_src ** Evil So... Evil Mode might be worth a try #+BEGIN_SRC emacs-lisp -(use-package evil - :ensure t - :defer .1 ;; don't block emacs when starting, load evil immediately after startup - :init - (setq evil-want-integration nil) ;; required by evil-collection - :config - (evil-mode 1)) ;; for now deactivate per default + (use-package evil + :ensure t + :defer .1 ;; don't block emacs when starting, load evil immediately after startup + :init + (setq evil-want-integration nil) ;; required by evil-collection + :config + (evil-mode 1)) ;; for now deactivate per default #+END_SRC Evil-collection is a bundle of configs for different modes. 2018-05-01: evil collection causes error "Invalid function: with-helm-buffer" #+BEGIN_SRC emacs-lisp -;(use-package evil-collection -; :after evil -; :ensure t -; :config -; (evil-collection-init)) + ;(use-package evil-collection + ; :after evil + ; :ensure t + ; :config + ; (evil-collection-init)) #+END_SRC Evil-goggles give visual hints when editing texts, so it's more obvious what is actually happening. [[https://github.com/edkolev/evil-goggles][Source]] #+BEGIN_SRC emacs-lisp -(use-package evil-goggles - :after evil - :ensure t - :config - (evil-goggles-mode) - (evil-goggles-use-diff-faces)) + (use-package evil-goggles + :after evil + :ensure t + :config + (evil-goggles-mode) + (evil-goggles-use-diff-faces)) #+END_SRC - -** List buffers - Ibuffer is the improved version of list-buffers. - Make ibuffer the default buffer lister. [[http://ergoemacs.org/emacs/emacs_buffer_management.html][Source]] - #+begin_src emacs-lisp - (defalias 'list-buffers 'ibuffer) - #+end_src +** General (keymapper) + I just use general.el to define keys and keymaps. With it I can set leader keys and create keymaps for them. It also integrates well with which-key. - Also auto refresh dired, but be quiet about it. [[http://whattheemacsd.com/sane-defaults.el-01.html][Source]] - #+begin_src emacs-lisp - (add-hook 'dired-mode-hook 'auto-revert-mode) - (setq global-auto-revert-non-file-buffers t) - (setq auto-revert-verbose nil) - #+end_src -** ivy / counsel / swiper + #+BEGIN_SRC emacs-lisp + (use-package general + :ensure t + ) + #+END_SRC +** Custom key mappings + Now some keymaps. + If there is no map defined, it is considered the global key map. - Flx is required for fuzzy-matching - Is it really necessary? - begin_src emacs-lisp - (use-package flx) - end_src + #+BEGIN_SRC emacs-lisp + (general-define-key + :states '(normal visual insert emacs) + :prefix "SPC" + :non-normal-prefix "M-SPC" + "TAB" '(ivy-switch-buffer :which-key "prev buffer") + "SPC" '(counsel-M-x :which-key "M-x")) + #+END_SRC - Ivy displays a window with suggestions for hotkeys and M-x + A map for org-mode + + #+BEGIN_SRC emacs-lisp + (general-define-key + :states '(normal visual insert emacs) + :keymaps 'org-mode-map + :prefix "SPC" + :non-normal-prefix "M-SPC" + "t" '(counsel-org-tag :which-key "org-tag")) + #+END_SRC + +** List buffers + Ibuffer is the improved version of list-buffers. + Make ibuffer the default buffer lister. [[http://ergoemacs.org/emacs/emacs_buffer_management.html][Source]] + #+begin_src emacs-lisp + (defalias 'list-buffers 'ibuffer) + #+end_src - #+begin_src emacs-lisp - (use-package ivy - :ensure t - :diminish - (ivy-mode . "") ;; does not display ivy in the mode line - :init - (ivy-mode 1) - :bind - ("C-c C-r" . ivy-resume) - :config - (setq ivy-use-virtual-buffers t) ;; recent files and bookmarks in ivy-switch-buffer - (setq ivy-height 20) ;; height of ivy window - (setq ivy-count-format "%d/%d") ;; current and total number - (setq ivy-re-builders-alist ;; regex replaces spaces with * - '((t . ivy--regex-plus))) - ) - #+end_src + Also auto refresh dired, but be quiet about it. [[http://whattheemacsd.com/sane-defaults.el-01.html][Source]] + #+begin_src emacs-lisp + (add-hook 'dired-mode-hook 'auto-revert-mode) + (setq global-auto-revert-non-file-buffers t) + (setq auto-revert-verbose nil) + #+end_src +** ivy / counsel / swiper + Flx is required for fuzzy-matching + Is it really necessary? + begin_src emacs-lisp + (use-package flx) + end_src - The find-file replacement is nicer to navigate + Ivy displays a window with suggestions for hotkeys and M-x - #+begin_src emacs-lisp - (use-package counsel - :ensure t - :bind* ;; load counsel when pressed - (("M-x" . counsel-M-x) - ("C-x C-f" . counsel-find-file) - ("C-x C-r" . counsel-recentf) - ("C-c C-f" . counsel-git) - ("C-c h f" . counsel-describe-function) - ("C-c h v" . counsel-describe-variable) - ("M-i" . counsel-imenu) - ) - ) - #+end_src + #+begin_src emacs-lisp + (use-package ivy + :ensure t + :diminish + (ivy-mode . "") ;; does not display ivy in the mode line + :init + (ivy-mode 1) + :bind + ("C-c C-r" . ivy-resume) + :config + (setq ivy-use-virtual-buffers t) ;; recent files and bookmarks in ivy-switch-buffer + (setq ivy-height 20) ;; height of ivy window + (setq ivy-count-format "%d/%d") ;; current and total number + (setq ivy-re-builders-alist ;; regex replaces spaces with * + '((t . ivy--regex-plus))) + ) + #+end_src - Swiper ivy-enhances isearch + The find-file replacement is nicer to navigate - #+begin_src emacs-lisp - (use-package swiper - :ensure t - :bind - (("C-s" . swiper) - ("C-c C-r" . ivy-resume) - ) - ) - #+end_src + #+begin_src emacs-lisp + (use-package counsel + :ensure t + :bind* ;; load counsel when pressed + (("M-x" . counsel-M-x) + ("C-x C-f" . counsel-find-file) + ("C-x C-r" . counsel-recentf) + ("C-c C-f" . counsel-git) + ("C-c h f" . counsel-describe-function) + ("C-c h v" . counsel-describe-variable) + ("M-i" . counsel-imenu) + ) + ) + #+end_src - Ivy-Hydra adds stuff in minibuffer when you press C-o + Swiper ivy-enhances isearch - #+BEGIN_SRC emacs-lisp -(use-package ivy-hydra - :ensure t) - #+END_SRC + #+begin_src emacs-lisp + (use-package swiper + :ensure t + :bind + (("C-s" . swiper) + ("C-c C-r" . ivy-resume) + ) + ) + #+end_src + Ivy-Hydra adds stuff in minibuffer when you press C-o + #+BEGIN_SRC emacs-lisp + (use-package ivy-hydra + :ensure t) + #+END_SRC -** which-key - Greatly increases discovery of functions! - Click [[https://github.com/justbur/emacs-which-key][here]] for source and more info. - Info in Emacs: M-x customize-group which-key +** Helm + This is just a try to see how it works differently. - #+begin_src emacs-lisp - (use-package which-key + #+BEGIN_SRC emacs-lisp + (use-package helm :ensure t - :diminish which-key-mode + :init + (helm-mode 1) + :bind + ; (("M-x" . helm-M-x) + ; ("C-x C-f" . helm-find-files) + ; ("C-x C-r" . helm-recentf) + ; ("C-x b" . helm-buffers-list)) :config - (which-key-mode) - (which-key-setup-side-window-right-bottom) - (which-key-setup-minibuffer) - (setq which-key-idle-delay 0.5) - ) - #+end_src + (setq helm-buffers-fuzzy-matching t) + ) + (use-package helm-descbinds + :ensure t + :bind + ("C-h b" . helm-descbinds)) + + (use-package helm-projectile + :ensure t + :config + (helm-projectile-on)) + #+END_SRC ** Undo Show an undo tree in a new buffer which can be navigated. #+BEGIN_SRC emacs-lisp -(use-package undo-tree - :ensure t - :diminish undo-tree-mode - :init - (undo-tree-mode)) + (use-package undo-tree + :ensure t + :diminish undo-tree-mode + :init + (undo-tree-mode)) #+END_SRC ** Ido (currently inactive) - better completion - - begin_src emacs-lisp - (use-package ido - :init - (setq ido-enable-flex-matching t) - (setq ido-everywhere t) - (ido-mode t) - (use-package ido-vertical-mode - :ensure t - :defer t - :init - (ido-vertical-mode 1) - (setq ido-vertical-define-keys 'C-n-and-C-p-only) - ) - ) - end_src - + better completion + #+begin_src emacs-lisp + ;(use-package ido + ; :init + ; (setq ido-enable-flex-matching t) + ; (setq ido-everywhere t) + ; (ido-mode t) + ; (use-package ido-vertical-mode + ; :ensure t + ; :defer t + ; :init + ; (ido-vertical-mode 1) + ; (setq ido-vertical-define-keys 'C-n-and-C-p-only) + ; ) + ;) + #+end_src ** Treemacs A file manager comparable to neotree. @@ -462,7 +536,6 @@ Smooth scrolling. Emacs tends to be jumpy, this should change it. - treemacs-bookmark - treemacs-find-file - treemacs-find-tag - ** Window Handling Some tools to easen the navigation, creation and deletion of windows @@ -491,43 +564,26 @@ Smooth scrolling. Emacs tends to be jumpy, this should change it. ) #+end_src - - -* Pandoc - Convert between formats, like from org to html. - Pandoc needs to be installed on the system - #+BEGIN_SRC shell -sudo apt install pandoc - #+END_SRC - - Pandoc-mode is a minor mode to interact with pandoc - #+BEGIN_SRC emacs-lisp -(use-package pandoc-mode - :ensure t - :init - (add-hook 'markdown-mode-hook 'pandoc-mode)) - #+END_SRC - * Org Mode ** Installation -Although org mode ships with Emacs, the latest version can be installed externally. The configuration here follows the [[http://orgmode.org/elpa.html][Org mode ELPA Installation instructions.]] -Added a hook to complete org functions, company-capf is necessary for this + Although org mode ships with Emacs, the latest version can be installed externally. The configuration here follows the [[http://orgmode.org/elpa.html][Org mode ELPA Installation instructions.]] + Added a hook to complete org functions, company-capf is necessary for this -#+begin_src emacs-lisp - (use-package org - :ensure org-plus-contrib - :init - (add-hook 'org-mode-hook 'company/org-mode-hook) - ) -#+end_src + #+begin_src emacs-lisp + (use-package org + :ensure org-plus-contrib + :init + (add-hook 'org-mode-hook 'company/org-mode-hook) + ) + #+end_src -To avoid problems executing source blocks out of the box. [[https://emacs.stackexchange.com/a/28604][Others have the same problem, too]]. The solution is to remove the .elc files form the package directory: + To avoid problems executing source blocks out of the box. [[https://emacs.stackexchange.com/a/28604][Others have the same problem, too]]. The solution is to remove the .elc files form the package directory: -#+begin_src sh: - var ORG_DIR=(let* ((org-v (cadr (split-string (org-version nil t) "@"))) (len (length org-v))) (substring org-v 1 (- len 2))) - rm ${ORG_DIR}/*.elc -#+end_src + #+begin_src shell + var ORG_DIR=(let* ((org-v (cadr (split-string (org-version nil t) "@"))) (len (length org-v))) (substring org-v 1 (- len 2))) + rm ${ORG_DIR}/*.elc + #+end_src *** Org key bindings Set up some global key bindings that integrate with Org mode features @@ -563,172 +619,168 @@ For a more detailed example [[https://github.com/sachac/.emacs.d/blob/83d21e4733 #+end_src ** Org Setup -Speed commands are a nice and quick way to perform certain actions while at the beginning of a heading. It's not activated by default. - -See the doc for speed keys by checking out the documentation for speed keys in Org mode. - -#+begin_src emacs-lisp - (setq org-use-speed-commands t) - (setq org-image-actual-width 550) - (setq org-highlight-latex-and-related '(latex script entities)) -#+end_src - -Hide emphasis markup (e.g. / ... / for italics, etc.) + Speed commands are a nice and quick way to perform certain actions while at the beginning of a heading. It's not activated by default. -#+begin_src emacs-lisp -(setq org-hide-emphasis-markers t) -#+end_src + See the doc for speed keys by checking out the documentation for speed keys in Org mode. + #+begin_src emacs-lisp + (setq org-use-speed-commands t) + (setq org-image-actual-width 550) + (setq org-highlight-latex-and-related '(latex script entities)) + #+end_src -Setting some environment paths + Hide emphasis markup (e.g. / ... / for italics, etc.) -#+begin_src emacs-lisp - (if (string-equal user-login-name "POH") - (progn - (defvar PATH_ORG_FILES "p:/Eigene Dateien/Notizen/") - (defvar PATH_ORG_JOURNAL "p:/Eigene Dateien/Notizen/Journal/") - (defvar PATH_START "p:/Eigene Dateien/Notizen/")) - ) -#+end_src + #+begin_src emacs-lisp + (setq org-hide-emphasis-markers t) + #+end_src + Setting some environment paths + #+begin_src emacs-lisp + (if (string-equal user-login-name "POH") + (progn + (defvar PATH_ORG_FILES "p:/Eigene Dateien/Notizen/") + (defvar PATH_ORG_JOURNAL "p:/Eigene Dateien/Notizen/Journal/") + (defvar PATH_START "p:/Eigene Dateien/Notizen/")) + ) + #+end_src -Sort org agenda by deadline and priority + Sort org agenda by deadline and priority -#+begin_src emacs-lisp - (setq org-agenda-sorting-strategy - (quote - ((agenda deadline-up priority-down) - (todo priority-down category-keep) - (tags priority-down category-keep) - (search category-keep))) - ) -#+end_src + #+begin_src emacs-lisp + (setq org-agenda-sorting-strategy + (quote + ((agenda deadline-up priority-down) + (todo priority-down category-keep) + (tags priority-down category-keep) + (search category-keep))) + ) + #+end_src -Custom todo-keywords, depending on environment + Custom todo-keywords, depending on environment -#+begin_src emacs-lisp - (if (string-equal user-login-name "POH") - (setq org-todo-keywords - '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE"))) - ) -#+end_src + #+begin_src emacs-lisp + (if (string-equal user-login-name "POH") + (setq org-todo-keywords + '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE"))) + ) + #+end_src -Set locations of some org files + Set locations of some org files -#+begin_src emacs-lisp - (if (string-equal user-login-name "POH") - (progn - (setq org-default-notes-file (concat PATH_ORG_FILES "notes.org")) - (setq org-agenda-files (list(concat PATH_ORG_FILES "notes.org") - (concat PATH_ORG_FILES "projects.org") - (concat PATH_ORG_FILES "todo.org")))) - ) -(setq org-id-locations-file (concat PATH_USER_LOCAL ".org-id-locations")) -#+end_src + #+begin_src emacs-lisp + (if (string-equal user-login-name "POH") + (progn + (setq org-default-notes-file (concat PATH_ORG_FILES "notes.org")) + (setq org-agenda-files (list(concat PATH_ORG_FILES "notes.org") + (concat PATH_ORG_FILES "projects.org") + (concat PATH_ORG_FILES "todo.org")))) + ) + (setq org-id-locations-file (concat PATH_USER_LOCAL ".org-id-locations")) + #+end_src -Work specific org-capture-templates + Work specific org-capture-templates -#+begin_src emacs-lisp - (if (string-equal user-login-name "POH") - (setq org-capture-templates - '(("t" "todo" entry (file (concat PATH_ORG_FILES "todo.org")) - "** TODO %\\n%u\n%a\n") - ("n" "note" entry (file org-default-notes-file)) - ("p" "project" entry (file (concat PATH_ORG_FILES "projects.org")) - "** OPEN %?\n%u\n** Beschreibung\n** Zu erledigen\n*** \n** Verlauf\n***" :clock-in t :clock-resume t) - ("u" "Unterbrechung" entry (file org-default-notes-file) - "* Unterbrechnung durch %? :Unterbrechung:\n%t" :clock-in t :clock-resume t))) - ) -#+end_src + #+begin_src emacs-lisp + (if (string-equal user-login-name "POH") + (setq org-capture-templates + '(("t" "todo" entry (file (concat PATH_ORG_FILES "todo.org")) + "** TODO %\\n%u\n%a\n") + ("n" "note" entry (file org-default-notes-file)) + ("p" "project" entry (file (concat PATH_ORG_FILES "projects.org")) + "** OPEN %?\n%u\n** Beschreibung\n** Zu erledigen\n*** \n** Verlauf\n***" :clock-in t :clock-resume t) + ("u" "Unterbrechung" entry (file org-default-notes-file) + "* Unterbrechnung durch %? :Unterbrechung:\n%t" :clock-in t :clock-resume t))) + ) + #+end_src -Customize the org agenda + Customize the org agenda -#+begin_src emacs-lisp - (defun my-org-skip-subtree-if-priority (priority) - "Skip an agenda subtree if it has a priority of PRIORITY. - - PRIORITY may be one of the characters ?A, ?B, or ?C." - (let ((subtree-end (save-excursion (org-end-of-subtree t))) - (pri-value (* 1000 (- org-lowest-priority priority))) - (pri-current (org-get-priority (thing-at-point 'line t)))) - (if (= pri-value pri-current) - subtree-end - nil))) - - (setq org-agenda-custom-commands - '(("c" "Simple agenda view" - ((tags "PRIORITY=\"A\"" - ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done)) - (org-agenda-overriding-header "Hohe Priorität:"))) - (agenda "" - ((org-agenda-span 7) - (org-agenda-start-on-weekday nil) - (org-agenda-overriding-header "Nächsten 7 Tage:"))) - (alltodo "" - ((org-agenda-skip-function '(or (my-org-skip-subtree-if-priority ?A) - (org-agenda-skip-if nil '(scheduled deadline)))) - (org-agenda-overriding-header "Sonstige Aufgaben:")))))) - ) -#+end_src + #+begin_src emacs-lisp + (defun my-org-skip-subtree-if-priority (priority) + "Skip an agenda subtree if it has a priority of PRIORITY. + + PRIORITY may be one of the characters ?A, ?B, or ?C." + (let ((subtree-end (save-excursion (org-end-of-subtree t))) + (pri-value (* 1000 (- org-lowest-priority priority))) + (pri-current (org-get-priority (thing-at-point 'line t)))) + (if (= pri-value pri-current) + subtree-end + nil))) + + (setq org-agenda-custom-commands + '(("c" "Simple agenda view" + ((tags "PRIORITY=\"A\"" + ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done)) + (org-agenda-overriding-header "Hohe Priorität:"))) + (agenda "" + ((org-agenda-span 7) + (org-agenda-start-on-weekday nil) + (org-agenda-overriding-header "Nächsten 7 Tage:"))) + (alltodo "" + ((org-agenda-skip-function '(or (my-org-skip-subtree-if-priority ?A) + (org-agenda-skip-if nil '(scheduled deadline)))) + (org-agenda-overriding-header "Sonstige Aufgaben:")))))) + ) + #+end_src ** Org tags -The default value is -77, which is weird for smaller width windows. I'd rather have the tags align horizontally with the header. -45 is a good column number to do that. + The default value is -77, which is weird for smaller width windows. I'd rather have the tags align horizontally with the header. + 45 is a good column number to do that. -#+begin_src emacs-lisp - (setq org-tags-column 45) -#+end_src + #+begin_src emacs-lisp + (setq org-tags-column 45) + #+end_src ** Org babel languages + This code block is linux specific. Loading languages which aren't available seems to be a problem + #+begin_src emacs-lisp + (cond ((eq system-type 'gnu/linux) + (org-babel-do-load-languages + 'org-babel-load-languages + '( + (C . t) + (calc . t) + (java . t) + (js . t) + (latex . t) + (ledger . t) + (beancount . t) + (lisp . t) + (python . t) + (R . t) + (ruby . t) + (scheme . t) + (shell . t) + (sqlite . t) + ) + )) + ) + #+end_src -This code block is linux specific. Loading languages which aren't available seems to be a problem -#+begin_src emacs-lisp - (cond ((eq system-type 'gnu/linux) - (org-babel-do-load-languages - 'org-babel-load-languages - '( - (C . t) - (calc . t) - (java . t) - (js . t) - (latex . t) - (ledger . t) - (beancount . t) - (lisp . t) - (python . t) - (R . t) - (ruby . t) - (scheme . t) - (shell . t) - (sqlite . t) - ) - )) - ) -#+end_src - -#+begin_src emacs-lisp - (defun my-org-confirm-babel-evaluate (lang body) - "Do not confirm evaluation for these languages." - (not (or (string= lang "beancount") - (string= lang "C") - (string= lang "emacs-lisp") - (string= lang "java") - (string= lang "ledger") - (string= lang "python") - (string= lang "R") - (string= lang "sqlite")))) - (setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate) -#+end_src + #+begin_src emacs-lisp + (defun my-org-confirm-babel-evaluate (lang body) + "Do not confirm evaluation for these languages." + (not (or (string= lang "beancount") + (string= lang "C") + (string= lang "emacs-lisp") + (string= lang "java") + (string= lang "ledger") + (string= lang "python") + (string= lang "R") + (string= lang "sqlite")))) + (setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate) + #+end_src -I want plots! -#+begin_src emacs-lisp - (use-package ess - :ensure t - ) -(add-hook 'org-babel-after-execute-hook 'org-display-inline-images) -(add-hook 'org-mode-hook 'org-display-inline-images) -#+end_src + I want plots! + #+begin_src emacs-lisp + (use-package ess + :ensure t + ) + (add-hook 'org-babel-after-execute-hook 'org-display-inline-images) + (add-hook 'org-mode-hook 'org-display-inline-images) + #+end_src ** Org babel/source blocks I like to have source blocks properly syntax highlighted and with the editing popup window staying within the same window so all the windows don't jump around. Also, having the top and bottom trailing lines in the block is a waste of space, so we can remove them @@ -746,91 +798,22 @@ I want plots! - -* Helm - I placed it after ivy to override any configuration made by the former. - This is just a try to see how it works differently. - - #+BEGIN_SRC emacs-lisp -(use-package helm - :ensure t - :init - (helm-mode 1) - :bind -; (("M-x" . helm-M-x) -; ("C-x C-f" . helm-find-files) -; ("C-x C-r" . helm-recentf) -; ("C-x b" . helm-buffers-list)) - :config - (setq helm-buffers-fuzzy-matching t) -) - -(use-package helm-descbinds - :ensure t - :bind - ("C-h b" . helm-descbinds)) - -(use-package helm-projectile - :ensure t - :config - (helm-projectile-on)) - #+END_SRC - -* Latex - Requirements for Linux: - - Latex - - pdf-tools - - #+begin_src emacs-lisp - (unless (string-equal user-login-name "POH") - (use-package pdf-tools - :ensure t - :config - (pdf-tools-install) - (setq TeX-view-program-selection '((output-pdf "pdf-tools"))) - (setq TeX-view-program-list '(("pdf-tools" "Tex-pdf-tools-sync-view"))) - ) - ) - #+end_src - - For latex-preview-pane a patch might be necessary (as of 2017-10), see the issue [[https://github.com/jsinglet/latex-preview-pane/issues/37][here]] - Update 2018-03: It seems to work without this patch. I will keep it here in case something breaks again. - #+begin_src - latex-preview-pane-update-p() - --- (doc-view-revert-buffer nil t) - +++ (revert-buffer-nil t 'preserve-modes) - #+end_src - After that M-x byte-compile-file - - #+begin_src emacs-lisp - (use-package latex-preview-pane - :ensure t - ) - (setq auto-mode-alist - (append '(("\\.tex$" . latex-mode)) auto-mode-alist)) - ;; one of these works - (add-hook 'LaTeX-mode-hook 'latex-preview-pane-mode) - (add-hook 'latex-mode-hook 'latex-preview-pane-mode) - - ;; necessary, because linum-mode isn't compatible and prints errors - (add-hook 'pdf-view-mode-hook (lambda () (linum-mode -1))) - #+end_src - - -* Markdown - Major mode to edit markdown files. - For previews it needs markdown installed on the system. - For debian: + +* Pandoc + Convert between formats, like from org to html. + Pandoc needs to be installed on the system #+BEGIN_SRC shell -sudo apt install markdown +sudo apt install pandoc #+END_SRC + Pandoc-mode is a minor mode to interact with pandoc #+BEGIN_SRC emacs-lisp -(use-package markdown-mode - :ensure t) +(use-package pandoc-mode + :ensure t + :init + (add-hook 'markdown-mode-hook 'pandoc-mode)) #+END_SRC - * Emails Currently following tools are required: - notmuch (edit, read, tag, delete emails) @@ -854,74 +837,54 @@ sudo apt install markdown ) #+end_src - * Personal Finances - I picked ledger for my personal accounting and will test if it's beneficial over gnucash. - ..and don't activate the modules at work. - - #+begin_src emacs-lisp -(unless (string-equal user-login-name "POH") - (use-package ledger-mode - :ensure t - :mode ("\\.ledger$" . ledger-mode) - :init - (setq clear-whole-transactions t) - ) -) - #+end_src - - Ok, maybe beancount is better. + After trying ledger, I chose beancount. It is closer to real bookkeeping and has stricter rules. Since there is no debian package, it is an option to install it via pip. I picked /opt for the installation path #+begin_src shell -sudo su -cd /opt -python3 -m venv beancount -source ./beancount/bin/activate -pip3 install wheel -pip3 install beancount -deactivate + sudo su + cd /opt + python3 -m venv beancount + source ./beancount/bin/activate + pip3 install wheel + pip3 install beancount + deactivate #+end_src When using beancount, it will automatically pick the created virtual environment. - Activate the beancount mode + Activate the beancount mode. ATTENTION: This mode is made by myself. #+begin_src emacs-lisp -(unless (string-equal user-login-name "POH") -;; (add-to-list 'package-archives -;; '("beancount" . "/opt/beancount/elisp") t) -; (use-package beancount -; :load-path "/opt/beancount/elisp/" -;; :ensure t -; :mode ("\\.beancount$" . beancount-mode) - (load "/home/marc/.emacs.d/user-local/elisp/beancount-mode.el") ; somehow load-path in use-package doesn't work - (use-package beancount - :load-path "/home/marc/.emacs.d/elisp" - :mode ("\\.beancount$" . beancount-mode) - :init - (add-hook 'beancount-mode-hook 'company/beancount-mode-hook) - (setenv "PATH" - (concat - "/opt/beancount/bin:" - (getenv "PATH")) - ) - :config - (setq beancount-filename-main "/home/marc/Archiv/Finanzen/transactions.beancount") + (unless (string-equal user-login-name "POH") + (load "/home/marc/.emacs.d/user-local/elisp/beancount-mode.el") ; somehow load-path in use-package doesn't work + (use-package beancount + :load-path "/home/marc/.emacs.d/elisp" + :mode ("\\.beancount$" . beancount-mode) + :init + (add-hook 'beancount-mode-hook 'company/beancount-mode-hook) + (setenv "PATH" + (concat + "/opt/beancount/bin:" + (getenv "PATH")) + ) + :config + (setq beancount-filename-main "/home/marc/Archiv/Finanzen/transactions.beancount") + ) ) -) #+end_src - For a nice frontend fava seems nice + Installing fava for reports is strongly recommended. + #+begin_src shell -sudo su -cd /opt -python3 -m venv vava -source ./vava/bin/activate -pip3 install wheel -pip3 install fava -deactivate + sudo su + cd /opt + python3 -m venv vava + source ./vava/bin/activate + pip3 install wheel + pip3 install fava + deactivate #+end_src Start fava with @@ -930,8 +893,8 @@ deactivate #+end_src It is accessable on this URL: [[http://127.0.0.1:5000][Fava]] + Beancount-mode can start fava and open the URL right away. - * Programming ** Common things List of plugins and settings which are shared between the language plugins @@ -1199,6 +1162,21 @@ For the popups the package pos-tip.el is used and automatically installed. Maybe add [[https://github.com/hlissner/emacs-company-dict][company-dict]]? It's a dictionary based on major modes, plus it has Yasnippet integration. +** Flycheck + Show errors right away! + #+begin_src emacs-lisp + (use-package flycheck + :ensure t + :diminish flycheck-mode " ✓" + :init + (setq flycheck-emacs-lisp-load-path 'inherit) + (add-hook 'after-init-hook #'global-flycheck-mode) +; (add-hook 'python-mode-hook (lambda () +; (semantic-mode 1) +; (flycheck-select-checker 'python-pylint))) + ) +#+end_src + ** Projectile Brings search functions on project level @@ -1253,45 +1231,34 @@ Add some helpers to handle and understand macros #+end_src ** Python + Systemwide following packages need to be installed: + - venv -Systemwide following packages need to be installed: -- venv + The virtual environments need to have following modules installed: + - jedi + - epc + - pylint -The virtual environments need to have following modules installed: -- jedi -- epc -- pylint + Automatically start python-mode when opening a .py-file. + Not sure if python.el is better than python-mode.el. + See [[https://github.com/jorgenschaefer/elpy/issues/887][here]] for info about ~python-shell-completion-native-enable~. + The custom function is to run inferiour processes (do I really need that?), see [[https://emacs.stackexchange.com/questions/16361/how-to-automatically-run-inferior-process-when-loading-major-mode][here]]. -#+begin_src emacs-lisp - (use-package flycheck - :ensure t - :diminish flycheck-mode " ✓" - :init - (setq flycheck-emacs-lisp-load-path 'inherit) - (add-hook 'after-init-hook #'global-flycheck-mode) - (add-hook 'python-mode-hook (lambda () - (semantic-mode 1) + Also limit the completion backends to those which make sense in Python. + + #+begin_src emacs-lisp + (use-package python + :mode ("\\.py\\'" . python-mode) + :interpreter ("python" . python-mode) + :init + (add-hook 'python-mode-hook (lambda () + 'company/python-mode-hook + (semantic-mode t) (flycheck-select-checker 'python-pylint))) - ) -#+end_src - - -Automatically start python-mode when opening a .py-file. -Not sure if python.el is better than python-mode.el. -See [[https://github.com/jorgenschaefer/elpy/issues/887][here]] for info about ~python-shell-completion-native-enable~. -The custom function is to run inferiour processes (do I really need that?), see [[https://emacs.stackexchange.com/questions/16361/how-to-automatically-run-inferior-process-when-loading-major-mode][here]]. - -Also limit the completion backends to those which make sense in Python. -#+begin_src emacs-lisp - (use-package python - :mode ("\\.py\\'" . python-mode) - :interpreter ("python" . python-mode) - :init - (add-hook 'python-mode-hook 'company/python-mode-hook) - :config - (setq python-shell-completion-native-enable nil) - ) -#+end_src + :config + (setq python-shell-completion-native-enable nil) + ) + #+end_src Jedi is a backend for python autocompletion and needs to be installed on the server: @@ -1395,6 +1362,57 @@ begin_src emacs-lisp end_src +** Latex + Requirements for Linux: + - Latex + - pdf-tools + + #+begin_src emacs-lisp + (unless (string-equal user-login-name "POH") + (use-package pdf-tools + :ensure t + :config + (pdf-tools-install) + (setq TeX-view-program-selection '((output-pdf "pdf-tools"))) + (setq TeX-view-program-list '(("pdf-tools" "Tex-pdf-tools-sync-view"))) + ) + ) + #+end_src + + For latex-preview-pane a patch might be necessary (as of 2017-10), see the issue [[https://github.com/jsinglet/latex-preview-pane/issues/37][here]] + Update 2018-03: It seems to work without this patch. I will keep it here in case something breaks again. + #+begin_src + latex-preview-pane-update-p() + --- (doc-view-revert-buffer nil t) + +++ (revert-buffer-nil t 'preserve-modes) + #+end_src + After that M-x byte-compile-file + + #+begin_src emacs-lisp + (use-package latex-preview-pane + :ensure t + ) + (setq auto-mode-alist + (append '(("\\.tex$" . latex-mode)) auto-mode-alist)) + ;; one of these works + (add-hook 'LaTeX-mode-hook 'latex-preview-pane-mode) + (add-hook 'latex-mode-hook 'latex-preview-pane-mode) + + ;; necessary, because linum-mode isn't compatible and prints errors + (add-hook 'pdf-view-mode-hook (lambda () (linum-mode -1))) + #+end_src +** Markdown + Major mode to edit markdown files. + For previews it needs markdown installed on the system. + For debian: + #+BEGIN_SRC shell + sudo apt install markdown + #+END_SRC + + #+BEGIN_SRC emacs-lisp + (use-package markdown-mode + :ensure t) + #+END_SRC ** Hydra Flycheck Flycheck is necessary, obviously @@ -1424,61 +1442,6 @@ _v_ verify setup _f_ check _s_ select #+end_src -* Custom key mappings - I just use general.el to define keys and keymaps. - - #+BEGIN_SRC emacs-lisp -(use-package general - :ensure t -) - #+END_SRC - - Now some keymaps. - If there is no map defined, it is considered the global key map. - #+BEGIN_SRC emacs-lisp -(general-define-key - :states '(normal visual insert emacs) - :prefix "SPC" - :non-normal-prefix "M-SPC" - "TAB" '(ivy-switch-buffer :which-key "prev buffer") - "SPC" '(counsel-M-x :which-key "M-x")) - #+END_SRC - - A map for org-mode - #+BEGIN_SRC emacs-lisp -(general-define-key - :states '(normal visual insert emacs) - :keymaps 'org-mode-map - :prefix "SPC" - :non-normal-prefix "M-SPC" - "t" '(counsel-org-tag :which-key "org-tag")) - #+END_SRC -* Quality of Life -** Default Window Size - ;; TODO: - ;; This size is only reasonable for linux@home - ;; hyperv is way smaller, use fullscreen here - ;; pm should be fullscreen, too - #+BEGIN_SRC emacs-lisp -(if (display-graphic-p) - (progn - (setq initial-frame-alist - '( - (width . 165) - (height . 70))) - (setq default-frame-alist - '( - (width . 165) - (height . 70)))) - ) - #+END_SRC -** Line numbers - #+BEGIN_SRC emacs-lisp -(use-package linum - :ensure t - :init - (add-hook 'prog-mode-hook 'linum-mode)) - #+END_SRC * Orchestrate the configuration Some settings should be set for all systems, some need to be specific (like my job-emacs doesn't need development tools).