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 "~/var/emacs/elpa"))
21 (normal-top-level-add-subdirs-to-load-path))
23 (add-to-list 'load-path '"~/lib/emacs_el/")
24 (let ((default-directory "~/lib/emacs_el/"))
25 (normal-top-level-add-subdirs-to-load-path))
26 (let ((default-directory "~/var/emacs/elpa"))
27 (normal-top-level-add-subdirs-to-load-path))
28 (setq package-user-dir "~/var/emacs/elpa")
30 * Initial startup stuff
31 ** Disable startup screen
32 #+BEGIN_SRC emacs-lisp
33 (setq inhibit-startup-screen t)
36 #+BEGIN_SRC emacs-lisp
37 ; (if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
38 (if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
39 (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
42 #+BEGIN_SRC emacs-lisp
43 (setq frame-resize-pixelwise t)
44 (add-to-list 'default-frame-alist '(fullscreen . maximixed))
47 ** package repositories and package manager
48 #+BEGIN_SRC emacs-lisp
49 (require 'use-package)
51 (add-to-list 'gnutls-trustfiles "/etc/ssl/ca-global/ca-certificates.crt")
52 (setq package-enable-at-startup nil)
53 (setq package--init-file-ensured t)
54 (setq package-user-dir "~/var/emacs/elpa")
55 (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
56 ("melpa" . "https://melpa.org/packages/")
57 ("org" . "http://orgmode.org/elpa/")))
58 (setq use-package-verbose (not (bound-and-true-p byte-compile-current-file)))
62 #+BEGIN_SRC emacs-lisp
65 :commands (paradox-upgrade-packages paradox-list-packages)
67 (setq paradox-execute-asynchronously t)
68 (setq paradox-github-token t) ; I don't want to be prompted about this integration
72 #+BEGIN_SRC emacs-lisp
73 ;; Set the custom file to /dev/null and don't bother to load it
74 (setq custom-file "/dev/null")
78 #+BEGIN_SRC emacs-lisp
79 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
80 ;; execute conditional code when loading libraries
81 ; (defmacro with-library (symbol &rest body)
82 ; `(when (require ,symbol nil t)
84 ; (put 'with-library 'lisp-indent-function 1)
88 ** Safe Local Variables
89 #+BEGIN_SRC emacs-lisp
90 (setq safe-local-variable-values
91 (quote ((auto-save-default)
93 (cperl-indent-level . 4)
95 (indent-tabs-mode . f)
96 (vcl-indent-level . 4)
100 #+BEGIN_SRC emacs-lisp
101 (setq global-mark-ring-max 128
105 (defun don/minibuffer-setup-hook ()
106 (setq gc-cons-threshold most-positive-fixnum))
108 (defun don/minibuffer-exit-hook ()
109 (setq gc-cons-threshold 1048576))
111 (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
112 (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
116 #+BEGIN_SRC emacs-lisp
117 (use-package spacemacs-common
118 :ensure spacemacs-theme
120 (load-theme 'spacemacs-dark t)
124 #+BEGIN_SRC emacs-lisp
125 (use-package hippie-exp
126 :bind* (("M-<SPC>" . hippie-expand))
130 #+BEGIN_SRC emacs-lisp
131 (use-package flyspell
133 :delight flyspell-mode 🐝
135 (add-hook 'text-mode-hook 'turn-on-flyspell)
136 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
137 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
138 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
140 (setq ispell-program-name "ispell")
146 #+begin_src emacs-lisp :tangle yes
147 (use-package flycheck
150 :if (version<= "24.4" emacs-version)
151 :commands flycheck-mode
152 :hook ((prog-mode . flycheck-mode)
156 (use-package flycheck-tip
158 :commands 'flycheck-tip-cycle
160 :bind (:map flycheck-mode-map
161 ("C-c C-n" . flycheck-tip-cycle)))
163 (use-package flycheck-package
166 (use-package flycheck-checkpatch
168 :config (flycheck-checkpatch-setup)
169 :config (setq flycheck-checkers (delete 'checkpatch
171 :config (add-to-list 'flycheck-checkers 'checkpatch t))
175 #+begin_src emacs-lisp :tangle yes
181 #+BEGIN_SRC emacs-lisp
186 #+BEGIN_SRC emacs-lisp
187 (use-package eyebrowse
189 :delight eyebrowse-mode
190 :init (setq eyebrowse-keymap-prefix (kbd "C-c e"))
192 (setq eyebrowse-wrap-around t)
195 (defun my/eyebrowse-new-window-config ()
199 ;; start at 1 run till 0
200 (let ((j (mod (+ i 1) 10)))
201 (when (and (not done)
202 (not (eyebrowse--window-config-present-p j)))
203 (eyebrowse-switch-to-window-config j)
204 (call-interactively 'eyebrowse-rename-window-config2 j)
209 ;; I don't use latex-preview-pane
210 ;; (require 'latex-preview-pane)
211 ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
212 ;; ;; latex-preview-pane uses window-parameters which are
213 ;; ;; not preserved by eyebrowse, so we close the preview
214 ;; ;; pane before switching, it will be regenerated when we
215 ;; ;; edit the TeX file.
216 ;; (when (lpp/window-containing-preview)
217 ;; (delete-window (lpp/window-containing-preview))))
219 ;; (add-to-list 'eyebrowse-pre-window-switch-hook
220 ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
222 ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
223 ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
224 ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
225 ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
226 ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
234 #+BEGIN_SRC emacs-lisp
235 (defun my/vsplit-last-buffer ()
236 "Split the window vertically and display the previous buffer."
238 (split-window-vertically)
240 (switch-to-next-buffer))
242 (defun my/hsplit-last-buffer ()
243 "Split the window horizontally and display the previous buffer."
245 (split-window-horizontally)
247 (switch-to-next-buffer))
249 (bind-key "C-x 2" 'my/vsplit-last-buffer)
250 (bind-key "C-x 3" 'my/hsplit-last-buffer)
252 (setq split-width-threshold 100)
253 (setq split-height-threshold 60)
255 (defun my/split-window-prefer-vertically (window)
256 "If there's only one window (excluding any possibly active
257 minibuffer), then split the current window horizontally."
258 (if (and (one-window-p t)
259 (not (active-minibuffer-window))
260 ( < (frame-width) (frame-height))
262 (let ((split-width-threshold nil))
263 (split-window-sensibly window))
264 (split-window-sensibly window)))
266 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
267 (setq window-combination-resize t)
270 *** Compilation window
272 If there is no compilation window, open one at the bottom, spanning
273 the complete width of the frame. Otherwise, reuse existing window. In
274 the former case, if there was no error the window closes
277 #+BEGIN_SRC emacs-lisp
278 (add-to-list 'display-buffer-alist
279 `(,(rx bos "*compilation*" eos)
280 (display-buffer-reuse-window
281 display-buffer-in-side-window)
282 (reusable-frames . visible)
284 (window-height . 0.4)))
287 #+BEGIN_SRC emacs-lisp
288 (defun my/compilation-exit-autoclose (status code msg)
289 ;; If M-x compile exists with a 0
290 (when (and (eq status 'exit) (zerop code))
291 ;; and delete the *compilation* window
292 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
293 (when (and (not (window-at-side-p compilation-window 'top))
294 (window-at-side-p compilation-window 'left)
295 (window-at-side-p compilation-window 'right))
296 (delete-window compilation-window))))
297 ;; Always return the anticipated result of compilation-exit-message-function
300 ;; Specify my function (maybe I should have done a lambda function)
301 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
304 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
305 value, the compilation buffer scrolls automatically to follow the
306 output. If the value is ~first-error~, scrolling stops when the first
307 error appears, leaving point at that error. For any other non-nil
308 value, scrolling continues until there is no more output.
310 #+BEGIN_SRC emacs-lisp
311 (setq compilation-scroll-output 'first-error)
314 ** Mode line cleaning
316 #+BEGIN_SRC emacs-lisp
322 #+BEGIN_SRC emacs-lisp
329 #+BEGIN_SRC emacs-lisp
331 :if (>= emacs-major-version 25)
333 :bind (("C-c C-<SPC>" . avy-goto-word-or-subword-1)
334 ("C-c j j" . avy-goto-word-or-subword-1)
335 ("M-g g" . avy-goto-line))
336 :config (progn (setq avy-background t))
339 *** Ace-link (jumping to links)
340 #+BEGIN_SRC emacs-lisp
341 (use-package ace-link
343 ; bind o in most modes
344 :config (ace-link-setup-default))
346 *** Jumping through edit points (goto-chg)
347 #+BEGIN_SRC emacs-lisp
348 (use-package goto-chg
350 :bind (("C-c j ," . goto-last-change)
351 ("C-c j ." . goto-last-change-reverse))
354 *** Jumping to bookmarks (visible bookmarks, bm)
355 #+BEGIN_SRC emacs-lisp
358 :bind (("C-c j b ." . bm-next)
359 ("C-c j b ," . bm-previous)
360 ("C-c j b SPC" . bm-toggle)))
365 #+BEGIN_SRC emacs-lisp
366 (use-package yasnippet
368 :delight yas-minor-mode
371 (setq yas-verbosity 1)
372 (define-key yas-minor-mode-map (kbd "<tab>") nil)
373 (define-key yas-minor-mode-map (kbd "TAB") nil)
374 (define-key yas-minor-mode-map (kbd "<backtab>") nil)
375 (setq yas-snippet-dirs '("~/lib/emacs_el/snippets/"
376 "~/lib/emacs_el/yasnippet-snippets/snippets/"))
377 (add-to-list 'hippie-expand-try-functions-list
378 'yas-hippie-try-expand)
384 #+BEGIN_SRC emacs-lisp
385 (use-package auto-yasnippet
387 :bind (("H-w" . aya-create)
392 ** Treemacs: Tree file viewer
393 #+BEGIN_SRC emacs-lisp
394 ;; Provides workspaces with file browsing (tree file viewer)
395 ;; and project management when coupled with `projectile`.
397 (use-package treemacs
401 (setq treemacs-no-png-images t
403 :bind ("C-c t" . treemacs))
406 #+BEGIN_SRC emacs-lisp
407 (use-package lsp-mode
410 :commands (lsp lsp-deferred)
411 :init (setq lsp-keymap-prefix "C-c l")
412 :hook (python-mode . lsp-deferred))
413 ;; Provides visual help in the buffer
414 ;; For example definitions on hover.
415 ;; The `imenu` lets me browse definitions quickly.
420 (setq lsp-ui-sideline-enable nil
422 :hook (lsp-mode . lsp-ui-mode)
423 :bind (:map lsp-ui-mode-map
424 ("C-c i" . lsp-ui-imenu)))
425 ;; Language server for Python
426 ;; Read the docs for the different variables set in the config.
427 (use-package lsp-pyright
431 (setq lsp-clients-python-library-directories '("/usr/" "~/miniconda3/pkgs"))
432 (setq lsp-pyright-disable-language-service nil
433 lsp-pyright-disable-organize-imports nil
434 lsp-pyright-auto-import-completions t
435 lsp-pyright-use-library-code-for-types t
436 lsp-pyright-venv-path "~/miniconda3/envs")
437 :hook ((python-mode . (lambda ()
438 (require 'lsp-pyright) (lsp-deferred)))))
441 #+BEGIN_SRC emacs-lisp
444 :bind (("M-/" . company-complete))
446 (setq company-echo-delay 0 ; remove blinking
447 company-show-numbers t ; show numbers for easy selection
448 company-selection-wrap-around t
449 company-require-match nil
450 company-dabbrev-ignore-case t
451 company-dabbrev-ignore-invisible t
452 company-dabbrev-other-buffers t
453 company-dabbrev-downcase nil
454 company-dabbrev-code-everywhere t
455 company-tooltip-align-annotations t
456 company-minimum-prefix-length 1
457 company-global-modes '(not)
458 company-lighter-base "(C)")
459 (setq company-backends '(company-capf
466 company-irony-c-headers
472 (global-company-mode 1)
473 :bind (:map company-active-map
474 ("C-n" . company-select-next)
475 ("C-p" . company-select-previous)
476 ("M-?" . company-show-doc-buffer)
477 ("M-." . company-show-location)
482 #+BEGIN_SRC emacs-lisp
483 (use-package company-c-headers
486 (defun malb/ede-object-system-include-path ()
487 "Return the system include path for the current buffer."
489 (ede-system-include-path ede-object)))
491 (setq company-c-headers-path-system
492 #'malb/ede-object-system-include-path)))
495 #+BEGIN_SRC emacs-lisp
496 (use-package company-jedi
498 :hook (python-mode . 'jedi:setup)
500 (setq jedi:complete-on-dot t)
504 #+BEGIN_SRC emacs-lisp
505 (use-package company-plsense
510 #+BEGIN_SRC emacs-lisp
511 (use-package company-math
514 #+BEGIN_SRC emacs-lisp
515 (use-package company-auctex
518 (defun company-auctex-labels (command &optional arg &rest ignored)
519 "company-auctex-labels backend"
520 (interactive (list 'interactive))
522 (interactive (company-begin-backend 'company-auctex-labels))
523 (prefix (company-auctex-prefix "\\\\.*ref{\\([^}]*\\)\\="))
524 (candidates (company-auctex-label-candidates arg))))
526 (add-to-list 'company-backends
527 '(company-auctex-macros
528 company-auctex-environments
529 company-math-symbols-unicode
530 company-math-symbols-latex))
532 (add-to-list 'company-backends #'company-auctex-labels)
533 (add-to-list 'company-backends #'company-auctex-bibs)
538 #+BEGIN_SRC emacs-lisp
539 (use-package company-bibtex
545 #+BEGIN_SRC emacs-lisp
546 (use-package company-shell
549 (setq company-shell-modes '(sh-mode shell-mode))
550 (add-to-list 'company-backends 'company-shell)))
555 Add YasSippet support for all company backends. ([[https://github.com/syl20bnr/spacemacs/pull/179][source]])
557 *Note:* Do this at the end of =company-mode= config.
559 #+BEGIN_SRC emacs-lisp
560 (defvar malb/company-mode/enable-yas t
561 "Enable yasnippet for all backends.")
563 (defun malb/company-mode/backend-with-yas (backend)
564 (if (or (not malb/company-mode/enable-yas)
566 (member 'company-yasnippet backend)))
568 (append (if (consp backend) backend (list backend))
569 '(:with company-yasnippet))))
571 (setq company-backends
572 (mapcar #'malb/company-mode/backend-with-yas company-backends))
577 Enable/disable company completion from ispell dictionaries ([[https://github.com/redguardtoo/emacs.d/blob/master/lisp/init-company.el][source]])
579 #+BEGIN_SRC emacs-lisp
580 (defun malb/toggle-company-ispell ()
583 ((member '(company-ispell :with company-yasnippet) company-backends)
584 (setq company-backends (delete '(company-ispell :with company-yasnippet) company-backends))
585 (add-to-list 'company-backends '(company-dabbrev :with company-yasnippet) t)
586 (message "company-ispell disabled"))
588 (setq company-backends (delete '(company-dabbrev :with company-yasnippet) company-backends))
589 (add-to-list 'company-backends '(company-ispell :with company-yasnippet) t)
590 (message "company-ispell enabled!"))))
592 (defun malb/company-ispell-setup ()
593 ;; @see https://github.com/company-mode/company-mode/issues/50
594 (when (boundp 'company-backends)
595 (make-local-variable 'company-backends)
596 (setq company-backends (delete '(company-dabbrev :with company-yasnippet) company-backends))
597 (add-to-list 'company-backends '(company-ispell :with company-yasnippet) t)
598 ;; https://github.com/redguardtoo/emacs.d/issues/473
599 (if (and (boundp 'ispell-alternate-dictionary)
600 ispell-alternate-dictionary)
601 (setq company-ispell-dictionary ispell-alternate-dictionary))))
606 1. =yas-expand= is run first and does what it has to, then it calls =malb/indent-fold-or-complete=.
608 2. This function then hopefully does what I want:
610 a. if a region is active, just indent
611 b. if we’re looking at a space after a non-whitespace character, we try some company-expansion
612 c. If =hs-minor-mode= or =outline-minor-mode= is active, try those next
613 d. otherwise call whatever would have been called otherwise.
615 ([[http://emacs.stackexchange.com/q/21182/8930][source]], [[http://emacs.stackexchange.com/q/7908/8930][source]])
617 #+BEGIN_SRC emacs-lisp
618 (defun malb/indent-fold-or-complete (&optional arg)
621 ;; if a region is active, indent
623 (indent-region (region-beginning)
625 ;; if the next char is space or eol, but prev char not whitespace
626 ((and (not (active-minibuffer-window))
629 (looking-back "[^[:space:]]")
630 (not (looking-back "^")))
632 (cond (company-mode (company-complete-common))
633 (auto-complete-mode (auto-complete))))
635 ;; no whitespace anywhere
636 ((and (not (active-minibuffer-window))
637 (looking-at "[^[:space:]]")
638 (looking-back "[^[:space:]]")
639 (not (looking-back "^")))
641 ((bound-and-true-p hs-minor-mode)
642 (save-excursion (end-of-line) (hs-toggle-hiding)))
643 ((bound-and-true-p outline-minor-mode)
644 (save-excursion (outline-cycle)))))
646 ;; by default just call whatever was bound
648 (let ((fn (or (if (current-local-map) (lookup-key (current-local-map) (kbd "TAB")))
649 'indent-for-tab-command)))
650 (if (not (called-interactively-p 'any))
652 (setq this-command fn)
653 (call-interactively fn))))))
655 (defun malb/toggle-fold ()
657 (cond ((eq major-mode 'org-mode)
658 (org-force-cycle-archived))
659 ((bound-and-true-p hs-minor-mode)
664 ((bound-and-true-p outline-minor-mode)
668 (bind-key "<tab>" #'malb/indent-fold-or-complete)
669 (bind-key "C-<tab>" #'malb/toggle-fold)
673 #+BEGIN_SRC emacs-lisp
675 (use-package tinyprocmail
676 :load-path "~/lib/emacs_el/tiny-tools/lisp/tiny"
677 :mode (".procmailrc" . turn-on-tinyprocmail-mode)
682 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
685 :bind (("C-x g" . magit-status)
686 ("C-x C-g" . magit-status))
688 ;; refine diffs always (hilight words)
689 (setq magit-diff-refine-hunk nil)
691 (use-package magit-annex
693 :load-path "~/lib/emacs_el/magit-annex/"
695 (use-package magit-vcsh
700 *** Forge (github/gitlab)
701 #+BEGIN_SRC emacs-lisp
709 #+BEGIN_SRC emacs-lisp
710 (use-package cperl-mode
714 ;; Use c-mode for perl .xs files
715 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
716 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
717 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
718 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
719 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
722 cperl-auto-newline nil
723 cperl-auto-newline-after-colon nil
724 cperl-continued-statement-offset 4
725 cperl-brace-offset -1
726 cperl-continued-brace-offset 0
727 cperl-label-offset -4
728 cperl-highlight-variables-indiscriminately t
729 cperl-electric-lbrace-space nil
730 cperl-indent-parens-as-block nil
731 cperl-close-paren-offset -1
732 cperl-tab-always-indent t)
733 ;;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
738 #+BEGIN_SRC emacs-lisp
739 (use-package markdown-mode
741 :mode (("\\.md\\'" . markdown-mode)
742 ("\\.mdwn\\'" . markdown-mode)
743 ("README\\.md\\'" . gfm-mode)
746 (setq markdown-enable-math t)
747 (setq markdown-follow-wiki-link-on-enter nil)
748 (bind-key "M-." #'markdown-jump markdown-mode-map)
749 (add-hook 'markdown-mode-hook #'flyspell-mode)
750 (add-hook 'markdown-mode-hook #'outline-minor-mode)
751 (bind-key "C-<tab>" #'outline-cycle markdown-mode-map)
756 #+BEGIN_SRC emacs-lisp
757 ; load sql-indent when sql is loaded
758 (use-package sql-indent
764 :mode (("\\.sql\\'" . sql-mode))
768 #+BEGIN_SRC emacs-lisp
770 :commands ediff ediff3
773 ;; ediff configuration
774 ;; don't use the multi-window configuration
775 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
778 ** Do the Right Thing Indenting
779 Attempts to automatically identify the right indentation for a file
780 #+BEGIN_SRC emacs-lisp
781 (use-package dtrt-indent
785 ** VCL --editing varnish configuration files
786 #+BEGIN_SRC emacs-lisp
787 (use-package vcl-mode
794 #+BEGIN_SRC emacs-lisp
800 ;; Different scroll margin
801 ;; (setq vertico-scroll-margin 0)
803 ;; Show more candidates
804 ;; (setq vertico-count 20)
806 ;; Grow and shrink the Vertico minibuffer
807 ;; (setq vertico-resize t)
809 ;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
810 ;; (setq vertico-cycle t)
812 (define-key vertico-map "\r" #'vertico-directory-enter)
813 (define-key vertico-map "\d" #'vertico-directory-delete-char)
814 (define-key vertico-map "\M-\d" #'vertico-directory-delete-word)
815 (add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy
818 ;; Persist history over Emacs restarts. Vertico sorts by history position.
819 (use-package savehist
825 ** Orderless: advanced completion style
826 #+begin_src emacs-lisp
827 (use-package orderless
830 ;; Configure a custom style dispatcher (see the Consult wiki)
831 ;; (setq orderless-style-dispatchers '(+orderless-dispatch)
832 ;; orderless-component-separator #'orderless-escapable-split-on-space)
833 (setq completion-styles '(orderless basic)
834 completion-category-defaults nil
835 completion-category-overrides '((file (styles partial-completion)))))
837 ** Marginalia: Rich annotations in the minibuffer
838 #+begin_src emacs-lisp
839 (use-package marginalia
841 :bind (("M-A" . marginalia-cycle)
842 :map minibuffer-local-map
843 ("M-A" . marginalia-cycle))
848 ** Embark: Minibuffer actions and context menu
849 #+begin_src emacs-lisp
854 (("C-." . embark-act) ;; pick some comfortable binding
855 ("C-;" . embark-dwim) ;; good alternative: M-.
856 ("C-h B" . embark-bindings)) ;; alternative for `describe-bindings'
860 ;; Optionally replace the key help with a completing-read interface
861 (setq prefix-help-command #'embark-prefix-help-command)
865 ;; Hide the mode line of the Embark live/completions buffers
866 (add-to-list 'display-buffer-alist
867 '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
869 (window-parameters (mode-line-format . none)))))
871 (use-package embark-consult
874 (embark-collect-mode . consult-preview-at-point-mode))
877 #+begin_src emacs-lisp
879 ;; Replace bindings. Lazily loaded due by `use-package'.
880 :bind (;; C-c bindings (mode-specific-map)
881 ("C-c h" . consult-history)
882 ("C-c m" . consult-mode-command)
883 ("C-c k" . consult-kmacro)
884 ;; C-x bindings (ctl-x-map)
885 ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command
886 ("C-x b" . consult-buffer) ;; orig. switch-to-buffer
887 ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
888 ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame
889 ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
890 ; ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer
891 ;; Custom M-# bindings for fast register access
892 ("M-#" . consult-register-load)
893 ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated)
894 ("C-M-#" . consult-register)
895 ;; Other custom bindings
896 ("M-y" . consult-yank-pop) ;; orig. yank-pop
897 ;; M-g bindings (goto-map)
898 ("M-g e" . consult-compile-error)
899 ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck
900 ("M-g g" . consult-goto-line) ;; orig. goto-line
901 ("M-g M-g" . consult-goto-line) ;; orig. goto-line
902 ("M-g o" . consult-outline) ;; Alternative: consult-org-heading
903 ("M-g m" . consult-mark)
904 ("M-g k" . consult-global-mark)
905 ("M-g i" . consult-imenu)
906 ("M-g I" . consult-imenu-multi)
907 ;; M-s bindings (search-map)
908 ("M-s d" . consult-find)
909 ("M-s D" . consult-locate)
910 ("M-s g" . consult-grep)
911 ("M-s G" . consult-git-grep)
912 ("M-s r" . consult-ripgrep)
913 ("M-s l" . consult-line)
914 ("M-s L" . consult-line-multi)
915 ("M-s k" . consult-keep-lines)
916 ("M-s u" . consult-focus-lines)
917 ;; Isearch integration
918 ("M-s e" . consult-isearch-history)
919 :map isearch-mode-map
920 ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string
921 ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string
922 ("M-s l" . consult-line) ;; needed by consult-line to detect isearch
923 ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch
924 ;; Minibuffer history
925 :map minibuffer-local-map
926 ("M-s" . consult-history) ;; orig. next-matching-history-element
927 ("M-r" . consult-history)) ;; orig. previous-matching-history-element
929 ;; Enable automatic preview at point in the *Completions* buffer. This is
930 ;; relevant when you use the default completion UI.
931 :hook (completion-list-mode . consult-preview-at-point-mode)
933 ;; The :init configuration is always executed (Not lazy)
936 ;; Optionally configure the register formatting. This improves the register
937 ;; preview for `consult-register', `consult-register-load',
938 ;; `consult-register-store' and the Emacs built-ins.
939 (setq register-preview-delay 0.5
940 register-preview-function #'consult-register-format)
942 ;; Optionally tweak the register preview window.
943 ;; This adds thin lines, sorting and hides the mode line of the window.
944 (advice-add #'register-preview :override #'consult-register-window)
946 ;; Use Consult to select xref locations with preview
947 (setq xref-show-xrefs-function #'consult-xref
948 xref-show-definitions-function #'consult-xref)
950 ;; Configure other variables and modes in the :config section,
951 ;; after lazily loading the package.
954 ;; Optionally configure preview. The default value
955 ;; is 'any, such that any key triggers the preview.
956 ;; (setq consult-preview-key 'any)
957 ;; (setq consult-preview-key (kbd "M-."))
958 ;; (setq consult-preview-key (list (kbd "<S-down>") (kbd "<S-up>")))
959 ;; For some commands and buffer sources it is useful to configure the
960 ;; :preview-key on a per-command basis using the `consult-customize' macro.
962 consult-theme :preview-key '(:debounce 0.2 any)
963 consult-ripgrep consult-git-grep consult-grep
964 consult-bookmark consult-recent-file consult-xref
965 consult--source-bookmark consult--source-file-register
966 consult--source-recent-file consult--source-project-recent-file
967 ;; :preview-key (kbd "M-.")
968 :preview-key '(:debounce 0.4 any))
970 ;; Optionally configure the narrowing key.
971 ;; Both < and C-+ work reasonably well.
972 (setq consult-narrow-key "<") ;; (kbd "C-+")
974 ;; Optionally make narrowing help available in the minibuffer.
975 ;; You may want to use `embark-prefix-help-command' or which-key instead.
976 ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)
978 ;; By default `consult-project-function' uses `project-root' from project.el.
979 ;; Optionally configure a different project root function.
980 ;; There are multiple reasonable alternatives to chose from.
981 ;;;; 1. project.el (the default)
982 ;; (setq consult-project-function #'consult--default-project--function)
983 ;;;; 2. projectile.el (projectile-project-root)
984 ;; (autoload 'projectile-project-root "projectile")
985 ;; (setq consult-project-function (lambda (_) (projectile-project-root)))
986 ;;;; 3. vc.el (vc-root-dir)
987 ;; (setq consult-project-function (lambda (_) (vc-root-dir)))
988 ;;;; 4. locate-dominating-file
989 ;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git")))
992 ** Projectile -- Project management
993 #+begin_src emacs-lisp
994 (use-package projectile
996 :bind (("<f5>" . projectile-compile-project)
997 ("<f6>" . next-error))
999 (use-package magit :ensure t)
1000 (projectile-global-mode)))
1004 #+BEGIN_SRC emacs-lisp
1005 (use-package avy-zap
1007 :bind ("M-z" . avy-zap-up-to-char-dwim))
1010 #+BEGIN_SRC emacs-lisp
1012 :bind (("C-c 2" . my/hydra-orgmodes/body)
1013 ("C-c @" . my/hydra-orgmodes/body)
1014 ("C-c #" . my/hydra-outline/body)
1015 ("C-c 3" . my/hydra-outline/body)
1018 (defhydra my/hydra-orgmodes (:color blue :hint nil)
1020 _n_: notes _c_: chaim _w_: wildman _o_: ool
1021 _u_: uddin _s_: steve _r_: refile _f_: fh
1022 _p_: read papers _R_: paper notes
1027 ("n" (find-file "~/projects/org-notes/notes.org"))
1028 ("c" (find-file "~/projects/org-notes/chaim.org"))
1029 ("w" (find-file "~/projects/org-notes/wildman.org"))
1030 ("u" (find-file "~/projects/org-notes/uddin.org"))
1031 ("o" (find-file "~/projects/org-notes/ool.org"))
1032 ("f" (find-file "~/projects/org-notes/fh.org"))
1033 ("s" (find-file "~/projects/org-notes/sndservers.org"))
1034 ("r" (find-file my/org-refile-file))
1035 ("p" (find-file "~/projects/research/papers_to_read.org"))
1036 ("R" (find-file "~/projects/research/paper_notes.org"))
1037 ("h" (find-file "~/projects/org-notes/hpcbio.org"))
1042 ;; from https://github.com/abo-abo/hydra/wiki/Emacs
1043 (defhydra my/hydra-outline (:color pink :hint nil)
1046 ^^^^^^------------------------------------------------------
1047 _q_: sublevels _a_: all _u_: up
1048 _t_: body _e_: entry _n_: next visible
1049 _o_: other _i_: children _p_: previous visible
1050 _c_: entry _k_: branches _f_: forward same level
1051 _l_: leaves _s_: subtree _b_: backward same level
1056 ("q" outline-hide-sublevels) ; Hide everything but the top-level headings
1057 ("t" outline-hide-body) ; Hide everything but headings (all body lines)
1058 ("o" outline-hide-other) ; Hide other branches
1059 ("c" outline-hide-entry) ; Hide this entry's body
1060 ("l" outline-hide-leaves) ; Hide body lines in this entry and sub-entries
1061 ("d" outline-hide-subtree) ; Hide everything in this entry and sub-entries
1063 ("a" outline-show-all) ; Show (expand) everything
1064 ("e" outline-show-entry) ; Show this heading's body
1065 ("i" outline-show-children) ; Show this heading's immediate child sub-headings
1066 ("k" outline-show-branches) ; Show all sub-headings under this heading
1067 ("s" outline-show-subtree) ; Show (expand) everything in this heading & below
1069 ("u" outline-up-heading) ; Up
1070 ("n" outline-next-visible-heading) ; Next
1071 ("p" outline-previous-visible-heading) ; Previous
1072 ("f" outline-forward-same-level) ; Forward - same level
1073 ("b" outline-backward-same-level) ; Backward - same level
1079 #+BEGIN_SRC emacs-lisp
1082 (add-to-list 'tramp-methods '("vcsh"
1083 (tramp-login-program "vcsh")
1087 (tramp-remote-shell "/bin/sh")
1088 (tramp-remote-shell-args
1092 #+BEGIN_SRC emacs-lisp
1096 (setq-default reftex-default-bibliography
1097 '("~/projects/research/references.bib")))
1100 #+BEGIN_SRC emacs-lisp
1102 :config (setq bibtex-user-optional-fields
1103 (quote (("annote" "Personal annotation (ignored)")
1111 #+BEGIN_SRC emacs-lisp
1116 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
1117 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
1118 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
1119 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
1120 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
1121 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
1122 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
1123 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
1124 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
1125 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
1126 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
1128 (setq-default reftex-plug-into-AUCTeX t)
1129 ;; support fake section headers
1130 (setq TeX-outline-extra
1134 ("%subsubsection" 4)
1136 ;; add font locking to the headers
1137 (font-lock-add-keywords
1139 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
1140 0 'font-lock-keyword-face t)
1141 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
1142 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
1143 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
1144 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
1145 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
1147 ;; use smart quotes by default instead of `` and ''
1148 ;; taken from http://kieranhealy.org/esk/kjhealy.html
1149 (setq TeX-open-quote "“")
1150 (setq TeX-close-quote "”")
1152 ;; (TeX-add-style-hook
1157 ;; (custom-set-variables
1158 ;; '(font-latex-user-keyword-classes
1161 ;; font-lock-function-name-face 2 (command 1 t))))
1163 (setq-default TeX-parse-self t)
1164 (setq-default TeX-auto-save t)
1165 (setq-default TeX-master nil)
1166 (add-to-list 'LaTeX-font-list
1167 '(?\C-a "\\alert{","}"))
1170 '(TeX-add-style-hook
1173 (if (boundp 'reftex-ref-style-alist)
1175 'reftex-ref-style-alist
1176 '("Cleveref" "cleveref"
1177 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
1178 (reftex-ref-style-activate "Cleveref")
1180 '("cref" TeX-arg-ref)
1181 '("Cref" TeX-arg-ref)
1182 '("cpageref" TeX-arg-ref)
1183 '("Cpageref" TeX-arg-ref)))))
1186 '(add-to-list 'LaTeX-fill-excluded-macros
1189 (use-package font-latex
1191 (setq font-latex-match-reference-keywords
1213 (setq font-latex-fontify-script nil)
1214 (setq font-latex-fontify-sectioning (quote color))
1215 (setq font-latex-script-display (quote (nil)))
1220 #+BEGIN_SRC emacs-lisp
1224 :mode ("\\.R\\'" . ess-r-mode)
1225 :bind (:map ess-mode-map
1226 ("C-c C-R" . dla/ess-region-remote-eval))
1228 (autoload 'ess-r-mode "ess-site" nil t)
1229 (autoload 'R "ess-site" nil t)
1231 ; actually load the rest of ess
1233 (defun ess-change-directory (path)
1234 "Set the current working directory to PATH for both *R* and Emacs."
1235 (interactive "Directory to change to: ")
1237 (when (file-exists-p path)
1238 (ess-command (concat "setwd(\"" path "\")\n"))
1239 ;; use file-name-as-directory to ensure it has trailing /
1240 (setq default-directory (file-name-as-directory path))))
1241 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
1242 ;; outlining support for ess modes
1246 (outline-minor-mode)
1247 (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
1248 (defun outline-level ()
1249 (cond ((looking-at "^##### ") 1)
1250 ((looking-at "^#### ") 2)
1251 ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
1254 (defun dla/ess-region-remote-eval (start end)
1255 "Evaluate region in a remote ESS instance"
1257 (shell-command-on-region start end "eval_r" (get-buffer-create "***essregionremoteeval***") nil nil nil)
1258 (kill-buffer "***essregionremoteeval***"))
1259 ;; Don't restore history or save workspace image
1260 '(inferior-R-args "--no-restore-history --no-save")
1265 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
1267 #+BEGIN_SRC emacs-lisp
1268 (use-package rainbow-mode
1269 ;; add ess to the x major mode
1270 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
1271 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
1276 #+BEGIN_SRC emacs-lisp
1277 (use-package yaml-mode
1278 ;; add ess to the x major mode
1279 :mode ("\\.\\(yaml|yml\\)\\'" . yaml-mode)
1284 #+BEGIN_SRC emacs-lisp
1285 (use-package poly-noweb
1290 (use-package poly-markdown
1296 :after (:all polymode poly-markdown poly-noweb)
1297 ; :mode ("\\.Snw" . poly-noweb+r-mode)
1298 ; :mode ("\\.Rnw" . poly-noweb+r-mode)
1299 ; :mode ("\\.Rmd" . poly-markdown+r-mode)
1301 (use-package polymode
1309 #+BEGIN_SRC emacs-lisp
1310 ; this package doesn't really do exactly what we want it to do
1311 ; (use-package outline-magic)
1314 #+BEGIN_SRC emacs-lisp
1315 ;; change the outline mode prefix from C-c @ to C-c C-2
1316 (setq outline-minor-mode-prefix "C-c C-2")
1317 ;;(add-hook 'outline-minor-mode-hook
1318 ;; (lambda () (local-set-key (kbd "C-c C-2")
1319 ;; outline-mode-prefix-map)))
1323 #+BEGIN_SRC emacs-lisp
1324 (use-package writeroom-mode
1326 (defun my/writing-mode ()
1327 "Start my writing mode; enable visual-line-mode and auto-fill-mode"
1332 (visual-line-mode -1)
1334 (visual-fill-column-mode -1)
1336 (visual-line-mode 1)
1338 (visual-fill-column-mode 1)
1343 ** GhostText/Atomic Chrome
1344 #+BEGIN_SRC emacs-lisp
1345 (use-package atomic-chrome
1347 (ignore-errors (atomic-chrome-start-server))
1348 (setq atomic-chrome-buffer-open-style 'full)
1352 #+BEGIN_SRC emacs-lisp
1353 (use-package edit-server
1355 :commands edit-server-start
1356 :init (if after-init-time
1358 (add-hook 'after-init-hook
1359 #'(lambda() (edit-server-start))))
1360 :config (setq edit-server-new-frame-alist
1361 '((name . "Edit with Emacs FRAME")
1367 (menu-bar-lines . t)
1368 (window-system . x)))
1372 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
1373 #+BEGIN_SRC emacs-lisp
1374 (use-package multiple-cursors
1375 :bind* (("C-;" . mc/mark-all-dwim)
1376 ("C-<" . mc/mark-previous-like-this)
1377 ("C->" . mc/mark-next-like-this)
1378 ("C-S-c C-S-c" . mc/edit-lines))
1382 #+BEGIN_SRC emacs-lisp
1383 (use-package web-mode
1384 :load-path "/home/don/projects/web-mode/"
1385 :mode ("\\.\\(tx|tmpl\\)\\'" . web-mode)
1387 (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . web-mode))
1388 (setq web-mode-enable-engine-detection t)
1389 (setq web-mode-engines-alist
1390 '(("template-toolkit" . "\\.tmpl\\'")))
1393 ** Spamassassin Mode
1394 #+BEGIN_SRC emacs-lisp
1395 (use-package spamassassin-mode
1396 :commands spamassassin-mode
1401 #+BEGIN_SRC emacs-lisp
1402 (use-package password-store
1404 :commands password-store-edit password-store-generate
1408 #+BEGIN_SRC emacs-lisp
1412 ;; fix up css mode to not be silly
1413 ;; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
1414 (setq cssm-indent-level 4)
1415 (setq cssm-newline-before-closing-bracket t)
1416 (setq cssm-indent-function #'cssm-c-style-indenter)
1417 (setq cssm-mirror-mode nil))
1420 #+BEGIN_SRC emacs-lisp
1422 :delight abbrev-mode
1424 ;; load abbreviations from
1425 (setq abbrev-file-name
1426 "~/.emacs_abbrev_def")
1428 ;; read the abbrev file if it exists
1429 (if (file-exists-p abbrev-file-name)
1430 (quietly-read-abbrev-file))
1432 ;; for now, use abbrev mode everywhere
1433 (setq default-abbrev-mode t))
1436 ** Debugging (realgud)
1437 #+BEGIN_SRC emacs-lisp
1438 (use-package realgud
1442 ** Python Programming
1443 #+BEGIN_SRC emacs-lisp
1444 (use-package python-mode
1447 (python-mode . pyenv-mode)
1448 (python-mode . flycheck-mode)
1449 (python-mode . company-mode)
1450 (python-mode . blacken-mode)
1451 (python-mode . yas-minor-mode)
1452 (python-mode . anaconda-mode)
1457 (use-package blacken
1460 (setq-default blacken-fast-unsafe t)
1461 ; (setq-default blacken-line-length 80)
1463 (use-package anaconda-mode
1474 #+begin_src emacs-lisp :tangle yes
1475 (use-package python-black
1479 *** Sphinx Documentation
1480 #+begin_src emacs-lisp :tangle yes
1481 (use-package numpydoc
1484 :bind (:map python-mode-map
1485 ("C-c C-n" . numpydoc-generate)))
1486 (use-package sphinx-doc
1490 (setq sphinx-doc-include-types t)
1494 #+BEGIN_SRC emacs-lisp
1495 (use-package go-mode
1502 #+BEGIN_SRC emacs-lisp
1503 (use-package expand-region
1504 :bind (("C-=" . 'er/expand-region))
1509 #+BEGIN_SRC emacs-lisp
1510 (use-package dockerfile-mode
1516 #+BEGIN_SRC emacs-lisp
1517 (use-package beancount
1518 :load-path "~/lib/emacs_el/beancount-mode/"
1520 :mode "\\.beancount\\'"
1527 #+BEGIN_SRC emacs-lisp
1528 (use-package message
1530 :delight (message "✉")
1531 :mode ("muttng-[a-z0-9]+-[0-9]+-" . message-mode)
1532 :mode ("mutt-[a-z0-9]+-[0-9]+-" . message-mode)
1533 :hook 'my/message-mode-settings
1534 :hook 'turn-on-flyspell
1535 :bind (:map message-mode-map
1536 ("C-c C-a" . my/post-attach-file))
1537 :delight (message-mode "✉")
1539 (defun my/message-mode-settings ()
1540 (font-lock-add-keywords nil
1541 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1542 (0 'message-multiply-quoted-text-face))
1543 ("^[ \t]*>[ \t]*>.*$"
1544 (0 'message-double-quoted-text-face))))
1547 (defun my/post-attach-file ()
1548 "Prompt for an attachment."
1550 (let ((file (read-file-name "Attach file: " nil nil t nil)))
1551 (my/header-attach-file file "")))
1553 (defun my/header-attach-file (file description)
1554 "Attach a FILE to the current message (works with Mutt).
1555 Argument DESCRIPTION MIME description."
1556 (interactive "fAttach file: \nsDescription: ")
1557 (when (> (length file) 0)
1562 (goto-char (point-min))
1563 (search-forward-regexp "^$")
1564 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1566 (message (concat "Attached '" file "'."))
1567 (setq post-has-attachment t))))))
1569 (setq mail-yank-prefix "> ")
1570 (setq mail-header-separator "") ; fix broken header detection
1574 #+BEGIN_SRC emacs-lisp
1575 (use-package muttrc-mode
1582 ** Reverting buffers
1583 #+BEGIN_SRC emacs-lisp
1584 (use-package autorevert
1585 :diminish auto-revert-mode
1587 (setq global-auto-revert-non-file-buffers t
1588 global-auto-revert-ignore-modes '(pdf-view-mode)
1589 auto-revert-verbose nil)
1590 (global-auto-revert-mode 1))
1593 ** Use-package and load things
1594 #+BEGIN_SRC emacs-lisp
1597 :delight (org-mode "ø")
1598 :mode ("\\.\\(org\\|org_archive\\|txt\\)\\'" . org-mode)
1599 :bind (("C-c l" . org-store-link)
1600 ("C-c a" . org-agenda)
1601 ("C-c b" . org-iswitchb))
1603 ** Agenda Configuration
1604 #+BEGIN_SRC emacs-lisp
1606 (setq-default org-log-done 'time)
1607 (setq-default org-agenda-ndays 5)
1609 (setq org-agenda-sticky t)
1610 (defun dla/show-org-agenda ()
1615 (and (string-match-p
1623 (buffer-name agendabuffer))
1625 (delete-other-windows))
1627 ;; agenda configuration
1628 ;; Do not dim blocked tasks
1629 (setq org-agenda-dim-blocked-tasks nil)
1630 (setq org-agenda-inhibit-startup t)
1631 (setq org-agenda-use-tag-inheritance nil)
1633 ;; Compact the block agenda view
1634 (setq org-agenda-compact-blocks t)
1636 ;; Custom agenda command definitions
1637 (setq org-agenda-custom-commands
1638 (quote (("N" "Notes" tags "NOTE"
1639 ((org-agenda-overriding-header "Notes")
1640 (org-tags-match-list-sublevels t)))
1641 ("h" "Habits" tags-todo "STYLE=\"habit\""
1642 ((org-agenda-overriding-header "Habits")
1643 (org-agenda-sorting-strategy
1644 '(todo-state-down effort-up category-keep))))
1648 ((org-agenda-overriding-header "Tasks to Refile")
1649 (org-tags-match-list-sublevels nil)))
1650 (tags-todo "-CANCELLED/!"
1651 ((org-agenda-overriding-header "Stuck Projects")
1652 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
1653 (org-agenda-sorting-strategy
1655 (tags-todo "-HOLD-CANCELLED/!"
1656 ((org-agenda-overriding-header "Projects")
1657 (org-agenda-skip-function 'bh/skip-non-projects)
1658 (org-tags-match-list-sublevels 'indented)
1659 (org-agenda-sorting-strategy
1661 (tags-todo "-CANCELLED/!NEXT"
1662 ((org-agenda-overriding-header (concat "Project Next Tasks"
1663 (if bh/hide-scheduled-and-waiting-next-tasks
1665 " (including WAITING and SCHEDULED tasks)")))
1666 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1667 (org-tags-match-list-sublevels t)
1668 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1669 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1670 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1671 (org-agenda-sorting-strategy
1672 '(todo-state-down effort-up category-keep))))
1673 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1674 ((org-agenda-overriding-header (concat "Project Subtasks"
1675 (if bh/hide-scheduled-and-waiting-next-tasks
1677 " (including WAITING and SCHEDULED tasks)")))
1678 (org-agenda-skip-function 'bh/skip-non-project-tasks)
1679 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1680 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1681 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1682 (org-agenda-sorting-strategy
1684 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1685 ((org-agenda-overriding-header (concat "Standalone Tasks"
1686 (if bh/hide-scheduled-and-waiting-next-tasks
1688 " (including WAITING and SCHEDULED tasks)")))
1689 (org-agenda-skip-function 'bh/skip-project-tasks)
1690 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1691 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1692 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1693 (org-agenda-sorting-strategy
1695 (tags-todo "-CANCELLED+WAITING|HOLD/!"
1696 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
1697 (org-agenda-skip-function 'bh/skip-stuck-projects)
1698 (org-tags-match-list-sublevels nil)
1699 (org-agenda-todo-ignore-scheduled t)
1700 (org-agenda-todo-ignore-deadlines t)))
1702 ((org-agenda-overriding-header "Tasks to Archive")
1703 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1704 (org-tags-match-list-sublevels nil))))
1707 ; org mode agenda files
1708 (setq org-agenda-files
1710 (file-expand-wildcards "~/projects/org-notes/*.org")
1711 (file-expand-wildcards "~/org-mode/from-mobile.org")
1712 (file-expand-wildcards "~/org-notes-*/*.org")
1715 (setq my/org-refile-file
1717 (lambda (file) (string-match-p (regexp-quote "/refile.org") file))
1720 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
1721 (set-register ?r (cons 'file my/org-refile-file))
1722 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
1723 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
1724 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
1725 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
1726 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
1727 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
1728 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
1729 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
1730 (defun org-agenda-timeline-all (&optional arg)
1733 (dolist (org-agenda-file org-agenda-files)
1734 (insert-file-contents org-agenda-file nil)
1735 (goto-char (point-max))
1737 (write-file "/tmp/timeline.org")
1738 (org-agenda arg "L")))
1739 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
1743 #+BEGIN_SRC emacs-lisp
1744 (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")))
1745 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
1747 (setq org-default-notes-file "~/projects/org-notes/notes.org")
1748 (setq org-id-link-to-org-use-id 'use-existing)
1750 ** Capture Templates
1751 #+BEGIN_SRC emacs-lisp
1752 (setq org-capture-templates ;; mail-specific note template, identified by "m"
1753 `(("m" "Mail" entry (file my/org-refile-file)
1754 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
1755 ("t" "todo" entry (file my/org-refile-file)
1756 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
1757 ("r" "respond" entry (file my/org-refile-file)
1758 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
1759 ("n" "note" entry (file my/org-refile-file)
1760 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
1761 ("s" "schedule" entry (file my/org-refile-file)
1762 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
1763 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
1764 "* %?\n%U\n" :clock-in t :clock-resume t)
1765 ("w" "org-protocol" entry (file my/org-refile-file)
1766 "* TODO Review %c\n%U\n" :immediate-finish t)
1767 ("M" "Meeting" entry (file my/org-refile-file)
1768 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
1769 ("S" "Seminar" entry (file my/org-refile-file)
1770 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
1771 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
1772 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
1773 ("p" "Phone call" entry (file my/org-refile-file)
1774 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
1775 ("J" "job" entry (file+olp "~/projects/org-notes/notes.org"
1777 ,(format-time-string "Positions %Y"))
1778 "* TODO Apply for %? :job:\nSCHEDULED: <%<%Y-%m-%d>>\n%U\n%x\n" :clock-in t :clock-resume t)
1779 ("h" "Habit" entry (file my/org-refile-file)
1780 "* 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")
1784 ;; Remove empty LOGBOOK drawers on clock out
1785 (defun bh/remove-empty-drawer-on-clock-out ()
1788 (beginning-of-line 0)
1789 (org-remove-empty-drawer-at (point))))
1791 (defun my/org-add-id ()
1794 (if (org-current-level)
1803 ** Org mode key bindings
1804 #+BEGIN_SRC emacs-lisp
1805 ;; org mode configuration from http://doc.norang.ca/org-mode.html
1806 ;; Custom Key Bindings
1807 :bind* (("<f9> a" . org-agenda)
1808 ("<f9> I" . bh/punch-in)
1809 ("<f9> O" . bh/punch-out)
1810 ("<f9> SPC" . bh/clock-in-last-task)
1811 ("<f12>" . dla/show-org-agenda)
1812 ;; ("<f5>" . bh/org-todo)
1813 ("<S-f5>" . bh/widen)
1814 ("<f7>" . bh/set-truncate-lines)
1815 ("<f8>" . org-cycle-agenda-files)
1816 ("<f9> <f9>" . dla/show-org-agenda)
1818 ("<f9> c" . calendar)
1819 ("<f9> f" . boxquote-insert-file)
1820 ("<f9> h" . bh/hide-other)
1821 ("<f9> n" . bh/toggle-next-task-display)
1824 ("<f9> r" . boxquote-region)
1825 ("<f9> s" . bh/switch-to-scratch)
1827 ("<f9> t" . bh/insert-inactive-timestamp)
1828 ("<f9> T" . bh/toggle-insert-inactive-timestamp)
1830 ("<f9> v" . visible-mode)
1831 ("<f9> l" . org-toggle-link-display)
1832 ("<f9> SPC" . bh/clock-in-last-task)
1833 ("C-<f9>" . previous-buffer)
1834 ("M-<f9>" . org-toggle-inline-images)
1835 ("C-x n r" . narrow-to-region)
1836 ("C-<f10>" . next-buffer)
1837 ("<f11>" . org-clock-goto)
1838 ("C-<f11>" . org-clock-in)
1839 ("C-s-<f12>" . bh/save-then-publish)
1840 ("C-c c" . org-capture))
1843 ** Utility Functions
1844 #+BEGIN_SRC emacs-lisp
1845 (defun bh/hide-other ()
1848 (org-back-to-heading 'invisible-ok)
1849 (outline-hide-other)
1854 (defun bh/set-truncate-lines ()
1855 "Toggle value of truncate-lines and refresh window display."
1857 (setq truncate-lines (not truncate-lines))
1858 ;; now refresh window display (an idiom from simple.el):
1860 (set-window-start (selected-window)
1861 (window-start (selected-window)))))
1863 (defun bh/switch-to-scratch ()
1865 (switch-to-buffer "*scratch*"))
1867 (setq org-use-fast-todo-selection t)
1868 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1870 ; create function to create headlines in file. This comes from
1871 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
1872 (defun my/org-add-ids-to-headlines-in-file ()
1873 "Add ID properties to all headlines in the current file which
1874 do not already have one."
1878 (goto-char (point-min))
1879 (when (not (re-search-forward "^#\\+OPTIONS:.*auto-id:f" (point-max) t))
1880 (org-map-entries 'org-id-get-create))))
1881 (defun dla/org-update-ids-to-headlines-in-file ()
1882 "Add or replace ID properties to all headlines in the current file
1883 (or narrowed region)."
1886 (org-map-entries '(lambda () (org-id-get-create t))))
1887 ; if we wanted to do this to every buffer, do the following:
1888 (add-hook 'org-mode-hook
1890 (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
1893 #+BEGIN_SRC emacs-lisp
1894 (use-package find-lisp
1896 (setq org-agenda-text-search-extra-files
1897 (append '(agenda-archives)
1898 (find-lisp-find-files "~/projects/org-notes" "\.org$")
1899 (find-lisp-find-files "~/projects/org-notes" "\.org_archive$")
1903 #+BEGIN_SRC emacs-lisp
1904 (setq org-todo-keywords
1905 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
1906 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
1908 (setq org-todo-keyword-faces
1909 (quote (("TODO" :foreground "red" :weight bold)
1910 ("NEXT" :foreground "blue" :weight bold)
1911 ("DONE" :foreground "forest green" :weight bold)
1912 ("WAITING" :foreground "orange" :weight bold)
1913 ("HOLD" :foreground "magenta" :weight bold)
1914 ("CANCELLED" :foreground "forest green" :weight bold)
1915 ("MEETING" :foreground "forest green" :weight bold)
1916 ("PHONE" :foreground "forest green" :weight bold))))
1918 (setq org-todo-state-tags-triggers
1919 (quote (("CANCELLED" ("CANCELLED" . t))
1920 ("WAITING" ("WAITING" . t))
1921 ("HOLD" ("WAITING") ("HOLD" . t))
1922 (done ("WAITING") ("HOLD"))
1923 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1924 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1925 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1929 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1930 ; add ids on creation of nodes
1931 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
1934 ; resolve clocks after 10 minutes of idle; use xprintidle
1935 ; (setq org-clock-idle-time 10)
1936 ; (setq org-clock-x11idle-program-name "xprintidle")
1938 ; this is from http://doc.norang.ca/org-mode.html#Capture
1939 ; use C-M-r for org mode capture
1940 (global-set-key (kbd "C-M-r") 'org-capture)
1942 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1943 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1944 (org-agenda-files :maxlevel . 9))))
1946 ; Use full outline paths for refile targets - we file directly with IDO
1947 (setq org-refile-use-outline-path t)
1949 ; Targets complete directly with IDO
1950 (setq org-outline-path-complete-in-steps nil)
1952 ; Allow refile to create parent tasks with confirmation
1953 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1955 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
1956 ; (setq org-completion-use-ido t)
1957 ; (setq ido-everywhere t)
1958 ; (setq ido-max-directory-size 100000)
1959 ; (ido-mode (quote both))
1960 ; ; Use the current window when visiting files and buffers with ido
1961 ; (setq ido-default-file-method 'selected-window)
1962 ; (setq ido-default-buffer-method 'selected-window)
1963 ; ; Use the current window for indirect buffer display
1964 ; (setq org-indirect-buffer-display 'current-window)
1967 ;;;; Refile settings
1968 ; Exclude DONE state tasks from refile targets
1969 (defun bh/verify-refile-target ()
1970 "Exclude todo keywords with a done state from refile targets"
1971 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
1973 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1975 ;; ensure that emacsclient will show just the note to be edited when invoked
1976 ;; from Mutt, and that it will shut down emacsclient once finished;
1977 ;; fallback to legacy behavior when not invoked via org-protocol.
1978 (require 'org-protocol)
1979 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
1980 (setq my-org-protocol-flag nil)
1981 (defadvice org-capture-finalize (after delete-frame-at-end activate)
1982 "Delete frame at remember finalization"
1983 (progn (if my-org-protocol-flag (delete-frame))
1984 (setq my-org-protocol-flag nil)))
1985 (defadvice org-capture-refile (around delete-frame-after-refile activate)
1986 "Delete frame at remember refile"
1987 (if my-org-protocol-flag
1989 (setq my-org-protocol-flag nil)
1994 (defadvice org-capture-kill (after delete-frame-at-end activate)
1995 "Delete frame at remember abort"
1996 (progn (if my-org-protocol-flag (delete-frame))
1997 (setq my-org-protocol-flag nil)))
1998 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
1999 (setq my-org-protocol-flag t))
2001 (defadvice org-insert-todo-heading (after dla/create-id activate)
2002 (unless (org-in-item-p)
2008 (add-to-list 'org-modules 'org-habit)
2010 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
2011 (defun open-mail-in-mutt (message)
2012 "Open a mail message in Mutt, using an external terminal.
2014 Message can be specified either by a path pointing inside a
2015 Maildir, or by Message-ID."
2016 (interactive "MPath or Message-ID: ")
2018 (format "faf xterm -e \"%s %s\""
2019 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
2021 ;; add support for "mutt:ID" links
2022 (org-add-link-type "mutt" 'open-mail-in-mutt)
2024 (defun my-org-mode-setup ()
2025 ; (load-library "reftex")
2026 (and (buffer-file-name)
2027 (file-exists-p (buffer-file-name))
2029 ; (reftex-parse-all)
2030 (reftex-set-cite-format
2031 '((?b . "[[bib:%l][%l-bib]]")
2032 (?n . "[[notes:%l][%l-notes]]")
2034 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
2036 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
2037 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
2038 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
2039 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
2041 (add-hook 'org-mode-hook 'my-org-mode-setup)
2043 (defun org-mode-reftex-search ()
2045 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
2047 (defun open-research-paper (bibtexkey)
2048 "Open a paper by bibtex key"
2049 (interactive "bibtex key: ")
2052 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
2053 (org-add-link-type "papers" 'open-research-paper)
2054 (defun open-research-paper-pdf (bibtexkey)
2055 "Open a paper pdf by bibtex key"
2056 (interactive "bibtex key: ")
2058 (format "%s -p evince_annot %s"
2059 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
2060 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
2062 (add-to-list 'org-link-abbrev-alist
2064 "~/projects/research/paper_notes.org::#%s"))
2066 ; I pretty much always want hiearchical checkboxes
2067 (setq org-hierachical-checkbox-statistics nil)
2069 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
2070 (add-to-list 'org-structure-template-alist
2071 '("E" "\\begin{equation}\n?\n\\end{equation}"))
2074 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
2075 (defun my-rtcite-export-handler (path desc format)
2076 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
2077 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
2078 (match-string 1 path)))
2079 (path (substring path 0 (match-beginning 0))))
2080 (cond ((eq format 'latex)
2082 (equal 0 (search "rtcite:" desc)))
2083 (format "\\cite{%s}" search)
2084 (format "\\cite[%s]{%s}" desc search))))))
2086 (org-add-link-type "rtcite"
2088 'my-rtcite-export-handler)
2092 ** Org Mobile Configuration
2093 #+BEGIN_SRC emacs-lisp
2094 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
2095 (when (string= system-name "linnode")
2096 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
2097 (setq-default org-directory "/home/don/org-mode/")
2098 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
2102 #+BEGIN_SRC emacs-lisp
2103 ;; org mode ical export
2104 (setq org-icalendar-timezone "America/Los_Angeles")
2105 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
2106 ;; we already add the id manually
2107 (setq org-icalendar-store-UID t)
2110 ** General Org Babel Configuration
2111 #+BEGIN_SRC emacs-lisp
2112 ;; org babel support
2113 (org-babel-do-load-languages
2114 'org-babel-load-languages
2121 ;; set the right path to ditaa.jar
2122 (setq org-ditaa-jar-path "/usr/share/ditaa/ditaa.jar")
2123 ;; use graphviz-dot for dot things
2124 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
2125 ;; do not indent begin_src blocks
2126 (setq org-edit-src-content-indentation 0)
2127 ;; org-babel-by-backend
2128 (defmacro org-babel-by-backend (&rest body)
2129 `(case (if (boundp 'backend)
2130 (org-export-backend-name backend)
2133 (defun my/fix-inline-images ()
2134 (when org-inline-image-overlays
2135 (org-redisplay-inline-images)))
2137 (add-hook 'org-babel-after-execute-hook
2138 'my/fix-inline-images)
2141 ** LaTeX configuration
2142 #+BEGIN_SRC emacs-lisp
2143 (use-package ox-extra
2145 (ox-extras-activate '(ignore-headlines)))
2147 (add-to-list 'org-latex-classes
2149 "\\documentclass[11pt,oneside,article]{memoir}\n"
2150 ("\\section{%s}" . "\\section*{%s}")
2151 ("\\subsection{%s}" . "\\subsection*{%s}")
2152 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2153 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2154 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2156 (setq org-beamer-outline-frame-options "")
2157 (add-to-list 'org-latex-classes
2159 "\\documentclass[ignorenonframetext]{beamer}
2160 [NO-DEFAULT-PACKAGES]
2163 ("\\section{%s}" . "\\section*{%s}")
2164 ("\\subsection{%s}" . "\\subsection*{%s}")
2165 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2166 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2167 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2169 (add-to-list 'org-latex-classes
2171 "\\documentclass[11pt,oneside]{memoir}\n"
2172 ("\\chapter{%s}" . "\\chapter*{%s}")
2173 ("\\section{%s}" . "\\section*{%s}")
2174 ("\\subsection{%s}" . "\\subsection*{%s}")
2175 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
2177 (add-to-list 'org-latex-classes
2179 "\\documentclass[11pt]{letter}
2180 [NO-DEFAULT-PACKAGES]
2183 ("\\section{%s}" . "\\section*{%s}")
2184 ("\\subsection{%s}" . "\\subsection*{%s}")
2185 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2186 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2187 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2189 (add-to-list 'org-latex-classes
2191 "\\documentclass{dlacv}
2192 [NO-DEFAULT-PACKAGES]
2195 ("\\section{%s}" . "\\section*{%s}")
2196 ("\\subsection{%s}" . "\\subsection*{%s}")
2197 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2198 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2199 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2202 (add-to-list 'org-latex-classes
2204 "\\documentclass{dlaresume}
2205 [NO-DEFAULT-PACKAGES]
2208 ("\\section{%s}" . "\\section*{%s}")
2209 ("\\subsection{%s}" . "\\subsection*{%s}")
2210 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2211 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2212 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2215 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
2216 ;; but adapted to use latexmk 4.22 or higher.
2217 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
2219 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
2220 (setq org-latex-default-packages-alist
2222 ("" "unicode-math" t)
2224 (setq org-latex-packages-alist
2231 ("" "longtable" nil)
2234 ;; make equations larger
2235 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
2237 (defun org-create-formula--latex-header ()
2238 "Return LaTeX header appropriate for previewing a LaTeX snippet."
2239 (let ((info (org-combine-plists (org-export--get-global-options
2240 (org-export-get-backend 'latex))
2241 (org-export--get-inbuffer-options
2242 (org-export-get-backend 'latex)))))
2243 (org-latex-guess-babel-language
2244 (org-latex-guess-inputenc
2245 (org-splice-latex-header
2246 org-format-latex-header
2247 org-latex-default-packages-alist
2249 (plist-get info :latex-header)))
2253 ; support ignoring headers in org mode export to latex
2254 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
2255 (defadvice org-latex-headline (around my-latex-skip-headlines
2256 (headline contents info) activate)
2257 (if (member "ignoreheading" (org-element-property :tags headline))
2258 (setq ad-return-value contents)
2261 ;; keep latex logfiles
2263 (setq org-latex-remove-logfiles nil)
2265 ;; Resume clocking task when emacs is restarted
2266 (org-clock-persistence-insinuate)
2268 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
2269 (setq org-clock-history-length 23)
2270 ;; Resume clocking task on clock-in if the clock is open
2271 (setq org-clock-in-resume t)
2272 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
2273 ;; there are things like PHONE calls
2274 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
2275 ;; Separate drawers for clocking and logs
2276 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
2277 ;; Save clock data and state changes and notes in the LOGBOOK drawer
2278 (setq org-clock-into-drawer t)
2279 (setq org-log-into-drawer t)
2280 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
2281 (setq org-clock-out-remove-zero-time-clocks t)
2282 ;; Clock out when moving task to a done state
2283 (setq org-clock-out-when-done t)
2284 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
2285 (setq org-clock-persist t)
2286 ;; Do not prompt to resume an active clock
2287 (setq org-clock-persist-query-resume nil)
2288 ;; Enable auto clock resolution for finding open clocks
2289 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
2290 ;; Include current clocking task in clock reports
2291 (setq org-clock-report-include-clocking-task t)
2293 ;; the cache seems to be broken
2294 (setq org-element-use-cache nil)
2296 (defvar bh/keep-clock-running nil)
2298 (defun bh/is-task-p ()
2299 "Any task with a todo keyword and no subtask"
2303 (subtree-end (save-excursion (org-end-of-subtree t)))
2304 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2307 (while (and (not has-subtask)
2308 (< (point) subtree-end)
2309 (re-search-forward "^\*+ " subtree-end t))
2310 (when (member (org-get-todo-state) org-todo-keywords-1)
2311 (setq has-subtask t))))
2312 (and is-a-task (not has-subtask)))))
2313 (defun bh/is-project-p ()
2314 "Any task with a todo keyword subtask"
2318 (subtree-end (save-excursion (org-end-of-subtree t)))
2319 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2322 (while (and (not has-subtask)
2323 (< (point) subtree-end)
2324 (re-search-forward "^\*+ " subtree-end t))
2325 (when (member (org-get-todo-state) org-todo-keywords-1)
2326 (setq has-subtask t))))
2327 (and is-a-task has-subtask))))
2329 (defun bh/is-subproject-p ()
2330 "Any task which is a subtask of another project"
2331 (let ((is-subproject)
2332 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2334 (while (and (not is-subproject) (org-up-heading-safe))
2335 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
2336 (setq is-subproject t))))
2337 (and is-a-task is-subproject)))
2340 (defun bh/clock-in-to-next (kw)
2341 "Switch a task from TODO to NEXT when clocking in.
2342 Skips capture tasks, projects, and subprojects.
2343 Switch projects and subprojects from NEXT back to TODO"
2344 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
2346 ((and (member (org-get-todo-state) (list "TODO"))
2349 ((and (member (org-get-todo-state) (list "NEXT"))
2353 (defun bh/punch-in (arg)
2354 "Start continuous clocking and set the default task to the
2355 selected task. If no task is selected set the Organization task
2356 as the default task."
2358 (setq bh/keep-clock-running t)
2359 (if (equal major-mode 'org-agenda-mode)
2361 ;; We're in the agenda
2363 (let* ((marker (org-get-at-bol 'org-hd-marker))
2364 (tags (org-with-point-at marker (org-get-tags))))
2365 (if (and (eq arg 4) tags)
2366 (org-agenda-clock-in '(16))
2367 (bh/clock-in-organization-task-as-default)))
2369 ;; We are not in the agenda
2373 ; Find the tags on the current task
2374 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
2375 (org-clock-in '(16))
2376 (bh/clock-in-organization-task-as-default)))))
2378 (defun bh/punch-out ()
2380 (setq bh/keep-clock-running nil)
2381 (when (org-clock-is-active)
2383 (org-agenda-remove-restriction-lock))
2385 (defun bh/clock-in-default-task ()
2387 (org-with-point-at org-clock-default-task
2390 (defun bh/clock-in-parent-task ()
2391 "Move point to the parent (project) task if any and clock in"
2392 (let ((parent-task))
2396 (while (and (not parent-task) (org-up-heading-safe))
2397 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
2398 (setq parent-task (point))))
2400 (org-with-point-at parent-task
2402 (when bh/keep-clock-running
2403 (bh/clock-in-default-task)))))))
2405 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
2407 (defun bh/clock-in-organization-task-as-default ()
2409 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
2410 (org-clock-in '(16))))
2412 (defun bh/clock-out-maybe ()
2413 (when (and bh/keep-clock-running
2414 (not org-clock-clocking-in)
2415 (marker-buffer org-clock-default-task)
2416 (not org-clock-resolving-clocks-due-to-idleness))
2417 (bh/clock-in-parent-task)))
2419 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
2422 (defun bh/clock-in-task-by-id (id)
2423 "Clock in a task by id"
2424 (org-with-point-at (org-id-find id 'marker)
2425 (org-clock-in nil)))
2427 (defun bh/clock-in-last-task (arg)
2428 "Clock in the interrupted task if there is one
2429 Skip the default task and get the next one.
2430 A prefix arg forces clock in of the default task."
2432 (let ((clock-in-to-task
2434 ((eq arg 4) org-clock-default-task)
2435 ((and (org-clock-is-active)
2436 (equal org-clock-default-task (cadr org-clock-history)))
2437 (caddr org-clock-history))
2438 ((org-clock-is-active) (cadr org-clock-history))
2439 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
2440 (t (car org-clock-history)))))
2442 (org-with-point-at clock-in-to-task
2443 (org-clock-in nil))))
2446 (defun org-export-to-ods ()
2448 (let ((csv-file "data.csv"))
2449 (org-table-export csv-file "orgtbl-to-csv")
2450 (org-odt-convert csv-file "ods" 'open)))
2452 ; allow for zero-width-space to be a break in regexp too
2453 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
2454 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
2455 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
2457 ;; support inserting screen shots
2458 (defun my/org-insert-screenshot ()
2459 "Take a screenshot into a time stamped unique-named file in the
2460 same directory as the org-buffer and insert a link to this file."
2462 (defvar my/org-insert-screenshot/filename)
2463 (setq my/org-insert-screenshot/filename
2465 "Screenshot to insert: "
2467 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
2470 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
2471 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
2472 (org-display-inline-images))
2474 (defun my/fix-inline-images ()
2475 (when org-inline-image-overlays
2476 (org-redisplay-inline-images)))
2478 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
2480 ;; use xelatex to preview with imagemagick
2481 (add-to-list 'org-preview-latex-process-alist
2482 '(xelateximagemagick
2483 :programs ("xelatex" "convert")
2484 :description "pdf > png"
2485 :message "you need to install xelatex and imagemagick"
2487 :image-input-type "pdf"
2488 :image-output-type "png"
2489 :image-size-adjust (1.0 . 1.0)
2490 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
2491 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
2493 ;; use xelatex by default
2494 (setq org-preview-latex-default-process 'xelateximagemagick)
2496 ; from http://orgmode.org/Changes.html
2497 (defun my/org-repair-property-drawers ()
2498 "Fix properties drawers in current buffer.
2499 Ignore non Org buffers."
2501 (when (eq major-mode 'org-mode)
2502 (org-with-wide-buffer
2503 (goto-char (point-min))
2504 (let ((case-fold-search t)
2505 (inline-re (and (featurep 'org-inlinetask)
2506 (concat (org-inlinetask-outline-regexp)
2510 (unless (and inline-re (org-looking-at-p inline-re))
2512 (let ((end (save-excursion (outline-next-heading) (point))))
2514 (when (org-looking-at-p org-planning-line-re) (forward-line))
2515 (when (and (< (point) end)
2516 (not (org-looking-at-p org-property-drawer-re))
2518 (and (re-search-forward org-property-drawer-re end t)
2519 (eq (org-element-type
2520 (save-match-data (org-element-at-point)))
2522 (insert (delete-and-extract-region
2524 (min (1+ (match-end 0)) end)))
2525 (unless (bolp) (insert "\n"))))))))))))
2529 #+BEGIN_SRC emacs-lisp
2533 (use-package calfw-org
2536 (use-package org-gcal
2537 :if (file-readable-p "~/.hide/org_gcal.el")
2539 :config '((if (file-readable-p "~/.hide/org_gcal.el")
2540 (load-file "~/.hide/org_gcal.el"))
2545 #+BEGIN_SRC emacs-lisp
2549 ;; Show notification 10 minutes before event
2550 (setq appt-message-warning-time 10)
2551 ;; Disable multiple reminders
2552 (setq appt-display-interval appt-message-warning-time)
2553 (setq appt-display-mode-line nil)
2555 ;; add automatic reminders for appointments
2556 (defun my/org-agenda-to-appt ()
2558 (setq appt-time-msg-list nil)
2559 (org-agenda-to-appt))
2560 ;; add reminders when starting emacs
2561 (my/org-agenda-to-appt)
2562 ;; when rebuilding the agenda
2563 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
2564 "Pressing `r' on the agenda will also add appointments."
2565 (my/org-agenda-to-appt)
2567 ;; when saving all org buffers
2568 (defadvice org-save-all-org-buffers (after org-save-all-org-buffers-add-appts)
2569 "Re-add appts after saving all org buffers"
2570 (my/org-agenda-to-appt))
2571 ;; Display appointments as a window manager notification
2572 (setq appt-disp-window-function 'my/appt-display)
2573 (setq appt-delete-window-function (lambda () t))
2575 (setq my/appt-notification-app (concat (getenv "HOME") "/bin/appt_notification"))
2577 (defun my/appt-display (min-to-app new-time msg)
2578 (if (atom min-to-app)
2579 (start-process "my/appt-notification-app" nil my/appt-notification-app min-to-app msg)
2580 (dolist (i (number-sequence 0 (1- (length min-to-app))))
2581 (start-process "my/appt-notification-app" nil my/appt-notification-app
2582 (nth i min-to-app) (nth i msg))))
2588 ** outshine (outlining) integration
2589 #+BEGIN_SRC emacs-lisp
2590 (use-package outshine
2592 :hook (outline-minor-mode . outshine-hook-function)
2596 #+BEGIN_SRC emacs-lisp
2600 ** Home/End Begining/End of line
2601 #+BEGIN_SRC emacs-lisp
2602 (global-set-key [home] 'move-beginning-of-line)
2603 (global-set-key [end] 'move-end-of-line)
2606 #+BEGIN_SRC emacs-lisp
2607 (global-unset-key "\M-g")
2608 (global-set-key (kbd "M-g l") 'goto-line)
2612 #+BEGIN_SRC emacs-lisp
2613 (use-package debian-changelog-mode
2614 :mode "debian/changelog"
2616 (setq debian-changelog-mailing-address "don@debian.org")
2617 (setq debian-changelog-full-name "Don Armstrong"))
2619 * Misc (uncharacterized)
2620 #+BEGIN_SRC emacs-lisp
2621 (setq calendar-latitude 38.6)
2622 (setq calendar-longitude -121.5)
2623 (setq case-fold-search t)
2624 (setq confirm-kill-emacs (quote y-or-n-p))
2625 (setq cperl-lazy-help-time nil)
2627 ** Turn on fontlock and icomplete
2628 #+BEGIN_SRC emacs-lisp
2629 (global-font-lock-mode 1)
2631 (setq log-edit-keep-buffer t)
2633 ** Set mail User agent
2634 #+BEGIN_SRC emacs-lisp
2635 (setq mail-user-agent (quote sendmail-user-agent))
2636 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
2639 #+BEGIN_SRC emacs-lisp
2640 (setq ps-footer-font-size (quote (8 . 10)))
2641 (setq ps-header-font-size (quote (8 . 10)))
2642 (setq ps-header-title-font-size (quote (10 . 10)))
2643 (setq ps-line-number-color "blue")
2644 (setq ps-print-footer t)
2645 (setq ps-print-footer-frame nil)
2646 (setq ps-print-only-one-header t)
2648 ** Only single spacing on sentences
2649 #+BEGIN_SRC emacs-lisp
2650 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
2652 (setq sentence-end-double-space nil)
2653 ; enable matching parenthesis
2655 ** Display paren mode
2656 #+BEGIN_SRC emacs-lisp
2658 (setq show-paren-delay 0.2)
2662 #+BEGIN_SRC emacs-lisp
2663 (setq user-mail-address "don@donarmstrong.com")
2666 ** Use primary selection on unix machines
2667 #+BEGIN_SRC emacs-lisp
2668 ;; switch back to the old primary selection method
2669 (if (or (string-equal system-type "darwin")
2670 (string-equal system-type "windows")
2673 (setq select-enable-clipboard t)
2674 (setq select-enable-primary nil)
2677 (setq select-enable-clipboard nil)
2678 (setq select-enable-primary t)
2680 ; (setq mouse-drag-copy-region t)
2682 ;; tramp configuration
2683 (setq tramp-use-ssh-controlmaster-options nil)
2685 (setq-default c-indent-level 4)
2686 (setq-default c-brace-imaginary-offset 0)
2687 (setq-default c-brace-offset -4)
2688 (setq-default c-argdecl-indent 4)
2689 (setq-default c-label-offset -4)
2690 (setq-default c-continued-statement-offset 4)
2692 (setq-default indent-tabs-mode nil)
2693 (setq-default tab-width 4)
2696 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
2697 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
2698 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
2699 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
2700 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
2703 (defun insert-date ()
2704 "Insert date at point."
2706 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
2707 (global-set-key "\C-[d" 'insert-date)
2709 (defun unfill-paragraph (arg)
2710 "Pull this whole paragraph up onto one line."
2712 (let ((fill-column 10000))
2713 (fill-paragraph arg))
2716 (column-number-mode t)
2719 ** Desktop-save-mode
2720 If the envvar EMACS_SERVER_NAME is set, consider this a separate
2721 emacs, and use a different desktop file to restore history
2722 #+BEGIN_SRC emacs-lisp
2723 (use-package desktop
2726 (setq desktop-base-file-name
2727 (convert-standard-filename
2729 (or (getenv "EMACS_SERVER_NAME")
2733 (setq desktop-base-lock-name
2734 (convert-standard-filename
2735 (concat desktop-base-file-name
2737 (setq desktop-auto-save-timeout 60)
2738 (setq desktop-restore-eager 5)
2739 (setq desktop-lazy-verbose nil)
2740 (desktop-save-mode 1)
2744 ** Misc (Uncharacterized)
2745 #+BEGIN_SRC emacs-lisp
2746 '(icomplete-mode on)
2748 ;; custom-set-faces was added by Custom.
2749 ;; If you edit it by hand, you could mess it up, so be careful.
2750 ;; Your init file should contain only one such instance.
2751 ;; If there is more than one, they won't work right.
2752 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
2755 (put 'upcase-region 'disabled nil)
2756 (put 'downcase-region 'disabled nil)
2757 (put 'narrow-to-region 'disabled nil)
2759 ; (defun turn-on-flyspell ()
2760 ; "Force flyspell-mode on using a positive arg. For use in hooks."
2762 ; (flyspell-mode 1))
2765 ; Outline-minor-mode key map
2766 (define-prefix-command 'cm-map nil "Outline-")
2768 (define-key cm-map "q" 'outline-hide-sublevels) ; Hide everything but the top-level headings
2769 (define-key cm-map "t" 'outline-hide-body) ; Hide everything but headings (all body lines)
2770 (define-key cm-map "o" 'outline-hide-other) ; Hide other branches
2771 (define-key cm-map "c" 'outline-hide-entry) ; Hide this entry's body
2772 (define-key cm-map "l" 'outline-hide-leaves) ; Hide body lines in this entry and sub-entries
2773 (define-key cm-map "d" 'outline-hide-subtree) ; Hide everything in this entry and sub-entries
2775 (define-key cm-map "a" 'outline-show-all) ; Show (expand) everything
2776 (define-key cm-map "e" 'outline-show-entry) ; Show this heading's body
2777 (define-key cm-map "i" 'outline-show-children) ; Show this heading's immediate child sub-headings
2778 (define-key cm-map "k" 'outline-show-branches) ; Show all sub-headings under this heading
2779 (define-key cm-map "s" 'outline-show-subtree) ; Show (expand) everything in this heading & below
2781 (define-key cm-map "u" 'outline-up-heading) ; Up
2782 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
2783 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
2784 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
2785 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
2786 (global-set-key "\M-o" cm-map)
2787 ; fix up tmux xterm keys
2788 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
2789 (defun fix-up-tmux-keys ()
2790 "Fix up tmux xterm keys"
2793 (let ((x 2) (tkey ""))
2813 ;; ctrl + alt + shift
2815 (setq tkey "C-M-S-"))
2818 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
2819 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
2820 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
2821 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
2823 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
2825 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
2827 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
2829 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
2831 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2833 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2835 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
2837 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
2839 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
2841 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
2843 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
2845 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
2847 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
2849 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
2851 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
2853 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
2855 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
2857 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
2859 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
2861 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
2863 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
2865 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
2867 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
2869 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
2871 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
2873 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
2880 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
2882 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
2883 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
2884 (if (or (buffer-modified-p)
2885 (verify-visited-file-modtime)
2886 (< (* 8 1024 1024) (buffer-size))
2887 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
2889 (clear-visited-file-modtime)
2891 (ad-activate 'ask-user-about-supersession-threat)
2895 #+BEGIN_SRC emacs-lisp
2899 (or (getenv "EMACS_SERVER_NAME")
2901 (unless (server-running-p)
2902 (global-set-key "\C-xp" 'server-edit)
2909 #+BEGIN_SRC emacs-lisp
2910 (provide 'don-configuration)