From a6a7b71611a7558b546882f1557defabb8ca518f Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Fri, 2 Dec 2022 06:01:38 -0500 Subject: [PATCH] Fix indentation --- global.org | 1987 ++++++++++++++++++++++++++-------------------------- 1 file changed, 997 insertions(+), 990 deletions(-) diff --git a/global.org b/global.org index c9c2621..5eab039 100644 --- a/global.org +++ b/global.org @@ -3,7 +3,9 @@ #+email: jacopods@math.utoronto.ca #+options: *:t ::t -* TODO Make indentation uniform +* COMMENT About indentation in this file + This file will be indented with ~org-adapt-indentation~ set to t + * TODO Look at tangling at [http://thewanderingcoder.com/2015/02/literate-emacs-configuration/] @@ -25,16 +27,18 @@ :source: [https://stackoverflow.com/a/18173666] ** Why not ~package.el~ - it is convenient, but it is not git-based; ~borg.el~ is promising, but it is - way complicated; I can do everything by hand as soon as it is neatly - ~org~-anized. In the end we use a few, but I plan to phase them out and - replace them with git submodules + it is convenient, but it is not git-based; ~borg.el~ is promising, but it is + way complicated; I can do everything by hand as soon as it is neatly + ~org~-anized. In the end we use a few, but I plan to phase them out and + replace them with git submodules + * Files and dirs Move ~Customize~ to a separate file #+begin_src emacs-lisp (setq custom-file "~/.emacs.d/custom.el") (load custom-file 'noerror) #+end_src + Add relevant dirs to load path [This is somewhat undesirable; I should uniformize the path-loading business at some point…] #+begin_src emacs-lisp @@ -49,6 +53,7 @@ "highlight-parentheses.el"))) #+end_src + Put autosave files (ie #foo#) and backup files (ie foo~) in ~/.emacs.d/. create the autosave dir if necessary, since emacs won't. #+begin_src emacs-lisp @@ -63,10 +68,11 @@ (load-theme 'lunarized t) #+end_src - Use patched terminus font (this overrides the settings in Customize, but I - never could it to work otherwise). See the special treatment later on for - dealing with bold weight. To avoid flickering one should also set the font - in .Xresources + + Use patched terminus font (this overrides the settings in Customize, + but I never could it work otherwise). See the special treatment + later on for dealing with bold weight. To avoid flickering one + should also set the font in .Xresources #+begin_src emacs-lisp (set-face-font 'default "-xos4-hackminus-medium-r-normal--20-200-72-72-c-100-ISO10646-1") (set-face-font 'fixed-pitch "-xos4-hackminus-medium-r-normal--20-200-72-72-c-100-ISO10646-1") @@ -94,62 +100,62 @@ (defun wilder/fixup-faces () (interactive) (mapc (lambda (face) - (set-face-attribute face nil :weight 'normal) - (set-face-attribute face nil :slant 'normal)) - (face-list)) - (set-face-font 'default "-xos4-hackminus-medium-r-normal--20-200-72-72-c-100-ISO10646-1")) + (set-face-attribute face nil :weight 'normal) + (set-face-attribute face nil :slant 'normal)) + (face-list)) + (set-face-font 'default "-xos4-hackminus-medium-r-normal--20-200-72-72-c-100-ISO10646-1")) #+end_src ** Cosmetics - Prefer a minimal appearance: no menu, toolbar or scroll-bars; no - splash screens or messages - #+begin_src emacs-lisp - (menu-bar-mode -1) - (tool-bar-mode 0) - (scroll-bar-mode -1) - (setq inhibit-startup-screen t - inhibit-startup-message t) - #+end_src - a blinking cursor keeps the gpu awake; add global hl-line mode to more - easily spot the cursor - #+begin_src emacs-lisp - (blink-cursor-mode 0) - (set-default 'cursor-type 'box) - #+end_src - Set frame title - #+begin_src emacs-lisp - (setq frame-title-format - '((buffer-file-name "%f" - (dired-directory dired-directory "%b")) " · emacs")) - #+end_src - Themed tooltips - #+begin_src emacs-lisp - (setq x-gtk-use-system-tooltips nil) - #+end_src - Set =fill-column= to 72, which happens to be good for third-tiled frames - and it also is a reasonable standard - #+begin_src emacs-lisp - (setq default-fill-column 72) - #+end_src - Highlight sexp (apparently I am not even using this) - #+begin_src emacs-lisp - ;(require 'highlight-sexps) - #+end_src - Try to get along with large margins - #+begin_src emacs-lisp - (setq-default left-margin-width 3 - right-margin-width 3 - helm-left-margin-width left-margin-width - helm-buffers-left-margin-width left-margin-width) - (fringe-mode 10) - ;(set-window-buffer nil (current-buffer)) - #+end_src - Setup [[https://github.com/purcell/page-break-lines][page-break-lines]] - #+begin_src emacs-lisp - (require 'page-break-lines) - (setq page-break-lines-char ?· - page-break-lines-lighter "") - (global-page-break-lines-mode) - #+end_src + Prefer a minimal appearance: no menu, toolbar or scroll-bars; no + splash screens or messages + #+begin_src emacs-lisp + (menu-bar-mode -1) + (tool-bar-mode 0) + (scroll-bar-mode -1) + (setq inhibit-startup-screen t + inhibit-startup-message t) + #+end_src + a blinking cursor keeps the gpu awake; add global hl-line mode to more + easily spot the cursor + #+begin_src emacs-lisp + (blink-cursor-mode 0) + (set-default 'cursor-type 'box) + #+end_src + Set frame title + #+begin_src emacs-lisp + (setq frame-title-format + '((buffer-file-name "%f" + (dired-directory dired-directory "%b")) " · emacs")) + #+end_src + Themed tooltips + #+begin_src emacs-lisp + (setq x-gtk-use-system-tooltips nil) + #+end_src + Set =fill-column= to 72, which happens to be good for third-tiled frames + and it also is a reasonable standard + #+begin_src emacs-lisp + (setq default-fill-column 72) + #+end_src + Highlight sexp (apparently I am not even using this) + #+begin_src emacs-lisp + ;(require 'highlight-sexps) + #+end_src + Try to get along with large margins + #+begin_src emacs-lisp + (setq-default left-margin-width 3 + right-margin-width 3 + helm-left-margin-width left-margin-width + helm-buffers-left-margin-width left-margin-width) + (fringe-mode 10) + ;(set-window-buffer nil (current-buffer)) + #+end_src + Setup [[https://github.com/purcell/page-break-lines][page-break-lines]] + #+begin_src emacs-lisp + (require 'page-break-lines) + (setq page-break-lines-char ?· + page-break-lines-lighter "") + (global-page-break-lines-mode) + #+end_src ** Mouseless Disable mouse interaction with emacs #+begin_src emacs-lisp @@ -162,59 +168,59 @@ *** TODO Find out what of the above is necessary given the disable-mouse mode below Use the ~disable-mouse~ package by Steve Purcell available at [https://github.com/purcell/disable-mouse] - #+begin_src emacs-lisp - (require 'disable-mouse) - (global-disable-mouse-mode) - #+end_src + #+begin_src emacs-lisp + (require 'disable-mouse) + (global-disable-mouse-mode) + #+end_src ** Window behavior Prevent compilation window eating up other windows #+begin_src emacs-lisp - (setq compilation-window-height 12 - compilation-scroll-output nil) + (setq compilation-window-height 12 + compilation-scroll-output nil) #+end_src Prevent any automatic splitting to split vertically #+begin_src emacs-lisp (setq split-height-threshold 0) #+end_src *** Display-buffer rules - First, treat ~mu4e-headers~ properly - #+begin_src emacs-lisp - (add-to-list 'display-buffer-alist - '("\\*mu4e-headers\\*" - (display-buffer-in-side-window) - (dedicated . t) - (side . top ) - (slot . 0) - (window-height . 40))) - #+end_src - Then, treat the ~calendar~ - #+begin_src emacs-lisp - (add-to-list 'display-buffer-alist - '("\\*Calendar\\*" - (display-buffer-in-side-window) - (side . bottom ) - (slot . 0) - (window-height . 10))) - #+end_src + First, treat ~mu4e-headers~ properly + #+begin_src emacs-lisp + (add-to-list 'display-buffer-alist + '("\\*mu4e-headers\\*" + (display-buffer-in-side-window) + (dedicated . t) + (side . top ) + (slot . 0) + (window-height . 40))) + #+end_src + Then, treat the ~calendar~ + #+begin_src emacs-lisp + (add-to-list 'display-buffer-alist + '("\\*Calendar\\*" + (display-buffer-in-side-window) + (side . bottom ) + (slot . 0) + (window-height . 10))) + #+end_src ** Scrolling Scrolling setup #+begin_src emacs-lisp - (setq redisplay-dont-pause t - scroll-margin 3 - scroll-step 1 - scroll-conservatively 10000 - scroll-preserve-screen-position 1) + (setq redisplay-dont-pause t + scroll-margin 3 + scroll-step 1 + scroll-conservatively 10000 + scroll-preserve-screen-position 1) #+end_src *** TODO find out what this was actually meant to do - #+begin_src emacs-lisp - (setq-default display-buffer-reuse-frames t) - #+end_src + #+begin_src emacs-lisp + (setq-default display-buffer-reuse-frames t) + #+end_src ** Mode-line #+begin_src emacs-lisp (setq-default mode-line-modified '(:eval (if (buffer-modified-p) "●" "·")) - ;Still needs some improvements, does not report Readonly state + ;Still needs some improvements, does not report Readonly state mode-line-remote '(:eval (let ((s (format-mode-line "%@"))) (cond ((equal s "-") " ") ((equal s "@") "@") (t s))))) @@ -277,27 +283,27 @@ (setq-default header-line-format nil);'("%e" ));wilder-buffer-vc-mode-line)) (setq mode-line-separator - '(:eval (let* ((len-left (length (format-mode-line mode-line-format-left))) - (len-right (length (format-mode-line mode-line-format-right))) - (len-separator (- (+ (window-width) 2 2 2) (+ len-left len-right)))) - (format (format "%%%ds" len-separator) "")))) + '(:eval (let* ((len-left (length (format-mode-line mode-line-format-left))) + (len-right (length (format-mode-line mode-line-format-right))) + (len-separator (- (+ (window-width) 2 2 2) (+ len-left len-right)))) + (format (format "%%%ds" len-separator) "")))) (setq mode-line-format-left - '("%e" - (:propertize "╺═╸" face mode-line-indicator) - mode-line-front-space - mode-line-modified - mode-line-remote - mode-line-frame-identification - wilder-buffer-vc-mode-line - "  " - wilder-position)) + '("%e" + (:propertize "╺═╸" face mode-line-indicator) + mode-line-front-space + mode-line-modified + mode-line-remote + mode-line-frame-identification + wilder-buffer-vc-mode-line + "  " + wilder-position)) (setq mode-line-format-right - '("  " - wilder/mode-line-modes - mode-line-misc-info - " ")) + '("  " + wilder/mode-line-modes + mode-line-misc-info + " ")) (put 'mode-line-format-left 'risky-local-variable t) (put 'mode-line-format-right 'risky-local-variable t) @@ -307,63 +313,63 @@ '("%e" mode-line-format-left mode-line-separator mode-line-format-right)) - #+end_src - The following has been found in [[https://www.masteringemacs.org/article/hiding-replacing-modeline-strings][here]] to clean up the modeline - #+begin_src emacs-lisp - (defvar mode-line-cleaner-alist - '() - "Alist for `clean-mode-line.' - - When you add a new element to the alist, keep in mind that you - must pass the correct minor/major mode symbol and a string you - want to use in the modeline *in lieu of* the original.") - - (setq mode-line-cleaner-alist - `((auto-complete-mode . " α") - (yas/minor-mode . " υ") - (paredit-mode . " π") - (eldoc-mode . "") - (abbrev-mode . "") - (auto-fill-function . "") - (disable-mouse-global-mode . "") - (auto-revert-mode . "") - (helm-mode . " η" ) - (smart-tab-mode . "") - (subword-mode . "") - (outshine-mode . " o") - (outline-minor-mode . "") - (reftex-mode . "") - (flyspell-mode . "") - (geiser-mode . " γ") - (geiser-autodoc-mode . "·α") - (org-src-mode . " ωσ") - ;; Major modes - (lisp-interaction-mode . "λ") - (hi-lock-mode . "") - (python-mode . "Py") - (emacs-lisp-mode . "ελ") - (help-mode . "+") - (scheme-mode . "λ") - (tex-mode . "χ") - (latex-mode . "χ") - (TeX-latex-mode . "χ") - (org-mode . "Ω") - (org-agenda-mode . "Ω:Agenda"))) - - (defun clean-mode-line () - (interactive) - (loop for cleaner in mode-line-cleaner-alist - do (let* ((mode (car cleaner)) - (mode-str (cdr cleaner)) - (old-mode-str (cdr (assq mode minor-mode-alist)))) - (when old-mode-str - (setcar old-mode-str mode-str)) - ;; major mode - (when (eq mode major-mode) - (setq mode-name mode-str))))) - - - (add-hook 'after-change-major-mode-hook 'clean-mode-line) + #+end_src + The following has been found in [[https://www.masteringemacs.org/article/hiding-replacing-modeline-strings][here]] to clean up the modeline + #+begin_src emacs-lisp + (defvar mode-line-cleaner-alist + '() + "Alist for `clean-mode-line.' + + When you add a new element to the alist, keep in mind that you + must pass the correct minor/major mode symbol and a string you + want to use in the modeline *in lieu of* the original.") + + (setq mode-line-cleaner-alist + `((auto-complete-mode . " α") + (yas/minor-mode . " υ") + (paredit-mode . " π") + (eldoc-mode . "") + (abbrev-mode . "") + (auto-fill-function . "") + (disable-mouse-global-mode . "") + (auto-revert-mode . "") + (helm-mode . " η" ) + (smart-tab-mode . "") + (subword-mode . "") + (outshine-mode . " o") + (outline-minor-mode . "") + (reftex-mode . "") + (flyspell-mode . "") + (geiser-mode . " γ") + (geiser-autodoc-mode . "·α") + (org-src-mode . " ωσ") + ;; Major modes + (lisp-interaction-mode . "λ") + (hi-lock-mode . "") + (python-mode . "Py") + (emacs-lisp-mode . "ελ") + (help-mode . "+") + (scheme-mode . "λ") + (tex-mode . "χ") + (latex-mode . "χ") + (TeX-latex-mode . "χ") + (org-mode . "Ω") + (org-agenda-mode . "Ω:Agenda"))) + + (defun clean-mode-line () + (interactive) + (loop for cleaner in mode-line-cleaner-alist + do (let* ((mode (car cleaner)) + (mode-str (cdr cleaner)) + (old-mode-str (cdr (assq mode minor-mode-alist)))) + (when old-mode-str + (setcar old-mode-str mode-str)) + ;; major mode + (when (eq mode major-mode) + (setq mode-name mode-str))))) + + + (add-hook 'after-change-major-mode-hook 'clean-mode-line) #+end_src ** Coding system @@ -376,60 +382,60 @@ ** Mark handling No transient mark is more flexible #+begin_src emacs-lisp - (transient-mark-mode 0) + (transient-mark-mode 0) #+end_src But of course we need to /see/ the mark #+begin_src emacs-lisp - (require 'visible-mark) - (visible-mark-mode t) - (global-visible-mark-mode t) + (require 'visible-mark) + (visible-mark-mode t) + (global-visible-mark-mode t) #+end_src - The following are some convenient bindings; notice that on my layout F13 and - F14 are obtained by tapping the left and right shift respectively - #+begin_src emacs-lisp - (defun jump-to-mark () - "Jumps to the local mark, respecting the `mark-ring' order. - This is the same as using \\[set-mark-command] with the prefix argument." - (interactive) - (set-mark-command 1)) + The following are some convenient bindings; notice that on my layout F13 and + F14 are obtained by tapping the left and right shift respectively + #+begin_src emacs-lisp + (defun jump-to-mark () + "Jumps to the local mark, respecting the `mark-ring' order. + This is the same as using \\[set-mark-command] with the prefix argument." + (interactive) + (set-mark-command 1)) - (defun just-activate-mark () - (interactive) - (activate-mark)) + (defun just-activate-mark () + (interactive) + (activate-mark)) - (global-set-key-alist - '(("" . set-mark-command) - ("" . set-mark-command) - ("" . jump-to-mark) - ("" . jump-to-mark) - ("" . just-activate-mark) - ("" . just-activate-mark))) + (global-set-key-alist + '(("" . set-mark-command) + ("" . set-mark-command) + ("" . jump-to-mark) + ("" . jump-to-mark) + ("" . just-activate-mark) + ("" . just-activate-mark))) #+end_src ** Global bindings Remove some bindings that I find supremely annoying. Additionally, unbind the ~C-x o~ binding to force me using ~ace-window~ Finally, unbind the ~C-SPC~ to mark the point, as I am using LR-shift Note that I will use ~C-SPC~ as a hydra below to deal with parenthesis -#+begin_src emacs-lisp - (dolist (ch '("C-c C-x" "C-x C-r" "C-z" "C-x f" "C-x C-f" "" "C-M-u" "C-M-d" "C-x o" "C-SPC")) - (global-unset-key (kbd ch))) -#+end_src + #+begin_src emacs-lisp + (dolist (ch '("C-c C-x" "C-x C-r" "C-z" "C-x f" "C-x C-f" "" "C-M-u" "C-M-d" "C-x o" "C-SPC")) + (global-unset-key (kbd ch))) + #+end_src Change {up,down}-list -#+begin_src emacs-lisp - (global-set-key (kbd "C-M-i") 'down-list) ;; -i stands for /in/ - (global-set-key (kbd "C-M-o") 'up-list) ;; -o stands for /out/ -#+end_src - Add some opinionated bindings -#+begin_src emacs-lisp - (global-set-key-alist - '(("C-M-d" . kill-sexp) - ("C-M-" . backward-kill-sexp) - ("C-x k" . kill-this-buffer) - ("C-S-v" . scroll-down-command) - ("C-M-u" . universal-argument))) -#+end_src + #+begin_src emacs-lisp + (global-set-key (kbd "C-M-i") 'down-list) ;; -i stands for /in/ + (global-set-key (kbd "C-M-o") 'up-list) ;; -o stands for /out/ + #+end_src + Add some opinionated bindings + #+begin_src emacs-lisp + (global-set-key-alist + '(("C-M-d" . kill-sexp) + ("C-M-" . backward-kill-sexp) + ("C-x k" . kill-this-buffer) + ("C-S-v" . scroll-down-command) + ("C-M-u" . universal-argument))) + #+end_src ** Disable commands Enable narrow commands #+begin_src emacs-lisp @@ -441,35 +447,35 @@ This is a relatively smart way to go back to the beginning of the line #+begin_src emacs-lisp (defun smart-line-beginning () - "Move point to the beginning of text on the current line; if that - is already the current position of point, then move it to the - beginning of the line." - (interactive) - (let ((pt (point))) - (beginning-of-line-text) - (when (eq pt (point)) - (beginning-of-line)))) - (global-set-key (kbd "C-a") 'smart-line-beginning) + "Move point to the beginning of text on the current line; if that + is already the current position of point, then move it to the + beginning of the line." + (interactive) + (let ((pt (point))) + (beginning-of-line-text) + (when (eq pt (point)) + (beginning-of-line)))) + (global-set-key (kbd "C-a") 'smart-line-beginning) #+end_src ** Whitespace Trailing whitespace is evil; get rid of it unless we are in special modes, namely calendar (and later mu4e) - #+begin_src emacs-lisp - (setq-default show-trailing-whitespace t) - (add-hook 'calendar-mode-hook - #'(lambda () (setq-local show-trailing-whitespace nil))) - (add-hook 'before-save-hook 'delete-trailing-whitespace) - #+end_src + #+begin_src emacs-lisp + (setq-default show-trailing-whitespace t) + (add-hook 'calendar-mode-hook + #'(lambda () (setq-local show-trailing-whitespace nil))) + (add-hook 'before-save-hook 'delete-trailing-whitespace) + #+end_src Define what is whitespace during a search - #+begin_src emacs-lisp - (setq search-whitespace-regexp "[ \t\r\n]+") - #+end_src - Tabs are evil; get rid of them - #+begin_src emacs-lisp - (setq c-basic-offset 4) - (setq-default tab-width 4 - indent-tabs-mode nil) - #+end_src + #+begin_src emacs-lisp + (setq search-whitespace-regexp "[ \t\r\n]+") + #+end_src + Tabs are evil; get rid of them + #+begin_src emacs-lisp + (setq c-basic-offset 4) + (setq-default tab-width 4 + indent-tabs-mode nil) + #+end_src *** TODO Have a look at ws-trim.el It is conf'ble to avoid removing whitespace from lines that were not modified; sounds like a good idea for git @@ -482,16 +488,16 @@ #+end_src *** TODO find out if there are better options out there ** Load hydra -#+begin_src emacs-lisp -(require 'hydra) -#+end_src + #+begin_src emacs-lisp + (require 'hydra) + #+end_src ** Abbrevs Set up abbrevs #+begin_src emacs-lisp - (setq-default abbrev-mode t) - (read-abbrev-file "~/.abbrev_defs") - (setq save-abbrevs t) + (setq-default abbrev-mode t) + (read-abbrev-file "~/.abbrev_defs") + (setq save-abbrevs t) #+end_src ** Spellcheck Use flyspell @@ -502,35 +508,35 @@ (add-hook 'text-mode-hook 'flyspell-mode) (setq flyspell-use-meta-tab nil) (defface flyspell-margin-incorrect - '((t nil)) - "flyspell-margin-incorrect" - :group 'flyspell) + '((t nil)) + "flyspell-margin-incorrect" + :group 'flyspell) (setq flyspell-before-incorrect-word-string - (propertize "." 'display `((margin left-margin) - ,(propertize "×" 'face 'flyspell-margin-incorrect)))) + (propertize "." 'display `((margin left-margin) + ,(propertize "×" 'face 'flyspell-margin-incorrect)))) #+end_src ** Fringe treatment *** TODO try linum-relative #+begin_src emacs-lisp -; (require 'linum-relative) -; (linum-relative-mode 1) + ; (require 'linum-relative) + ; (linum-relative-mode 1) + #+end_src + Add line numbers globally + #+begin_src emacs-lisp + ; (global-linum-mode 1) + #+end_src + Highlight also the linum in the fringe + #+begin_src emacs-lisp + ; (require 'hlinum) + ; (hlinum-activate) + #+end_src + Add marker for current line in the margin (see + [https://github.com/kyanagi/fringe-current-line] and + [https://github.com/nschum/fringe-helper.el] for inspiration) + #+begin_src emacs-lisp + (require 'margin-current-line) + (global-margin-current-line-mode 1) #+end_src - Add line numbers globally - #+begin_src emacs-lisp - ; (global-linum-mode 1) - #+end_src - Highlight also the linum in the fringe - #+begin_src emacs-lisp -; (require 'hlinum) -; (hlinum-activate) - #+end_src - Add marker for current line in the margin (see - [https://github.com/kyanagi/fringe-current-line] and - [https://github.com/nschum/fringe-helper.el] for inspiration) - #+begin_src emacs-lisp - (require 'margin-current-line) - (global-margin-current-line-mode 1) - #+end_src ** Turn on echo mode Display unfinished commands in the echo area after the specified delay. @@ -563,28 +569,28 @@ (pop-to-buffer-same-window b) (kill-buffer)))))) (run-with-idle-timer 180 t 'kill-buffers-on-idle) - #+end_src + #+end_src ** Calendar #+begin_src emacs-lisp - (add-hook 'calendar-load-hook - (lambda () - (calendar-set-date-style 'european))) - ;; first day of the week is monday instead of sunday: - (setq calendar-week-start-day 1 - calendar-location-name "Toronto, ON Canada" - calendar-latitude 43.7 - calendar-longitude -79.4 - calendar-today-marker "·") + (add-hook 'calendar-load-hook + (lambda () + (calendar-set-date-style 'european))) + ;; first day of the week is monday instead of sunday: + (setq calendar-week-start-day 1 + calendar-location-name "Toronto, ON Canada" + calendar-latitude 43.7 + calendar-longitude -79.4 + calendar-today-marker "·") (add-hook 'today-visible-calendar-hook 'calendar-mark-today) #+end_src ** Use local proxy I need this to route bibretrieve requests through my local proxy, that in turn routes requests to ~mathscinet~ through the University network -#+begin_src emacs-lisp - ;; Use system proxy - (setq url-proxy-services '(("http" . "127.0.0.1:8118") - ("https" . "127.0.0.1:8118"))) -#+end_src + #+begin_src emacs-lisp + ;; Use system proxy + (setq url-proxy-services '(("http" . "127.0.0.1:8118") + ("https" . "127.0.0.1:8118"))) + #+end_src ** Indicator Change cursor color to reflect different layers on the keyboard This is the handler @@ -604,9 +610,9 @@ ;; important that the =service= argument is =nil=, otherwise the registration ;; would stop once the process is respawned. (ignore-errors (dbus-register-signal - :session nil "/org/xkbvleds" "org.xkbvleds" "indicatorChanged" - 'xkbvleds-indicator-signal-handler)) - #+end_src + :session nil "/org/xkbvleds" "org.xkbvleds" "indicatorChanged" + 'xkbvleds-indicator-signal-handler)) + #+end_src ** COMMENT Tarmak-ready Set up all possible combinations of modifiers #+begin_src emacs-lisp @@ -654,19 +660,19 @@ mu4e-completing-read-function 'completing-read) (let (p1 p2 myLine) - (setq p1 (line-beginning-position) ) + (setq p1 (line-beginning-position) ) (setq p2 (line-end-position) ) (setq myLine (buffer-substring-no-properties p1 p2))) (defun get-buffer-current-line () - (let ((p (line-beginning-position)) - (q (line-end-position))) - (buffer-substring-no-properties p q))) + (let ((p (line-beginning-position)) + (q (line-end-position))) + (buffer-substring-no-properties p q))) (defun get-buffer-to-eol () - (let ((p (point)) - (q (line-end-position))) - (buffer-substring-no-properties p q))) + (let ((p (point)) + (q (line-end-position))) + (buffer-substring-no-properties p q))) (defun format-zoom-meeting () (concat zoom-summary @@ -698,7 +704,7 @@ ;; define 'z' as the shortcut (add-to-list 'mu4e-view-actions - '("zCreate agenda item for meeting" . create-item-for-meeting) t) + '("zCreate agenda item for meeting" . create-item-for-meeting) t) (advice-add 'mu4e~header-line-format :around (lambda (orig-fun &rest args) @@ -826,7 +832,7 @@ (let ((ignore nil)) (if (dolist (address filter-addresses ignore) (setq ignore (or ignore (string-equal addr address)))) - nil addr))) + nil addr))) (setq mu4e-contact-process-function 'my-mu4e-contact-filter-function) #+end_src @@ -843,11 +849,11 @@ (require 'org-pomodoro) (require 'org-habit) - ;(require 'helm-org) - ;(add-to-list 'helm-completing-read-handlers-alist '(org-capture . helm-org-completing-read-tags)) -; (add-to-list 'helm-completing-read-handlers-alist '(org-set-tags-command . helm-org-completing-read-tags)) - ; (add-to-list 'helm-completing-read-handlers-alist '(org-set-tags - ; . helm-org-completing-read-tags)) + ;(require 'helm-org) + ;(add-to-list 'helm-completing-read-handlers-alist '(org-capture . helm-org-completing-read-tags)) + ; (add-to-list 'helm-completing-read-handlers-alist '(org-set-tags-command . helm-org-completing-read-tags)) + ; (add-to-list 'helm-completing-read-handlers-alist '(org-set-tags + ; . helm-org-completing-read-tags)) #+end_src *** Hooks Enable ~auto-fill-mode~ (see [[[https://www.gnu.org/software/emacs/manual/html_node/emacs/Auto-Fill.html][the manual]]]: honestly I do not see @@ -906,20 +912,20 @@ *** Agenda Set the canonical binding for the agenda #+begin_src emacs-lisp - (global-set-key (kbd "C-c a") 'org-agenda) + (global-set-key (kbd "C-c a") 'org-agenda) #+end_src Define agenda files: the main one is ~master.org~, but then I have a bunch of them on orgzly #+begin_src emacs-lisp - (setq org-agenda-files - '("~/org/master.org" - "~/org/next.org" - "~/org/orgzly/work.org" - "~/org/orgzly/scheduled.org" - "~/org/orgzly/hack.org" - "~/org/orgzly/library.org" - "~/org/kaizen.org" - "~/org/orgzly/refile.org")) + (setq org-agenda-files + '("~/org/master.org" + "~/org/next.org" + "~/org/orgzly/work.org" + "~/org/orgzly/scheduled.org" + "~/org/orgzly/hack.org" + "~/org/orgzly/library.org" + "~/org/kaizen.org" + "~/org/orgzly/refile.org")) #+end_src Default to daily agenda #+begin_src emacs-lisp @@ -958,71 +964,71 @@ #+end_src - Use figlet-type fonts to display the date #+begin_src emacs-lisp - (setq figlet - [["███" "██ " "███" "███" "█ █" "███" "███" "███" "███" "███"] - ["█ █" " █ " " █" " █" "█ █" "█ " "█ " " █" "█ █" "█ █"] - ["█ █" " █ " "███" "███" "███" "███" "███" " █" "███" "███"] - ["█ █" " █ " "█ " " █" " █" " █" "█ █" " █" "█ █" " █"] - ["███" "███" "███" "███" " █" "███" "███" " █" "███" "███"]]) - - (setq figlet-lean - [["┌──┐" "╶┐ " "╶──┐" "╶──┐" "╷ ╷" "┌──╴" "┌──╴" "╶──┐" "┌──┐" "┌──┐"] - ["│ │" " │ " " │" " │" "│ │" "│ " "│ " " │" "│ │" "│ │"] - ["│ │" " │ " "┌──┘" "╶──┤" "└──┤" "└──┐" "├──┐" " │" "├──┤" "└──┤"] - ["│ │" " │ " "│ " " │" " │" " │" "│ │" " │" "│ │" " │"] - ["└──┘" "╶┴╴" "└──╴" "╶──┘" " ╵" "╶──┘" "└──┘" " ╵" "└──┘" "╶──┘"]]) - - (defun figlet-digit (digit row) - (aref (aref figlet-lean row) digit)) - - (defun figlet-num (number row) - (let ((n number) - (d (list))) - (while (> n 0) - (setq d (append (list (mod n 10)) d)) - (setq n (/ n 10))) - (string-join (mapcar - (lambda (digit) (concat (figlet-digit digit row) " ")) - d)))) - (defun org-agenda-format-date-figlet (date) - "Format a DATE string for display in the daily/weekly agenda. + (setq figlet + [["███" "██ " "███" "███" "█ █" "███" "███" "███" "███" "███"] + ["█ █" " █ " " █" " █" "█ █" "█ " "█ " " █" "█ █" "█ █"] + ["█ █" " █ " "███" "███" "███" "███" "███" " █" "███" "███"] + ["█ █" " █ " "█ " " █" " █" " █" "█ █" " █" "█ █" " █"] + ["███" "███" "███" "███" " █" "███" "███" " █" "███" "███"]]) + + (setq figlet-lean + [["┌──┐" "╶┐ " "╶──┐" "╶──┐" "╷ ╷" "┌──╴" "┌──╴" "╶──┐" "┌──┐" "┌──┐"] + ["│ │" " │ " " │" " │" "│ │" "│ " "│ " " │" "│ │" "│ │"] + ["│ │" " │ " "┌──┘" "╶──┤" "└──┤" "└──┐" "├──┐" " │" "├──┤" "└──┤"] + ["│ │" " │ " "│ " " │" " │" " │" "│ │" " │" "│ │" " │"] + ["└──┘" "╶┴╴" "└──╴" "╶──┘" " ╵" "╶──┘" "└──┘" " ╵" "└──┘" "╶──┘"]]) + + (defun figlet-digit (digit row) + (aref (aref figlet-lean row) digit)) + + (defun figlet-num (number row) + (let ((n number) + (d (list))) + (while (> n 0) + (setq d (append (list (mod n 10)) d)) + (setq n (/ n 10))) + (string-join (mapcar + (lambda (digit) (concat (figlet-digit digit row) " ")) + d)))) + (defun org-agenda-format-date-figlet (date) + "Format a DATE string for display in the daily/weekly agenda. This function makes sure that dates are aligned for easy reading." - ;(require 'cal-iso) - (let* ((dayname (calendar-day-name date)) - (day (cadr date)) - (day-of-week (calendar-day-of-week date)) - (month (car date)) - (monthname (calendar-month-name month)) - (year (nth 2 date))nf - (iso-week (org-days-to-iso-week - (calendar-absolute-from-gregorian date))) - (weekyear (cond ((and (= month 1) (>= iso-week 52)) + ;(require 'cal-iso) + (let* ((dayname (calendar-day-name date)) + (day (cadr date)) + (day-of-week (calendar-day-of-week date)) + (month (car date)) + (monthname (calendar-month-name month)) + (year (nth 2 date))nf + (iso-week (org-days-to-iso-week + (calendar-absolute-from-gregorian date))) + (weekyear (cond ((and (= month 1) (>= iso-week 52)) (1- year)) ((and (= month 12) (<= iso-week 1)) (1+ year)) (t year))) - (weekstring (if (= day-of-week 1) + (weekstring (if (= day-of-week 1) (format " W%02d" iso-week) - ""))) - - (format (concat "\n" - "%12s %s %4d%s\n" - "%12s \n" - "%12s %-10s\n" - "%12s \n" - "%12s %s\n") - (figlet-num day 0) monthname year weekstring - (figlet-num day 1) - (figlet-num day 2) dayname - (figlet-num day 3) - (figlet-num day 4) (sunrise-sunset)))) + ""))) + + (format (concat "\n" + "%12s %s %4d%s\n" + "%12s \n" + "%12s %-10s\n" + "%12s \n" + "%12s %s\n") + (figlet-num day 0) monthname year weekstring + (figlet-num day 1) + (figlet-num day 2) dayname + (figlet-num day 3) + (figlet-num day 4) (sunrise-sunset)))) (setq org-agenda-format-date #'org-agenda-format-date-figlet) (setq org-agenda-prefix-format '((agenda . " %i %9c · %?-12t% s") - (todo . " %i %9c · ") - (tags . " %i %9c · ") - (search . " %i %9c · "))) + (todo . " %i %9c · ") + (tags . " %i %9c · ") + (search . " %i %9c · "))) #+end_src - Add a whiteline after the header Now, this is a horrible hack: the string that forms the header is obtained by constructing @@ -1032,17 +1038,17 @@ each function that produces the headers #+begin_src emacs-lisp (defun concat-newline (s) - (concat s "\n")) + (concat s "\n")) (dolist (fun '(org-tags-view org-todo-list)) (advice-add fun :around - (lambda (orig-fun &rest args) - (advice-add #'buffer-string :filter-return #'concat-newline) - (apply orig-fun args) - (advice-remove #'buffer-string #'concat-newline)))) + (lambda (orig-fun &rest args) + (advice-add #'buffer-string :filter-return #'concat-newline) + (apply orig-fun args) + (advice-remove #'buffer-string #'concat-newline)))) #+end_src #+begin_src emacs-lisp - (advice-add #'org-agenda--insert-overriding-header :filter-args + (advice-add #'org-agenda--insert-overriding-header :filter-args (lambda (params) (list `(concat ,(car params) "\n")))) #+end_src @@ -1163,64 +1169,64 @@ estimate on the time it would take to take care of them #+begin_src emacs-lisp (setq org-agenda-custom-commands - '( - ("a" "Main agenda" - ((agenda "") - (todo "NEXT|ONGOING") - (tags-todo "hack") - (tags-todo "5m") - (todo "TODO"))) - ("h" "Agenda and Android tasks" - ((agenda "") - (tags-todo "Android"))) - ("5" "Agenda and Break tasks" - ((agenda "") - (tags-todo "5m") - (tags-todo "20m"))))) + '( + ("a" "Main agenda" + ((agenda "") + (todo "NEXT|ONGOING") + (tags-todo "hack") + (tags-todo "5m") + (todo "TODO"))) + ("h" "Agenda and Android tasks" + ((agenda "") + (tags-todo "Android"))) + ("5" "Agenda and Break tasks" + ((agenda "") + (tags-todo "5m") + (tags-todo "20m"))))) #+end_src Custom agenda view - - cleanup stuff (TODO, what is this doing, exactly? ) + - cleanup stuff (TODO, what is this doing, exactly? ) #+begin_src emacs-lisp (defun org-agenda-prepare (&optional name) - (let ((filter-alist (if org-agenda-persistent-filter - (with-current-buffer - (get-buffer-create org-agenda-buffer-name) - (list `(tag . ,org-agenda-tag-filter) - `(re . ,org-agenda-regexp-filter) - `(effort . ,org-agenda-effort-filter) - `(cat . ,org-agenda-category-filter)))))) - (if (org-agenda-use-sticky-p) + (let ((filter-alist (if org-agenda-persistent-filter + (with-current-buffer + (get-buffer-create org-agenda-buffer-name) + (list `(tag . ,org-agenda-tag-filter) + `(re . ,org-agenda-regexp-filter) + `(effort . ,org-agenda-effort-filter) + `(cat . ,org-agenda-category-filter)))))) + (if (org-agenda-use-sticky-p) (progn (put 'org-agenda-tag-filter :preset-filter nil) (put 'org-agenda-category-filter :preset-filter nil) (put 'org-agenda-regexp-filter :preset-filter nil) ;; Popup existing buffer (org-agenda-prepare-window (get-buffer org-agenda-buffer-name) - filter-alist) + filter-alist) (message "Sticky Agenda buffer, use `r' to refresh") (or org-agenda-multi (org-agenda-fit-window-to-buffer)) (throw 'exit "Sticky Agenda buffer, use `r' to refresh")) - (setq org-todo-keywords-for-agenda nil) - (put 'org-agenda-tag-filter :preset-filter + (setq org-todo-keywords-for-agenda nil) + (put 'org-agenda-tag-filter :preset-filter org-agenda-tag-filter-preset) - (put 'org-agenda-category-filter :preset-filter + (put 'org-agenda-category-filter :preset-filter org-agenda-category-filter-preset) - (put 'org-agenda-regexp-filter :preset-filter + (put 'org-agenda-regexp-filter :preset-filter org-agenda-regexp-filter-preset) - (put 'org-agenda-effort-filter :preset-filter + (put 'org-agenda-effort-filter :preset-filter org-agenda-effort-filter-preset) - (if org-agenda-multi + (if org-agenda-multi (progn (setq buffer-read-only nil) (goto-char (point-max)) (unless (or (bobp) org-agenda-compact-blocks - (not org-agenda-block-separator)) + (not org-agenda-block-separator)) (insert "\n" - (if (stringp org-agenda-block-separator) - org-agenda-block-separator - (make-string (window-width) org-agenda-block-separator)) - "\n\n")) + (if (stringp org-agenda-block-separator) + org-agenda-block-separator + (make-string (window-width) org-agenda-block-separator)) + "\n\n")) (narrow-to-region (point) (point-max))) (setq org-done-keywords-for-agenda nil) ;; Setting any org variables that are in org-agenda-local-vars @@ -1245,9 +1251,9 @@ (setq org-agenda-this-buffer-name org-agenda-buffer-name) (and name (not org-agenda-name) (setq-local org-agenda-name name))) - (setq buffer-read-only nil)))) + (setq buffer-read-only nil)))) - (add-hook 'org-agenda-mode-hook + (add-hook 'org-agenda-mode-hook (lambda () (setq truncate-lines t show-trailing-whitespace nil))) @@ -1285,41 +1291,41 @@ (with-current-buffer b (string-match-p "orgzly" default-directory))) (pop-to-buffer-same-window b) (revert-buffer t 'no-confirm))))) - (org-agenda-redo-all)) + (org-agenda-redo-all)) (define-key org-agenda-mode-map (kbd "Z") 'org-revert-all-orgzly-buffers) #+end_src *** Hydras for timestamps -#+begin_src emacs-lisp - (defun hydra-timestamp/hl-paren-force-fix () - ;;; This is needed b/c hl-parent caches the point position and - ;;; refuses to update if the point did not move - (let ((hl-paren-last-point -1)) - (hl-paren-highlight))) - (defun hydra-timestamp/pre () - (unless (boundp 'hydra-timestamp/hpm) - (highlight-parentheses-mode 1)) - (setq hydra-timestamp/hpm t)) - (defun hydra-timestamp/post () - (highlight-parentheses-mode -1) - (makunbound 'hydra-timestamp/hpm)) - (global-set-key - (kbd "C-α") - (defhydra hydra-timestamp - (:pre hydra-timestamp/pre :post hydra-timestamp/post) - "paren slurp and barf" - ("l" (progn - (org-timestamp-up-day) - (hydra-timestamp/hl-paren-force-fix)) "+1D") - ("n" (progn - (org-timestamp-down-day) - (hydra-timestamp/hl-paren-force-fix)) "-1D") - ("t" (progn - (org-timestamp-up-day 7) - (hydra-timestamp/hl-paren-force-fix)) "+1W") - ("s" (progn - (org-timestamp-down-day 7) - (hydra-timestamp/hl-paren-force-fix)) "-1W"))) -#+end_src + #+begin_src emacs-lisp + (defun hydra-timestamp/hl-paren-force-fix () + ;;; This is needed b/c hl-parent caches the point position and + ;;; refuses to update if the point did not move + (let ((hl-paren-last-point -1)) + (hl-paren-highlight))) + (defun hydra-timestamp/pre () + (unless (boundp 'hydra-timestamp/hpm) + (highlight-parentheses-mode 1)) + (setq hydra-timestamp/hpm t)) + (defun hydra-timestamp/post () + (highlight-parentheses-mode -1) + (makunbound 'hydra-timestamp/hpm)) + (global-set-key + (kbd "C-α") + (defhydra hydra-timestamp + (:pre hydra-timestamp/pre :post hydra-timestamp/post) + "paren slurp and barf" + ("l" (progn + (org-timestamp-up-day) + (hydra-timestamp/hl-paren-force-fix)) "+1D") + ("n" (progn + (org-timestamp-down-day) + (hydra-timestamp/hl-paren-force-fix)) "-1D") + ("t" (progn + (org-timestamp-up-day 7) + (hydra-timestamp/hl-paren-force-fix)) "+1W") + ("s" (progn + (org-timestamp-down-day 7) + (hydra-timestamp/hl-paren-force-fix)) "-1W"))) + #+end_src *** Hydras for refiling This bit evolved from [[https://www.mollermara.com/blog/Fast-refiling-in-org-mode-with-hydras/][this post]]; see more at [[https://gist.github.com/mm--/60e0790bcbf8447160cc87a66dc949ab ][this gist]]. #+begin_src emacs-lisp @@ -1330,27 +1336,27 @@ (org-refile arg nil (list headline file nil pos))) (switch-to-buffer (current-buffer))) #+end_src -#+begin_src emacs-lisp - (defhydra wilder/hydra-org-refile (:foreign-keys run) - "Refile" - ("g" (wilder/refile "hack.org" "emacs") "Refile to Hack-emacs") - ("q" nil "cancel")) - (define-key org-mode-map (kbd "C-x \\") 'wilder/hydra-org-refile/body) -#+end_src + #+begin_src emacs-lisp + (defhydra wilder/hydra-org-refile (:foreign-keys run) + "Refile" + ("g" (wilder/refile "hack.org" "emacs") "Refile to Hack-emacs") + ("q" nil "cancel")) + (define-key org-mode-map (kbd "C-x \\") 'wilder/hydra-org-refile/body) + #+end_src *** Hydras for moving headlines around -#+begin_src emacs-lisp - (defhydra wilder/hydra-org-move () - "Move subtree" - ("f" org-backward-heading-same-level "move up" :column "Movement") - ("s" org-forward-heading-same-level "move down") - ("r" outline-up-heading "level down") - ("n" org-promote-subtree "promote" :column "Bubbling") - ("l" org-demote-subtree "demote") - ("i" org-move-subtree-up "bubble up") - ("e" org-move-subtree-down "bubble down") - ("q" nil "cancel")) - (define-key org-mode-map (kbd "C-x SPC") 'wilder/hydra-org-move/body) -#+end_src + #+begin_src emacs-lisp + (defhydra wilder/hydra-org-move () + "Move subtree" + ("f" org-backward-heading-same-level "move up" :column "Movement") + ("s" org-forward-heading-same-level "move down") + ("r" outline-up-heading "level down") + ("n" org-promote-subtree "promote" :column "Bubbling") + ("l" org-demote-subtree "demote") + ("i" org-move-subtree-up "bubble up") + ("e" org-move-subtree-down "bubble down") + ("q" nil "cancel")) + (define-key org-mode-map (kbd "C-x SPC") 'wilder/hydra-org-move/body) + #+end_src *** Capture Set default keybinding @@ -1381,17 +1387,17 @@ (org-read-date nil t \"+0d\"))\n%a\n%?\n") ("z" "Zoom meeting" entry (file+headline "~/org/orgzly/scheduled.org" "Tasks") "* TODO Attend %(format-zoom-meeting)\n%a" :immediate-finish t))) - #+end_src + #+end_src *** LaTeX export -#+begin_src emacs-lisp -; (add-to-list 'org-latex-classes -; '("amsart" "\\documentclass[11pt]{amsart}" -; ("\\section{%s}" . "\\section*{%s}") -; ("\\subsection{%s}" . "\\subsection*{%s}") -; ("\\subsubsection{%s}" . "\\subsubsection*{%s}") -; ("\\paragraph{%s}" . "\\paragraph*{%s}") -; ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) -#+end_src + #+begin_src emacs-lisp + ; (add-to-list 'org-latex-classes + ; '("amsart" "\\documentclass[11pt]{amsart}" + ; ("\\section{%s}" . "\\section*{%s}") + ; ("\\subsection{%s}" . "\\subsection*{%s}") + ; ("\\subsubsection{%s}" . "\\subsubsection*{%s}") + ; ("\\paragraph{%s}" . "\\paragraph*{%s}") + ; ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) + #+end_src *** Source blocks Add template for a source block in a few selected languages; for now I have @@ -1415,16 +1421,16 @@ (setq org-src-fontify-natively t) #+end_src This makes scheme src blocks work -#+begin_src emacs-lisp - (org-babel-do-load-languages - 'org-babel-load-languages - '((python . t) - (scheme . t) - (emacs-lisp . t))) -#+end_src + #+begin_src emacs-lisp + (org-babel-do-load-languages + 'org-babel-load-languages + '((python . t) + (scheme . t) + (emacs-lisp . t))) + #+end_src Patch ~ob-scheme.el~ while waiting for upstream #+begin_src emacs-lisp - (defun org-babel-scheme-execute-with-geiser (code output impl repl) + (defun org-babel-scheme-execute-with-geiser (code output impl repl) "Execute code in specified REPL. If the REPL doesn't exist, create it using the given scheme implementation. @@ -1439,36 +1445,36 @@ (insert code) (geiser-mode) (let ((geiser-repl-window-allow-split nil) - (geiser-repl-use-other-window nil)) - (let ((repl-buffer (save-current-buffer - (org-babel-scheme-get-repl impl repl)))) - (when (not (eq impl (org-babel-scheme-get-buffer-impl - (current-buffer)))) - (message "Implementation mismatch: %s (%s) %s (%s)" impl (symbolp impl) - (org-babel-scheme-get-buffer-impl (current-buffer)) - (symbolp (org-babel-scheme-get-buffer-impl - (current-buffer))))) - (setq geiser-repl--repl repl-buffer) - (setq geiser-impl--implementation nil) - (let ((geiser-debug-jump-to-debug-p nil) - (geiser-debug-show-debug-p nil)) - (let ((ret (funcall - ;; use `geiser-eval-region/wait' only when available - ;; in newer versions of `geiser' - (if (fboundp 'geiser-eval-region/wait) - 'geiser-eval-region/wait - 'geiser-eval-region) - (point-min) - (point-max)))) - (setq result (if output - (or (geiser-eval--retort-output ret) - "Geiser Interpreter produced no output") - (geiser-eval--retort-result-str ret ""))))) - (when (not repl) - (save-current-buffer (set-buffer repl-buffer) - (geiser-repl-exit)) - (set-process-query-on-exit-flag (get-buffer-process repl-buffer) nil) - (kill-buffer repl-buffer))))) + (geiser-repl-use-other-window nil)) + (let ((repl-buffer (save-current-buffer + (org-babel-scheme-get-repl impl repl)))) + (when (not (eq impl (org-babel-scheme-get-buffer-impl + (current-buffer)))) + (message "Implementation mismatch: %s (%s) %s (%s)" impl (symbolp impl) + (org-babel-scheme-get-buffer-impl (current-buffer)) + (symbolp (org-babel-scheme-get-buffer-impl + (current-buffer))))) + (setq geiser-repl--repl repl-buffer) + (setq geiser-impl--implementation nil) + (let ((geiser-debug-jump-to-debug-p nil) + (geiser-debug-show-debug-p nil)) + (let ((ret (funcall + ;; use `geiser-eval-region/wait' only when available + ;; in newer versions of `geiser' + (if (fboundp 'geiser-eval-region/wait) + 'geiser-eval-region/wait + 'geiser-eval-region) + (point-min) + (point-max)))) + (setq result (if output + (or (geiser-eval--retort-output ret) + "Geiser Interpreter produced no output") + (geiser-eval--retort-result-str ret ""))))) + (when (not repl) + (save-current-buffer (set-buffer repl-buffer) + (geiser-repl-exit)) + (set-process-query-on-exit-flag (get-buffer-process repl-buffer) nil) + (kill-buffer repl-buffer))))) result)) #+end_src *** Lowercase org blocks @@ -1499,21 +1505,21 @@ #+end_src *** Clocking #+begin_src emacs-lisp - ;; Separate drawers for clocking and logs - (setq org-drawers (quote ("PROPERTIES" "CLOCKBOOK"))) - ;; Save clock data and state changes and notes in the CLOCK drawer - (setq org-clock-into-drawer "CLOCKBOOK") - ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration - (setq org-clock-out-remove-zero-time-clocks t) - ;; Clock out when moving task to a done state - (setq org-clock-out-when-done t) - - (setq org-clock-persist 'history) - - (setq org-duration-format 'h:mm) - (setq org-clock-clocktable-default-properties '(:maxlevel 2 :scope subtree)) - (org-clock-persistence-insinuate) - #+end_src + ;; Separate drawers for clocking and logs + (setq org-drawers (quote ("PROPERTIES" "CLOCKBOOK"))) + ;; Save clock data and state changes and notes in the CLOCK drawer + (setq org-clock-into-drawer "CLOCKBOOK") + ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration + (setq org-clock-out-remove-zero-time-clocks t) + ;; Clock out when moving task to a done state + (setq org-clock-out-when-done t) + + (setq org-clock-persist 'history) + + (setq org-duration-format 'h:mm) + (setq org-clock-clocktable-default-properties '(:maxlevel 2 :scope subtree)) + (org-clock-persistence-insinuate) + #+end_src *** COMMENT Tangle to different files This has been broken by commit 3ebee033103ccd3c3e8c354bad01c15332b9d901 and a2cb9b853d30fc301f4553d1556dba4ee6bc1ead. @@ -1525,74 +1531,74 @@ This is some some super-clever stuff. See [https://emacs.stackexchange.com/questions/39032/tangle-the-same-src-block-to-different-files] - #+begin_src emacs-lisp - (defun org-babel-tangle-collect-blocks-handle-tangle-list (&optional language tangle-file) - "Can be used as :override advice for `org-babel-tangle-collect-blocks'. - Handles lists of :tangle files." - (let ((counter 0) last-heading-pos blocks) - (org-babel-map-src-blocks (buffer-file-name) - (let ((current-heading-pos - (org-with-wide-buffer - (org-with-limited-levels (outline-previous-heading))))) - (if (eq last-heading-pos current-heading-pos) (cl-incf counter) - (setq counter 1) - (setq last-heading-pos current-heading-pos))) - (unless (org-in-commented-heading-p) - (let* ((info (org-babel-get-src-block-info)) - (src-lang (nth 0 info)) - (src-tfiles (cdr (assq :tangle (nth 2 info))))) ; Tobias: accept list for :tangle - (unless (consp src-tfiles) ; Tobias: unify handling of strings and lists for :tangle - (setq src-tfiles (list src-tfiles))) ; Tobias: unify handling - (dolist (src-tfile src-tfiles) ; Tobias: iterate over list - (unless (or (string= src-tfile "no") - (and tangle-file (not (equal tangle-file src-tfile))) - (and language (not (string= language src-lang)))) - ;; Add the spec for this block to blocks under its - ;; language. - (let ((by-lang (assoc src-lang blocks)) - (block (org-babel-tangle-single-block counter))) - (setcdr (assoc :tangle (nth 4 block)) src-tfile) ; Tobias: - (if by-lang (setcdr by-lang (cons block (cdr by-lang))) - (push (cons src-lang (list block)) blocks)))))))) ; Tobias: just () - ;; Ensure blocks are in the correct order. - (mapcar (lambda (b) (cons (car b) (nreverse (cdr b)))) blocks))) - - (defun org-babel-tangle-single-block-handle-tangle-list (oldfun block-counter &optional only-this-block) - "Can be used as :around advice for `org-babel-tangle-single-block'. - If the :tangle header arg is a list of files. Handle all files" - (let* ((info (org-babel-get-src-block-info)) - (params (nth 2 info)) - (tfiles (cdr (assoc :tangle params)))) - (message nil) - (if (null (and only-this-block (consp tfiles))) - (funcall oldfun block-counter only-this-block) - (cl-assert (listp tfiles) nil - ":tangle only allows a tangle file name or a list of tangle file names") - (let ((ret (mapcar - (lambda (tfile) - (message tfile) - (sleep-for 1) - (let (old-get-info) - (cl-letf* (((symbol-function 'old-get-info) (symbol-function 'org-babel-get-src-block-info)) - ((symbol-function 'org-babel-get-src-block-info) - `(lambda (&rest get-info-args) - (let* ((info (apply 'old-get-info get-info-args)) - (params (nth 2 info)) - (tfile-cons (assoc :tangle params))) - (setcdr tfile-cons ,tfile) - info)))) - (funcall oldfun block-counter only-this-block)))) - tfiles))) - (if only-this-block - (list (cons (cl-caaar ret) (mapcar #'cadar ret))) - ret))))) - - - (advice-add 'org-babel-tangle-collect-blocks :override - #'org-babel-tangle-collect-blocks-handle-tangle-list) - (advice-add 'org-babel-tangle-single-block :around - #'org-babel-tangle-single-block-handle-tangle-list) - #+end_src + #+begin_src emacs-lisp + (defun org-babel-tangle-collect-blocks-handle-tangle-list (&optional language tangle-file) + "Can be used as :override advice for `org-babel-tangle-collect-blocks'. + Handles lists of :tangle files." + (let ((counter 0) last-heading-pos blocks) + (org-babel-map-src-blocks (buffer-file-name) + (let ((current-heading-pos + (org-with-wide-buffer + (org-with-limited-levels (outline-previous-heading))))) + (if (eq last-heading-pos current-heading-pos) (cl-incf counter) + (setq counter 1) + (setq last-heading-pos current-heading-pos))) + (unless (org-in-commented-heading-p) + (let* ((info (org-babel-get-src-block-info)) + (src-lang (nth 0 info)) + (src-tfiles (cdr (assq :tangle (nth 2 info))))) ; Tobias: accept list for :tangle + (unless (consp src-tfiles) ; Tobias: unify handling of strings and lists for :tangle + (setq src-tfiles (list src-tfiles))) ; Tobias: unify handling + (dolist (src-tfile src-tfiles) ; Tobias: iterate over list + (unless (or (string= src-tfile "no") + (and tangle-file (not (equal tangle-file src-tfile))) + (and language (not (string= language src-lang)))) + ;; Add the spec for this block to blocks under its + ;; language. + (let ((by-lang (assoc src-lang blocks)) + (block (org-babel-tangle-single-block counter))) + (setcdr (assoc :tangle (nth 4 block)) src-tfile) ; Tobias: + (if by-lang (setcdr by-lang (cons block (cdr by-lang))) + (push (cons src-lang (list block)) blocks)))))))) ; Tobias: just () + ;; Ensure blocks are in the correct order. + (mapcar (lambda (b) (cons (car b) (nreverse (cdr b)))) blocks))) + + (defun org-babel-tangle-single-block-handle-tangle-list (oldfun block-counter &optional only-this-block) + "Can be used as :around advice for `org-babel-tangle-single-block'. + If the :tangle header arg is a list of files. Handle all files" + (let* ((info (org-babel-get-src-block-info)) + (params (nth 2 info)) + (tfiles (cdr (assoc :tangle params)))) + (message nil) + (if (null (and only-this-block (consp tfiles))) + (funcall oldfun block-counter only-this-block) + (cl-assert (listp tfiles) nil + ":tangle only allows a tangle file name or a list of tangle file names") + (let ((ret (mapcar + (lambda (tfile) + (message tfile) + (sleep-for 1) + (let (old-get-info) + (cl-letf* (((symbol-function 'old-get-info) (symbol-function 'org-babel-get-src-block-info)) + ((symbol-function 'org-babel-get-src-block-info) + `(lambda (&rest get-info-args) + (let* ((info (apply 'old-get-info get-info-args)) + (params (nth 2 info)) + (tfile-cons (assoc :tangle params))) + (setcdr tfile-cons ,tfile) + info)))) + (funcall oldfun block-counter only-this-block)))) + tfiles))) + (if only-this-block + (list (cons (cl-caaar ret) (mapcar #'cadar ret))) + ret))))) + + + (advice-add 'org-babel-tangle-collect-blocks :override + #'org-babel-tangle-collect-blocks-handle-tangle-list) + (advice-add 'org-babel-tangle-single-block :around + #'org-babel-tangle-single-block-handle-tangle-list) + #+end_src *** Append tangle #+begin_src emacs-lisp (defun org-babel-tangle-append (filename) @@ -1608,27 +1614,27 @@ Source on gitlab]] #+begin_src emacs-lisp (defun tangle-file(&rest files nokill) - "Tangle FILES or all files in the project." - (when (null files) - (setq files command-line-args-left)) - (dolist (file files) - (with-current-buffer (find-file-noselect file) - (org-babel-tangle) -; (unless nokill (kill-buffer)) - ))) + "Tangle FILES or all files in the project." + (when (null files) + (setq files command-line-args-left)) + (dolist (file files) + (with-current-buffer (find-file-noselect file) + (org-babel-tangle) + ; (unless nokill (kill-buffer)) + ))) #+end_src *** Export file This can be used to tangle one or more files to their output files [[https://gitlab.com/to1ne/literate-dotfiles/blob/master/elisp/tangle.el][ Source on gitlab]] #+begin_src emacs-lisp (defun export-org-file-pdf(&rest files nokill) - "Export FILES or all files in the project." - (when (null files) - (setq files command-line-args-left)) - (dolist (file files) - (with-current-buffer (find-file-noselect file) - (org-latex-export-to-pdf) - (kill-buffer)))) + "Export FILES or all files in the project." + (when (null files) + (setq files command-line-args-left)) + (dolist (file files) + (with-current-buffer (find-file-noselect file) + (org-latex-export-to-pdf) + (kill-buffer)))) #+end_src *** Crypto stuff #+begin_src emacs-lisp @@ -1641,16 +1647,16 @@ *** ox-export Load ox-hugo -#+begin_src emacs-lisp -(with-eval-after-load 'ox - (require 'ox-hugo)) -#+end_src + #+begin_src emacs-lisp + (with-eval-after-load 'ox + (require 'ox-hugo)) + #+end_src *** ~org-roam~ setup -#+begin_src emacs-lisp - (setq org-roam-directory (file-truename "~/org-roam")) - (org-roam-db-autosync-mode) - (global-set-key (kbd "C-c n f") 'org-roam-node-find) -#+end_src + #+begin_src emacs-lisp + (setq org-roam-directory (file-truename "~/org-roam")) + (org-roam-db-autosync-mode) + (global-set-key (kbd "C-c n f") 'org-roam-node-find) + #+end_src ** elisp *** Paredit #+begin_src emacs-lisp @@ -1708,14 +1714,14 @@ (add-to-list 'auto-mode-alist '("\\.qml\\'" . qml-mode)) #+end_src ** Python -Silent offset warning -#+begin_src emacs-lisp - (setq python-indent-guess-indent-offset-verbose nil) -#+end_src + Silent offset warning + #+begin_src emacs-lisp + (setq python-indent-guess-indent-offset-verbose nil) + #+end_src ** C and C++ *** Hooks #+begin_src emacs-lisp -;; (require 'doxymacs) + ;; (require 'doxymacs) (add-hook 'c-mode-hook (lambda () @@ -1730,101 +1736,101 @@ Silent offset warning #+end_src ** TODO split --- LaTeX *** TODO Setup ~reftex~ - #+begin_src emacs-lisp - (with-eval-after-load "reftex" - (setq reftex-cite-format "~\\cite{%l}" - reftex-plug-into-AUCTeX '(t t nil t t) - reftex-insert-label-flags '(t t) - reftex-label-alist - '(("thm" ?t "thm:" "~\\ref{%s}" thm (regexp "theorems?")) - ("lem" ?l "lem:" "~\\ref{%s}" lem (regexp "lemma{ta}?")) - ("prop" ?p "prp:" "~\\ref{%s}" prp (regexp "propositions?")) - ("cor" ?c "cor:" "~\\ref{%s}" cor (regexp "corollary")) - ("def" ?d "def:" "~\\ref{%s}" cor (regexp "defintions?"))))) - ;;; advice the auctex function to replace the - ;;; lighter with somthing softer - (with-eval-after-load "auctex" - (defun cleanup-TeX-mode (&optional mode) - "Advice for the base auctex MODE naming" - (setq mode-name (replace-regexp-in-string "LaTeX" "χ" mode-name t)) - (setq mode-name (replace-regexp-in-string "/" "·" mode-name))) - (advice-add 'TeX-set-mode-name :after 'cleanup-TeX-mode)) - - #+end_src + #+begin_src emacs-lisp + (with-eval-after-load "reftex" + (setq reftex-cite-format "~\\cite{%l}" + reftex-plug-into-AUCTeX '(t t nil t t) + reftex-insert-label-flags '(t t) + reftex-label-alist + '(("thm" ?t "thm:" "~\\ref{%s}" thm (regexp "theorems?")) + ("lem" ?l "lem:" "~\\ref{%s}" lem (regexp "lemma{ta}?")) + ("prop" ?p "prp:" "~\\ref{%s}" prp (regexp "propositions?")) + ("cor" ?c "cor:" "~\\ref{%s}" cor (regexp "corollary")) + ("def" ?d "def:" "~\\ref{%s}" cor (regexp "defintions?"))))) + ;;; advice the auctex function to replace the + ;;; lighter with somthing softer + (with-eval-after-load "auctex" + (defun cleanup-TeX-mode (&optional mode) + "Advice for the base auctex MODE naming" + (setq mode-name (replace-regexp-in-string "LaTeX" "χ" mode-name t)) + (setq mode-name (replace-regexp-in-string "/" "·" mode-name))) + (advice-add 'TeX-set-mode-name :after 'cleanup-TeX-mode)) + + #+end_src *** Setup ~latex-mode~ - #+begin_src emacs-lisp - (eval-after-load 'latex - '(progn - (font-lock-add-keywords 'latex-mode - `((,(rx "$") 0 'font-latex-sedate-face t)) t) - (defface font-latex-special-comment-face '((t (:foreground "#2aa198"))) "Cyan") - - - (font-lock-add-keywords 'latex-mode '(("^% \\([^*].*\\)" 1 'font-latex-special-comment-face t))) - - (define-key-alist LaTeX-mode-map - '(("M-S-SPC" . TeX-insert-braces) - ("C-c C-v" . wilder/TeX-insert-reference) - ("C-M-" . wilder/TeX-insert-align-dwim) - ;; unbind return - NOTE it is important to unbind - ;; and not RET. If we unbind RET then C-m won't work - ;; either. - ("" . (lambda() (interactive) (insert "\\"))) - ("S-" . (lambda() (interactive) (insert "|"))) - ("C-c C-." . LaTeX-mark-environment) - ("C-c " . LaTeX-environment) - ("C-c C-e" . (lambda (r-begin r-end) - (interactive "r") - (add-delimiter "_{" "}" r-begin r-end))) - ("C-c C-i" . (lambda (r-begin r-end) - (interactive "r") - (add-delimiter "^{" "}" r-begin r-end))) - ("M-|" . (lambda (r-begin r-end) - (interactive "r") - (add-delimiter "|" "|" r-begin r-end))) - ("M-," . (lambda (r-begin r-end) - (interactive "r") - (add-delimiter ", " ", " r-begin r-end))) - ("M-\"" . (lambda (r-begin r-end) - (interactive "r") - (add-delimiter "“" "”" r-begin r-end))) - - ;; This is the rationale: C-M-SPC starts inline math C-M-RET starts display math - - ("C-M-SPC" . (lambda (r-begin r-end) (interactive "r") (add-delimiter "$" "$" r-begin r-end))) - ("C-c C-d" . wilder/TeX-insert-todonote) - ("C-M-d" . kill-sexp) - ("C-M-i" . down-list) ;; -i stands for /in/ - ("C-M-o" . up-list) ;; -o stands for /out/ - ("" . ( lambda() (interactive) (message "Use C-c C-c"))) - ("C-c C-c" . ( lambda() (interactive) (compile "/home/jacopods/scripts/latex-mk")) ) - ("~" . wilder/TeX-replace-tilde) - ("C-o" . wilder/open-line-and-indent) - ;; Force moves around to be more “semantic” - ("C-v" . goto-next-comment-line) - ("M-v" . goto-previous-comment-line) - ("C-x n c" . narrow-between-comments) - ("C-S-v" . backward-paragraph))) - - (dolist (ch '("=" "≠" ">" "<" "≥" "≤" "⇒" "∩" "∪" "∨" "∧" "×" "⊂" "⊃")) - (define-key LaTeX-mode-map (kbd ch) 'insert-char-with-padding)) - - ;; Move around commands in the Right Way™ - (modify-syntax-entry ?\\ "w" LaTeX-mode-syntax-table) - - ;; add fancy quotes to the syntax table - (modify-syntax-entry ?“ "(”" LaTeX-mode-syntax-table) - (modify-syntax-entry ?” ")“" LaTeX-mode-syntax-table) - - (setq subword-forward-regexp "\\W*\\(\\([\\\\[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)") - (setq subword-backward-regexp "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([\\\\[:upper:]]+\\W*\\)\\|\\W\\w+\\)"))) - #+end_src + #+begin_src emacs-lisp + (eval-after-load 'latex + '(progn + (font-lock-add-keywords 'latex-mode + `((,(rx "$") 0 'font-latex-sedate-face t)) t) + (defface font-latex-special-comment-face '((t (:foreground "#2aa198"))) "Cyan") + + + (font-lock-add-keywords 'latex-mode '(("^% \\([^*].*\\)" 1 'font-latex-special-comment-face t))) + + (define-key-alist LaTeX-mode-map + '(("M-S-SPC" . TeX-insert-braces) + ("C-c C-v" . wilder/TeX-insert-reference) + ("C-M-" . wilder/TeX-insert-align-dwim) + ;; unbind return - NOTE it is important to unbind + ;; and not RET. If we unbind RET then C-m won't work + ;; either. + ("" . (lambda() (interactive) (insert "\\"))) + ("S-" . (lambda() (interactive) (insert "|"))) + ("C-c C-." . LaTeX-mark-environment) + ("C-c " . LaTeX-environment) + ("C-c C-e" . (lambda (r-begin r-end) + (interactive "r") + (add-delimiter "_{" "}" r-begin r-end))) + ("C-c C-i" . (lambda (r-begin r-end) + (interactive "r") + (add-delimiter "^{" "}" r-begin r-end))) + ("M-|" . (lambda (r-begin r-end) + (interactive "r") + (add-delimiter "|" "|" r-begin r-end))) + ("M-," . (lambda (r-begin r-end) + (interactive "r") + (add-delimiter ", " ", " r-begin r-end))) + ("M-\"" . (lambda (r-begin r-end) + (interactive "r") + (add-delimiter "“" "”" r-begin r-end))) + + ;; This is the rationale: C-M-SPC starts inline math C-M-RET starts display math + + ("C-M-SPC" . (lambda (r-begin r-end) (interactive "r") (add-delimiter "$" "$" r-begin r-end))) + ("C-c C-d" . wilder/TeX-insert-todonote) + ("C-M-d" . kill-sexp) + ("C-M-i" . down-list) ;; -i stands for /in/ + ("C-M-o" . up-list) ;; -o stands for /out/ + ("" . ( lambda() (interactive) (message "Use C-c C-c"))) + ("C-c C-c" . ( lambda() (interactive) (compile "/home/jacopods/scripts/latex-mk")) ) + ("~" . wilder/TeX-replace-tilde) + ("C-o" . wilder/open-line-and-indent) + ;; Force moves around to be more “semantic” + ("C-v" . goto-next-comment-line) + ("M-v" . goto-previous-comment-line) + ("C-x n c" . narrow-between-comments) + ("C-S-v" . backward-paragraph))) + + (dolist (ch '("=" "≠" ">" "<" "≥" "≤" "⇒" "∩" "∪" "∨" "∧" "×" "⊂" "⊃")) + (define-key LaTeX-mode-map (kbd ch) 'insert-char-with-padding)) + + ;; Move around commands in the Right Way™ + (modify-syntax-entry ?\\ "w" LaTeX-mode-syntax-table) + + ;; add fancy quotes to the syntax table + (modify-syntax-entry ?“ "(”" LaTeX-mode-syntax-table) + (modify-syntax-entry ?” ")“" LaTeX-mode-syntax-table) + + (setq subword-forward-regexp "\\W*\\(\\([\\\\[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)") + (setq subword-backward-regexp "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([\\\\[:upper:]]+\\W*\\)\\|\\W\\w+\\)"))) + #+end_src *** Require Load auctex, reftex and set up related hooks #+begin_src emacs-lisp - (require 'tex-site) - (require 'reftex) + (require 'tex-site) + (require 'reftex) #+end_src *** Set default TeX options #+begin_src emacs-lisp @@ -1832,7 +1838,7 @@ Silent offset warning (setq TeX-auto-save t TeX-parse-self t TeX-insert-braces nil) - #+end_src + #+end_src *** Appearance No fontification for sub and superscripts #+begin_src emacs-lisp @@ -1840,34 +1846,34 @@ Silent offset warning #+end_src Add unicode quotes to the quote-list #+begin_src emacs-lisp -; (defvar font-latex-quote-list '(("``" "''") ("“" "”") ("<<" ">>" french) ("«" "»" french)) ; + ; (defvar font-latex-quote-list '(("``" "''") ("“" "”") ("<<" ">>" french) ("«" "»" french)) ; #+end_src Redefine fold ellipsis #+begin_src emacs-lisp - (setq TeX-fold-ellipsis " …") + (setq TeX-fold-ellipsis " …") #+end_src *** Default labels #+begin_src emacs-lisp - (setq LaTeX-equation-label "e_" - LaTeX-section-label "s_" - LaTeX-figure-label "f_") + (setq LaTeX-equation-label "e_" + LaTeX-section-label "s_" + LaTeX-figure-label "f_") #+end_src *** Spell checking help Do not spell-check inside the following commands. See [https://tex.stackexchange.com/questions/117204/skip-spelling-in-emacs-for-the-content-of-a-user-macro] - #+begin_src emacs-lisp - (setq ispell-tex-skip-alists - (list - (append - (car ispell-tex-skip-alists) ;tell ispell to ignore content of this: - '(("\\\\eqref" ispell-tex-arg-end) - ("\\\\cite" ispell-tex-arg-end) - ("\\\\author" ispell-tex-arg-end) - ("\\\\address" ispell-tex-arg-end) - ("\\\\include" ispell-tex-arg-end) - )) - (cadr ispell-tex-skip-alists))) - #+end_src + #+begin_src emacs-lisp + (setq ispell-tex-skip-alists + (list + (append + (car ispell-tex-skip-alists) ;tell ispell to ignore content of this: + '(("\\\\eqref" ispell-tex-arg-end) + ("\\\\cite" ispell-tex-arg-end) + ("\\\\author" ispell-tex-arg-end) + ("\\\\address" ispell-tex-arg-end) + ("\\\\include" ispell-tex-arg-end) + )) + (cadr ispell-tex-skip-alists))) + #+end_src *** Specialty functions This function adds a pair of delimiters or surrounds the active region with the given delimiters. @@ -1893,43 +1899,43 @@ Silent offset warning negative argument #+begin_src emacs-lisp (defun TeX-insert-braces (arg) - "Make a pair of braces around next ARG sexps and leave point inside. + "Make a pair of braces around next ARG sexps and leave point inside. No argument is equivalent to zero: just insert braces and leave point between. If there is an active region, ARG will be ignored, braces will be inserted around the region, and point will be left after the closing brace." - (interactive "P") - (if (TeX-active-mark) - (progn - (if (< (point) (mark)) - (exchange-point-and-mark)) - (insert TeX-grcl) - (save-excursion - (goto-char (mark)) - (insert TeX-grop))) - (if (and arg (< arg 0)) - (progn - (save-excursion - (backward-sexp (prefix-numeric-value (- 0 arg))) - (insert TeX-grop)) - (insert TeX-grcl)) - (insert TeX-grop) - (save-excursion - (if arg (forward-sexp (prefix-numeric-value arg))) - (insert TeX-grcl))))) - - (defun TeX-back-insert-braces (arg) - (interactive "P") - (if arg (TeX-insert-braces (- 0 arg)) - (insert TeX-grcl))) + (interactive "P") + (if (TeX-active-mark) + (progn + (if (< (point) (mark)) + (exchange-point-and-mark)) + (insert TeX-grcl) + (save-excursion + (goto-char (mark)) + (insert TeX-grop))) + (if (and arg (< arg 0)) + (progn + (save-excursion + (backward-sexp (prefix-numeric-value (- 0 arg))) + (insert TeX-grop)) + (insert TeX-grcl)) + (insert TeX-grop) + (save-excursion + (if arg (forward-sexp (prefix-numeric-value arg))) + (insert TeX-grcl))))) + + (defun TeX-back-insert-braces (arg) + (interactive "P") + (if arg (TeX-insert-braces (- 0 arg)) + (insert TeX-grcl))) #+end_src This is a helper for [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Dynamic-Abbrevs.html][Dynamic abbrev expansion]] #+begin_src emacs-lisp (defun dabbrev-expand-helper () (interactive) - (call-interactively 'dabbrev-expand)) + (call-interactively 'dabbrev-expand)) #+end_src This inserts a char adding some whitespace padding whenever necessary #+begin_src emacs-lisp @@ -1952,18 +1958,18 @@ Silent offset warning This inserts a plain reference (or a reference to an equation with prefix arg) #+begin_src emacs-lisp - (defun wilder/TeX-insert-reference (arg) - (interactive "P") - (insert "~") - (if arg (TeX-insert-macro "eqref") - (TeX-insert-macro "ref"))) + (defun wilder/TeX-insert-reference (arg) + (interactive "P") + (insert "~") + (if arg (TeX-insert-macro "eqref") + (TeX-insert-macro "ref"))) #+end_src This inserts a citation #+begin_src emacs-lisp - (defun wilder/TeX-insert-cite (arg) - (interactive "P") - (insert "~") - (TeX-insert-macro "cite")) + (defun wilder/TeX-insert-cite (arg) + (interactive "P") + (insert "~") + (TeX-insert-macro "cite")) #+end_src This inserts an ~align~ environment (or an ~align*~ with prefix arg) #+begin_src emacs-lisp @@ -1987,9 +1993,9 @@ Silent offset warning This replaces horizontal space with a tilde #+begin_src emacs-lisp (defun wilder/TeX-replace-tilde (arg) - (interactive "P") - (delete-horizontal-space) - (insert "~")) + (interactive "P") + (delete-horizontal-space) + (insert "~")) #+end_src Insert a todonote at point or wrap the region in a todonote. #+begin_src emacs-lisp @@ -1997,7 +2003,7 @@ Silent offset warning (interactive "P\nr") (if arg (add-delimiter "{\\todo[inline]{" "}}" r-begin r-end) - (add-delimiter "{\\todo{" "}}" r-begin r-end))) + (add-delimiter "{\\todo{" "}}" r-begin r-end))) #+end_src Promote inline math to an align #+begin_src emacs-lisp @@ -2080,7 +2086,7 @@ Silent offset warning ((looking-at "[ \t]*$") (delete-horizontal-space) (insert-before-markers "\n") - ;(newline) + ;(newline) (when prefix (insert prefix))) (t (delete-horizontal-space) @@ -2125,159 +2131,159 @@ Silent offset warning with font selection. The function below patches the annoying behavior, by defaulting to the default behavior if the prefix argument is 0 -#+begin_src emacs-lisp - (defun wilder/TeX-font (replace what) - "Insert template for font change command. - If REPLACE is not nil, replace current font. WHAT determines the font - to use, as specified by `TeX-font-list'." - (interactive "*P\nc") - (TeX-update-style) - (let* ((entry (assoc what TeX-font-list)) - (in-math (texmathp)) - (before (nth 1 entry)) - (after (nth 2 entry))) - (setq replace (or replace (eq t (nth 3 entry)) (eq t (nth 5 entry)))) - (if (and in-math (stringp (nth 3 entry))) - (setq before (nth 3 entry) - after (nth 4 entry))) - (setq arg (prefix-numeric-value replace)) - (cond - ((null entry) - (let ((help (concat - "Font list: " - "KEY TEXTFONT MATHFONT\n\n" - (mapconcat 'TeX-describe-font-entry - TeX-font-list "\n")))) - (with-output-to-temp-buffer "*Help*" - (set-buffer "*Help*") - (insert help)))) - ((and replace (eq 0 arg)) - (funcall TeX-font-replace-function before after)) - ((and replace (< arg 0) ) - (progn - (save-excursion - (backward-sexp (- 0 arg)) - (insert before)) - (insert after))) - ((and replace (> arg 0)) - (insert before) - (save-excursion - (forward-sexp arg) - (insert after))) - ((TeX-active-mark) - (save-excursion - (cond ((> (mark) (point)) - (insert before) - (goto-char (mark)) - (insert after)) - (t - (insert after) - (goto-char (mark)) - (insert before))))) - (t - (insert before) - (save-excursion - (insert after)))))) - (advice-add 'TeX-font :override #'wilder/TeX-font) -#+end_src + #+begin_src emacs-lisp + (defun wilder/TeX-font (replace what) + "Insert template for font change command. + If REPLACE is not nil, replace current font. WHAT determines the font + to use, as specified by `TeX-font-list'." + (interactive "*P\nc") + (TeX-update-style) + (let* ((entry (assoc what TeX-font-list)) + (in-math (texmathp)) + (before (nth 1 entry)) + (after (nth 2 entry))) + (setq replace (or replace (eq t (nth 3 entry)) (eq t (nth 5 entry)))) + (if (and in-math (stringp (nth 3 entry))) + (setq before (nth 3 entry) + after (nth 4 entry))) + (setq arg (prefix-numeric-value replace)) + (cond + ((null entry) + (let ((help (concat + "Font list: " + "KEY TEXTFONT MATHFONT\n\n" + (mapconcat 'TeX-describe-font-entry + TeX-font-list "\n")))) + (with-output-to-temp-buffer "*Help*" + (set-buffer "*Help*") + (insert help)))) + ((and replace (eq 0 arg)) + (funcall TeX-font-replace-function before after)) + ((and replace (< arg 0) ) + (progn + (save-excursion + (backward-sexp (- 0 arg)) + (insert before)) + (insert after))) + ((and replace (> arg 0)) + (insert before) + (save-excursion + (forward-sexp arg) + (insert after))) + ((TeX-active-mark) + (save-excursion + (cond ((> (mark) (point)) + (insert before) + (goto-char (mark)) + (insert after)) + (t + (insert after) + (goto-char (mark)) + (insert before))))) + (t + (insert before) + (save-excursion + (insert after)))))) + (advice-add 'TeX-font :override #'wilder/TeX-font) + #+end_src *** The hook #+begin_src emacs-lisp (add-hook 'LaTeX-mode-hook - (lambda () - (turn-on-reftex) + (lambda () + (turn-on-reftex) - (setq comment-column 0) - (setq prettify-symbols-alist nil) - (add-to-list 'prettify-symbols-alist '(" ⊂ " . (? (Br . Bl) ? (Br . Bl) ?))) + (setq comment-column 0) + (setq prettify-symbols-alist nil) + (add-to-list 'prettify-symbols-alist '(" ⊂ " . (? (Br . Bl) ? (Br . Bl) ?))) - (turn-on-auto-fill) - (subword-mode) - (TeX-fold-mode 1) - (outshine-mode))) + (turn-on-auto-fill) + (subword-mode) + (TeX-fold-mode 1) + (outshine-mode))) #+end_src *** Compilation fixes Load appropriate compliation filters for warnings #+begin_src emacs-lisp (load "latex-compile-filters.el") - #+end_src - Fix erroneous parsing of the LuaLaTeχ output "avail lists" as an - error (works on ≥ emacs-27.1) - #+begin_src emacs-lisp - (add-to-list 'compilation-transform-file-match-alist '(" avail lists" nil)) - #+end_src + #+end_src + Fix erroneous parsing of the LuaLaTeχ output "avail lists" as an + error (works on ≥ emacs-27.1) + #+begin_src emacs-lisp + (add-to-list 'compilation-transform-file-match-alist '(" avail lists" nil)) + #+end_src *** Load ~bibretrieve~ - #+begin_src emacs-lisp - (byte-recompile-directory "~/.emacs.d/bibretrieve" 0) - (load "bibretrieve") - (setq bibretrieve-backends '(("msn" . 10))) - (require 'biblio) - #+end_src + #+begin_src emacs-lisp + (byte-recompile-directory "~/.emacs.d/bibretrieve" 0) + (load "bibretrieve") + (setq bibretrieve-backends '(("msn" . 10))) + (require 'biblio) + #+end_src ** TODO KDE integration *** TODO cleanup and split These functions connects to dbus to find out the current activity id and name #+begin_src emacs-lisp (defun kde-current-activity () - "Returns the current KDE activity" - (substring (shell-command-to-string "qdbus org.kde.ActivityManager /ActivityManager/Activities org.kde.ActivityManager.Activities.CurrentActivity") 0 -1) - ) + "Returns the current KDE activity" + (substring (shell-command-to-string "qdbus org.kde.ActivityManager /ActivityManager/Activities org.kde.ActivityManager.Activities.CurrentActivity") 0 -1) + ) (defun kde-current-activity-name () - "Returns the name of the current KDE activity" - (substring (shell-command-to-string (concat "qdbus org.kde.ActivityManager /ActivityManager/Activities org.kde.ActivityManager.Activities.ActivityName " (kde-current-activity))) 0 -1)) + "Returns the name of the current KDE activity" + (substring (shell-command-to-string (concat "qdbus org.kde.ActivityManager /ActivityManager/Activities org.kde.ActivityManager.Activities.ActivityName " (kde-current-activity))) 0 -1)) #+end_src #+begin_src emacs-lisp (defun X-window-id-belongs-to-activity (window-id activity) - (= (shell-command (concat "xprop -id " window-id " | grep _KDE_NET_WM_ACTIVITIES | grep " activity ">/dev/null")) 0) - ) + (= (shell-command (concat "xprop -id " window-id " | grep _KDE_NET_WM_ACTIVITIES | grep " activity ">/dev/null")) 0) + ) (defun select-frame-on-activity (activity) - (setq framelist (frame-list)) - (setq done nil) - (while (and framelist (not done)) - (setq cur (car framelist)) - (setq cur-id (cdr (assq 'window-id (frame-parameters cur)))) - (if cur-id (if (X-window-id-belongs-to-activity cur-id activity) (progn; - (setq done 't) (select-frame cur)) )) - (setq framelist (cdr framelist))) - done - ) + (setq framelist (frame-list)) + (setq done nil) + (while (and framelist (not done)) + (setq cur (car framelist)) + (setq cur-id (cdr (assq 'window-id (frame-parameters cur)))) + (if cur-id (if (X-window-id-belongs-to-activity cur-id activity) (progn; + (setq done 't) (select-frame cur)) )) + (setq framelist (cdr framelist))) + done + ) (defun select-X-frame () - (setq framelist (frame-list)) - (setq done nil) - (while (and framelist (not done)) - (setq cur (car framelist)) - (setq cur-id (cdr (assq 'window-id (frame-parameters cur)))) - (if cur-id (progn; - (setq done 't) (raise-frame cur))) - (setq framelist (cdr framelist))) - done - ) + (setq framelist (frame-list)) + (setq done nil) + (while (and framelist (not done)) + (setq cur (car framelist)) + (setq cur-id (cdr (assq 'window-id (frame-parameters cur)))) + (if cur-id (progn; + (setq done 't) (raise-frame cur))) + (setq framelist (cdr framelist))) + done + ) #+end_src This function is used to raise the frame associated to the current activity *** TODO These entries should be added to the subtree once it is split #+begin_src emacs-lisp (defun select-frame-on-current-activity () - (select-frame-on-activity (kde-current-activity))) + (select-frame-on-activity (kde-current-activity))) #+end_src I prefer to keep one server for each KDE activity, so set the server name to be the name of the current activity #+begin_src emacs-lisp -; (setq server-name (kde-current-activity-name)) + ; (setq server-name (kde-current-activity-name)) #+end_src *** Journal Setup ~org-journal~ - #+begin_src emacs-lisp - (require 'org-journal) - (setq org-journal-dir "~/org/journal" - org-journal-file-type 'yearly - org-journal-file-format "%Y" - org-journal-encrypt-journal t) + #+begin_src emacs-lisp + (require 'org-journal) + (setq org-journal-dir "~/org/journal" + org-journal-file-type 'yearly + org-journal-file-format "%Y" + org-journal-encrypt-journal t) - #+end_src + #+end_src * Specialties ** beacon =beacon= is a package that helps finding the point when switching @@ -2308,9 +2314,9 @@ Silent offset warning "Takes a multi-line paragraph and makes it into a single line of text." (interactive (progn (barf-if-buffer-read-only) '(t))) (let ((fill-column (point-max)) - ;; This would override `fill-column' if it's an integer. - (emacs-lisp-docstring-fill-column t)) - (fill-paragraph nil region))) + ;; This would override `fill-column' if it's an integer. + (emacs-lisp-docstring-fill-column t)) + (fill-paragraph nil region))) #+end_src ** kill-word dwim manage space after kill-word. This has been morally pasted from @@ -2359,7 +2365,7 @@ Silent offset warning ** COMMENT gist Use [[https://github.com/defunkt/gist.el][gist.el]] #+begin_src emacs-lisp - (require 'gist) + (require 'gist) #+end_src * Main packages ** Magit @@ -2367,15 +2373,16 @@ Silent offset warning (require 'magit) (global-set-key (kbd "C-x g") 'magit-status) (magit-add-section-hook 'magit-status-sections-hook - #'magit-insert-modules-overview - #'magit-insert-unpushed-to-pushremote - :append) + #'magit-insert-modules-overview + #'magit-insert-unpushed-to-pushremote + :append) (magit-add-section-hook 'magit-status-sections-hook - #'magit-insert-untracked-files - #'magit-insert-modules-overview - :append) + #'magit-insert-untracked-files + #'magit-insert-modules-overview + :append) #+end_src *** magit-todos + #+begin_src emacs-lisp (require 'magit-todos) #+end_src @@ -2386,45 +2393,45 @@ Silent offset warning (global-smart-tab-mode 1) #+end_src ** Outshine - #+begin_src emacs-lisp - (defvar outline-minor-mode-prefix "\M-#") - (setq outshine-use-speed-commands t) - (with-eval-after-load 'outshine - (define-key outshine-mode-map (kbd "C-M-i") nil)) - (add-hook 'sh-mode-hook 'outshine-mode) - (require 'outshine) - (require 'outorg) - #+end_src - Cook up some extra narrowing function - #+begin_src emacs-lisp - (defun goto-next-comment-line () - (interactive) - (re-search-forward "^\\S<" nil 1) - (re-search-forward "^\\s<" nil 1) - (beginning-of-line) - ) + #+begin_src emacs-lisp + (defvar outline-minor-mode-prefix "\M-#") + (setq outshine-use-speed-commands t) + (with-eval-after-load 'outshine + (define-key outshine-mode-map (kbd "C-M-i") nil)) + (add-hook 'sh-mode-hook 'outshine-mode) + (require 'outshine) + (require 'outorg) + #+end_src + Cook up some extra narrowing function + #+begin_src emacs-lisp + (defun goto-next-comment-line () + (interactive) + (re-search-forward "^\\S<" nil 1) + (re-search-forward "^\\s<" nil 1) + (beginning-of-line) + ) - (defun goto-previous-comment-line () - (interactive) - (re-search-backward "^\\s<" nil 1 ) - (re-search-backward "^\\S<" nil 1 ) - (beginning-of-line) - (unless (bobp) (next-line)) - ) + (defun goto-previous-comment-line () + (interactive) + (re-search-backward "^\\s<" nil 1 ) + (re-search-backward "^\\S<" nil 1 ) + (beginning-of-line) + (unless (bobp) (next-line)) + ) - (defun narrow-between-comments () - (interactive) - (save-excursion - (next-line) - (goto-previous-comment-line) - (setq beginning (point))) - (save-excursion - (goto-next-comment-line) - (unless (bobp) (previous-line) (end-of-line)) - (setq ending (point))) - (narrow-to-region beginning ending)) + (defun narrow-between-comments () + (interactive) + (save-excursion + (next-line) + (goto-previous-comment-line) + (setq beginning (point))) + (save-excursion + (goto-next-comment-line) + (unless (bobp) (previous-line) (end-of-line)) + (setq ending (point))) + (narrow-to-region beginning ending)) - #+end_src + #+end_src ** helm #+begin_src emacs-lisp @@ -2453,12 +2460,12 @@ Silent offset warning nil 'helm-ff-delete-char-backward--exit-fn) (add-hook 'helm-after-initialize-hook 'fix-helm-margins) - #+end_src - Customize ~helm-mini~ adding bookmarks for files and dirs. This - is particularly useful to quickly open commonly accessed files - that I keep in the bookmarks. As an exercise, I wonder if we - could have per-server bookmarks. - #+begin_src emacs-lisp + #+end_src + Customize ~helm-mini~ adding bookmarks for files and dirs. This + is particularly useful to quickly open commonly accessed files + that I keep in the bookmarks. As an exercise, I wonder if we + could have per-server bookmarks. + #+begin_src emacs-lisp (setq helm-mini-default-sources '(helm-source-buffers-list helm-source-recentf @@ -2467,7 +2474,7 @@ Silent offset warning #+end_src Fix helm margins the bad way #+begin_src emacs-lisp - (defun helm-display-mode-line (source &optional force) + (defun helm-display-mode-line (source &optional force) "Set up mode-line and header-line for `helm-buffer'. SOURCE is a Helm source object. @@ -2545,18 +2552,18 @@ Silent offset warning (when force (force-mode-line-update))) #+end_src ** multiple-cursors - #+begin_src emacs-lisp - (require 'multiple-cursors) - (define-key mc/keymap (kbd "") nil) - (global-set-key-alist - '(("C->" . mc/mark-next-like-this) - ("C-<" . mc/mark-previous-like-this) - ("C-c C-<" . mc/mark-all-like-this) - ("C-c C-#" . mc/insert-numbers) - ("C-c C-\\" . mc/mark-all-dwim) - ("C-c " . mc/mark-pop) - ("C-c " . mc/mark-pop))) - #+end_src + #+begin_src emacs-lisp + (require 'multiple-cursors) + (define-key mc/keymap (kbd "") nil) + (global-set-key-alist + '(("C->" . mc/mark-next-like-this) + ("C-<" . mc/mark-previous-like-this) + ("C-c C-<" . mc/mark-all-like-this) + ("C-c C-#" . mc/insert-numbers) + ("C-c C-\\" . mc/mark-all-dwim) + ("C-c " . mc/mark-pop) + ("C-c " . mc/mark-pop))) + #+end_src ** =avy= and =avy-zap= These packages allow fast navigation and zapping #+begin_src emacs-lisp @@ -2595,16 +2602,16 @@ Silent offset warning (require 'erc-dcc) #+end_src ** vterm - #+begin_src emacs-lisp - (require 'vterm) - #+end_src + #+begin_src emacs-lisp + (require 'vterm) + #+end_src ** TODO Phase out Package.el Load package.el - #+begin_src emacs-lisp - (require 'package) - (add-to-list 'package-archives - '("melpa-stable" . "http://stable.melpa.org/packages/") t) - #+end_src + #+begin_src emacs-lisp + (require 'package) + (add-to-list 'package-archives + '("melpa-stable" . "http://stable.melpa.org/packages/") t) + #+end_src * Tidy-up ** Save emacs-session files in appropriate directory @@ -2623,42 +2630,42 @@ Silent offset warning #+end_src * Moving to colemak -Set up all possible combinations of modifiers - #+begin_src emacs-lisp - (defun concat-recursive (b &optional a) - (if b - (append (concat-recursive (cdr b) (concat a (car b))) - (concat-recursive (cdr b) a)) - (when a (list a)))) + Set up all possible combinations of modifiers + #+begin_src emacs-lisp + (defun concat-recursive (b &optional a) + (if b + (append (concat-recursive (cdr b) (concat a (car b))) + (concat-recursive (cdr b) a)) + (when a (list a)))) - (setq modifier-combo (concat-recursive '("C-" "M-" "s-" "H-"))) - #+end_src - Then list the swapped keys - #+begin_src emacs-lisp - (setq tarmak1-swap-alist '((?j . ?e) - (?e . ?k) - (?k . ?n) - (?n . ?j))) - (setq tarmak2-swap-alist '((?j . ?g) - (?g . ?t) - (?t . ?f) - (?f . ?e) - (?e . ?k) - (?k . ?n) - (?n . ?j))) - (setq tarmak3-swap-alist '((?j . ?r) - (?r . ?s) - (?s . ?d) - (?d . ?g) - (?g . ?t) - (?t . ?f) - (?f . ?e) - (?e . ?k) - (?k . ?n) - (?n . ?j))) - - (setq tarmak-current-swap-alist tarmak3-swap-alist) - #+end_src + (setq modifier-combo (concat-recursive '("C-" "M-" "s-" "H-"))) + #+end_src + Then list the swapped keys + #+begin_src emacs-lisp + (setq tarmak1-swap-alist '((?j . ?e) + (?e . ?k) + (?k . ?n) + (?n . ?j))) + (setq tarmak2-swap-alist '((?j . ?g) + (?g . ?t) + (?t . ?f) + (?f . ?e) + (?e . ?k) + (?k . ?n) + (?n . ?j))) + (setq tarmak3-swap-alist '((?j . ?r) + (?r . ?s) + (?s . ?d) + (?d . ?g) + (?g . ?t) + (?t . ?f) + (?f . ?e) + (?e . ?k) + (?k . ?n) + (?n . ?j))) + + (setq tarmak-current-swap-alist tarmak3-swap-alist) + #+end_src #+begin_src emacs-lisp (defun set-key-translation-map (pairs) @@ -2696,16 +2703,16 @@ Set up all possible combinations of modifiers (setq aw-keys (mapcar 'untarmak-key '(?j ?f ?g ?h ?k ?d ?l ?s ?a)) avy-keys (mapcar 'untarmak-key - '(?j ?f ?g ?h ?k ?d ?l ?s ?a)))) + '(?j ?f ?g ?h ?k ?d ?l ?s ?a)))) (defun qwerty() (interactive) (reset-key-translation-map)) -;; (untarmak-modifiers) + ;; (untarmak-modifiers) (tarmak-avy) - #+end_src + #+end_src * Finale ** Fixup faces This is really a workaround as I do not like either bold or italic. @@ -2723,6 +2730,6 @@ Set up all possible combinations of modifiers (add-hook 'gnus-art-load-hook #'wilder/fixup-faces) #+end_src ** Start server - #+begin_src emacs-lisp -; (server-start) - #+end_src + #+begin_src emacs-lisp + ; (server-start) + #+end_src