1 #+PROPERTY: header-args:emacs-lisp :tangle don-configuration.el
4 # if for some reason, things get pear-shaped, we want to be able to
5 # enter the debugger by sending -USR2 to emacs
8 (setq debug-on-event 'siguser2)
12 #+BEGIN_SRC emacs-lisp
13 (add-to-list 'load-path '"~/lib/emacs_el/")
14 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/tiny")
15 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/other")
16 (add-to-list 'load-path '"~/lib/emacs_el/magit-annex")
20 ** package repositories and package manager
21 #+BEGIN_SRC emacs-lisp
23 (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
24 ("melpa" . "https://melpa.org/packages/")
25 ("org" . "http://orgmode.org/elpa/") ))
27 ** [[https://github.com/jwiegley/use-package/][use-package]]
28 #+BEGIN_SRC emacs-lisp
31 (require 'use-package)
32 (progn (package-install 'use-package)
33 (require 'use-package)))
36 #+BEGIN_SRC emacs-lisp
42 #+BEGIN_SRC emacs-lisp
43 ;; Set the custom file to /dev/null and don't bother to load it
44 (setq custom-file "/dev/null")
48 #+BEGIN_SRC emacs-lisp
49 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
50 ;; execute conditional code when loading libraries
51 (defmacro with-library (symbol &rest body)
52 `(when (require ,symbol nil t)
54 (put 'with-library 'lisp-indent-function 1)
58 ** Safe Local Variables
59 #+BEGIN_SRC emacs-lisp
60 (setq safe-local-variable-values
61 (quote ((auto-save-default)
63 (cperl-indent-level . 4)
65 (indent-tabs-mode . f)
69 #+BEGIN_SRC emacs-lisp
70 (setq global-mark-ring-max 128
74 (defun don/minibuffer-setup-hook ()
75 (setq gc-cons-threshold most-positive-fixnum))
77 (defun don/minibuffer-exit-hook ()
78 (setq gc-cons-threshold 1048576))
80 (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
81 (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
85 #+BEGIN_SRC emacs-lisp
88 :diminish flyspell-mode 🐝
90 (add-hook 'message-mode-hook 'turn-on-flyspell)
91 (add-hook 'text-mode-hook 'turn-on-flyspell)
92 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
93 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
94 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
96 (setq ispell-program-name "ispell")
101 #+BEGIN_SRC emacs-lisp
106 #+BEGIN_SRC emacs-lisp
107 ;; (use-package eyebrowse
109 ;; :diminish eyebrowse-mode
110 ;; :init (setq eyebrowse-keymap-prefix (kbd "C-c C-\\"))
112 ;; (setq eyebrowse-wrap-around t)
113 ;; (eyebrowse-mode t)
115 ;; (defun my/eyebrowse-new-window-config ()
119 ;; ;; start at 1 run till 0
120 ;; (let ((j (mod (+ i 1) 10)))
121 ;; (when (and (not done)
122 ;; (not (eyebrowse--window-config-present-p j)))
123 ;; (eyebrowse-switch-to-window-config j)
124 ;; (call-interactively 'eyebrowse-rename-window-config2 j)
129 ;; ;; I don't use latex-preview-pane
130 ;; ;; (require 'latex-preview-pane)
131 ;; ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
132 ;; ;; ;; latex-preview-pane uses window-parameters which are
133 ;; ;; ;; not preserved by eyebrowse, so we close the preview
134 ;; ;; ;; pane before switching, it will be regenerated when we
135 ;; ;; ;; edit the TeX file.
136 ;; ;; (when (lpp/window-containing-preview)
137 ;; ;; (delete-window (lpp/window-containing-preview))))
139 ;; ;; (add-to-list 'eyebrowse-pre-window-switch-hook
140 ;; ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
142 ;; ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
143 ;; ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
144 ;; ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
145 ;; ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
146 ;; ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
154 #+BEGIN_SRC emacs-lisp
155 (defun my/vsplit-last-buffer ()
156 "Split the window vertically and display the previous buffer."
158 (split-window-vertically)
160 (switch-to-next-buffer))
162 (defun my/hsplit-last-buffer ()
163 "Split the window horizontally and display the previous buffer."
165 (split-window-horizontally)
167 (switch-to-next-buffer))
169 (bind-key "C-x 2" 'my/vsplit-last-buffer)
170 (bind-key "C-x 3" 'my/hsplit-last-buffer)
172 (setq split-width-threshold 100)
173 (setq split-height-threshold 60)
175 (defun my/split-window-prefer-vertically (window)
176 "If there's only one window (excluding any possibly active
177 minibuffer), then split the current window horizontally."
178 (if (and (one-window-p t)
179 (not (active-minibuffer-window))
180 ( < (frame-width) (frame-height))
182 (let ((split-width-threshold nil))
183 (split-window-sensibly window))
184 (split-window-sensibly window)))
186 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
187 (setq window-combination-resize t)
190 *** Compilation window
192 If there is no compilation window, open one at the bottom, spanning
193 the complete width of the frame. Otherwise, reuse existing window. In
194 the former case, if there was no error the window closes
197 #+BEGIN_SRC emacs-lisp
198 (add-to-list 'display-buffer-alist
199 `(,(rx bos "*compilation*" eos)
200 (display-buffer-reuse-window
201 display-buffer-in-side-window)
202 (reusable-frames . visible)
204 (window-height . 0.4)))
207 #+BEGIN_SRC emacs-lisp
208 (defun my/compilation-exit-autoclose (status code msg)
209 ;; If M-x compile exists with a 0
210 (when (and (eq status 'exit) (zerop code))
211 ;; and delete the *compilation* window
212 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
213 (when (and (not (window-at-side-p compilation-window 'top))
214 (window-at-side-p compilation-window 'left)
215 (window-at-side-p compilation-window 'right))
216 (delete-window compilation-window))))
217 ;; Always return the anticipated result of compilation-exit-message-function
220 ;; Specify my function (maybe I should have done a lambda function)
221 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
224 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
225 value, the compilation buffer scrolls automatically to follow the
226 output. If the value is ~first-error~, scrolling stops when the first
227 error appears, leaving point at that error. For any other non-nil
228 value, scrolling continues until there is no more output.
230 #+BEGIN_SRC emacs-lisp
231 (setq compilation-scroll-output 'first-error)
234 ** Mode line cleaning
236 #+BEGIN_SRC emacs-lisp
237 (use-package diminish
242 #+BEGIN_SRC emacs-lisp
249 #+BEGIN_SRC emacs-lisp
252 :bind (("C-c C-<SPC>" . avy-goto-word-or-subword-1)
253 ("C-c j j" . avy-goto-word-or-subword-1)
254 ("M-g g" . avy-goto-line))
255 :config (progn (setq avy-background t))
258 *** Ace-link (jumping to links)
259 #+BEGIN_SRC emacs-lisp
260 (use-package ace-link
262 ; bind o in most modes
263 :config (ace-link-setup-default))
265 *** Jumping through edit points (goto-chg)
266 #+BEGIN_SRC emacs-lisp
267 (use-package goto-chg
269 :bind (("C-c j ," . goto-last-change)
270 ("C-c j ." . goto-last-change-reverse))
273 *** Jumping to bookmarks (visible bookmarks, bm)
274 #+BEGIN_SRC emacs-lisp
277 :bind (("C-c j b ." . bm-next)
278 ("C-c j b ," . bm-previous)
279 ("C-c j b SPC" . bm-toggle)))
284 #+BEGIN_SRC emacs-lisp
285 (use-package yasnippet
287 :diminish yas-minor-mode
290 (setq yas-verbosity 1)
291 (define-key yas-minor-mode-map (kbd "<tab>") nil)
292 (define-key yas-minor-mode-map (kbd "TAB") nil)
293 (define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)
294 (setq yas-snippet-dirs '("~/lib/emacs_el/snippets/"
295 "~/lib/emacs_el/yasnippet-snippets/snippets/"))
296 (add-to-list 'hippie-expand-try-functions-list
297 'yas-hippie-try-expand)
302 #+BEGIN_SRC emacs-lisp
303 (use-package auto-yasnippet
304 :bind (("H-w" . aya-create)
311 #+BEGIN_SRC emacs-lisp
313 (use-package tinyprocmail
315 :config (with-library 'tinyprocmail
316 ;; (setq tinyprocmail--procmail-version "v3.22")
317 (add-hook 'tinyprocmail--load-hook 'tinyprocmail-install))
322 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
325 :bind (("C-x g" . magit-status)
326 ("C-x C-g" . magit-status))
328 ;; don't verify where we are pushing
329 (setq magit-push-always-verify nil)
330 ;; refine diffs always (hilight words)
331 (setq magit-diff-refine-hunk nil)
334 (append '("~/lib/emacs_el/magit-annex")
338 (append '("~/lib/emacs_el/magit-vcsh")
341 (use-package magit-annex
344 (use-package magit-vcsh
345 :ensure f ; currently not in melpa, so don't try to install
350 #+BEGIN_SRC emacs-lisp
351 (use-package cperl-mode
354 ;; Use c-mode for perl .xs files
355 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
356 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
357 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
358 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
359 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
362 cperl-auto-newline nil
363 cperl-auto-newline-after-colon nil
364 cperl-continued-statement-offset 4
365 cperl-brace-offset -1
366 cperl-continued-brace-offset 0
367 cperl-label-offset -4
368 cperl-highlight-variables-indiscriminately t
369 cperl-electric-lbrace-space nil
370 cperl-indent-parens-as-block nil
371 cperl-close-paren-offset -1
372 cperl-tab-always-indent t)
373 ;;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
378 #+BEGIN_SRC emacs-lisp
383 (define-key global-map [remap find-file] 'helm-find-files)
384 (define-key global-map [remap occur] 'helm-occur)
385 (define-key global-map [remap list-buffers] 'helm-buffers-list)
386 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
387 (global-set-key (kbd "M-x") 'helm-M-x)
388 (unless (boundp 'completion-in-region-function)
389 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
390 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
391 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
396 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
398 #+BEGIN_SRC emacs-lisp
399 (use-package helm-flx
402 ;; these are helm configs, but they kind of fit here nicely
403 (setq helm-M-x-fuzzy-match t
404 helm-bookmark-show-location t
405 helm-buffers-fuzzy-matching t
406 helm-completion-in-region-fuzzy-match t
407 helm-file-cache-fuzzy-match t
408 helm-imenu-fuzzy-match t
409 helm-mode-fuzzy-match t
410 helm-locate-fuzzy-match nil
412 helm-recentf-fuzzy-match nil
413 helm-semantic-fuzzy-match t)
417 #+BEGIN_SRC emacs-lisp
419 ;;; stolen from https://github.com/malb/emacs.d/blob/master/malb.org
420 (defun malb/helm-swoop-pre-fill ()
421 (thing-at-point 'symbol))
422 (setq malb/helm-swoop-ignore-major-mode '(dired-mode
423 paradox-menu-mode doc-view-mode pdf-view-mode
424 mu4e-headers-mode org-mode markdown-mode latex-mode
425 ein:notebook-multilang-mode))
427 (defun malb/swoop-or-search ()
429 (if (or (> (buffer-size) 1048576) ;; helm-swoop can be slow on big buffers
430 (memq major-mode malb/helm-swoop-ignore-major-mode))
434 (use-package helm-swoop
436 :bind (("C-c o" . helm-multi-swoop-org)
437 ("C-s" . malb/swoop-or-search)
438 ("C-M-s" . helm-multi-swoop-all))
441 (setq helm-swoop-pre-input-function #'malb/helm-swoop-pre-fill
442 helm-swoop-split-with-multiple-windows nil
443 helm-swoop-split-direction #'split-window-horizontally
444 helm-swoop-split-window-function 'helm-default-display-buffer
445 helm-swoop-speed-or-color t)
447 ;; https://emacs.stackexchange.com/questions/28790/helm-swoop-how-to-make-it-behave-more-like-isearch
448 (defun malb/helm-swoop-C-s ()
450 (if (boundp 'helm-swoop-pattern)
451 (if (equal helm-swoop-pattern "")
452 (previous-history-element 1)
456 (bind-key "C-S-s" #'helm-swoop-from-isearch isearch-mode-map)
457 (bind-key "C-S-s" #'helm-multi-swoop-all-from-helm-swoop helm-swoop-map)
458 (bind-key "C-r" #'helm-previous-line helm-swoop-map)
459 (bind-key "C-s" #'malb/helm-swoop-C-s helm-swoop-map)
460 (bind-key "C-r" #'helm-previous-line helm-multi-swoop-map)
461 (bind-key "C-s" #'malb/helm-swoop-C-s helm-multi-swoop-map))
466 #+BEGIN_SRC emacs-lisp
469 :config (setq helm-ag-base-command "ag --nocolor --nogroup"
470 helm-ag-command-option "--all-text"
471 helm-ag-insert-at-point 'symbol
472 helm-ag-fuzzy-match t
473 helm-ag-use-temp-buffer t
474 helm-ag-use-grep-ignore-list t
475 helm-ag-use-agignore t))
478 #+BEGIN_SRC emacs-lisp
479 (use-package helm-descbinds
481 :bind ("C-h b" . helm-descbinds)
482 :init (fset 'describe-bindings 'helm-descbinds))
486 #+BEGIN_SRC emacs-lisp
487 (use-package helm-c-yasnippet
489 :bind ("C-c h y" . helm-yas-complete)
491 (setq helm-yas-space-match-any-greedy t)))
494 #+BEGIN_SRC emacs-lisp
495 (use-package helm-org-rifle
498 (defun malb/helm-org-rifle-agenda-files (arg)
500 (let ((current-prefix-arg nil))
502 ((equal arg 4) (call-interactively #'helm-org-rifle-agenda-files nil))
503 ((equal arg 16) (helm-org-rifle-occur-agenda-files))
504 (t (helm-org-agenda-files-headings)))))))
508 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
513 #+BEGIN_SRC emacs-lisp
514 (add-to-list 'tramp-methods '("vcsh"
515 (tramp-login-program "vcsh")
519 (tramp-remote-shell "/bin/sh")
520 (tramp-remote-shell-args
524 #+BEGIN_SRC emacs-lisp
528 (setq-default reftex-default-bibliography
529 '("~/projects/research/references.bib")))
532 #+BEGIN_SRC emacs-lisp
534 :config (setq bibtex-user-optional-fields
535 (quote (("annote" "Personal annotation (ignored)")
543 #+BEGIN_SRC emacs-lisp
548 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
549 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
550 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
551 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
552 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
553 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
554 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
555 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
556 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
557 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
558 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
560 (setq-default reftex-plug-into-AUCTeX t)
561 ;; support fake section headers
562 (setq TeX-outline-extra
568 ;; add font locking to the headers
569 (font-lock-add-keywords
571 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
572 0 'font-lock-keyword-face t)
573 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
574 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
575 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
576 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
577 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
579 ;; use smart quotes by default instead of `` and ''
580 ;; taken from http://kieranhealy.org/esk/kjhealy.html
581 (setq TeX-open-quote "“")
582 (setq TeX-close-quote "”")
584 ;; (TeX-add-style-hook
589 ;; (custom-set-variables
590 ;; '(font-latex-user-keyword-classes
593 ;; font-lock-function-name-face 2 (command 1 t))))
595 (setq-default TeX-parse-self t)
596 (setq-default TeX-auto-save t)
597 (setq-default TeX-master nil)
603 (if (boundp 'reftex-ref-style-alist)
605 'reftex-ref-style-alist
606 '("Cleveref" "cleveref"
607 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
608 (reftex-ref-style-activate "Cleveref")
610 '("cref" TeX-arg-ref)
611 '("Cref" TeX-arg-ref)
612 '("cpageref" TeX-arg-ref)
613 '("Cpageref" TeX-arg-ref)))))
616 '(add-to-list 'LaTeX-fill-excluded-macros
619 (use-package font-latex
621 (setq font-latex-match-reference-keywords
643 (setq font-latex-fontify-script nil)
644 (setq font-latex-fontify-sectioning (quote color))
645 (setq font-latex-script-display (quote (nil)))
650 #+BEGIN_SRC emacs-lisp
654 (defun ess-change-directory (path)
655 "Set the current working directory to PATH for both *R* and Emacs."
656 (interactive "DDirectory to change to: ")
658 (when (file-exists-p path)
659 (ess-command (concat "setwd(\"" path "\")\n"))
660 ;; use file-name-as-directory to ensure it has trailing /
661 (setq default-directory (file-name-as-directory path))))
662 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
663 ;; outlining support for ess modes
668 (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
669 (defun outline-level ()
670 (cond ((looking-at "^##### ") 1)
671 ((looking-at "^#### ") 2)
672 ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
675 (add-hook 'ess-mode-hook
677 (local-set-key (kbd "C-c C-R")
678 'dla/ess-region-remote-eval)))
680 ;; Don't restore history or save workspace image
681 '(inferior-R-args "--no-restore-history --no-save")
686 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
688 #+BEGIN_SRC emacs-lisp
689 (use-package rainbow-mode
690 ;; add ess to the x major mode
691 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
692 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
697 #+BEGIN_SRC emacs-lisp
698 (use-package polymode
701 (use-package poly-noweb)
702 (use-package poly-markdown)
703 :mode ("\\.Snw" . poly-noweb+r-mode)
704 :mode ("\\.Rnw" . poly-noweb+r-mode)
705 :mode ("\\.Rmd" . poly-markdown+r-mode)
711 #+BEGIN_SRC emacs-lisp
712 (use-package outline-magic)
715 #+BEGIN_SRC emacs-lisp
716 (use-package writeroom-mode
718 (defun my/writing-mode ()
719 "Start my writing mode; enable visual-line-mode and auto-fill-mode"
724 (visual-line-mode -1)
726 (visual-fill-column-mode -1)
730 (visual-fill-column-mode 1)
735 ** GhostText/Atomic Chrome
736 #+BEGIN_SRC emacs-lisp
737 (use-package atomic-chrome
739 (ignore-errors (atomic-chrome-start-server))
740 (setq atomic-chrome-buffer-open-style 'full)
745 :ID: 6fcf218b-a762-4c37-9339-a8202ddeb544
747 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
748 #+BEGIN_SRC emacs-lisp
749 (use-package multiple-cursors
750 :bind (("C-;" . mc/mark-all-dwim)
751 ("C-<" . mc/mark-previous-like-this)
752 ("C->" . mc/mark-next-like-this)
753 ("C-S-c C-S-c" . mc/edit-lines))
757 #+BEGIN_SRC emacs-lisp
758 (use-package web-mode
760 (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . web-mode))
761 (setq web-mode-enable-engine-detection t)
762 (setq web-mode-engines-alist
763 '(("template-toolkit" . "\\.tmpl\\'")))
768 #+BEGIN_SRC emacs-lisp
771 (setq post-email-address "don@donarmstrong.com")
772 (setq post-kill-quoted-sig nil)
773 (setq post-mail-message "mutt\\(ng\\|\\)-[a-z0-9]+-[0-9]+-.*")
774 (setq post-uses-fill-mode nil)
779 #+BEGIN_SRC emacs-lisp
780 (use-package message-mode
782 :mode "muttng-[a-z0-9]+-[0-9]+-"
783 :mode "mutt-[a-z0-9]+-[0-9]+-"
784 :hook 'my/message-mode-settings
785 :hook 'turn-on-flyspell
786 :bind (:map message-mode-map
787 ("C-c C-a" . my/post-attach-file))
789 (defun my/message-mode-settings ()
790 (font-lock-add-keywords nil
791 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
792 (0 'message-multiply-quoted-text-face))
793 ("^[ \t]*>[ \t]*>.*$"
794 (0 'message-double-quoted-text-face))))
797 (defun my/post-attach-file ()
798 "Prompt for an attachment."
800 (let ((file (read-file-name "Attach file: " nil nil t nil))
801 (description (string-read "Description: ")))
802 (my/header-attach-file file description)))
804 (defun my/header-attach-file (file description)
805 "Attach a FILE to the current message (works with Mutt).
806 Argument DESCRIPTION MIME description."
807 (interactive "fAttach file: \nsDescription: ")
808 (when (> (length file) 0)
813 (goto-char (point-min))
814 (search-forward-regexp "^$")
815 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
817 (message (concat "Attached '" file "'."))
818 (setq post-has-attachment t))))))
820 (setq mail-yank-prefix "> ")
824 #+BEGIN_SRC emacs-lisp
825 (use-package muttrc-mode
832 ** Use-package and load things
833 #+BEGIN_SRC emacs-lisp
839 ** Agenda Configuration
840 #+BEGIN_SRC emacs-lisp
841 ;; The following lines are always needed. Choose your own keys.
842 (add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode))
843 (global-set-key "\C-cl" 'org-store-link)
844 (global-set-key "\C-ca" 'org-agenda)
845 (global-set-key "\C-cb" 'org-iswitchb)
846 (setq-default org-log-done 'time)
847 (setq-default org-agenda-ndays 5)
849 ;; agenda configuration
850 ;; Do not dim blocked tasks
851 (setq org-agenda-dim-blocked-tasks nil)
852 (setq org-agenda-inhibit-startup t)
853 (setq org-agenda-use-tag-inheritance nil)
855 ;; Compact the block agenda view
856 (setq org-agenda-compact-blocks t)
858 ;; Custom agenda command definitions
859 (setq org-agenda-custom-commands
860 (quote (("N" "Notes" tags "NOTE"
861 ((org-agenda-overriding-header "Notes")
862 (org-tags-match-list-sublevels t)))
863 ("h" "Habits" tags-todo "STYLE=\"habit\""
864 ((org-agenda-overriding-header "Habits")
865 (org-agenda-sorting-strategy
866 '(todo-state-down effort-up category-keep))))
870 ((org-agenda-overriding-header "Tasks to Refile")
871 (org-tags-match-list-sublevels nil)))
872 (tags-todo "-CANCELLED/!"
873 ((org-agenda-overriding-header "Stuck Projects")
874 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
875 (org-agenda-sorting-strategy
877 (tags-todo "-HOLD-CANCELLED/!"
878 ((org-agenda-overriding-header "Projects")
879 (org-agenda-skip-function 'bh/skip-non-projects)
880 (org-tags-match-list-sublevels 'indented)
881 (org-agenda-sorting-strategy
883 (tags-todo "-CANCELLED/!NEXT"
884 ((org-agenda-overriding-header (concat "Project Next Tasks"
885 (if bh/hide-scheduled-and-waiting-next-tasks
887 " (including WAITING and SCHEDULED tasks)")))
888 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
889 (org-tags-match-list-sublevels t)
890 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
891 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
892 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
893 (org-agenda-sorting-strategy
894 '(todo-state-down effort-up category-keep))))
895 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
896 ((org-agenda-overriding-header (concat "Project Subtasks"
897 (if bh/hide-scheduled-and-waiting-next-tasks
899 " (including WAITING and SCHEDULED tasks)")))
900 (org-agenda-skip-function 'bh/skip-non-project-tasks)
901 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
902 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
903 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
904 (org-agenda-sorting-strategy
906 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
907 ((org-agenda-overriding-header (concat "Standalone Tasks"
908 (if bh/hide-scheduled-and-waiting-next-tasks
910 " (including WAITING and SCHEDULED tasks)")))
911 (org-agenda-skip-function 'bh/skip-project-tasks)
912 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
913 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
914 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
915 (org-agenda-sorting-strategy
917 (tags-todo "-CANCELLED+WAITING|HOLD/!"
918 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
919 (org-agenda-skip-function 'bh/skip-stuck-projects)
920 (org-tags-match-list-sublevels nil)
921 (org-agenda-todo-ignore-scheduled t)
922 (org-agenda-todo-ignore-deadlines t)))
924 ((org-agenda-overriding-header "Tasks to Archive")
925 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
926 (org-tags-match-list-sublevels nil))))
929 ; org mode agenda files
930 (setq org-agenda-files
931 (quote ("~/projects/org-notes/debbugs.org"
932 "~/projects/org-notes/notes.org"
933 "~/projects/org-notes/holidays.org"
934 "~/projects/org-notes/refile.org"
935 "~/projects/org-notes/diary.org"
936 "~/projects/org-notes/ool.org"
937 "~/projects/org-notes/sndservers.org"
938 "~/projects/org-notes/chaim.org"
939 "~/projects/org-notes/wildman.org"
940 "~/projects/org-notes/uddin.org"
941 "~/projects/org-notes/reviews.org"
942 "~/projects/org-notes/hpcbio.org"
943 "~/org-mode/from-mobile.org"
944 "~/projects/org-notes/fh.org")))
946 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
947 (set-register ?r (cons 'file "~/projects/org-notes/refile.org"))
948 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
949 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
950 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
951 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
952 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
953 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
954 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
955 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
956 (defun org-agenda-timeline-all (&optional arg)
959 (dolist (org-agenda-file org-agenda-files)
960 (insert-file-contents org-agenda-file nil)
963 (write-file "/tmp/timeline.org")
964 (org-agenda arg "L")))
965 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
966 ;; add automatic reminders for appointments
967 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
968 "Pressing `r' on the agenda will also add appointments."
970 (setq appt-time-msg-list nil)
971 (org-agenda-to-appt)))
975 #+BEGIN_SRC emacs-lisp
976 (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")))
977 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
979 (setq org-default-notes-file "~/projects/org-notes/notes.org")
980 (setq org-id-link-to-org-use-id 'use-existing)
983 #+BEGIN_SRC emacs-lisp
984 (setq org-capture-templates ;; mail-specific note template, identified by "m"
985 '(("m" "Mail" entry (file "~/projects/org-notes/refile.org")
986 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
987 ("t" "todo" entry (file "~/projects/org-notes/refile.org")
988 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
989 ("r" "respond" entry (file "~/projects/org-notes/refile.org")
990 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
991 ("n" "note" entry (file "~/projects/org-notes/refile.org")
992 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
993 ("s" "schedule" entry (file "~/projects/org-notes/refile.org")
994 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
995 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
996 "* %?\n%U\n" :clock-in t :clock-resume t)
997 ("w" "org-protocol" entry (file "~/projects/org-notes/refile.org")
998 "* TODO Review %c\n%U\n" :immediate-finish t)
999 ("M" "Meeting" entry (file "~/projects/org-notes/refile.org")
1000 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
1001 ("S" "Seminar" entry (file "~/projects/org-notes/refile.org")
1002 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
1003 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
1004 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
1005 ("p" "Phone call" entry (file "~/projects/org-notes/refile.org")
1006 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
1007 ("J" "job" entry (file "~/projects/org-notes/refile.org")
1008 "* TODO Apply for %a%? :job:\nSCHEDULED: %(format-time-string \"<%Y-%m-%d 17:00-17:30>\")\n%U\n%a\n" :clock-in t :clock-resume t)
1009 ("h" "Habit" entry (file "~/projects/org-notes/refile.org")
1010 "* 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")
1014 ;; Remove empty LOGBOOK drawers on clock out
1015 (defun bh/remove-empty-drawer-on-clock-out ()
1018 (beginning-of-line 0)
1019 (org-remove-empty-drawer-at (point))))
1021 (defun my/org-add-id ()
1024 (if (org-current-level)
1033 ** Org mode key bindings
1034 #+BEGIN_SRC emacs-lisp
1035 ; org mode configuration from http://doc.norang.ca/org-mode.html
1036 ;; Custom Key Bindings
1037 (global-set-key (kbd "<f12>") 'org-agenda)
1038 (global-set-key (kbd "<f5>") 'bh/org-todo)
1039 (global-set-key (kbd "<S-f5>") 'bh/widen)
1040 (global-set-key (kbd "<f7>") 'bh/set-truncate-lines)
1041 (global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
1042 (global-set-key (kbd "<f9> <f9>") 'bh/show-org-agenda)
1043 (global-set-key (kbd "<f9> b") 'bbdb)
1044 (global-set-key (kbd "<f9> c") 'calendar)
1045 (global-set-key (kbd "<f9> f") 'boxquote-insert-file)
1046 (global-set-key (kbd "<f9> h") 'bh/hide-other)
1047 (global-set-key (kbd "<f9> n") 'bh/toggle-next-task-display)
1048 (global-set-key (kbd "<f9> w") 'widen)
1050 ; change the outline mode prefix from C-c @ to C-c C-2
1051 (setq outline-minor-mode-prefix "C-c C-2")
1052 ;(add-hook 'outline-minor-mode-hook
1053 ; (lambda () (local-set-key (kbd "C-c C-2")
1054 ; outline-mode-prefix-map)))
1056 (global-set-key (kbd "<f9> I") 'bh/punch-in)
1057 (global-set-key (kbd "<f9> O") 'bh/punch-out)
1059 (global-set-key (kbd "<f9> o") 'bh/make-org-scratch)
1061 (global-set-key (kbd "<f9> r") 'boxquote-region)
1062 (global-set-key (kbd "<f9> s") 'bh/switch-to-scratch)
1064 (global-set-key (kbd "<f9> t") 'bh/insert-inactive-timestamp)
1065 (global-set-key (kbd "<f9> T") 'bh/toggle-insert-inactive-timestamp)
1067 (global-set-key (kbd "<f9> v") 'visible-mode)
1068 (global-set-key (kbd "<f9> l") 'org-toggle-link-display)
1069 (global-set-key (kbd "<f9> SPC") 'bh/clock-in-last-task)
1070 (global-set-key (kbd "C-<f9>") 'previous-buffer)
1071 (global-set-key (kbd "M-<f9>") 'org-toggle-inline-images)
1072 (global-set-key (kbd "C-x n r") 'narrow-to-region)
1073 (global-set-key (kbd "C-<f10>") 'next-buffer)
1074 (global-set-key (kbd "<f11>") 'org-clock-goto)
1075 (global-set-key (kbd "C-<f11>") 'org-clock-in)
1076 (global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)
1077 (global-set-key (kbd "C-c c") 'org-capture)
1080 ** Utility Functions
1081 #+BEGIN_SRC emacs-lisp
1082 (defun bh/hide-other ()
1085 (org-back-to-heading 'invisible-ok)
1091 (defun bh/set-truncate-lines ()
1092 "Toggle value of truncate-lines and refresh window display."
1094 (setq truncate-lines (not truncate-lines))
1095 ;; now refresh window display (an idiom from simple.el):
1097 (set-window-start (selected-window)
1098 (window-start (selected-window)))))
1100 (defun bh/make-org-scratch ()
1102 (find-file "/tmp/publish/scratch.org")
1103 (gnus-make-directory "/tmp/publish"))
1105 (defun bh/switch-to-scratch ()
1107 (switch-to-buffer "*scratch*"))
1109 (setq org-use-fast-todo-selection t)
1110 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1112 ; create function to create headlines in file. This comes from
1113 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
1114 (defun my/org-add-ids-to-headlines-in-file ()
1115 "Add ID properties to all headlines in the current file which
1116 do not already have one."
1118 (org-map-entries 'org-id-get-create))
1119 ; if we wanted to do this to every buffer, do the following:
1120 ; (add-hook 'org-mode-hook
1122 ; (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
1125 #+BEGIN_SRC emacs-lisp
1126 (setq org-todo-keywords
1127 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
1128 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
1130 (setq org-todo-keyword-faces
1131 (quote (("TODO" :foreground "red" :weight bold)
1132 ("NEXT" :foreground "blue" :weight bold)
1133 ("DONE" :foreground "forest green" :weight bold)
1134 ("WAITING" :foreground "orange" :weight bold)
1135 ("HOLD" :foreground "magenta" :weight bold)
1136 ("CANCELLED" :foreground "forest green" :weight bold)
1137 ("MEETING" :foreground "forest green" :weight bold)
1138 ("PHONE" :foreground "forest green" :weight bold))))
1140 (setq org-todo-state-tags-triggers
1141 (quote (("CANCELLED" ("CANCELLED" . t))
1142 ("WAITING" ("WAITING" . t))
1143 ("HOLD" ("WAITING") ("HOLD" . t))
1144 (done ("WAITING") ("HOLD"))
1145 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1146 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1147 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1151 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1152 ; add ids on creation of nodes
1153 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
1156 ; resolve clocks after 10 minutes of idle; use xprintidle
1157 ; (setq org-clock-idle-time 10)
1158 ; (setq org-clock-x11idle-program-name "xprintidle")
1160 ; this is from http://doc.norang.ca/org-mode.html#Capture
1161 ; use C-M-r for org mode capture
1162 (global-set-key (kbd "C-M-r") 'org-capture)
1164 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1165 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1166 (org-agenda-files :maxlevel . 9))))
1168 ; Use full outline paths for refile targets - we file directly with IDO
1169 (setq org-refile-use-outline-path t)
1171 ; Targets complete directly with IDO
1172 (setq org-outline-path-complete-in-steps nil)
1174 ; Allow refile to create parent tasks with confirmation
1175 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1177 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
1178 ; (setq org-completion-use-ido t)
1179 ; (setq ido-everywhere t)
1180 ; (setq ido-max-directory-size 100000)
1181 ; (ido-mode (quote both))
1182 ; ; Use the current window when visiting files and buffers with ido
1183 ; (setq ido-default-file-method 'selected-window)
1184 ; (setq ido-default-buffer-method 'selected-window)
1185 ; ; Use the current window for indirect buffer display
1186 ; (setq org-indirect-buffer-display 'current-window)
1189 ;;;; Refile settings
1190 ; Exclude DONE state tasks from refile targets
1191 (defun bh/verify-refile-target ()
1192 "Exclude todo keywords with a done state from refile targets"
1193 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
1195 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1197 ;; ensure that emacsclient will show just the note to be edited when invoked
1198 ;; from Mutt, and that it will shut down emacsclient once finished;
1199 ;; fallback to legacy behavior when not invoked via org-protocol.
1200 (require 'org-protocol)
1201 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
1202 (setq my-org-protocol-flag nil)
1203 (defadvice org-capture-finalize (after delete-frame-at-end activate)
1204 "Delete frame at remember finalization"
1205 (progn (if my-org-protocol-flag (delete-frame))
1206 (setq my-org-protocol-flag nil)))
1207 (defadvice org-capture-refile (around delete-frame-after-refile activate)
1208 "Delete frame at remember refile"
1209 (if my-org-protocol-flag
1211 (setq my-org-protocol-flag nil)
1216 (defadvice org-capture-kill (after delete-frame-at-end activate)
1217 "Delete frame at remember abort"
1218 (progn (if my-org-protocol-flag (delete-frame))
1219 (setq my-org-protocol-flag nil)))
1220 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
1221 (setq my-org-protocol-flag t))
1223 (defadvice org-insert-todo-heading (after dla/create-id activate)
1228 (add-to-list 'org-modules 'org-habit)
1230 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
1231 (defun open-mail-in-mutt (message)
1232 "Open a mail message in Mutt, using an external terminal.
1234 Message can be specified either by a path pointing inside a
1235 Maildir, or by Message-ID."
1236 (interactive "MPath or Message-ID: ")
1238 (format "faf xterm -e \"%s %s\""
1239 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
1241 ;; add support for "mutt:ID" links
1242 (org-add-link-type "mutt" 'open-mail-in-mutt)
1244 (defun my-org-mode-setup ()
1245 ; (load-library "reftex")
1246 (and (buffer-file-name)
1247 (file-exists-p (buffer-file-name))
1249 ; (reftex-parse-all)
1250 (reftex-set-cite-format
1251 '((?b . "[[bib:%l][%l-bib]]")
1252 (?n . "[[notes:%l][%l-notes]]")
1254 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
1256 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
1257 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
1258 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
1259 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
1261 (add-hook 'org-mode-hook 'my-org-mode-setup)
1263 (defun org-mode-reftex-search ()
1265 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
1267 (defun open-research-paper (bibtexkey)
1268 "Open a paper by bibtex key"
1269 (interactive "bibtex key: ")
1272 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1273 (org-add-link-type "papers" 'open-research-paper)
1274 (defun open-research-paper-pdf (bibtexkey)
1275 "Open a paper pdf by bibtex key"
1276 (interactive "bibtex key: ")
1278 (format "%s -p evince_annot %s"
1279 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1280 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
1282 (add-to-list 'org-link-abbrev-alist
1284 "~/projects/research/paper_notes.org::#%s"))
1286 ; I pretty much always want hiearchical checkboxes
1287 (setq org-hierachical-checkbox-statistics nil)
1289 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
1290 (add-to-list 'org-structure-template-alist
1291 '("E" "\\begin{equation}\n?\n\\end{equation}"))
1294 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
1295 (defun my-rtcite-export-handler (path desc format)
1296 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
1297 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
1298 (match-string 1 path)))
1299 (path (substring path 0 (match-beginning 0))))
1300 (cond ((eq format 'latex)
1302 (equal 0 (search "rtcite:" desc)))
1303 (format "\\cite{%s}" search)
1304 (format "\\cite[%s]{%s}" desc search))))))
1306 (org-add-link-type "rtcite"
1308 'my-rtcite-export-handler)
1312 ** Org Mobile Configuration
1313 #+BEGIN_SRC emacs-lisp
1314 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
1315 (when (string= system-name "linnode")
1316 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
1317 (setq-default org-directory "/home/don/org-mode/")
1318 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
1322 #+BEGIN_SRC emacs-lisp
1323 ;; org mode ical export
1324 (setq org-icalendar-timezone "America/Los_Angeles")
1325 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
1326 ;; we already add the id manually
1327 (setq org-icalendar-store-UID t)
1330 ** General Org Babel Configuration
1331 #+BEGIN_SRC emacs-lisp
1332 ;; org babel support
1333 (org-babel-do-load-languages
1334 'org-babel-load-languages
1341 ;; use graphviz-dot for dot things
1342 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
1343 ;; org-babel-by-backend
1344 (defmacro org-babel-by-backend (&rest body)
1345 `(case (if (boundp 'backend)
1346 (org-export-backend-name backend)
1349 (defun my/fix-inline-images ()
1350 (when org-inline-image-overlays
1351 (org-redisplay-inline-images)))
1353 (add-hook 'org-babel-after-execute-hook
1354 'my/fix-inline-images)
1357 ** LaTeX configuration
1359 :ID: 7135ba17-6a50-4eed-84ca-b90afa5b12f8
1361 #+BEGIN_SRC emacs-lisp
1363 (add-to-list 'org-latex-classes
1365 "\\documentclass[11pt,oneside,article]{memoir}\n"
1366 ("\\section{%s}" . "\\section*{%s}")
1367 ("\\subsection{%s}" . "\\subsection*{%s}")
1368 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1369 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1370 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1372 (setq org-beamer-outline-frame-options "")
1373 (add-to-list 'org-latex-classes
1375 "\\documentclass[ignorenonframetext]{beamer}
1376 [NO-DEFAULT-PACKAGES]
1379 ("\\section{%s}" . "\\section*{%s}")
1380 ("\\subsection{%s}" . "\\subsection*{%s}")
1381 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1382 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1383 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1385 (add-to-list 'org-latex-classes
1387 "\\documentclass[11pt,oneside]{memoir}\n"
1388 ("\\chapter{%s}" . "\\chapter*{%s}")
1389 ("\\section{%s}" . "\\section*{%s}")
1390 ("\\subsection{%s}" . "\\subsection*{%s}")
1391 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
1393 (add-to-list 'org-latex-classes
1395 "\\documentclass[11pt]{letter}
1396 [NO-DEFAULT-PACKAGES]
1399 ("\\section{%s}" . "\\section*{%s}")
1400 ("\\subsection{%s}" . "\\subsection*{%s}")
1401 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1402 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1403 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1405 (add-to-list 'org-latex-classes
1407 "\\documentclass{dlacv}
1408 [NO-DEFAULT-PACKAGES]
1411 ("\\section{%s}" . "\\section*{%s}")
1412 ("\\subsection{%s}" . "\\subsection*{%s}")
1413 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1414 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1415 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1418 (add-to-list 'org-latex-classes
1420 "\\documentclass{dlaresume}
1421 [NO-DEFAULT-PACKAGES]
1424 ("\\section{%s}" . "\\section*{%s}")
1425 ("\\subsection{%s}" . "\\subsection*{%s}")
1426 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1427 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1428 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1431 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
1432 ;; but adapted to use latexmk 4.22 or higher.
1433 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
1435 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
1436 (setq org-latex-default-packages-alist
1438 ("" "unicode-math" t)
1440 (setq org-latex-packages-alist
1447 ("" "longtable" nil)
1450 ;; make equations larger
1451 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
1453 (defun org-create-formula--latex-header ()
1454 "Return LaTeX header appropriate for previewing a LaTeX snippet."
1455 (let ((info (org-combine-plists (org-export--get-global-options
1456 (org-export-get-backend 'latex))
1457 (org-export--get-inbuffer-options
1458 (org-export-get-backend 'latex)))))
1459 (org-latex-guess-babel-language
1460 (org-latex-guess-inputenc
1461 (org-splice-latex-header
1462 org-format-latex-header
1463 org-latex-default-packages-alist
1465 (plist-get info :latex-header)))
1469 ; support ignoring headers in org mode export to latex
1470 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
1471 (defadvice org-latex-headline (around my-latex-skip-headlines
1472 (headline contents info) activate)
1473 (if (member "ignoreheading" (org-element-property :tags headline))
1474 (setq ad-return-value contents)
1477 ;; keep latex logfiles
1479 (setq org-latex-remove-logfiles nil)
1481 ;; Resume clocking task when emacs is restarted
1482 (org-clock-persistence-insinuate)
1484 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
1485 (setq org-clock-history-length 23)
1486 ;; Resume clocking task on clock-in if the clock is open
1487 (setq org-clock-in-resume t)
1488 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
1489 ;; there are things like PHONE calls
1490 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
1491 ;; Separate drawers for clocking and logs
1492 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
1493 ;; Save clock data and state changes and notes in the LOGBOOK drawer
1494 (setq org-clock-into-drawer t)
1495 (setq org-log-into-drawer t)
1496 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
1497 (setq org-clock-out-remove-zero-time-clocks t)
1498 ;; Clock out when moving task to a done state
1499 (setq org-clock-out-when-done t)
1500 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
1501 (setq org-clock-persist t)
1502 ;; Do not prompt to resume an active clock
1503 (setq org-clock-persist-query-resume nil)
1504 ;; Enable auto clock resolution for finding open clocks
1505 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
1506 ;; Include current clocking task in clock reports
1507 (setq org-clock-report-include-clocking-task t)
1509 ;; the cache seems to be broken
1510 (setq org-element-use-cache nil)
1512 (defvar bh/keep-clock-running nil)
1514 (defun bh/is-task-p ()
1515 "Any task with a todo keyword and no subtask"
1519 (subtree-end (save-excursion (org-end-of-subtree t)))
1520 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1523 (while (and (not has-subtask)
1524 (< (point) subtree-end)
1525 (re-search-forward "^\*+ " subtree-end t))
1526 (when (member (org-get-todo-state) org-todo-keywords-1)
1527 (setq has-subtask t))))
1528 (and is-a-task (not has-subtask)))))
1529 (defun bh/is-project-p ()
1530 "Any task with a todo keyword subtask"
1534 (subtree-end (save-excursion (org-end-of-subtree t)))
1535 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1538 (while (and (not has-subtask)
1539 (< (point) subtree-end)
1540 (re-search-forward "^\*+ " subtree-end t))
1541 (when (member (org-get-todo-state) org-todo-keywords-1)
1542 (setq has-subtask t))))
1543 (and is-a-task has-subtask))))
1545 (defun bh/is-subproject-p ()
1546 "Any task which is a subtask of another project"
1547 (let ((is-subproject)
1548 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1550 (while (and (not is-subproject) (org-up-heading-safe))
1551 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1552 (setq is-subproject t))))
1553 (and is-a-task is-subproject)))
1556 (defun bh/clock-in-to-next (kw)
1557 "Switch a task from TODO to NEXT when clocking in.
1558 Skips capture tasks, projects, and subprojects.
1559 Switch projects and subprojects from NEXT back to TODO"
1560 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
1562 ((and (member (org-get-todo-state) (list "TODO"))
1565 ((and (member (org-get-todo-state) (list "NEXT"))
1569 (defun bh/punch-in (arg)
1570 "Start continuous clocking and set the default task to the
1571 selected task. If no task is selected set the Organization task
1572 as the default task."
1574 (setq bh/keep-clock-running t)
1575 (if (equal major-mode 'org-agenda-mode)
1577 ;; We're in the agenda
1579 (let* ((marker (org-get-at-bol 'org-hd-marker))
1580 (tags (org-with-point-at marker (org-get-tags-at))))
1581 (if (and (eq arg 4) tags)
1582 (org-agenda-clock-in '(16))
1583 (bh/clock-in-organization-task-as-default)))
1585 ;; We are not in the agenda
1589 ; Find the tags on the current task
1590 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
1591 (org-clock-in '(16))
1592 (bh/clock-in-organization-task-as-default)))))
1594 (defun bh/punch-out ()
1596 (setq bh/keep-clock-running nil)
1597 (when (org-clock-is-active)
1599 (org-agenda-remove-restriction-lock))
1601 (defun bh/clock-in-default-task ()
1603 (org-with-point-at org-clock-default-task
1606 (defun bh/clock-in-parent-task ()
1607 "Move point to the parent (project) task if any and clock in"
1608 (let ((parent-task))
1612 (while (and (not parent-task) (org-up-heading-safe))
1613 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1614 (setq parent-task (point))))
1616 (org-with-point-at parent-task
1618 (when bh/keep-clock-running
1619 (bh/clock-in-default-task)))))))
1621 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
1623 (defun bh/clock-in-organization-task-as-default ()
1625 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
1626 (org-clock-in '(16))))
1628 (defun bh/clock-out-maybe ()
1629 (when (and bh/keep-clock-running
1630 (not org-clock-clocking-in)
1631 (marker-buffer org-clock-default-task)
1632 (not org-clock-resolving-clocks-due-to-idleness))
1633 (bh/clock-in-parent-task)))
1635 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1638 (defun bh/clock-in-task-by-id (id)
1639 "Clock in a task by id"
1640 (org-with-point-at (org-id-find id 'marker)
1641 (org-clock-in nil)))
1643 (defun bh/clock-in-last-task (arg)
1644 "Clock in the interrupted task if there is one
1645 Skip the default task and get the next one.
1646 A prefix arg forces clock in of the default task."
1648 (let ((clock-in-to-task
1650 ((eq arg 4) org-clock-default-task)
1651 ((and (org-clock-is-active)
1652 (equal org-clock-default-task (cadr org-clock-history)))
1653 (caddr org-clock-history))
1654 ((org-clock-is-active) (cadr org-clock-history))
1655 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
1656 (t (car org-clock-history)))))
1658 (org-with-point-at clock-in-to-task
1659 (org-clock-in nil))))
1662 (defun org-export-to-ods ()
1664 (let ((csv-file "data.csv"))
1665 (org-table-export csv-file "orgtbl-to-csv")
1666 (org-odt-convert csv-file "ods" 'open)))
1668 ; allow for zero-width-space to be a break in regexp too
1669 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
1670 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
1671 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
1673 ;; support inserting screen shots
1674 (defun my/org-insert-screenshot ()
1675 "Take a screenshot into a time stamped unique-named file in the
1676 same directory as the org-buffer and insert a link to this file."
1678 (defvar my/org-insert-screenshot/filename)
1679 (setq my/org-insert-screenshot/filename
1681 "Screenshot to insert: "
1683 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
1686 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
1687 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
1688 (org-display-inline-images))
1690 (defun my/fix-inline-images ()
1691 (when org-inline-image-overlays
1692 (org-redisplay-inline-images)))
1694 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
1696 ;; use xelatex to preview with imagemagick
1697 (add-to-list 'org-preview-latex-process-alist
1698 '(xelateximagemagick
1699 :programs ("xelatex" "convert")
1700 :description "pdf > png"
1701 :message "you need to install xelatex and imagemagick"
1703 :image-input-type "pdf"
1704 :image-output-type "png"
1705 :image-size-adjust (1.0 . 1.0)
1706 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
1707 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
1709 ;; use xelatex by default
1710 (setq org-preview-latex-default-process 'xelateximagemagick)
1712 ; from http://orgmode.org/Changes.html
1713 (defun my/org-repair-property-drawers ()
1714 "Fix properties drawers in current buffer.
1715 Ignore non Org buffers."
1717 (when (eq major-mode 'org-mode)
1718 (org-with-wide-buffer
1719 (goto-char (point-min))
1720 (let ((case-fold-search t)
1721 (inline-re (and (featurep 'org-inlinetask)
1722 (concat (org-inlinetask-outline-regexp)
1726 (unless (and inline-re (org-looking-at-p inline-re))
1728 (let ((end (save-excursion (outline-next-heading) (point))))
1730 (when (org-looking-at-p org-planning-line-re) (forward-line))
1731 (when (and (< (point) end)
1732 (not (org-looking-at-p org-property-drawer-re))
1734 (and (re-search-forward org-property-drawer-re end t)
1735 (eq (org-element-type
1736 (save-match-data (org-element-at-point)))
1738 (insert (delete-and-extract-region
1740 (min (1+ (match-end 0)) end)))
1741 (unless (bolp) (insert "\n"))))))))))))
1745 #+BEGIN_SRC emacs-lisp
1749 (use-package calfw-org
1752 (use-package org-gcal
1754 :config '((if (file-readable-p "~/.hide/org_gcal.el")
1755 (load-file "~/.hide/org_gcal.el"))
1760 #+BEGIN_SRC emacs-lisp
1764 ** Override other things
1765 #+BEGIN_SRC emacs-lisp
1766 ; apparently things like to step on C-;, so we'll use a hack from
1767 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
1769 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
1772 (define-key my-keys-minor-mode-map (kbd "C-;") 'mc/mark-all-dwim)
1773 ;; use outline mode keybindings everywhere
1774 ;; (define-key my-keys-minor-mode-map (kbd "C-;") 'my/mydra-outline/body)
1776 (define-minor-mode my-keys-minor-mode
1777 "A minor mode so that my key settings override annoying major modes."
1778 t " my-keys" 'my-keys-minor-mode-map)
1780 (my-keys-minor-mode 1)
1781 (defun my-minibuffer-setup-hook ()
1782 (my-keys-minor-mode 0))
1784 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
1785 (defadvice load (after give-my-keybindings-priority)
1786 "Try to ensure that my keybindings always have priority."
1787 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
1788 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
1789 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
1790 (add-to-list 'minor-mode-map-alist mykeys))))
1794 #+BEGIN_SRC emacs-lisp
1795 (global-unset-key "\M-g")
1796 (global-set-key (kbd "M-g l") 'goto-line)
1798 * Misc (uncharacterized)
1799 #+BEGIN_SRC emacs-lisp
1800 (setq calendar-latitude 40.11)
1801 (setq calendar-longitude -88.24)
1802 (setq case-fold-search t)
1803 (setq confirm-kill-emacs (quote y-or-n-p))
1804 (setq cperl-lazy-help-time nil)
1805 (setq debian-changelog-mailing-address "don@debian.org")
1807 (setq display-time-24hr-format t)
1808 (setq display-time-day-and-date t)
1809 (display-time-mode 1)
1810 (global-auto-revert-mode 1)
1811 (global-font-lock-mode 1)
1813 (setq log-edit-keep-buffer t)
1814 (setq mail-user-agent (quote sendmail-user-agent))
1815 (setq markdown-enable-math t)
1816 (setq markdown-follow-wiki-link-on-enter nil)
1817 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
1818 (setq ps-footer-font-size (quote (8 . 10)))
1819 (setq ps-header-font-size (quote (8 . 10)))
1820 (setq ps-header-title-font-size (quote (10 . 10)))
1821 (setq ps-line-number-color "blue")
1822 (setq ps-print-footer t)
1823 (setq ps-print-footer-frame nil)
1824 (setq ps-print-only-one-header t)
1825 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
1827 (setq sentence-end-double-space nil)
1828 ; enable matching parenthesis
1831 (setq user-mail-address "don@donarmstrong.com")
1832 (setq vc-delete-logbuf-window nil)
1833 (setq vc-follow-symlinks t)
1835 ;; use git before SVN; use CVS earlier, because I have CVS
1836 ;; repositories inside of git directories
1837 (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
1839 ;; switch back to the old primary selection method
1840 (setq x-select-enable-clipboard nil)
1841 (setq x-select-enable-primary t)
1842 ; (setq mouse-drag-copy-region t)
1844 (fset 'perl-mode 'cperl-mode)
1845 ;;(load-file "cperl-mode.el")
1849 (global-set-key "\C-xp" 'server-edit)
1851 (setq-default auto-mode-alist (cons '("\.wml$" .
1852 (lambda () (html-mode) (auto-fill-mode)))
1856 ; use markdown mode for mdwn files
1857 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
1858 (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
1861 ;; tramp configuration
1862 (setq tramp-use-ssh-controlmaster-options nil)
1864 ;; self-insert-command hack.
1865 ;; Without this, "if<SP>" expands to
1868 ;; which really should be,
1874 ;(load-library "php-mode")
1876 (setq-default c-indent-level 4)
1877 (setq-default c-brace-imaginary-offset 0)
1878 (setq-default c-brace-offset -4)
1879 (setq-default c-argdecl-indent 4)
1880 (setq-default c-label-offset -4)
1881 (setq-default c-continued-statement-offset 4)
1883 (setq-default indent-tabs-mode nil)
1884 (setq-default tab-width 4)
1887 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
1888 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
1889 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
1890 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
1891 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
1894 (defun insert-date ()
1895 "Insert date at point."
1897 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
1898 (global-set-key "\C-[d" 'insert-date)
1900 (defun unfill-paragraph (arg)
1901 "Pull this whole paragraph up onto one line."
1903 (let ((fill-column 10000))
1904 (fill-paragraph arg))
1907 (column-number-mode t)
1909 ; (require 'mode-compile)
1911 (defadvice server-process-filter (after post-mode-message first activate)
1912 "If the buffer is in post mode, overwrite the server-edit
1913 message with a post-save-current-buffer-and-exit message."
1914 (if (eq major-mode 'post-mode)
1916 (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done."))))
1917 ; This is also needed to see the magic message. Set to a higher
1918 ; number if you have a faster computer or read slower than me.
1919 '(font-lock-verbose 1000)
1920 ;(setq-default server-temp-file-regexp "mutt\(-\|ng-\)")
1921 ; (add-hook 'server-switch-hook
1922 ; (function (lambda()
1923 ; (cond ((string-match "Post" mode-name)
1924 ; (post-goto-body)))
1925 ; set-buffer-file-coding-system 'utf-8
1929 (add-hook 'post-mode-hook
1930 (auto-fill-mode nil)
1932 ; abbrev mode settings
1933 ; load abbreviations from
1934 (setq abbrev-file-name
1935 "~/.emacs_abbrev_def")
1937 ; read the abbrev file if it exists
1938 (if (file-exists-p abbrev-file-name)
1939 (quietly-read-abbrev-file))
1941 ; for now, use abbrev mode everywhere
1942 (setq default-abbrev-mode t)
1945 (defun insert-function-documentation ()
1946 "Insert function documentation"
1948 (insert-file-contents "/home/don/lib/templates/perl_function_documentation" nil))
1949 (global-set-key "\M-f" 'insert-function-documentation)
1951 (eval-after-load "lilypond-mode"
1953 (load-library "lyqi-mode")
1954 (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
1956 (autoload 'spamassassin-mode "spamassassin-mode" nil t)
1958 (desktop-load-default)
1960 '(icomplete-mode on)
1962 ;; custom-set-faces was added by Custom.
1963 ;; If you edit it by hand, you could mess it up, so be careful.
1964 ;; Your init file should contain only one such instance.
1965 ;; If there is more than one, they won't work right.
1966 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
1969 (put 'upcase-region 'disabled nil)
1970 (put 'downcase-region 'disabled nil)
1971 (put 'narrow-to-region 'disabled nil)
1973 ; (defun turn-on-flyspell ()
1974 ; "Force flyspell-mode on using a positive arg. For use in hooks."
1976 ; (flyspell-mode 1))
1979 ; Outline-minor-mode key map
1980 (define-prefix-command 'cm-map nil "Outline-")
1982 (define-key cm-map "q" 'hide-sublevels) ; Hide everything but the top-level headings
1983 (define-key cm-map "t" 'hide-body) ; Hide everything but headings (all body lines)
1984 (define-key cm-map "o" 'hide-other) ; Hide other branches
1985 (define-key cm-map "c" 'hide-entry) ; Hide this entry's body
1986 (define-key cm-map "l" 'hide-leaves) ; Hide body lines in this entry and sub-entries
1987 (define-key cm-map "d" 'hide-subtree) ; Hide everything in this entry and sub-entries
1989 (define-key cm-map "a" 'show-all) ; Show (expand) everything
1990 (define-key cm-map "e" 'show-entry) ; Show this heading's body
1991 (define-key cm-map "i" 'show-children) ; Show this heading's immediate child sub-headings
1992 (define-key cm-map "k" 'show-branches) ; Show all sub-headings under this heading
1993 (define-key cm-map "s" 'show-subtree) ; Show (expand) everything in this heading & below
1995 (define-key cm-map "u" 'outline-up-heading) ; Up
1996 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
1997 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
1998 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
1999 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
2000 (global-set-key "\M-o" cm-map)
2004 (setq-default debian-changelog-mailing-address "don@debian.org")
2005 (setq-default debian-changelog-full-name "Don Armstrong")
2007 ; ediff configuration
2008 ; don't use the multi-window configuration
2009 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
2011 ; fix up css mode to not be silly
2012 ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
2013 (setq cssm-indent-level 4)
2014 (setq cssm-newline-before-closing-bracket t)
2015 (setq cssm-indent-function #'cssm-c-style-indenter)
2016 (setq cssm-mirror-mode nil)
2018 (require 'multi-web-mode)
2019 (setq mweb-default-major-mode 'html-mode)
2020 (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
2021 (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
2022 (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
2023 (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
2024 (multi-web-global-mode 1)
2026 ;;; alias the new `flymake-report-status-slim' to
2027 ;;; `flymake-report-status'
2028 (defalias 'flymake-report-status 'flymake-report-status-slim)
2029 (defun flymake-report-status-slim (e-w &optional status)
2030 "Show \"slim\" flymake status in mode line."
2032 (setq flymake-mode-line-e-w e-w))
2034 (setq flymake-mode-line-status status))
2035 (let* ((mode-line " Φ"))
2036 (when (> (length flymake-mode-line-e-w) 0)
2037 (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
2038 (setq mode-line (concat mode-line flymake-mode-line-status))
2039 (setq flymake-mode-line mode-line)
2040 (force-mode-line-update)))
2042 ; load sql-indent when sql is loaded
2043 (eval-after-load "sql"
2044 '(load-library "sql-indent"))
2046 ; fix up tmux xterm keys
2047 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
2048 (defun fix-up-tmux-keys ()
2049 "Fix up tmux xterm keys"
2052 (let ((x 2) (tkey ""))
2072 ;; ctrl + alt + shift
2074 (setq tkey "C-M-S-"))
2077 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
2078 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
2079 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
2080 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
2082 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
2084 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
2086 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
2088 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
2090 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2092 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2094 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
2096 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
2098 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
2100 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
2102 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
2104 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
2106 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
2108 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
2110 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
2112 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
2114 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
2116 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
2118 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
2120 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
2122 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
2124 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
2126 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
2128 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
2130 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
2132 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
2139 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
2141 ; procmailmode configuration
2142 (load "procmail_mode")
2144 (load "mode-line-cleaner")
2146 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
2147 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
2148 (if (or (buffer-modified-p)
2149 (verify-visited-file-modtime)
2150 (< (* 8 1024 1024) (buffer-size))
2151 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
2153 (clear-visited-file-modtime)
2155 (ad-activate 'ask-user-about-supersession-threat)
2157 ; apparently things like to step on C-;, so we'll use a hack from
2158 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
2160 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
2162 ; use iedit everywhere
2163 (define-key my-keys-minor-mode-map (kbd "C-;") 'mc/mark-all-dwim)
2165 (define-minor-mode my-keys-minor-mode
2166 "A minor mode so that my key settings override annoying major modes."
2167 t " my-keys" 'my-keys-minor-mode-map)
2169 (my-keys-minor-mode 1)
2170 (defun my-minibuffer-setup-hook ()
2171 (my-keys-minor-mode 0))
2173 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
2174 (defadvice load (after give-my-keybindings-priority)
2175 "Try to ensure that my keybindings always have priority."
2176 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
2177 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
2178 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
2179 (add-to-list 'minor-mode-map-alist mykeys))))
2181 (global-set-key "\M- " 'hippie-expand)
2186 #+BEGIN_SRC emacs-lisp
2187 (unless (server-running-p)
2194 #+BEGIN_SRC emacs-lisp
2195 (provide 'don-configuration)