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
786 (defun my-message-mode-settings ()
787 (font-lock-add-keywords nil
788 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
789 (0 'message-multiply-quoted-text-face))
790 ("^[ \t]*>[ \t]*>.*$"
791 (0 'message-double-quoted-text-face))))
792 (local-set-key (kbd "C-c C-a") 'my-post-attach-file)
795 (defun my-post-attach-file ()
796 "Prompt for an attachment."
798 (let ((file (read-file-name "Attach file: " nil nil t nil))
799 (description (string-read "Description: ")))
800 (my-header-attach-file file description)))
802 (symbol-function 'my-post-attach-file)
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))))))
822 (setq mail-yank-prefix "> ")
826 #+BEGIN_SRC emacs-lisp
827 (use-package muttrc-mode
834 ** Use-package and load things
835 #+BEGIN_SRC emacs-lisp
841 ** Agenda Configuration
842 #+BEGIN_SRC emacs-lisp
843 ;; The following lines are always needed. Choose your own keys.
844 (add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode))
845 (global-set-key "\C-cl" 'org-store-link)
846 (global-set-key "\C-ca" 'org-agenda)
847 (global-set-key "\C-cb" 'org-iswitchb)
848 (setq-default org-log-done 'time)
849 (setq-default org-agenda-ndays 5)
851 ;; agenda configuration
852 ;; Do not dim blocked tasks
853 (setq org-agenda-dim-blocked-tasks nil)
854 (setq org-agenda-inhibit-startup t)
855 (setq org-agenda-use-tag-inheritance nil)
857 ;; Compact the block agenda view
858 (setq org-agenda-compact-blocks t)
860 ;; Custom agenda command definitions
861 (setq org-agenda-custom-commands
862 (quote (("N" "Notes" tags "NOTE"
863 ((org-agenda-overriding-header "Notes")
864 (org-tags-match-list-sublevels t)))
865 ("h" "Habits" tags-todo "STYLE=\"habit\""
866 ((org-agenda-overriding-header "Habits")
867 (org-agenda-sorting-strategy
868 '(todo-state-down effort-up category-keep))))
872 ((org-agenda-overriding-header "Tasks to Refile")
873 (org-tags-match-list-sublevels nil)))
874 (tags-todo "-CANCELLED/!"
875 ((org-agenda-overriding-header "Stuck Projects")
876 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
877 (org-agenda-sorting-strategy
879 (tags-todo "-HOLD-CANCELLED/!"
880 ((org-agenda-overriding-header "Projects")
881 (org-agenda-skip-function 'bh/skip-non-projects)
882 (org-tags-match-list-sublevels 'indented)
883 (org-agenda-sorting-strategy
885 (tags-todo "-CANCELLED/!NEXT"
886 ((org-agenda-overriding-header (concat "Project Next Tasks"
887 (if bh/hide-scheduled-and-waiting-next-tasks
889 " (including WAITING and SCHEDULED tasks)")))
890 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
891 (org-tags-match-list-sublevels t)
892 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
893 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
894 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
895 (org-agenda-sorting-strategy
896 '(todo-state-down effort-up category-keep))))
897 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
898 ((org-agenda-overriding-header (concat "Project Subtasks"
899 (if bh/hide-scheduled-and-waiting-next-tasks
901 " (including WAITING and SCHEDULED tasks)")))
902 (org-agenda-skip-function 'bh/skip-non-project-tasks)
903 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
904 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
905 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
906 (org-agenda-sorting-strategy
908 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
909 ((org-agenda-overriding-header (concat "Standalone Tasks"
910 (if bh/hide-scheduled-and-waiting-next-tasks
912 " (including WAITING and SCHEDULED tasks)")))
913 (org-agenda-skip-function 'bh/skip-project-tasks)
914 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
915 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
916 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
917 (org-agenda-sorting-strategy
919 (tags-todo "-CANCELLED+WAITING|HOLD/!"
920 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
921 (org-agenda-skip-function 'bh/skip-stuck-projects)
922 (org-tags-match-list-sublevels nil)
923 (org-agenda-todo-ignore-scheduled t)
924 (org-agenda-todo-ignore-deadlines t)))
926 ((org-agenda-overriding-header "Tasks to Archive")
927 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
928 (org-tags-match-list-sublevels nil))))
931 ; org mode agenda files
932 (setq org-agenda-files
933 (quote ("~/projects/org-notes/debbugs.org"
934 "~/projects/org-notes/notes.org"
935 "~/projects/org-notes/holidays.org"
936 "~/projects/org-notes/refile.org"
937 "~/projects/org-notes/diary.org"
938 "~/projects/org-notes/ool.org"
939 "~/projects/org-notes/sndservers.org"
940 "~/projects/org-notes/chaim.org"
941 "~/projects/org-notes/wildman.org"
942 "~/projects/org-notes/uddin.org"
943 "~/projects/org-notes/reviews.org"
944 "~/projects/org-notes/hpcbio.org"
945 "~/org-mode/from-mobile.org"
946 "~/projects/org-notes/fh.org")))
948 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
949 (set-register ?r (cons 'file "~/projects/org-notes/refile.org"))
950 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
951 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
952 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
953 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
954 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
955 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
956 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
957 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
958 (defun org-agenda-timeline-all (&optional arg)
961 (dolist (org-agenda-file org-agenda-files)
962 (insert-file-contents org-agenda-file nil)
965 (write-file "/tmp/timeline.org")
966 (org-agenda arg "L")))
967 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
968 ;; add automatic reminders for appointments
969 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
970 "Pressing `r' on the agenda will also add appointments."
972 (setq appt-time-msg-list nil)
973 (org-agenda-to-appt)))
977 #+BEGIN_SRC emacs-lisp
978 (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")))
979 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
981 (setq org-default-notes-file "~/projects/org-notes/notes.org")
982 (setq org-id-link-to-org-use-id 'use-existing)
985 #+BEGIN_SRC emacs-lisp
986 (setq org-capture-templates ;; mail-specific note template, identified by "m"
987 '(("m" "Mail" entry (file "~/projects/org-notes/refile.org")
988 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
989 ("t" "todo" entry (file "~/projects/org-notes/refile.org")
990 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
991 ("r" "respond" entry (file "~/projects/org-notes/refile.org")
992 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
993 ("n" "note" entry (file "~/projects/org-notes/refile.org")
994 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
995 ("s" "schedule" entry (file "~/projects/org-notes/refile.org")
996 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
997 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
998 "* %?\n%U\n" :clock-in t :clock-resume t)
999 ("w" "org-protocol" entry (file "~/projects/org-notes/refile.org")
1000 "* TODO Review %c\n%U\n" :immediate-finish t)
1001 ("M" "Meeting" entry (file "~/projects/org-notes/refile.org")
1002 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
1003 ("S" "Seminar" entry (file "~/projects/org-notes/refile.org")
1004 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
1005 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
1006 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
1007 ("p" "Phone call" entry (file "~/projects/org-notes/refile.org")
1008 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
1009 ("J" "job" entry (file "~/projects/org-notes/refile.org")
1010 "* 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)
1011 ("h" "Habit" entry (file "~/projects/org-notes/refile.org")
1012 "* 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")
1016 ;; Remove empty LOGBOOK drawers on clock out
1017 (defun bh/remove-empty-drawer-on-clock-out ()
1020 (beginning-of-line 0)
1021 (org-remove-empty-drawer-at (point))))
1023 (defun my/org-add-id ()
1026 (if (org-current-level)
1035 ** Org mode key bindings
1036 #+BEGIN_SRC emacs-lisp
1037 ; org mode configuration from http://doc.norang.ca/org-mode.html
1038 ;; Custom Key Bindings
1039 (global-set-key (kbd "<f12>") 'org-agenda)
1040 (global-set-key (kbd "<f5>") 'bh/org-todo)
1041 (global-set-key (kbd "<S-f5>") 'bh/widen)
1042 (global-set-key (kbd "<f7>") 'bh/set-truncate-lines)
1043 (global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
1044 (global-set-key (kbd "<f9> <f9>") 'bh/show-org-agenda)
1045 (global-set-key (kbd "<f9> b") 'bbdb)
1046 (global-set-key (kbd "<f9> c") 'calendar)
1047 (global-set-key (kbd "<f9> f") 'boxquote-insert-file)
1048 (global-set-key (kbd "<f9> h") 'bh/hide-other)
1049 (global-set-key (kbd "<f9> n") 'bh/toggle-next-task-display)
1050 (global-set-key (kbd "<f9> w") 'widen)
1052 ; change the outline mode prefix from C-c @ to C-c C-2
1053 (setq outline-minor-mode-prefix "C-c C-2")
1054 ;(add-hook 'outline-minor-mode-hook
1055 ; (lambda () (local-set-key (kbd "C-c C-2")
1056 ; outline-mode-prefix-map)))
1058 (global-set-key (kbd "<f9> I") 'bh/punch-in)
1059 (global-set-key (kbd "<f9> O") 'bh/punch-out)
1061 (global-set-key (kbd "<f9> o") 'bh/make-org-scratch)
1063 (global-set-key (kbd "<f9> r") 'boxquote-region)
1064 (global-set-key (kbd "<f9> s") 'bh/switch-to-scratch)
1066 (global-set-key (kbd "<f9> t") 'bh/insert-inactive-timestamp)
1067 (global-set-key (kbd "<f9> T") 'bh/toggle-insert-inactive-timestamp)
1069 (global-set-key (kbd "<f9> v") 'visible-mode)
1070 (global-set-key (kbd "<f9> l") 'org-toggle-link-display)
1071 (global-set-key (kbd "<f9> SPC") 'bh/clock-in-last-task)
1072 (global-set-key (kbd "C-<f9>") 'previous-buffer)
1073 (global-set-key (kbd "M-<f9>") 'org-toggle-inline-images)
1074 (global-set-key (kbd "C-x n r") 'narrow-to-region)
1075 (global-set-key (kbd "C-<f10>") 'next-buffer)
1076 (global-set-key (kbd "<f11>") 'org-clock-goto)
1077 (global-set-key (kbd "C-<f11>") 'org-clock-in)
1078 (global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)
1079 (global-set-key (kbd "C-c c") 'org-capture)
1082 ** Utility Functions
1083 #+BEGIN_SRC emacs-lisp
1084 (defun bh/hide-other ()
1087 (org-back-to-heading 'invisible-ok)
1093 (defun bh/set-truncate-lines ()
1094 "Toggle value of truncate-lines and refresh window display."
1096 (setq truncate-lines (not truncate-lines))
1097 ;; now refresh window display (an idiom from simple.el):
1099 (set-window-start (selected-window)
1100 (window-start (selected-window)))))
1102 (defun bh/make-org-scratch ()
1104 (find-file "/tmp/publish/scratch.org")
1105 (gnus-make-directory "/tmp/publish"))
1107 (defun bh/switch-to-scratch ()
1109 (switch-to-buffer "*scratch*"))
1111 (setq org-use-fast-todo-selection t)
1112 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1114 ; create function to create headlines in file. This comes from
1115 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
1116 (defun my/org-add-ids-to-headlines-in-file ()
1117 "Add ID properties to all headlines in the current file which
1118 do not already have one."
1120 (org-map-entries 'org-id-get-create))
1121 ; if we wanted to do this to every buffer, do the following:
1122 ; (add-hook 'org-mode-hook
1124 ; (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
1127 #+BEGIN_SRC emacs-lisp
1128 (setq org-todo-keywords
1129 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
1130 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
1132 (setq org-todo-keyword-faces
1133 (quote (("TODO" :foreground "red" :weight bold)
1134 ("NEXT" :foreground "blue" :weight bold)
1135 ("DONE" :foreground "forest green" :weight bold)
1136 ("WAITING" :foreground "orange" :weight bold)
1137 ("HOLD" :foreground "magenta" :weight bold)
1138 ("CANCELLED" :foreground "forest green" :weight bold)
1139 ("MEETING" :foreground "forest green" :weight bold)
1140 ("PHONE" :foreground "forest green" :weight bold))))
1142 (setq org-todo-state-tags-triggers
1143 (quote (("CANCELLED" ("CANCELLED" . t))
1144 ("WAITING" ("WAITING" . t))
1145 ("HOLD" ("WAITING") ("HOLD" . t))
1146 (done ("WAITING") ("HOLD"))
1147 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1148 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1149 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1153 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1154 ; add ids on creation of nodes
1155 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
1158 ; resolve clocks after 10 minutes of idle; use xprintidle
1159 ; (setq org-clock-idle-time 10)
1160 ; (setq org-clock-x11idle-program-name "xprintidle")
1162 ; this is from http://doc.norang.ca/org-mode.html#Capture
1163 ; use C-M-r for org mode capture
1164 (global-set-key (kbd "C-M-r") 'org-capture)
1166 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1167 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1168 (org-agenda-files :maxlevel . 9))))
1170 ; Use full outline paths for refile targets - we file directly with IDO
1171 (setq org-refile-use-outline-path t)
1173 ; Targets complete directly with IDO
1174 (setq org-outline-path-complete-in-steps nil)
1176 ; Allow refile to create parent tasks with confirmation
1177 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1179 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
1180 ; (setq org-completion-use-ido t)
1181 ; (setq ido-everywhere t)
1182 ; (setq ido-max-directory-size 100000)
1183 ; (ido-mode (quote both))
1184 ; ; Use the current window when visiting files and buffers with ido
1185 ; (setq ido-default-file-method 'selected-window)
1186 ; (setq ido-default-buffer-method 'selected-window)
1187 ; ; Use the current window for indirect buffer display
1188 ; (setq org-indirect-buffer-display 'current-window)
1191 ;;;; Refile settings
1192 ; Exclude DONE state tasks from refile targets
1193 (defun bh/verify-refile-target ()
1194 "Exclude todo keywords with a done state from refile targets"
1195 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
1197 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1199 ;; ensure that emacsclient will show just the note to be edited when invoked
1200 ;; from Mutt, and that it will shut down emacsclient once finished;
1201 ;; fallback to legacy behavior when not invoked via org-protocol.
1202 (require 'org-protocol)
1203 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
1204 (setq my-org-protocol-flag nil)
1205 (defadvice org-capture-finalize (after delete-frame-at-end activate)
1206 "Delete frame at remember finalization"
1207 (progn (if my-org-protocol-flag (delete-frame))
1208 (setq my-org-protocol-flag nil)))
1209 (defadvice org-capture-refile (around delete-frame-after-refile activate)
1210 "Delete frame at remember refile"
1211 (if my-org-protocol-flag
1213 (setq my-org-protocol-flag nil)
1218 (defadvice org-capture-kill (after delete-frame-at-end activate)
1219 "Delete frame at remember abort"
1220 (progn (if my-org-protocol-flag (delete-frame))
1221 (setq my-org-protocol-flag nil)))
1222 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
1223 (setq my-org-protocol-flag t))
1225 (defadvice org-insert-todo-heading (after dla/create-id activate)
1230 (add-to-list 'org-modules 'org-habit)
1232 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
1233 (defun open-mail-in-mutt (message)
1234 "Open a mail message in Mutt, using an external terminal.
1236 Message can be specified either by a path pointing inside a
1237 Maildir, or by Message-ID."
1238 (interactive "MPath or Message-ID: ")
1240 (format "faf xterm -e \"%s %s\""
1241 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
1243 ;; add support for "mutt:ID" links
1244 (org-add-link-type "mutt" 'open-mail-in-mutt)
1246 (defun my-org-mode-setup ()
1247 ; (load-library "reftex")
1248 (and (buffer-file-name)
1249 (file-exists-p (buffer-file-name))
1251 ; (reftex-parse-all)
1252 (reftex-set-cite-format
1253 '((?b . "[[bib:%l][%l-bib]]")
1254 (?n . "[[notes:%l][%l-notes]]")
1256 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
1258 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
1259 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
1260 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
1261 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
1263 (add-hook 'org-mode-hook 'my-org-mode-setup)
1265 (defun org-mode-reftex-search ()
1267 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
1269 (defun open-research-paper (bibtexkey)
1270 "Open a paper by bibtex key"
1271 (interactive "bibtex key: ")
1274 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1275 (org-add-link-type "papers" 'open-research-paper)
1276 (defun open-research-paper-pdf (bibtexkey)
1277 "Open a paper pdf by bibtex key"
1278 (interactive "bibtex key: ")
1280 (format "%s -p evince_annot %s"
1281 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1282 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
1284 (add-to-list 'org-link-abbrev-alist
1286 "~/projects/research/paper_notes.org::#%s"))
1288 ; I pretty much always want hiearchical checkboxes
1289 (setq org-hierachical-checkbox-statistics nil)
1291 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
1292 (add-to-list 'org-structure-template-alist
1293 '("E" "\\begin{equation}\n?\n\\end{equation}"))
1296 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
1297 (defun my-rtcite-export-handler (path desc format)
1298 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
1299 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
1300 (match-string 1 path)))
1301 (path (substring path 0 (match-beginning 0))))
1302 (cond ((eq format 'latex)
1304 (equal 0 (search "rtcite:" desc)))
1305 (format "\\cite{%s}" search)
1306 (format "\\cite[%s]{%s}" desc search))))))
1308 (org-add-link-type "rtcite"
1310 'my-rtcite-export-handler)
1314 ** Org Mobile Configuration
1315 #+BEGIN_SRC emacs-lisp
1316 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
1317 (when (string= system-name "linnode")
1318 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
1319 (setq-default org-directory "/home/don/org-mode/")
1320 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
1324 #+BEGIN_SRC emacs-lisp
1325 ;; org mode ical export
1326 (setq org-icalendar-timezone "America/Los_Angeles")
1327 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
1328 ;; we already add the id manually
1329 (setq org-icalendar-store-UID t)
1332 ** General Org Babel Configuration
1333 #+BEGIN_SRC emacs-lisp
1334 ;; org babel support
1335 (org-babel-do-load-languages
1336 'org-babel-load-languages
1343 ;; use graphviz-dot for dot things
1344 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
1345 ;; org-babel-by-backend
1346 (defmacro org-babel-by-backend (&rest body)
1347 `(case (if (boundp 'backend)
1348 (org-export-backend-name backend)
1351 (defun my/fix-inline-images ()
1352 (when org-inline-image-overlays
1353 (org-redisplay-inline-images)))
1355 (add-hook 'org-babel-after-execute-hook
1356 'my/fix-inline-images)
1359 ** LaTeX configuration
1361 :ID: 7135ba17-6a50-4eed-84ca-b90afa5b12f8
1363 #+BEGIN_SRC emacs-lisp
1365 (add-to-list 'org-latex-classes
1367 "\\documentclass[11pt,oneside,article]{memoir}\n"
1368 ("\\section{%s}" . "\\section*{%s}")
1369 ("\\subsection{%s}" . "\\subsection*{%s}")
1370 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1371 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1372 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1374 (setq org-beamer-outline-frame-options "")
1375 (add-to-list 'org-latex-classes
1377 "\\documentclass[ignorenonframetext]{beamer}
1378 [NO-DEFAULT-PACKAGES]
1381 ("\\section{%s}" . "\\section*{%s}")
1382 ("\\subsection{%s}" . "\\subsection*{%s}")
1383 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1384 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1385 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1387 (add-to-list 'org-latex-classes
1389 "\\documentclass[11pt,oneside]{memoir}\n"
1390 ("\\chapter{%s}" . "\\chapter*{%s}")
1391 ("\\section{%s}" . "\\section*{%s}")
1392 ("\\subsection{%s}" . "\\subsection*{%s}")
1393 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
1395 (add-to-list 'org-latex-classes
1397 "\\documentclass[11pt]{letter}
1398 [NO-DEFAULT-PACKAGES]
1401 ("\\section{%s}" . "\\section*{%s}")
1402 ("\\subsection{%s}" . "\\subsection*{%s}")
1403 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1404 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1405 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1407 (add-to-list 'org-latex-classes
1409 "\\documentclass{dlacv}
1410 [NO-DEFAULT-PACKAGES]
1413 ("\\section{%s}" . "\\section*{%s}")
1414 ("\\subsection{%s}" . "\\subsection*{%s}")
1415 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1416 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1417 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1420 (add-to-list 'org-latex-classes
1422 "\\documentclass{dlaresume}
1423 [NO-DEFAULT-PACKAGES]
1426 ("\\section{%s}" . "\\section*{%s}")
1427 ("\\subsection{%s}" . "\\subsection*{%s}")
1428 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1429 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1430 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1433 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
1434 ;; but adapted to use latexmk 4.22 or higher.
1435 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
1437 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
1438 (setq org-latex-default-packages-alist
1440 ("" "unicode-math" t)
1442 (setq org-latex-packages-alist
1449 ("" "longtable" nil)
1452 ;; make equations larger
1453 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
1455 (defun org-create-formula--latex-header ()
1456 "Return LaTeX header appropriate for previewing a LaTeX snippet."
1457 (let ((info (org-combine-plists (org-export--get-global-options
1458 (org-export-get-backend 'latex))
1459 (org-export--get-inbuffer-options
1460 (org-export-get-backend 'latex)))))
1461 (org-latex-guess-babel-language
1462 (org-latex-guess-inputenc
1463 (org-splice-latex-header
1464 org-format-latex-header
1465 org-latex-default-packages-alist
1467 (plist-get info :latex-header)))
1471 ; support ignoring headers in org mode export to latex
1472 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
1473 (defadvice org-latex-headline (around my-latex-skip-headlines
1474 (headline contents info) activate)
1475 (if (member "ignoreheading" (org-element-property :tags headline))
1476 (setq ad-return-value contents)
1479 ;; keep latex logfiles
1481 (setq org-latex-remove-logfiles nil)
1483 ;; Resume clocking task when emacs is restarted
1484 (org-clock-persistence-insinuate)
1486 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
1487 (setq org-clock-history-length 23)
1488 ;; Resume clocking task on clock-in if the clock is open
1489 (setq org-clock-in-resume t)
1490 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
1491 ;; there are things like PHONE calls
1492 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
1493 ;; Separate drawers for clocking and logs
1494 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
1495 ;; Save clock data and state changes and notes in the LOGBOOK drawer
1496 (setq org-clock-into-drawer t)
1497 (setq org-log-into-drawer t)
1498 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
1499 (setq org-clock-out-remove-zero-time-clocks t)
1500 ;; Clock out when moving task to a done state
1501 (setq org-clock-out-when-done t)
1502 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
1503 (setq org-clock-persist t)
1504 ;; Do not prompt to resume an active clock
1505 (setq org-clock-persist-query-resume nil)
1506 ;; Enable auto clock resolution for finding open clocks
1507 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
1508 ;; Include current clocking task in clock reports
1509 (setq org-clock-report-include-clocking-task t)
1511 ;; the cache seems to be broken
1512 (setq org-element-use-cache nil)
1514 (defvar bh/keep-clock-running nil)
1516 (defun bh/is-task-p ()
1517 "Any task with a todo keyword and no subtask"
1521 (subtree-end (save-excursion (org-end-of-subtree t)))
1522 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1525 (while (and (not has-subtask)
1526 (< (point) subtree-end)
1527 (re-search-forward "^\*+ " subtree-end t))
1528 (when (member (org-get-todo-state) org-todo-keywords-1)
1529 (setq has-subtask t))))
1530 (and is-a-task (not has-subtask)))))
1531 (defun bh/is-project-p ()
1532 "Any task with a todo keyword subtask"
1536 (subtree-end (save-excursion (org-end-of-subtree t)))
1537 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1540 (while (and (not has-subtask)
1541 (< (point) subtree-end)
1542 (re-search-forward "^\*+ " subtree-end t))
1543 (when (member (org-get-todo-state) org-todo-keywords-1)
1544 (setq has-subtask t))))
1545 (and is-a-task has-subtask))))
1547 (defun bh/is-subproject-p ()
1548 "Any task which is a subtask of another project"
1549 (let ((is-subproject)
1550 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1552 (while (and (not is-subproject) (org-up-heading-safe))
1553 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1554 (setq is-subproject t))))
1555 (and is-a-task is-subproject)))
1558 (defun bh/clock-in-to-next (kw)
1559 "Switch a task from TODO to NEXT when clocking in.
1560 Skips capture tasks, projects, and subprojects.
1561 Switch projects and subprojects from NEXT back to TODO"
1562 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
1564 ((and (member (org-get-todo-state) (list "TODO"))
1567 ((and (member (org-get-todo-state) (list "NEXT"))
1571 (defun bh/punch-in (arg)
1572 "Start continuous clocking and set the default task to the
1573 selected task. If no task is selected set the Organization task
1574 as the default task."
1576 (setq bh/keep-clock-running t)
1577 (if (equal major-mode 'org-agenda-mode)
1579 ;; We're in the agenda
1581 (let* ((marker (org-get-at-bol 'org-hd-marker))
1582 (tags (org-with-point-at marker (org-get-tags-at))))
1583 (if (and (eq arg 4) tags)
1584 (org-agenda-clock-in '(16))
1585 (bh/clock-in-organization-task-as-default)))
1587 ;; We are not in the agenda
1591 ; Find the tags on the current task
1592 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
1593 (org-clock-in '(16))
1594 (bh/clock-in-organization-task-as-default)))))
1596 (defun bh/punch-out ()
1598 (setq bh/keep-clock-running nil)
1599 (when (org-clock-is-active)
1601 (org-agenda-remove-restriction-lock))
1603 (defun bh/clock-in-default-task ()
1605 (org-with-point-at org-clock-default-task
1608 (defun bh/clock-in-parent-task ()
1609 "Move point to the parent (project) task if any and clock in"
1610 (let ((parent-task))
1614 (while (and (not parent-task) (org-up-heading-safe))
1615 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1616 (setq parent-task (point))))
1618 (org-with-point-at parent-task
1620 (when bh/keep-clock-running
1621 (bh/clock-in-default-task)))))))
1623 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
1625 (defun bh/clock-in-organization-task-as-default ()
1627 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
1628 (org-clock-in '(16))))
1630 (defun bh/clock-out-maybe ()
1631 (when (and bh/keep-clock-running
1632 (not org-clock-clocking-in)
1633 (marker-buffer org-clock-default-task)
1634 (not org-clock-resolving-clocks-due-to-idleness))
1635 (bh/clock-in-parent-task)))
1637 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1640 (defun bh/clock-in-task-by-id (id)
1641 "Clock in a task by id"
1642 (org-with-point-at (org-id-find id 'marker)
1643 (org-clock-in nil)))
1645 (defun bh/clock-in-last-task (arg)
1646 "Clock in the interrupted task if there is one
1647 Skip the default task and get the next one.
1648 A prefix arg forces clock in of the default task."
1650 (let ((clock-in-to-task
1652 ((eq arg 4) org-clock-default-task)
1653 ((and (org-clock-is-active)
1654 (equal org-clock-default-task (cadr org-clock-history)))
1655 (caddr org-clock-history))
1656 ((org-clock-is-active) (cadr org-clock-history))
1657 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
1658 (t (car org-clock-history)))))
1660 (org-with-point-at clock-in-to-task
1661 (org-clock-in nil))))
1664 (defun org-export-to-ods ()
1666 (let ((csv-file "data.csv"))
1667 (org-table-export csv-file "orgtbl-to-csv")
1668 (org-odt-convert csv-file "ods" 'open)))
1670 ; allow for zero-width-space to be a break in regexp too
1671 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
1672 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
1673 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
1675 ;; support inserting screen shots
1676 (defun my/org-insert-screenshot ()
1677 "Take a screenshot into a time stamped unique-named file in the
1678 same directory as the org-buffer and insert a link to this file."
1680 (defvar my/org-insert-screenshot/filename)
1681 (setq my/org-insert-screenshot/filename
1683 "Screenshot to insert: "
1685 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
1688 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
1689 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
1690 (org-display-inline-images))
1692 (defun my/fix-inline-images ()
1693 (when org-inline-image-overlays
1694 (org-redisplay-inline-images)))
1696 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
1698 ;; use xelatex to preview with imagemagick
1699 (add-to-list 'org-preview-latex-process-alist
1700 '(xelateximagemagick
1701 :programs ("xelatex" "convert")
1702 :description "pdf > png"
1703 :message "you need to install xelatex and imagemagick"
1705 :image-input-type "pdf"
1706 :image-output-type "png"
1707 :image-size-adjust (1.0 . 1.0)
1708 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
1709 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
1711 ;; use xelatex by default
1712 (setq org-preview-latex-default-process 'xelateximagemagick)
1714 ; from http://orgmode.org/Changes.html
1715 (defun my/org-repair-property-drawers ()
1716 "Fix properties drawers in current buffer.
1717 Ignore non Org buffers."
1719 (when (eq major-mode 'org-mode)
1720 (org-with-wide-buffer
1721 (goto-char (point-min))
1722 (let ((case-fold-search t)
1723 (inline-re (and (featurep 'org-inlinetask)
1724 (concat (org-inlinetask-outline-regexp)
1728 (unless (and inline-re (org-looking-at-p inline-re))
1730 (let ((end (save-excursion (outline-next-heading) (point))))
1732 (when (org-looking-at-p org-planning-line-re) (forward-line))
1733 (when (and (< (point) end)
1734 (not (org-looking-at-p org-property-drawer-re))
1736 (and (re-search-forward org-property-drawer-re end t)
1737 (eq (org-element-type
1738 (save-match-data (org-element-at-point)))
1740 (insert (delete-and-extract-region
1742 (min (1+ (match-end 0)) end)))
1743 (unless (bolp) (insert "\n"))))))))))))
1747 #+BEGIN_SRC emacs-lisp
1751 (use-package calfw-org
1754 (use-package org-gcal
1756 :config '((if (file-readable-p "~/.hide/org_gcal.el")
1757 (load-file "~/.hide/org_gcal.el"))
1762 #+BEGIN_SRC emacs-lisp
1766 ** Override other things
1767 #+BEGIN_SRC emacs-lisp
1768 ; apparently things like to step on C-;, so we'll use a hack from
1769 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
1771 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
1774 (define-key my-keys-minor-mode-map (kbd "C-;") 'mc/mark-all-dwim)
1775 ;; use outline mode keybindings everywhere
1776 ;; (define-key my-keys-minor-mode-map (kbd "C-;") 'my/mydra-outline/body)
1778 (define-minor-mode my-keys-minor-mode
1779 "A minor mode so that my key settings override annoying major modes."
1780 t " my-keys" 'my-keys-minor-mode-map)
1782 (my-keys-minor-mode 1)
1783 (defun my-minibuffer-setup-hook ()
1784 (my-keys-minor-mode 0))
1786 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
1787 (defadvice load (after give-my-keybindings-priority)
1788 "Try to ensure that my keybindings always have priority."
1789 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
1790 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
1791 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
1792 (add-to-list 'minor-mode-map-alist mykeys))))
1796 #+BEGIN_SRC emacs-lisp
1797 (global-unset-key "\M-g")
1798 (global-set-key (kbd "M-g l") 'goto-line)
1800 * Misc (uncharacterized)
1801 #+BEGIN_SRC emacs-lisp
1802 (setq calendar-latitude 40.11)
1803 (setq calendar-longitude -88.24)
1804 (setq case-fold-search t)
1805 (setq confirm-kill-emacs (quote y-or-n-p))
1806 (setq cperl-lazy-help-time nil)
1807 (setq debian-changelog-mailing-address "don@debian.org")
1809 (setq display-time-24hr-format t)
1810 (setq display-time-day-and-date t)
1811 (display-time-mode 1)
1812 (global-auto-revert-mode 1)
1813 (global-font-lock-mode 1)
1815 (setq log-edit-keep-buffer t)
1816 (setq mail-user-agent (quote sendmail-user-agent))
1817 (setq markdown-enable-math t)
1818 (setq markdown-follow-wiki-link-on-enter nil)
1819 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
1820 (setq ps-footer-font-size (quote (8 . 10)))
1821 (setq ps-header-font-size (quote (8 . 10)))
1822 (setq ps-header-title-font-size (quote (10 . 10)))
1823 (setq ps-line-number-color "blue")
1824 (setq ps-print-footer t)
1825 (setq ps-print-footer-frame nil)
1826 (setq ps-print-only-one-header t)
1827 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
1829 (setq sentence-end-double-space nil)
1830 ; enable matching parenthesis
1833 (setq user-mail-address "don@donarmstrong.com")
1834 (setq vc-delete-logbuf-window nil)
1835 (setq vc-follow-symlinks t)
1837 ;; use git before SVN; use CVS earlier, because I have CVS
1838 ;; repositories inside of git directories
1839 (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
1841 ;; switch back to the old primary selection method
1842 (setq x-select-enable-clipboard nil)
1843 (setq x-select-enable-primary t)
1844 ; (setq mouse-drag-copy-region t)
1846 (fset 'perl-mode 'cperl-mode)
1847 ;;(load-file "cperl-mode.el")
1851 (global-set-key "\C-xp" 'server-edit)
1853 (setq-default auto-mode-alist (cons '("\.wml$" .
1854 (lambda () (html-mode) (auto-fill-mode)))
1858 ; use markdown mode for mdwn files
1859 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
1860 (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
1863 ;; tramp configuration
1864 (setq tramp-use-ssh-controlmaster-options nil)
1866 ;; self-insert-command hack.
1867 ;; Without this, "if<SP>" expands to
1870 ;; which really should be,
1876 ;(load-library "php-mode")
1878 (setq-default c-indent-level 4)
1879 (setq-default c-brace-imaginary-offset 0)
1880 (setq-default c-brace-offset -4)
1881 (setq-default c-argdecl-indent 4)
1882 (setq-default c-label-offset -4)
1883 (setq-default c-continued-statement-offset 4)
1885 (setq-default indent-tabs-mode nil)
1886 (setq-default tab-width 4)
1889 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
1890 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
1891 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
1892 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
1893 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
1896 (defun insert-date ()
1897 "Insert date at point."
1899 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
1900 (global-set-key "\C-[d" 'insert-date)
1902 (defun unfill-paragraph (arg)
1903 "Pull this whole paragraph up onto one line."
1905 (let ((fill-column 10000))
1906 (fill-paragraph arg))
1909 (column-number-mode t)
1911 ; (require 'mode-compile)
1913 (defadvice server-process-filter (after post-mode-message first activate)
1914 "If the buffer is in post mode, overwrite the server-edit
1915 message with a post-save-current-buffer-and-exit message."
1916 (if (eq major-mode 'post-mode)
1918 (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done."))))
1919 ; This is also needed to see the magic message. Set to a higher
1920 ; number if you have a faster computer or read slower than me.
1921 '(font-lock-verbose 1000)
1922 ;(setq-default server-temp-file-regexp "mutt\(-\|ng-\)")
1923 ; (add-hook 'server-switch-hook
1924 ; (function (lambda()
1925 ; (cond ((string-match "Post" mode-name)
1926 ; (post-goto-body)))
1927 ; set-buffer-file-coding-system 'utf-8
1931 (add-hook 'post-mode-hook
1932 (auto-fill-mode nil)
1934 ; abbrev mode settings
1935 ; load abbreviations from
1936 (setq abbrev-file-name
1937 "~/.emacs_abbrev_def")
1939 ; read the abbrev file if it exists
1940 (if (file-exists-p abbrev-file-name)
1941 (quietly-read-abbrev-file))
1943 ; for now, use abbrev mode everywhere
1944 (setq default-abbrev-mode t)
1947 (defun insert-function-documentation ()
1948 "Insert function documentation"
1950 (insert-file-contents "/home/don/lib/templates/perl_function_documentation" nil))
1951 (global-set-key "\M-f" 'insert-function-documentation)
1953 (eval-after-load "lilypond-mode"
1955 (load-library "lyqi-mode")
1956 (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
1958 (autoload 'spamassassin-mode "spamassassin-mode" nil t)
1960 (desktop-load-default)
1962 '(icomplete-mode on)
1964 ;; custom-set-faces was added by Custom.
1965 ;; If you edit it by hand, you could mess it up, so be careful.
1966 ;; Your init file should contain only one such instance.
1967 ;; If there is more than one, they won't work right.
1968 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
1971 (put 'upcase-region 'disabled nil)
1972 (put 'downcase-region 'disabled nil)
1973 (put 'narrow-to-region 'disabled nil)
1975 ; (defun turn-on-flyspell ()
1976 ; "Force flyspell-mode on using a positive arg. For use in hooks."
1978 ; (flyspell-mode 1))
1981 ; Outline-minor-mode key map
1982 (define-prefix-command 'cm-map nil "Outline-")
1984 (define-key cm-map "q" 'hide-sublevels) ; Hide everything but the top-level headings
1985 (define-key cm-map "t" 'hide-body) ; Hide everything but headings (all body lines)
1986 (define-key cm-map "o" 'hide-other) ; Hide other branches
1987 (define-key cm-map "c" 'hide-entry) ; Hide this entry's body
1988 (define-key cm-map "l" 'hide-leaves) ; Hide body lines in this entry and sub-entries
1989 (define-key cm-map "d" 'hide-subtree) ; Hide everything in this entry and sub-entries
1991 (define-key cm-map "a" 'show-all) ; Show (expand) everything
1992 (define-key cm-map "e" 'show-entry) ; Show this heading's body
1993 (define-key cm-map "i" 'show-children) ; Show this heading's immediate child sub-headings
1994 (define-key cm-map "k" 'show-branches) ; Show all sub-headings under this heading
1995 (define-key cm-map "s" 'show-subtree) ; Show (expand) everything in this heading & below
1997 (define-key cm-map "u" 'outline-up-heading) ; Up
1998 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
1999 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
2000 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
2001 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
2002 (global-set-key "\M-o" cm-map)
2006 (setq-default debian-changelog-mailing-address "don@debian.org")
2007 (setq-default debian-changelog-full-name "Don Armstrong")
2009 ; ediff configuration
2010 ; don't use the multi-window configuration
2011 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
2013 ; fix up css mode to not be silly
2014 ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
2015 (setq cssm-indent-level 4)
2016 (setq cssm-newline-before-closing-bracket t)
2017 (setq cssm-indent-function #'cssm-c-style-indenter)
2018 (setq cssm-mirror-mode nil)
2020 (require 'multi-web-mode)
2021 (setq mweb-default-major-mode 'html-mode)
2022 (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
2023 (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
2024 (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
2025 (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
2026 (multi-web-global-mode 1)
2028 ;;; alias the new `flymake-report-status-slim' to
2029 ;;; `flymake-report-status'
2030 (defalias 'flymake-report-status 'flymake-report-status-slim)
2031 (defun flymake-report-status-slim (e-w &optional status)
2032 "Show \"slim\" flymake status in mode line."
2034 (setq flymake-mode-line-e-w e-w))
2036 (setq flymake-mode-line-status status))
2037 (let* ((mode-line " Φ"))
2038 (when (> (length flymake-mode-line-e-w) 0)
2039 (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
2040 (setq mode-line (concat mode-line flymake-mode-line-status))
2041 (setq flymake-mode-line mode-line)
2042 (force-mode-line-update)))
2044 ; load sql-indent when sql is loaded
2045 (eval-after-load "sql"
2046 '(load-library "sql-indent"))
2048 ; fix up tmux xterm keys
2049 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
2050 (defun fix-up-tmux-keys ()
2051 "Fix up tmux xterm keys"
2054 (let ((x 2) (tkey ""))
2074 ;; ctrl + alt + shift
2076 (setq tkey "C-M-S-"))
2079 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
2080 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
2081 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
2082 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
2084 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
2086 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
2088 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
2090 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
2092 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2094 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2096 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
2098 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
2100 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
2102 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
2104 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
2106 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
2108 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
2110 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
2112 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
2114 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
2116 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
2118 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
2120 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
2122 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
2124 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
2126 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
2128 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
2130 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
2132 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
2134 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
2141 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
2143 ; procmailmode configuration
2144 (load "procmail_mode")
2146 (load "mode-line-cleaner")
2148 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
2149 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
2150 (if (or (buffer-modified-p)
2151 (verify-visited-file-modtime)
2152 (< (* 8 1024 1024) (buffer-size))
2153 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
2155 (clear-visited-file-modtime)
2157 (ad-activate 'ask-user-about-supersession-threat)
2159 ; apparently things like to step on C-;, so we'll use a hack from
2160 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
2162 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
2164 ; use iedit everywhere
2165 (define-key my-keys-minor-mode-map (kbd "C-;") 'mc/mark-all-dwim)
2167 (define-minor-mode my-keys-minor-mode
2168 "A minor mode so that my key settings override annoying major modes."
2169 t " my-keys" 'my-keys-minor-mode-map)
2171 (my-keys-minor-mode 1)
2172 (defun my-minibuffer-setup-hook ()
2173 (my-keys-minor-mode 0))
2175 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
2176 (defadvice load (after give-my-keybindings-priority)
2177 "Try to ensure that my keybindings always have priority."
2178 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
2179 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
2180 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
2181 (add-to-list 'minor-mode-map-alist mykeys))))
2183 (global-set-key "\M- " 'hippie-expand)
2188 #+BEGIN_SRC emacs-lisp
2189 (unless (server-running-p)
2196 #+BEGIN_SRC emacs-lisp
2197 (provide 'don-configuration)