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 (add-hook 'text-mode-hook 'turn-on-flyspell)
207 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
208 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
209 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
211 (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 (lsp-completion-mode . my/lsp-mode-setup-completion)
488 (lsp-completion-provider :none) ;; we use Corfu!
490 ;; Provides visual help in the buffer
491 ;; For example definitions on hover.
492 ;; The `imenu` lets me browse definitions quickly.
496 (setq lsp-ui-sideline-enable nil
498 :hook (lsp-mode . lsp-ui-mode)
499 :bind (:map lsp-ui-mode-map
500 ("C-c i" . lsp-ui-imenu)))
501 ;; Language server for Python
502 ;; Read the docs for the different variables set in the config.
503 (use-package lsp-pyright
506 (setq lsp-clients-python-library-directories '("/usr/"))
507 (setq lsp-pyright-disable-language-service nil
508 lsp-pyright-disable-organize-imports nil
509 lsp-pyright-auto-import-completions t
510 lsp-pyright-use-library-code-for-types t
511 lsp-pyright-venv-path "venv")
512 :hook ((python-mode . (lambda ()
513 (require 'lsp-pyright) (lsp-deferred)))))
516 #+BEGIN_SRC emacs-lisp
520 ;; Optional customizations
522 (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
523 (corfu-auto t) ;; Enable auto completion
524 (corfu-separator ?\s) ;; Orderless field separator
525 (corfu-quit-at-boundary nil) ;; Never quit at completion boundary
526 (corfu-quit-no-match nil) ;; Never quit, even if there is no match
527 (corfu-preview-current nil) ;; Disable current candidate preview
528 (corfu-preselect 'prompt) ;; Preselect the prompt
529 (corfu-on-exact-match nil) ;; Configure handling of exact matches
530 (corfu-scroll-margin 5) ;; Use scroll margin
536 #+BEGIN_SRC emacs-lisp
539 ;; Swap M-/ and C-M-/
540 :bind (("M-/" . dabbrev-completion)
541 ("C-M-/" . dabbrev-expand))
542 ;; Other useful Dabbrev configurations.
544 (dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'")))
548 #+BEGIN_SRC emacs-lisp
550 (use-package tinyprocmail
551 :straight (tinytools :type git :type git :host github :repo "jaalto/project--emacs-tiny-tools")
552 ; :load-path "~/lib/emacs_el/tiny-tools/lisp/tiny"
553 :mode (".procmailrc" . turn-on-tinyprocmail-mode)
558 #+BEGIN_SRC emacs-lisp
561 :bind (("C-x g" . magit-status)
562 ("C-x C-g" . magit-status))
564 ;; refine diffs always (hilight words)
565 (setq magit-diff-refine-hunk nil)
567 (use-package magit-annex
570 (use-package magit-vcsh
575 *** Forge (github/gitlab)
576 #+BEGIN_SRC emacs-lisp
583 #+BEGIN_SRC emacs-lisp
584 (use-package cperl-mode
587 ;; Use c-mode for perl .xs files
588 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
589 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
590 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
591 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
592 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
595 cperl-auto-newline nil
596 cperl-auto-newline-after-colon nil
597 cperl-continued-statement-offset 4
598 cperl-brace-offset -1
599 cperl-continued-brace-offset 0
600 cperl-label-offset -4
601 cperl-highlight-variables-indiscriminately t
602 cperl-electric-lbrace-space nil
603 cperl-indent-parens-as-block nil
604 cperl-close-paren-offset -1
605 cperl-tab-always-indent t)
606 (setq cperl-lazy-help-time nil)
607 ;;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
612 #+BEGIN_SRC emacs-lisp
613 (use-package markdown-mode
616 :mode (("\\.md\\'" . markdown-mode)
617 ("\\.mdwn\\'" . markdown-mode)
618 ("README\\.md\\'" . gfm-mode)
621 (setq markdown-enable-math t)
622 (setq markdown-follow-wiki-link-on-enter nil)
623 (bind-key "M-." #'markdown-jump markdown-mode-map)
624 (add-hook 'markdown-mode-hook #'flyspell-mode)
625 (add-hook 'markdown-mode-hook #'outline-minor-mode)
626 (bind-key "C-<tab>" #'outline-cycle markdown-mode-map)
631 #+BEGIN_SRC emacs-lisp
632 ; load sql-indent when sql is loaded
633 (use-package sql-indent
637 :mode (("\\.sql\\'" . sql-mode))
641 #+BEGIN_SRC emacs-lisp
643 :commands ediff ediff3
645 ;; ediff configuration
646 ;; don't use the multi-window configuration
647 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
650 ** Do the Right Thing Indenting
651 Attempts to automatically identify the right indentation for a file
652 #+BEGIN_SRC emacs-lisp
653 (use-package dtrt-indent
656 ** VCL --editing varnish configuration files
657 #+BEGIN_SRC emacs-lisp
658 (use-package vcl-mode
663 #+BEGIN_SRC emacs-lisp
668 ; (define-key vertico-map "\r" #'vertico-directory-enter)
669 ; (define-key vertico-map "\d" #'vertico-directory-delete-char)
670 ; (define-key vertico-map "\M-\d" #'vertico-directory-delete-word)
671 ; (add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy)
673 ;; Different scroll margin
674 ;; (setq vertico-scroll-margin 0)
676 ;; Show more candidates
677 ;; (setq vertico-count 20)
679 ;; Grow and shrink the Vertico minibuffer
680 ;; (setq vertico-resize t)
682 ;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
683 ;; (setq vertico-cycle t)
685 (vertico-grid-separator " ")
686 (vertico-grid-lookahead 50)
688 (use-package vertico-multiform
690 :load-path "~/var/emacs/straight/build/vertico/extensions/"
693 (setq vertico-multiform-categories
695 (consult-grep buffer)
698 (library reverse indexed)
699 (org-roam-node reverse indexed)
703 (setq vertico-multiform-commands
704 '(("flyspell-correct-*" grid reverse)
705 (org-refile grid reverse indexed)
706 (consult-yank-pop indexed)
708 (consult-lsp-diagnostics)
711 (vertico-multiform-mode)
714 (use-package vertico-grid
718 (use-package vertico-reverse
722 (use-package vertico-indexed
726 (use-package vertico-buffer
732 ;; Persist history over Emacs restarts. Vertico sorts by history position.
733 (use-package savehist
739 ** Orderless: advanced completion style
740 #+begin_src emacs-lisp
741 (use-package orderless
744 ;; Configure a custom style dispatcher (see the Consult wiki)
745 ;; (setq orderless-style-dispatchers '(+orderless-dispatch)
746 ;; orderless-component-separator #'orderless-escapable-split-on-space)
747 (setq completion-styles '(orderless basic)
748 completion-category-defaults nil
749 completion-category-overrides '((file (styles partial-completion)))))
751 ** Marginalia: Rich annotations in the minibuffer
752 #+begin_src emacs-lisp
753 (use-package marginalia
755 :bind (:map minibuffer-local-map
756 ("M-A" . marginalia-cycle))
761 ** Embark: Minibuffer actions and context menu
762 #+begin_src emacs-lisp
765 (("C-." . embark-act) ;; pick some comfortable binding
766 ("C-;" . embark-dwim) ;; good alternative: M-.
767 ("C-h B" . embark-bindings)) ;; alternative for `describe-bindings'
771 ;; Optionally replace the key help with a completing-read interface
772 (setq prefix-help-command #'embark-prefix-help-command)
776 ;; Hide the mode line of the Embark live/completions buffers
777 (add-to-list 'display-buffer-alist
778 '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
780 (window-parameters (mode-line-format . none)))))
782 (use-package embark-consult
784 (embark-collect-mode . consult-preview-at-point-mode))
787 #+begin_src emacs-lisp
789 ;; Replace bindings. Lazily loaded due by `use-package'.
790 :bind (;; C-c bindings in `mode-specific-map'
791 ("C-c M-x" . consult-mode-command)
792 ("C-c h" . consult-history)
793 ("C-c k" . consult-kmacro)
794 ("C-c m" . consult-man)
795 ("C-c i" . consult-info)
796 ([remap Info-search] . consult-info)
797 ;; C-x bindings in `ctl-x-map'
798 ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command
799 ("C-x b" . consult-buffer) ;; orig. switch-to-buffer
800 ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
801 ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame
802 ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
803 ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer
804 ;; Custom M-# bindings for fast register access
805 ("M-#" . consult-register-load)
806 ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated)
807 ("C-M-#" . consult-register)
808 ;; Other custom bindings
809 ("M-y" . consult-yank-pop) ;; orig. yank-pop
810 ;; M-g bindings in `goto-map'
811 ("M-g e" . consult-compile-error)
812 ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck
813 ("M-g g" . consult-goto-line) ;; orig. goto-line
814 ("M-g M-g" . consult-goto-line) ;; orig. goto-line
815 ("M-g o" . consult-outline) ;; Alternative: consult-org-heading
816 ("M-g m" . consult-mark)
817 ("M-g k" . consult-global-mark)
818 ("M-g i" . consult-imenu)
819 ("M-g I" . consult-imenu-multi)
820 ;; M-s bindings in `search-map'
821 ("M-s d" . consult-find)
822 ("M-s D" . consult-locate)
823 ("M-s g" . consult-grep)
824 ("M-s G" . consult-git-grep)
825 ("M-s r" . consult-ripgrep)
826 ("M-s l" . consult-line)
827 ("M-s L" . consult-line-multi)
828 ("M-s k" . consult-keep-lines)
829 ("M-s u" . consult-focus-lines)
830 ;; Isearch integration
831 ("M-s e" . consult-isearch-history)
832 :map isearch-mode-map
833 ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string
834 ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string
835 ("M-s l" . consult-line) ;; needed by consult-line to detect isearch
836 ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch
837 ;; Minibuffer history
838 :map minibuffer-local-map
839 ("M-s" . consult-history) ;; orig. next-matching-history-element
840 ("M-r" . consult-history)) ;; orig. previous-matching-history-element
842 ;; Enable automatic preview at point in the *Completions* buffer. This is
843 ;; relevant when you use the default completion UI.
844 :hook (completion-list-mode . consult-preview-at-point-mode)
846 :commands (consult-xref)
848 ;; The :init configuration is always executed (Not lazy)
851 ;; Optionally configure the register formatting. This improves the register
852 ;; preview for `consult-register', `consult-register-load',
853 ;; `consult-register-store' and the Emacs built-ins.
854 (setq register-preview-delay 0.5
855 register-preview-function #'consult-register-format)
857 ;; Optionally tweak the register preview window.
858 ;; This adds thin lines, sorting and hides the mode line of the window.
859 (advice-add #'register-preview :override #'consult-register-window)
861 ;; Use Consult to select xref locations with preview
862 (setq xref-show-xrefs-function #'consult-xref
863 xref-show-definitions-function #'consult-xref)
865 ;; Configure other variables and modes in the :config section,
866 ;; after lazily loading the package.
868 ;; Optionally configure preview. The default value
869 ;; is 'any, such that any key triggers the preview.
870 ;; (setq consult-preview-key 'any)
871 ;; (setq consult-preview-key "M-.")
872 ;; (setq consult-preview-key '("S-<down>" "S-<up>"))
873 ;; For some commands and buffer sources it is useful to configure the
874 ;; :preview-key on a per-command basis using the `consult-customize' macro.
876 consult-theme :preview-key '(:debounce 0.2 any)
877 consult-ripgrep consult-git-grep consult-grep
878 consult-bookmark consult-recent-file consult-xref
879 consult--source-bookmark consult--source-file-register
880 consult--source-recent-file consult--source-project-recent-file
881 ;; :preview-key "M-."
882 :preview-key '(:debounce 0.4 any))
884 ;; Optionally configure the narrowing key.
885 ;; Both < and C-+ work reasonably well.
886 (setq consult-narrow-key "<") ;; "C-+"
888 ;; Optionally make narrowing help available in the minibuffer.
889 ;; You may want to use `embark-prefix-help-command' or which-key instead.
890 ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)
892 ;; By default `consult-project-function' uses `project-root' from project.el.
893 ;; Optionally configure a different project root function.
894 ;;;; 1. project.el (the default)
895 ;; (setq consult-project-function #'consult--default-project--function)
896 ;;;; 2. vc.el (vc-root-dir)
897 ;; (setq consult-project-function (lambda (_) (vc-root-dir)))
898 ;;;; 3. locate-dominating-file
899 ;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git")))
900 ;;;; 4. projectile.el (projectile-project-root)
901 ;; (autoload 'projectile-project-root "projectile")
902 ;; (setq consult-project-function (lambda (_) (projectile-project-root)))
903 ;;;; 5. No project support
904 ;; (setq consult-project-function nil)
907 ** Projectile -- Project management
908 #+begin_src emacs-lisp
909 (use-package projectile
910 :bind (("<f5>" . projectile-compile-project)
911 ("<f6>" . next-error))
912 :config (projectile-global-mode))
916 #+BEGIN_SRC emacs-lisp
918 :bind ("M-z" . avy-zap-up-to-char-dwim))
921 #+BEGIN_SRC emacs-lisp
923 :bind (("C-c 2" . my/hydra-orgmodes/body)
924 ("C-c @" . my/hydra-orgmodes/body)
925 ("C-c #" . my/hydra-outline/body)
926 ("C-c 3" . my/hydra-outline/body)
929 (defhydra my/hydra-orgmodes (:color blue :hint nil)
931 _n_: notes _c_: chaim _w_: wildman _o_: ool
932 _u_: uddin _s_: steve _r_: refile _f_: fh
933 _p_: read papers _R_: paper notes
938 ("n" (find-file "~/projects/org-notes/notes.org"))
939 ("c" (find-file "~/projects/org-notes/chaim.org"))
940 ("w" (find-file "~/projects/org-notes/wildman.org"))
941 ("u" (find-file "~/projects/org-notes/uddin.org"))
942 ("o" (find-file "~/projects/org-notes/ool.org"))
943 ("f" (find-file "~/projects/org-notes/fh.org"))
944 ("s" (find-file "~/projects/org-notes/sndservers.org"))
945 ("r" (find-file my/org-refile-file))
946 ("p" (find-file "~/projects/research/papers_to_read.org"))
947 ("R" (find-file "~/projects/research/paper_notes.org"))
948 ("h" (find-file "~/projects/org-notes/hpcbio.org"))
953 ;; from https://github.com/abo-abo/hydra/wiki/Emacs
954 (defhydra my/hydra-outline (:color pink :hint nil)
957 ^^^^^^------------------------------------------------------
958 _q_: sublevels _a_: all _u_: up
959 _t_: body _e_: entry _n_: next visible
960 _o_: other _i_: children _p_: previous visible
961 _c_: entry _k_: branches _f_: forward same level
962 _l_: leaves _s_: subtree _b_: backward same level
967 ("q" outline-hide-sublevels) ; Hide everything but the top-level headings
968 ("t" outline-hide-body) ; Hide everything but headings (all body lines)
969 ("o" outline-hide-other) ; Hide other branches
970 ("c" outline-hide-entry) ; Hide this entry's body
971 ("l" outline-hide-leaves) ; Hide body lines in this entry and sub-entries
972 ("d" outline-hide-subtree) ; Hide everything in this entry and sub-entries
974 ("a" outline-show-all) ; Show (expand) everything
975 ("e" outline-show-entry) ; Show this heading's body
976 ("i" outline-show-children) ; Show this heading's immediate child sub-headings
977 ("k" outline-show-branches) ; Show all sub-headings under this heading
978 ("s" outline-show-subtree) ; Show (expand) everything in this heading & below
980 ("u" outline-up-heading) ; Up
981 ("n" outline-next-visible-heading) ; Next
982 ("p" outline-previous-visible-heading) ; Previous
983 ("f" outline-forward-same-level) ; Forward - same level
984 ("b" outline-backward-same-level) ; Backward - same level
990 #+BEGIN_SRC emacs-lisp
993 ; use the built in tramp
996 (setq tramp-use-ssh-controlmaster-options nil)
997 (add-to-list 'tramp-methods '("vcsh"
998 (tramp-login-program "vcsh")
1002 (tramp-remote-shell "/bin/sh")
1003 (tramp-remote-shell-args
1007 #+BEGIN_SRC emacs-lisp
1010 (setq-default reftex-default-bibliography
1011 '("~/projects/research/references.bib")))
1014 #+BEGIN_SRC emacs-lisp
1016 :config (setq bibtex-user-optional-fields
1017 (quote (("annote" "Personal annotation (ignored)")
1025 #+BEGIN_SRC emacs-lisp
1026 (use-package tex-site
1028 :mode ("\\.tex\\'" . LaTeX-mode)
1029 :mode ("\\.bib\\'" . bibtex-mode)
1031 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
1032 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
1033 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
1034 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
1035 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
1036 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
1037 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
1038 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
1039 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
1040 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
1041 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
1043 (setq-default reftex-plug-into-AUCTeX t)
1044 ;; support fake section headers
1045 (setq TeX-outline-extra
1049 ("%subsubsection" 4)
1051 ;; add font locking to the headers
1052 (font-lock-add-keywords
1054 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
1055 0 'font-lock-keyword-face t)
1056 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
1057 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
1058 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
1059 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
1060 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
1062 ;; use smart quotes by default instead of `` and ''
1063 ;; taken from http://kieranhealy.org/esk/kjhealy.html
1064 (setq TeX-open-quote "“")
1065 (setq TeX-close-quote "”")
1067 ;; (TeX-add-style-hook
1072 ;; (custom-set-variables
1073 ;; '(font-latex-user-keyword-classes
1076 ;; font-lock-function-name-face 2 (command 1 t))))
1078 (setq-default TeX-parse-self t)
1079 (setq-default TeX-auto-save t)
1080 (setq-default TeX-master nil)
1081 (add-to-list 'LaTeX-font-list
1082 '(?\C-a "\\alert{","}"))
1085 '(TeX-add-style-hook
1088 (if (boundp 'reftex-ref-style-alist)
1090 'reftex-ref-style-alist
1091 '("Cleveref" "cleveref"
1092 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
1093 (reftex-ref-style-activate "Cleveref")
1095 '("cref" TeX-arg-ref)
1096 '("Cref" TeX-arg-ref)
1097 '("cpageref" TeX-arg-ref)
1098 '("Cpageref" TeX-arg-ref)))))
1101 '(add-to-list 'LaTeX-fill-excluded-macros
1104 (setq font-latex-match-reference-keywords
1125 (setq font-latex-fontify-script nil)
1126 (setq font-latex-fontify-sectioning (quote color))
1127 (setq font-latex-script-display (quote (nil)))
1132 #+BEGIN_SRC emacs-lisp
1135 :mode ("\\.R\\'" . ess-r-mode)
1136 :bind (:map ess-mode-map
1137 ("C-c C-R" . dla/ess-region-remote-eval))
1139 (autoload 'ess-r-mode "ess-site" nil t)
1140 (autoload 'R "ess-site" nil t)
1142 ; actually load the rest of ess
1144 (defun ess-change-directory (path)
1145 "Set the current working directory to PATH for both *R* and Emacs."
1146 (interactive "Directory to change to: ")
1148 (when (file-exists-p path)
1149 (ess-command (concat "setwd(\"" path "\")\n"))
1150 ;; use file-name-as-directory to ensure it has trailing /
1151 (setq default-directory (file-name-as-directory path))))
1152 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
1153 ;; outlining support for ess modes
1157 (outline-minor-mode)
1158 (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
1159 (defun outline-level ()
1160 (cond ((looking-at "^##### ") 1)
1161 ((looking-at "^#### ") 2)
1162 ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
1165 (defun dla/ess-region-remote-eval (start end)
1166 "Evaluate region in a remote ESS instance"
1168 (shell-command-on-region start end "eval_r" (get-buffer-create "***essregionremoteeval***") nil nil nil)
1169 (kill-buffer "***essregionremoteeval***"))
1170 ;; Don't restore history or save workspace image
1171 '(inferior-R-args "--no-restore-history --no-save")
1176 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
1178 #+BEGIN_SRC emacs-lisp
1179 (use-package rainbow-mode
1180 ;; add ess to the x major mode
1181 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
1182 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
1187 #+BEGIN_SRC emacs-lisp
1188 (use-package yaml-mode
1189 ;; add ess to the x major mode
1190 :mode ("\\.\\(yaml|yml\\)\\'" . yaml-mode)
1195 #+BEGIN_SRC emacs-lisp
1196 (use-package poly-noweb
1200 (use-package poly-markdown
1204 :after (:all polymode poly-markdown poly-noweb)
1205 :mode ("\\.Snw" . poly-noweb+r-mode)
1206 :mode ("\\.Rnw" . poly-noweb+r-mode)
1207 :mode ("\\.Rmd" . poly-markdown+r-mode)
1209 (use-package polymode
1215 *** outline minor mode
1216 #+BEGIN_SRC emacs-lisp
1217 (use-package outline
1221 (setq outline-minor-mode-prefix "C-c C-2")
1224 *** outshine (outlining) integration
1225 #+BEGIN_SRC emacs-lisp
1226 (use-package outshine
1228 :hook (outline-minor-mode . outshine-mode)
1232 #+BEGIN_SRC emacs-lisp
1233 (use-package writeroom-mode
1235 (defun my/writing-mode ()
1236 "Start my writing mode; enable visual-line-mode and auto-fill-mode"
1241 (visual-line-mode -1)
1243 (visual-fill-column-mode -1)
1245 (visual-line-mode 1)
1247 (visual-fill-column-mode 1)
1252 ** GhostText/Atomic Chrome
1253 #+BEGIN_SRC emacs-lisp
1254 (use-package atomic-chrome
1256 (ignore-errors (atomic-chrome-start-server))
1257 (setq atomic-chrome-buffer-open-style 'full)
1261 #+BEGIN_SRC emacs-lisp
1262 (use-package edit-server
1263 :commands edit-server-start
1264 :init (if after-init-time
1266 (add-hook 'after-init-hook
1267 #'(lambda() (edit-server-start))))
1268 :config (setq edit-server-new-frame-alist
1269 '((name . "Edit with Emacs FRAME")
1275 (menu-bar-lines . t)
1276 (window-system . x)))
1280 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
1281 #+BEGIN_SRC emacs-lisp
1282 (use-package multiple-cursors
1283 :bind* (("C-;" . mc/mark-all-dwim)
1284 ("C-<" . mc/mark-previous-like-this)
1285 ("C->" . mc/mark-next-like-this)
1286 ("C-S-c C-S-c" . mc/edit-lines))
1290 #+BEGIN_SRC emacs-lisp
1291 (use-package web-mode
1292 :mode ("\\.\\(tx|tmpl\\)\\'" . web-mode)
1294 (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . web-mode))
1295 (setq web-mode-enable-engine-detection t)
1296 (setq web-mode-engines-alist
1297 '(("template-toolkit" . "\\.tmpl\\'")))
1300 ** Spamassassin Mode
1301 #+BEGIN_SRC emacs-lisp
1302 (use-package spamassassin-mode
1304 :load-path "~/lib/emacs_el"
1305 :commands spamassassin-mode
1309 #+BEGIN_SRC emacs-lisp
1310 (use-package password-store
1311 :commands password-store-edit password-store-generate
1313 (defun dla/password-store-edit (entry)
1314 "Edit password for ENTRY which doesn't require it to already exist"
1315 (interactive (list (password-store--completing-read nil)))
1316 (password-store--run-edit entry))
1317 (advice-add 'password-store-edit :override #'dla/password-store-edit)
1321 #+BEGIN_SRC emacs-lisp
1326 ;; fix up css mode to not be silly
1327 ;; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
1328 (setq cssm-indent-level 4)
1329 (setq cssm-newline-before-closing-bracket t)
1330 (setq cssm-indent-function #'cssm-c-style-indenter)
1331 (setq cssm-mirror-mode nil))
1334 #+BEGIN_SRC emacs-lisp
1337 :delight abbrev-mode
1339 ;; load abbreviations from
1340 (setq abbrev-file-name
1341 "~/.emacs_abbrev_def")
1343 ;; read the abbrev file if it exists
1344 (if (file-exists-p abbrev-file-name)
1345 (quietly-read-abbrev-file))
1347 ;; for now, use abbrev mode everywhere
1349 (setq default-abbrev-mode t))
1352 ** Debugging (realgud)
1353 #+BEGIN_SRC emacs-lisp
1354 (use-package realgud
1355 :commands (realgud:pdb realgud:gdb)
1358 ** Python Programming
1359 #+BEGIN_SRC emacs-lisp
1360 (use-package python-mode
1363 (python-mode . pyenv-mode)
1364 (python-mode . flycheck-mode)
1365 (python-mode . blacken-mode)
1366 (python-mode . yas-minor-mode)
1367 (python-mode . anaconda-mode)
1369 (use-package pyenv-mode
1372 (use-package blacken
1376 (setq-default blacken-fast-unsafe t)
1380 #+begin_src emacs-lisp :tangle yes
1381 (use-package python-black
1385 *** Sphinx Documentation
1386 #+begin_src emacs-lisp :tangle yes
1387 (use-package numpydoc
1389 :bind (:map python-mode-map
1390 ("C-c C-n" . numpydoc-generate)))
1391 (use-package sphinx-doc
1394 (setq sphinx-doc-include-types t)
1396 :hook (python-mode . sphinx-doc)
1398 (use-package python-docstring
1401 :hook (python-mode . python-docstring-mode)
1405 #+BEGIN_SRC emacs-lisp
1406 (use-package go-mode
1413 #+BEGIN_SRC emacs-lisp
1414 (use-package expand-region
1415 :bind (("C-=" . 'er/expand-region))
1420 #+BEGIN_SRC emacs-lisp
1421 (use-package dockerfile-mode
1427 #+BEGIN_SRC emacs-lisp
1428 (use-package beancount
1430 :load-path "~/lib/emacs_el/beancount-mode/"
1431 :mode "\\.beancount\\'"
1438 #+BEGIN_SRC emacs-lisp
1439 (use-package message
1441 :delight (message "✉")
1442 :delight (message-mode "✉")
1443 :mode ("muttng-[a-z0-9]+-[0-9]+-" . message-mode)
1444 :mode ("mutt-[a-z0-9]+-[0-9]+-" . message-mode)
1445 :hook 'my/message-mode-settings
1446 :hook 'turn-on-flyspell
1447 :bind (:map message-mode-map
1448 ("C-c C-a" . my/post-attach-file)
1449 ("C-x p" . my/message-kill-buffer)
1452 (defun my/message-mode-settings ()
1453 (font-lock-add-keywords nil
1454 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1455 (0 'message-multiply-quoted-text-face))
1456 ("^[ \t]*>[ \t]*>.*$"
1457 (0 'message-double-quoted-text-face))))
1459 (defun my/message-kill-buffer ()
1463 (defun my/post-attach-file ()
1464 "Prompt for an attachment."
1466 (let ((file (read-file-name "Attach file: " nil nil t nil)))
1467 (my/header-attach-file file "")))
1469 (defun my/header-attach-file (file description)
1470 "Attach a FILE to the current message (works with Mutt).
1471 Argument DESCRIPTION MIME description."
1472 (interactive "fAttach file: \nsDescription: ")
1473 (when (> (length file) 0)
1478 (goto-char (point-min))
1479 (search-forward-regexp "^$")
1480 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1482 (message (concat "Attached '" file "'."))
1483 (setq post-has-attachment t))))))
1485 (setq mail-yank-prefix "> ")
1486 (setq mail-header-separator "") ; fix broken header detection
1490 #+BEGIN_SRC emacs-lisp
1491 (use-package mutt-mode
1496 *** Set mail User agent
1497 #+BEGIN_SRC emacs-lisp
1498 (setq mail-user-agent (quote sendmail-user-agent))
1501 #+BEGIN_SRC emacs-lisp
1506 ; (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
1510 ** Reverting buffers
1511 #+BEGIN_SRC emacs-lisp
1512 (use-package autorevert
1513 :delight auto-revert-mode
1515 (setq global-auto-revert-non-file-buffers t
1516 global-auto-revert-ignore-modes '(pdf-view-mode)
1517 auto-revert-verbose nil)
1518 (global-auto-revert-mode 1))
1521 ** Use-package and load things
1522 #+BEGIN_SRC emacs-lisp
1525 :delight (org-mode "ø")
1526 :mode ("\\.\\(org\\|org_archive\\|txt\\)\\'" . org-mode)
1527 :bind (("C-c l" . org-store-link)
1528 ("C-c a" . org-agenda)
1529 ("C-c b" . org-iswitchb))
1531 ** Agenda Configuration
1532 #+BEGIN_SRC emacs-lisp
1534 (setq-default org-log-done 'time)
1535 (setq-default org-agenda-ndays 5)
1537 (setq org-agenda-sticky t)
1538 (defun dla/show-org-agenda ()
1543 (and (string-match-p
1551 (buffer-name agendabuffer))
1553 (delete-other-windows))
1555 ;; agenda configuration
1556 ;; Do not dim blocked tasks
1557 (setq org-agenda-dim-blocked-tasks nil)
1558 (setq org-agenda-inhibit-startup t)
1559 (setq org-agenda-use-tag-inheritance nil)
1561 ;; Compact the block agenda view
1562 (setq org-agenda-compact-blocks t)
1564 ;; Custom agenda command definitions
1565 (setq org-agenda-custom-commands
1566 (quote (("N" "Notes" tags "NOTE"
1567 ((org-agenda-overriding-header "Notes")
1568 (org-tags-match-list-sublevels t)))
1569 ("h" "Habits" tags-todo "STYLE=\"habit\""
1570 ((org-agenda-overriding-header "Habits")
1571 (org-agenda-sorting-strategy
1572 '(todo-state-down effort-up category-keep))))
1576 ((org-agenda-overriding-header "Tasks to Refile")
1577 (org-tags-match-list-sublevels nil)))
1578 (tags-todo "-CANCELLED/!"
1579 ((org-agenda-overriding-header "Stuck Projects")
1580 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
1581 (org-agenda-sorting-strategy
1583 (tags-todo "-HOLD-CANCELLED/!"
1584 ((org-agenda-overriding-header "Projects")
1585 (org-agenda-skip-function 'bh/skip-non-projects)
1586 (org-tags-match-list-sublevels 'indented)
1587 (org-agenda-sorting-strategy
1589 (tags-todo "-CANCELLED/!NEXT"
1590 ((org-agenda-overriding-header (concat "Project Next Tasks"
1591 (if bh/hide-scheduled-and-waiting-next-tasks
1593 " (including WAITING and SCHEDULED tasks)")))
1594 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1595 (org-tags-match-list-sublevels t)
1596 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1597 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1598 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1599 (org-agenda-sorting-strategy
1600 '(todo-state-down effort-up category-keep))))
1601 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1602 ((org-agenda-overriding-header (concat "Project Subtasks"
1603 (if bh/hide-scheduled-and-waiting-next-tasks
1605 " (including WAITING and SCHEDULED tasks)")))
1606 (org-agenda-skip-function 'bh/skip-non-project-tasks)
1607 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1608 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1609 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1610 (org-agenda-sorting-strategy
1612 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1613 ((org-agenda-overriding-header (concat "Standalone Tasks"
1614 (if bh/hide-scheduled-and-waiting-next-tasks
1616 " (including WAITING and SCHEDULED tasks)")))
1617 (org-agenda-skip-function 'bh/skip-project-tasks)
1618 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1619 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1620 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1621 (org-agenda-sorting-strategy
1623 (tags-todo "-CANCELLED+WAITING|HOLD/!"
1624 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
1625 (org-agenda-skip-function 'bh/skip-stuck-projects)
1626 (org-tags-match-list-sublevels nil)
1627 (org-agenda-todo-ignore-scheduled t)
1628 (org-agenda-todo-ignore-deadlines t)))
1630 ((org-agenda-overriding-header "Tasks to Archive")
1631 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1632 (org-tags-match-list-sublevels nil))))
1635 ; org mode agenda files
1636 (setq org-agenda-files
1638 (file-expand-wildcards "~/projects/org-notes/*.org")
1639 (file-expand-wildcards "~/org-mode/from-mobile.org")
1640 (file-expand-wildcards "~/org-notes-*/*.org")
1643 (setq my/org-refile-file
1645 (lambda (file) (string-match-p (regexp-quote "/refile.org") file))
1648 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
1649 (set-register ?r (cons 'file my/org-refile-file))
1650 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
1651 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
1652 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
1653 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
1654 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
1655 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
1656 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
1657 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
1658 ; (defun org-agenda-timeline-all (&optional arg)
1661 ; (dolist (org-agenda-file org-agenda-files)
1662 ; (insert-file-contents org-agenda-file nil)
1663 ; (goto-char (point-max))
1665 ; (write-file "/tmp/timeline.org")
1666 ; (org-agenda arg "L")))
1667 ; (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
1671 #+BEGIN_SRC emacs-lisp
1672 (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")))
1673 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
1675 (setq org-default-notes-file "~/projects/org-notes/notes.org")
1676 (setq org-id-link-to-org-use-id 'use-existing)
1678 ** Capture Templates
1679 #+BEGIN_SRC emacs-lisp
1680 (setq org-capture-templates ;; mail-specific note template, identified by "m"
1681 `(("m" "Mail" entry (file my/org-refile-file)
1682 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
1683 ("t" "todo" entry (file my/org-refile-file)
1684 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
1685 ("r" "respond" entry (file my/org-refile-file)
1686 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
1687 ("n" "note" entry (file my/org-refile-file)
1688 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
1689 ("s" "schedule" entry (file my/org-refile-file)
1690 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
1691 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
1692 "* %?\n%U\n" :clock-in t :clock-resume t)
1693 ("w" "org-protocol" entry (file my/org-refile-file)
1694 "* TODO Review %c\n%U\n" :immediate-finish t)
1695 ("M" "Meeting" entry (file my/org-refile-file)
1696 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
1697 ("S" "Seminar" entry (file my/org-refile-file)
1698 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
1699 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
1700 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
1701 ("p" "Phone call" entry (file my/org-refile-file)
1702 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
1703 ("J" "job" entry (file+olp "~/projects/org-notes/notes.org"
1705 ,(format-time-string "Positions %Y"))
1706 "* TODO Apply for %? :job:\nSCHEDULED: <%<%Y-%m-%d>>\n%U\n%x\n" :clock-in t :clock-resume t)
1707 ("h" "Habit" entry (file my/org-refile-file)
1708 "* 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")
1712 ;; Remove empty LOGBOOK drawers on clock out
1713 (defun bh/remove-empty-drawer-on-clock-out ()
1716 (beginning-of-line 0)
1717 (org-remove-empty-drawer-at (point))))
1719 (defun my/org-add-id ()
1722 (if (org-current-level)
1731 ** Org mode key bindings
1732 #+BEGIN_SRC emacs-lisp
1733 ;; org mode configuration from http://doc.norang.ca/org-mode.html
1734 ;; Custom Key Bindings
1735 :bind* (("<f9> a" . org-agenda)
1736 ("<f9> I" . bh/punch-in)
1737 ("<f9> O" . bh/punch-out)
1738 ("<f9> SPC" . bh/clock-in-last-task)
1739 ("<f12>" . dla/show-org-agenda)
1740 ;; ("<f5>" . bh/org-todo)
1741 ("<S-f5>" . bh/widen)
1742 ("<f7>" . bh/set-truncate-lines)
1743 ("<f8>" . org-cycle-agenda-files)
1744 ("<f9> <f9>" . dla/show-org-agenda)
1746 ("<f9> c" . calendar)
1747 ("<f9> f" . boxquote-insert-file)
1748 ("<f9> h" . bh/hide-other)
1749 ("<f9> n" . bh/toggle-next-task-display)
1752 ("<f9> r" . boxquote-region)
1753 ("<f9> s" . bh/switch-to-scratch)
1755 ("<f9> t" . bh/insert-inactive-timestamp)
1756 ("<f9> T" . bh/toggle-insert-inactive-timestamp)
1758 ("<f9> v" . visible-mode)
1759 ("<f9> l" . org-toggle-link-display)
1760 ("<f9> SPC" . bh/clock-in-last-task)
1761 ("C-<f9>" . previous-buffer)
1762 ("M-<f9>" . org-toggle-inline-images)
1763 ("C-x n r" . narrow-to-region)
1764 ("C-<f10>" . next-buffer)
1765 ("<f11>" . org-clock-goto)
1766 ("C-<f11>" . org-clock-in)
1767 ("C-s-<f12>" . bh/save-then-publish)
1768 ("C-c c" . org-capture))
1771 ** Utility Functions
1772 #+BEGIN_SRC emacs-lisp
1773 (defun bh/hide-other ()
1776 (org-back-to-heading 'invisible-ok)
1777 (outline-hide-other)
1782 (defun bh/set-truncate-lines ()
1783 "Toggle value of truncate-lines and refresh window display."
1785 (setq truncate-lines (not truncate-lines))
1786 ;; now refresh window display (an idiom from simple.el):
1788 (set-window-start (selected-window)
1789 (window-start (selected-window)))))
1791 (defun bh/switch-to-scratch ()
1793 (switch-to-buffer "*scratch*"))
1795 (setq org-use-fast-todo-selection t)
1796 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1798 ; create function to create headlines in file. This comes from
1799 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
1800 (defun my/org-add-ids-to-headlines-in-file ()
1801 "Add ID properties to all headlines in the current file which
1802 do not already have one."
1806 (goto-char (point-min))
1807 (when (not (re-search-forward "^#\\+OPTIONS:.*auto-id:f" (point-max) t))
1808 (org-map-entries 'org-id-get-create))))
1809 (defun dla/org-update-ids-to-headlines-in-file ()
1810 "Add or replace ID properties to all headlines in the current file
1811 (or narrowed region)."
1814 (org-map-entries '(lambda () (org-id-get-create t))))
1815 ; if we wanted to do this to every buffer, do the following:
1816 (add-hook 'org-mode-hook
1818 (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
1821 #+BEGIN_SRC emacs-lisp
1822 (use-package find-lisp
1824 (setq org-agenda-text-search-extra-files
1825 (append '(agenda-archives)
1826 (find-lisp-find-files "~/projects/org-notes" "\.org$")
1827 (find-lisp-find-files "~/projects/org-notes" "\.org_archive$")
1831 #+BEGIN_SRC emacs-lisp
1832 (setq org-todo-keywords
1833 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
1834 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
1836 (setq org-todo-keyword-faces
1837 (quote (("TODO" :foreground "red" :weight bold)
1838 ("NEXT" :foreground "blue" :weight bold)
1839 ("DONE" :foreground "forest green" :weight bold)
1840 ("WAITING" :foreground "orange" :weight bold)
1841 ("HOLD" :foreground "magenta" :weight bold)
1842 ("CANCELLED" :foreground "forest green" :weight bold)
1843 ("MEETING" :foreground "forest green" :weight bold)
1844 ("PHONE" :foreground "forest green" :weight bold))))
1846 (setq org-todo-state-tags-triggers
1847 (quote (("CANCELLED" ("CANCELLED" . t))
1848 ("WAITING" ("WAITING" . t))
1849 ("HOLD" ("WAITING") ("HOLD" . t))
1850 (done ("WAITING") ("HOLD"))
1851 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1852 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1853 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1857 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1858 ; add ids on creation of nodes
1859 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
1862 ; resolve clocks after 10 minutes of idle; use xprintidle
1863 ; (setq org-clock-idle-time 10)
1864 ; (setq org-clock-x11idle-program-name "xprintidle")
1866 ; this is from http://doc.norang.ca/org-mode.html#Capture
1867 ; use C-M-r for org mode capture
1868 (global-set-key (kbd "C-M-r") 'org-capture)
1870 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1871 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1872 (org-agenda-files :maxlevel . 9))))
1874 ; Use full outline paths for refile targets - we file directly with IDO
1875 (setq org-refile-use-outline-path t)
1877 ; Targets complete directly with IDO
1878 (setq org-outline-path-complete-in-steps nil)
1880 ; Allow refile to create parent tasks with confirmation
1881 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1883 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
1884 ; (setq org-completion-use-ido t)
1885 ; (setq ido-everywhere t)
1886 ; (setq ido-max-directory-size 100000)
1887 ; (ido-mode (quote both))
1888 ; ; Use the current window when visiting files and buffers with ido
1889 ; (setq ido-default-file-method 'selected-window)
1890 ; (setq ido-default-buffer-method 'selected-window)
1891 ; ; Use the current window for indirect buffer display
1892 ; (setq org-indirect-buffer-display 'current-window)
1895 ;;;; Refile settings
1896 ; Exclude DONE state tasks from refile targets
1897 (defun bh/verify-refile-target ()
1898 "Exclude todo keywords with a done state from refile targets"
1899 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
1901 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1903 ;; ensure that emacsclient will show just the note to be edited when invoked
1904 ;; from Mutt, and that it will shut down emacsclient once finished;
1905 ;; fallback to legacy behavior when not invoked via org-protocol.
1906 (require 'org-protocol)
1907 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
1908 (setq my-org-protocol-flag nil)
1909 (defadvice org-capture-finalize (after delete-frame-at-end activate)
1910 "Delete frame at remember finalization"
1911 (progn (if my-org-protocol-flag (delete-frame))
1912 (setq my-org-protocol-flag nil)))
1913 (defadvice org-capture-refile (around delete-frame-after-refile activate)
1914 "Delete frame at remember refile"
1915 (if my-org-protocol-flag
1917 (setq my-org-protocol-flag nil)
1922 (defadvice org-capture-kill (after delete-frame-at-end activate)
1923 "Delete frame at remember abort"
1924 (progn (if my-org-protocol-flag (delete-frame))
1925 (setq my-org-protocol-flag nil)))
1926 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
1927 (setq my-org-protocol-flag t))
1929 (defadvice org-insert-todo-heading (after dla/create-id activate)
1930 (unless (org-in-item-p)
1936 (add-to-list 'org-modules 'org-habit)
1938 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
1939 (defun open-mail-in-mutt (message)
1940 "Open a mail message in Mutt, using an external terminal.
1942 Message can be specified either by a path pointing inside a
1943 Maildir, or by Message-ID."
1944 (interactive "MPath or Message-ID: ")
1946 (format "faf xterm -e \"%s %s\""
1947 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
1949 ;; add support for "mutt:ID" links
1950 (org-add-link-type "mutt" 'open-mail-in-mutt)
1952 (defun my-org-mode-setup ()
1953 ; (load-library "reftex")
1954 (and (buffer-file-name)
1955 (file-exists-p (buffer-file-name))
1957 ; (reftex-parse-all)
1958 (reftex-set-cite-format
1959 '((?b . "[[bib:%l][%l-bib]]")
1960 (?n . "[[notes:%l][%l-notes]]")
1962 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
1964 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
1965 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
1966 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
1967 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
1969 (add-hook 'org-mode-hook 'my-org-mode-setup)
1971 (defun org-mode-reftex-search ()
1973 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
1975 (defun open-research-paper (bibtexkey)
1976 "Open a paper by bibtex key"
1977 (interactive "bibtex key: ")
1980 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1981 (org-add-link-type "papers" 'open-research-paper)
1982 (defun open-research-paper-pdf (bibtexkey)
1983 "Open a paper pdf by bibtex key"
1984 (interactive "bibtex key: ")
1986 (format "%s -p evince_annot %s"
1987 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1988 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
1990 (add-to-list 'org-link-abbrev-alist
1992 "~/projects/research/paper_notes.org::#%s"))
1994 ; I pretty much always want hiearchical checkboxes
1995 (setq org-hierachical-checkbox-statistics nil)
1997 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
1998 (add-to-list 'org-structure-template-alist
1999 '("E" "\\begin{equation}\n?\n\\end{equation}"))
2002 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
2003 (defun my-rtcite-export-handler (path desc format)
2004 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
2005 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
2006 (match-string 1 path)))
2007 (path (substring path 0 (match-beginning 0))))
2008 (cond ((eq format 'latex)
2010 (equal 0 (search "rtcite:" desc)))
2011 (format "\\cite{%s}" search)
2012 (format "\\cite[%s]{%s}" desc search))))))
2014 (org-add-link-type "rtcite"
2016 'my-rtcite-export-handler)
2020 ** Org Mobile Configuration
2021 #+BEGIN_SRC emacs-lisp
2022 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
2023 (when (string= system-name "linnode")
2024 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
2025 (setq-default org-directory "/home/don/org-mode/")
2026 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
2030 #+BEGIN_SRC emacs-lisp
2031 ;; org mode ical export
2032 (setq org-icalendar-timezone "America/Los_Angeles")
2033 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
2034 ;; we already add the id manually
2035 (setq org-icalendar-store-UID t)
2038 ** General Org Babel Configuration
2039 #+BEGIN_SRC emacs-lisp
2040 ;; org babel support
2041 (org-babel-do-load-languages
2042 'org-babel-load-languages
2049 ;; set the right path to ditaa.jar
2050 (setq org-ditaa-jar-path "/usr/share/ditaa/ditaa.jar")
2051 ;; use graphviz-dot for dot things
2052 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
2053 ;; do not indent begin_src blocks
2054 (setq org-edit-src-content-indentation 0)
2055 ;; org-babel-by-backend
2056 (defmacro org-babel-by-backend (&rest body)
2057 `(case (if (boundp 'backend)
2058 (org-export-backend-name backend)
2061 (defun my/fix-inline-images ()
2062 (when org-inline-image-overlays
2063 (org-redisplay-inline-images)))
2065 (add-hook 'org-babel-after-execute-hook
2066 'my/fix-inline-images)
2069 ** LaTeX configuration
2070 #+BEGIN_SRC emacs-lisp
2071 (use-package org-contrib
2076 (ox-extras-activate '(latex-header-blocks ignore-headlines))
2078 (add-to-list 'org-latex-classes
2080 "\\documentclass[11pt,oneside,article]{memoir}\n"
2081 ("\\section{%s}" . "\\section*{%s}")
2082 ("\\subsection{%s}" . "\\subsection*{%s}")
2083 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2084 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2085 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2087 (setq org-beamer-outline-frame-options "")
2088 (add-to-list 'org-latex-classes
2090 "\\documentclass[ignorenonframetext]{beamer}
2091 [NO-DEFAULT-PACKAGES]
2094 ("\\section{%s}" . "\\section*{%s}")
2095 ("\\subsection{%s}" . "\\subsection*{%s}")
2096 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2097 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2098 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2100 (add-to-list 'org-latex-classes
2102 "\\documentclass[11pt,oneside]{memoir}\n"
2103 ("\\chapter{%s}" . "\\chapter*{%s}")
2104 ("\\section{%s}" . "\\section*{%s}")
2105 ("\\subsection{%s}" . "\\subsection*{%s}")
2106 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
2108 (add-to-list 'org-latex-classes
2110 "\\documentclass[11pt]{letter}
2111 [NO-DEFAULT-PACKAGES]
2114 ("\\section{%s}" . "\\section*{%s}")
2115 ("\\subsection{%s}" . "\\subsection*{%s}")
2116 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2117 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2118 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2120 (add-to-list 'org-latex-classes
2122 "\\documentclass{dlacv}
2123 [NO-DEFAULT-PACKAGES]
2126 ("\\section{%s}" . "\\section*{%s}")
2127 ("\\subsection{%s}" . "\\subsection*{%s}")
2128 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2129 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2130 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2133 (add-to-list 'org-latex-classes
2135 "\\documentclass{dlaresume}
2136 [NO-DEFAULT-PACKAGES]
2139 ("\\section{%s}" . "\\section*{%s}")
2140 ("\\subsection{%s}" . "\\subsection*{%s}")
2141 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2142 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2143 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2146 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
2147 ;; but adapted to use latexmk 4.22 or higher.
2148 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
2150 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
2151 (setq org-latex-default-packages-alist
2153 ("" "unicode-math" t)
2155 (setq org-latex-packages-alist
2162 ("" "longtable" nil)
2165 ;; make equations larger
2166 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
2168 (defun org-create-formula--latex-header ()
2169 "Return LaTeX header appropriate for previewing a LaTeX snippet."
2170 (let ((info (org-combine-plists (org-export--get-global-options
2171 (org-export-get-backend 'latex))
2172 (org-export--get-inbuffer-options
2173 (org-export-get-backend 'latex)))))
2174 (org-latex-guess-babel-language
2175 (org-latex-guess-inputenc
2176 (org-splice-latex-header
2177 org-format-latex-header
2178 org-latex-default-packages-alist
2180 (plist-get info :latex-header)))
2184 ; support ignoring headers in org mode export to latex
2185 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
2186 (defadvice org-latex-headline (around my-latex-skip-headlines
2187 (headline contents info) activate)
2188 (if (member "ignoreheading" (org-element-property :tags headline))
2189 (setq ad-return-value contents)
2192 ;; keep latex logfiles
2194 (setq org-latex-remove-logfiles nil)
2197 ;; Resume clocking task when emacs is restarted
2198 (org-clock-persistence-insinuate)
2200 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
2201 (setq org-clock-history-length 23)
2202 ;; Resume clocking task on clock-in if the clock is open
2203 (setq org-clock-in-resume t)
2204 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
2205 ;; there are things like PHONE calls
2206 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
2207 ;; Separate drawers for clocking and logs
2208 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
2209 ;; Save clock data and state changes and notes in the LOGBOOK drawer
2210 (setq org-clock-into-drawer t)
2211 (setq org-log-into-drawer t)
2212 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
2213 (setq org-clock-out-remove-zero-time-clocks t)
2214 ;; Clock out when moving task to a done state
2215 (setq org-clock-out-when-done t)
2216 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
2217 (setq org-clock-persist t)
2218 ;; Do not prompt to resume an active clock
2219 (setq org-clock-persist-query-resume nil)
2220 ;; Enable auto clock resolution for finding open clocks
2221 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
2222 ;; Include current clocking task in clock reports
2223 (setq org-clock-report-include-clocking-task t)
2225 ;; the cache seems to be broken
2226 (setq org-element-use-cache nil)
2228 (defvar bh/keep-clock-running nil)
2230 (defun bh/is-task-p ()
2231 "Any task with a todo keyword and no subtask"
2235 (subtree-end (save-excursion (org-end-of-subtree t)))
2236 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2239 (while (and (not has-subtask)
2240 (< (point) subtree-end)
2241 (re-search-forward "^\*+ " subtree-end t))
2242 (when (member (org-get-todo-state) org-todo-keywords-1)
2243 (setq has-subtask t))))
2244 (and is-a-task (not has-subtask)))))
2245 (defun bh/is-project-p ()
2246 "Any task with a todo keyword subtask"
2250 (subtree-end (save-excursion (org-end-of-subtree t)))
2251 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2254 (while (and (not has-subtask)
2255 (< (point) subtree-end)
2256 (re-search-forward "^\*+ " subtree-end t))
2257 (when (member (org-get-todo-state) org-todo-keywords-1)
2258 (setq has-subtask t))))
2259 (and is-a-task has-subtask))))
2261 (defun bh/is-subproject-p ()
2262 "Any task which is a subtask of another project"
2263 (let ((is-subproject)
2264 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2266 (while (and (not is-subproject) (org-up-heading-safe))
2267 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
2268 (setq is-subproject t))))
2269 (and is-a-task is-subproject)))
2272 (defun bh/clock-in-to-next (kw)
2273 "Switch a task from TODO to NEXT when clocking in.
2274 Skips capture tasks, projects, and subprojects.
2275 Switch projects and subprojects from NEXT back to TODO"
2276 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
2278 ((and (member (org-get-todo-state) (list "TODO"))
2281 ((and (member (org-get-todo-state) (list "NEXT"))
2285 (defun bh/punch-in (arg)
2286 "Start continuous clocking and set the default task to the
2287 selected task. If no task is selected set the Organization task
2288 as the default task."
2290 (setq bh/keep-clock-running t)
2291 (if (equal major-mode 'org-agenda-mode)
2293 ;; We're in the agenda
2295 (let* ((marker (org-get-at-bol 'org-hd-marker))
2296 (tags (org-with-point-at marker (org-get-tags))))
2297 (if (and (eq arg 4) tags)
2298 (org-agenda-clock-in '(16))
2299 (bh/clock-in-organization-task-as-default)))
2301 ;; We are not in the agenda
2305 ; Find the tags on the current task
2306 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
2307 (org-clock-in '(16))
2308 (bh/clock-in-organization-task-as-default)))))
2310 (defun bh/punch-out ()
2312 (setq bh/keep-clock-running nil)
2313 (when (org-clock-is-active)
2315 (org-agenda-remove-restriction-lock))
2317 (defun bh/clock-in-default-task ()
2319 (org-with-point-at org-clock-default-task
2322 (defun bh/clock-in-parent-task ()
2323 "Move point to the parent (project) task if any and clock in"
2324 (let ((parent-task))
2328 (while (and (not parent-task) (org-up-heading-safe))
2329 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
2330 (setq parent-task (point))))
2332 (org-with-point-at parent-task
2334 (when bh/keep-clock-running
2335 (bh/clock-in-default-task)))))))
2337 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
2339 (defun bh/clock-in-organization-task-as-default ()
2341 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
2342 (org-clock-in '(16))))
2344 (defun bh/clock-out-maybe ()
2345 (when (and bh/keep-clock-running
2346 (not org-clock-clocking-in)
2347 (marker-buffer org-clock-default-task)
2348 (not org-clock-resolving-clocks-due-to-idleness))
2349 (bh/clock-in-parent-task)))
2351 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
2354 (defun bh/clock-in-task-by-id (id)
2355 "Clock in a task by id"
2356 (org-with-point-at (org-id-find id 'marker)
2357 (org-clock-in nil)))
2359 (defun bh/clock-in-last-task (arg)
2360 "Clock in the interrupted task if there is one
2361 Skip the default task and get the next one.
2362 A prefix arg forces clock in of the default task."
2364 (let ((clock-in-to-task
2366 ((eq arg 4) org-clock-default-task)
2367 ((and (org-clock-is-active)
2368 (equal org-clock-default-task (cadr org-clock-history)))
2369 (caddr org-clock-history))
2370 ((org-clock-is-active) (cadr org-clock-history))
2371 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
2372 (t (car org-clock-history)))))
2374 (org-with-point-at clock-in-to-task
2375 (org-clock-in nil))))
2378 (defun org-export-to-ods ()
2380 (let ((csv-file "data.csv"))
2381 (org-table-export csv-file "orgtbl-to-csv")
2382 (org-odt-convert csv-file "ods" 'open)))
2384 ; allow for zero-width-space to be a break in regexp too
2385 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
2386 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
2387 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
2389 ;; support inserting screen shots
2390 (defun my/org-insert-screenshot ()
2391 "Take a screenshot into a time stamped unique-named file in the
2392 same directory as the org-buffer and insert a link to this file."
2394 (defvar my/org-insert-screenshot/filename)
2395 (setq my/org-insert-screenshot/filename
2397 "Screenshot to insert: "
2399 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
2402 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
2403 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
2404 (org-display-inline-images))
2406 (defun my/fix-inline-images ()
2407 (when org-inline-image-overlays
2408 (org-redisplay-inline-images)))
2410 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
2412 ;; use xelatex to preview with imagemagick
2413 (add-to-list 'org-preview-latex-process-alist
2414 '(xelateximagemagick
2415 :programs ("xelatex" "convert")
2416 :description "pdf > png"
2417 :message "you need to install xelatex and imagemagick"
2419 :image-input-type "pdf"
2420 :image-output-type "png"
2421 :image-size-adjust (1.0 . 1.0)
2422 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
2423 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
2425 ;; use xelatex by default
2426 (setq org-preview-latex-default-process 'xelateximagemagick)
2428 ; from http://orgmode.org/Changes.html
2429 (defun my/org-repair-property-drawers ()
2430 "Fix properties drawers in current buffer.
2431 Ignore non Org buffers."
2433 (when (eq major-mode 'org-mode)
2434 (org-with-wide-buffer
2435 (goto-char (point-min))
2436 (let ((case-fold-search t)
2437 (inline-re (and (featurep 'org-inlinetask)
2438 (concat (org-inlinetask-outline-regexp)
2442 (unless (and inline-re (org-looking-at-p inline-re))
2444 (let ((end (save-excursion (outline-next-heading) (point))))
2446 (when (org-looking-at-p org-planning-line-re) (forward-line))
2447 (when (and (< (point) end)
2448 (not (org-looking-at-p org-property-drawer-re))
2450 (and (re-search-forward org-property-drawer-re end t)
2451 (eq (org-element-type
2452 (save-match-data (org-element-at-point)))
2454 (insert (delete-and-extract-region
2456 (min (1+ (match-end 0)) end)))
2457 (unless (bolp) (insert "\n"))))))))))))
2461 #+BEGIN_SRC emacs-lisp
2465 (use-package calfw-org
2468 (use-package org-gcal
2469 :if (file-readable-p "~/.hide/org_gcal.el")
2471 :config '((if (file-readable-p "~/.hide/org_gcal.el")
2472 (load-file "~/.hide/org_gcal.el"))
2477 #+BEGIN_SRC emacs-lisp
2481 ;; Show notification 10 minutes before event
2482 (setq appt-message-warning-time 10)
2483 ;; Disable multiple reminders
2484 (setq appt-display-interval appt-message-warning-time)
2485 (setq appt-display-mode-line nil)
2487 ;; add automatic reminders for appointments
2488 (defun my/org-agenda-to-appt ()
2490 (setq appt-time-msg-list nil)
2491 (org-agenda-to-appt))
2492 ;; add reminders when starting emacs
2493 (my/org-agenda-to-appt)
2494 ;; when rebuilding the agenda
2495 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
2496 "Pressing `r' on the agenda will also add appointments."
2497 (my/org-agenda-to-appt)
2499 ;; when saving all org buffers
2500 (defadvice org-save-all-org-buffers (after org-save-all-org-buffers-add-appts)
2501 "Re-add appts after saving all org buffers"
2502 (my/org-agenda-to-appt))
2503 ;; Display appointments as a window manager notification
2504 (setq appt-disp-window-function 'my/appt-display)
2505 (setq appt-delete-window-function (lambda () t))
2507 (setq my/appt-notification-app (concat (getenv "HOME") "/bin/appt_notification"))
2509 (defun my/appt-display (min-to-app new-time msg)
2510 (if (atom min-to-app)
2511 (start-process "my/appt-notification-app" nil my/appt-notification-app min-to-app msg)
2512 (dolist (i (number-sequence 0 (1- (length min-to-app))))
2513 (start-process "my/appt-notification-app" nil my/appt-notification-app
2514 (nth i min-to-app) (nth i msg))))
2521 #+BEGIN_SRC emacs-lisp
2525 ** Home/End Begining/End of line
2526 #+BEGIN_SRC emacs-lisp
2527 (global-set-key [home] 'move-beginning-of-line)
2528 (global-set-key [end] 'move-end-of-line)
2531 #+BEGIN_SRC emacs-lisp
2532 ; (global-unset-key "\M-g")
2533 ; (global-set-key (kbd "M-g l") 'goto-line)
2537 #+BEGIN_SRC emacs-lisp
2538 (use-package debian-changelog-mode
2539 :mode "debian/changelog"
2542 (setq debian-changelog-mailing-address "don@debian.org")
2543 (setq debian-changelog-full-name "Don Armstrong"))
2545 * Misc (uncharacterized)
2546 #+BEGIN_SRC emacs-lisp
2547 (setq calendar-latitude 38.6)
2548 (setq calendar-longitude -121.5)
2549 (setq case-fold-search t)
2550 (setq confirm-kill-emacs (quote y-or-n-p))
2554 #+BEGIN_SRC emacs-lisp
2555 (global-font-lock-mode 1)
2558 #+BEGIN_SRC emacs-lisp
2559 (setq ps-footer-font-size (quote (8 . 10)))
2560 (setq ps-header-font-size (quote (8 . 10)))
2561 (setq ps-header-title-font-size (quote (10 . 10)))
2562 (setq ps-line-number-color "blue")
2563 (setq ps-print-footer t)
2564 (setq ps-print-footer-frame nil)
2565 (setq ps-print-only-one-header t)
2567 ** Only single spacing on sentences
2568 #+BEGIN_SRC emacs-lisp
2569 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
2571 (setq sentence-end-double-space nil)
2572 ; enable matching parenthesis
2574 ** Display paren mode
2575 #+BEGIN_SRC emacs-lisp
2577 (setq show-paren-delay 0.2)
2581 #+BEGIN_SRC emacs-lisp
2582 (setq user-mail-address "don@donarmstrong.com")
2585 ** Use primary selection on unix machines
2586 #+BEGIN_SRC emacs-lisp
2587 ;; switch back to the old primary selection method
2588 (if (or (string-equal system-type "darwin")
2589 (string-equal system-type "windows")
2592 (setq select-enable-clipboard t)
2593 (setq select-enable-primary nil)
2596 (setq select-enable-clipboard nil)
2597 (setq select-enable-primary t)
2599 ; (setq mouse-drag-copy-region t)
2601 (setq-default c-indent-level 4)
2602 (setq-default c-brace-imaginary-offset 0)
2603 (setq-default c-brace-offset -4)
2604 (setq-default c-argdecl-indent 4)
2605 (setq-default c-label-offset -4)
2606 (setq-default c-continued-statement-offset 4)
2608 (setq-default indent-tabs-mode nil)
2609 (setq-default tab-width 4)
2611 (defun insert-date ()
2612 "Insert date at point."
2614 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
2615 (global-set-key "\C-[d" 'insert-date)
2617 (defun unfill-paragraph (arg)
2618 "Pull this whole paragraph up onto one line."
2620 (let ((fill-column 10000))
2621 (fill-paragraph arg))
2624 (column-number-mode t)
2627 ** Desktop-save-mode
2628 If the envvar EMACS_SERVER_NAME is set, consider this a separate
2629 emacs, and use a different desktop file to restore history
2630 #+BEGIN_SRC emacs-lisp
2631 (use-package desktop
2634 (setq desktop-base-file-name
2635 (convert-standard-filename
2637 (or (getenv "EMACS_SERVER_NAME")
2641 (setq desktop-base-lock-name
2642 (convert-standard-filename
2643 (concat desktop-base-file-name
2645 (setq desktop-auto-save-timeout 60)
2646 (setq desktop-restore-eager 5)
2647 (setq desktop-lazy-verbose nil)
2648 (desktop-save-mode 1)
2652 ** Misc (Uncharacterized)
2653 #+BEGIN_SRC emacs-lisp
2655 (put 'upcase-region 'disabled nil)
2656 (put 'downcase-region 'disabled nil)
2657 (put 'narrow-to-region 'disabled nil)
2659 ; Outline-minor-mode key map
2660 (define-prefix-command 'cm-map nil "Outline-")
2662 (define-key cm-map "q" 'outline-hide-sublevels) ; Hide everything but the top-level headings
2663 (define-key cm-map "t" 'outline-hide-body) ; Hide everything but headings (all body lines)
2664 (define-key cm-map "o" 'outline-hide-other) ; Hide other branches
2665 (define-key cm-map "c" 'outline-hide-entry) ; Hide this entry's body
2666 (define-key cm-map "l" 'outline-hide-leaves) ; Hide body lines in this entry and sub-entries
2667 (define-key cm-map "d" 'outline-hide-subtree) ; Hide everything in this entry and sub-entries
2669 (define-key cm-map "a" 'outline-show-all) ; Show (expand) everything
2670 (define-key cm-map "e" 'outline-show-entry) ; Show this heading's body
2671 (define-key cm-map "i" 'outline-show-children) ; Show this heading's immediate child sub-headings
2672 (define-key cm-map "k" 'outline-show-branches) ; Show all sub-headings under this heading
2673 (define-key cm-map "s" 'outline-show-subtree) ; Show (expand) everything in this heading & below
2675 (define-key cm-map "u" 'outline-up-heading) ; Up
2676 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
2677 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
2678 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
2679 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
2680 (global-set-key "\M-o" cm-map)
2681 ; fix up tmux xterm keys
2682 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
2683 (defun fix-up-tmux-keys ()
2684 "Fix up tmux xterm keys"
2687 (let ((x 2) (tkey ""))
2707 ;; ctrl + alt + shift
2709 (setq tkey "C-M-S-"))
2712 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
2713 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
2714 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
2715 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
2717 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
2719 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
2721 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
2723 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
2725 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2727 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2729 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
2731 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
2733 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
2735 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
2737 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
2739 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
2741 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
2743 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
2745 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
2747 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
2749 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
2751 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
2753 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
2755 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
2757 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
2759 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
2761 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
2763 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
2765 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
2767 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
2774 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
2776 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
2777 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
2778 (if (or (buffer-modified-p)
2779 (verify-visited-file-modtime)
2780 (< (* 8 1024 1024) (buffer-size))
2781 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
2783 (clear-visited-file-modtime)
2785 (ad-activate 'ask-user-about-supersession-threat)
2789 #+BEGIN_SRC emacs-lisp
2793 (or (getenv "EMACS_SERVER_NAME")
2795 (unless (server-running-p)
2796 ; (global-set-key "\C-xp" 'server-edit)
2801 #+BEGIN_SRC emacs-lisp
2802 (provide 'don-configuration)