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
30 (require 'use-package)
33 #+BEGIN_SRC emacs-lisp
39 #+BEGIN_SRC emacs-lisp
40 ;; Set the custom file to /dev/null and don't bother to load it
41 (setq custom-file "/dev/null")
45 #+BEGIN_SRC emacs-lisp
46 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
47 ;; execute conditional code when loading libraries
48 (defmacro with-library (symbol &rest body)
49 `(when (require ,symbol nil t)
51 (put 'with-library 'lisp-indent-function 1)
55 ** Safe Local Variables
56 #+BEGIN_SRC emacs-lisp
57 (setq safe-local-variable-values
58 (quote ((auto-save-default)
60 (cperl-indent-level . 4)
62 (indent-tabs-mode . f)
66 #+BEGIN_SRC emacs-lisp
67 (setq global-mark-ring-max 128
71 (defun don/minibuffer-setup-hook ()
72 (setq gc-cons-threshold most-positive-fixnum))
74 (defun don/minibuffer-exit-hook ()
75 (setq gc-cons-threshold 1048576))
77 (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
78 (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
82 #+BEGIN_SRC emacs-lisp
85 :diminish flyspell-mode 🐝
87 (add-hook 'message-mode-hook 'turn-on-flyspell)
88 (add-hook 'text-mode-hook 'turn-on-flyspell)
89 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
90 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
91 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
93 (setq ispell-program-name "ispell")
98 #+BEGIN_SRC emacs-lisp
103 #+BEGIN_SRC emacs-lisp
104 ;; (use-package eyebrowse
106 ;; :diminish eyebrowse-mode
107 ;; :init (setq eyebrowse-keymap-prefix (kbd "C-c C-\\"))
109 ;; (setq eyebrowse-wrap-around t)
110 ;; (eyebrowse-mode t)
112 ;; (defun my/eyebrowse-new-window-config ()
116 ;; ;; start at 1 run till 0
117 ;; (let ((j (mod (+ i 1) 10)))
118 ;; (when (and (not done)
119 ;; (not (eyebrowse--window-config-present-p j)))
120 ;; (eyebrowse-switch-to-window-config j)
121 ;; (call-interactively 'eyebrowse-rename-window-config2 j)
126 ;; ;; I don't use latex-preview-pane
127 ;; ;; (require 'latex-preview-pane)
128 ;; ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
129 ;; ;; ;; latex-preview-pane uses window-parameters which are
130 ;; ;; ;; not preserved by eyebrowse, so we close the preview
131 ;; ;; ;; pane before switching, it will be regenerated when we
132 ;; ;; ;; edit the TeX file.
133 ;; ;; (when (lpp/window-containing-preview)
134 ;; ;; (delete-window (lpp/window-containing-preview))))
136 ;; ;; (add-to-list 'eyebrowse-pre-window-switch-hook
137 ;; ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
139 ;; ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
140 ;; ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
141 ;; ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
142 ;; ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
143 ;; ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
151 #+BEGIN_SRC emacs-lisp
152 (defun my/vsplit-last-buffer ()
153 "Split the window vertically and display the previous buffer."
155 (split-window-vertically)
157 (switch-to-next-buffer))
159 (defun my/hsplit-last-buffer ()
160 "Split the window horizontally and display the previous buffer."
162 (split-window-horizontally)
164 (switch-to-next-buffer))
166 (bind-key "C-x 2" 'my/vsplit-last-buffer)
167 (bind-key "C-x 3" 'my/hsplit-last-buffer)
169 (setq split-width-threshold 100)
170 (setq split-height-threshold 60)
172 (defun my/split-window-prefer-vertically (window)
173 "If there's only one window (excluding any possibly active
174 minibuffer), then split the current window horizontally."
175 (if (and (one-window-p t)
176 (not (active-minibuffer-window))
177 ( < (frame-width) (frame-height))
179 (let ((split-width-threshold nil))
180 (split-window-sensibly window))
181 (split-window-sensibly window)))
183 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
184 (setq window-combination-resize t)
187 *** Compilation window
189 If there is no compilation window, open one at the bottom, spanning
190 the complete width of the frame. Otherwise, reuse existing window. In
191 the former case, if there was no error the window closes
194 #+BEGIN_SRC emacs-lisp
195 (add-to-list 'display-buffer-alist
196 `(,(rx bos "*compilation*" eos)
197 (display-buffer-reuse-window
198 display-buffer-in-side-window)
199 (reusable-frames . visible)
201 (window-height . 0.4)))
204 #+BEGIN_SRC emacs-lisp
205 (defun my/compilation-exit-autoclose (status code msg)
206 ;; If M-x compile exists with a 0
207 (when (and (eq status 'exit) (zerop code))
208 ;; and delete the *compilation* window
209 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
210 (when (and (not (window-at-side-p compilation-window 'top))
211 (window-at-side-p compilation-window 'left)
212 (window-at-side-p compilation-window 'right))
213 (delete-window compilation-window))))
214 ;; Always return the anticipated result of compilation-exit-message-function
217 ;; Specify my function (maybe I should have done a lambda function)
218 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
221 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
222 value, the compilation buffer scrolls automatically to follow the
223 output. If the value is ~first-error~, scrolling stops when the first
224 error appears, leaving point at that error. For any other non-nil
225 value, scrolling continues until there is no more output.
227 #+BEGIN_SRC emacs-lisp
228 (setq compilation-scroll-output 'first-error)
231 ** Mode line cleaning
233 #+BEGIN_SRC emacs-lisp
234 (use-package diminish
239 #+BEGIN_SRC emacs-lisp
246 #+BEGIN_SRC emacs-lisp
249 :bind (("C-c C-<SPC>" . avy-goto-word-or-subword-1)
250 ("C-c j j" . avy-goto-word-or-subword-1)
251 ("M-g g" . avy-goto-line))
252 :config (progn (setq avy-background t))
255 *** Ace-link (jumping to links)
256 #+BEGIN_SRC emacs-lisp
257 (use-package ace-link
259 ; bind o in most modes
260 :config (ace-link-setup-default))
262 *** Jumping through edit points (goto-chg)
263 #+BEGIN_SRC emacs-lisp
264 (use-package goto-chg
266 :bind (("C-c j ," . goto-last-change)
267 ("C-c j ." . goto-last-change-reverse))
270 *** Jumping to bookmarks (visible bookmarks, bm)
271 #+BEGIN_SRC emacs-lisp
274 :bind (("C-c j b ." . bm-next)
275 ("C-c j b ," . bm-previous)
276 ("C-c j b SPC" . bm-toggle)))
281 #+BEGIN_SRC emacs-lisp
282 (use-package yasnippet
284 :diminish yas-minor-mode
287 (setq yas-verbosity 1)
288 (define-key yas-minor-mode-map (kbd "<tab>") nil)
289 (define-key yas-minor-mode-map (kbd "TAB") nil)
290 (define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)
291 (setq yas-snippet-dirs '("~/lib/emacs_el/snippets/"
292 "~/lib/emacs_el/yasnippet-snippets/snippets/"))
293 (add-to-list 'hippie-expand-try-functions-list
294 'yas-hippie-try-expand)
299 #+BEGIN_SRC emacs-lisp
300 (use-package auto-yasnippet
301 :bind (("H-w" . aya-create)
308 #+BEGIN_SRC emacs-lisp
310 (use-package tinyprocmail
312 :config (with-library 'tinyprocmail
313 ;; (setq tinyprocmail--procmail-version "v3.22")
314 (add-hook 'tinyprocmail--load-hook 'tinyprocmail-install))
319 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
322 :bind (("C-x g" . magit-status)
323 ("C-x C-g" . magit-status))
325 ;; don't verify where we are pushing
326 (setq magit-push-always-verify nil)
327 ;; refine diffs always (hilight words)
328 (setq magit-diff-refine-hunk nil)
331 (append '("~/lib/emacs_el/magit-annex")
335 (append '("~/lib/emacs_el/magit-vcsh")
338 (use-package magit-annex
341 (use-package magit-vcsh
342 :ensure f ; currently not in melpa, so don't try to install
347 #+BEGIN_SRC emacs-lisp
348 (use-package cperl-mode
351 ;; Use c-mode for perl .xs files
352 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
353 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
354 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
355 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
356 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
359 cperl-auto-newline nil
360 cperl-auto-newline-after-colon nil
361 cperl-continued-statement-offset 4
362 cperl-brace-offset -1
363 cperl-continued-brace-offset 0
364 cperl-label-offset -4
365 cperl-highlight-variables-indiscriminately t
366 cperl-electric-lbrace-space nil
367 cperl-indent-parens-as-block nil
368 cperl-close-paren-offset -1
369 cperl-tab-always-indent t)
370 ;;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
375 #+BEGIN_SRC emacs-lisp
380 (define-key global-map [remap find-file] 'helm-find-files)
381 (define-key global-map [remap occur] 'helm-occur)
382 (define-key global-map [remap list-buffers] 'helm-buffers-list)
383 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
384 (global-set-key (kbd "M-x") 'helm-M-x)
385 (unless (boundp 'completion-in-region-function)
386 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
387 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
388 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
393 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
395 #+BEGIN_SRC emacs-lisp
396 (use-package helm-flx
399 ;; these are helm configs, but they kind of fit here nicely
400 (setq helm-M-x-fuzzy-match t
401 helm-bookmark-show-location t
402 helm-buffers-fuzzy-matching t
403 helm-completion-in-region-fuzzy-match t
404 helm-file-cache-fuzzy-match t
405 helm-imenu-fuzzy-match t
406 helm-mode-fuzzy-match t
407 helm-locate-fuzzy-match nil
409 helm-recentf-fuzzy-match nil
410 helm-semantic-fuzzy-match t)
414 #+BEGIN_SRC emacs-lisp
416 ;;; stolen from https://github.com/malb/emacs.d/blob/master/malb.org
417 (defun malb/helm-swoop-pre-fill ()
418 (thing-at-point 'symbol))
419 (setq malb/helm-swoop-ignore-major-mode '(dired-mode
420 paradox-menu-mode doc-view-mode pdf-view-mode
421 mu4e-headers-mode org-mode markdown-mode latex-mode
422 ein:notebook-multilang-mode))
424 (defun malb/swoop-or-search ()
426 (if (or (> (buffer-size) 1048576) ;; helm-swoop can be slow on big buffers
427 (memq major-mode malb/helm-swoop-ignore-major-mode))
431 (use-package helm-swoop
433 :bind (("C-c o" . helm-multi-swoop-org)
434 ("C-s" . malb/swoop-or-search)
435 ("C-M-s" . helm-multi-swoop-all))
438 (setq helm-swoop-pre-input-function #'malb/helm-swoop-pre-fill
439 helm-swoop-split-with-multiple-windows nil
440 helm-swoop-split-direction #'split-window-horizontally
441 helm-swoop-split-window-function 'helm-default-display-buffer
442 helm-swoop-speed-or-color t)
444 ;; https://emacs.stackexchange.com/questions/28790/helm-swoop-how-to-make-it-behave-more-like-isearch
445 (defun malb/helm-swoop-C-s ()
447 (if (boundp 'helm-swoop-pattern)
448 (if (equal helm-swoop-pattern "")
449 (previous-history-element 1)
453 (bind-key "C-S-s" #'helm-swoop-from-isearch isearch-mode-map)
454 (bind-key "C-S-s" #'helm-multi-swoop-all-from-helm-swoop helm-swoop-map)
455 (bind-key "C-r" #'helm-previous-line helm-swoop-map)
456 (bind-key "C-s" #'malb/helm-swoop-C-s helm-swoop-map)
457 (bind-key "C-r" #'helm-previous-line helm-multi-swoop-map)
458 (bind-key "C-s" #'malb/helm-swoop-C-s helm-multi-swoop-map))
463 #+BEGIN_SRC emacs-lisp
466 :config (setq helm-ag-base-command "ag --nocolor --nogroup"
467 helm-ag-command-option "--all-text"
468 helm-ag-insert-at-point 'symbol
469 helm-ag-fuzzy-match t
470 helm-ag-use-temp-buffer t
471 helm-ag-use-grep-ignore-list t
472 helm-ag-use-agignore t))
475 #+BEGIN_SRC emacs-lisp
476 (use-package helm-descbinds
478 :bind ("C-h b" . helm-descbinds)
479 :init (fset 'describe-bindings 'helm-descbinds))
483 #+BEGIN_SRC emacs-lisp
484 (use-package helm-c-yasnippet
486 :bind ("C-c h y" . helm-yas-complete)
488 (setq helm-yas-space-match-any-greedy t)))
491 #+BEGIN_SRC emacs-lisp
492 (use-package helm-org-rifle
495 (defun malb/helm-org-rifle-agenda-files (arg)
497 (let ((current-prefix-arg nil))
499 ((equal arg 4) (call-interactively #'helm-org-rifle-agenda-files nil))
500 ((equal arg 16) (helm-org-rifle-occur-agenda-files))
501 (t (helm-org-agenda-files-headings)))))))
505 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
510 #+BEGIN_SRC emacs-lisp
511 (add-to-list 'tramp-methods '("vcsh"
512 (tramp-login-program "vcsh")
516 (tramp-remote-shell "/bin/sh")
517 (tramp-remote-shell-args
521 #+BEGIN_SRC emacs-lisp
525 (setq-default reftex-default-bibliography
526 '("~/projects/research/references.bib")))
529 #+BEGIN_SRC emacs-lisp
534 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
535 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
536 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
537 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
538 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
539 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
540 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
541 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
542 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
543 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
544 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
546 (setq-default reftex-plug-into-AUCTeX t)
547 ;; support fake section headers
548 (setq TeX-outline-extra
554 ;; add font locking to the headers
555 (font-lock-add-keywords
557 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
558 0 'font-lock-keyword-face t)
559 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
560 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
561 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
562 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
563 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
565 ;; use smart quotes by default instead of `` and ''
566 ;; taken from http://kieranhealy.org/esk/kjhealy.html
567 (setq TeX-open-quote "“")
568 (setq TeX-close-quote "”")
570 ;; (TeX-add-style-hook
575 ;; (custom-set-variables
576 ;; '(font-latex-user-keyword-classes
579 ;; font-lock-function-name-face 2 (command 1 t))))
581 (setq-default TeX-parse-self t)
582 (setq-default TeX-auto-save t)
583 (setq-default TeX-master nil)
589 (if (boundp 'reftex-ref-style-alist)
591 'reftex-ref-style-alist
592 '("Cleveref" "cleveref"
593 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
594 (reftex-ref-style-activate "Cleveref")
596 '("cref" TeX-arg-ref)
597 '("Cref" TeX-arg-ref)
598 '("cpageref" TeX-arg-ref)
599 '("Cpageref" TeX-arg-ref)))))
602 '(add-to-list 'LaTeX-fill-excluded-macros
605 (use-package font-latex
607 (setq font-latex-match-reference-keywords
633 #+BEGIN_SRC emacs-lisp
637 (use-package calfw-org
640 (use-package org-gcal
642 :config '((if (file-readable-p "~/.hide/org_gcal.el")
643 (load-file "~/.hide/org_gcal.el"))
648 #+BEGIN_SRC emacs-lisp
652 (defun ess-change-directory (path)
653 "Set the current working directory to PATH for both *R* and Emacs."
654 (interactive "DDirectory to change to: ")
656 (when (file-exists-p path)
657 (ess-command (concat "setwd(\"" path "\")\n"))
658 ;; use file-name-as-directory to ensure it has trailing /
659 (setq default-directory (file-name-as-directory path))))
660 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
661 ;; outlining support for ess modes
666 (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
667 (defun outline-level ()
668 (cond ((looking-at "^##### ") 1)
669 ((looking-at "^#### ") 2)
670 ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
673 (add-hook 'ess-mode-hook
675 (local-set-key (kbd "C-c C-R")
676 'dla/ess-region-remote-eval)))
678 ;; Don't restore history or save workspace image
679 '(inferior-R-args "--no-restore-history --no-save")
684 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
686 #+BEGIN_SRC emacs-lisp
687 (use-package rainbow-mode
688 ;; add ess to the x major mode
689 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
690 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
695 #+BEGIN_SRC emacs-lisp
696 (use-package polymode
699 (use-package poly-noweb)
700 (use-package poly-markdown)
701 :mode ("\\.Snw" . poly-noweb+r-mode)
702 :mode ("\\.Rnw" . poly-noweb+r-mode)
703 :mode ("\\.Rmd" . poly-markdown+r-mode)
709 #+BEGIN_SRC emacs-lisp
710 (use-package outline-magic)
713 #+BEGIN_SRC emacs-lisp
714 (use-package writeroom-mode
716 (defun my/writing-mode ()
717 "Start my writing mode; enable visual-line-mode and auto-fill-mode"
722 (visual-line-mode -1)
724 (visual-fill-column-mode -1)
728 (visual-fill-column-mode 1)
733 ** GhostText/Atomic Chrome
734 #+BEGIN_SRC emacs-lisp
735 (use-package atomic-chrome
736 :config (atomic-chrome-start-server)
737 (setq atomic-chrome-buffer-open-style 'full)
742 :ID: 6fcf218b-a762-4c37-9339-a8202ddeb544
744 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
745 #+BEGIN_SRC emacs-lisp
746 (use-package multiple-cursors
747 :bind (("C-;" . mc/mark-all-dwim)
748 ("C-<" . mc/mark-previous-like-this)
749 ("C->" . mc/mark-next-like-this)
750 ("C-S-c C-S-c" . mc/edit-lines))
754 #+BEGIN_SRC emacs-lisp
755 (use-package web-mode
757 (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . web-mode))
758 (setq web-mode-enable-engine-detection t)
759 (setq web-mode-engines-alist
760 '(("template-toolkit" . "\\.tmpl\\'")))
764 ** Use-package and load things
765 #+BEGIN_SRC emacs-lisp
771 ** Agenda Configuration
772 #+BEGIN_SRC emacs-lisp
773 ;; The following lines are always needed. Choose your own keys.
774 (add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode))
775 (global-set-key "\C-cl" 'org-store-link)
776 (global-set-key "\C-ca" 'org-agenda)
777 (global-set-key "\C-cb" 'org-iswitchb)
778 (setq-default org-log-done 'time)
779 (setq-default org-agenda-ndays 5)
781 ;; agenda configuration
782 ;; Do not dim blocked tasks
783 (setq org-agenda-dim-blocked-tasks nil)
784 (setq org-agenda-inhibit-startup t)
785 (setq org-agenda-use-tag-inheritance nil)
787 ;; Compact the block agenda view
788 (setq org-agenda-compact-blocks t)
790 ;; Custom agenda command definitions
791 (setq org-agenda-custom-commands
792 (quote (("N" "Notes" tags "NOTE"
793 ((org-agenda-overriding-header "Notes")
794 (org-tags-match-list-sublevels t)))
795 ("h" "Habits" tags-todo "STYLE=\"habit\""
796 ((org-agenda-overriding-header "Habits")
797 (org-agenda-sorting-strategy
798 '(todo-state-down effort-up category-keep))))
802 ((org-agenda-overriding-header "Tasks to Refile")
803 (org-tags-match-list-sublevels nil)))
804 (tags-todo "-CANCELLED/!"
805 ((org-agenda-overriding-header "Stuck Projects")
806 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
807 (org-agenda-sorting-strategy
809 (tags-todo "-HOLD-CANCELLED/!"
810 ((org-agenda-overriding-header "Projects")
811 (org-agenda-skip-function 'bh/skip-non-projects)
812 (org-tags-match-list-sublevels 'indented)
813 (org-agenda-sorting-strategy
815 (tags-todo "-CANCELLED/!NEXT"
816 ((org-agenda-overriding-header (concat "Project Next Tasks"
817 (if bh/hide-scheduled-and-waiting-next-tasks
819 " (including WAITING and SCHEDULED tasks)")))
820 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
821 (org-tags-match-list-sublevels t)
822 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
823 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
824 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
825 (org-agenda-sorting-strategy
826 '(todo-state-down effort-up category-keep))))
827 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
828 ((org-agenda-overriding-header (concat "Project Subtasks"
829 (if bh/hide-scheduled-and-waiting-next-tasks
831 " (including WAITING and SCHEDULED tasks)")))
832 (org-agenda-skip-function 'bh/skip-non-project-tasks)
833 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
834 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
835 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
836 (org-agenda-sorting-strategy
838 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
839 ((org-agenda-overriding-header (concat "Standalone Tasks"
840 (if bh/hide-scheduled-and-waiting-next-tasks
842 " (including WAITING and SCHEDULED tasks)")))
843 (org-agenda-skip-function 'bh/skip-project-tasks)
844 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
845 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
846 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
847 (org-agenda-sorting-strategy
849 (tags-todo "-CANCELLED+WAITING|HOLD/!"
850 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
851 (org-agenda-skip-function 'bh/skip-stuck-projects)
852 (org-tags-match-list-sublevels nil)
853 (org-agenda-todo-ignore-scheduled t)
854 (org-agenda-todo-ignore-deadlines t)))
856 ((org-agenda-overriding-header "Tasks to Archive")
857 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
858 (org-tags-match-list-sublevels nil))))
861 ; org mode agenda files
862 (setq org-agenda-files
863 (quote ("~/projects/org-notes/debbugs.org"
864 "~/projects/org-notes/notes.org"
865 "~/projects/org-notes/holidays.org"
866 "~/projects/org-notes/refile.org"
867 "~/projects/org-notes/diary.org"
868 "~/projects/org-notes/ool.org"
869 "~/projects/org-notes/sndservers.org"
870 "~/projects/org-notes/chaim.org"
871 "~/projects/org-notes/wildman.org"
872 "~/projects/org-notes/uddin.org"
873 "~/projects/org-notes/reviews.org"
874 "~/projects/org-notes/hpcbio.org"
875 "~/org-mode/from-mobile.org"
876 "~/projects/org-notes/fh.org")))
878 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
879 (set-register ?r (cons 'file "~/projects/org-notes/refile.org"))
880 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
881 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
882 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
883 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
884 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
885 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
886 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
887 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
888 (defun org-agenda-timeline-all (&optional arg)
891 (dolist (org-agenda-file org-agenda-files)
892 (insert-file-contents org-agenda-file nil)
895 (write-file "/tmp/timeline.org")
896 (org-agenda arg "L")))
897 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
898 ;; add automatic reminders for appointments
899 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
900 "Pressing `r' on the agenda will also add appointments."
902 (setq appt-time-msg-list nil)
903 (org-agenda-to-appt)))
907 #+BEGIN_SRC emacs-lisp
908 (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")))
909 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
911 (setq org-default-notes-file "~/projects/org-notes/notes.org")
912 (setq org-id-link-to-org-use-id t)
915 #+BEGIN_SRC emacs-lisp
916 (setq org-capture-templates ;; mail-specific note template, identified by "m"
917 '(("m" "Mail" entry (file "~/projects/org-notes/refile.org")
918 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
919 ("t" "todo" entry (file "~/projects/org-notes/refile.org")
920 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
921 ("r" "respond" entry (file "~/projects/org-notes/refile.org")
922 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
923 ("n" "note" entry (file "~/projects/org-notes/refile.org")
924 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
925 ("s" "schedule" entry (file "~/projects/org-notes/refile.org")
926 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
927 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
928 "* %?\n%U\n" :clock-in t :clock-resume t)
929 ("w" "org-protocol" entry (file "~/projects/org-notes/refile.org")
930 "* TODO Review %c\n%U\n" :immediate-finish t)
931 ("M" "Meeting" entry (file "~/projects/org-notes/refile.org")
932 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
933 ("S" "Seminar" entry (file "~/projects/org-notes/refile.org")
934 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
935 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
936 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
937 ("p" "Phone call" entry (file "~/projects/org-notes/refile.org")
938 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
939 ("J" "job" entry (file "~/projects/org-notes/refile.org")
940 "* 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)
941 ("h" "Habit" entry (file "~/projects/org-notes/refile.org")
942 "* 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")
946 ;; Remove empty LOGBOOK drawers on clock out
947 (defun bh/remove-empty-drawer-on-clock-out ()
950 (beginning-of-line 0)
951 (org-remove-empty-drawer-at (point))))
953 (defun my/org-add-id ()
956 (if (org-current-level)
965 ** Org mode key bindings
966 #+BEGIN_SRC emacs-lisp
967 ; org mode configuration from http://doc.norang.ca/org-mode.html
968 ;; Custom Key Bindings
969 (global-set-key (kbd "<f12>") 'org-agenda)
970 (global-set-key (kbd "<f5>") 'bh/org-todo)
971 (global-set-key (kbd "<S-f5>") 'bh/widen)
972 (global-set-key (kbd "<f7>") 'bh/set-truncate-lines)
973 (global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
974 (global-set-key (kbd "<f9> <f9>") 'bh/show-org-agenda)
975 (global-set-key (kbd "<f9> b") 'bbdb)
976 (global-set-key (kbd "<f9> c") 'calendar)
977 (global-set-key (kbd "<f9> f") 'boxquote-insert-file)
978 (global-set-key (kbd "<f9> h") 'bh/hide-other)
979 (global-set-key (kbd "<f9> n") 'bh/toggle-next-task-display)
980 (global-set-key (kbd "<f9> w") 'widen)
982 ; change the outline mode prefix from C-c @ to C-c C-2
983 (setq outline-minor-mode-prefix "C-c C-2")
984 ;(add-hook 'outline-minor-mode-hook
985 ; (lambda () (local-set-key (kbd "C-c C-2")
986 ; outline-mode-prefix-map)))
988 (global-set-key (kbd "<f9> I") 'bh/punch-in)
989 (global-set-key (kbd "<f9> O") 'bh/punch-out)
991 (global-set-key (kbd "<f9> o") 'bh/make-org-scratch)
993 (global-set-key (kbd "<f9> r") 'boxquote-region)
994 (global-set-key (kbd "<f9> s") 'bh/switch-to-scratch)
996 (global-set-key (kbd "<f9> t") 'bh/insert-inactive-timestamp)
997 (global-set-key (kbd "<f9> T") 'bh/toggle-insert-inactive-timestamp)
999 (global-set-key (kbd "<f9> v") 'visible-mode)
1000 (global-set-key (kbd "<f9> l") 'org-toggle-link-display)
1001 (global-set-key (kbd "<f9> SPC") 'bh/clock-in-last-task)
1002 (global-set-key (kbd "C-<f9>") 'previous-buffer)
1003 (global-set-key (kbd "M-<f9>") 'org-toggle-inline-images)
1004 (global-set-key (kbd "C-x n r") 'narrow-to-region)
1005 (global-set-key (kbd "C-<f10>") 'next-buffer)
1006 (global-set-key (kbd "<f11>") 'org-clock-goto)
1007 (global-set-key (kbd "C-<f11>") 'org-clock-in)
1008 (global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)
1009 (global-set-key (kbd "C-c c") 'org-capture)
1012 ** Utility Functions
1013 #+BEGIN_SRC emacs-lisp
1014 (defun bh/hide-other ()
1017 (org-back-to-heading 'invisible-ok)
1023 (defun bh/set-truncate-lines ()
1024 "Toggle value of truncate-lines and refresh window display."
1026 (setq truncate-lines (not truncate-lines))
1027 ;; now refresh window display (an idiom from simple.el):
1029 (set-window-start (selected-window)
1030 (window-start (selected-window)))))
1032 (defun bh/make-org-scratch ()
1034 (find-file "/tmp/publish/scratch.org")
1035 (gnus-make-directory "/tmp/publish"))
1037 (defun bh/switch-to-scratch ()
1039 (switch-to-buffer "*scratch*"))
1041 (setq org-use-fast-todo-selection t)
1042 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1044 ; create function to create headlines in file. This comes from
1045 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
1046 (defun my/org-add-ids-to-headlines-in-file ()
1047 "Add ID properties to all headlines in the current file which
1048 do not already have one."
1050 (org-map-entries 'org-id-get-create))
1051 ; if we wanted to do this to every buffer, do the following:
1052 ; (add-hook 'org-mode-hook
1054 ; (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
1057 #+BEGIN_SRC emacs-lisp
1058 (setq org-todo-keywords
1059 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
1060 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
1062 (setq org-todo-keyword-faces
1063 (quote (("TODO" :foreground "red" :weight bold)
1064 ("NEXT" :foreground "blue" :weight bold)
1065 ("DONE" :foreground "forest green" :weight bold)
1066 ("WAITING" :foreground "orange" :weight bold)
1067 ("HOLD" :foreground "magenta" :weight bold)
1068 ("CANCELLED" :foreground "forest green" :weight bold)
1069 ("MEETING" :foreground "forest green" :weight bold)
1070 ("PHONE" :foreground "forest green" :weight bold))))
1072 (setq org-todo-state-tags-triggers
1073 (quote (("CANCELLED" ("CANCELLED" . t))
1074 ("WAITING" ("WAITING" . t))
1075 ("HOLD" ("WAITING") ("HOLD" . t))
1076 (done ("WAITING") ("HOLD"))
1077 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1078 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1079 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1083 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1084 ; add ids on creation of nodes
1085 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
1088 ; resolve clocks after 10 minutes of idle; use xprintidle
1089 ; (setq org-clock-idle-time 10)
1090 ; (setq org-clock-x11idle-program-name "xprintidle")
1092 ; this is from http://doc.norang.ca/org-mode.html#Capture
1093 ; use C-M-r for org mode capture
1094 (global-set-key (kbd "C-M-r") 'org-capture)
1096 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1097 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1098 (org-agenda-files :maxlevel . 9))))
1100 ; Use full outline paths for refile targets - we file directly with IDO
1101 (setq org-refile-use-outline-path t)
1103 ; Targets complete directly with IDO
1104 (setq org-outline-path-complete-in-steps nil)
1106 ; Allow refile to create parent tasks with confirmation
1107 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1109 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
1110 ; (setq org-completion-use-ido t)
1111 ; (setq ido-everywhere t)
1112 ; (setq ido-max-directory-size 100000)
1113 ; (ido-mode (quote both))
1114 ; ; Use the current window when visiting files and buffers with ido
1115 ; (setq ido-default-file-method 'selected-window)
1116 ; (setq ido-default-buffer-method 'selected-window)
1117 ; ; Use the current window for indirect buffer display
1118 ; (setq org-indirect-buffer-display 'current-window)
1121 ;;;; Refile settings
1122 ; Exclude DONE state tasks from refile targets
1123 (defun bh/verify-refile-target ()
1124 "Exclude todo keywords with a done state from refile targets"
1125 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
1127 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1129 ;; ensure that emacsclient will show just the note to be edited when invoked
1130 ;; from Mutt, and that it will shut down emacsclient once finished;
1131 ;; fallback to legacy behavior when not invoked via org-protocol.
1132 (require 'org-protocol)
1133 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
1134 (setq my-org-protocol-flag nil)
1135 (defadvice org-capture-finalize (after delete-frame-at-end activate)
1136 "Delete frame at remember finalization"
1137 (progn (if my-org-protocol-flag (delete-frame))
1138 (setq my-org-protocol-flag nil)))
1139 (defadvice org-capture-refile (around delete-frame-after-refile activate)
1140 "Delete frame at remember refile"
1141 (if my-org-protocol-flag
1143 (setq my-org-protocol-flag nil)
1148 (defadvice org-capture-kill (after delete-frame-at-end activate)
1149 "Delete frame at remember abort"
1150 (progn (if my-org-protocol-flag (delete-frame))
1151 (setq my-org-protocol-flag nil)))
1152 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
1153 (setq my-org-protocol-flag t))
1155 (defadvice org-insert-todo-heading (after dla/create-id activate)
1160 (add-to-list 'org-modules 'org-habit)
1162 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
1163 (defun open-mail-in-mutt (message)
1164 "Open a mail message in Mutt, using an external terminal.
1166 Message can be specified either by a path pointing inside a
1167 Maildir, or by Message-ID."
1168 (interactive "MPath or Message-ID: ")
1170 (format "faf xterm -e \"%s %s\""
1171 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
1173 ;; add support for "mutt:ID" links
1174 (org-add-link-type "mutt" 'open-mail-in-mutt)
1176 (defun my-org-mode-setup ()
1177 (load-library "reftex")
1178 (and (buffer-file-name)
1179 (file-exists-p (buffer-file-name))
1182 (reftex-set-cite-format
1183 '((?b . "[[bib:%l][%l-bib]]")
1184 (?n . "[[notes:%l][%l-notes]]")
1186 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
1188 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
1189 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
1190 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
1191 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
1193 (add-hook 'org-mode-hook 'my-org-mode-setup)
1195 (defun org-mode-reftex-search ()
1197 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
1199 (defun open-research-paper (bibtexkey)
1200 "Open a paper by bibtex key"
1201 (interactive "bibtex key: ")
1204 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1205 (org-add-link-type "papers" 'open-research-paper)
1206 (defun open-research-paper-pdf (bibtexkey)
1207 "Open a paper pdf by bibtex key"
1208 (interactive "bibtex key: ")
1210 (format "%s -p evince_annot %s"
1211 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1212 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
1214 (add-to-list 'org-link-abbrev-alist
1216 "~/projects/research/paper_notes.org::#%s"))
1218 ; I pretty much always want hiearchical checkboxes
1219 (setq org-hierachical-checkbox-statistics nil)
1221 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
1222 (add-to-list 'org-structure-template-alist
1223 '("E" "\\begin{equation}\n?\n\\end{equation}"))
1226 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
1227 (defun my-rtcite-export-handler (path desc format)
1228 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
1229 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
1230 (match-string 1 path)))
1231 (path (substring path 0 (match-beginning 0))))
1232 (cond ((eq format 'latex)
1234 (equal 0 (search "rtcite:" desc)))
1235 (format "\\cite{%s}" search)
1236 (format "\\cite[%s]{%s}" desc search))))))
1238 (org-add-link-type "rtcite"
1240 'my-rtcite-export-handler)
1244 ** Org Mobile Configuration
1245 #+BEGIN_SRC emacs-lisp
1246 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
1247 (when (string= system-name "linnode")
1248 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
1249 (setq-default org-directory "/home/don/org-mode/")
1250 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
1254 #+BEGIN_SRC emacs-lisp
1255 ;; org mode ical export
1256 (setq org-icalendar-timezone "America/Los_Angeles")
1257 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
1258 ;; we already add the id manually
1259 ;; (setq org-icalendar-store-UID t)
1262 ** General Org Babel Configuration
1263 #+BEGIN_SRC emacs-lisp
1264 ;; org babel support
1265 (org-babel-do-load-languages
1266 'org-babel-load-languages
1273 ;; use graphviz-dot for dot things
1274 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
1275 ;; org-babel-by-backend
1276 (defmacro org-babel-by-backend (&rest body)
1277 `(case (if (boundp 'backend)
1278 (org-export-backend-name backend)
1281 (defun my/fix-inline-images ()
1282 (when org-inline-image-overlays
1283 (org-redisplay-inline-images)))
1285 (add-hook 'org-babel-after-execute-hook
1286 'my/fix-inline-images)
1289 ** LaTeX configuration
1291 :ID: 7135ba17-6a50-4eed-84ca-b90afa5b12f8
1293 #+BEGIN_SRC emacs-lisp
1295 (add-to-list 'org-latex-classes
1297 "\\documentclass[11pt,oneside,article]{memoir}\n"
1298 ("\\section{%s}" . "\\section*{%s}")
1299 ("\\subsection{%s}" . "\\subsection*{%s}")
1300 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1301 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1302 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1304 (setq org-beamer-outline-frame-options "")
1305 (add-to-list 'org-latex-classes
1307 "\\documentclass[ignorenonframetext]{beamer}
1308 [NO-DEFAULT-PACKAGES]
1311 ("\\section{%s}" . "\\section*{%s}")
1312 ("\\subsection{%s}" . "\\subsection*{%s}")
1313 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1314 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1315 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1317 (add-to-list 'org-latex-classes
1319 "\\documentclass[11pt,oneside]{memoir}\n"
1320 ("\\chapter{%s}" . "\\chapter*{%s}")
1321 ("\\section{%s}" . "\\section*{%s}")
1322 ("\\subsection{%s}" . "\\subsection*{%s}")
1323 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
1325 (add-to-list 'org-latex-classes
1327 "\\documentclass[11pt]{letter}
1328 [NO-DEFAULT-PACKAGES]
1331 ("\\section{%s}" . "\\section*{%s}")
1332 ("\\subsection{%s}" . "\\subsection*{%s}")
1333 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1334 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1335 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1337 (add-to-list 'org-latex-classes
1339 "\\documentclass{dlacv}
1340 [NO-DEFAULT-PACKAGES]
1343 ("\\section{%s}" . "\\section*{%s}")
1344 ("\\subsection{%s}" . "\\subsection*{%s}")
1345 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1346 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1347 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1350 (add-to-list 'org-latex-classes
1352 "\\documentclass{dlaresume}
1353 [NO-DEFAULT-PACKAGES]
1356 ("\\section{%s}" . "\\section*{%s}")
1357 ("\\subsection{%s}" . "\\subsection*{%s}")
1358 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1359 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1360 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1363 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
1364 ;; but adapted to use latexmk 4.22 or higher.
1365 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
1367 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
1368 (setq org-latex-default-packages-alist
1370 ("" "unicode-math" t)
1372 (setq org-latex-packages-alist
1379 ("" "longtable" nil)
1382 ;; make equations larger
1383 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
1385 (defun org-create-formula--latex-header ()
1386 "Return LaTeX header appropriate for previewing a LaTeX snippet."
1387 (let ((info (org-combine-plists (org-export--get-global-options
1388 (org-export-get-backend 'latex))
1389 (org-export--get-inbuffer-options
1390 (org-export-get-backend 'latex)))))
1391 (org-latex-guess-babel-language
1392 (org-latex-guess-inputenc
1393 (org-splice-latex-header
1394 org-format-latex-header
1395 org-latex-default-packages-alist
1397 (plist-get info :latex-header)))
1401 ; support ignoring headers in org mode export to latex
1402 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
1403 (defadvice org-latex-headline (around my-latex-skip-headlines
1404 (headline contents info) activate)
1405 (if (member "ignoreheading" (org-element-property :tags headline))
1406 (setq ad-return-value contents)
1409 ;; keep latex logfiles
1411 (setq org-latex-remove-logfiles nil)
1413 ;; Resume clocking task when emacs is restarted
1414 (org-clock-persistence-insinuate)
1416 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
1417 (setq org-clock-history-length 23)
1418 ;; Resume clocking task on clock-in if the clock is open
1419 (setq org-clock-in-resume t)
1420 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
1421 ;; there are things like PHONE calls
1422 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
1423 ;; Separate drawers for clocking and logs
1424 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
1425 ;; Save clock data and state changes and notes in the LOGBOOK drawer
1426 (setq org-clock-into-drawer t)
1427 (setq org-log-into-drawer t)
1428 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
1429 (setq org-clock-out-remove-zero-time-clocks t)
1430 ;; Clock out when moving task to a done state
1431 (setq org-clock-out-when-done t)
1432 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
1433 (setq org-clock-persist t)
1434 ;; Do not prompt to resume an active clock
1435 (setq org-clock-persist-query-resume nil)
1436 ;; Enable auto clock resolution for finding open clocks
1437 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
1438 ;; Include current clocking task in clock reports
1439 (setq org-clock-report-include-clocking-task t)
1441 ;; the cache seems to be broken
1442 (setq org-element-use-cache nil)
1444 (defvar bh/keep-clock-running nil)
1446 (defun bh/is-task-p ()
1447 "Any task with a todo keyword and no subtask"
1451 (subtree-end (save-excursion (org-end-of-subtree t)))
1452 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1455 (while (and (not has-subtask)
1456 (< (point) subtree-end)
1457 (re-search-forward "^\*+ " subtree-end t))
1458 (when (member (org-get-todo-state) org-todo-keywords-1)
1459 (setq has-subtask t))))
1460 (and is-a-task (not has-subtask)))))
1461 (defun bh/is-project-p ()
1462 "Any task with a todo keyword subtask"
1466 (subtree-end (save-excursion (org-end-of-subtree t)))
1467 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1470 (while (and (not has-subtask)
1471 (< (point) subtree-end)
1472 (re-search-forward "^\*+ " subtree-end t))
1473 (when (member (org-get-todo-state) org-todo-keywords-1)
1474 (setq has-subtask t))))
1475 (and is-a-task has-subtask))))
1477 (defun bh/is-subproject-p ()
1478 "Any task which is a subtask of another project"
1479 (let ((is-subproject)
1480 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1482 (while (and (not is-subproject) (org-up-heading-safe))
1483 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1484 (setq is-subproject t))))
1485 (and is-a-task is-subproject)))
1488 (defun bh/clock-in-to-next (kw)
1489 "Switch a task from TODO to NEXT when clocking in.
1490 Skips capture tasks, projects, and subprojects.
1491 Switch projects and subprojects from NEXT back to TODO"
1492 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
1494 ((and (member (org-get-todo-state) (list "TODO"))
1497 ((and (member (org-get-todo-state) (list "NEXT"))
1501 (defun bh/punch-in (arg)
1502 "Start continuous clocking and set the default task to the
1503 selected task. If no task is selected set the Organization task
1504 as the default task."
1506 (setq bh/keep-clock-running t)
1507 (if (equal major-mode 'org-agenda-mode)
1509 ;; We're in the agenda
1511 (let* ((marker (org-get-at-bol 'org-hd-marker))
1512 (tags (org-with-point-at marker (org-get-tags-at))))
1513 (if (and (eq arg 4) tags)
1514 (org-agenda-clock-in '(16))
1515 (bh/clock-in-organization-task-as-default)))
1517 ;; We are not in the agenda
1521 ; Find the tags on the current task
1522 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
1523 (org-clock-in '(16))
1524 (bh/clock-in-organization-task-as-default)))))
1526 (defun bh/punch-out ()
1528 (setq bh/keep-clock-running nil)
1529 (when (org-clock-is-active)
1531 (org-agenda-remove-restriction-lock))
1533 (defun bh/clock-in-default-task ()
1535 (org-with-point-at org-clock-default-task
1538 (defun bh/clock-in-parent-task ()
1539 "Move point to the parent (project) task if any and clock in"
1540 (let ((parent-task))
1544 (while (and (not parent-task) (org-up-heading-safe))
1545 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1546 (setq parent-task (point))))
1548 (org-with-point-at parent-task
1550 (when bh/keep-clock-running
1551 (bh/clock-in-default-task)))))))
1553 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
1555 (defun bh/clock-in-organization-task-as-default ()
1557 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
1558 (org-clock-in '(16))))
1560 (defun bh/clock-out-maybe ()
1561 (when (and bh/keep-clock-running
1562 (not org-clock-clocking-in)
1563 (marker-buffer org-clock-default-task)
1564 (not org-clock-resolving-clocks-due-to-idleness))
1565 (bh/clock-in-parent-task)))
1567 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1570 (defun bh/clock-in-task-by-id (id)
1571 "Clock in a task by id"
1572 (org-with-point-at (org-id-find id 'marker)
1573 (org-clock-in nil)))
1575 (defun bh/clock-in-last-task (arg)
1576 "Clock in the interrupted task if there is one
1577 Skip the default task and get the next one.
1578 A prefix arg forces clock in of the default task."
1580 (let ((clock-in-to-task
1582 ((eq arg 4) org-clock-default-task)
1583 ((and (org-clock-is-active)
1584 (equal org-clock-default-task (cadr org-clock-history)))
1585 (caddr org-clock-history))
1586 ((org-clock-is-active) (cadr org-clock-history))
1587 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
1588 (t (car org-clock-history)))))
1590 (org-with-point-at clock-in-to-task
1591 (org-clock-in nil))))
1594 (defun org-export-to-ods ()
1596 (let ((csv-file "data.csv"))
1597 (org-table-export csv-file "orgtbl-to-csv")
1598 (org-odt-convert csv-file "ods" 'open)))
1600 ; allow for zero-width-space to be a break in regexp too
1601 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
1602 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
1603 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
1605 ;; support inserting screen shots
1606 (defun my/org-insert-screenshot ()
1607 "Take a screenshot into a time stamped unique-named file in the
1608 same directory as the org-buffer and insert a link to this file."
1610 (defvar my/org-insert-screenshot/filename)
1611 (setq my/org-insert-screenshot/filename
1613 "Screenshot to insert: "
1615 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
1618 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
1619 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
1620 (org-display-inline-images))
1622 (defun my/fix-inline-images ()
1623 (when org-inline-image-overlays
1624 (org-redisplay-inline-images)))
1626 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
1628 ;; use xelatex to preview with imagemagick
1629 (add-to-list 'org-preview-latex-process-alist
1630 '(xelateximagemagick
1631 :programs ("xelatex" "convert")
1632 :description "pdf > png"
1633 :message "you need to install xelatex and imagemagick"
1635 :image-input-type "pdf"
1636 :image-output-type "png"
1637 :image-size-adjust (1.0 . 1.0)
1638 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
1639 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
1641 ;; use xelatex by default
1642 (setq org-preview-latex-default-process 'xelateximagemagick)
1644 ; from http://orgmode.org/Changes.html
1645 (defun my/org-repair-property-drawers ()
1646 "Fix properties drawers in current buffer.
1647 Ignore non Org buffers."
1649 (when (eq major-mode 'org-mode)
1650 (org-with-wide-buffer
1651 (goto-char (point-min))
1652 (let ((case-fold-search t)
1653 (inline-re (and (featurep 'org-inlinetask)
1654 (concat (org-inlinetask-outline-regexp)
1658 (unless (and inline-re (org-looking-at-p inline-re))
1660 (let ((end (save-excursion (outline-next-heading) (point))))
1662 (when (org-looking-at-p org-planning-line-re) (forward-line))
1663 (when (and (< (point) end)
1664 (not (org-looking-at-p org-property-drawer-re))
1666 (and (re-search-forward org-property-drawer-re end t)
1667 (eq (org-element-type
1668 (save-match-data (org-element-at-point)))
1670 (insert (delete-and-extract-region
1672 (min (1+ (match-end 0)) end)))
1673 (unless (bolp) (insert "\n"))))))))))))
1677 #+BEGIN_SRC emacs-lisp
1681 ** Override other things
1682 #+BEGIN_SRC emacs-lisp
1683 ; apparently things like to step on C-;, so we'll use a hack from
1684 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
1686 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
1689 (define-key my-keys-minor-mode-map (kbd "C-;") 'mc/mark-all-dwim)
1690 ;; use outline mode keybindings everywhere
1691 ;; (define-key my-keys-minor-mode-map (kbd "C-;") 'my/mydra-outline/body)
1693 (define-minor-mode my-keys-minor-mode
1694 "A minor mode so that my key settings override annoying major modes."
1695 t " my-keys" 'my-keys-minor-mode-map)
1697 (my-keys-minor-mode 1)
1698 (defun my-minibuffer-setup-hook ()
1699 (my-keys-minor-mode 0))
1701 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
1702 (defadvice load (after give-my-keybindings-priority)
1703 "Try to ensure that my keybindings always have priority."
1704 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
1705 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
1706 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
1707 (add-to-list 'minor-mode-map-alist mykeys))))
1711 #+BEGIN_SRC emacs-lisp
1712 (global-unset-key "\M-g")
1713 (global-set-key (kbd "M-g l") 'goto-line)
1715 * Misc (uncharacterized)
1716 #+BEGIN_SRC emacs-lisp
1717 (setq bibtex-user-optional-fields (quote (("annote" "Personal annotation (ignored)") ("abstract" "") ("pmid" "") ("doi" ""))))
1718 (setq calendar-latitude 40.11)
1719 (setq calendar-longitude -88.24)
1720 (setq case-fold-search t)
1721 (setq confirm-kill-emacs (quote y-or-n-p))
1722 (setq cperl-lazy-help-time nil)
1723 (setq debian-changelog-mailing-address "don@debian.org")
1725 (setq display-time-24hr-format t)
1726 (setq display-time-day-and-date t)
1727 (display-time-mode 1)
1728 (setq font-latex-fontify-script nil)
1729 (setq font-latex-fontify-sectioning (quote color))
1730 (setq font-latex-script-display (quote (nil)))
1731 (global-auto-revert-mode 1)
1732 (global-font-lock-mode 1)
1734 (setq log-edit-keep-buffer t)
1735 (setq mail-user-agent (quote sendmail-user-agent))
1736 (setq markdown-enable-math t)
1737 (setq markdown-follow-wiki-link-on-enter nil)
1738 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
1739 (setq post-email-address "don@donarmstrong.com")
1740 (setq post-kill-quoted-sig nil)
1741 (setq post-mail-message "mutt\\(ng\\|\\)-[a-z0-9]+-[0-9]+-.*")
1742 (setq post-uses-fill-mode nil)
1743 (setq ps-footer-font-size (quote (8 . 10)))
1744 (setq ps-header-font-size (quote (8 . 10)))
1745 (setq ps-header-title-font-size (quote (10 . 10)))
1746 (setq ps-line-number-color "blue")
1747 (setq ps-print-footer t)
1748 (setq ps-print-footer-frame nil)
1749 (setq ps-print-only-one-header t)
1750 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
1752 (setq sentence-end-double-space nil)
1753 ; enable matching parenthesis
1756 (setq user-mail-address "don@donarmstrong.com")
1757 (setq vc-delete-logbuf-window nil)
1758 (setq vc-follow-symlinks t)
1760 ;; use git before SVN; use CVS earlier, because I have CVS
1761 ;; repositories inside of git directories
1762 (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
1764 ;; switch back to the old primary selection method
1765 (setq x-select-enable-clipboard nil)
1766 (setq x-select-enable-primary t)
1767 ; (setq mouse-drag-copy-region t)
1769 (fset 'perl-mode 'cperl-mode)
1770 ;;(load-file "cperl-mode.el")
1776 ;;(require 'ecasound)
1777 ;;(require 'emacs-wiki)
1781 ; (require 'google-weather)
1782 ; (require 'org-google-weather)
1783 ; (setq-default org-google-weather-format "%i %c, [%l,%h] %s %C")
1785 (global-set-key "\C-xp" 'server-edit)
1787 (setq-default auto-mode-alist (cons '("\.wml$" .
1788 (lambda () (html-mode) (auto-fill-mode)))
1792 ; use markdown mode for mdwn files
1793 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
1794 (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
1797 ;; tramp configuration
1798 (setq tramp-use-ssh-controlmaster-options nil)
1800 ; mail configuration
1801 (add-to-list 'auto-mode-alist '("muttng-[a-z0-9]+-[0-9]+-" . message-mode))
1802 (add-to-list 'auto-mode-alist '("muttngrc" . muttrc-mode))
1804 (add-to-list 'auto-mode-alist '("mutt-[a-z0-9]+-[0-9]+-" . message-mode))
1805 (add-to-list 'auto-mode-alist '("muttrc" . muttrc-mode))
1806 (defun my-message-mode-settings ()
1807 (font-lock-add-keywords nil
1808 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1809 (0 'message-multiply-quoted-text-face))
1810 ("^[ \t]*>[ \t]*>.*$"
1811 (0 'message-double-quoted-text-face))))
1812 (local-set-key (kbd "C-c C-a") 'my-post-attach-file)
1814 (add-hook 'message-mode-hook 'my-message-mode-settings)
1816 (defun my-post-attach-file ()
1817 "Prompt for an attachment."
1819 (let ((file (read-file-name "Attach file: " nil nil t nil))
1820 (description (string-read "Description: ")))
1821 (my-header-attach-file file description)))
1823 (symbol-function 'my-post-attach-file)
1825 (defun my-header-attach-file (file description)
1826 "Attach a FILE to the current message (works with Mutt).
1827 Argument DESCRIPTION MIME description."
1828 (interactive "fAttach file: \nsDescription: ")
1829 (when (> (length file) 0)
1834 (goto-char (point-min))
1835 (search-forward-regexp "^$")
1836 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1838 (message (concat "Attached '" file "'."))
1839 (setq post-has-attachment t))))))
1843 (setq mail-yank-prefix "> ")
1845 ;; self-insert-command hack.
1846 ;; Without this, "if<SP>" expands to
1849 ;; which really should be,
1855 ;(load-library "php-mode")
1857 (setq-default c-indent-level 4)
1858 (setq-default c-brace-imaginary-offset 0)
1859 (setq-default c-brace-offset -4)
1860 (setq-default c-argdecl-indent 4)
1861 (setq-default c-label-offset -4)
1862 (setq-default c-continued-statement-offset 4)
1864 (setq-default indent-tabs-mode nil)
1865 (setq-default tab-width 4)
1868 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
1869 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
1870 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
1871 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
1872 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
1875 (defun insert-date ()
1876 "Insert date at point."
1878 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
1879 (global-set-key "\C-[d" 'insert-date)
1881 (defun unfill-paragraph (arg)
1882 "Pull this whole paragraph up onto one line."
1884 (let ((fill-column 10000))
1885 (fill-paragraph arg))
1888 (column-number-mode t)
1892 ; (require 'mode-compile)
1894 (defadvice server-process-filter (after post-mode-message first activate)
1895 "If the buffer is in post mode, overwrite the server-edit
1896 message with a post-save-current-buffer-and-exit message."
1897 (if (eq major-mode 'post-mode)
1899 (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done."))))
1900 ; This is also needed to see the magic message. Set to a higher
1901 ; number if you have a faster computer or read slower than me.
1902 '(font-lock-verbose 1000)
1903 ;(setq-default server-temp-file-regexp "mutt\(-\|ng-\)")
1904 ; (add-hook 'server-switch-hook
1905 ; (function (lambda()
1906 ; (cond ((string-match "Post" mode-name)
1907 ; (post-goto-body)))
1908 ; set-buffer-file-coding-system 'utf-8
1912 (add-hook 'post-mode-hook
1913 (auto-fill-mode nil)
1915 ; abbrev mode settings
1916 ; load abbreviations from
1917 (setq abbrev-file-name
1918 "~/.emacs_abbrev_def")
1920 ; read the abbrev file if it exists
1921 (if (file-exists-p abbrev-file-name)
1922 (quietly-read-abbrev-file))
1924 ; for now, use abbrev mode everywhere
1925 (setq default-abbrev-mode t)
1928 (defun insert-function-documentation ()
1929 "Insert function documentation"
1931 (insert-file-contents "/home/don/lib/templates/perl_function_documentation" nil))
1932 (global-set-key "\M-f" 'insert-function-documentation)
1934 (eval-after-load "lilypond-mode"
1936 (load-library "lyqi-mode")
1937 (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
1939 (autoload 'spamassassin-mode "spamassassin-mode" nil t)
1941 (desktop-load-default)
1943 '(icomplete-mode on)
1945 ;; custom-set-faces was added by Custom.
1946 ;; If you edit it by hand, you could mess it up, so be careful.
1947 ;; Your init file should contain only one such instance.
1948 ;; If there is more than one, they won't work right.
1949 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
1952 (put 'upcase-region 'disabled nil)
1953 (put 'downcase-region 'disabled nil)
1954 (put 'narrow-to-region 'disabled nil)
1956 ; (defun turn-on-flyspell ()
1957 ; "Force flyspell-mode on using a positive arg. For use in hooks."
1959 ; (flyspell-mode 1))
1962 ; Outline-minor-mode key map
1963 (define-prefix-command 'cm-map nil "Outline-")
1965 (define-key cm-map "q" 'hide-sublevels) ; Hide everything but the top-level headings
1966 (define-key cm-map "t" 'hide-body) ; Hide everything but headings (all body lines)
1967 (define-key cm-map "o" 'hide-other) ; Hide other branches
1968 (define-key cm-map "c" 'hide-entry) ; Hide this entry's body
1969 (define-key cm-map "l" 'hide-leaves) ; Hide body lines in this entry and sub-entries
1970 (define-key cm-map "d" 'hide-subtree) ; Hide everything in this entry and sub-entries
1972 (define-key cm-map "a" 'show-all) ; Show (expand) everything
1973 (define-key cm-map "e" 'show-entry) ; Show this heading's body
1974 (define-key cm-map "i" 'show-children) ; Show this heading's immediate child sub-headings
1975 (define-key cm-map "k" 'show-branches) ; Show all sub-headings under this heading
1976 (define-key cm-map "s" 'show-subtree) ; Show (expand) everything in this heading & below
1978 (define-key cm-map "u" 'outline-up-heading) ; Up
1979 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
1980 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
1981 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
1982 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
1983 (global-set-key "\M-o" cm-map)
1987 (setq-default debian-changelog-mailing-address "don@debian.org")
1988 (setq-default debian-changelog-full-name "Don Armstrong")
1990 ; ediff configuration
1991 ; don't use the multi-window configuration
1992 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
1994 ; fix up css mode to not be silly
1995 ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
1996 (setq cssm-indent-level 4)
1997 (setq cssm-newline-before-closing-bracket t)
1998 (setq cssm-indent-function #'cssm-c-style-indenter)
1999 (setq cssm-mirror-mode nil)
2001 (require 'multi-web-mode)
2002 (setq mweb-default-major-mode 'html-mode)
2003 (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
2004 (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
2005 (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
2006 (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
2007 (multi-web-global-mode 1)
2009 ;;; alias the new `flymake-report-status-slim' to
2010 ;;; `flymake-report-status'
2011 (defalias 'flymake-report-status 'flymake-report-status-slim)
2012 (defun flymake-report-status-slim (e-w &optional status)
2013 "Show \"slim\" flymake status in mode line."
2015 (setq flymake-mode-line-e-w e-w))
2017 (setq flymake-mode-line-status status))
2018 (let* ((mode-line " Φ"))
2019 (when (> (length flymake-mode-line-e-w) 0)
2020 (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
2021 (setq mode-line (concat mode-line flymake-mode-line-status))
2022 (setq flymake-mode-line mode-line)
2023 (force-mode-line-update)))
2025 ; load sql-indent when sql is loaded
2026 (eval-after-load "sql"
2027 '(load-library "sql-indent"))
2029 ; fix up tmux xterm keys
2030 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
2031 (defun fix-up-tmux-keys ()
2032 "Fix up tmux xterm keys"
2035 (let ((x 2) (tkey ""))
2055 ;; ctrl + alt + shift
2057 (setq tkey "C-M-S-"))
2060 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
2061 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
2062 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
2063 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
2065 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
2067 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
2069 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
2071 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
2073 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2075 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2077 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
2079 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
2081 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
2083 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
2085 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
2087 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
2089 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
2091 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
2093 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
2095 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
2097 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
2099 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
2101 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
2103 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
2105 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
2107 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
2109 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
2111 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
2113 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
2115 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
2122 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
2124 ; procmailmode configuration
2125 (load "procmail_mode")
2127 (load "mode-line-cleaner")
2129 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
2130 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
2131 (if (or (buffer-modified-p)
2132 (verify-visited-file-modtime)
2133 (< (* 8 1024 1024) (buffer-size))
2134 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
2136 (clear-visited-file-modtime)
2138 (ad-activate 'ask-user-about-supersession-threat)
2140 ; apparently things like to step on C-;, so we'll use a hack from
2141 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
2143 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
2145 ; use iedit everywhere
2146 (define-key my-keys-minor-mode-map (kbd "C-;") 'mc/mark-all-dwim)
2148 (define-minor-mode my-keys-minor-mode
2149 "A minor mode so that my key settings override annoying major modes."
2150 t " my-keys" 'my-keys-minor-mode-map)
2152 (my-keys-minor-mode 1)
2153 (defun my-minibuffer-setup-hook ()
2154 (my-keys-minor-mode 0))
2156 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
2157 (defadvice load (after give-my-keybindings-priority)
2158 "Try to ensure that my keybindings always have priority."
2159 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
2160 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
2161 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
2162 (add-to-list 'minor-mode-map-alist mykeys))))
2164 (global-set-key "\M- " 'hippie-expand)
2169 #+BEGIN_SRC emacs-lisp
2170 (provide 'don-configuration)