From 0abb53d67d5700aedffcdffb2397ce17e5bf5691 Mon Sep 17 00:00:00 2001 From: Marc Pohling Date: Sat, 5 May 2018 19:04:53 +0200 Subject: [PATCH] changed the structure, added an org babel config to indent src --- config.org | 1035 ++++++++++++++++++++++++++-------------------------- 1 file changed, 515 insertions(+), 520 deletions(-) diff --git a/config.org b/config.org index 367d509..9974b6e 100644 --- a/config.org +++ b/config.org @@ -4,8 +4,8 @@ * Personal Information #+begin_src emacs-lisp - (setq user-full-name "Marc Pohling" - user-mail-address "marc.pohling@googlemail.com") + (setq user-full-name "Marc Pohling" + user-mail-address "marc.pohling@googlemail.com") #+end_src * Stuff to add / to fix @@ -19,6 +19,7 @@ - Some webmode stuff - markdown: 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 @@ -28,108 +29,145 @@ Two options: - Point at the end of any sexp and press C-x C-e -* Customize settings - -Move the customize settings to its own file, instead of saving -customize settings in [[file:init.el][init.el]]. - -#+begin_src emacs-lisp - (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) - (load custom-file) -#+end_src +* 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 #+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")) ;"~/.emacs.d/user-dir/bookmarks") +(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 save-abbrevs 'silently) ; don't bother me with asking if new abbrevs should be saved +(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 -* Theme -** Font +Answering just 'y' or 'n' should be enough. +#+begin_src emacs-lisp + (defalias 'yes-or-no-p 'y-or-n-p) +#+end_src -Don't add the font in the work environment, which I am logged in as POH +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 +Delete the region when typing, just like as we expect nowadays. #+begin_src emacs-lisp + (delete-selection-mode t) +#+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 + +* Visuals +** Theme +*** Font + + Don't add the font in the work environment, which I am logged in as POH + + #+begin_src emacs-lisp (unless (string-equal user-login-name "POH") (set-face-attribute 'default nil :font "Hack-12") ) -#+end_src + #+end_src -** Material Theme -The [[https://github.com/cpaulik/emacs-material-theme][Material Theme]] comes in a dark and a light variant. Not too dark -to be strenious though. -b -#+begin_src emacs-lisp +*** Material Theme + The [[https://github.com/cpaulik/emacs-material-theme][Material Theme]] comes in a dark and a light variant. Not too dark + to be strenious though. + b + #+begin_src emacs-lisp (use-package material-theme :if (window-system) :defer t :ensure t ;; :init -;; (load-theme 'material t) ) -#+end_src -** Apropospriate Theme -Variants dark and light + #+end_src +*** Apropospriate Theme + Variants dark and light -#+begin_src emacs-lisp + #+begin_src emacs-lisp (use-package apropospriate-theme :if (window-system) :defer t :ensure t :config -; (load-theme 'apropospriate-dark t) ) -#+end_src + #+end_src -** Ample Theme - Variants: - - ample - - ample-flat - - ample-light +*** Ample Theme + Variants: + - ample + - ample-flat + - ample-light -#+begin_src emacs-lisp + #+begin_src emacs-lisp (use-package ample-theme :defer t :ensure t :init (load-theme 'ample-flat) -; (load-theme 'ample-light) -; (enable-theme 'ample-flat) ) -#+end_src + #+end_src +** Prettier Line Wraps + By default there is no line wrapping. M-q actually modifies the buffer, which might not be wanted. + So: enable visual wrapping and keep indentation if there are any. -* Sane defaults -Sources for this section include [[https://github.com/magnars/.emacs.d/blob/master/settings/sane-defaults.el][Magnars Sveen]] and [[http://pages.sachachua.com/.emacs.d/Sacha.html][Sacha Chua]] - -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 - -Answering just 'y' or 'n' should be enough. -#+begin_src emacs-lisp - (defalias 'yes-or-no-p 'y-or-n-p) -#+end_src + #+begin_src emacs-lisp + (global-visual-line-mode) + (diminish 'visual-line-mode) + (use-package adaptive-wrap + :ensure t + :init + (when (fboundp 'adaptive-wrap-prefix-mode) + (defun my-activate-adaptive-wrap-prefix-mode () + "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously." + (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1))) + (add-hook 'visual-line-mode-hook 'my-activate-adaptive-wrap-prefix-mode)) + ) + #+end_src -Keep all backup and auto-save files in one directory +** Mode Line + Change the default mode line to something prettier. [[https://github.com/Malabarba/smart-mode-line][Source]] -#+begin_src emacs-lisp -(setq backup-directory-alist `((".*" . ,temporary-file-directory))) -(setq auto-save-file-name-transforms `((".*" ,temporary-file-directory))) -#+end_src + #+BEGIN_SRC emacs-lisp +(use-package smart-mode-line + :ensure t + :config + (tool-bar-mode -1) + (setq sml/theme 'respectful) + (setq sml/name-width 40) + (setq sml/mode-width 'full) + (set-face-attribute 'mode-line nil + :box nil) + (sml/setup)) + #+END_SRC -UTF-8 please +** Misc + UTF-8 please + #+begin_src emacs-lisp (setq locale-coding-system 'utf-8) (set-terminal-coding-system 'utf-8) @@ -138,41 +176,24 @@ UTF-8 please (prefer-coding-system 'utf-8) #+end_src -Avoid tabs in place of multiple spaces (they look bad in TeX) -and show empty lines -#+begin_src emacs-lisp - (setq-default indent-tabs-mode nil) - (setq-default indicate-empty-lines t) -#+end_src - -Turn off blinking cursor + Turn off blinking cursor + #+begin_src emacs-lisp (blink-cursor-mode -1) #+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 - -Delete the region when typing, just like as we expect nowadays. #+begin_src emacs-lisp - (delete-selection-mode t) + (show-paren-mode t) + (column-number-mode t) + (setq uniquify-buffer-name-style 'forward) #+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 +Avoid tabs in place of multiple spaces (they look bad in TeX) +and show empty lines -Various stuff #+begin_src emacs-lisp - (show-paren-mode t) - (column-number-mode t) - (setq uniquify-buffer-name-style 'forward) + (setq-default indent-tabs-mode nil) + (setq-default indicate-empty-lines t) #+end_src Smooth scrolling. Emacs tends to be jumpy, this should change it. @@ -183,56 +204,293 @@ Smooth scrolling. Emacs tends to be jumpy, this should change it. scroll-step 1) #+END_SRC +* Usability + Activate and configure recentf -* Prettier Line Wraps - By default there is no line wrapping. M-q actually modifies the buffer, which might not be wanted. - So: enable visual wrapping and keep indentation if there are any. + #+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 - (global-visual-line-mode) - (diminish 'visual-line-mode) - (use-package adaptive-wrap + #+begin_src emacs-lisp + (use-package hydra :ensure t - :init - (when (fboundp 'adaptive-wrap-prefix-mode) - (defun my-activate-adaptive-wrap-prefix-mode () - "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously." - (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1))) - (add-hook 'visual-line-mode-hook 'my-activate-adaptive-wrap-prefix-mode)) - ) - #+end_src + :bind + ("C-c f" . hydra-flycheck/body) + ("C-c g" . hydra-git-gutter/body) + :config + (setq-default hydra-default-hint nil) + ) + #+end_src -* Mode Line - Change the default mode line to something prettier. [[https://github.com/Malabarba/smart-mode-line][Source]] +** Evil + So... Evil Mode might be worth a try - #+BEGIN_SRC emacs-lisp -(use-package smart-mode-line + #+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 - (tool-bar-mode -1) - (setq sml/theme 'respectful) - (setq sml/name-width 40) - (setq sml/mode-width 'full) - (set-face-attribute 'mode-line nil - :box nil) - (sml/setup)) - #+END_SRC + (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)) + #+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 + 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)) + #+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 + #+end_src -Also auto refresh dired, but be quiet about it. [[http://whattheemacsd.com/sane-defaults.el-01.html][Source]] -#+begin_src emacs-lisp + 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 + #+end_src +** ivy / counsel / swiper + + Flx is required for fuzzy-matching + Is it really necessary? + begin_src emacs-lisp + (use-package flx) + end_src + + Ivy displays a window with suggestions for hotkeys and M-x + + #+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 + + The find-file replacement is nicer to navigate + + #+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 + + Swiper ivy-enhances isearch + + #+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 + + #+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 + + +** 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)) + #+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 + + + +** Treemacs + A file manager comparable to neotree. + [[https://github.com/Alexander-Miller/treemacs][Github]] + + It has some requirements, which gets used here anyway: + - ace-window + - hydra + - projectile + - python + + I copied the configuration example from the github site. + No idea what this executable-find is about. + TODO check it out! + + #+begin_src emacs-lisp + (use-package treemacs + :ensure t + :defer t + :config + (setq treemacs-change-root-without-asking nil + treemacs-collapse-dirs (if (executable-find "python") 3 0) + treemacs-file-event-delay 5000 + treemacs-follow-after-init t + treemacs-follow-recenter-distance 0.1 + treemacs-goto-tag-strategy 'refetch-index + treemacs-indentation 2 + treemacs-indentation-string " " + treemacs-is-never-other-window nil + treemacs-never-persist nil + treemacs-no-png-images nil + treemacs-recenter-after-file-follow nil + treemacs-recenter-after-tag-follow nil + treemacs-show-hidden-files t + treemacs-silent-filewatch nil + treemacs-silent-refresh nil + treemacs-sorting 'alphabetic-desc + treemacs-tag-follow-cleanup t + treemacs-tag-follow-delay 1.5 + treemacs-width 35) + (treemacs-follow-mode t) + (treemacs-filewatch-mode t) + (pcase (cons (not (null (executable-find "git"))) + (not (null (executable-find "python3")))) + (`(t . t) + (treemacs-git-mode 'extended)) + (`(t . _) + (treemacs-git-mode 'simple))) + :bind + (:map global-map + ([f8] . treemacs-toggle)) + ) + #+end_src + + Treemacs-projectile is useful for uhh.. TODO explain! + + #+begin_src emacs-lisp + (use-package treemacs-projectile + :ensure t + :defer t + :config + (setq treemacs-header-function #'treemacs-projectile-create-header) + ) + #+end_src + + TODO + Hydrastuff or keybindings for functions: + - treemacs-projectile + - treemacs-projectile-toggle + - treemacs-toggle + - treemacs-bookmark + - treemacs-find-file + - treemacs-find-tag + + +** Window Handling + Some tools to easen the navigation, creation and deletion of windows + +*** Ace-Window + + #+begin_src emacs-lisp + (use-package ace-window + :ensure t + :init + (global-set-key (kbd "C-x o") 'ace-window) + ) + #+end_src + +*** Windmove + Windmove easens the navigation between windows. + Here we are setting the default keybindings (shift+arrow) + + CURRENTLY NOT WORKING, defaults are blocked. + Also not sure if necessary when using ace-window. + #+begin_src emacs-lisp + (use-package windmove + :ensure t + :config + (windmove-default-keybindings) + ) + #+end_src + * Pandoc @@ -384,277 +642,109 @@ Work specific org-capture-templates ) #+end_src -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 - -** 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. - -#+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 - -#+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 - -** 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 - -I noticed that fontification doesn't work with markdown mode when the block is indented after editing it in the org src buffer - the leading #s for headers don't get fontified properly because they apppear as Org comments. Setting ~org-src-preserve-identation~ makes things consistent as it doesn't pad source blocks with leading spaces - -#+begin_src emacs-lisp - (setq org-src-fontify-natively t - org-src-window-setup 'current-window - org-src-strip-leading-and-trailing-blank-lines t - org-src-preserve-indentation t - org-src-tab-acts-natively 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 - -#+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 - - -* 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 - -Some persistent navigation in git-gutter is nice, so here's a hydra for it: -#+BEGIN_SRC emacs-lisp -(defhydra hydra-git-gutter (:body-pre (git-gutter-mode 1) - :hint nil) - - " -^Git Gutter^ ^Git^ ^misc^ -^──────────^────────^───^────────────────^────^────────────────────────── -_j_: next hunk _s_tage hunk _q_uit -_k_: previous hunk _r_evert hunk _g_ : call magit-status -_h_: first hunk _p_opup hunk -_l_: last hunk set start _R_evision -^^ ^^ ^^ -" - ("j" git-gutter:next-hunk) - ("k" git-gutter:previous-hunk) - ("h" (progn (goto-char (point-min)) - (git-gutter:next-hunk 1))) - ("l" (progn (goto-char (point-min)) - (git-gutter:previous-hunk 1))) - ("s" git-gutter:stage-hunk) - ("r" git-gutter:revert-hunk) - ("p" git-gutter:popup-hunk) - ("R" git-gutter:set-start-revision) - ("q" nil :color blue) - ("g" magit-status) -) -#+END_SRC - - -* Undo - #+BEGIN_SRC emacs-lisp -(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 - - - -* Recentf - -#+begin_src emacs-lisp -(use-package recentf - :init - (setq recentf-save-file (concat PATH_USER_LOCAL "recentf")) - :config - (recentf-mode t) - (setq recentf-max-saved-items 200) - ) -#+end_src - +Customize the org agenda -* ivy / counsel / swiper +#+begin_src emacs-lisp + (defun my-org-skip-subtree-if-priority (priority) + "Skip an agenda subtree if it has a priority of PRIORITY. -Flx is required for fuzzy-matching -Is it really necessary? -begin_src emacs-lisp - (use-package flx) -end_src + 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 -Ivy displays a window with suggestions for hotkeys and M-x +** 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. #+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))) - ) + (setq org-tags-column 45) #+end_src -The find-file replacement is nicer to navigate +** Org babel languages +This code block is linux specific. Loading languages which aren't available seems to be a problem #+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) + (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 -Swiper ivy-enhances isearch +#+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 swiper - :ensure t - :bind - (("C-s" . swiper) - ("C-c C-r" . ivy-resume) - ) + (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 -Ivy-Hydra adds stuff in minibuffer when you press C-o +** 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 + + I noticed that fontification doesn't work with markdown mode when the block is indented after editing it in the org src buffer - the leading #s for headers don't get fontified properly because they apppear as Org comments. Setting ~org-src-preserve-identation~ makes things consistent as it doesn't pad source blocks with leading spaces + + #+begin_src emacs-lisp + (setq org-src-fontify-natively t + org-src-window-setup 'current-window + org-src-strip-leading-and-trailing-blank-lines t + org-src-preserve-indentation nil ; these two lines respect the indentation of + org-edit-src-content-indentation 0 ; the surrounding text around the source block + org-src-tab-acts-natively t) + #+end_src + -#+BEGIN_SRC emacs-lisp -(use-package ivy-hydra - :ensure t) -#+END_SRC * Helm @@ -910,6 +1000,7 @@ Highlight parens etc. for improved readability ) #+end_src ** Git +*** Magit [[https://magit.vc/manual/magit/index.html][Link]] I want to do git stuff here, not in a separate terminal window @@ -939,24 +1030,54 @@ Highlight parens etc. for improved readability :bind (("C-x g" . magit-status)) ) #+end_src - +*** Git-gutter Display line changes in gutter based on git history. Enable it everywhere [[https://github.com/syohex/emacs-git-gutter][Source]] #+begin_src emacs-lisp -(use-package git-gutter - :ensure t - :config - (global-git-gutter-mode t) - :diminish git-gutter-mode -) + (use-package git-gutter + :ensure t + :config + (global-git-gutter-mode t) + :diminish git-gutter-mode + ) #+end_src + + Some persistent navigation in git-gutter is nice, so here's a hydra for it: + + #+BEGIN_SRC emacs-lisp + (defhydra hydra-git-gutter (:body-pre (git-gutter-mode 1) + :hint nil) + " +^Git Gutter^ ^Git^ ^misc^ +^──────────^────────^───^────────────────^────^────────────────────────── +_j_: next hunk _s_tage hunk _q_uit +_k_: previous hunk _r_evert hunk _g_ : call magit-status +_h_: first hunk _p_opup hunk +_l_: last hunk set start _R_evision +^^ ^^ ^^ +" + ("j" git-gutter:next-hunk) + ("k" git-gutter:previous-hunk) + ("h" (progn (goto-char (point-min)) + (git-gutter:next-hunk 1))) + ("l" (progn (goto-char (point-min)) + (git-gutter:previous-hunk 1))) + ("s" git-gutter:stage-hunk) + ("r" git-gutter:revert-hunk) + ("p" git-gutter:popup-hunk) + ("R" git-gutter:set-start-revision) + ("q" nil :color blue) + ("g" magit-status) +) + #+END_SRC +*** Git-timemachine Time machine lets me step through the history of a file as recorded in git. [[https://github.com/pidu/git-timemachine][Source]] #+begin_src emacs-lisp -(use-package git-timemachine - :ensure t -) + (use-package git-timemachine + :ensure t + ) #+end_src ** Company Mode @@ -1303,144 +1424,6 @@ _v_ verify setup _f_ check _s_ select #+end_src -* Treemacs - A file manager comparable to neotree. - [[https://github.com/Alexander-Miller/treemacs][Github]] - - It has some requirements, which gets used here anyway: - - ace-window - - hydra - - projectile - - python - - I copied the configuration example from the github site. - No idea what this executable-find is about. - TODO check it out! - - #+begin_src emacs-lisp - (use-package treemacs - :ensure t - :defer t - :config - (setq treemacs-change-root-without-asking nil - treemacs-collapse-dirs (if (executable-find "python") 3 0) - treemacs-file-event-delay 5000 - treemacs-follow-after-init t - treemacs-follow-recenter-distance 0.1 - treemacs-goto-tag-strategy 'refetch-index - treemacs-indentation 2 - treemacs-indentation-string " " - treemacs-is-never-other-window nil - treemacs-never-persist nil - treemacs-no-png-images nil - treemacs-recenter-after-file-follow nil - treemacs-recenter-after-tag-follow nil - treemacs-show-hidden-files t - treemacs-silent-filewatch nil - treemacs-silent-refresh nil - treemacs-sorting 'alphabetic-desc - treemacs-tag-follow-cleanup t - treemacs-tag-follow-delay 1.5 - treemacs-width 35) - (treemacs-follow-mode t) - (treemacs-filewatch-mode t) - (pcase (cons (not (null (executable-find "git"))) - (not (null (executable-find "python3")))) - (`(t . t) - (treemacs-git-mode 'extended)) - (`(t . _) - (treemacs-git-mode 'simple))) - :bind - (:map global-map - ([f8] . treemacs-toggle)) - ) - #+end_src - - Treemacs-projectile is useful for uhh.. TODO explain! - - #+begin_src emacs-lisp - (use-package treemacs-projectile - :ensure t - :defer t - :config - (setq treemacs-header-function #'treemacs-projectile-create-header) - ) - #+end_src - - TODO - Hydrastuff or keybindings for functions: - - treemacs-projectile - - treemacs-projectile-toggle - - treemacs-toggle - - treemacs-bookmark - - treemacs-find-file - - treemacs-find-tag - - -* 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 - #+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)) - #+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)) - #+END_SRC - - -* Window Handling - Some tools to easen the navigation, creation and deletion of windows - -** Ace-Window - - #+begin_src emacs-lisp - (use-package ace-window - :ensure t - :init - (global-set-key (kbd "C-x o") 'ace-window) - ) - #+end_src - -** Windmove - Windmove easens the navigation between windows. - Here we are setting the default keybindings (shift+arrow) - - CURRENTLY NOT WORKING, defaults are blocked. - Also not sure if necessary when using ace-window. - #+begin_src emacs-lisp - (use-package windmove - :ensure t - :config - (windmove-default-keybindings) - ) - #+end_src - - * Custom key mappings I just use general.el to define keys and keymaps. @@ -1496,3 +1479,15 @@ _v_ verify setup _f_ check _s_ select :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). + +** Common + +** Home + +** Work + I mainly only use org +** Work, Hyper-V + For testing purproses I keep a working emacs in a debian on hyper-v. The demands here are different to the other work-emacs