1 #+PROPERTY: header-args:emacs-lisp :tangle don-configuration.el
5 # if for some reason, things get pear-shaped, we want to be able to
6 # enter the debugger by sending -USR2 to emacs
9 (setq debug-on-event 'siguser2)
13 #+BEGIN_SRC emacs-lisp
14 (add-to-list 'exec-path '"/usr/local/bin")
15 (add-to-list 'exec-path '"~/bin/")
18 #+BEGIN_SRC emacs-lisp
20 (let ((default-directory "~/lib/emacs_el/"))
21 (normal-top-level-add-subdirs-to-load-path))
24 (let ((default-directory "~/var/emacs/elpa"))
25 (normal-top-level-add-subdirs-to-load-path))
28 (add-to-list 'load-path '"~/lib/emacs_el")
31 (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 ** package repositories and package manager
53 #+BEGIN_SRC emacs-lisp
54 (require 'use-package)
55 (setq use-package-always-ensure t)
57 (add-to-list 'gnutls-trustfiles "/etc/ssl/ca-global/ca-certificates.crt")
60 (setq package-enable-at-startup nil)
61 (setq package--init-file-ensured t)
62 (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
63 ("melpa" . "https://melpa.org/packages/")
64 ("org" . "http://orgmode.org/elpa/")))
65 (setq use-package-verbose (not (bound-and-true-p byte-compile-current-file)))
69 #+BEGIN_SRC emacs-lisp
72 :commands (paradox-upgrade-packages paradox-list-packages)
74 (setq paradox-execute-asynchronously t)
75 (setq paradox-github-token t) ; I don't want to be prompted about this integration
79 #+BEGIN_SRC emacs-lisp
80 ;; Set the custom file to /dev/null and don't bother to load it
81 (setq custom-file "/dev/null")
85 #+BEGIN_SRC emacs-lisp
86 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
87 ;; execute conditional code when loading libraries
88 ; (defmacro with-library (symbol &rest body)
89 ; `(when (require ,symbol nil t)
91 ; (put 'with-library 'lisp-indent-function 1)
95 ** Safe Local Variables
96 #+BEGIN_SRC emacs-lisp
97 (setq safe-local-variable-values
98 (quote ((auto-save-default)
100 (cperl-indent-level . 4)
102 (indent-tabs-mode . f)
103 (vcl-indent-level . 4)
107 #+BEGIN_SRC emacs-lisp
108 (setq global-mark-ring-max 128
112 (defun don/minibuffer-setup-hook ()
113 (setq gc-cons-threshold most-positive-fixnum))
115 (defun don/minibuffer-exit-hook ()
116 (setq gc-cons-threshold 1048576))
118 (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
119 (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
123 #+BEGIN_SRC emacs-lisp
124 (use-package tree-sitter
127 (global-tree-sitter-mode)
129 (use-package tree-sitter-langs
134 ; (defun dla/python-function-at-point ()
135 ; "Return a list of function arguments
137 ; Borrowed from https://xenodium.com/emacs-generate-a-swift-initializer/
140 ; (cl-assert (seq-contains-p local-minor-modes 'tree-sitter-mode) "tree-sitter-mode not enabled")
141 ; (let* ((node (tree-sitter-node-at-point 'function_definition)
147 ; (error "Not in function"))
150 ; (cond ((eq 'func_name
153 ; ; (setq args (append args (list arg)))
155 ; (setq arg (list (cons 'function (tsc-node-text
159 ; (setq arg (map-insert arg 'ident (tsc-node-text
163 ; (setq arg (map-insert arg 'ident_type (tsc-node-text
167 ; (setq arg (map-insert arg 'ret_type (tsc-node-text
170 ; (tsc-query-captures
171 ; (tsc-make-query tree-sitter-language
172 ; "(function_definition (identifier) @func_name (parameters [(identifier) @ident (typed_parameter (identifier) @ident (type) @ident_type)]) (type)? @ret_type)")
173 ; (tree-sitter-node-at-point 'function_definition) nil))
175 ; (setq args (append args (list arg))))
181 #+BEGIN_SRC emacs-lisp
182 (use-package spacemacs-theme
184 (load-theme 'spacemacs-dark t)
188 #+BEGIN_SRC emacs-lisp
189 (use-package hippie-exp
190 :bind* (("M-<SPC>" . hippie-expand))
194 #+BEGIN_SRC emacs-lisp
195 (use-package flyspell
196 :delight flyspell-mode 🐝
198 (add-hook 'text-mode-hook 'turn-on-flyspell)
199 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
200 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
201 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
203 (setq ispell-program-name "ispell")
209 #+begin_src emacs-lisp :tangle yes
210 (use-package flycheck
213 :if (version<= "24.4" emacs-version)
214 :commands flycheck-mode
215 :hook ((prog-mode . flycheck-mode)
219 (use-package flycheck-tip
221 :commands 'flycheck-tip-cycle
223 :bind (:map flycheck-mode-map
224 ("C-c C-n" . flycheck-tip-cycle)))
226 (use-package flycheck-package
229 (use-package flycheck-checkpatch
231 :config (flycheck-checkpatch-setup)
232 :config (setq flycheck-checkers (delete 'checkpatch
234 :config (add-to-list 'flycheck-checkers 'checkpatch t))
238 #+BEGIN_SRC emacs-lisp
244 #+BEGIN_SRC emacs-lisp
249 #+BEGIN_SRC emacs-lisp
250 (use-package eyebrowse
252 :delight eyebrowse-mode
253 :init (setq eyebrowse-keymap-prefix (kbd "C-c e"))
255 (setq eyebrowse-wrap-around t)
258 (defun my/eyebrowse-new-window-config ()
262 ;; start at 1 run till 0
263 (let ((j (mod (+ i 1) 10)))
264 (when (and (not done)
265 (not (eyebrowse--window-config-present-p j)))
266 (eyebrowse-switch-to-window-config j)
267 (call-interactively 'eyebrowse-rename-window-config2 j)
272 ;; I don't use latex-preview-pane
273 ;; (require 'latex-preview-pane)
274 ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
275 ;; ;; latex-preview-pane uses window-parameters which are
276 ;; ;; not preserved by eyebrowse, so we close the preview
277 ;; ;; pane before switching, it will be regenerated when we
278 ;; ;; edit the TeX file.
279 ;; (when (lpp/window-containing-preview)
280 ;; (delete-window (lpp/window-containing-preview))))
282 ;; (add-to-list 'eyebrowse-pre-window-switch-hook
283 ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
285 ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
286 ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
287 ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
288 ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
289 ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
297 #+BEGIN_SRC emacs-lisp
298 (defun my/vsplit-last-buffer ()
299 "Split the window vertically and display the previous buffer."
301 (split-window-vertically)
303 (switch-to-next-buffer))
305 (defun my/hsplit-last-buffer ()
306 "Split the window horizontally and display the previous buffer."
308 (split-window-horizontally)
310 (switch-to-next-buffer))
312 (bind-key "C-x 2" 'my/vsplit-last-buffer)
313 (bind-key "C-x 3" 'my/hsplit-last-buffer)
315 (setq split-width-threshold 100)
316 (setq split-height-threshold 60)
318 (defun my/split-window-prefer-vertically (window)
319 "If there's only one window (excluding any possibly active
320 minibuffer), then split the current window horizontally."
321 (if (and (one-window-p t)
322 (not (active-minibuffer-window))
323 ( < (frame-width) (frame-height))
325 (let ((split-width-threshold nil))
326 (split-window-sensibly window))
327 (split-window-sensibly window)))
329 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
330 (setq window-combination-resize t)
333 *** Compilation window
335 If there is no compilation window, open one at the bottom, spanning
336 the complete width of the frame. Otherwise, reuse existing window. In
337 the former case, if there was no error the window closes
340 #+BEGIN_SRC emacs-lisp
341 (add-to-list 'display-buffer-alist
342 `(,(rx bos "*compilation*" eos)
343 (display-buffer-reuse-window
344 display-buffer-in-side-window)
345 (reusable-frames . visible)
347 (window-height . 0.4)))
350 #+BEGIN_SRC emacs-lisp
351 (defun my/compilation-exit-autoclose (status code msg)
352 ;; If M-x compile exists with a 0
353 (when (and (eq status 'exit) (zerop code))
354 ;; and delete the *compilation* window
355 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
356 (when (and (not (window-at-side-p compilation-window 'top))
357 (window-at-side-p compilation-window 'left)
358 (window-at-side-p compilation-window 'right))
359 (delete-window compilation-window))))
360 ;; Always return the anticipated result of compilation-exit-message-function
363 ;; Specify my function (maybe I should have done a lambda function)
364 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
367 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
368 value, the compilation buffer scrolls automatically to follow the
369 output. If the value is ~first-error~, scrolling stops when the first
370 error appears, leaving point at that error. For any other non-nil
371 value, scrolling continues until there is no more output.
373 #+BEGIN_SRC emacs-lisp
374 (setq compilation-scroll-output 'first-error)
377 ** Mode line cleaning
379 #+BEGIN_SRC emacs-lisp
386 #+BEGIN_SRC emacs-lisp
388 :if (>= emacs-major-version 25)
390 :bind (("C-c C-<SPC>" . avy-goto-word-or-subword-1)
391 ("C-c j j" . avy-goto-word-or-subword-1)
392 ("M-g g" . avy-goto-line))
393 :config (progn (setq avy-background t))
396 *** Ace-link (jumping to links)
397 #+BEGIN_SRC emacs-lisp
398 (use-package ace-link
400 ; bind o in most modes
401 :config (ace-link-setup-default))
403 *** Jumping through edit points (goto-chg)
404 #+BEGIN_SRC emacs-lisp
405 (use-package goto-chg
407 :bind (("C-c j ," . goto-last-change)
408 ("C-c j ." . goto-last-change-reverse))
411 *** Jumping to bookmarks (visible bookmarks, bm)
412 #+BEGIN_SRC emacs-lisp
415 :bind (("C-c j b ." . bm-next)
416 ("C-c j b ," . bm-previous)
417 ("C-c j b SPC" . bm-toggle)))
422 #+BEGIN_SRC emacs-lisp
423 (use-package yasnippet
425 :delight yas-minor-mode
428 (setq yas-verbosity 1)
429 (define-key yas-minor-mode-map (kbd "<tab>") nil)
430 (define-key yas-minor-mode-map (kbd "TAB") nil)
431 (define-key yas-minor-mode-map (kbd "<backtab>") nil)
432 (setq yas-snippet-dirs '("~/lib/emacs_el/snippets/"
433 "~/lib/emacs_el/yasnippet-snippets/snippets/"))
434 (add-to-list 'hippie-expand-try-functions-list
435 'yas-hippie-try-expand)
441 #+BEGIN_SRC emacs-lisp
442 (use-package auto-yasnippet
444 :bind (("H-w" . aya-create)
449 ** Treemacs: Tree file viewer
450 #+BEGIN_SRC emacs-lisp
451 ;; Provides workspaces with file browsing (tree file viewer)
452 ;; and project management when coupled with `projectile`.
454 ; (use-package treemacs
458 ; (setq treemacs-no-png-images t
460 ; :bind ("C-c t" . treemacs))
463 #+BEGIN_SRC emacs-lisp
464 (use-package lsp-mode
466 :commands (lsp lsp-deferred)
467 :init (setq lsp-keymap-prefix "C-c l")
468 (defun my/orderless-dispatch-flex-first (_pattern index _total)
469 (and (eq index 0) 'orderless-flex))
471 (defun my/lsp-mode-setup-completion ()
472 (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
475 ;; Optionally configure the first word as flex filtered.
476 (add-hook 'orderless-style-dispatchers #'my/orderless-dispatch-flex-first nil 'local)
478 ;; Optionally configure the cape-capf-buster.
479 ; (setq-local completion-at-point-functions (list (cape-capf-buster #'lsp-completion-at-point)))
481 :hook (python-mode . lsp-deferred)
482 (lsp-completion-mode . my/lsp-mode-setup-completion)
484 (lsp-completion-provider :none) ;; we use Corfu!
486 ;; Provides visual help in the buffer
487 ;; For example definitions on hover.
488 ;; The `imenu` lets me browse definitions quickly.
492 (setq lsp-ui-sideline-enable nil
494 :hook (lsp-mode . lsp-ui-mode)
495 :bind (:map lsp-ui-mode-map
496 ("C-c i" . lsp-ui-imenu)))
497 ;; Language server for Python
498 ;; Read the docs for the different variables set in the config.
499 (use-package lsp-pyright
502 (setq lsp-clients-python-library-directories '("/usr/"))
503 (setq lsp-pyright-disable-language-service nil
504 lsp-pyright-disable-organize-imports nil
505 lsp-pyright-auto-import-completions t
506 lsp-pyright-use-library-code-for-types t
507 lsp-pyright-venv-path "venv")
508 :hook ((python-mode . (lambda ()
509 (require 'lsp-pyright) (lsp-deferred)))))
512 #+BEGIN_SRC emacs-lisp
516 ;; Optional customizations
518 (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
519 (corfu-auto t) ;; Enable auto completion
520 (corfu-separator ?\s) ;; Orderless field separator
521 (corfu-quit-at-boundary nil) ;; Never quit at completion boundary
522 (corfu-quit-no-match nil) ;; Never quit, even if there is no match
523 (corfu-preview-current nil) ;; Disable current candidate preview
524 (corfu-preselect 'prompt) ;; Preselect the prompt
525 (corfu-on-exact-match nil) ;; Configure handling of exact matches
526 (corfu-scroll-margin 5) ;; Use scroll margin
532 #+BEGIN_SRC emacs-lisp
535 ;; Swap M-/ and C-M-/
536 :bind (("M-/" . dabbrev-completion)
537 ("C-M-/" . dabbrev-expand))
538 ;; Other useful Dabbrev configurations.
540 (dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'")))
544 #+BEGIN_SRC emacs-lisp
546 (use-package tinyprocmail
548 :load-path "~/lib/emacs_el/tiny-tools/lisp/tiny"
549 :mode (".procmailrc" . turn-on-tinyprocmail-mode)
554 #+BEGIN_SRC emacs-lisp
557 :bind (("C-x g" . magit-status)
558 ("C-x C-g" . magit-status))
560 ;; refine diffs always (hilight words)
561 (setq magit-diff-refine-hunk nil)
563 (use-package magit-annex
565 :load-path "~/lib/emacs_el/magit-annex/"
567 (use-package magit-vcsh
572 *** Forge (github/gitlab)
573 #+BEGIN_SRC emacs-lisp
580 #+BEGIN_SRC emacs-lisp
581 (use-package cperl-mode
585 ;; Use c-mode for perl .xs files
586 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
587 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
588 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
589 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
590 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
593 cperl-auto-newline nil
594 cperl-auto-newline-after-colon nil
595 cperl-continued-statement-offset 4
596 cperl-brace-offset -1
597 cperl-continued-brace-offset 0
598 cperl-label-offset -4
599 cperl-highlight-variables-indiscriminately t
600 cperl-electric-lbrace-space nil
601 cperl-indent-parens-as-block nil
602 cperl-close-paren-offset -1
603 cperl-tab-always-indent t)
604 (setq cperl-lazy-help-time nil)
605 ;;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
610 #+BEGIN_SRC emacs-lisp
611 (use-package markdown-mode
614 :mode (("\\.md\\'" . markdown-mode)
615 ("\\.mdwn\\'" . markdown-mode)
616 ("README\\.md\\'" . gfm-mode)
619 (setq markdown-enable-math t)
620 (setq markdown-follow-wiki-link-on-enter nil)
621 (bind-key "M-." #'markdown-jump markdown-mode-map)
622 (add-hook 'markdown-mode-hook #'flyspell-mode)
623 (add-hook 'markdown-mode-hook #'outline-minor-mode)
624 (bind-key "C-<tab>" #'outline-cycle markdown-mode-map)
629 #+BEGIN_SRC emacs-lisp
630 ; load sql-indent when sql is loaded
631 (use-package sql-indent
637 :mode (("\\.sql\\'" . sql-mode))
641 #+BEGIN_SRC emacs-lisp
644 :commands ediff ediff3
646 ;; ediff configuration
647 ;; don't use the multi-window configuration
648 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
651 ** Do the Right Thing Indenting
652 Attempts to automatically identify the right indentation for a file
653 #+BEGIN_SRC emacs-lisp
654 (use-package dtrt-indent
657 ** VCL --editing varnish configuration files
658 #+BEGIN_SRC emacs-lisp
659 (use-package vcl-mode
665 #+BEGIN_SRC emacs-lisp
670 ; (define-key vertico-map "\r" #'vertico-directory-enter)
671 ; (define-key vertico-map "\d" #'vertico-directory-delete-char)
672 ; (define-key vertico-map "\M-\d" #'vertico-directory-delete-word)
673 ; (add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy)
675 ;; Different scroll margin
676 ;; (setq vertico-scroll-margin 0)
678 ;; Show more candidates
679 ;; (setq vertico-count 20)
681 ;; Grow and shrink the Vertico minibuffer
682 ;; (setq vertico-resize t)
684 ;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
685 ;; (setq vertico-cycle t)
687 (vertico-grid-separator " ")
688 (vertico-grid-lookahead 50)
690 (require 'vertico-multiform)
691 (setq vertico-multiform-categories
693 (consult-grep buffer)
696 (library reverse indexed)
697 (org-roam-node reverse indexed)
701 (setq vertico-multiform-commands
702 '(("flyspell-correct-*" grid reverse)
703 (org-refile grid reverse indexed)
704 (consult-yank-pop indexed)
706 (consult-lsp-diagnostics)
709 (vertico-multiform-mode)
711 (use-package vertico-grid
715 (use-package vertico-reverse
719 (use-package vertico-indexed
723 (use-package vertico-buffer
728 ;; Persist history over Emacs restarts. Vertico sorts by history position.
729 (use-package savehist
735 ** Orderless: advanced completion style
736 #+begin_src emacs-lisp
737 (use-package orderless
740 ;; Configure a custom style dispatcher (see the Consult wiki)
741 ;; (setq orderless-style-dispatchers '(+orderless-dispatch)
742 ;; orderless-component-separator #'orderless-escapable-split-on-space)
743 (setq completion-styles '(orderless basic)
744 completion-category-defaults nil
745 completion-category-overrides '((file (styles partial-completion)))))
747 ** Marginalia: Rich annotations in the minibuffer
748 #+begin_src emacs-lisp
749 (use-package marginalia
751 :bind (:map minibuffer-local-map
752 ("M-A" . marginalia-cycle))
757 ** Embark: Minibuffer actions and context menu
758 #+begin_src emacs-lisp
761 (("C-." . embark-act) ;; pick some comfortable binding
762 ("C-;" . embark-dwim) ;; good alternative: M-.
763 ("C-h B" . embark-bindings)) ;; alternative for `describe-bindings'
767 ;; Optionally replace the key help with a completing-read interface
768 (setq prefix-help-command #'embark-prefix-help-command)
772 ;; Hide the mode line of the Embark live/completions buffers
773 (add-to-list 'display-buffer-alist
774 '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
776 (window-parameters (mode-line-format . none)))))
778 (use-package embark-consult
780 (embark-collect-mode . consult-preview-at-point-mode))
783 #+begin_src emacs-lisp
785 ;; Replace bindings. Lazily loaded due by `use-package'.
786 :bind (;; C-c bindings in `mode-specific-map'
787 ("C-c M-x" . consult-mode-command)
788 ("C-c h" . consult-history)
789 ("C-c k" . consult-kmacro)
790 ("C-c m" . consult-man)
791 ("C-c i" . consult-info)
792 ([remap Info-search] . consult-info)
793 ;; C-x bindings in `ctl-x-map'
794 ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command
795 ("C-x b" . consult-buffer) ;; orig. switch-to-buffer
796 ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
797 ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame
798 ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
799 ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer
800 ;; Custom M-# bindings for fast register access
801 ("M-#" . consult-register-load)
802 ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated)
803 ("C-M-#" . consult-register)
804 ;; Other custom bindings
805 ("M-y" . consult-yank-pop) ;; orig. yank-pop
806 ;; M-g bindings in `goto-map'
807 ("M-g e" . consult-compile-error)
808 ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck
809 ("M-g g" . consult-goto-line) ;; orig. goto-line
810 ("M-g M-g" . consult-goto-line) ;; orig. goto-line
811 ("M-g o" . consult-outline) ;; Alternative: consult-org-heading
812 ("M-g m" . consult-mark)
813 ("M-g k" . consult-global-mark)
814 ("M-g i" . consult-imenu)
815 ("M-g I" . consult-imenu-multi)
816 ;; M-s bindings in `search-map'
817 ("M-s d" . consult-find)
818 ("M-s D" . consult-locate)
819 ("M-s g" . consult-grep)
820 ("M-s G" . consult-git-grep)
821 ("M-s r" . consult-ripgrep)
822 ("M-s l" . consult-line)
823 ("M-s L" . consult-line-multi)
824 ("M-s k" . consult-keep-lines)
825 ("M-s u" . consult-focus-lines)
826 ;; Isearch integration
827 ("M-s e" . consult-isearch-history)
828 :map isearch-mode-map
829 ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string
830 ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string
831 ("M-s l" . consult-line) ;; needed by consult-line to detect isearch
832 ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch
833 ;; Minibuffer history
834 :map minibuffer-local-map
835 ("M-s" . consult-history) ;; orig. next-matching-history-element
836 ("M-r" . consult-history)) ;; orig. previous-matching-history-element
838 ;; Enable automatic preview at point in the *Completions* buffer. This is
839 ;; relevant when you use the default completion UI.
840 :hook (completion-list-mode . consult-preview-at-point-mode)
842 ;; The :init configuration is always executed (Not lazy)
845 ;; Optionally configure the register formatting. This improves the register
846 ;; preview for `consult-register', `consult-register-load',
847 ;; `consult-register-store' and the Emacs built-ins.
848 (setq register-preview-delay 0.5
849 register-preview-function #'consult-register-format)
851 ;; Optionally tweak the register preview window.
852 ;; This adds thin lines, sorting and hides the mode line of the window.
853 (advice-add #'register-preview :override #'consult-register-window)
855 ;; Use Consult to select xref locations with preview
856 (setq xref-show-xrefs-function #'consult-xref
857 xref-show-definitions-function #'consult-xref)
859 ;; Configure other variables and modes in the :config section,
860 ;; after lazily loading the package.
863 ;; Optionally configure preview. The default value
864 ;; is 'any, such that any key triggers the preview.
865 ;; (setq consult-preview-key 'any)
866 ;; (setq consult-preview-key "M-.")
867 ;; (setq consult-preview-key '("S-<down>" "S-<up>"))
868 ;; For some commands and buffer sources it is useful to configure the
869 ;; :preview-key on a per-command basis using the `consult-customize' macro.
871 consult-theme :preview-key '(:debounce 0.2 any)
872 consult-ripgrep consult-git-grep consult-grep
873 consult-bookmark consult-recent-file consult-xref
874 consult--source-bookmark consult--source-file-register
875 consult--source-recent-file consult--source-project-recent-file
876 ;; :preview-key "M-."
877 :preview-key '(:debounce 0.4 any))
879 ;; Optionally configure the narrowing key.
880 ;; Both < and C-+ work reasonably well.
881 (setq consult-narrow-key "<") ;; "C-+"
883 ;; Optionally make narrowing help available in the minibuffer.
884 ;; You may want to use `embark-prefix-help-command' or which-key instead.
885 ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)
887 ;; By default `consult-project-function' uses `project-root' from project.el.
888 ;; Optionally configure a different project root function.
889 ;;;; 1. project.el (the default)
890 ;; (setq consult-project-function #'consult--default-project--function)
891 ;;;; 2. vc.el (vc-root-dir)
892 ;; (setq consult-project-function (lambda (_) (vc-root-dir)))
893 ;;;; 3. locate-dominating-file
894 ;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git")))
895 ;;;; 4. projectile.el (projectile-project-root)
896 ;; (autoload 'projectile-project-root "projectile")
897 ;; (setq consult-project-function (lambda (_) (projectile-project-root)))
898 ;;;; 5. No project support
899 ;; (setq consult-project-function nil)
902 ** Projectile -- Project management
903 #+begin_src emacs-lisp
904 (use-package projectile
905 :bind (("<f5>" . projectile-compile-project)
906 ("<f6>" . next-error))
907 :config (projectile-global-mode))
911 #+BEGIN_SRC emacs-lisp
914 :bind ("M-z" . avy-zap-up-to-char-dwim))
917 #+BEGIN_SRC emacs-lisp
919 :bind (("C-c 2" . my/hydra-orgmodes/body)
920 ("C-c @" . my/hydra-orgmodes/body)
921 ("C-c #" . my/hydra-outline/body)
922 ("C-c 3" . my/hydra-outline/body)
925 (defhydra my/hydra-orgmodes (:color blue :hint nil)
927 _n_: notes _c_: chaim _w_: wildman _o_: ool
928 _u_: uddin _s_: steve _r_: refile _f_: fh
929 _p_: read papers _R_: paper notes
934 ("n" (find-file "~/projects/org-notes/notes.org"))
935 ("c" (find-file "~/projects/org-notes/chaim.org"))
936 ("w" (find-file "~/projects/org-notes/wildman.org"))
937 ("u" (find-file "~/projects/org-notes/uddin.org"))
938 ("o" (find-file "~/projects/org-notes/ool.org"))
939 ("f" (find-file "~/projects/org-notes/fh.org"))
940 ("s" (find-file "~/projects/org-notes/sndservers.org"))
941 ("r" (find-file my/org-refile-file))
942 ("p" (find-file "~/projects/research/papers_to_read.org"))
943 ("R" (find-file "~/projects/research/paper_notes.org"))
944 ("h" (find-file "~/projects/org-notes/hpcbio.org"))
949 ;; from https://github.com/abo-abo/hydra/wiki/Emacs
950 (defhydra my/hydra-outline (:color pink :hint nil)
953 ^^^^^^------------------------------------------------------
954 _q_: sublevels _a_: all _u_: up
955 _t_: body _e_: entry _n_: next visible
956 _o_: other _i_: children _p_: previous visible
957 _c_: entry _k_: branches _f_: forward same level
958 _l_: leaves _s_: subtree _b_: backward same level
963 ("q" outline-hide-sublevels) ; Hide everything but the top-level headings
964 ("t" outline-hide-body) ; Hide everything but headings (all body lines)
965 ("o" outline-hide-other) ; Hide other branches
966 ("c" outline-hide-entry) ; Hide this entry's body
967 ("l" outline-hide-leaves) ; Hide body lines in this entry and sub-entries
968 ("d" outline-hide-subtree) ; Hide everything in this entry and sub-entries
970 ("a" outline-show-all) ; Show (expand) everything
971 ("e" outline-show-entry) ; Show this heading's body
972 ("i" outline-show-children) ; Show this heading's immediate child sub-headings
973 ("k" outline-show-branches) ; Show all sub-headings under this heading
974 ("s" outline-show-subtree) ; Show (expand) everything in this heading & below
976 ("u" outline-up-heading) ; Up
977 ("n" outline-next-visible-heading) ; Next
978 ("p" outline-previous-visible-heading) ; Previous
979 ("f" outline-forward-same-level) ; Forward - same level
980 ("b" outline-backward-same-level) ; Backward - same level
986 #+BEGIN_SRC emacs-lisp
989 (add-to-list 'tramp-methods '("vcsh"
990 (tramp-login-program "vcsh")
994 (tramp-remote-shell "/bin/sh")
995 (tramp-remote-shell-args
999 #+BEGIN_SRC emacs-lisp
1002 (setq-default reftex-default-bibliography
1003 '("~/projects/research/references.bib")))
1006 #+BEGIN_SRC emacs-lisp
1008 :config (setq bibtex-user-optional-fields
1009 (quote (("annote" "Personal annotation (ignored)")
1017 #+BEGIN_SRC emacs-lisp
1022 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
1023 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
1024 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
1025 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
1026 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
1027 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
1028 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
1029 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
1030 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
1031 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
1032 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
1034 (setq-default reftex-plug-into-AUCTeX t)
1035 ;; support fake section headers
1036 (setq TeX-outline-extra
1040 ("%subsubsection" 4)
1042 ;; add font locking to the headers
1043 (font-lock-add-keywords
1045 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
1046 0 'font-lock-keyword-face t)
1047 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
1048 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
1049 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
1050 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
1051 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
1053 ;; use smart quotes by default instead of `` and ''
1054 ;; taken from http://kieranhealy.org/esk/kjhealy.html
1055 (setq TeX-open-quote "“")
1056 (setq TeX-close-quote "”")
1058 ;; (TeX-add-style-hook
1063 ;; (custom-set-variables
1064 ;; '(font-latex-user-keyword-classes
1067 ;; font-lock-function-name-face 2 (command 1 t))))
1069 (setq-default TeX-parse-self t)
1070 (setq-default TeX-auto-save t)
1071 (setq-default TeX-master nil)
1072 (add-to-list 'LaTeX-font-list
1073 '(?\C-a "\\alert{","}"))
1076 '(TeX-add-style-hook
1079 (if (boundp 'reftex-ref-style-alist)
1081 'reftex-ref-style-alist
1082 '("Cleveref" "cleveref"
1083 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
1084 (reftex-ref-style-activate "Cleveref")
1086 '("cref" TeX-arg-ref)
1087 '("Cref" TeX-arg-ref)
1088 '("cpageref" TeX-arg-ref)
1089 '("Cpageref" TeX-arg-ref)))))
1092 '(add-to-list 'LaTeX-fill-excluded-macros
1095 (use-package font-latex
1097 (setq font-latex-match-reference-keywords
1119 (setq font-latex-fontify-script nil)
1120 (setq font-latex-fontify-sectioning (quote color))
1121 (setq font-latex-script-display (quote (nil)))
1126 #+BEGIN_SRC emacs-lisp
1129 :mode ("\\.R\\'" . ess-r-mode)
1130 :bind (:map ess-mode-map
1131 ("C-c C-R" . dla/ess-region-remote-eval))
1133 (autoload 'ess-r-mode "ess-site" nil t)
1134 (autoload 'R "ess-site" nil t)
1136 ; actually load the rest of ess
1138 (defun ess-change-directory (path)
1139 "Set the current working directory to PATH for both *R* and Emacs."
1140 (interactive "Directory to change to: ")
1142 (when (file-exists-p path)
1143 (ess-command (concat "setwd(\"" path "\")\n"))
1144 ;; use file-name-as-directory to ensure it has trailing /
1145 (setq default-directory (file-name-as-directory path))))
1146 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
1147 ;; outlining support for ess modes
1151 (outline-minor-mode)
1152 (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
1153 (defun outline-level ()
1154 (cond ((looking-at "^##### ") 1)
1155 ((looking-at "^#### ") 2)
1156 ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
1159 (defun dla/ess-region-remote-eval (start end)
1160 "Evaluate region in a remote ESS instance"
1162 (shell-command-on-region start end "eval_r" (get-buffer-create "***essregionremoteeval***") nil nil nil)
1163 (kill-buffer "***essregionremoteeval***"))
1164 ;; Don't restore history or save workspace image
1165 '(inferior-R-args "--no-restore-history --no-save")
1170 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
1172 #+BEGIN_SRC emacs-lisp
1173 (use-package rainbow-mode
1174 ;; add ess to the x major mode
1175 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
1176 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
1181 #+BEGIN_SRC emacs-lisp
1182 (use-package yaml-mode
1183 ;; add ess to the x major mode
1184 :mode ("\\.\\(yaml|yml\\)\\'" . yaml-mode)
1189 #+BEGIN_SRC emacs-lisp
1190 (use-package poly-noweb
1194 (use-package poly-markdown
1198 :after (:all polymode poly-markdown poly-noweb)
1199 :mode ("\\.Snw" . poly-noweb+r-mode)
1200 :mode ("\\.Rnw" . poly-noweb+r-mode)
1201 :mode ("\\.Rmd" . poly-markdown+r-mode)
1203 (use-package polymode
1210 #+BEGIN_SRC emacs-lisp
1211 ; this package doesn't really do exactly what we want it to do
1212 ; (use-package outline-magic)
1215 #+BEGIN_SRC emacs-lisp
1216 ;; change the outline mode prefix from C-c @ to C-c C-2
1217 (setq outline-minor-mode-prefix "C-c C-2")
1218 ;;(add-hook 'outline-minor-mode-hook
1219 ;; (lambda () (local-set-key (kbd "C-c C-2")
1220 ;; outline-mode-prefix-map)))
1224 #+BEGIN_SRC emacs-lisp
1225 (use-package writeroom-mode
1227 (defun my/writing-mode ()
1228 "Start my writing mode; enable visual-line-mode and auto-fill-mode"
1233 (visual-line-mode -1)
1235 (visual-fill-column-mode -1)
1237 (visual-line-mode 1)
1239 (visual-fill-column-mode 1)
1244 ** GhostText/Atomic Chrome
1245 #+BEGIN_SRC emacs-lisp
1246 (use-package atomic-chrome
1248 (ignore-errors (atomic-chrome-start-server))
1249 (setq atomic-chrome-buffer-open-style 'full)
1253 #+BEGIN_SRC emacs-lisp
1254 (use-package edit-server
1255 :commands edit-server-start
1256 :init (if after-init-time
1258 (add-hook 'after-init-hook
1259 #'(lambda() (edit-server-start))))
1260 :config (setq edit-server-new-frame-alist
1261 '((name . "Edit with Emacs FRAME")
1267 (menu-bar-lines . t)
1268 (window-system . x)))
1272 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
1273 #+BEGIN_SRC emacs-lisp
1274 (use-package multiple-cursors
1275 :bind* (("C-;" . mc/mark-all-dwim)
1276 ("C-<" . mc/mark-previous-like-this)
1277 ("C->" . mc/mark-next-like-this)
1278 ("C-S-c C-S-c" . mc/edit-lines))
1282 #+BEGIN_SRC emacs-lisp
1283 (use-package web-mode
1284 :load-path "/home/don/projects/web-mode/"
1285 :mode ("\\.\\(tx|tmpl\\)\\'" . web-mode)
1287 (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . web-mode))
1288 (setq web-mode-enable-engine-detection t)
1289 (setq web-mode-engines-alist
1290 '(("template-toolkit" . "\\.tmpl\\'")))
1293 ** Spamassassin Mode
1294 #+BEGIN_SRC emacs-lisp
1295 (use-package spamassassin-mode
1296 :commands spamassassin-mode
1300 #+BEGIN_SRC emacs-lisp
1301 (use-package password-store
1302 :commands password-store-edit password-store-generate
1304 (defun dla/password-store-edit (entry)
1305 "Edit password for ENTRY which doesn't require it to already exist"
1306 (interactive (list (password-store--completing-read nil)))
1307 (password-store--run-edit entry))
1308 (advice-add 'password-store-edit :override #'dla/password-store-edit)
1312 #+BEGIN_SRC emacs-lisp
1316 ;; fix up css mode to not be silly
1317 ;; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
1318 (setq cssm-indent-level 4)
1319 (setq cssm-newline-before-closing-bracket t)
1320 (setq cssm-indent-function #'cssm-c-style-indenter)
1321 (setq cssm-mirror-mode nil))
1324 #+BEGIN_SRC emacs-lisp
1326 :delight abbrev-mode
1328 ;; load abbreviations from
1329 (setq abbrev-file-name
1330 "~/.emacs_abbrev_def")
1332 ;; read the abbrev file if it exists
1333 (if (file-exists-p abbrev-file-name)
1334 (quietly-read-abbrev-file))
1336 ;; for now, use abbrev mode everywhere
1337 (setq default-abbrev-mode t))
1340 ** Debugging (realgud)
1341 #+BEGIN_SRC emacs-lisp
1342 (use-package realgud
1345 ** Python Programming
1346 #+BEGIN_SRC emacs-lisp
1347 (use-package python-mode
1350 (python-mode . pyenv-mode)
1351 (python-mode . flycheck-mode)
1352 (python-mode . blacken-mode)
1353 (python-mode . yas-minor-mode)
1354 (python-mode . anaconda-mode)
1356 (use-package pyenv-mode
1359 (use-package blacken
1363 (setq-default blacken-fast-unsafe t)
1367 #+begin_src emacs-lisp :tangle yes
1368 (use-package python-black
1372 *** Sphinx Documentation
1373 #+begin_src emacs-lisp :tangle yes
1374 (use-package numpydoc
1377 :bind (:map python-mode-map
1378 ("C-c C-n" . numpydoc-generate)))
1379 (use-package sphinx-doc
1383 (setq sphinx-doc-include-types t)
1385 (use-package python-docstring
1389 (python-mode . python-docstring-mode)
1393 #+BEGIN_SRC emacs-lisp
1394 (use-package go-mode
1401 #+BEGIN_SRC emacs-lisp
1402 (use-package expand-region
1403 :bind (("C-=" . 'er/expand-region))
1408 #+BEGIN_SRC emacs-lisp
1409 (use-package dockerfile-mode
1415 #+BEGIN_SRC emacs-lisp
1416 (use-package beancount
1417 :load-path "~/lib/emacs_el/beancount-mode/"
1419 :mode "\\.beancount\\'"
1426 #+BEGIN_SRC emacs-lisp
1427 (use-package message
1428 :delight (message "✉")
1429 :delight (message-mode "✉")
1430 :mode ("muttng-[a-z0-9]+-[0-9]+-" . message-mode)
1431 :mode ("mutt-[a-z0-9]+-[0-9]+-" . message-mode)
1432 :hook 'my/message-mode-settings
1433 :hook 'turn-on-flyspell
1434 :bind (:map message-mode-map
1435 ("C-c C-a" . my/post-attach-file))
1437 (defun my/message-mode-settings ()
1438 (font-lock-add-keywords nil
1439 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1440 (0 'message-multiply-quoted-text-face))
1441 ("^[ \t]*>[ \t]*>.*$"
1442 (0 'message-double-quoted-text-face))))
1445 (defun my/post-attach-file ()
1446 "Prompt for an attachment."
1448 (let ((file (read-file-name "Attach file: " nil nil t nil)))
1449 (my/header-attach-file file "")))
1451 (defun my/header-attach-file (file description)
1452 "Attach a FILE to the current message (works with Mutt).
1453 Argument DESCRIPTION MIME description."
1454 (interactive "fAttach file: \nsDescription: ")
1455 (when (> (length file) 0)
1460 (goto-char (point-min))
1461 (search-forward-regexp "^$")
1462 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1464 (message (concat "Attached '" file "'."))
1465 (setq post-has-attachment t))))))
1467 (setq mail-yank-prefix "> ")
1468 (setq mail-header-separator "") ; fix broken header detection
1472 #+BEGIN_SRC emacs-lisp
1473 (use-package muttrc-mode
1478 *** Set mail User agent
1479 #+BEGIN_SRC emacs-lisp
1480 (setq mail-user-agent (quote sendmail-user-agent))
1483 #+BEGIN_SRC emacs-lisp
1488 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
1492 ** Reverting buffers
1493 #+BEGIN_SRC emacs-lisp
1494 (use-package autorevert
1495 :delight auto-revert-mode
1497 (setq global-auto-revert-non-file-buffers t
1498 global-auto-revert-ignore-modes '(pdf-view-mode)
1499 auto-revert-verbose nil)
1500 (global-auto-revert-mode 1))
1503 ** Use-package and load things
1504 #+BEGIN_SRC emacs-lisp
1507 :delight (org-mode "ø")
1508 :mode ("\\.\\(org\\|org_archive\\|txt\\)\\'" . org-mode)
1509 :bind (("C-c l" . org-store-link)
1510 ("C-c a" . org-agenda)
1511 ("C-c b" . org-iswitchb))
1513 ** Agenda Configuration
1514 #+BEGIN_SRC emacs-lisp
1516 (setq-default org-log-done 'time)
1517 (setq-default org-agenda-ndays 5)
1519 (setq org-agenda-sticky t)
1520 (defun dla/show-org-agenda ()
1525 (and (string-match-p
1533 (buffer-name agendabuffer))
1535 (delete-other-windows))
1537 ;; agenda configuration
1538 ;; Do not dim blocked tasks
1539 (setq org-agenda-dim-blocked-tasks nil)
1540 (setq org-agenda-inhibit-startup t)
1541 (setq org-agenda-use-tag-inheritance nil)
1543 ;; Compact the block agenda view
1544 (setq org-agenda-compact-blocks t)
1546 ;; Custom agenda command definitions
1547 (setq org-agenda-custom-commands
1548 (quote (("N" "Notes" tags "NOTE"
1549 ((org-agenda-overriding-header "Notes")
1550 (org-tags-match-list-sublevels t)))
1551 ("h" "Habits" tags-todo "STYLE=\"habit\""
1552 ((org-agenda-overriding-header "Habits")
1553 (org-agenda-sorting-strategy
1554 '(todo-state-down effort-up category-keep))))
1558 ((org-agenda-overriding-header "Tasks to Refile")
1559 (org-tags-match-list-sublevels nil)))
1560 (tags-todo "-CANCELLED/!"
1561 ((org-agenda-overriding-header "Stuck Projects")
1562 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
1563 (org-agenda-sorting-strategy
1565 (tags-todo "-HOLD-CANCELLED/!"
1566 ((org-agenda-overriding-header "Projects")
1567 (org-agenda-skip-function 'bh/skip-non-projects)
1568 (org-tags-match-list-sublevels 'indented)
1569 (org-agenda-sorting-strategy
1571 (tags-todo "-CANCELLED/!NEXT"
1572 ((org-agenda-overriding-header (concat "Project Next Tasks"
1573 (if bh/hide-scheduled-and-waiting-next-tasks
1575 " (including WAITING and SCHEDULED tasks)")))
1576 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1577 (org-tags-match-list-sublevels t)
1578 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1579 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1580 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1581 (org-agenda-sorting-strategy
1582 '(todo-state-down effort-up category-keep))))
1583 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1584 ((org-agenda-overriding-header (concat "Project Subtasks"
1585 (if bh/hide-scheduled-and-waiting-next-tasks
1587 " (including WAITING and SCHEDULED tasks)")))
1588 (org-agenda-skip-function 'bh/skip-non-project-tasks)
1589 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1590 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1591 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1592 (org-agenda-sorting-strategy
1594 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1595 ((org-agenda-overriding-header (concat "Standalone Tasks"
1596 (if bh/hide-scheduled-and-waiting-next-tasks
1598 " (including WAITING and SCHEDULED tasks)")))
1599 (org-agenda-skip-function 'bh/skip-project-tasks)
1600 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1601 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1602 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1603 (org-agenda-sorting-strategy
1605 (tags-todo "-CANCELLED+WAITING|HOLD/!"
1606 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
1607 (org-agenda-skip-function 'bh/skip-stuck-projects)
1608 (org-tags-match-list-sublevels nil)
1609 (org-agenda-todo-ignore-scheduled t)
1610 (org-agenda-todo-ignore-deadlines t)))
1612 ((org-agenda-overriding-header "Tasks to Archive")
1613 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1614 (org-tags-match-list-sublevels nil))))
1617 ; org mode agenda files
1618 (setq org-agenda-files
1620 (file-expand-wildcards "~/projects/org-notes/*.org")
1621 (file-expand-wildcards "~/org-mode/from-mobile.org")
1622 (file-expand-wildcards "~/org-notes-*/*.org")
1625 (setq my/org-refile-file
1627 (lambda (file) (string-match-p (regexp-quote "/refile.org") file))
1630 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
1631 (set-register ?r (cons 'file my/org-refile-file))
1632 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
1633 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
1634 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
1635 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
1636 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
1637 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
1638 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
1639 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
1640 ; (defun org-agenda-timeline-all (&optional arg)
1643 ; (dolist (org-agenda-file org-agenda-files)
1644 ; (insert-file-contents org-agenda-file nil)
1645 ; (goto-char (point-max))
1647 ; (write-file "/tmp/timeline.org")
1648 ; (org-agenda arg "L")))
1649 ; (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
1653 #+BEGIN_SRC emacs-lisp
1654 (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")))
1655 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
1657 (setq org-default-notes-file "~/projects/org-notes/notes.org")
1658 (setq org-id-link-to-org-use-id 'use-existing)
1660 ** Capture Templates
1661 #+BEGIN_SRC emacs-lisp
1662 (setq org-capture-templates ;; mail-specific note template, identified by "m"
1663 `(("m" "Mail" entry (file my/org-refile-file)
1664 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
1665 ("t" "todo" entry (file my/org-refile-file)
1666 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
1667 ("r" "respond" entry (file my/org-refile-file)
1668 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
1669 ("n" "note" entry (file my/org-refile-file)
1670 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
1671 ("s" "schedule" entry (file my/org-refile-file)
1672 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
1673 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
1674 "* %?\n%U\n" :clock-in t :clock-resume t)
1675 ("w" "org-protocol" entry (file my/org-refile-file)
1676 "* TODO Review %c\n%U\n" :immediate-finish t)
1677 ("M" "Meeting" entry (file my/org-refile-file)
1678 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
1679 ("S" "Seminar" entry (file my/org-refile-file)
1680 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
1681 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
1682 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
1683 ("p" "Phone call" entry (file my/org-refile-file)
1684 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
1685 ("J" "job" entry (file+olp "~/projects/org-notes/notes.org"
1687 ,(format-time-string "Positions %Y"))
1688 "* TODO Apply for %? :job:\nSCHEDULED: <%<%Y-%m-%d>>\n%U\n%x\n" :clock-in t :clock-resume t)
1689 ("h" "Habit" entry (file my/org-refile-file)
1690 "* 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")
1694 ;; Remove empty LOGBOOK drawers on clock out
1695 (defun bh/remove-empty-drawer-on-clock-out ()
1698 (beginning-of-line 0)
1699 (org-remove-empty-drawer-at (point))))
1701 (defun my/org-add-id ()
1704 (if (org-current-level)
1713 ** Org mode key bindings
1714 #+BEGIN_SRC emacs-lisp
1715 ;; org mode configuration from http://doc.norang.ca/org-mode.html
1716 ;; Custom Key Bindings
1717 :bind* (("<f9> a" . org-agenda)
1718 ("<f9> I" . bh/punch-in)
1719 ("<f9> O" . bh/punch-out)
1720 ("<f9> SPC" . bh/clock-in-last-task)
1721 ("<f12>" . dla/show-org-agenda)
1722 ;; ("<f5>" . bh/org-todo)
1723 ("<S-f5>" . bh/widen)
1724 ("<f7>" . bh/set-truncate-lines)
1725 ("<f8>" . org-cycle-agenda-files)
1726 ("<f9> <f9>" . dla/show-org-agenda)
1728 ("<f9> c" . calendar)
1729 ("<f9> f" . boxquote-insert-file)
1730 ("<f9> h" . bh/hide-other)
1731 ("<f9> n" . bh/toggle-next-task-display)
1734 ("<f9> r" . boxquote-region)
1735 ("<f9> s" . bh/switch-to-scratch)
1737 ("<f9> t" . bh/insert-inactive-timestamp)
1738 ("<f9> T" . bh/toggle-insert-inactive-timestamp)
1740 ("<f9> v" . visible-mode)
1741 ("<f9> l" . org-toggle-link-display)
1742 ("<f9> SPC" . bh/clock-in-last-task)
1743 ("C-<f9>" . previous-buffer)
1744 ("M-<f9>" . org-toggle-inline-images)
1745 ("C-x n r" . narrow-to-region)
1746 ("C-<f10>" . next-buffer)
1747 ("<f11>" . org-clock-goto)
1748 ("C-<f11>" . org-clock-in)
1749 ("C-s-<f12>" . bh/save-then-publish)
1750 ("C-c c" . org-capture))
1753 ** Utility Functions
1754 #+BEGIN_SRC emacs-lisp
1755 (defun bh/hide-other ()
1758 (org-back-to-heading 'invisible-ok)
1759 (outline-hide-other)
1764 (defun bh/set-truncate-lines ()
1765 "Toggle value of truncate-lines and refresh window display."
1767 (setq truncate-lines (not truncate-lines))
1768 ;; now refresh window display (an idiom from simple.el):
1770 (set-window-start (selected-window)
1771 (window-start (selected-window)))))
1773 (defun bh/switch-to-scratch ()
1775 (switch-to-buffer "*scratch*"))
1777 (setq org-use-fast-todo-selection t)
1778 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1780 ; create function to create headlines in file. This comes from
1781 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
1782 (defun my/org-add-ids-to-headlines-in-file ()
1783 "Add ID properties to all headlines in the current file which
1784 do not already have one."
1788 (goto-char (point-min))
1789 (when (not (re-search-forward "^#\\+OPTIONS:.*auto-id:f" (point-max) t))
1790 (org-map-entries 'org-id-get-create))))
1791 (defun dla/org-update-ids-to-headlines-in-file ()
1792 "Add or replace ID properties to all headlines in the current file
1793 (or narrowed region)."
1796 (org-map-entries '(lambda () (org-id-get-create t))))
1797 ; if we wanted to do this to every buffer, do the following:
1798 (add-hook 'org-mode-hook
1800 (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
1803 #+BEGIN_SRC emacs-lisp
1804 (use-package find-lisp
1806 (setq org-agenda-text-search-extra-files
1807 (append '(agenda-archives)
1808 (find-lisp-find-files "~/projects/org-notes" "\.org$")
1809 (find-lisp-find-files "~/projects/org-notes" "\.org_archive$")
1813 #+BEGIN_SRC emacs-lisp
1814 (setq org-todo-keywords
1815 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
1816 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
1818 (setq org-todo-keyword-faces
1819 (quote (("TODO" :foreground "red" :weight bold)
1820 ("NEXT" :foreground "blue" :weight bold)
1821 ("DONE" :foreground "forest green" :weight bold)
1822 ("WAITING" :foreground "orange" :weight bold)
1823 ("HOLD" :foreground "magenta" :weight bold)
1824 ("CANCELLED" :foreground "forest green" :weight bold)
1825 ("MEETING" :foreground "forest green" :weight bold)
1826 ("PHONE" :foreground "forest green" :weight bold))))
1828 (setq org-todo-state-tags-triggers
1829 (quote (("CANCELLED" ("CANCELLED" . t))
1830 ("WAITING" ("WAITING" . t))
1831 ("HOLD" ("WAITING") ("HOLD" . t))
1832 (done ("WAITING") ("HOLD"))
1833 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1834 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1835 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1839 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1840 ; add ids on creation of nodes
1841 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
1844 ; resolve clocks after 10 minutes of idle; use xprintidle
1845 ; (setq org-clock-idle-time 10)
1846 ; (setq org-clock-x11idle-program-name "xprintidle")
1848 ; this is from http://doc.norang.ca/org-mode.html#Capture
1849 ; use C-M-r for org mode capture
1850 (global-set-key (kbd "C-M-r") 'org-capture)
1852 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1853 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1854 (org-agenda-files :maxlevel . 9))))
1856 ; Use full outline paths for refile targets - we file directly with IDO
1857 (setq org-refile-use-outline-path t)
1859 ; Targets complete directly with IDO
1860 (setq org-outline-path-complete-in-steps nil)
1862 ; Allow refile to create parent tasks with confirmation
1863 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1865 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
1866 ; (setq org-completion-use-ido t)
1867 ; (setq ido-everywhere t)
1868 ; (setq ido-max-directory-size 100000)
1869 ; (ido-mode (quote both))
1870 ; ; Use the current window when visiting files and buffers with ido
1871 ; (setq ido-default-file-method 'selected-window)
1872 ; (setq ido-default-buffer-method 'selected-window)
1873 ; ; Use the current window for indirect buffer display
1874 ; (setq org-indirect-buffer-display 'current-window)
1877 ;;;; Refile settings
1878 ; Exclude DONE state tasks from refile targets
1879 (defun bh/verify-refile-target ()
1880 "Exclude todo keywords with a done state from refile targets"
1881 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
1883 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1885 ;; ensure that emacsclient will show just the note to be edited when invoked
1886 ;; from Mutt, and that it will shut down emacsclient once finished;
1887 ;; fallback to legacy behavior when not invoked via org-protocol.
1888 (require 'org-protocol)
1889 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
1890 (setq my-org-protocol-flag nil)
1891 (defadvice org-capture-finalize (after delete-frame-at-end activate)
1892 "Delete frame at remember finalization"
1893 (progn (if my-org-protocol-flag (delete-frame))
1894 (setq my-org-protocol-flag nil)))
1895 (defadvice org-capture-refile (around delete-frame-after-refile activate)
1896 "Delete frame at remember refile"
1897 (if my-org-protocol-flag
1899 (setq my-org-protocol-flag nil)
1904 (defadvice org-capture-kill (after delete-frame-at-end activate)
1905 "Delete frame at remember abort"
1906 (progn (if my-org-protocol-flag (delete-frame))
1907 (setq my-org-protocol-flag nil)))
1908 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
1909 (setq my-org-protocol-flag t))
1911 (defadvice org-insert-todo-heading (after dla/create-id activate)
1912 (unless (org-in-item-p)
1918 (add-to-list 'org-modules 'org-habit)
1920 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
1921 (defun open-mail-in-mutt (message)
1922 "Open a mail message in Mutt, using an external terminal.
1924 Message can be specified either by a path pointing inside a
1925 Maildir, or by Message-ID."
1926 (interactive "MPath or Message-ID: ")
1928 (format "faf xterm -e \"%s %s\""
1929 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
1931 ;; add support for "mutt:ID" links
1932 (org-add-link-type "mutt" 'open-mail-in-mutt)
1934 (defun my-org-mode-setup ()
1935 ; (load-library "reftex")
1936 (and (buffer-file-name)
1937 (file-exists-p (buffer-file-name))
1939 ; (reftex-parse-all)
1940 (reftex-set-cite-format
1941 '((?b . "[[bib:%l][%l-bib]]")
1942 (?n . "[[notes:%l][%l-notes]]")
1944 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
1946 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
1947 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
1948 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
1949 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
1951 (add-hook 'org-mode-hook 'my-org-mode-setup)
1953 (defun org-mode-reftex-search ()
1955 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
1957 (defun open-research-paper (bibtexkey)
1958 "Open a paper by bibtex key"
1959 (interactive "bibtex key: ")
1962 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1963 (org-add-link-type "papers" 'open-research-paper)
1964 (defun open-research-paper-pdf (bibtexkey)
1965 "Open a paper pdf by bibtex key"
1966 (interactive "bibtex key: ")
1968 (format "%s -p evince_annot %s"
1969 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1970 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
1972 (add-to-list 'org-link-abbrev-alist
1974 "~/projects/research/paper_notes.org::#%s"))
1976 ; I pretty much always want hiearchical checkboxes
1977 (setq org-hierachical-checkbox-statistics nil)
1979 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
1980 (add-to-list 'org-structure-template-alist
1981 '("E" "\\begin{equation}\n?\n\\end{equation}"))
1984 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
1985 (defun my-rtcite-export-handler (path desc format)
1986 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
1987 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
1988 (match-string 1 path)))
1989 (path (substring path 0 (match-beginning 0))))
1990 (cond ((eq format 'latex)
1992 (equal 0 (search "rtcite:" desc)))
1993 (format "\\cite{%s}" search)
1994 (format "\\cite[%s]{%s}" desc search))))))
1996 (org-add-link-type "rtcite"
1998 'my-rtcite-export-handler)
2002 ** Org Mobile Configuration
2003 #+BEGIN_SRC emacs-lisp
2004 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
2005 (when (string= system-name "linnode")
2006 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
2007 (setq-default org-directory "/home/don/org-mode/")
2008 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
2012 #+BEGIN_SRC emacs-lisp
2013 ;; org mode ical export
2014 (setq org-icalendar-timezone "America/Los_Angeles")
2015 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
2016 ;; we already add the id manually
2017 (setq org-icalendar-store-UID t)
2020 ** General Org Babel Configuration
2021 #+BEGIN_SRC emacs-lisp
2022 ;; org babel support
2023 (org-babel-do-load-languages
2024 'org-babel-load-languages
2031 ;; set the right path to ditaa.jar
2032 (setq org-ditaa-jar-path "/usr/share/ditaa/ditaa.jar")
2033 ;; use graphviz-dot for dot things
2034 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
2035 ;; do not indent begin_src blocks
2036 (setq org-edit-src-content-indentation 0)
2037 ;; org-babel-by-backend
2038 (defmacro org-babel-by-backend (&rest body)
2039 `(case (if (boundp 'backend)
2040 (org-export-backend-name backend)
2043 (defun my/fix-inline-images ()
2044 (when org-inline-image-overlays
2045 (org-redisplay-inline-images)))
2047 (add-hook 'org-babel-after-execute-hook
2048 'my/fix-inline-images)
2051 ** LaTeX configuration
2052 #+BEGIN_SRC emacs-lisp
2053 (use-package org-plus-contrib
2058 (ox-extras-activate '(latex-header-blocks ignore-headlines))
2060 (add-to-list 'org-latex-classes
2062 "\\documentclass[11pt,oneside,article]{memoir}\n"
2063 ("\\section{%s}" . "\\section*{%s}")
2064 ("\\subsection{%s}" . "\\subsection*{%s}")
2065 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2066 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2067 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2069 (setq org-beamer-outline-frame-options "")
2070 (add-to-list 'org-latex-classes
2072 "\\documentclass[ignorenonframetext]{beamer}
2073 [NO-DEFAULT-PACKAGES]
2076 ("\\section{%s}" . "\\section*{%s}")
2077 ("\\subsection{%s}" . "\\subsection*{%s}")
2078 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2079 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2080 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2082 (add-to-list 'org-latex-classes
2084 "\\documentclass[11pt,oneside]{memoir}\n"
2085 ("\\chapter{%s}" . "\\chapter*{%s}")
2086 ("\\section{%s}" . "\\section*{%s}")
2087 ("\\subsection{%s}" . "\\subsection*{%s}")
2088 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
2090 (add-to-list 'org-latex-classes
2092 "\\documentclass[11pt]{letter}
2093 [NO-DEFAULT-PACKAGES]
2096 ("\\section{%s}" . "\\section*{%s}")
2097 ("\\subsection{%s}" . "\\subsection*{%s}")
2098 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2099 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2100 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2102 (add-to-list 'org-latex-classes
2104 "\\documentclass{dlacv}
2105 [NO-DEFAULT-PACKAGES]
2108 ("\\section{%s}" . "\\section*{%s}")
2109 ("\\subsection{%s}" . "\\subsection*{%s}")
2110 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2111 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2112 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2115 (add-to-list 'org-latex-classes
2117 "\\documentclass{dlaresume}
2118 [NO-DEFAULT-PACKAGES]
2121 ("\\section{%s}" . "\\section*{%s}")
2122 ("\\subsection{%s}" . "\\subsection*{%s}")
2123 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2124 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2125 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2128 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
2129 ;; but adapted to use latexmk 4.22 or higher.
2130 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
2132 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
2133 (setq org-latex-default-packages-alist
2135 ("" "unicode-math" t)
2137 (setq org-latex-packages-alist
2144 ("" "longtable" nil)
2147 ;; make equations larger
2148 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
2150 (defun org-create-formula--latex-header ()
2151 "Return LaTeX header appropriate for previewing a LaTeX snippet."
2152 (let ((info (org-combine-plists (org-export--get-global-options
2153 (org-export-get-backend 'latex))
2154 (org-export--get-inbuffer-options
2155 (org-export-get-backend 'latex)))))
2156 (org-latex-guess-babel-language
2157 (org-latex-guess-inputenc
2158 (org-splice-latex-header
2159 org-format-latex-header
2160 org-latex-default-packages-alist
2162 (plist-get info :latex-header)))
2166 ; support ignoring headers in org mode export to latex
2167 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
2168 (defadvice org-latex-headline (around my-latex-skip-headlines
2169 (headline contents info) activate)
2170 (if (member "ignoreheading" (org-element-property :tags headline))
2171 (setq ad-return-value contents)
2174 ;; keep latex logfiles
2176 (setq org-latex-remove-logfiles nil)
2179 ;; Resume clocking task when emacs is restarted
2180 (org-clock-persistence-insinuate)
2182 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
2183 (setq org-clock-history-length 23)
2184 ;; Resume clocking task on clock-in if the clock is open
2185 (setq org-clock-in-resume t)
2186 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
2187 ;; there are things like PHONE calls
2188 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
2189 ;; Separate drawers for clocking and logs
2190 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
2191 ;; Save clock data and state changes and notes in the LOGBOOK drawer
2192 (setq org-clock-into-drawer t)
2193 (setq org-log-into-drawer t)
2194 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
2195 (setq org-clock-out-remove-zero-time-clocks t)
2196 ;; Clock out when moving task to a done state
2197 (setq org-clock-out-when-done t)
2198 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
2199 (setq org-clock-persist t)
2200 ;; Do not prompt to resume an active clock
2201 (setq org-clock-persist-query-resume nil)
2202 ;; Enable auto clock resolution for finding open clocks
2203 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
2204 ;; Include current clocking task in clock reports
2205 (setq org-clock-report-include-clocking-task t)
2207 ;; the cache seems to be broken
2208 (setq org-element-use-cache nil)
2210 (defvar bh/keep-clock-running nil)
2212 (defun bh/is-task-p ()
2213 "Any task with a todo keyword and no subtask"
2217 (subtree-end (save-excursion (org-end-of-subtree t)))
2218 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2221 (while (and (not has-subtask)
2222 (< (point) subtree-end)
2223 (re-search-forward "^\*+ " subtree-end t))
2224 (when (member (org-get-todo-state) org-todo-keywords-1)
2225 (setq has-subtask t))))
2226 (and is-a-task (not has-subtask)))))
2227 (defun bh/is-project-p ()
2228 "Any task with a todo keyword subtask"
2232 (subtree-end (save-excursion (org-end-of-subtree t)))
2233 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2236 (while (and (not has-subtask)
2237 (< (point) subtree-end)
2238 (re-search-forward "^\*+ " subtree-end t))
2239 (when (member (org-get-todo-state) org-todo-keywords-1)
2240 (setq has-subtask t))))
2241 (and is-a-task has-subtask))))
2243 (defun bh/is-subproject-p ()
2244 "Any task which is a subtask of another project"
2245 (let ((is-subproject)
2246 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2248 (while (and (not is-subproject) (org-up-heading-safe))
2249 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
2250 (setq is-subproject t))))
2251 (and is-a-task is-subproject)))
2254 (defun bh/clock-in-to-next (kw)
2255 "Switch a task from TODO to NEXT when clocking in.
2256 Skips capture tasks, projects, and subprojects.
2257 Switch projects and subprojects from NEXT back to TODO"
2258 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
2260 ((and (member (org-get-todo-state) (list "TODO"))
2263 ((and (member (org-get-todo-state) (list "NEXT"))
2267 (defun bh/punch-in (arg)
2268 "Start continuous clocking and set the default task to the
2269 selected task. If no task is selected set the Organization task
2270 as the default task."
2272 (setq bh/keep-clock-running t)
2273 (if (equal major-mode 'org-agenda-mode)
2275 ;; We're in the agenda
2277 (let* ((marker (org-get-at-bol 'org-hd-marker))
2278 (tags (org-with-point-at marker (org-get-tags))))
2279 (if (and (eq arg 4) tags)
2280 (org-agenda-clock-in '(16))
2281 (bh/clock-in-organization-task-as-default)))
2283 ;; We are not in the agenda
2287 ; Find the tags on the current task
2288 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
2289 (org-clock-in '(16))
2290 (bh/clock-in-organization-task-as-default)))))
2292 (defun bh/punch-out ()
2294 (setq bh/keep-clock-running nil)
2295 (when (org-clock-is-active)
2297 (org-agenda-remove-restriction-lock))
2299 (defun bh/clock-in-default-task ()
2301 (org-with-point-at org-clock-default-task
2304 (defun bh/clock-in-parent-task ()
2305 "Move point to the parent (project) task if any and clock in"
2306 (let ((parent-task))
2310 (while (and (not parent-task) (org-up-heading-safe))
2311 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
2312 (setq parent-task (point))))
2314 (org-with-point-at parent-task
2316 (when bh/keep-clock-running
2317 (bh/clock-in-default-task)))))))
2319 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
2321 (defun bh/clock-in-organization-task-as-default ()
2323 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
2324 (org-clock-in '(16))))
2326 (defun bh/clock-out-maybe ()
2327 (when (and bh/keep-clock-running
2328 (not org-clock-clocking-in)
2329 (marker-buffer org-clock-default-task)
2330 (not org-clock-resolving-clocks-due-to-idleness))
2331 (bh/clock-in-parent-task)))
2333 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
2336 (defun bh/clock-in-task-by-id (id)
2337 "Clock in a task by id"
2338 (org-with-point-at (org-id-find id 'marker)
2339 (org-clock-in nil)))
2341 (defun bh/clock-in-last-task (arg)
2342 "Clock in the interrupted task if there is one
2343 Skip the default task and get the next one.
2344 A prefix arg forces clock in of the default task."
2346 (let ((clock-in-to-task
2348 ((eq arg 4) org-clock-default-task)
2349 ((and (org-clock-is-active)
2350 (equal org-clock-default-task (cadr org-clock-history)))
2351 (caddr org-clock-history))
2352 ((org-clock-is-active) (cadr org-clock-history))
2353 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
2354 (t (car org-clock-history)))))
2356 (org-with-point-at clock-in-to-task
2357 (org-clock-in nil))))
2360 (defun org-export-to-ods ()
2362 (let ((csv-file "data.csv"))
2363 (org-table-export csv-file "orgtbl-to-csv")
2364 (org-odt-convert csv-file "ods" 'open)))
2366 ; allow for zero-width-space to be a break in regexp too
2367 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
2368 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
2369 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
2371 ;; support inserting screen shots
2372 (defun my/org-insert-screenshot ()
2373 "Take a screenshot into a time stamped unique-named file in the
2374 same directory as the org-buffer and insert a link to this file."
2376 (defvar my/org-insert-screenshot/filename)
2377 (setq my/org-insert-screenshot/filename
2379 "Screenshot to insert: "
2381 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
2384 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
2385 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
2386 (org-display-inline-images))
2388 (defun my/fix-inline-images ()
2389 (when org-inline-image-overlays
2390 (org-redisplay-inline-images)))
2392 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
2394 ;; use xelatex to preview with imagemagick
2395 (add-to-list 'org-preview-latex-process-alist
2396 '(xelateximagemagick
2397 :programs ("xelatex" "convert")
2398 :description "pdf > png"
2399 :message "you need to install xelatex and imagemagick"
2401 :image-input-type "pdf"
2402 :image-output-type "png"
2403 :image-size-adjust (1.0 . 1.0)
2404 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
2405 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
2407 ;; use xelatex by default
2408 (setq org-preview-latex-default-process 'xelateximagemagick)
2410 ; from http://orgmode.org/Changes.html
2411 (defun my/org-repair-property-drawers ()
2412 "Fix properties drawers in current buffer.
2413 Ignore non Org buffers."
2415 (when (eq major-mode 'org-mode)
2416 (org-with-wide-buffer
2417 (goto-char (point-min))
2418 (let ((case-fold-search t)
2419 (inline-re (and (featurep 'org-inlinetask)
2420 (concat (org-inlinetask-outline-regexp)
2424 (unless (and inline-re (org-looking-at-p inline-re))
2426 (let ((end (save-excursion (outline-next-heading) (point))))
2428 (when (org-looking-at-p org-planning-line-re) (forward-line))
2429 (when (and (< (point) end)
2430 (not (org-looking-at-p org-property-drawer-re))
2432 (and (re-search-forward org-property-drawer-re end t)
2433 (eq (org-element-type
2434 (save-match-data (org-element-at-point)))
2436 (insert (delete-and-extract-region
2438 (min (1+ (match-end 0)) end)))
2439 (unless (bolp) (insert "\n"))))))))))))
2443 #+BEGIN_SRC emacs-lisp
2447 (use-package calfw-org
2450 (use-package org-gcal
2451 :if (file-readable-p "~/.hide/org_gcal.el")
2453 :config '((if (file-readable-p "~/.hide/org_gcal.el")
2454 (load-file "~/.hide/org_gcal.el"))
2459 #+BEGIN_SRC emacs-lisp
2463 ;; Show notification 10 minutes before event
2464 (setq appt-message-warning-time 10)
2465 ;; Disable multiple reminders
2466 (setq appt-display-interval appt-message-warning-time)
2467 (setq appt-display-mode-line nil)
2469 ;; add automatic reminders for appointments
2470 (defun my/org-agenda-to-appt ()
2472 (setq appt-time-msg-list nil)
2473 (org-agenda-to-appt))
2474 ;; add reminders when starting emacs
2475 (my/org-agenda-to-appt)
2476 ;; when rebuilding the agenda
2477 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
2478 "Pressing `r' on the agenda will also add appointments."
2479 (my/org-agenda-to-appt)
2481 ;; when saving all org buffers
2482 (defadvice org-save-all-org-buffers (after org-save-all-org-buffers-add-appts)
2483 "Re-add appts after saving all org buffers"
2484 (my/org-agenda-to-appt))
2485 ;; Display appointments as a window manager notification
2486 (setq appt-disp-window-function 'my/appt-display)
2487 (setq appt-delete-window-function (lambda () t))
2489 (setq my/appt-notification-app (concat (getenv "HOME") "/bin/appt_notification"))
2491 (defun my/appt-display (min-to-app new-time msg)
2492 (if (atom min-to-app)
2493 (start-process "my/appt-notification-app" nil my/appt-notification-app min-to-app msg)
2494 (dolist (i (number-sequence 0 (1- (length min-to-app))))
2495 (start-process "my/appt-notification-app" nil my/appt-notification-app
2496 (nth i min-to-app) (nth i msg))))
2502 ** outshine (outlining) integration
2503 #+BEGIN_SRC emacs-lisp
2504 (use-package outshine
2506 :hook (outline-minor-mode . outshine-hook-function)
2510 #+BEGIN_SRC emacs-lisp
2514 ** Home/End Begining/End of line
2515 #+BEGIN_SRC emacs-lisp
2516 (global-set-key [home] 'move-beginning-of-line)
2517 (global-set-key [end] 'move-end-of-line)
2520 #+BEGIN_SRC emacs-lisp
2521 (global-unset-key "\M-g")
2522 (global-set-key (kbd "M-g l") 'goto-line)
2526 #+BEGIN_SRC emacs-lisp
2527 (use-package debian-changelog-mode
2528 :mode "debian/changelog"
2530 (setq debian-changelog-mailing-address "don@debian.org")
2531 (setq debian-changelog-full-name "Don Armstrong"))
2533 * Misc (uncharacterized)
2534 #+BEGIN_SRC emacs-lisp
2535 (setq calendar-latitude 38.6)
2536 (setq calendar-longitude -121.5)
2537 (setq case-fold-search t)
2538 (setq confirm-kill-emacs (quote y-or-n-p))
2542 #+BEGIN_SRC emacs-lisp
2543 (global-font-lock-mode 1)
2546 #+BEGIN_SRC emacs-lisp
2547 (setq ps-footer-font-size (quote (8 . 10)))
2548 (setq ps-header-font-size (quote (8 . 10)))
2549 (setq ps-header-title-font-size (quote (10 . 10)))
2550 (setq ps-line-number-color "blue")
2551 (setq ps-print-footer t)
2552 (setq ps-print-footer-frame nil)
2553 (setq ps-print-only-one-header t)
2555 ** Only single spacing on sentences
2556 #+BEGIN_SRC emacs-lisp
2557 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
2559 (setq sentence-end-double-space nil)
2560 ; enable matching parenthesis
2562 ** Display paren mode
2563 #+BEGIN_SRC emacs-lisp
2565 (setq show-paren-delay 0.2)
2569 #+BEGIN_SRC emacs-lisp
2570 (setq user-mail-address "don@donarmstrong.com")
2573 ** Use primary selection on unix machines
2574 #+BEGIN_SRC emacs-lisp
2575 ;; switch back to the old primary selection method
2576 (if (or (string-equal system-type "darwin")
2577 (string-equal system-type "windows")
2580 (setq select-enable-clipboard t)
2581 (setq select-enable-primary nil)
2584 (setq select-enable-clipboard nil)
2585 (setq select-enable-primary t)
2587 ; (setq mouse-drag-copy-region t)
2589 ;; tramp configuration
2590 (setq tramp-use-ssh-controlmaster-options nil)
2592 (setq-default c-indent-level 4)
2593 (setq-default c-brace-imaginary-offset 0)
2594 (setq-default c-brace-offset -4)
2595 (setq-default c-argdecl-indent 4)
2596 (setq-default c-label-offset -4)
2597 (setq-default c-continued-statement-offset 4)
2599 (setq-default indent-tabs-mode nil)
2600 (setq-default tab-width 4)
2602 (defun insert-date ()
2603 "Insert date at point."
2605 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
2606 (global-set-key "\C-[d" 'insert-date)
2608 (defun unfill-paragraph (arg)
2609 "Pull this whole paragraph up onto one line."
2611 (let ((fill-column 10000))
2612 (fill-paragraph arg))
2615 (column-number-mode t)
2618 ** Desktop-save-mode
2619 If the envvar EMACS_SERVER_NAME is set, consider this a separate
2620 emacs, and use a different desktop file to restore history
2621 #+BEGIN_SRC emacs-lisp
2622 (use-package desktop
2625 (setq desktop-base-file-name
2626 (convert-standard-filename
2628 (or (getenv "EMACS_SERVER_NAME")
2632 (setq desktop-base-lock-name
2633 (convert-standard-filename
2634 (concat desktop-base-file-name
2636 (setq desktop-auto-save-timeout 60)
2637 (setq desktop-restore-eager 5)
2638 (setq desktop-lazy-verbose nil)
2639 (desktop-save-mode 1)
2643 ** Misc (Uncharacterized)
2644 #+BEGIN_SRC emacs-lisp
2646 (put 'upcase-region 'disabled nil)
2647 (put 'downcase-region 'disabled nil)
2648 (put 'narrow-to-region 'disabled nil)
2650 ; Outline-minor-mode key map
2651 (define-prefix-command 'cm-map nil "Outline-")
2653 (define-key cm-map "q" 'outline-hide-sublevels) ; Hide everything but the top-level headings
2654 (define-key cm-map "t" 'outline-hide-body) ; Hide everything but headings (all body lines)
2655 (define-key cm-map "o" 'outline-hide-other) ; Hide other branches
2656 (define-key cm-map "c" 'outline-hide-entry) ; Hide this entry's body
2657 (define-key cm-map "l" 'outline-hide-leaves) ; Hide body lines in this entry and sub-entries
2658 (define-key cm-map "d" 'outline-hide-subtree) ; Hide everything in this entry and sub-entries
2660 (define-key cm-map "a" 'outline-show-all) ; Show (expand) everything
2661 (define-key cm-map "e" 'outline-show-entry) ; Show this heading's body
2662 (define-key cm-map "i" 'outline-show-children) ; Show this heading's immediate child sub-headings
2663 (define-key cm-map "k" 'outline-show-branches) ; Show all sub-headings under this heading
2664 (define-key cm-map "s" 'outline-show-subtree) ; Show (expand) everything in this heading & below
2666 (define-key cm-map "u" 'outline-up-heading) ; Up
2667 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
2668 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
2669 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
2670 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
2671 (global-set-key "\M-o" cm-map)
2672 ; fix up tmux xterm keys
2673 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
2674 (defun fix-up-tmux-keys ()
2675 "Fix up tmux xterm keys"
2678 (let ((x 2) (tkey ""))
2698 ;; ctrl + alt + shift
2700 (setq tkey "C-M-S-"))
2703 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
2704 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
2705 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
2706 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
2708 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
2710 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
2712 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
2714 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
2716 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2718 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2720 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
2722 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
2724 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
2726 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
2728 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
2730 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
2732 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
2734 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
2736 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
2738 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
2740 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
2742 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
2744 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
2746 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
2748 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
2750 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
2752 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
2754 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
2756 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
2758 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
2765 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
2767 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
2768 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
2769 (if (or (buffer-modified-p)
2770 (verify-visited-file-modtime)
2771 (< (* 8 1024 1024) (buffer-size))
2772 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
2774 (clear-visited-file-modtime)
2776 (ad-activate 'ask-user-about-supersession-threat)
2780 #+BEGIN_SRC emacs-lisp
2784 (or (getenv "EMACS_SERVER_NAME")
2786 (unless (server-running-p)
2787 ; (global-set-key "\C-xp" 'server-edit)
2792 #+BEGIN_SRC emacs-lisp
2793 (provide 'don-configuration)