diff --git a/global.org b/global.org index 5e21ed6..1b2e454 100644 --- a/global.org +++ b/global.org @@ -1,7 +1,7 @@ -#+TITLE: emacs init file -#+AUTHOR: Jacopo De Simoi -#+EMAIL: jacopods@math.utoronto.ca -#+OPTIONS: *:t ::t +#+title: emacs init file +#+author: Jacopo De Simoi +#+email: jacopods@math.utoronto.ca +#+options: *:t ::t * TODO Make indentation uniform * TODO Look at tangling at @@ -31,13 +31,13 @@ replace them with git submodules * Files and dirs Move ~Customize~ to a separate file - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq custom-file "~/.emacs.d/custom.el") (load custom-file 'noerror) - #+END_SRC + #+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 + #+begin_src emacs-lisp (let ((default-directory "~/.emacs.d/")) (normal-top-level-add-subdirs-to-load-path) (normal-top-level-add-to-load-path '("biblio.el" @@ -48,37 +48,37 @@ "webpaste.el" "highlight-parentheses.el"))) - #+END_SRC + #+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 + #+begin_src emacs-lisp (make-directory "~/.emacs.d/autosaves/" t) (make-directory "~/.emacs.d/backup/" t) - #+END_SRC + #+end_src * Themes Use (my clone of) the solarized theme - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (add-to-list 'custom-theme-load-path "/home/jacopods/.emacs.d/emacs-color-theme-solarized") (load-theme 'lunarized t) - #+END_SRC + #+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 - #+BEGIN_SRC emacs-lisp + #+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") (set-face-font 'fixed-pitch-serif "-xos4-hackminus-medium-r-normal--20-200-72-72-c-100-ISO10646-1") (set-face-font 'variable-pitch "-xos4-hackminus-medium-r-normal--20-200-72-72-c-100-ISO10646-1") - #+END_SRC + #+end_src * Global settings ** Global helper functions This is a helper function used to set several global keys given in provided as a parameter in ~binding-alist~ - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun global-set-key-alist (binding-alist) "This function iterates over the binding-alist, which should be an alist of key and binding and sets each binding in the global-key-map" (mapcar @@ -90,102 +90,102 @@ (mapcar (lambda (binding) (define-key keymap (kbd (car binding)) (cdr binding))) binding-alist)) - #+END_SRC + #+end_src This is a hack to remove slant and bold from all faces - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun wilder/fixup-faces () (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")) - #+END_SRC + #+end_src ** Cosmetics Prefer a minimal appearance: no menu, toolbar or scroll-bars; no splash screens or messages - #+BEGIN_SRC emacs-lisp + #+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 + #+end_src a blinking cursor keeps the gpu awake; add global hl-line mode to more easily spot the cursor - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (blink-cursor-mode 0) (set-default 'cursor-type 'box) - #+END_SRC + #+end_src Set frame title - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq frame-title-format '((buffer-file-name "%f" (dired-directory dired-directory "%b")) " · emacs"));; · " (:eval (kde-current-activity-name)))) ;; "%S")) - #+END_SRC + #+end_src Themed tooltips - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq x-gtk-use-system-tooltips nil) - #+END_SRC + #+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 + #+begin_src emacs-lisp (setq default-fill-column 72) - #+END_SRC + #+end_src Highlight sexp (apparently I am not even using this) - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp ;(require 'highlight-sexps) - #+END_SRC + #+end_src Try to get along with large margins - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq-default left-margin-width 3 right-margin-width 3) (fringe-mode 10) ;(set-window-buffer nil (current-buffer)) - #+END_SRC + #+end_src ** Mouseless Disable mouse interaction with emacs - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (mouse-wheel-mode -1) (setq mouse-autoselect-window nil mouse-yank-at-point nil focus-follows-mouse nil mouse-highlight nil) - #+END_SRC + #+end_src *** 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 + #+begin_src emacs-lisp (require 'disable-mouse) (global-disable-mouse-mode) - #+END_SRC + #+end_src ** Window behavior Prevent compilation window eating up other windows - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq compilation-window-height 12 compilation-scroll-output nil) - #+END_SRC + #+end_src Prevent any automatic splitting to split vertically - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq split-height-threshold 0) - #+END_SRC + #+end_src ** Scrolling Scrolling setup - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq redisplay-dont-pause t scroll-margin 3 scroll-step 1 scroll-conservatively 10000 scroll-preserve-screen-position 1) - #+END_SRC + #+end_src *** TODO find out what this was actually meant to do - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq-default display-buffer-reuse-frames t) - #+END_SRC + #+end_src ** Mode-line - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq-default mode-line-modified '(:eval (if (buffer-modified-p) "●" "·")) ;Still needs some improvements, does not report Readonly state mode-line-remote '(:eval (let ((s (format-mode-line "%@"))) @@ -282,9 +282,9 @@ '("%e" mode-line-format-left mode-line-separator mode-line-format-right)) - #+END_SRC + #+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 + #+begin_src emacs-lisp (defvar mode-line-cleaner-alist `((auto-complete-mode . " α") (yas/minor-mode . " υ") @@ -332,29 +332,29 @@ (add-hook 'after-change-major-mode-hook 'clean-mode-line) - #+END_SRC + #+end_src ** Coding system Prefer the utf-8 coding system globally. This helps with the issue of magit not correctly staging hunks containing utf-8 characters. See [https://github.com/magit/magit/issues/32] - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (prefer-coding-system 'utf-8) - #+END_SRC + #+end_src ** Mark handling No transient mark is more flexible - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (transient-mark-mode 0) - #+END_SRC + #+end_src But of course we need to /see/ the mark - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'visible-mark) (visible-mark-mode t) (global-visible-mark-mode t) - #+END_SRC + #+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 + #+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." @@ -372,43 +372,43 @@ ("" . jump-to-mark) ("" . just-activate-mark) ("" . just-activate-mark))) - #+END_SRC + #+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 +#+begin_src emacs-lisp (mapcar (lambda (ch) (global-unset-key (kbd ch))) '("C-z" "C-x f" "" "C-M-u" "C-M-d" "C-x o" "C-SPC")) -#+END_SRC +#+end_src Change {up,down}-list -#+BEGIN_SRC emacs-lisp +#+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 +#+end_src Add some opinionated bindings -#+BEGIN_SRC emacs-lisp +#+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 +#+end_src ** Disable commands Enable narrow commands - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (put 'narrow-to-region 'disabled nil) (put 'LaTeX-narrow-to-environment 'disabled nil) (put 'narrow-to-page 'disabled nil) - #+END_SRC + #+end_src ** Smart beginning-of-line This is a relatively smart way to go back to the beginning of the line - #+BEGIN_SRC emacs-lisp + #+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 @@ -419,23 +419,23 @@ (when (eq pt (point)) (beginning-of-line)))) (global-set-key (kbd "C-a") 'smart-line-beginning) - #+END_SRC + #+end_src ** White-space Trailing whitespace is evil; get rid of it - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq-default show-trailing-whitespace t) (add-hook 'before-save-hook 'delete-trailing-whitespace) - #+END_SRC + #+end_src Define what is whitespace during a search - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq search-whitespace-regexp "[ \t\r\n]+") - #+END_SRC + #+end_src Tabs are evil; get rid of them - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq c-basic-offset 4) (setq-default tab-width 4 indent-tabs-mode nil) - #+END_SRC + #+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 @@ -443,26 +443,26 @@ ** Show matching parens Use ~show-paren~ for paren-highlighting - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (show-paren-mode 1) - #+END_SRC + #+end_src *** TODO find out if there are better options out there ** Load hydra -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (require 'hydra) -#+END_SRC +#+end_src ** Abbrevs Set up abbrevs - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq-default abbrev-mode t) (read-abbrev-file "~/.abbrev_defs") (setq save-abbrevs t) - #+END_SRC + #+end_src ** Spellcheck Use flyspell - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'flyspell-lazy) (flyspell-lazy-mode 1) (add-hook 'text-mode-hook 'flyspell-mode) @@ -474,50 +474,50 @@ (setq flyspell-before-incorrect-word-string (propertize "." 'display `((margin left-margin) ,(propertize "×" 'face 'flyspell-margin-incorrect)))) - #+END_SRC + #+end_src ** Fringe treatment *** TODO try linum-relative - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp ; (require 'linum-relative) ; (linum-relative-mode 1) - #+END_SRC + #+end_src Add line numbers globally - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp ; (global-linum-mode 1) - #+END_SRC + #+end_src Highlight also the linum in the fringe - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp ; (require 'hlinum) ; (hlinum-activate) - #+END_SRC + #+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 + #+begin_src emacs-lisp (require 'margin-current-line) (global-margin-current-line-mode 1) - #+END_SRC + #+end_src ** Turn on echo mode Display unfinished commands in the echo area after the specified delay. - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq echo-keystrokes 0.10) - #+END_SRC + #+end_src ** Disable completion buffer Remove the completion buffer as soon as we get out of the minibuffer - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (add-hook 'minibuffer-exit-hook '(lambda () (let ((buffer "*Completions*")) (and (get-buffer buffer) (kill-buffer buffer))) )) - #+END_SRC + #+end_src ** Auto save on compile - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq compilation-ask-about-save nil) - #+END_SRC + #+end_src ** Idle-kill - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun kill-buffers-on-idle () "Kill buffers that have the appropriate property set." (save-excursion @@ -529,9 +529,9 @@ (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 + #+begin_src emacs-lisp (add-hook 'calendar-load-hook (lambda () (calendar-set-date-style 'european))) @@ -540,19 +540,19 @@ calendar-location-name "Toronto, ON Canada" calendar-latitude 43.7 calendar-longitude -79.4) - #+END_SRC + #+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 +#+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 +#+end_src ** Indicator Change cursor color to reflect different layers on the keyboard This is the handler - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun xkbvleds-indicator-signal-handler (indicator on) (if on (cond ((string-equal indicator "Greek") @@ -560,9 +560,9 @@ ((string-equal indicator "Math") (set-face-background 'cursor "#cb4b16"))) (set-face-background 'cursor "#919191"))) - #+END_SRC + #+end_src Connect the signal from xkbvleds to the handler - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'dbus) ;; Register for the signal indicatorChanged coming from our service. It is ;; important that the =service= argument is =nil=, otherwise the registration @@ -570,10 +570,10 @@ (dbus-register-signal :session nil "/org/xkbvleds" "org.xkbvleds" "indicatorChanged" 'xkbvleds-indicator-signal-handler) - #+END_SRC + #+end_src ** Tarmak-ready Set up all possible combinations of modifiers - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun concat-recursive (b &optional a) (if b (append (concat-recursive (cdr b) (concat a (car b))) @@ -581,50 +581,50 @@ (when a (list a)))) (setq modifier-combo (concat-recursive '("C-" "M-" "s-" "H-"))) - #+END_SRC + #+end_src Then list the swapped keys - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq tarmak1-swaps '(("j" . "e") ("e" . "k") ("k" . "n") ("n" . "j"))) - #+END_SRC + #+end_src ** Transmission - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'transmission) (setq transmission-host "192.168.0.40") - #+END_SRC + #+end_src * Main major modes ** org-mode *** Require Require the ~org~ package; I also occasionally use org-pomodoro - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (with-eval-after-load "org" (define-key org-src-mode-map (kbd "C-c C-c") 'org-edit-src-exit) (define-key org-src-mode-map (kbd "C-c C-k") nil) ;this conflicts with my LaTeX bindings (define-key org-src-mode-map (kbd "C-c C-`") 'org-edit-src-abort)) (require 'org) (require 'org-pomodoro) - #+END_SRC + #+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 where I would not want to use this feature). Also, disable ~truncate-lines~ - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (add-hook 'org-mode-hook 'turn-on-auto-fill) (setq org-starting-truncated nil) - #+END_SRC + #+end_src *** Cosmetics Change the default ellipsis ~...~ to the unicode ellipsis ~…~ *Does not work properly* - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp ; (setq org-ellipsis "…") - #+END_SRC + #+end_src *** Ligatures These require a patched ~hackminus~ font. Too bad it does not work for some reason - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp ;; (defun delayed-org-prettify () ;; (prettify-symbols-mode 0) ;; (run-with-idle-timer 0 nil @@ -635,23 +635,23 @@ ;; (add-to-list 'prettify-symbols-alist '("****" . (? (Br . Bl) ? (Br . Bl) ? (Br . Bl) ?)))))) ;;(add-hook 'org-mode-hook 'delayed-org-prettify) - #+END_SRC + #+end_src *** Links Open links with external stuff - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq org-file-apps '((auto-mode . emacs) ("\\.x?html?\\'" . "xdg-open %s") ("\\.pdf\\'" . "xdg-open \"%s\""))) - #+END_SRC + #+end_src *** Agenda Set the canonical binding for the agenda - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (global-set-key (kbd "C-c a") 'org-agenda) - #+END_SRC + #+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 + #+begin_src emacs-lisp (setq org-agenda-files '("~/org/master.org" "~/org/next.org" @@ -661,38 +661,38 @@ "~/org/orgzly/live.org" "~/org/orgzly/library.org" "~/org/orgzly/refile.org")) - #+END_SRC + #+end_src Default to daily agenda - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq org-agenda-span 1) - #+END_SRC + #+end_src Prevent headlines to be marked as DONE if some sub-headings are still TODO. - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq org-enforce-todo-dependencies t) - #+END_SRC + #+end_src Do not show scheduled or deadline'd stuff in the Global TODO list - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq org-agenda-todo-ignore-deadlines 'all org-agenda-todo-ignore-scheduled 'all) - #+END_SRC + #+end_src Do not show stuff marked with DONE even if they have a deadline - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq org-agenda-skip-deadline-if-done t) - #+END_SRC + #+end_src Custom separator - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq org-agenda-block-separator ?─) - #+END_SRC + #+end_src Turn on speed keys - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq org-use-speed-commands t) - #+END_SRC + #+end_src Ideally I should tag some tasks as “break” tasks, which are suitable to be taken care of during a pomodoro break. Such tasks should be marked with tags ~:5m:~ and ~:20m:~ according to the estimate on the time it would take to take care of them - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq org-agenda-custom-commands '( ("a" "Main agenda" @@ -708,9 +708,9 @@ ((agenda "") (tags-todo "5m") (tags-todo "20m"))))) - #+END_SRC + #+end_src Custom agenda view - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun org-agenda-prepare (&optional name) (let ((filter-alist (if org-agenda-persistent-filter (with-current-buffer @@ -779,14 +779,14 @@ (add-hook 'org-agenda-mode-hook (lambda () (setq truncate-lines t))) - #+END_SRC + #+end_src *** Automate saving This will take care of most of the other stuff - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (add-hook 'auto-save-hook 'org-save-all-org-buffers) - #+END_SRC + #+end_src *** Reverting stuff from orgzly - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun org-revert-all-orgzly-buffers (&optional ALL) "Revert all Org buffers that are sitting in orgzly Prompt for confirmation when there are unsaved changes. Be sure @@ -804,15 +804,15 @@ (revert-buffer t 'no-confirm))))) (org-agenda-redo-all)) (define-key org-agenda-mode-map (kbd "Z") 'org-revert-all-orgzly-buffers) - #+END_SRC + #+end_src *** Capture Set default keybinding - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (global-set-key (kbd "C-c c") 'org-capture) - #+END_SRC + #+end_src This is my capture template: it needs to be revised as I really do not use The Idea, journal and break entry - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq org-default-notes-file "~/org/master.org") (setq org-capture-templates '(("t" "TODO today" entry (file+headline "~/org/master.org" "Tasks") @@ -831,9 +831,9 @@ "* DONE mailto:%?") ("r" "Reply to" entry (file+headline "~/org/master.org" "E-mails") "* DONE mailto:%?"))) - #+END_SRC + #+end_src *** LaTeX export -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp ; (add-to-list 'org-latex-classes ; '("amsart" "\\documentclass[11pt]{amsart}" ; ("\\section{%s}" . "\\section*{%s}") @@ -841,7 +841,7 @@ ; ("\\subsubsection{%s}" . "\\subsubsection*{%s}") ; ("\\paragraph{%s}" . "\\paragraph*{%s}") ; ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) -#+END_SRC +#+end_src *** Source blocks Add template for a source block in a few selected languages; for now I have @@ -851,18 +851,18 @@ or dotfiles for other code. Since Org 9.2, the behavior that I grew accustomed to (e.g. ~", "#+FOO". (while (re-search-forward "\\(?1:#\\+[A-Z_]+\\(?:_[[:alpha:]]+\\)*\\)\\(?:[ :=~’”]\\|$\\)" nil :noerror) (setq count (1+ count)) @@ -890,7 +890,7 @@ (message "Lower-cased %d matches" count)))) #+end_src *** Clocking - #+BEGIN_SRC emacs-lisp + #+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 @@ -905,11 +905,11 @@ (setq org-duration-format 'h:mm) (setq org-clock-clocktable-default-properties '(:maxlevel 2 :scope subtree)) (org-clock-persistence-insinuate) - #+END_SRC + #+end_src *** Tangle to different files 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 + #+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." @@ -970,9 +970,9 @@ (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 + #+end_src *** Append tangle - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun org-babel-tangle-append (filename) "Append source code block at point to its tangle file. The command works like `org-babel-tangle' with prefix arg @@ -980,11 +980,11 @@ (interactive) (cl-letf (((symbol-function 'delete-file) #'ignore)) (org-babel-tangle '(4) filename))) - #+END_SRC + #+end_src *** Tangle 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 + #+begin_src emacs-lisp (defun tangle-file(&rest files nokill) "Tangle FILES or all files in the project." (when (null files) @@ -994,11 +994,11 @@ (org-babel-tangle) ; (unless nokill (kill-buffer)) ))) - #+END_SRC + #+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 + #+begin_src emacs-lisp (defun export-org-file-pdf(&rest files nokill) "Export FILES or all files in the project." (when (null files) @@ -1007,25 +1007,25 @@ (with-current-buffer (find-file-noselect file) (org-latex-export-to-pdf) (kill-buffer)))) - #+END_SRC + #+end_src *** Crypto stuff - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'org-crypt) (org-crypt-use-before-save-magic) (setq org-tags-exclude-from-inheritance (quote ("crypt"))) (setq org-crypt-key "C86A9E7675295C62") - #+END_SRC + #+end_src *** ox-export Load ox-hugo -#+BEGIN_SRC emacs-lisp +#+begin_src emacs-lisp (with-eval-after-load 'ox (require 'ox-hugo)) -#+END_SRC +#+end_src ** elisp *** Paredit - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (autoload 'enable-paredit-mode "paredit" "Turn on pseudo-structural editing of Lisp code." t) (add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode) @@ -1061,10 +1061,10 @@ ("f" (progn (paredit-backward-barf-sexp) (hydra-paren/hl-paren-force-fix)) "barf backward"))) - #+END_SRC + #+end_src *** Replace last sexp I use this a lot to evaluate (e.g.) quick computations in files - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun replace-last-sexp () (interactive) (let ((value (eval (preceding-sexp)))) @@ -1072,16 +1072,16 @@ (insert (format "%S" value)))) (global-set-key (kbd "C-c C-x C-e") #'replace-last-sexp) - #+END_SRC + #+end_src ** qml Load ~qml-mode~ - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (autoload 'qml-mode "qml-mode.el" t) (add-to-list 'auto-mode-alist '("\\.qml\\'" . qml-mode)) - #+END_SRC + #+end_src ** C and C++ *** Hooks - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp ;; (require 'doxymacs) (add-hook 'c-mode-hook @@ -1094,10 +1094,10 @@ (subword-mode) (doxymacs-mode) (define-key c++-mode-map (kbd "C-c C-c") 'make))) - #+END_SRC + #+end_src ** TODO split --- LaTeX *** TODO Setup ~reftex~ - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (with-eval-after-load "reftex" (setq reftex-cite-format "~\\cite{%l}" reftex-plug-into-AUCTeX '(t t nil t t) @@ -1117,9 +1117,9 @@ (setq mode-name (replace-regexp-in-string "/" "·" mode-name))) (advice-add 'TeX-set-mode-name :after 'cleanup-TeX-mode)) - #+END_SRC + #+end_src *** Setup ~latex-mode~ - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (eval-after-load 'latex '(progn (font-lock-add-keywords 'latex-mode @@ -1185,44 +1185,44 @@ (setq subword-forward-regexp "\\W*\\(\\([\\\\[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)") (setq subword-backward-regexp "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([\\\\[:upper:]]+\\W*\\)\\|\\W\\w+\\)"))) - #+END_SRC + #+end_src *** Require Load auctex, reftex and set up related hooks - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'tex-site) (require 'reftex) - #+END_SRC + #+end_src *** Set default TeX options - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq-default TeX-master nil) (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 + #+begin_src emacs-lisp (setq font-latex-fontify-script nil) - #+END_SRC + #+end_src Add unicode quotes to the quote-list - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp ; (defvar font-latex-quote-list '(("``" "''") ("“" "”") ("<<" ">>" french) ("«" "»" french)) ; - #+END_SRC + #+end_src Redefine fold ellipsis - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq TeX-fold-ellipsis " …") - #+END_SRC + #+end_src *** Default labels - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (setq LaTeX-equation-label "e_" LaTeX-section-label "s_" LaTeX-figure-label "f_") - #+END_SRC + #+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 + #+begin_src emacs-lisp (setq ispell-tex-skip-alists (list (append @@ -1234,12 +1234,12 @@ ("\\\\include" ispell-tex-arg-end) )) (cadr ispell-tex-skip-alists))) - #+END_SRC + #+end_src *** Specialty functions This function adds a pair of delimiters or surrounds the active region with the given delimiters. TODO it breaks when there is no mark - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun add-delimiter (delim-begin delim-end r-begin r-end) "Add the pair of delimiters given in delim at the ends of the region if it is activated" @@ -1255,10 +1255,10 @@ (save-excursion (insert delim-end)) (insert delim-begin)))) - #+END_SRC + #+end_src The following re-implements =TeX-insert-braces= to work with negative argument - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun TeX-insert-braces (arg) "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 @@ -1291,15 +1291,15 @@ (interactive "P") (if arg (TeX-insert-braces (- 0 arg)) (insert TeX-grcl))) - #+END_SRC + #+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 + #+begin_src emacs-lisp (defun dabbrev-expand-helper () (interactive) (call-interactively 'dabbrev-expand)) - #+END_SRC + #+end_src This inserts a char adding some whitespace padding whenever necessary - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun insert-char-with-padding (arg) (interactive "*P") (unless (string-match (string (preceding-char)) " \&") @@ -1307,33 +1307,33 @@ (self-insert-command (prefix-numeric-value arg)) (unless (char-equal (following-char) ?\s) (insert " "))) ;; decide what to do with the point - #+END_SRC + #+end_src This function opens a line and indents it - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun wilder/open-line-and-indent (arg) "This function opens a line using (open-line) and indents it" (interactive "p") (open-line arg) (save-excursion (forward-char arg) (unless (eolp) (indent-according-to-mode)))) - #+END_SRC + #+end_src This inserts a plain reference (or a reference to an equation with prefix arg) - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun wilder/TeX-insert-reference (arg) (interactive "P") (insert "~") (if arg (TeX-insert-macro "eqref") (TeX-insert-macro "ref"))) - #+END_SRC + #+end_src This inserts a citation - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun wilder/TeX-insert-cite (arg) (interactive "P") (insert "~") (TeX-insert-macro "cite")) - #+END_SRC + #+end_src This inserts an ~align~ environment (or an ~align*~ with prefix arg) - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun wilder/TeX-insert-align (arg) (interactive "P") (if arg @@ -1350,24 +1350,24 @@ ((string-equal "equation" why) (LaTeX-modify-environment "align")) ((string-equal "align*" why) (when arg (LaTeX-modify-environment "align"))))) (wilder/TeX-insert-align arg))) - #+END_SRC + #+end_src This replaces horizontal space with a tilde - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun wilder/TeX-replace-tilde (arg) (interactive "P") (delete-horizontal-space) (insert "~")) - #+END_SRC + #+end_src Insert a todonote at point or wrap the region in a todonote. - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun wilder/TeX-insert-todonote (arg r-begin r-end) (interactive "P\nr") (if arg (add-delimiter "{\\todo[inline]{" "}}" r-begin r-end) (add-delimiter "{\\todo{" "}}" r-begin r-end))) - #+END_SRC + #+end_src Promote inline math to an align - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun wilder/char-punctuation-p (ch) "returns t if the char is a punctuation" (interactive) @@ -1389,9 +1389,9 @@ (wilder/TeX-insert-align arg) (pop-mark) (pop-mark)))) - #+END_SRC + #+end_src Shadow the AucTeX version of this function - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun LaTeX-insert-environment (environment &optional extra) "Insert LaTeX ENVIRONMENT with optional argument EXTRA." (let ((active-mark (and (TeX-active-mark) (not (eq (mark) (point))))) @@ -1486,13 +1486,13 @@ (match-beginning 0))) (run-hook-with-args 'LaTeX-after-insert-env-hooks environment env-start env-end))) - #+END_SRC + #+end_src *** Patch auctex I don't particularly like the way that the prefix arguments works 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 +#+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 @@ -1546,9 +1546,9 @@ (save-excursion (insert after)))))) (advice-add 'TeX-font :override #'wilder/TeX-font) -#+END_SRC +#+end_src *** The hook - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (add-hook 'LaTeX-mode-hook (lambda () (turn-on-reftex) @@ -1561,23 +1561,23 @@ (subword-mode) (TeX-fold-mode 1) (outshine-mode))) - #+END_SRC + #+end_src *** Load compilation filters - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (load "latex-compile-filters.el") - #+END_SRC + #+end_src *** Load ~bibretrieve~ - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (byte-recompile-directory "~/.emacs.d/bibretrieve" 0) (load "bibretrieve") (setq bibretrieve-backends '(("msn" . 10))) (require 'biblio) - #+END_SRC + #+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 + #+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) @@ -1585,9 +1585,9 @@ (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)) - #+END_SRC + #+end_src - #+BEGIN_SRC emacs-lisp + #+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) ) @@ -1615,22 +1615,22 @@ (setq framelist (cdr framelist))) done ) - #+END_SRC + #+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 + #+begin_src emacs-lisp (defun select-frame-on-current-activity () (select-frame-on-activity (kde-current-activity))) - #+END_SRC + #+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 + #+begin_src emacs-lisp ; (setq server-name (kde-current-activity-name)) - #+END_SRC + #+end_src *** Journal Setup ~org-journal~ - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'org-journal) (setq org-journal-dir "~/org/journal" org-journal-file-type 'yearly @@ -1638,7 +1638,7 @@ org-journal-encrypt-journal t) - #+END_SRC + #+end_src * Specialties ** beacon =beacon= is a package that helps finding the point when switching @@ -1648,7 +1648,7 @@ This function is defined to help in training with new keybindings. It acts as a visual bell which flashes the current line. It is (arbitrarily) bound to F15 which is supposed to be triggered by some “illegal” key hit - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun flash-hline () "Flash the current line to emph some mistake" (interactive) @@ -1660,11 +1660,11 @@ (set-face-background 'hl-line "#303030") )))) (global-set-key (kbd "") 'flash-hline) - #+END_SRC + #+end_src ** unfill-paragraph This is authored by Stefan Monnier . It is the opposite of fill-paragraph - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun unfill-paragraph (&optional region) "Takes a multi-line paragraph and makes it into a single line of text." (interactive (progn (barf-if-buffer-read-only) '(t))) @@ -1672,12 +1672,12 @@ ;; This would override `fill-column' if it's an integer. (emacs-lisp-docstring-fill-column t)) (fill-paragraph nil region))) - #+END_SRC + #+end_src ** kill-word dwim manage space after kill-word. This has been morally pasted from [[https://www.reddit.com/r/emacs/comments/3nlws0/automanage_spaces_post_word_kills/][this reddit post]]. The original version does not allow for double spaces after a period. - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun modi/just-one-space-post-kill-word (&rest _) "Function to manage white space after `kill-word' operations. @@ -1707,24 +1707,24 @@ )))) ;; Delete extra horizontal white space after `kill-word' and `backward-kill-word' (advice-add 'kill-word :after #'modi/just-one-space-post-kill-word) - #+END_SRC + #+end_src - #+RESULTS: + #+results: ** word-count Add word count in modeline; useful to prepare those pesky grant applications - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'word-count) - #+END_SRC + #+end_src ** gist Use [[https://github.com/defunkt/gist.el][gist.el]] - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'gist) - #+END_SRC + #+end_src * Main packages ** Magit - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'magit) (global-set-key (kbd "C-x C-g") 'magit-status) (magit-add-section-hook 'magit-status-sections-hook @@ -1735,19 +1735,19 @@ #'magit-insert-untracked-files #'magit-insert-modules-overview :append) - #+END_SRC + #+end_src *** magit-todos - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'magit-todos) - #+END_SRC + #+end_src ** smart-tab This package is a gem: it allows to make tab work dwim - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'smart-tab) (global-smart-tab-mode 1) - #+END_SRC + #+end_src ** Outshine - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defvar outline-minor-mode-prefix "\M-#") (setq outshine-use-speed-commands t) (with-eval-after-load 'outshine @@ -1755,9 +1755,9 @@ (add-hook 'sh-mode-hook 'outshine-mode) (require 'outshine) (require 'outorg) - #+END_SRC + #+end_src Cook up some extra narrowing function - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun goto-next-comment-line () (interactive) (re-search-forward "^\\S<" nil 1) @@ -1785,10 +1785,10 @@ (setq ending (point))) (narrow-to-region beginning ending)) - #+END_SRC + #+end_src ** helm - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'helm-config) (helm-mode 1) @@ -1808,9 +1808,9 @@ '(([C-c DEL] . helm-ff-run-toggle-auto-update)) nil 'helm-ff-delete-char-backward--exit-fn) (add-hook 'helm-after-initialize-hook 'fix-helm-margins) - #+END_SRC + #+end_src ** multiple-cursors - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'multiple-cursors) (define-key mc/keymap (kbd "") nil) (global-set-key-alist @@ -1821,10 +1821,10 @@ ("C-c C-\\" . mc/mark-all-dwim) ("C-c " . mc/mark-pop) ("C-c " . mc/mark-pop))) - #+END_SRC + #+end_src ** =avy= and =avy-zap= These packages allow fast navigation and zapping - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'avy-zap) (avy-setup-default) (global-set-key-alist @@ -1849,36 +1849,36 @@ ; (add-to-list 'avy-styles-alist '(ace-link-org . at-full)) (define-key org-mode-map (kbd "C-c M-o") 'ace-link-org) (define-key org-agenda-mode-map (kbd "C-c M-o") 'ace-link-org) - #+END_SRC + #+end_src ** expand-region This is an excellent package, although I do not use it that much I should find a better binding - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'expand-region) (global-set-key (kbd "C-=") 'er/expand-region) - #+END_SRC + #+end_src ** ERC Enable ~erc dcc~ files transfer - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'erc-dcc) - #+END_SRC + #+end_src ** vterm - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'vterm) - #+END_SRC + #+end_src ** TODO Phase out Package.el Load package.el - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (require 'package) (add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/") t) - #+END_SRC + #+end_src * Tidy-up ** Save emacs-session files in appropriate directory Save session files to the ~sessions~ directory so that they do not litter the ~.emacs.d~ base directory. - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp (defun emacs-session-filename (session-id) "Construct a filename to save the session in based on SESSION-ID. If the directory ~/.emacs.d exists, we make a filename in there, otherwise @@ -1888,7 +1888,7 @@ (expand-file-name (if (file-directory-p emacs-dir) (concat emacs-dir basename) (concat "~/.emacs-" basename))))) - #+END_SRC + #+end_src * Finale ** Fixup faces @@ -1897,15 +1897,15 @@ packages that have loaded in the meantime; yet it does not work perfectly as some packages are still to be loaded (most notably ~magit~) - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp ;; (set-face-font 'default "-xos4-hackminus-medium-r-normal--20-200-72-72-c-100-ISO10646-1") (set-face-bold 'bold nil) (wilder/fixup-faces) (with-eval-after-load "info" (wilder/fixup-faces) nil) (with-eval-after-load "vterm" (wilder/fixup-faces) nil) - #+END_SRC + #+end_src ** Start server - #+BEGIN_SRC emacs-lisp + #+begin_src emacs-lisp ; (server-start) - #+END_SRC + #+end_src