1 #+PROPERTY: header-args:emacs-lisp :tangle don-configuration.el
7 To look up options for symbols for delight, check out https://en.wikipedia.org/wiki/Emoji#Unicode_blocks
11 # if for some reason, things get pear-shaped, we want to be able to
12 # enter the debugger by sending -USR2 to emacs
14 #+BEGIN_SRC emacs-lisp
15 (setq debug-on-event 'siguser2)
19 #+BEGIN_SRC emacs-lisp
20 (add-to-list 'exec-path '"/usr/local/bin")
21 (add-to-list 'exec-path '"~/bin/")
24 #+BEGIN_SRC emacs-lisp
25 (let ((default-directory "~/lib/emacs_el/"))
26 (normal-top-level-add-subdirs-to-load-path))
28 ;; (let ((default-directory "~/var/emacs/elpa"))
29 ;; (normal-top-level-add-subdirs-to-load-path))
31 (add-to-list 'load-path '"~/lib/emacs_el")
32 (setq package-user-dir "~/var/emacs/elpa")
35 * Initial startup stuff
36 ** Disable startup screen
37 #+BEGIN_SRC emacs-lisp
38 (setq inhibit-startup-screen t)
41 #+BEGIN_SRC emacs-lisp
42 ; (if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
43 (if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
44 (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
47 #+BEGIN_SRC emacs-lisp
48 (setq frame-resize-pixelwise t)
49 (add-to-list 'default-frame-alist '(fullscreen . maximixed))
52 ** Bootstrap straight.el
53 #+BEGIN_SRC emacs-lisp
54 (defvar bootstrap-version)
55 (setq straight-base-dir '"~/var/emacs/")
57 (expand-file-name "straight/repos/straight.el/bootstrap.el" straight-base-dir))
58 (bootstrap-version 6))
59 (unless (file-exists-p bootstrap-file)
61 (url-retrieve-synchronously
62 "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
63 'silent 'inhibit-cookies)
64 (goto-char (point-max))
65 (eval-print-last-sexp)))
66 (load bootstrap-file nil 'nomessage))
68 ** package repositories and package manager
69 #+BEGIN_SRC emacs-lisp
70 (straight-use-package 'use-package)
71 (setq straight-use-package-by-default t)
72 (setq use-package-verbose (not (bound-and-true-p byte-compile-current-file)))
74 (add-to-list 'gnutls-trustfiles "/etc/ssl/ca-global/ca-certificates.crt")
77 #+BEGIN_SRC emacs-lisp
80 :commands (paradox-upgrade-packages paradox-list-packages)
82 (setq paradox-execute-asynchronously t)
83 (setq paradox-github-token t) ; I don't want to be prompted about this integration
87 #+BEGIN_SRC emacs-lisp
88 ;; Set the custom file to /dev/null and don't bother to load it
89 (setq custom-file "/dev/null")
93 #+BEGIN_SRC emacs-lisp
94 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
95 ;; execute conditional code when loading libraries
96 ; (defmacro with-library (symbol &rest body)
97 ; `(when (require ,symbol nil t)
99 ; (put 'with-library 'lisp-indent-function 1)
103 ** Safe Local Variables
104 #+BEGIN_SRC emacs-lisp
105 (setq safe-local-variable-values
106 (quote ((auto-save-default)
108 (cperl-indent-level . 4)
110 (indent-tabs-mode . f)
111 (vcl-indent-level . 4)
115 #+BEGIN_SRC emacs-lisp
116 (setq global-mark-ring-max 128
120 (defun don/minibuffer-setup-hook ()
121 (setq gc-cons-threshold most-positive-fixnum))
123 (defun don/minibuffer-exit-hook ()
124 (setq gc-cons-threshold 1048576))
126 (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
127 (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
131 #+BEGIN_SRC emacs-lisp
132 (use-package tree-sitter
135 (global-tree-sitter-mode)
137 (use-package tree-sitter-langs
142 ; (defun dla/python-function-at-point ()
143 ; "Return a list of function arguments
145 ; Borrowed from https://xenodium.com/emacs-generate-a-swift-initializer/
148 ; (cl-assert (seq-contains-p local-minor-modes 'tree-sitter-mode) "tree-sitter-mode not enabled")
149 ; (let* ((node (tree-sitter-node-at-point 'function_definition)
155 ; (error "Not in function"))
158 ; (cond ((eq 'func_name
161 ; ; (setq args (append args (list arg)))
163 ; (setq arg (list (cons 'function (tsc-node-text
167 ; (setq arg (map-insert arg 'ident (tsc-node-text
171 ; (setq arg (map-insert arg 'ident_type (tsc-node-text
175 ; (setq arg (map-insert arg 'ret_type (tsc-node-text
178 ; (tsc-query-captures
179 ; (tsc-make-query tree-sitter-language
180 ; "(function_definition (identifier) @func_name (parameters [(identifier) @ident (typed_parameter (identifier) @ident (type) @ident_type)]) (type)? @ret_type)")
181 ; (tree-sitter-node-at-point 'function_definition) nil))
183 ; (setq args (append args (list arg))))
189 #+BEGIN_SRC emacs-lisp
190 (use-package spacemacs-theme
192 (load-theme 'spacemacs-dark t)
196 #+BEGIN_SRC emacs-lisp
197 (use-package hippie-exp
198 :bind* (("M-<SPC>" . hippie-expand))
202 #+BEGIN_SRC emacs-lisp
203 (use-package flyspell
204 ; :delight flyspell-mode 🐝
206 (setq flyspell-mode-line-string " 🐝")
207 (add-hook 'text-mode-hook 'turn-on-flyspell)
208 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
209 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
210 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
212 (setq ispell-program-name "ispell")
217 #+begin_src emacs-lisp :tangle yes
218 (use-package flycheck
220 :if (version<= "24.4" emacs-version)
221 :commands flycheck-mode
222 :hook ((prog-mode . flycheck-mode)
226 (use-package flycheck-tip
227 :commands 'flycheck-tip-cycle
229 :bind (:map flycheck-mode-map
230 ("C-c C-n" . flycheck-tip-cycle)))
232 (use-package flycheck-package)
234 (use-package flycheck-checkpatch
235 :config (flycheck-checkpatch-setup)
236 :config (setq flycheck-checkers (delete 'checkpatch
238 :config (add-to-list 'flycheck-checkers 'checkpatch t))
242 #+BEGIN_SRC emacs-lisp
248 #+BEGIN_SRC emacs-lisp
253 #+BEGIN_SRC emacs-lisp
254 (use-package eyebrowse
256 :delight eyebrowse-mode
257 :init (setq eyebrowse-keymap-prefix (kbd "C-c e"))
259 (setq eyebrowse-wrap-around t)
262 (defun my/eyebrowse-new-window-config ()
266 ;; start at 1 run till 0
267 (let ((j (mod (+ i 1) 10)))
268 (when (and (not done)
269 (not (eyebrowse--window-config-present-p j)))
270 (eyebrowse-switch-to-window-config j)
271 (call-interactively 'eyebrowse-rename-window-config2 j)
276 ;; I don't use latex-preview-pane
277 ;; (require 'latex-preview-pane)
278 ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
279 ;; ;; latex-preview-pane uses window-parameters which are
280 ;; ;; not preserved by eyebrowse, so we close the preview
281 ;; ;; pane before switching, it will be regenerated when we
282 ;; ;; edit the TeX file.
283 ;; (when (lpp/window-containing-preview)
284 ;; (delete-window (lpp/window-containing-preview))))
286 ;; (add-to-list 'eyebrowse-pre-window-switch-hook
287 ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
289 ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
290 ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
291 ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
292 ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
293 ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
301 #+BEGIN_SRC emacs-lisp
302 (defun my/vsplit-last-buffer ()
303 "Split the window vertically and display the previous buffer."
305 (split-window-vertically)
307 (switch-to-next-buffer))
309 (defun my/hsplit-last-buffer ()
310 "Split the window horizontally and display the previous buffer."
312 (split-window-horizontally)
314 (switch-to-next-buffer))
316 (bind-key "C-x 2" 'my/vsplit-last-buffer)
317 (bind-key "C-x 3" 'my/hsplit-last-buffer)
319 (setq split-width-threshold 100)
320 (setq split-height-threshold 60)
322 (defun my/split-window-prefer-vertically (window)
323 "If there's only one window (excluding any possibly active
324 minibuffer), then split the current window horizontally."
325 (if (and (one-window-p t)
326 (not (active-minibuffer-window))
327 ( < (frame-width) (frame-height))
329 (let ((split-width-threshold nil))
330 (split-window-sensibly window))
331 (split-window-sensibly window)))
333 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
334 (setq window-combination-resize t)
337 *** Compilation window
339 If there is no compilation window, open one at the bottom, spanning
340 the complete width of the frame. Otherwise, reuse existing window. In
341 the former case, if there was no error the window closes
344 #+BEGIN_SRC emacs-lisp
345 (add-to-list 'display-buffer-alist
346 `(,(rx bos "*compilation*" eos)
347 (display-buffer-reuse-window
348 display-buffer-in-side-window)
349 (reusable-frames . visible)
351 (window-height . 0.4)))
354 #+BEGIN_SRC emacs-lisp
355 (defun my/compilation-exit-autoclose (status code msg)
356 ;; If M-x compile exists with a 0
357 (when (and (eq status 'exit) (zerop code))
358 ;; and delete the *compilation* window
359 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
360 (when (and (not (window-at-side-p compilation-window 'top))
361 (window-at-side-p compilation-window 'left)
362 (window-at-side-p compilation-window 'right))
363 (delete-window compilation-window))))
364 ;; Always return the anticipated result of compilation-exit-message-function
367 ;; Specify my function (maybe I should have done a lambda function)
368 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
371 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
372 value, the compilation buffer scrolls automatically to follow the
373 output. If the value is ~first-error~, scrolling stops when the first
374 error appears, leaving point at that error. For any other non-nil
375 value, scrolling continues until there is no more output.
377 #+BEGIN_SRC emacs-lisp
378 (setq compilation-scroll-output 'first-error)
381 ** Mode line cleaning
383 #+BEGIN_SRC emacs-lisp
390 #+BEGIN_SRC emacs-lisp
392 :if (>= emacs-major-version 25)
394 :bind (("C-c C-<SPC>" . avy-goto-word-or-subword-1)
395 ("C-c j j" . avy-goto-word-or-subword-1)
396 ("M-g g" . avy-goto-line))
397 :config (progn (setq avy-background t))
400 *** Ace-link (jumping to links)
401 #+BEGIN_SRC emacs-lisp
402 (use-package ace-link
404 ; bind o in most modes
405 :config (ace-link-setup-default))
407 *** Jumping through edit points (goto-chg)
408 #+BEGIN_SRC emacs-lisp
409 (use-package goto-chg
411 :bind (("C-c j ," . goto-last-change)
412 ("C-c j ." . goto-last-change-reverse))
415 *** Jumping to bookmarks (visible bookmarks, bm)
416 #+BEGIN_SRC emacs-lisp
419 :bind (("C-c j b ." . bm-next)
420 ("C-c j b ," . bm-previous)
421 ("C-c j b SPC" . bm-toggle)))
426 #+BEGIN_SRC emacs-lisp
427 (use-package yasnippet
429 :delight yas-minor-mode
432 (setq yas-verbosity 1)
433 (define-key yas-minor-mode-map (kbd "<tab>") nil)
434 (define-key yas-minor-mode-map (kbd "TAB") nil)
435 (define-key yas-minor-mode-map (kbd "<backtab>") nil)
436 (setq yas-snippet-dirs '("~/lib/emacs_el/snippets/"
437 "~/lib/emacs_el/yasnippet-snippets/snippets/"))
438 (add-to-list 'hippie-expand-try-functions-list
439 'yas-hippie-try-expand)
445 #+BEGIN_SRC emacs-lisp
446 (use-package auto-yasnippet
448 :bind (("H-w" . aya-create)
453 ** Treemacs: Tree file viewer
454 #+BEGIN_SRC emacs-lisp
455 ;; Provides workspaces with file browsing (tree file viewer)
456 ;; and project management when coupled with `projectile`.
458 ; (use-package treemacs
462 ; (setq treemacs-no-png-images t
464 ; :bind ("C-c t" . treemacs))
467 #+BEGIN_SRC emacs-lisp
468 (use-package lsp-mode
470 :commands (lsp lsp-deferred)
471 :init (setq lsp-keymap-prefix "C-c l")
472 (defun my/orderless-dispatch-flex-first (_pattern index _total)
473 (and (eq index 0) 'orderless-flex))
475 (defun my/lsp-mode-setup-completion ()
476 (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
479 ;; Optionally configure the first word as flex filtered.
480 (add-hook 'orderless-style-dispatchers #'my/orderless-dispatch-flex-first nil 'local)
482 ;; Optionally configure the cape-capf-buster.
483 ; (setq-local completion-at-point-functions (list (cape-capf-buster #'lsp-completion-at-point)))
485 :hook (python-mode . lsp-deferred)
486 (cperl-mode . lsp-deferred)
487 (lsp-completion-mode . my/lsp-mode-setup-completion)
489 (lsp-completion-provider :none) ;; we use Corfu!
491 (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]venv\\'")
495 #+BEGIN_SRC emacs-lisp
496 ;; provides visual help in the buffer
497 ;; for example definitions on hover.
498 ;; the `imenu` lets me browse definitions quickly.
503 (setq lsp-ui-sideline-enable t
505 :hook (lsp-mode . lsp-ui-mode)
506 :bind (:map lsp-ui-mode-map
507 ("c-c i" . lsp-ui-imenu)))
509 *** LSP Pyright -- Python language server
510 #+BEGIN_SRC emacs-lisp
511 ;; language server for python
512 ;; read the docs for the different variables set in the config.
513 (use-package lsp-pyright
516 (setq lsp-clients-python-library-directories '("/usr/"))
517 (setq lsp-pyright-disable-language-service nil
518 lsp-pyright-disable-organize-imports nil
519 lsp-pyright-auto-import-completions t
520 lsp-pyright-use-library-code-for-types t
521 lsp-pyright-venv-path "venv")
522 :hook ((python-mode . (lambda ()
523 (require 'lsp-pyright) (lsp-deferred)))))
526 #+BEGIN_SRC emacs-lisp
528 ;; Optional customizations
530 (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
531 (corfu-auto t) ;; Enable auto completion
532 (corfu-separator ?\s) ;; Orderless field separator
533 (corfu-quit-at-boundary t)
534 (corfu-quit-no-match 'separator)
535 (corfu-preview-current nil) ;; Disable current candidate preview
536 (corfu-preselect 'prompt) ;; Preselect the prompt
537 (corfu-on-exact-match nil) ;; Configure handling of exact matches
538 (corfu-scroll-margin 5) ;; Use scroll margin
542 ("M-m" , corfu-move-to-minibuffer)
546 (setq completion-cycle-threshold 3)
547 (setq tab-always-indent 'complete)
549 (defun corfu-move-to-minibuffer ()
551 (when completion-in-region--data
552 (let ((completion-extra-properties corfu--extra)
553 completion-cycle-threshold completion-cycling)
554 (apply #'consult-completion-in-region completion-in-region--data))))
555 (add-to-list 'corfu-continue-commands #'corfu-move-to-minibuffer)
559 #+BEGIN_SRC emacs-lisp
562 ;; Swap M-/ and C-M-/
563 :bind (("M-/" . dabbrev-completion)
564 ("C-M-/" . dabbrev-expand))
565 ;; Other useful Dabbrev configurations.
567 (dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'")))
571 #+BEGIN_SRC emacs-lisp
573 (use-package tinyprocmail
574 :straight (tinytools :type git :type git :host github :repo "jaalto/project--emacs-tiny-tools")
575 ; :load-path "~/lib/emacs_el/tiny-tools/lisp/tiny"
576 :mode (".procmailrc" . turn-on-tinyprocmail-mode)
581 #+BEGIN_SRC emacs-lisp
584 :bind (("C-x g" . magit-status)
585 ("C-x C-g" . magit-status))
587 ;; refine diffs always (hilight words)
588 (setq magit-diff-refine-hunk nil)
590 (use-package magit-annex
594 (use-package magit-vcsh
600 *** Forge (github/gitlab)
601 #+BEGIN_SRC emacs-lisp
609 #+BEGIN_SRC emacs-lisp
610 (use-package cperl-mode
611 :mode ("\\.pl'" . cperl-mode)
612 ("\\.perl5\\'" . cperl-mode)
613 ("\\.perl\\'" . cperl-mode)
614 ("\\.miniperl\\'" . cperl-mode)
615 ("\\.\\([Pp][Llm]\\|al\\)\\'" . cperl-mode)
616 ;; use c-mode for perl .xs files
617 ("\\.xs\\'" . c-mode)
621 cperl-auto-newline nil
622 cperl-auto-newline-after-colon nil
623 cperl-continued-statement-offset 4
624 cperl-brace-offset -1
625 cperl-continued-brace-offset 0
626 cperl-label-offset -4
627 cperl-highlight-variables-indiscriminately t
628 cperl-electric-lbrace-space nil
629 cperl-indent-parens-as-block nil
630 cperl-close-paren-offset -1
631 cperl-tab-always-indent t)
632 (setq cperl-lazy-help-time nil)
633 ;;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
638 #+BEGIN_SRC emacs-lisp
639 (use-package markdown-mode
641 :mode (("\\.md\\'" . markdown-mode)
642 ("\\.mdwn\\'" . markdown-mode)
643 ("README\\.md\\'" . gfm-mode)
646 (setq markdown-enable-math t)
647 (setq markdown-follow-wiki-link-on-enter nil)
648 (bind-key "M-." #'markdown-jump markdown-mode-map)
649 (add-hook 'markdown-mode-hook #'flyspell-mode)
650 (add-hook 'markdown-mode-hook #'outline-minor-mode)
651 (bind-key "C-<tab>" #'outline-cycle markdown-mode-map)
656 #+BEGIN_SRC emacs-lisp
657 ; load sql-indent when sql is loaded
658 (use-package sql-indent
664 :mode (("\\.sql\\'" . sql-mode))
668 #+BEGIN_SRC emacs-lisp
670 :commands ediff ediff3
672 ;; ediff configuration
673 ;; don't use the multi-window configuration
674 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
677 ** Do the Right Thing Indenting
678 Attempts to automatically identify the right indentation for a file
679 #+BEGIN_SRC emacs-lisp
680 (use-package dtrt-indent
683 ** VCL --editing varnish configuration files
684 #+BEGIN_SRC emacs-lisp
685 (use-package vcl-mode
690 #+BEGIN_SRC emacs-lisp
695 ; (define-key vertico-map "\r" #'vertico-directory-enter)
696 ; (define-key vertico-map "\d" #'vertico-directory-delete-char)
697 ; (define-key vertico-map "\M-\d" #'vertico-directory-delete-word)
698 ; (add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy)
700 ;; Different scroll margin
701 ;; (setq vertico-scroll-margin 0)
703 ;; Show more candidates
704 ;; (setq vertico-count 20)
706 ;; Grow and shrink the Vertico minibuffer
707 ;; (setq vertico-resize t)
709 ;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
710 ;; (setq vertico-cycle t)
712 (vertico-grid-separator " ")
713 (vertico-grid-lookahead 50)
715 (use-package vertico-multiform
717 :load-path "~/var/emacs/straight/build/vertico/extensions/"
720 (setq vertico-multiform-categories
722 (consult-grep buffer)
725 (library reverse indexed)
726 (org-roam-node reverse indexed)
730 (setq vertico-multiform-commands
731 '(("flyspell-correct-*" grid reverse)
732 (org-refile grid reverse indexed)
733 (consult-yank-pop indexed)
735 (consult-lsp-diagnostics)
738 (vertico-multiform-mode)
741 (use-package vertico-grid
745 (use-package vertico-reverse
749 (use-package vertico-indexed
753 (use-package vertico-buffer
759 ;; Persist history over Emacs restarts. Vertico sorts by history position.
760 (use-package savehist
766 ** Orderless: advanced completion style
767 #+begin_src emacs-lisp
768 (use-package orderless
770 ;; Configure a custom style dispatcher (see the Consult wiki)
771 ;; (setq orderless-style-dispatchers '(+orderless-dispatch)
772 ;; orderless-component-separator #'orderless-escapable-split-on-space)
773 (setq completion-styles '(orderless basic)
774 completion-category-defaults nil
775 completion-category-overrides '((file (styles partial-completion)))))
777 ** Marginalia: Rich annotations in the minibuffer
778 #+begin_src emacs-lisp
779 (use-package marginalia
781 :bind (:map minibuffer-local-map
782 ("M-A" . marginalia-cycle))
787 ** Embark: Minibuffer actions and context menu
788 #+begin_src emacs-lisp
791 (("C-." . embark-act) ;; pick some comfortable binding
792 ("C-;" . embark-dwim) ;; good alternative: M-.
793 ("C-h B" . embark-bindings)) ;; alternative for `describe-bindings'
797 ;; Optionally replace the key help with a completing-read interface
798 (setq prefix-help-command #'embark-prefix-help-command)
802 ;; Hide the mode line of the Embark live/completions buffers
803 (add-to-list 'display-buffer-alist
804 '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
806 (window-parameters (mode-line-format . none)))))
808 (use-package embark-consult
810 (embark-collect-mode . consult-preview-at-point-mode))
812 ** which-key (show possible completions of a key combination)
813 #+BEGIN_SRC emacs-lisp
814 (use-package which-key
819 #+begin_src emacs-lisp
821 ;; Replace bindings. Lazily loaded due by `use-package'.
822 :bind (;; C-c bindings in `mode-specific-map'
823 ("C-c M-x" . consult-mode-command)
824 ("C-c h" . consult-history)
825 ("C-c k" . consult-kmacro)
826 ("C-c m" . consult-man)
827 ("C-c i" . consult-info)
828 ([remap Info-search] . consult-info)
829 ;; C-x bindings in `ctl-x-map'
830 ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command
831 ("C-x b" . consult-buffer) ;; orig. switch-to-buffer
832 ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
833 ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame
834 ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
835 ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer
836 ;; Custom M-# bindings for fast register access
837 ("M-#" . consult-register-load)
838 ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated)
839 ("C-M-#" . consult-register)
840 ;; Other custom bindings
841 ("M-y" . consult-yank-pop) ;; orig. yank-pop
842 ;; M-g bindings in `goto-map'
843 ("M-g e" . consult-compile-error)
844 ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck
845 ("M-g g" . consult-goto-line) ;; orig. goto-line
846 ("M-g M-g" . consult-goto-line) ;; orig. goto-line
847 ("M-g o" . consult-outline) ;; Alternative: consult-org-heading
848 ("M-g m" . consult-mark)
849 ("M-g k" . consult-global-mark)
850 ("M-g i" . consult-imenu)
851 ("M-g I" . consult-imenu-multi)
852 ;; M-s bindings in `search-map'
853 ("M-s d" . consult-find)
854 ("M-s D" . consult-locate)
855 ("M-s g" . consult-grep)
856 ("M-s G" . consult-git-grep)
857 ("M-s r" . consult-ripgrep)
858 ("M-s l" . consult-line)
859 ("M-s L" . consult-line-multi)
860 ("M-s k" . consult-keep-lines)
861 ("M-s u" . consult-focus-lines)
862 ;; Isearch integration
863 ("M-s e" . consult-isearch-history)
864 :map isearch-mode-map
865 ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string
866 ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string
867 ("M-s l" . consult-line) ;; needed by consult-line to detect isearch
868 ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch
869 ;; Minibuffer history
870 :map minibuffer-local-map
871 ("M-s" . consult-history) ;; orig. next-matching-history-element
872 ("M-r" . consult-history)) ;; orig. previous-matching-history-element
874 ;; Enable automatic preview at point in the *Completions* buffer. This is
875 ;; relevant when you use the default completion UI.
876 :hook (completion-list-mode . consult-preview-at-point-mode)
878 :commands (consult-xref)
880 ;; The :init configuration is always executed (Not lazy)
883 ;; Optionally configure the register formatting. This improves the register
884 ;; preview for `consult-register', `consult-register-load',
885 ;; `consult-register-store' and the Emacs built-ins.
886 (setq register-preview-delay 0.5
887 register-preview-function #'consult-register-format)
889 ;; Optionally tweak the register preview window.
890 ;; This adds thin lines, sorting and hides the mode line of the window.
891 (advice-add #'register-preview :override #'consult-register-window)
893 ;; Use Consult to select xref locations with preview
894 (setq xref-show-xrefs-function #'consult-xref
895 xref-show-definitions-function #'consult-xref)
897 ;; Configure other variables and modes in the :config section,
898 ;; after lazily loading the package.
900 ;; Optionally configure preview. The default value
901 ;; is 'any, such that any key triggers the preview.
902 ;; (setq consult-preview-key 'any)
903 ;; (setq consult-preview-key "M-.")
904 ;; (setq consult-preview-key '("S-<down>" "S-<up>"))
905 ;; For some commands and buffer sources it is useful to configure the
906 ;; :preview-key on a per-command basis using the `consult-customize' macro.
908 consult-theme :preview-key '(:debounce 0.2 any)
909 consult-ripgrep consult-git-grep consult-grep
910 consult-bookmark consult-recent-file consult-xref
911 consult--source-bookmark consult--source-file-register
912 consult--source-recent-file consult--source-project-recent-file
913 ;; :preview-key "M-."
914 :preview-key '(:debounce 0.4 any))
916 ;; Optionally configure the narrowing key.
917 ;; Both < and C-+ work reasonably well.
918 (setq consult-narrow-key "<") ;; "C-+"
920 ;; Optionally make narrowing help available in the minibuffer.
921 ;; You may want to use `embark-prefix-help-command' or which-key instead.
922 ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)
924 ;; By default `consult-project-function' uses `project-root' from project.el.
925 ;; Optionally configure a different project root function.
926 ;;;; 1. project.el (the default)
927 ;; (setq consult-project-function #'consult--default-project--function)
928 ;;;; 2. vc.el (vc-root-dir)
929 ;; (setq consult-project-function (lambda (_) (vc-root-dir)))
930 ;;;; 3. locate-dominating-file
931 ;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git")))
932 ;;;; 4. projectile.el (projectile-project-root)
933 ;; (autoload 'projectile-project-root "projectile")
934 ;; (setq consult-project-function (lambda (_) (projectile-project-root)))
935 ;;;; 5. No project support
936 ;; (setq consult-project-function nil)
939 ** Projectile -- Project management
940 #+begin_src emacs-lisp
941 (use-package projectile
942 :bind (("<f5>" . projectile-compile-project)
943 ("<f6>" . next-error))
944 :config (projectile-global-mode))
948 #+BEGIN_SRC emacs-lisp
950 :bind ("M-z" . avy-zap-up-to-char-dwim))
953 #+BEGIN_SRC emacs-lisp
955 :bind (("C-c 2" . my/hydra-orgmodes/body)
956 ("C-c @" . my/hydra-orgmodes/body)
957 ("C-c #" . my/hydra-outline/body)
958 ("C-c 3" . my/hydra-outline/body)
961 (defhydra my/hydra-orgmodes (:color blue :hint nil)
963 _n_: notes _c_: chaim _w_: wildman _o_: ool
964 _u_: uddin _s_: steve _r_: refile _f_: fh
965 _p_: read papers _R_: paper notes
970 ("n" (find-file "~/projects/org-notes/notes.org"))
971 ("c" (find-file "~/projects/org-notes/chaim.org"))
972 ("w" (find-file "~/projects/org-notes/wildman.org"))
973 ("u" (find-file "~/projects/org-notes/uddin.org"))
974 ("o" (find-file "~/projects/org-notes/ool.org"))
975 ("f" (find-file "~/projects/org-notes/fh.org"))
976 ("s" (find-file "~/projects/org-notes/sndservers.org"))
977 ("r" (find-file my/org-refile-file))
978 ("p" (find-file "~/projects/research/papers_to_read.org"))
979 ("R" (find-file "~/projects/research/paper_notes.org"))
980 ("h" (find-file "~/projects/org-notes/hpcbio.org"))
985 ;; from https://github.com/abo-abo/hydra/wiki/Emacs
986 (defhydra my/hydra-outline (:color pink :hint nil)
989 ^^^^^^------------------------------------------------------
990 _q_: sublevels _a_: all _u_: up
991 _t_: body _e_: entry _n_: next visible
992 _o_: other _i_: children _p_: previous visible
993 _c_: entry _k_: branches _f_: forward same level
994 _l_: leaves _s_: subtree _b_: backward same level
999 ("q" outline-hide-sublevels) ; Hide everything but the top-level headings
1000 ("t" outline-hide-body) ; Hide everything but headings (all body lines)
1001 ("o" outline-hide-other) ; Hide other branches
1002 ("c" outline-hide-entry) ; Hide this entry's body
1003 ("l" outline-hide-leaves) ; Hide body lines in this entry and sub-entries
1004 ("d" outline-hide-subtree) ; Hide everything in this entry and sub-entries
1006 ("a" outline-show-all) ; Show (expand) everything
1007 ("e" outline-show-entry) ; Show this heading's body
1008 ("i" outline-show-children) ; Show this heading's immediate child sub-headings
1009 ("k" outline-show-branches) ; Show all sub-headings under this heading
1010 ("s" outline-show-subtree) ; Show (expand) everything in this heading & below
1012 ("u" outline-up-heading) ; Up
1013 ("n" outline-next-visible-heading) ; Next
1014 ("p" outline-previous-visible-heading) ; Previous
1015 ("f" outline-forward-same-level) ; Forward - same level
1016 ("b" outline-backward-same-level) ; Backward - same level
1022 #+BEGIN_SRC emacs-lisp
1025 ; use the built in tramp
1028 (setq tramp-use-ssh-controlmaster-options nil)
1029 (add-to-list 'tramp-methods '("vcsh"
1030 (tramp-login-program "vcsh")
1034 (tramp-remote-shell "/bin/sh")
1035 (tramp-remote-shell-args
1039 #+BEGIN_SRC emacs-lisp
1042 (setq-default reftex-default-bibliography
1043 '("~/projects/research/references.bib")))
1046 #+BEGIN_SRC emacs-lisp
1048 :config (setq bibtex-user-optional-fields
1049 (quote (("annote" "Personal annotation (ignored)")
1057 #+BEGIN_SRC emacs-lisp
1060 :mode ("\\.tex\\'" . LaTeX-mode)
1061 :mode ("\\.bib\\'" . bibtex-mode)
1063 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
1064 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
1065 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
1066 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
1067 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
1068 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
1069 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
1070 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
1071 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
1072 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
1073 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
1075 (setq-default reftex-plug-into-AUCTeX t)
1076 ;; support fake section headers
1077 (setq TeX-outline-extra
1081 ("%subsubsection" 4)
1083 ;; add font locking to the headers
1084 (font-lock-add-keywords
1086 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
1087 0 'font-lock-keyword-face t)
1088 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
1089 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
1090 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
1091 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
1092 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
1094 ;; use smart quotes by default instead of `` and ''
1095 ;; taken from http://kieranhealy.org/esk/kjhealy.html
1096 (setq TeX-open-quote "“")
1097 (setq TeX-close-quote "”")
1099 ;; (TeX-add-style-hook
1104 ;; (custom-set-variables
1105 ;; '(font-latex-user-keyword-classes
1108 ;; font-lock-function-name-face 2 (command 1 t))))
1110 (setq-default TeX-parse-self t)
1111 (setq-default TeX-auto-save t)
1112 (setq-default TeX-master nil)
1113 (add-to-list 'LaTeX-font-list
1114 '(?\C-a "\\alert{","}"))
1117 '(TeX-add-style-hook
1120 (if (boundp 'reftex-ref-style-alist)
1122 'reftex-ref-style-alist
1123 '("Cleveref" "cleveref"
1124 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
1125 (reftex-ref-style-activate "Cleveref")
1127 '("cref" TeX-arg-ref)
1128 '("Cref" TeX-arg-ref)
1129 '("cpageref" TeX-arg-ref)
1130 '("Cpageref" TeX-arg-ref)))))
1133 '(add-to-list 'LaTeX-fill-excluded-macros
1136 (setq font-latex-match-reference-keywords
1157 (setq font-latex-fontify-script nil)
1158 (setq font-latex-fontify-sectioning (quote color))
1159 (setq font-latex-script-display (quote (nil)))
1164 #+BEGIN_SRC emacs-lisp
1167 :mode ("\\.R\\'" . ess-r-mode)
1168 :bind (:map ess-mode-map
1169 ("C-c C-R" . dla/ess-region-remote-eval))
1171 (autoload 'ess-r-mode "ess-site" nil t)
1172 (autoload 'R "ess-site" nil t)
1174 ; actually load the rest of ess
1176 (defun ess-change-directory (path)
1177 "Set the current working directory to PATH for both *R* and Emacs."
1178 (interactive "Directory to change to: ")
1180 (when (file-exists-p path)
1181 (ess-command (concat "setwd(\"" path "\")\n"))
1182 ;; use file-name-as-directory to ensure it has trailing /
1183 (setq default-directory (file-name-as-directory path))))
1184 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
1185 ;; outlining support for ess modes
1189 (outline-minor-mode)
1190 (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
1191 (defun outline-level ()
1192 (cond ((looking-at "^##### ") 1)
1193 ((looking-at "^#### ") 2)
1194 ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
1197 (defun dla/ess-region-remote-eval (start end)
1198 "Evaluate region in a remote ESS instance"
1200 (shell-command-on-region start end "eval_r" (get-buffer-create "***essregionremoteeval***") nil nil nil)
1201 (kill-buffer "***essregionremoteeval***"))
1202 ;; Don't restore history or save workspace image
1203 '(inferior-R-args "--no-restore-history --no-save")
1208 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
1210 #+BEGIN_SRC emacs-lisp
1211 (use-package rainbow-mode
1213 ;; add ess to the x major mode
1214 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
1215 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
1220 #+BEGIN_SRC emacs-lisp
1221 (use-package yaml-mode
1222 ;; add ess to the x major mode
1223 :mode ("\\.\\(yaml|yml\\)\\'" . yaml-mode)
1228 #+BEGIN_SRC emacs-lisp
1229 (use-package poly-noweb
1233 (use-package poly-markdown
1237 :after (:all polymode poly-markdown poly-noweb)
1238 :mode ("\\.Snw" . poly-noweb+r-mode)
1239 :mode ("\\.Rnw" . poly-noweb+r-mode)
1240 :mode ("\\.Rmd" . poly-markdown+r-mode)
1242 (use-package polymode
1249 *** outline minor mode
1250 #+BEGIN_SRC emacs-lisp
1251 (use-package outline
1255 (setq outline-minor-mode-prefix "C-c C-2")
1258 *** outshine (outlining) integration
1259 #+BEGIN_SRC emacs-lisp
1260 (use-package outshine
1262 :hook (outline-minor-mode . outshine-mode)
1266 #+BEGIN_SRC emacs-lisp
1267 (use-package writeroom-mode
1269 (defun my/writing-mode ()
1270 "Start my writing mode; enable visual-line-mode and auto-fill-mode"
1275 (visual-line-mode -1)
1277 (visual-fill-column-mode -1)
1279 (visual-line-mode 1)
1281 (visual-fill-column-mode 1)
1286 ** GhostText/Atomic Chrome
1287 #+BEGIN_SRC emacs-lisp
1288 (use-package atomic-chrome
1290 (ignore-errors (atomic-chrome-start-server))
1291 (setq atomic-chrome-buffer-open-style 'full)
1295 #+BEGIN_SRC emacs-lisp
1296 (use-package edit-server
1297 :commands edit-server-start
1298 :init (if after-init-time
1300 (add-hook 'after-init-hook
1301 #'(lambda() (edit-server-start))))
1302 :config (setq edit-server-new-frame-alist
1303 '((name . "Edit with Emacs FRAME")
1309 (menu-bar-lines . t)
1310 (window-system . x)))
1314 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
1315 #+BEGIN_SRC emacs-lisp
1316 (use-package multiple-cursors
1317 :bind* (("C-;" . mc/mark-all-dwim)
1318 ("C-<" . mc/mark-previous-like-this)
1319 ("C->" . mc/mark-next-like-this)
1320 ("C-S-c C-S-c" . mc/edit-lines))
1324 #+BEGIN_SRC emacs-lisp
1325 (use-package web-mode
1326 :mode ("\\.\\(tx|tmpl\\)\\'" . web-mode)
1328 (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . web-mode))
1329 (setq web-mode-enable-engine-detection t)
1330 (setq web-mode-engines-alist
1331 '(("template-toolkit" . "\\.tmpl\\'")))
1334 ** Spamassassin Mode
1335 #+BEGIN_SRC emacs-lisp
1336 (use-package spamassassin-mode
1338 :load-path "~/lib/emacs_el"
1339 :commands spamassassin-mode
1343 #+BEGIN_SRC emacs-lisp
1344 (use-package password-store
1345 :commands password-store-edit password-store-generate
1347 (defun dla/password-store-edit (entry)
1348 "Edit password for ENTRY which doesn't require it to already exist"
1349 (interactive (list (password-store--completing-read nil)))
1350 (password-store--run-edit entry))
1351 (advice-add 'password-store-edit :override #'dla/password-store-edit)
1355 #+BEGIN_SRC emacs-lisp
1360 ;; fix up css mode to not be silly
1361 ;; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
1362 (setq cssm-indent-level 4)
1363 (setq cssm-newline-before-closing-bracket t)
1364 (setq cssm-indent-function #'cssm-c-style-indenter)
1365 (setq cssm-mirror-mode nil))
1368 #+BEGIN_SRC emacs-lisp
1371 :delight abbrev-mode
1373 ;; load abbreviations from
1374 (setq abbrev-file-name
1375 "~/.emacs_abbrev_def")
1377 ;; read the abbrev file if it exists
1378 (if (file-exists-p abbrev-file-name)
1379 (quietly-read-abbrev-file))
1381 ;; for now, use abbrev mode everywhere
1383 (setq default-abbrev-mode t))
1386 ** Debugging (realgud)
1387 #+BEGIN_SRC emacs-lisp
1388 (use-package realgud
1389 :commands (realgud:pdb realgud:gdb)
1392 ** Python Programming
1393 #+BEGIN_SRC emacs-lisp
1394 (use-package python-mode
1397 (python-mode . pyvenv-mode)
1398 (python-mode . flycheck-mode)
1399 (python-mode . blacken-mode)
1400 (python-mode . yas-minor-mode)
1401 (python-mode . anaconda-mode)
1407 (use-package blacken
1410 :commands (blacken-buffer)
1412 (setq-default blacken-fast-unsafe t)
1416 #+begin_src emacs-lisp :tangle yes
1417 (use-package python-black
1419 :commands (python-black-buffer python-black-statement)
1422 *** Sphinx Documentation
1423 #+begin_src emacs-lisp :tangle yes
1424 (use-package numpydoc
1426 :bind (:map python-mode-map
1427 ("C-c C-n" . numpydoc-generate)))
1428 (use-package sphinx-doc
1431 (setq sphinx-doc-include-types t)
1433 :hook (python-mode . sphinx-doc-mode)
1435 (use-package python-docstring
1438 :hook (python-mode . python-docstring-mode)
1441 *** Anaconda Mode (Documentation lookup and completion)
1442 #+BEGIN_SRC emacs-lisp
1443 (use-package anaconda-mode
1449 #+BEGIN_SRC emacs-lisp
1450 (use-package go-mode
1457 #+BEGIN_SRC emacs-lisp
1458 (use-package expand-region
1459 :bind (("C-=" . 'er/expand-region))
1464 #+BEGIN_SRC emacs-lisp
1465 (use-package dockerfile-mode
1471 #+BEGIN_SRC emacs-lisp
1472 (use-package beancount
1474 :load-path "~/lib/emacs_el/beancount-mode/"
1475 :mode "\\.beancount\\'"
1480 #+BEGIN_SRC emacs-lisp
1481 (use-package apache-mode
1483 :mode "apache\\.conf\\'"
1487 #+BEGIN_SRC emacs-lisp
1490 :commands eldoc-mode
1498 #+BEGIN_SRC emacs-lisp
1499 (use-package message
1501 :delight (message "✉")
1502 :delight (message-mode "✉")
1503 :mode ("muttng-[a-z0-9]+-[0-9]+-" . message-mode)
1504 :mode ("mutt-[a-z0-9]+-[0-9]+-" . message-mode)
1505 :hook 'my/message-mode-settings
1506 :hook 'turn-on-flyspell
1507 :bind (:map message-mode-map
1508 ("C-c C-a" . my/post-attach-file)
1509 ("C-x p" . my/message-kill-buffer)
1512 (defun my/message-mode-settings ()
1513 (font-lock-add-keywords nil
1514 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1515 (0 'message-multiply-quoted-text-face))
1516 ("^[ \t]*>[ \t]*>.*$"
1517 (0 'message-double-quoted-text-face))))
1519 (defun my/message-kill-buffer ()
1523 (defun my/post-attach-file ()
1524 "Prompt for an attachment."
1526 (let ((file (read-file-name "Attach file: " nil nil t nil)))
1527 (my/header-attach-file file "")))
1529 (defun my/header-attach-file (file description)
1530 "Attach a FILE to the current message (works with Mutt).
1531 Argument DESCRIPTION MIME description."
1532 (interactive "fAttach file: \nsDescription: ")
1533 (when (> (length file) 0)
1538 (goto-char (point-min))
1539 (search-forward-regexp "^$")
1540 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1542 (message (concat "Attached '" file "'."))
1543 (setq post-has-attachment t))))))
1545 (setq mail-yank-prefix "> ")
1546 (setq mail-header-separator "") ; fix broken header detection
1550 #+BEGIN_SRC emacs-lisp
1551 (use-package mutt-mode
1556 *** Set mail User agent
1557 #+BEGIN_SRC emacs-lisp
1558 (setq mail-user-agent (quote sendmail-user-agent))
1561 #+BEGIN_SRC emacs-lisp
1566 ; (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
1570 ** Reverting buffers
1571 #+BEGIN_SRC emacs-lisp
1572 (use-package autorevert
1573 :delight auto-revert-mode
1575 (setq global-auto-revert-non-file-buffers t
1576 global-auto-revert-ignore-modes '(pdf-view-mode)
1577 auto-revert-verbose nil)
1578 (global-auto-revert-mode 1))
1581 ** Use-package and load things
1582 #+BEGIN_SRC emacs-lisp
1585 :delight (org-mode "ø")
1586 :mode ("\\.\\(org\\|org_archive\\|txt\\)\\'" . org-mode)
1587 :bind (("C-c l l" . org-store-link)
1588 ("C-c a" . org-agenda)
1589 ("C-c b" . org-iswitchb))
1591 ** Agenda Configuration
1592 #+BEGIN_SRC emacs-lisp
1594 (setq-default org-log-done 'time)
1595 (setq-default org-agenda-ndays 5)
1597 (setq org-agenda-sticky t)
1598 (defun dla/show-org-agenda ()
1603 (and (string-match-p
1611 (buffer-name agendabuffer))
1613 (delete-other-windows))
1615 ;; agenda configuration
1616 ;; Do not dim blocked tasks
1617 (setq org-agenda-dim-blocked-tasks nil)
1618 (setq org-agenda-inhibit-startup t)
1619 (setq org-agenda-use-tag-inheritance nil)
1621 ;; Compact the block agenda view
1622 (setq org-agenda-compact-blocks t)
1624 ;; Custom agenda command definitions
1625 (setq org-agenda-custom-commands
1626 (quote (("N" "Notes" tags "NOTE"
1627 ((org-agenda-overriding-header "Notes")
1628 (org-tags-match-list-sublevels t)))
1629 ("h" "Habits" tags-todo "STYLE=\"habit\""
1630 ((org-agenda-overriding-header "Habits")
1631 (org-agenda-sorting-strategy
1632 '(todo-state-down effort-up category-keep))))
1636 ((org-agenda-overriding-header "Tasks to Refile")
1637 (org-tags-match-list-sublevels nil)))
1638 (tags-todo "-CANCELLED/!"
1639 ((org-agenda-overriding-header "Stuck Projects")
1640 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
1641 (org-agenda-sorting-strategy
1643 (tags-todo "-HOLD-CANCELLED/!"
1644 ((org-agenda-overriding-header "Projects")
1645 (org-agenda-skip-function 'bh/skip-non-projects)
1646 (org-tags-match-list-sublevels 'indented)
1647 (org-agenda-sorting-strategy
1649 (tags-todo "-CANCELLED/!NEXT"
1650 ((org-agenda-overriding-header (concat "Project Next Tasks"
1651 (if bh/hide-scheduled-and-waiting-next-tasks
1653 " (including WAITING and SCHEDULED tasks)")))
1654 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1655 (org-tags-match-list-sublevels t)
1656 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1657 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1658 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1659 (org-agenda-sorting-strategy
1660 '(todo-state-down effort-up category-keep))))
1661 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1662 ((org-agenda-overriding-header (concat "Project Subtasks"
1663 (if bh/hide-scheduled-and-waiting-next-tasks
1665 " (including WAITING and SCHEDULED tasks)")))
1666 (org-agenda-skip-function 'bh/skip-non-project-tasks)
1667 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1668 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1669 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1670 (org-agenda-sorting-strategy
1672 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1673 ((org-agenda-overriding-header (concat "Standalone Tasks"
1674 (if bh/hide-scheduled-and-waiting-next-tasks
1676 " (including WAITING and SCHEDULED tasks)")))
1677 (org-agenda-skip-function 'bh/skip-project-tasks)
1678 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1679 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1680 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1681 (org-agenda-sorting-strategy
1683 (tags-todo "-CANCELLED+WAITING|HOLD/!"
1684 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
1685 (org-agenda-skip-function 'bh/skip-stuck-projects)
1686 (org-tags-match-list-sublevels nil)
1687 (org-agenda-todo-ignore-scheduled t)
1688 (org-agenda-todo-ignore-deadlines t)))
1690 ((org-agenda-overriding-header "Tasks to Archive")
1691 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1692 (org-tags-match-list-sublevels nil))))
1695 ; org mode agenda files
1696 (setq org-agenda-files
1698 (file-expand-wildcards "~/projects/org-notes/*.org")
1699 (file-expand-wildcards "~/org-mode/from-mobile.org")
1700 (file-expand-wildcards "~/org-notes-*/*.org")
1703 (setq my/org-refile-file
1705 (lambda (file) (string-match-p (regexp-quote "/refile.org") file))
1708 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
1709 (set-register ?r (cons 'file my/org-refile-file))
1710 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
1711 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
1712 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
1713 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
1714 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
1715 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
1716 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
1717 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
1718 ; (defun org-agenda-timeline-all (&optional arg)
1721 ; (dolist (org-agenda-file org-agenda-files)
1722 ; (insert-file-contents org-agenda-file nil)
1723 ; (goto-char (point-max))
1725 ; (write-file "/tmp/timeline.org")
1726 ; (org-agenda arg "L")))
1727 ; (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
1731 #+BEGIN_SRC emacs-lisp
1732 (setq org-global-properties '(("Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00")))
1733 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
1735 (setq org-default-notes-file "~/projects/org-notes/notes.org")
1736 (setq org-id-link-to-org-use-id 'use-existing)
1738 ** Capture Templates
1739 #+BEGIN_SRC emacs-lisp
1740 (setq org-capture-templates ;; mail-specific note template, identified by "m"
1741 `(("m" "Mail" entry (file my/org-refile-file)
1742 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
1743 ("t" "todo" entry (file my/org-refile-file)
1744 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
1745 ("r" "respond" entry (file my/org-refile-file)
1746 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
1747 ("n" "note" entry (file my/org-refile-file)
1748 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
1749 ("s" "schedule" entry (file my/org-refile-file)
1750 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
1751 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
1752 "* %?\n%U\n" :clock-in t :clock-resume t)
1753 ("w" "org-protocol" entry (file my/org-refile-file)
1754 "* TODO Review %c\n%U\n" :immediate-finish t)
1755 ("M" "Meeting" entry (file my/org-refile-file)
1756 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
1757 ("S" "Seminar" entry (file my/org-refile-file)
1758 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
1759 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
1760 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
1761 ("p" "Phone call" entry (file my/org-refile-file)
1762 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
1763 ("J" "job" entry (file+olp "~/projects/org-notes/notes.org"
1765 ,(format-time-string "Positions %Y"))
1766 "* TODO Apply for %? :job:\nSCHEDULED: <%<%Y-%m-%d>>\n%U\n%x\n" :clock-in t :clock-resume t)
1767 ("h" "Habit" entry (file my/org-refile-file)
1768 "* NEXT %?\n%U\n%a\nSCHEDULED: %(format-time-string \"<%Y-%m-%d .+1d/3d>\")\n:PROPERTIES:\n:STYLE: habit\n:REPEAT_TO_STATE: NEXT\n:END:\n%a\n")
1772 ;; Remove empty LOGBOOK drawers on clock out
1773 (defun bh/remove-empty-drawer-on-clock-out ()
1776 (beginning-of-line 0)
1777 (org-remove-empty-drawer-at (point))))
1779 (defun my/org-add-id ()
1782 (if (org-current-level)
1791 ** Org mode key bindings
1792 #+BEGIN_SRC emacs-lisp
1793 ;; org mode configuration from http://doc.norang.ca/org-mode.html
1794 ;; Custom Key Bindings
1795 :bind* (("<f9> a" . org-agenda)
1796 ("<f9> I" . bh/punch-in)
1797 ("<f9> O" . bh/punch-out)
1798 ("<f9> SPC" . bh/clock-in-last-task)
1799 ("<f12>" . dla/show-org-agenda)
1800 ;; ("<f5>" . bh/org-todo)
1801 ("<S-f5>" . bh/widen)
1802 ("<f7>" . bh/set-truncate-lines)
1803 ("<f8>" . org-cycle-agenda-files)
1804 ("<f9> <f9>" . dla/show-org-agenda)
1806 ("<f9> c" . calendar)
1807 ("<f9> f" . boxquote-insert-file)
1808 ("<f9> h" . bh/hide-other)
1809 ("<f9> n" . bh/toggle-next-task-display)
1812 ("<f9> r" . boxquote-region)
1813 ("<f9> s" . bh/switch-to-scratch)
1815 ("<f9> t" . bh/insert-inactive-timestamp)
1816 ("<f9> T" . bh/toggle-insert-inactive-timestamp)
1818 ("<f9> v" . visible-mode)
1819 ("<f9> l" . org-toggle-link-display)
1820 ("<f9> SPC" . bh/clock-in-last-task)
1821 ("C-<f9>" . previous-buffer)
1822 ("M-<f9>" . org-toggle-inline-images)
1823 ("C-x n r" . narrow-to-region)
1824 ("C-<f10>" . next-buffer)
1825 ("<f11>" . org-clock-goto)
1826 ("C-<f11>" . org-clock-in)
1827 ("C-s-<f12>" . bh/save-then-publish)
1828 ("C-c c" . org-capture))
1831 ** Utility Functions
1832 #+BEGIN_SRC emacs-lisp
1833 (defun bh/hide-other ()
1836 (org-back-to-heading 'invisible-ok)
1837 (outline-hide-other)
1842 (defun bh/set-truncate-lines ()
1843 "Toggle value of truncate-lines and refresh window display."
1845 (setq truncate-lines (not truncate-lines))
1846 ;; now refresh window display (an idiom from simple.el):
1848 (set-window-start (selected-window)
1849 (window-start (selected-window)))))
1851 (defun bh/switch-to-scratch ()
1853 (switch-to-buffer "*scratch*"))
1855 (setq org-use-fast-todo-selection t)
1856 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1858 ; create function to create headlines in file. This comes from
1859 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
1860 (defun my/org-add-ids-to-headlines-in-file ()
1861 "Add ID properties to all headlines in the current file which
1862 do not already have one."
1866 (goto-char (point-min))
1867 (when (not (re-search-forward "^#\\+OPTIONS:.*auto-id:f" (point-max) t))
1868 (org-map-entries 'org-id-get-create))))
1869 (defun dla/org-update-ids-to-headlines-in-file ()
1870 "Add or replace ID properties to all headlines in the current file
1871 (or narrowed region)."
1874 (org-map-entries '(lambda () (org-id-get-create t))))
1875 ; if we wanted to do this to every buffer, do the following:
1876 (add-hook 'org-mode-hook
1878 (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
1881 #+BEGIN_SRC emacs-lisp
1882 (use-package find-lisp
1884 (setq org-agenda-text-search-extra-files
1885 (append '(agenda-archives)
1886 (find-lisp-find-files "~/projects/org-notes" "\.org$")
1887 (find-lisp-find-files "~/projects/org-notes" "\.org_archive$")
1891 #+BEGIN_SRC emacs-lisp
1892 (setq org-todo-keywords
1893 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
1894 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
1896 (setq org-todo-keyword-faces
1897 (quote (("TODO" :foreground "red" :weight bold)
1898 ("NEXT" :foreground "blue" :weight bold)
1899 ("DONE" :foreground "forest green" :weight bold)
1900 ("WAITING" :foreground "orange" :weight bold)
1901 ("HOLD" :foreground "magenta" :weight bold)
1902 ("CANCELLED" :foreground "forest green" :weight bold)
1903 ("MEETING" :foreground "forest green" :weight bold)
1904 ("PHONE" :foreground "forest green" :weight bold))))
1906 (setq org-todo-state-tags-triggers
1907 (quote (("CANCELLED" ("CANCELLED" . t))
1908 ("WAITING" ("WAITING" . t))
1909 ("HOLD" ("WAITING") ("HOLD" . t))
1910 (done ("WAITING") ("HOLD"))
1911 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1912 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1913 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1917 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1918 ; add ids on creation of nodes
1919 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
1922 ; resolve clocks after 10 minutes of idle; use xprintidle
1923 ; (setq org-clock-idle-time 10)
1924 ; (setq org-clock-x11idle-program-name "xprintidle")
1926 ; this is from http://doc.norang.ca/org-mode.html#Capture
1927 ; use C-M-r for org mode capture
1928 (global-set-key (kbd "C-M-r") 'org-capture)
1930 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1931 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1932 (org-agenda-files :maxlevel . 9))))
1934 ; Use full outline paths for refile targets - we file directly with IDO
1935 (setq org-refile-use-outline-path t)
1937 ; Targets complete directly with IDO
1938 (setq org-outline-path-complete-in-steps nil)
1940 ; Allow refile to create parent tasks with confirmation
1941 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1943 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
1944 ; (setq org-completion-use-ido t)
1945 ; (setq ido-everywhere t)
1946 ; (setq ido-max-directory-size 100000)
1947 ; (ido-mode (quote both))
1948 ; ; Use the current window when visiting files and buffers with ido
1949 ; (setq ido-default-file-method 'selected-window)
1950 ; (setq ido-default-buffer-method 'selected-window)
1951 ; ; Use the current window for indirect buffer display
1952 ; (setq org-indirect-buffer-display 'current-window)
1955 ;;;; Refile settings
1956 ; Exclude DONE state tasks from refile targets
1957 (defun bh/verify-refile-target ()
1958 "Exclude todo keywords with a done state from refile targets"
1959 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
1961 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1963 ;; ensure that emacsclient will show just the note to be edited when invoked
1964 ;; from Mutt, and that it will shut down emacsclient once finished;
1965 ;; fallback to legacy behavior when not invoked via org-protocol.
1966 (require 'org-protocol)
1967 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
1968 (setq my-org-protocol-flag nil)
1969 (defadvice org-capture-finalize (after delete-frame-at-end activate)
1970 "Delete frame at remember finalization"
1971 (progn (if my-org-protocol-flag (delete-frame))
1972 (setq my-org-protocol-flag nil)))
1973 (defadvice org-capture-refile (around delete-frame-after-refile activate)
1974 "Delete frame at remember refile"
1975 (if my-org-protocol-flag
1977 (setq my-org-protocol-flag nil)
1982 (defadvice org-capture-kill (after delete-frame-at-end activate)
1983 "Delete frame at remember abort"
1984 (progn (if my-org-protocol-flag (delete-frame))
1985 (setq my-org-protocol-flag nil)))
1986 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
1987 (setq my-org-protocol-flag t))
1989 (defadvice org-insert-todo-heading (after dla/create-id activate)
1990 (unless (org-in-item-p)
1996 (add-to-list 'org-modules 'org-habit)
1998 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
1999 (defun open-mail-in-mutt (message)
2000 "Open a mail message in Mutt, using an external terminal.
2002 Message can be specified either by a path pointing inside a
2003 Maildir, or by Message-ID."
2004 (interactive "MPath or Message-ID: ")
2006 (format "faf xterm -e \"%s %s\""
2007 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
2009 ;; add support for "mutt:ID" links
2010 (org-add-link-type "mutt" 'open-mail-in-mutt)
2012 (defun my-org-mode-setup ()
2013 ; (load-library "reftex")
2014 (and (buffer-file-name)
2015 (file-exists-p (buffer-file-name))
2017 ; (reftex-parse-all)
2018 (reftex-set-cite-format
2019 '((?b . "[[bib:%l][%l-bib]]")
2020 (?n . "[[notes:%l][%l-notes]]")
2022 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
2024 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
2025 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
2026 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
2027 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
2029 (add-hook 'org-mode-hook 'my-org-mode-setup)
2031 (defun org-mode-reftex-search ()
2033 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
2035 (defun open-research-paper (bibtexkey)
2036 "Open a paper by bibtex key"
2037 (interactive "bibtex key: ")
2040 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
2041 (org-add-link-type "papers" 'open-research-paper)
2042 (defun open-research-paper-pdf (bibtexkey)
2043 "Open a paper pdf by bibtex key"
2044 (interactive "bibtex key: ")
2046 (format "%s -p evince_annot %s"
2047 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
2048 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
2050 (add-to-list 'org-link-abbrev-alist
2052 "~/projects/research/paper_notes.org::#%s"))
2054 ; I pretty much always want hiearchical checkboxes
2055 (setq org-hierachical-checkbox-statistics nil)
2057 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
2058 (add-to-list 'org-structure-template-alist
2059 '("E" "\\begin{equation}\n?\n\\end{equation}"))
2062 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
2063 (defun my-rtcite-export-handler (path desc format)
2064 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
2065 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
2066 (match-string 1 path)))
2067 (path (substring path 0 (match-beginning 0))))
2068 (cond ((eq format 'latex)
2070 (equal 0 (search "rtcite:" desc)))
2071 (format "\\cite{%s}" search)
2072 (format "\\cite[%s]{%s}" desc search))))))
2074 (org-add-link-type "rtcite"
2076 'my-rtcite-export-handler)
2080 ** Org Mobile Configuration
2081 #+BEGIN_SRC emacs-lisp
2082 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
2083 (when (string= system-name "linnode")
2084 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
2085 (setq-default org-directory "/home/don/org-mode/")
2086 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
2090 #+BEGIN_SRC emacs-lisp
2091 ;; org mode ical export
2092 (setq org-icalendar-timezone "America/Los_Angeles")
2093 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
2094 ;; we already add the id manually
2095 (setq org-icalendar-store-UID t)
2098 ** General Org Babel Configuration
2099 #+BEGIN_SRC emacs-lisp
2100 ;; org babel support
2101 (org-babel-do-load-languages
2102 'org-babel-load-languages
2109 ;; set the right path to ditaa.jar
2110 (setq org-ditaa-jar-path "/usr/share/ditaa/ditaa.jar")
2111 ;; use graphviz-dot for dot things
2112 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
2113 ;; do not indent begin_src blocks
2114 (setq org-edit-src-content-indentation 0)
2115 ;; org-babel-by-backend
2116 (defmacro org-babel-by-backend (&rest body)
2117 `(case (if (boundp 'backend)
2118 (org-export-backend-name backend)
2121 (defun my/fix-inline-images ()
2122 (when org-inline-image-overlays
2123 (org-redisplay-inline-images)))
2125 (add-hook 'org-babel-after-execute-hook
2126 'my/fix-inline-images)
2129 ** LaTeX configuration
2130 #+BEGIN_SRC emacs-lisp
2131 (use-package org-contrib
2136 (ox-extras-activate '(latex-header-blocks ignore-headlines))
2138 (add-to-list 'org-latex-classes
2140 "\\documentclass[11pt,oneside,article]{memoir}\n"
2141 ("\\section{%s}" . "\\section*{%s}")
2142 ("\\subsection{%s}" . "\\subsection*{%s}")
2143 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2144 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2145 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2147 (setq org-beamer-outline-frame-options "")
2148 (add-to-list 'org-latex-classes
2150 "\\documentclass[ignorenonframetext]{beamer}
2151 [NO-DEFAULT-PACKAGES]
2154 ("\\section{%s}" . "\\section*{%s}")
2155 ("\\subsection{%s}" . "\\subsection*{%s}")
2156 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2157 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2158 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2160 (add-to-list 'org-latex-classes
2162 "\\documentclass[11pt,oneside]{memoir}\n"
2163 ("\\chapter{%s}" . "\\chapter*{%s}")
2164 ("\\section{%s}" . "\\section*{%s}")
2165 ("\\subsection{%s}" . "\\subsection*{%s}")
2166 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
2168 (add-to-list 'org-latex-classes
2170 "\\documentclass[11pt]{letter}
2171 [NO-DEFAULT-PACKAGES]
2174 ("\\section{%s}" . "\\section*{%s}")
2175 ("\\subsection{%s}" . "\\subsection*{%s}")
2176 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2177 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2178 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2180 (add-to-list 'org-latex-classes
2182 "\\documentclass{dlacv}
2183 [NO-DEFAULT-PACKAGES]
2186 ("\\section{%s}" . "\\section*{%s}")
2187 ("\\subsection{%s}" . "\\subsection*{%s}")
2188 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2189 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2190 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2193 (add-to-list 'org-latex-classes
2195 "\\documentclass{dlaresume}
2196 [NO-DEFAULT-PACKAGES]
2199 ("\\section{%s}" . "\\section*{%s}")
2200 ("\\subsection{%s}" . "\\subsection*{%s}")
2201 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2202 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2203 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2206 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
2207 ;; but adapted to use latexmk 4.22 or higher.
2208 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
2210 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
2211 (setq org-latex-default-packages-alist
2213 ("" "unicode-math" t)
2215 (setq org-latex-packages-alist
2222 ("" "longtable" nil)
2225 ;; make equations larger
2226 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
2228 (defun org-create-formula--latex-header ()
2229 "Return LaTeX header appropriate for previewing a LaTeX snippet."
2230 (let ((info (org-combine-plists (org-export--get-global-options
2231 (org-export-get-backend 'latex))
2232 (org-export--get-inbuffer-options
2233 (org-export-get-backend 'latex)))))
2234 (org-latex-guess-babel-language
2235 (org-latex-guess-inputenc
2236 (org-splice-latex-header
2237 org-format-latex-header
2238 org-latex-default-packages-alist
2240 (plist-get info :latex-header)))
2244 ; support ignoring headers in org mode export to latex
2245 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
2246 (defadvice org-latex-headline (around my-latex-skip-headlines
2247 (headline contents info) activate)
2248 (if (member "ignoreheading" (org-element-property :tags headline))
2249 (setq ad-return-value contents)
2252 ;; keep latex logfiles
2254 (setq org-latex-remove-logfiles nil)
2257 ;; Resume clocking task when emacs is restarted
2258 (org-clock-persistence-insinuate)
2260 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
2261 (setq org-clock-history-length 23)
2262 ;; Resume clocking task on clock-in if the clock is open
2263 (setq org-clock-in-resume t)
2264 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
2265 ;; there are things like PHONE calls
2266 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
2267 ;; Separate drawers for clocking and logs
2268 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
2269 ;; Save clock data and state changes and notes in the LOGBOOK drawer
2270 (setq org-clock-into-drawer t)
2271 (setq org-log-into-drawer t)
2272 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
2273 (setq org-clock-out-remove-zero-time-clocks t)
2274 ;; Clock out when moving task to a done state
2275 (setq org-clock-out-when-done t)
2276 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
2277 (setq org-clock-persist t)
2278 ;; Do not prompt to resume an active clock
2279 (setq org-clock-persist-query-resume nil)
2280 ;; Enable auto clock resolution for finding open clocks
2281 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
2282 ;; Include current clocking task in clock reports
2283 (setq org-clock-report-include-clocking-task t)
2285 ;; the cache seems to be broken
2286 (setq org-element-use-cache nil)
2288 (defvar bh/keep-clock-running nil)
2290 (defun bh/is-task-p ()
2291 "Any task with a todo keyword and no subtask"
2295 (subtree-end (save-excursion (org-end-of-subtree t)))
2296 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2299 (while (and (not has-subtask)
2300 (< (point) subtree-end)
2301 (re-search-forward "^\*+ " subtree-end t))
2302 (when (member (org-get-todo-state) org-todo-keywords-1)
2303 (setq has-subtask t))))
2304 (and is-a-task (not has-subtask)))))
2305 (defun bh/is-project-p ()
2306 "Any task with a todo keyword subtask"
2310 (subtree-end (save-excursion (org-end-of-subtree t)))
2311 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2314 (while (and (not has-subtask)
2315 (< (point) subtree-end)
2316 (re-search-forward "^\*+ " subtree-end t))
2317 (when (member (org-get-todo-state) org-todo-keywords-1)
2318 (setq has-subtask t))))
2319 (and is-a-task has-subtask))))
2321 (defun bh/is-subproject-p ()
2322 "Any task which is a subtask of another project"
2323 (let ((is-subproject)
2324 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2326 (while (and (not is-subproject) (org-up-heading-safe))
2327 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
2328 (setq is-subproject t))))
2329 (and is-a-task is-subproject)))
2332 (defun bh/clock-in-to-next (kw)
2333 "Switch a task from TODO to NEXT when clocking in.
2334 Skips capture tasks, projects, and subprojects.
2335 Switch projects and subprojects from NEXT back to TODO"
2336 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
2338 ((and (member (org-get-todo-state) (list "TODO"))
2341 ((and (member (org-get-todo-state) (list "NEXT"))
2345 (defun bh/punch-in (arg)
2346 "Start continuous clocking and set the default task to the
2347 selected task. If no task is selected set the Organization task
2348 as the default task."
2350 (setq bh/keep-clock-running t)
2351 (if (equal major-mode 'org-agenda-mode)
2353 ;; We're in the agenda
2355 (let* ((marker (org-get-at-bol 'org-hd-marker))
2356 (tags (org-with-point-at marker (org-get-tags))))
2357 (if (and (eq arg 4) tags)
2358 (org-agenda-clock-in '(16))
2359 (bh/clock-in-organization-task-as-default)))
2361 ;; We are not in the agenda
2365 ; Find the tags on the current task
2366 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
2367 (org-clock-in '(16))
2368 (bh/clock-in-organization-task-as-default)))))
2370 (defun bh/punch-out ()
2372 (setq bh/keep-clock-running nil)
2373 (when (org-clock-is-active)
2375 (org-agenda-remove-restriction-lock))
2377 (defun bh/clock-in-default-task ()
2379 (org-with-point-at org-clock-default-task
2382 (defun bh/clock-in-parent-task ()
2383 "Move point to the parent (project) task if any and clock in"
2384 (let ((parent-task))
2388 (while (and (not parent-task) (org-up-heading-safe))
2389 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
2390 (setq parent-task (point))))
2392 (org-with-point-at parent-task
2394 (when bh/keep-clock-running
2395 (bh/clock-in-default-task)))))))
2397 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
2399 (defun bh/clock-in-organization-task-as-default ()
2401 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
2402 (org-clock-in '(16))))
2404 (defun bh/clock-out-maybe ()
2405 (when (and bh/keep-clock-running
2406 (not org-clock-clocking-in)
2407 (marker-buffer org-clock-default-task)
2408 (not org-clock-resolving-clocks-due-to-idleness))
2409 (bh/clock-in-parent-task)))
2411 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
2414 (defun bh/clock-in-task-by-id (id)
2415 "Clock in a task by id"
2416 (org-with-point-at (org-id-find id 'marker)
2417 (org-clock-in nil)))
2419 (defun bh/clock-in-last-task (arg)
2420 "Clock in the interrupted task if there is one
2421 Skip the default task and get the next one.
2422 A prefix arg forces clock in of the default task."
2424 (let ((clock-in-to-task
2426 ((eq arg 4) org-clock-default-task)
2427 ((and (org-clock-is-active)
2428 (equal org-clock-default-task (cadr org-clock-history)))
2429 (caddr org-clock-history))
2430 ((org-clock-is-active) (cadr org-clock-history))
2431 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
2432 (t (car org-clock-history)))))
2434 (org-with-point-at clock-in-to-task
2435 (org-clock-in nil))))
2438 (defun org-export-to-ods ()
2440 (let ((csv-file "data.csv"))
2441 (org-table-export csv-file "orgtbl-to-csv")
2442 (org-odt-convert csv-file "ods" 'open)))
2444 ; allow for zero-width-space to be a break in regexp too
2445 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
2446 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
2447 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
2449 ;; support inserting screen shots
2450 (defun my/org-insert-screenshot ()
2451 "Take a screenshot into a time stamped unique-named file in the
2452 same directory as the org-buffer and insert a link to this file."
2454 (defvar my/org-insert-screenshot/filename)
2455 (setq my/org-insert-screenshot/filename
2457 "Screenshot to insert: "
2459 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
2462 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
2463 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
2464 (org-display-inline-images))
2466 (defun my/fix-inline-images ()
2467 (when org-inline-image-overlays
2468 (org-redisplay-inline-images)))
2470 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
2472 ;; use xelatex to preview with imagemagick
2473 (add-to-list 'org-preview-latex-process-alist
2474 '(xelateximagemagick
2475 :programs ("xelatex" "convert")
2476 :description "pdf > png"
2477 :message "you need to install xelatex and imagemagick"
2479 :image-input-type "pdf"
2480 :image-output-type "png"
2481 :image-size-adjust (1.0 . 1.0)
2482 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
2483 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
2485 ;; use xelatex by default
2486 (setq org-preview-latex-default-process 'xelateximagemagick)
2488 ; from http://orgmode.org/Changes.html
2489 (defun my/org-repair-property-drawers ()
2490 "Fix properties drawers in current buffer.
2491 Ignore non Org buffers."
2493 (when (eq major-mode 'org-mode)
2494 (org-with-wide-buffer
2495 (goto-char (point-min))
2496 (let ((case-fold-search t)
2497 (inline-re (and (featurep 'org-inlinetask)
2498 (concat (org-inlinetask-outline-regexp)
2502 (unless (and inline-re (org-looking-at-p inline-re))
2504 (let ((end (save-excursion (outline-next-heading) (point))))
2506 (when (org-looking-at-p org-planning-line-re) (forward-line))
2507 (when (and (< (point) end)
2508 (not (org-looking-at-p org-property-drawer-re))
2510 (and (re-search-forward org-property-drawer-re end t)
2511 (eq (org-element-type
2512 (save-match-data (org-element-at-point)))
2514 (insert (delete-and-extract-region
2516 (min (1+ (match-end 0)) end)))
2517 (unless (bolp) (insert "\n"))))))))))))
2521 #+BEGIN_SRC emacs-lisp
2525 (use-package calfw-org
2528 (use-package org-gcal
2529 :if (file-readable-p "~/.hide/org_gcal.el")
2531 :config '((if (file-readable-p "~/.hide/org_gcal.el")
2532 (load-file "~/.hide/org_gcal.el"))
2537 #+BEGIN_SRC emacs-lisp
2541 ;; Show notification 10 minutes before event
2542 (setq appt-message-warning-time 10)
2543 ;; Disable multiple reminders
2544 (setq appt-display-interval appt-message-warning-time)
2545 (setq appt-display-mode-line nil)
2547 ;; add automatic reminders for appointments
2548 (defun my/org-agenda-to-appt ()
2550 (setq appt-time-msg-list nil)
2551 (org-agenda-to-appt))
2552 ;; add reminders when starting emacs
2553 (my/org-agenda-to-appt)
2554 ;; when rebuilding the agenda
2555 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
2556 "Pressing `r' on the agenda will also add appointments."
2557 (my/org-agenda-to-appt)
2559 ;; when saving all org buffers
2560 (defadvice org-save-all-org-buffers (after org-save-all-org-buffers-add-appts)
2561 "Re-add appts after saving all org buffers"
2562 (my/org-agenda-to-appt))
2563 ;; Display appointments as a window manager notification
2564 (setq appt-disp-window-function 'my/appt-display)
2565 (setq appt-delete-window-function (lambda () t))
2567 (setq my/appt-notification-app (concat (getenv "HOME") "/bin/appt_notification"))
2569 (defun my/appt-display (min-to-app new-time msg)
2570 (if (atom min-to-app)
2571 (start-process "my/appt-notification-app" nil my/appt-notification-app min-to-app msg)
2572 (dolist (i (number-sequence 0 (1- (length min-to-app))))
2573 (start-process "my/appt-notification-app" nil my/appt-notification-app
2574 (nth i min-to-app) (nth i msg))))
2581 #+BEGIN_SRC emacs-lisp
2585 ** Home/End Begining/End of line
2586 #+BEGIN_SRC emacs-lisp
2587 (global-set-key [home] 'move-beginning-of-line)
2588 (global-set-key [end] 'move-end-of-line)
2591 #+BEGIN_SRC emacs-lisp
2592 ; (global-unset-key "\M-g")
2593 ; (global-set-key (kbd "M-g l") 'goto-line)
2597 #+BEGIN_SRC emacs-lisp
2598 (use-package debian-changelog-mode
2599 :mode "debian/changelog"
2602 (setq debian-changelog-mailing-address "don@debian.org")
2603 (setq debian-changelog-full-name "Don Armstrong"))
2605 * Misc (uncharacterized)
2606 #+BEGIN_SRC emacs-lisp
2607 (setq calendar-latitude 38.6)
2608 (setq calendar-longitude -121.5)
2609 (setq case-fold-search t)
2610 (setq confirm-kill-emacs (quote y-or-n-p))
2614 #+BEGIN_SRC emacs-lisp
2615 (global-font-lock-mode 1)
2618 #+BEGIN_SRC emacs-lisp
2619 (setq ps-footer-font-size (quote (8 . 10)))
2620 (setq ps-header-font-size (quote (8 . 10)))
2621 (setq ps-header-title-font-size (quote (10 . 10)))
2622 (setq ps-line-number-color "blue")
2623 (setq ps-print-footer t)
2624 (setq ps-print-footer-frame nil)
2625 (setq ps-print-only-one-header t)
2627 ** Only single spacing on sentences
2628 #+BEGIN_SRC emacs-lisp
2629 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
2631 (setq sentence-end-double-space nil)
2632 ; enable matching parenthesis
2634 ** Display paren mode
2635 #+BEGIN_SRC emacs-lisp
2637 (setq show-paren-delay 0.2)
2641 #+BEGIN_SRC emacs-lisp
2642 (setq user-mail-address "don@donarmstrong.com")
2645 ** Use primary selection on unix machines
2646 #+BEGIN_SRC emacs-lisp
2647 ;; switch back to the old primary selection method
2648 (if (or (string-equal system-type "darwin")
2649 (string-equal system-type "windows")
2652 (setq select-enable-clipboard t)
2653 (setq select-enable-primary nil)
2656 (setq select-enable-clipboard nil)
2657 (setq select-enable-primary t)
2659 ; (setq mouse-drag-copy-region t)
2661 (setq-default c-indent-level 4)
2662 (setq-default c-brace-imaginary-offset 0)
2663 (setq-default c-brace-offset -4)
2664 (setq-default c-argdecl-indent 4)
2665 (setq-default c-label-offset -4)
2666 (setq-default c-continued-statement-offset 4)
2668 (setq-default indent-tabs-mode nil)
2669 (setq-default tab-width 4)
2671 (defun insert-date ()
2672 "Insert date at point."
2674 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
2675 (global-set-key "\C-[d" 'insert-date)
2677 (defun unfill-paragraph (arg)
2678 "Pull this whole paragraph up onto one line."
2680 (let ((fill-column 10000))
2681 (fill-paragraph arg))
2684 (column-number-mode t)
2687 ** Desktop-save-mode
2688 If the envvar EMACS_SERVER_NAME is set, consider this a separate
2689 emacs, and use a different desktop file to restore history
2690 #+BEGIN_SRC emacs-lisp
2691 (use-package desktop
2694 (setq desktop-base-file-name
2695 (convert-standard-filename
2697 (or (getenv "EMACS_SERVER_NAME")
2701 (setq desktop-base-lock-name
2702 (convert-standard-filename
2703 (concat desktop-base-file-name
2705 (setq desktop-auto-save-timeout 60)
2706 (setq desktop-restore-eager 5)
2707 (setq desktop-lazy-verbose nil)
2708 (desktop-save-mode 1)
2712 ** Misc (Uncharacterized)
2713 #+BEGIN_SRC emacs-lisp
2715 (put 'upcase-region 'disabled nil)
2716 (put 'downcase-region 'disabled nil)
2717 (put 'narrow-to-region 'disabled nil)
2719 ; Outline-minor-mode key map
2720 (define-prefix-command 'cm-map nil "Outline-")
2722 (define-key cm-map "q" 'outline-hide-sublevels) ; Hide everything but the top-level headings
2723 (define-key cm-map "t" 'outline-hide-body) ; Hide everything but headings (all body lines)
2724 (define-key cm-map "o" 'outline-hide-other) ; Hide other branches
2725 (define-key cm-map "c" 'outline-hide-entry) ; Hide this entry's body
2726 (define-key cm-map "l" 'outline-hide-leaves) ; Hide body lines in this entry and sub-entries
2727 (define-key cm-map "d" 'outline-hide-subtree) ; Hide everything in this entry and sub-entries
2729 (define-key cm-map "a" 'outline-show-all) ; Show (expand) everything
2730 (define-key cm-map "e" 'outline-show-entry) ; Show this heading's body
2731 (define-key cm-map "i" 'outline-show-children) ; Show this heading's immediate child sub-headings
2732 (define-key cm-map "k" 'outline-show-branches) ; Show all sub-headings under this heading
2733 (define-key cm-map "s" 'outline-show-subtree) ; Show (expand) everything in this heading & below
2735 (define-key cm-map "u" 'outline-up-heading) ; Up
2736 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
2737 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
2738 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
2739 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
2740 (global-set-key "\M-o" cm-map)
2741 ; fix up tmux xterm keys
2742 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
2743 (defun fix-up-tmux-keys ()
2744 "Fix up tmux xterm keys"
2747 (let ((x 2) (tkey ""))
2767 ;; ctrl + alt + shift
2769 (setq tkey "C-M-S-"))
2772 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
2773 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
2774 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
2775 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
2777 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
2779 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
2781 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
2783 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
2785 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2787 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2789 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
2791 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
2793 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
2795 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
2797 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
2799 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
2801 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
2803 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
2805 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
2807 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
2809 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
2811 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
2813 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
2815 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
2817 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
2819 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
2821 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
2823 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
2825 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
2827 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
2834 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
2836 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
2837 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
2838 (if (or (buffer-modified-p)
2839 (verify-visited-file-modtime)
2840 (< (* 8 1024 1024) (buffer-size))
2841 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
2843 (clear-visited-file-modtime)
2845 (ad-activate 'ask-user-about-supersession-threat)
2849 #+BEGIN_SRC emacs-lisp
2853 (or (getenv "EMACS_SERVER_NAME")
2855 (unless (server-running-p)
2856 ; (global-set-key "\C-xp" 'server-edit)
2861 #+BEGIN_SRC emacs-lisp
2862 (provide 'don-configuration)