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 'text-mode-hook 'turn-on-flyspell)
91 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
92 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
93 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
95 (setq ispell-program-name "ispell")
100 #+BEGIN_SRC emacs-lisp
105 #+BEGIN_SRC emacs-lisp
106 ;; (use-package eyebrowse
108 ;; :diminish eyebrowse-mode
109 ;; :init (setq eyebrowse-keymap-prefix (kbd "C-c C-\\"))
111 ;; (setq eyebrowse-wrap-around t)
112 ;; (eyebrowse-mode t)
114 ;; (defun my/eyebrowse-new-window-config ()
118 ;; ;; start at 1 run till 0
119 ;; (let ((j (mod (+ i 1) 10)))
120 ;; (when (and (not done)
121 ;; (not (eyebrowse--window-config-present-p j)))
122 ;; (eyebrowse-switch-to-window-config j)
123 ;; (call-interactively 'eyebrowse-rename-window-config2 j)
128 ;; ;; I don't use latex-preview-pane
129 ;; ;; (require 'latex-preview-pane)
130 ;; ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
131 ;; ;; ;; latex-preview-pane uses window-parameters which are
132 ;; ;; ;; not preserved by eyebrowse, so we close the preview
133 ;; ;; ;; pane before switching, it will be regenerated when we
134 ;; ;; ;; edit the TeX file.
135 ;; ;; (when (lpp/window-containing-preview)
136 ;; ;; (delete-window (lpp/window-containing-preview))))
138 ;; ;; (add-to-list 'eyebrowse-pre-window-switch-hook
139 ;; ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
141 ;; ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
142 ;; ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
143 ;; ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
144 ;; ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
145 ;; ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
153 #+BEGIN_SRC emacs-lisp
154 (defun my/vsplit-last-buffer ()
155 "Split the window vertically and display the previous buffer."
157 (split-window-vertically)
159 (switch-to-next-buffer))
161 (defun my/hsplit-last-buffer ()
162 "Split the window horizontally and display the previous buffer."
164 (split-window-horizontally)
166 (switch-to-next-buffer))
168 (bind-key "C-x 2" 'my/vsplit-last-buffer)
169 (bind-key "C-x 3" 'my/hsplit-last-buffer)
171 (setq split-width-threshold 100)
172 (setq split-height-threshold 60)
174 (defun my/split-window-prefer-vertically (window)
175 "If there's only one window (excluding any possibly active
176 minibuffer), then split the current window horizontally."
177 (if (and (one-window-p t)
178 (not (active-minibuffer-window))
179 ( < (frame-width) (frame-height))
181 (let ((split-width-threshold nil))
182 (split-window-sensibly window))
183 (split-window-sensibly window)))
185 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
186 (setq window-combination-resize t)
189 *** Compilation window
191 If there is no compilation window, open one at the bottom, spanning
192 the complete width of the frame. Otherwise, reuse existing window. In
193 the former case, if there was no error the window closes
196 #+BEGIN_SRC emacs-lisp
197 (add-to-list 'display-buffer-alist
198 `(,(rx bos "*compilation*" eos)
199 (display-buffer-reuse-window
200 display-buffer-in-side-window)
201 (reusable-frames . visible)
203 (window-height . 0.4)))
206 #+BEGIN_SRC emacs-lisp
207 (defun my/compilation-exit-autoclose (status code msg)
208 ;; If M-x compile exists with a 0
209 (when (and (eq status 'exit) (zerop code))
210 ;; and delete the *compilation* window
211 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
212 (when (and (not (window-at-side-p compilation-window 'top))
213 (window-at-side-p compilation-window 'left)
214 (window-at-side-p compilation-window 'right))
215 (delete-window compilation-window))))
216 ;; Always return the anticipated result of compilation-exit-message-function
219 ;; Specify my function (maybe I should have done a lambda function)
220 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
223 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
224 value, the compilation buffer scrolls automatically to follow the
225 output. If the value is ~first-error~, scrolling stops when the first
226 error appears, leaving point at that error. For any other non-nil
227 value, scrolling continues until there is no more output.
229 #+BEGIN_SRC emacs-lisp
230 (setq compilation-scroll-output 'first-error)
233 ** Mode line cleaning
235 #+BEGIN_SRC emacs-lisp
236 (use-package diminish
241 #+BEGIN_SRC emacs-lisp
248 #+BEGIN_SRC emacs-lisp
251 :bind (("C-c C-<SPC>" . avy-goto-word-or-subword-1)
252 ("C-c j j" . avy-goto-word-or-subword-1)
253 ("M-g g" . avy-goto-line))
254 :config (progn (setq avy-background t))
257 *** Ace-link (jumping to links)
258 #+BEGIN_SRC emacs-lisp
259 (use-package ace-link
261 ; bind o in most modes
262 :config (ace-link-setup-default))
264 *** Jumping through edit points (goto-chg)
265 #+BEGIN_SRC emacs-lisp
266 (use-package goto-chg
268 :bind (("C-c j ," . goto-last-change)
269 ("C-c j ." . goto-last-change-reverse))
272 *** Jumping to bookmarks (visible bookmarks, bm)
273 #+BEGIN_SRC emacs-lisp
276 :bind (("C-c j b ." . bm-next)
277 ("C-c j b ," . bm-previous)
278 ("C-c j b SPC" . bm-toggle)))
283 #+BEGIN_SRC emacs-lisp
284 (use-package yasnippet
286 :diminish yas-minor-mode
289 (setq yas-verbosity 1)
290 (define-key yas-minor-mode-map (kbd "<tab>") nil)
291 (define-key yas-minor-mode-map (kbd "TAB") nil)
292 (define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)
293 (setq yas-snippet-dirs '("~/lib/emacs_el/snippets/"
294 "~/lib/emacs_el/yasnippet-snippets/snippets/"))
295 (add-to-list 'hippie-expand-try-functions-list
296 'yas-hippie-try-expand)
301 #+BEGIN_SRC emacs-lisp
302 (use-package auto-yasnippet
303 :bind (("H-w" . aya-create)
310 #+BEGIN_SRC emacs-lisp
312 (use-package tinyprocmail
314 :config (with-library 'tinyprocmail
315 ;; (setq tinyprocmail--procmail-version "v3.22")
316 (add-hook 'tinyprocmail--load-hook 'tinyprocmail-install))
321 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
324 :bind (("C-x g" . magit-status)
325 ("C-x C-g" . magit-status))
327 ;; don't verify where we are pushing
328 (setq magit-push-always-verify nil)
329 ;; refine diffs always (hilight words)
330 (setq magit-diff-refine-hunk nil)
333 (append '("~/lib/emacs_el/magit-annex")
337 (append '("~/lib/emacs_el/magit-vcsh")
340 (use-package magit-annex
343 (use-package magit-vcsh
344 :ensure f ; currently not in melpa, so don't try to install
349 #+BEGIN_SRC emacs-lisp
350 (use-package cperl-mode
353 ;; Use c-mode for perl .xs files
354 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
355 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
356 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
357 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
358 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
361 cperl-auto-newline nil
362 cperl-auto-newline-after-colon nil
363 cperl-continued-statement-offset 4
364 cperl-brace-offset -1
365 cperl-continued-brace-offset 0
366 cperl-label-offset -4
367 cperl-highlight-variables-indiscriminately t
368 cperl-electric-lbrace-space nil
369 cperl-indent-parens-as-block nil
370 cperl-close-paren-offset -1
371 cperl-tab-always-indent t)
372 ;;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
377 #+BEGIN_SRC emacs-lisp
382 (define-key global-map [remap find-file] 'helm-find-files)
383 (define-key global-map [remap occur] 'helm-occur)
384 (define-key global-map [remap list-buffers] 'helm-buffers-list)
385 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
386 (global-set-key (kbd "M-x") 'helm-M-x)
387 (unless (boundp 'completion-in-region-function)
388 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
389 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
390 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
395 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
397 #+BEGIN_SRC emacs-lisp
398 (use-package helm-flx
401 ;; these are helm configs, but they kind of fit here nicely
402 (setq helm-M-x-fuzzy-match t
403 helm-bookmark-show-location t
404 helm-buffers-fuzzy-matching t
405 helm-completion-in-region-fuzzy-match t
406 helm-file-cache-fuzzy-match t
407 helm-imenu-fuzzy-match t
408 helm-mode-fuzzy-match t
409 helm-locate-fuzzy-match nil
411 helm-recentf-fuzzy-match nil
412 helm-semantic-fuzzy-match t)
416 #+BEGIN_SRC emacs-lisp
418 ;;; stolen from https://github.com/malb/emacs.d/blob/master/malb.org
419 (defun malb/helm-swoop-pre-fill ()
420 (thing-at-point 'symbol))
421 (setq malb/helm-swoop-ignore-major-mode '(dired-mode
422 paradox-menu-mode doc-view-mode pdf-view-mode
423 mu4e-headers-mode org-mode markdown-mode latex-mode
424 ein:notebook-multilang-mode))
426 (defun malb/swoop-or-search ()
428 (if (or (> (buffer-size) 1048576) ;; helm-swoop can be slow on big buffers
429 (memq major-mode malb/helm-swoop-ignore-major-mode))
433 (use-package helm-swoop
435 :bind (("C-c o" . helm-multi-swoop-org)
436 ("C-s" . malb/swoop-or-search)
437 ("C-M-s" . helm-multi-swoop-all))
440 (setq helm-swoop-pre-input-function #'malb/helm-swoop-pre-fill
441 helm-swoop-split-with-multiple-windows nil
442 helm-swoop-split-direction #'split-window-horizontally
443 helm-swoop-split-window-function 'helm-default-display-buffer
444 helm-swoop-speed-or-color t)
446 ;; https://emacs.stackexchange.com/questions/28790/helm-swoop-how-to-make-it-behave-more-like-isearch
447 (defun malb/helm-swoop-C-s ()
449 (if (boundp 'helm-swoop-pattern)
450 (if (equal helm-swoop-pattern "")
451 (previous-history-element 1)
455 (bind-key "C-S-s" #'helm-swoop-from-isearch isearch-mode-map)
456 (bind-key "C-S-s" #'helm-multi-swoop-all-from-helm-swoop helm-swoop-map)
457 (bind-key "C-r" #'helm-previous-line helm-swoop-map)
458 (bind-key "C-s" #'malb/helm-swoop-C-s helm-swoop-map)
459 (bind-key "C-r" #'helm-previous-line helm-multi-swoop-map)
460 (bind-key "C-s" #'malb/helm-swoop-C-s helm-multi-swoop-map))
465 #+BEGIN_SRC emacs-lisp
468 :config (setq helm-ag-base-command "ag --nocolor --nogroup"
469 helm-ag-command-option "--all-text"
470 helm-ag-insert-at-point 'symbol
471 helm-ag-fuzzy-match t
472 helm-ag-use-temp-buffer t
473 helm-ag-use-grep-ignore-list t
474 helm-ag-use-agignore t))
477 #+BEGIN_SRC emacs-lisp
478 (use-package helm-descbinds
480 :bind ("C-h b" . helm-descbinds)
481 :init (fset 'describe-bindings 'helm-descbinds))
485 #+BEGIN_SRC emacs-lisp
486 (use-package helm-c-yasnippet
488 :bind ("C-c h y" . helm-yas-complete)
490 (setq helm-yas-space-match-any-greedy t)))
493 #+BEGIN_SRC emacs-lisp
494 (use-package helm-org-rifle
497 (defun malb/helm-org-rifle-agenda-files (arg)
499 (let ((current-prefix-arg nil))
501 ((equal arg 4) (call-interactively #'helm-org-rifle-agenda-files nil))
502 ((equal arg 16) (helm-org-rifle-occur-agenda-files))
503 (t (helm-org-agenda-files-headings)))))))
506 This can be used to link things pretty quickly if necessary
507 #+BEGIN_SRC emacs-lisp
508 (use-package helm-google
510 :bind ("C-c h g" . helm-google)
512 (progn (add-to-list 'helm-google-actions
513 '("Copy URL" . (lambda (candidate)
515 (replace-regexp-in-string
516 "https://.*q=\\(.*\\)\&sa=.*"
522 (add-to-list 'helm-google-actions
523 '("Org Store Link" . (lambda (candidate)
524 (let ((title (car (split-string candidate "[\n]+")))
526 (replace-regexp-in-string
527 "https://.*q=\\(.*\\)\&sa=.*"
529 (push (list url title) org-stored-links))))
534 #+BEGIN_SRC emacs-lisp
537 :bind ("M-z" . avy-zap-up-to-char-dwim))
540 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
545 #+BEGIN_SRC emacs-lisp
546 (add-to-list 'tramp-methods '("vcsh"
547 (tramp-login-program "vcsh")
551 (tramp-remote-shell "/bin/sh")
552 (tramp-remote-shell-args
556 #+BEGIN_SRC emacs-lisp
560 (setq-default reftex-default-bibliography
561 '("~/projects/research/references.bib")))
564 #+BEGIN_SRC emacs-lisp
566 :config (setq bibtex-user-optional-fields
567 (quote (("annote" "Personal annotation (ignored)")
575 #+BEGIN_SRC emacs-lisp
580 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
581 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
582 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
583 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
584 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
585 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
586 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
587 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
588 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
589 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
590 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
592 (setq-default reftex-plug-into-AUCTeX t)
593 ;; support fake section headers
594 (setq TeX-outline-extra
600 ;; add font locking to the headers
601 (font-lock-add-keywords
603 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
604 0 'font-lock-keyword-face t)
605 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
606 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
607 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
608 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
609 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
611 ;; use smart quotes by default instead of `` and ''
612 ;; taken from http://kieranhealy.org/esk/kjhealy.html
613 (setq TeX-open-quote "“")
614 (setq TeX-close-quote "”")
616 ;; (TeX-add-style-hook
621 ;; (custom-set-variables
622 ;; '(font-latex-user-keyword-classes
625 ;; font-lock-function-name-face 2 (command 1 t))))
627 (setq-default TeX-parse-self t)
628 (setq-default TeX-auto-save t)
629 (setq-default TeX-master nil)
635 (if (boundp 'reftex-ref-style-alist)
637 'reftex-ref-style-alist
638 '("Cleveref" "cleveref"
639 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
640 (reftex-ref-style-activate "Cleveref")
642 '("cref" TeX-arg-ref)
643 '("Cref" TeX-arg-ref)
644 '("cpageref" TeX-arg-ref)
645 '("Cpageref" TeX-arg-ref)))))
648 '(add-to-list 'LaTeX-fill-excluded-macros
651 (use-package font-latex
653 (setq font-latex-match-reference-keywords
675 (setq font-latex-fontify-script nil)
676 (setq font-latex-fontify-sectioning (quote color))
677 (setq font-latex-script-display (quote (nil)))
682 #+BEGIN_SRC emacs-lisp
686 (defun ess-change-directory (path)
687 "Set the current working directory to PATH for both *R* and Emacs."
688 (interactive "DDirectory to change to: ")
690 (when (file-exists-p path)
691 (ess-command (concat "setwd(\"" path "\")\n"))
692 ;; use file-name-as-directory to ensure it has trailing /
693 (setq default-directory (file-name-as-directory path))))
694 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
695 ;; outlining support for ess modes
700 (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
701 (defun outline-level ()
702 (cond ((looking-at "^##### ") 1)
703 ((looking-at "^#### ") 2)
704 ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
707 (add-hook 'ess-mode-hook
709 (local-set-key (kbd "C-c C-R")
710 'dla/ess-region-remote-eval)))
712 ;; Don't restore history or save workspace image
713 '(inferior-R-args "--no-restore-history --no-save")
718 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
720 #+BEGIN_SRC emacs-lisp
721 (use-package rainbow-mode
722 ;; add ess to the x major mode
723 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
724 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
729 #+BEGIN_SRC emacs-lisp
730 (use-package polymode
733 (use-package poly-noweb)
734 (use-package poly-markdown)
735 :mode ("\\.Snw" . poly-noweb+r-mode)
736 :mode ("\\.Rnw" . poly-noweb+r-mode)
737 :mode ("\\.Rmd" . poly-markdown+r-mode)
743 #+BEGIN_SRC emacs-lisp
744 (use-package outline-magic)
747 #+BEGIN_SRC emacs-lisp
748 (use-package writeroom-mode
750 (defun my/writing-mode ()
751 "Start my writing mode; enable visual-line-mode and auto-fill-mode"
756 (visual-line-mode -1)
758 (visual-fill-column-mode -1)
762 (visual-fill-column-mode 1)
767 ** GhostText/Atomic Chrome
768 #+BEGIN_SRC emacs-lisp
769 (use-package atomic-chrome
771 (ignore-errors (atomic-chrome-start-server))
772 (setq atomic-chrome-buffer-open-style 'full)
777 :ID: 6fcf218b-a762-4c37-9339-a8202ddeb544
779 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
780 #+BEGIN_SRC emacs-lisp
781 (use-package multiple-cursors
782 :bind (("C-;" . mc/mark-all-dwim)
783 ("C-<" . mc/mark-previous-like-this)
784 ("C->" . mc/mark-next-like-this)
785 ("C-S-c C-S-c" . mc/edit-lines))
789 #+BEGIN_SRC emacs-lisp
790 (use-package web-mode
792 (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . web-mode))
793 (setq web-mode-enable-engine-detection t)
794 (setq web-mode-engines-alist
795 '(("template-toolkit" . "\\.tmpl\\'")))
800 #+BEGIN_SRC emacs-lisp
803 (setq post-email-address "don@donarmstrong.com")
804 (setq post-kill-quoted-sig nil)
805 (setq post-mail-message "mutt\\(ng\\|\\)-[a-z0-9]+-[0-9]+-.*")
806 (setq post-uses-fill-mode nil)
811 #+BEGIN_SRC emacs-lisp
812 (use-package message-mode
814 :mode "muttng-[a-z0-9]+-[0-9]+-"
815 :mode "mutt-[a-z0-9]+-[0-9]+-"
816 :hook 'my/message-mode-settings
817 :hook 'turn-on-flyspell
818 :bind (:map message-mode-map
819 ("C-c C-a" . my/post-attach-file))
821 (defun my/message-mode-settings ()
822 (font-lock-add-keywords nil
823 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
824 (0 'message-multiply-quoted-text-face))
825 ("^[ \t]*>[ \t]*>.*$"
826 (0 'message-double-quoted-text-face))))
829 (defun my/post-attach-file ()
830 "Prompt for an attachment."
832 (let ((file (read-file-name "Attach file: " nil nil t nil))
833 (description (string-read "Description: ")))
834 (my/header-attach-file file description)))
836 (defun my/header-attach-file (file description)
837 "Attach a FILE to the current message (works with Mutt).
838 Argument DESCRIPTION MIME description."
839 (interactive "fAttach file: \nsDescription: ")
840 (when (> (length file) 0)
845 (goto-char (point-min))
846 (search-forward-regexp "^$")
847 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
849 (message (concat "Attached '" file "'."))
850 (setq post-has-attachment t))))))
852 (setq mail-yank-prefix "> ")
856 #+BEGIN_SRC emacs-lisp
857 (use-package muttrc-mode
864 ** Use-package and load things
865 #+BEGIN_SRC emacs-lisp
871 ** Agenda Configuration
872 #+BEGIN_SRC emacs-lisp
873 :mode "\\.\\(org\\|org_archive\\|txt\\)$"
874 :bind (("C-c l" . org-store-link)
875 ("C-c a" . org-agenda)
876 ("C-c b" . org-iswitchb)
878 (setq-default org-log-done 'time)
879 (setq-default org-agenda-ndays 5)
881 ;; agenda configuration
882 ;; Do not dim blocked tasks
883 (setq org-agenda-dim-blocked-tasks nil)
884 (setq org-agenda-inhibit-startup t)
885 (setq org-agenda-use-tag-inheritance nil)
887 ;; Compact the block agenda view
888 (setq org-agenda-compact-blocks t)
890 ;; Custom agenda command definitions
891 (setq org-agenda-custom-commands
892 (quote (("N" "Notes" tags "NOTE"
893 ((org-agenda-overriding-header "Notes")
894 (org-tags-match-list-sublevels t)))
895 ("h" "Habits" tags-todo "STYLE=\"habit\""
896 ((org-agenda-overriding-header "Habits")
897 (org-agenda-sorting-strategy
898 '(todo-state-down effort-up category-keep))))
902 ((org-agenda-overriding-header "Tasks to Refile")
903 (org-tags-match-list-sublevels nil)))
904 (tags-todo "-CANCELLED/!"
905 ((org-agenda-overriding-header "Stuck Projects")
906 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
907 (org-agenda-sorting-strategy
909 (tags-todo "-HOLD-CANCELLED/!"
910 ((org-agenda-overriding-header "Projects")
911 (org-agenda-skip-function 'bh/skip-non-projects)
912 (org-tags-match-list-sublevels 'indented)
913 (org-agenda-sorting-strategy
915 (tags-todo "-CANCELLED/!NEXT"
916 ((org-agenda-overriding-header (concat "Project Next Tasks"
917 (if bh/hide-scheduled-and-waiting-next-tasks
919 " (including WAITING and SCHEDULED tasks)")))
920 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
921 (org-tags-match-list-sublevels t)
922 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
923 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
924 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
925 (org-agenda-sorting-strategy
926 '(todo-state-down effort-up category-keep))))
927 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
928 ((org-agenda-overriding-header (concat "Project Subtasks"
929 (if bh/hide-scheduled-and-waiting-next-tasks
931 " (including WAITING and SCHEDULED tasks)")))
932 (org-agenda-skip-function 'bh/skip-non-project-tasks)
933 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
934 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
935 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
936 (org-agenda-sorting-strategy
938 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
939 ((org-agenda-overriding-header (concat "Standalone Tasks"
940 (if bh/hide-scheduled-and-waiting-next-tasks
942 " (including WAITING and SCHEDULED tasks)")))
943 (org-agenda-skip-function 'bh/skip-project-tasks)
944 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
945 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
946 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
947 (org-agenda-sorting-strategy
949 (tags-todo "-CANCELLED+WAITING|HOLD/!"
950 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
951 (org-agenda-skip-function 'bh/skip-stuck-projects)
952 (org-tags-match-list-sublevels nil)
953 (org-agenda-todo-ignore-scheduled t)
954 (org-agenda-todo-ignore-deadlines t)))
956 ((org-agenda-overriding-header "Tasks to Archive")
957 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
958 (org-tags-match-list-sublevels nil))))
961 ; org mode agenda files
962 (setq org-agenda-files
963 (quote ("~/projects/org-notes/debbugs.org"
964 "~/projects/org-notes/notes.org"
965 "~/projects/org-notes/holidays.org"
966 "~/projects/org-notes/refile.org"
967 "~/projects/org-notes/diary.org"
968 "~/projects/org-notes/ool.org"
969 "~/projects/org-notes/sndservers.org"
970 "~/projects/org-notes/chaim.org"
971 "~/projects/org-notes/wildman.org"
972 "~/projects/org-notes/uddin.org"
973 "~/projects/org-notes/reviews.org"
974 "~/org-mode/from-mobile.org"
975 "~/projects/org-notes/fh.org")))
977 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
978 (set-register ?r (cons 'file "~/projects/org-notes/refile.org"))
979 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
980 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
981 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
982 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
983 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
984 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
985 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
986 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
987 (defun org-agenda-timeline-all (&optional arg)
990 (dolist (org-agenda-file org-agenda-files)
991 (insert-file-contents org-agenda-file nil)
994 (write-file "/tmp/timeline.org")
995 (org-agenda arg "L")))
996 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
997 ;; add automatic reminders for appointments
998 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
999 "Pressing `r' on the agenda will also add appointments."
1001 (setq appt-time-msg-list nil)
1002 (org-agenda-to-appt)))
1006 #+BEGIN_SRC emacs-lisp
1007 (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")))
1008 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
1010 (setq org-default-notes-file "~/projects/org-notes/notes.org")
1011 (setq org-id-link-to-org-use-id 'use-existing)
1013 ** Capture Templates
1014 #+BEGIN_SRC emacs-lisp
1015 (setq org-capture-templates ;; mail-specific note template, identified by "m"
1016 '(("m" "Mail" entry (file "~/projects/org-notes/refile.org")
1017 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
1018 ("t" "todo" entry (file "~/projects/org-notes/refile.org")
1019 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
1020 ("r" "respond" entry (file "~/projects/org-notes/refile.org")
1021 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
1022 ("n" "note" entry (file "~/projects/org-notes/refile.org")
1023 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
1024 ("s" "schedule" entry (file "~/projects/org-notes/refile.org")
1025 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
1026 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
1027 "* %?\n%U\n" :clock-in t :clock-resume t)
1028 ("w" "org-protocol" entry (file "~/projects/org-notes/refile.org")
1029 "* TODO Review %c\n%U\n" :immediate-finish t)
1030 ("M" "Meeting" entry (file "~/projects/org-notes/refile.org")
1031 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
1032 ("S" "Seminar" entry (file "~/projects/org-notes/refile.org")
1033 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
1034 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
1035 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
1036 ("p" "Phone call" entry (file "~/projects/org-notes/refile.org")
1037 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
1038 ("J" "job" entry (file "~/projects/org-notes/refile.org")
1039 "* 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)
1040 ("h" "Habit" entry (file "~/projects/org-notes/refile.org")
1041 "* 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")
1045 ;; Remove empty LOGBOOK drawers on clock out
1046 (defun bh/remove-empty-drawer-on-clock-out ()
1049 (beginning-of-line 0)
1050 (org-remove-empty-drawer-at (point))))
1052 (defun my/org-add-id ()
1055 (if (org-current-level)
1064 ** Org mode key bindings
1065 #+BEGIN_SRC emacs-lisp
1066 ; org mode configuration from http://doc.norang.ca/org-mode.html
1067 ;; Custom Key Bindings
1068 (global-set-key (kbd "<f12>") 'org-agenda)
1069 (global-set-key (kbd "<f5>") 'bh/org-todo)
1070 (global-set-key (kbd "<S-f5>") 'bh/widen)
1071 (global-set-key (kbd "<f7>") 'bh/set-truncate-lines)
1072 (global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
1073 (global-set-key (kbd "<f9> <f9>") 'bh/show-org-agenda)
1074 (global-set-key (kbd "<f9> b") 'bbdb)
1075 (global-set-key (kbd "<f9> c") 'calendar)
1076 (global-set-key (kbd "<f9> f") 'boxquote-insert-file)
1077 (global-set-key (kbd "<f9> h") 'bh/hide-other)
1078 (global-set-key (kbd "<f9> n") 'bh/toggle-next-task-display)
1079 (global-set-key (kbd "<f9> w") 'widen)
1081 ; change the outline mode prefix from C-c @ to C-c C-2
1082 (setq outline-minor-mode-prefix "C-c C-2")
1083 ;(add-hook 'outline-minor-mode-hook
1084 ; (lambda () (local-set-key (kbd "C-c C-2")
1085 ; outline-mode-prefix-map)))
1087 (global-set-key (kbd "<f9> I") 'bh/punch-in)
1088 (global-set-key (kbd "<f9> O") 'bh/punch-out)
1090 (global-set-key (kbd "<f9> o") 'bh/make-org-scratch)
1092 (global-set-key (kbd "<f9> r") 'boxquote-region)
1093 (global-set-key (kbd "<f9> s") 'bh/switch-to-scratch)
1095 (global-set-key (kbd "<f9> t") 'bh/insert-inactive-timestamp)
1096 (global-set-key (kbd "<f9> T") 'bh/toggle-insert-inactive-timestamp)
1098 (global-set-key (kbd "<f9> v") 'visible-mode)
1099 (global-set-key (kbd "<f9> l") 'org-toggle-link-display)
1100 (global-set-key (kbd "<f9> SPC") 'bh/clock-in-last-task)
1101 (global-set-key (kbd "C-<f9>") 'previous-buffer)
1102 (global-set-key (kbd "M-<f9>") 'org-toggle-inline-images)
1103 (global-set-key (kbd "C-x n r") 'narrow-to-region)
1104 (global-set-key (kbd "C-<f10>") 'next-buffer)
1105 (global-set-key (kbd "<f11>") 'org-clock-goto)
1106 (global-set-key (kbd "C-<f11>") 'org-clock-in)
1107 (global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)
1108 (global-set-key (kbd "C-c c") 'org-capture)
1111 ** Utility Functions
1112 #+BEGIN_SRC emacs-lisp
1113 (defun bh/hide-other ()
1116 (org-back-to-heading 'invisible-ok)
1122 (defun bh/set-truncate-lines ()
1123 "Toggle value of truncate-lines and refresh window display."
1125 (setq truncate-lines (not truncate-lines))
1126 ;; now refresh window display (an idiom from simple.el):
1128 (set-window-start (selected-window)
1129 (window-start (selected-window)))))
1131 (defun bh/make-org-scratch ()
1133 (find-file "/tmp/publish/scratch.org")
1134 (gnus-make-directory "/tmp/publish"))
1136 (defun bh/switch-to-scratch ()
1138 (switch-to-buffer "*scratch*"))
1140 (setq org-use-fast-todo-selection t)
1141 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1143 ; create function to create headlines in file. This comes from
1144 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
1145 (defun my/org-add-ids-to-headlines-in-file ()
1146 "Add ID properties to all headlines in the current file which
1147 do not already have one."
1149 (org-map-entries 'org-id-get-create))
1150 ; if we wanted to do this to every buffer, do the following:
1151 ; (add-hook 'org-mode-hook
1153 ; (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
1156 #+BEGIN_SRC emacs-lisp
1157 (setq org-todo-keywords
1158 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
1159 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
1161 (setq org-todo-keyword-faces
1162 (quote (("TODO" :foreground "red" :weight bold)
1163 ("NEXT" :foreground "blue" :weight bold)
1164 ("DONE" :foreground "forest green" :weight bold)
1165 ("WAITING" :foreground "orange" :weight bold)
1166 ("HOLD" :foreground "magenta" :weight bold)
1167 ("CANCELLED" :foreground "forest green" :weight bold)
1168 ("MEETING" :foreground "forest green" :weight bold)
1169 ("PHONE" :foreground "forest green" :weight bold))))
1171 (setq org-todo-state-tags-triggers
1172 (quote (("CANCELLED" ("CANCELLED" . t))
1173 ("WAITING" ("WAITING" . t))
1174 ("HOLD" ("WAITING") ("HOLD" . t))
1175 (done ("WAITING") ("HOLD"))
1176 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1177 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1178 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1182 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1183 ; add ids on creation of nodes
1184 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
1187 ; resolve clocks after 10 minutes of idle; use xprintidle
1188 ; (setq org-clock-idle-time 10)
1189 ; (setq org-clock-x11idle-program-name "xprintidle")
1191 ; this is from http://doc.norang.ca/org-mode.html#Capture
1192 ; use C-M-r for org mode capture
1193 (global-set-key (kbd "C-M-r") 'org-capture)
1195 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1196 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1197 (org-agenda-files :maxlevel . 9))))
1199 ; Use full outline paths for refile targets - we file directly with IDO
1200 (setq org-refile-use-outline-path t)
1202 ; Targets complete directly with IDO
1203 (setq org-outline-path-complete-in-steps nil)
1205 ; Allow refile to create parent tasks with confirmation
1206 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1208 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
1209 ; (setq org-completion-use-ido t)
1210 ; (setq ido-everywhere t)
1211 ; (setq ido-max-directory-size 100000)
1212 ; (ido-mode (quote both))
1213 ; ; Use the current window when visiting files and buffers with ido
1214 ; (setq ido-default-file-method 'selected-window)
1215 ; (setq ido-default-buffer-method 'selected-window)
1216 ; ; Use the current window for indirect buffer display
1217 ; (setq org-indirect-buffer-display 'current-window)
1220 ;;;; Refile settings
1221 ; Exclude DONE state tasks from refile targets
1222 (defun bh/verify-refile-target ()
1223 "Exclude todo keywords with a done state from refile targets"
1224 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
1226 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1228 ;; ensure that emacsclient will show just the note to be edited when invoked
1229 ;; from Mutt, and that it will shut down emacsclient once finished;
1230 ;; fallback to legacy behavior when not invoked via org-protocol.
1231 (require 'org-protocol)
1232 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
1233 (setq my-org-protocol-flag nil)
1234 (defadvice org-capture-finalize (after delete-frame-at-end activate)
1235 "Delete frame at remember finalization"
1236 (progn (if my-org-protocol-flag (delete-frame))
1237 (setq my-org-protocol-flag nil)))
1238 (defadvice org-capture-refile (around delete-frame-after-refile activate)
1239 "Delete frame at remember refile"
1240 (if my-org-protocol-flag
1242 (setq my-org-protocol-flag nil)
1247 (defadvice org-capture-kill (after delete-frame-at-end activate)
1248 "Delete frame at remember abort"
1249 (progn (if my-org-protocol-flag (delete-frame))
1250 (setq my-org-protocol-flag nil)))
1251 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
1252 (setq my-org-protocol-flag t))
1254 (defadvice org-insert-todo-heading (after dla/create-id activate)
1259 (add-to-list 'org-modules 'org-habit)
1261 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
1262 (defun open-mail-in-mutt (message)
1263 "Open a mail message in Mutt, using an external terminal.
1265 Message can be specified either by a path pointing inside a
1266 Maildir, or by Message-ID."
1267 (interactive "MPath or Message-ID: ")
1269 (format "faf xterm -e \"%s %s\""
1270 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
1272 ;; add support for "mutt:ID" links
1273 (org-add-link-type "mutt" 'open-mail-in-mutt)
1275 (defun my-org-mode-setup ()
1276 ; (load-library "reftex")
1277 (and (buffer-file-name)
1278 (file-exists-p (buffer-file-name))
1280 ; (reftex-parse-all)
1281 (reftex-set-cite-format
1282 '((?b . "[[bib:%l][%l-bib]]")
1283 (?n . "[[notes:%l][%l-notes]]")
1285 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
1287 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
1288 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
1289 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
1290 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
1292 (add-hook 'org-mode-hook 'my-org-mode-setup)
1294 (defun org-mode-reftex-search ()
1296 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
1298 (defun open-research-paper (bibtexkey)
1299 "Open a paper by bibtex key"
1300 (interactive "bibtex key: ")
1303 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1304 (org-add-link-type "papers" 'open-research-paper)
1305 (defun open-research-paper-pdf (bibtexkey)
1306 "Open a paper pdf by bibtex key"
1307 (interactive "bibtex key: ")
1309 (format "%s -p evince_annot %s"
1310 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1311 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
1313 (add-to-list 'org-link-abbrev-alist
1315 "~/projects/research/paper_notes.org::#%s"))
1317 ; I pretty much always want hiearchical checkboxes
1318 (setq org-hierachical-checkbox-statistics nil)
1320 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
1321 (add-to-list 'org-structure-template-alist
1322 '("E" "\\begin{equation}\n?\n\\end{equation}"))
1325 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
1326 (defun my-rtcite-export-handler (path desc format)
1327 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
1328 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
1329 (match-string 1 path)))
1330 (path (substring path 0 (match-beginning 0))))
1331 (cond ((eq format 'latex)
1333 (equal 0 (search "rtcite:" desc)))
1334 (format "\\cite{%s}" search)
1335 (format "\\cite[%s]{%s}" desc search))))))
1337 (org-add-link-type "rtcite"
1339 'my-rtcite-export-handler)
1343 ** Org Mobile Configuration
1344 #+BEGIN_SRC emacs-lisp
1345 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
1346 (when (string= system-name "linnode")
1347 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
1348 (setq-default org-directory "/home/don/org-mode/")
1349 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
1353 #+BEGIN_SRC emacs-lisp
1354 ;; org mode ical export
1355 (setq org-icalendar-timezone "America/Los_Angeles")
1356 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
1357 ;; we already add the id manually
1358 (setq org-icalendar-store-UID t)
1361 ** General Org Babel Configuration
1362 #+BEGIN_SRC emacs-lisp
1363 ;; org babel support
1364 (org-babel-do-load-languages
1365 'org-babel-load-languages
1372 ;; use graphviz-dot for dot things
1373 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
1374 ;; org-babel-by-backend
1375 (defmacro org-babel-by-backend (&rest body)
1376 `(case (if (boundp 'backend)
1377 (org-export-backend-name backend)
1380 (defun my/fix-inline-images ()
1381 (when org-inline-image-overlays
1382 (org-redisplay-inline-images)))
1384 (add-hook 'org-babel-after-execute-hook
1385 'my/fix-inline-images)
1388 ** LaTeX configuration
1390 :ID: 7135ba17-6a50-4eed-84ca-b90afa5b12f8
1392 #+BEGIN_SRC emacs-lisp
1394 (add-to-list 'org-latex-classes
1396 "\\documentclass[11pt,oneside,article]{memoir}\n"
1397 ("\\section{%s}" . "\\section*{%s}")
1398 ("\\subsection{%s}" . "\\subsection*{%s}")
1399 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1400 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1401 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1403 (setq org-beamer-outline-frame-options "")
1404 (add-to-list 'org-latex-classes
1406 "\\documentclass[ignorenonframetext]{beamer}
1407 [NO-DEFAULT-PACKAGES]
1410 ("\\section{%s}" . "\\section*{%s}")
1411 ("\\subsection{%s}" . "\\subsection*{%s}")
1412 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1413 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1414 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1416 (add-to-list 'org-latex-classes
1418 "\\documentclass[11pt,oneside]{memoir}\n"
1419 ("\\chapter{%s}" . "\\chapter*{%s}")
1420 ("\\section{%s}" . "\\section*{%s}")
1421 ("\\subsection{%s}" . "\\subsection*{%s}")
1422 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
1424 (add-to-list 'org-latex-classes
1426 "\\documentclass[11pt]{letter}
1427 [NO-DEFAULT-PACKAGES]
1430 ("\\section{%s}" . "\\section*{%s}")
1431 ("\\subsection{%s}" . "\\subsection*{%s}")
1432 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1433 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1434 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1436 (add-to-list 'org-latex-classes
1438 "\\documentclass{dlacv}
1439 [NO-DEFAULT-PACKAGES]
1442 ("\\section{%s}" . "\\section*{%s}")
1443 ("\\subsection{%s}" . "\\subsection*{%s}")
1444 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1445 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1446 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1449 (add-to-list 'org-latex-classes
1451 "\\documentclass{dlaresume}
1452 [NO-DEFAULT-PACKAGES]
1455 ("\\section{%s}" . "\\section*{%s}")
1456 ("\\subsection{%s}" . "\\subsection*{%s}")
1457 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1458 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1459 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1462 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
1463 ;; but adapted to use latexmk 4.22 or higher.
1464 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
1466 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
1467 (setq org-latex-default-packages-alist
1469 ("" "unicode-math" t)
1471 (setq org-latex-packages-alist
1478 ("" "longtable" nil)
1481 ;; make equations larger
1482 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
1484 (defun org-create-formula--latex-header ()
1485 "Return LaTeX header appropriate for previewing a LaTeX snippet."
1486 (let ((info (org-combine-plists (org-export--get-global-options
1487 (org-export-get-backend 'latex))
1488 (org-export--get-inbuffer-options
1489 (org-export-get-backend 'latex)))))
1490 (org-latex-guess-babel-language
1491 (org-latex-guess-inputenc
1492 (org-splice-latex-header
1493 org-format-latex-header
1494 org-latex-default-packages-alist
1496 (plist-get info :latex-header)))
1500 ; support ignoring headers in org mode export to latex
1501 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
1502 (defadvice org-latex-headline (around my-latex-skip-headlines
1503 (headline contents info) activate)
1504 (if (member "ignoreheading" (org-element-property :tags headline))
1505 (setq ad-return-value contents)
1508 ;; keep latex logfiles
1510 (setq org-latex-remove-logfiles nil)
1512 ;; Resume clocking task when emacs is restarted
1513 (org-clock-persistence-insinuate)
1515 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
1516 (setq org-clock-history-length 23)
1517 ;; Resume clocking task on clock-in if the clock is open
1518 (setq org-clock-in-resume t)
1519 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
1520 ;; there are things like PHONE calls
1521 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
1522 ;; Separate drawers for clocking and logs
1523 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
1524 ;; Save clock data and state changes and notes in the LOGBOOK drawer
1525 (setq org-clock-into-drawer t)
1526 (setq org-log-into-drawer t)
1527 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
1528 (setq org-clock-out-remove-zero-time-clocks t)
1529 ;; Clock out when moving task to a done state
1530 (setq org-clock-out-when-done t)
1531 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
1532 (setq org-clock-persist t)
1533 ;; Do not prompt to resume an active clock
1534 (setq org-clock-persist-query-resume nil)
1535 ;; Enable auto clock resolution for finding open clocks
1536 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
1537 ;; Include current clocking task in clock reports
1538 (setq org-clock-report-include-clocking-task t)
1540 ;; the cache seems to be broken
1541 (setq org-element-use-cache nil)
1543 (defvar bh/keep-clock-running nil)
1545 (defun bh/is-task-p ()
1546 "Any task with a todo keyword and no subtask"
1550 (subtree-end (save-excursion (org-end-of-subtree t)))
1551 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1554 (while (and (not has-subtask)
1555 (< (point) subtree-end)
1556 (re-search-forward "^\*+ " subtree-end t))
1557 (when (member (org-get-todo-state) org-todo-keywords-1)
1558 (setq has-subtask t))))
1559 (and is-a-task (not has-subtask)))))
1560 (defun bh/is-project-p ()
1561 "Any task with a todo keyword subtask"
1565 (subtree-end (save-excursion (org-end-of-subtree t)))
1566 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1569 (while (and (not has-subtask)
1570 (< (point) subtree-end)
1571 (re-search-forward "^\*+ " subtree-end t))
1572 (when (member (org-get-todo-state) org-todo-keywords-1)
1573 (setq has-subtask t))))
1574 (and is-a-task has-subtask))))
1576 (defun bh/is-subproject-p ()
1577 "Any task which is a subtask of another project"
1578 (let ((is-subproject)
1579 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1581 (while (and (not is-subproject) (org-up-heading-safe))
1582 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1583 (setq is-subproject t))))
1584 (and is-a-task is-subproject)))
1587 (defun bh/clock-in-to-next (kw)
1588 "Switch a task from TODO to NEXT when clocking in.
1589 Skips capture tasks, projects, and subprojects.
1590 Switch projects and subprojects from NEXT back to TODO"
1591 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
1593 ((and (member (org-get-todo-state) (list "TODO"))
1596 ((and (member (org-get-todo-state) (list "NEXT"))
1600 (defun bh/punch-in (arg)
1601 "Start continuous clocking and set the default task to the
1602 selected task. If no task is selected set the Organization task
1603 as the default task."
1605 (setq bh/keep-clock-running t)
1606 (if (equal major-mode 'org-agenda-mode)
1608 ;; We're in the agenda
1610 (let* ((marker (org-get-at-bol 'org-hd-marker))
1611 (tags (org-with-point-at marker (org-get-tags-at))))
1612 (if (and (eq arg 4) tags)
1613 (org-agenda-clock-in '(16))
1614 (bh/clock-in-organization-task-as-default)))
1616 ;; We are not in the agenda
1620 ; Find the tags on the current task
1621 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
1622 (org-clock-in '(16))
1623 (bh/clock-in-organization-task-as-default)))))
1625 (defun bh/punch-out ()
1627 (setq bh/keep-clock-running nil)
1628 (when (org-clock-is-active)
1630 (org-agenda-remove-restriction-lock))
1632 (defun bh/clock-in-default-task ()
1634 (org-with-point-at org-clock-default-task
1637 (defun bh/clock-in-parent-task ()
1638 "Move point to the parent (project) task if any and clock in"
1639 (let ((parent-task))
1643 (while (and (not parent-task) (org-up-heading-safe))
1644 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1645 (setq parent-task (point))))
1647 (org-with-point-at parent-task
1649 (when bh/keep-clock-running
1650 (bh/clock-in-default-task)))))))
1652 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
1654 (defun bh/clock-in-organization-task-as-default ()
1656 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
1657 (org-clock-in '(16))))
1659 (defun bh/clock-out-maybe ()
1660 (when (and bh/keep-clock-running
1661 (not org-clock-clocking-in)
1662 (marker-buffer org-clock-default-task)
1663 (not org-clock-resolving-clocks-due-to-idleness))
1664 (bh/clock-in-parent-task)))
1666 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1669 (defun bh/clock-in-task-by-id (id)
1670 "Clock in a task by id"
1671 (org-with-point-at (org-id-find id 'marker)
1672 (org-clock-in nil)))
1674 (defun bh/clock-in-last-task (arg)
1675 "Clock in the interrupted task if there is one
1676 Skip the default task and get the next one.
1677 A prefix arg forces clock in of the default task."
1679 (let ((clock-in-to-task
1681 ((eq arg 4) org-clock-default-task)
1682 ((and (org-clock-is-active)
1683 (equal org-clock-default-task (cadr org-clock-history)))
1684 (caddr org-clock-history))
1685 ((org-clock-is-active) (cadr org-clock-history))
1686 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
1687 (t (car org-clock-history)))))
1689 (org-with-point-at clock-in-to-task
1690 (org-clock-in nil))))
1693 (defun org-export-to-ods ()
1695 (let ((csv-file "data.csv"))
1696 (org-table-export csv-file "orgtbl-to-csv")
1697 (org-odt-convert csv-file "ods" 'open)))
1699 ; allow for zero-width-space to be a break in regexp too
1700 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
1701 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
1702 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
1704 ;; support inserting screen shots
1705 (defun my/org-insert-screenshot ()
1706 "Take a screenshot into a time stamped unique-named file in the
1707 same directory as the org-buffer and insert a link to this file."
1709 (defvar my/org-insert-screenshot/filename)
1710 (setq my/org-insert-screenshot/filename
1712 "Screenshot to insert: "
1714 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
1717 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
1718 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
1719 (org-display-inline-images))
1721 (defun my/fix-inline-images ()
1722 (when org-inline-image-overlays
1723 (org-redisplay-inline-images)))
1725 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
1727 ;; use xelatex to preview with imagemagick
1728 (add-to-list 'org-preview-latex-process-alist
1729 '(xelateximagemagick
1730 :programs ("xelatex" "convert")
1731 :description "pdf > png"
1732 :message "you need to install xelatex and imagemagick"
1734 :image-input-type "pdf"
1735 :image-output-type "png"
1736 :image-size-adjust (1.0 . 1.0)
1737 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
1738 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
1740 ;; use xelatex by default
1741 (setq org-preview-latex-default-process 'xelateximagemagick)
1743 ; from http://orgmode.org/Changes.html
1744 (defun my/org-repair-property-drawers ()
1745 "Fix properties drawers in current buffer.
1746 Ignore non Org buffers."
1748 (when (eq major-mode 'org-mode)
1749 (org-with-wide-buffer
1750 (goto-char (point-min))
1751 (let ((case-fold-search t)
1752 (inline-re (and (featurep 'org-inlinetask)
1753 (concat (org-inlinetask-outline-regexp)
1757 (unless (and inline-re (org-looking-at-p inline-re))
1759 (let ((end (save-excursion (outline-next-heading) (point))))
1761 (when (org-looking-at-p org-planning-line-re) (forward-line))
1762 (when (and (< (point) end)
1763 (not (org-looking-at-p org-property-drawer-re))
1765 (and (re-search-forward org-property-drawer-re end t)
1766 (eq (org-element-type
1767 (save-match-data (org-element-at-point)))
1769 (insert (delete-and-extract-region
1771 (min (1+ (match-end 0)) end)))
1772 (unless (bolp) (insert "\n"))))))))))))
1776 #+BEGIN_SRC emacs-lisp
1780 (use-package calfw-org
1783 (use-package org-gcal
1785 :config '((if (file-readable-p "~/.hide/org_gcal.el")
1786 (load-file "~/.hide/org_gcal.el"))
1791 #+BEGIN_SRC emacs-lisp
1795 ** Override other things
1796 #+BEGIN_SRC emacs-lisp
1797 ; apparently things like to step on C-;, so we'll use a hack from
1798 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
1800 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
1803 (define-key my-keys-minor-mode-map (kbd "C-;") 'mc/mark-all-dwim)
1804 ;; use outline mode keybindings everywhere
1805 ;; (define-key my-keys-minor-mode-map (kbd "C-;") 'my/mydra-outline/body)
1807 (define-minor-mode my-keys-minor-mode
1808 "A minor mode so that my key settings override annoying major modes."
1809 t " my-keys" 'my-keys-minor-mode-map)
1811 (my-keys-minor-mode 1)
1812 (defun my-minibuffer-setup-hook ()
1813 (my-keys-minor-mode 0))
1815 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
1816 (defadvice load (after give-my-keybindings-priority)
1817 "Try to ensure that my keybindings always have priority."
1818 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
1819 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
1820 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
1821 (add-to-list 'minor-mode-map-alist mykeys))))
1825 #+BEGIN_SRC emacs-lisp
1826 (global-unset-key "\M-g")
1827 (global-set-key (kbd "M-g l") 'goto-line)
1829 * Misc (uncharacterized)
1830 #+BEGIN_SRC emacs-lisp
1831 (setq calendar-latitude 40.11)
1832 (setq calendar-longitude -88.24)
1833 (setq case-fold-search t)
1834 (setq confirm-kill-emacs (quote y-or-n-p))
1835 (setq cperl-lazy-help-time nil)
1836 (setq debian-changelog-mailing-address "don@debian.org")
1838 (setq display-time-24hr-format t)
1839 (setq display-time-day-and-date t)
1840 (display-time-mode 1)
1841 (global-auto-revert-mode 1)
1842 (global-font-lock-mode 1)
1844 (setq log-edit-keep-buffer t)
1845 (setq mail-user-agent (quote sendmail-user-agent))
1846 (setq markdown-enable-math t)
1847 (setq markdown-follow-wiki-link-on-enter nil)
1848 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
1849 (setq ps-footer-font-size (quote (8 . 10)))
1850 (setq ps-header-font-size (quote (8 . 10)))
1851 (setq ps-header-title-font-size (quote (10 . 10)))
1852 (setq ps-line-number-color "blue")
1853 (setq ps-print-footer t)
1854 (setq ps-print-footer-frame nil)
1855 (setq ps-print-only-one-header t)
1856 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
1858 (setq sentence-end-double-space nil)
1859 ; enable matching parenthesis
1862 (setq user-mail-address "don@donarmstrong.com")
1863 (setq vc-delete-logbuf-window nil)
1864 (setq vc-follow-symlinks t)
1866 ;; use git before SVN; use CVS earlier, because I have CVS
1867 ;; repositories inside of git directories
1868 (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
1870 ;; switch back to the old primary selection method
1871 (setq x-select-enable-clipboard nil)
1872 (setq x-select-enable-primary t)
1873 ; (setq mouse-drag-copy-region t)
1875 (fset 'perl-mode 'cperl-mode)
1876 ;;(load-file "cperl-mode.el")
1880 (global-set-key "\C-xp" 'server-edit)
1882 (setq-default auto-mode-alist (cons '("\.wml$" .
1883 (lambda () (html-mode) (auto-fill-mode)))
1887 ; use markdown mode for mdwn files
1888 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
1889 (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
1892 ;; tramp configuration
1893 (setq tramp-use-ssh-controlmaster-options nil)
1895 ;; self-insert-command hack.
1896 ;; Without this, "if<SP>" expands to
1899 ;; which really should be,
1905 ;(load-library "php-mode")
1907 (setq-default c-indent-level 4)
1908 (setq-default c-brace-imaginary-offset 0)
1909 (setq-default c-brace-offset -4)
1910 (setq-default c-argdecl-indent 4)
1911 (setq-default c-label-offset -4)
1912 (setq-default c-continued-statement-offset 4)
1914 (setq-default indent-tabs-mode nil)
1915 (setq-default tab-width 4)
1918 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
1919 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
1920 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
1921 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
1922 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
1925 (defun insert-date ()
1926 "Insert date at point."
1928 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
1929 (global-set-key "\C-[d" 'insert-date)
1931 (defun unfill-paragraph (arg)
1932 "Pull this whole paragraph up onto one line."
1934 (let ((fill-column 10000))
1935 (fill-paragraph arg))
1938 (column-number-mode t)
1940 ; (require 'mode-compile)
1942 (defadvice server-process-filter (after post-mode-message first activate)
1943 "If the buffer is in post mode, overwrite the server-edit
1944 message with a post-save-current-buffer-and-exit message."
1945 (if (eq major-mode 'post-mode)
1947 (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done."))))
1948 ; This is also needed to see the magic message. Set to a higher
1949 ; number if you have a faster computer or read slower than me.
1950 '(font-lock-verbose 1000)
1951 ;(setq-default server-temp-file-regexp "mutt\(-\|ng-\)")
1952 ; (add-hook 'server-switch-hook
1953 ; (function (lambda()
1954 ; (cond ((string-match "Post" mode-name)
1955 ; (post-goto-body)))
1956 ; set-buffer-file-coding-system 'utf-8
1960 (add-hook 'post-mode-hook
1961 (auto-fill-mode nil)
1963 ; abbrev mode settings
1964 ; load abbreviations from
1965 (setq abbrev-file-name
1966 "~/.emacs_abbrev_def")
1968 ; read the abbrev file if it exists
1969 (if (file-exists-p abbrev-file-name)
1970 (quietly-read-abbrev-file))
1972 ; for now, use abbrev mode everywhere
1973 (setq default-abbrev-mode t)
1976 (defun insert-function-documentation ()
1977 "Insert function documentation"
1979 (insert-file-contents "/home/don/lib/templates/perl_function_documentation" nil))
1980 (global-set-key "\M-f" 'insert-function-documentation)
1982 (eval-after-load "lilypond-mode"
1984 (load-library "lyqi-mode")
1985 (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
1987 (autoload 'spamassassin-mode "spamassassin-mode" nil t)
1989 (desktop-load-default)
1991 '(icomplete-mode on)
1993 ;; custom-set-faces was added by Custom.
1994 ;; If you edit it by hand, you could mess it up, so be careful.
1995 ;; Your init file should contain only one such instance.
1996 ;; If there is more than one, they won't work right.
1997 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
2000 (put 'upcase-region 'disabled nil)
2001 (put 'downcase-region 'disabled nil)
2002 (put 'narrow-to-region 'disabled nil)
2004 ; (defun turn-on-flyspell ()
2005 ; "Force flyspell-mode on using a positive arg. For use in hooks."
2007 ; (flyspell-mode 1))
2010 ; Outline-minor-mode key map
2011 (define-prefix-command 'cm-map nil "Outline-")
2013 (define-key cm-map "q" 'hide-sublevels) ; Hide everything but the top-level headings
2014 (define-key cm-map "t" 'hide-body) ; Hide everything but headings (all body lines)
2015 (define-key cm-map "o" 'hide-other) ; Hide other branches
2016 (define-key cm-map "c" 'hide-entry) ; Hide this entry's body
2017 (define-key cm-map "l" 'hide-leaves) ; Hide body lines in this entry and sub-entries
2018 (define-key cm-map "d" 'hide-subtree) ; Hide everything in this entry and sub-entries
2020 (define-key cm-map "a" 'show-all) ; Show (expand) everything
2021 (define-key cm-map "e" 'show-entry) ; Show this heading's body
2022 (define-key cm-map "i" 'show-children) ; Show this heading's immediate child sub-headings
2023 (define-key cm-map "k" 'show-branches) ; Show all sub-headings under this heading
2024 (define-key cm-map "s" 'show-subtree) ; Show (expand) everything in this heading & below
2026 (define-key cm-map "u" 'outline-up-heading) ; Up
2027 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
2028 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
2029 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
2030 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
2031 (global-set-key "\M-o" cm-map)
2035 (setq-default debian-changelog-mailing-address "don@debian.org")
2036 (setq-default debian-changelog-full-name "Don Armstrong")
2038 ; ediff configuration
2039 ; don't use the multi-window configuration
2040 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
2042 ; fix up css mode to not be silly
2043 ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
2044 (setq cssm-indent-level 4)
2045 (setq cssm-newline-before-closing-bracket t)
2046 (setq cssm-indent-function #'cssm-c-style-indenter)
2047 (setq cssm-mirror-mode nil)
2049 (require 'multi-web-mode)
2050 (setq mweb-default-major-mode 'html-mode)
2051 (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
2052 (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
2053 (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
2054 (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
2055 (multi-web-global-mode 1)
2057 ;;; alias the new `flymake-report-status-slim' to
2058 ;;; `flymake-report-status'
2059 (defalias 'flymake-report-status 'flymake-report-status-slim)
2060 (defun flymake-report-status-slim (e-w &optional status)
2061 "Show \"slim\" flymake status in mode line."
2063 (setq flymake-mode-line-e-w e-w))
2065 (setq flymake-mode-line-status status))
2066 (let* ((mode-line " Φ"))
2067 (when (> (length flymake-mode-line-e-w) 0)
2068 (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
2069 (setq mode-line (concat mode-line flymake-mode-line-status))
2070 (setq flymake-mode-line mode-line)
2071 (force-mode-line-update)))
2073 ; load sql-indent when sql is loaded
2074 (eval-after-load "sql"
2075 '(load-library "sql-indent"))
2077 ; fix up tmux xterm keys
2078 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
2079 (defun fix-up-tmux-keys ()
2080 "Fix up tmux xterm keys"
2083 (let ((x 2) (tkey ""))
2103 ;; ctrl + alt + shift
2105 (setq tkey "C-M-S-"))
2108 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
2109 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
2110 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
2111 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
2113 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
2115 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
2117 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
2119 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
2121 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2123 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2125 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
2127 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
2129 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
2131 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
2133 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
2135 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
2137 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
2139 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
2141 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
2143 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
2145 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
2147 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
2149 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
2151 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
2153 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
2155 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
2157 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
2159 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
2161 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
2163 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
2170 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
2172 ; procmailmode configuration
2173 (load "procmail_mode")
2175 (load "mode-line-cleaner")
2177 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
2178 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
2179 (if (or (buffer-modified-p)
2180 (verify-visited-file-modtime)
2181 (< (* 8 1024 1024) (buffer-size))
2182 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
2184 (clear-visited-file-modtime)
2186 (ad-activate 'ask-user-about-supersession-threat)
2188 ; apparently things like to step on C-;, so we'll use a hack from
2189 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
2191 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
2193 ; use iedit everywhere
2194 (define-key my-keys-minor-mode-map (kbd "C-;") 'mc/mark-all-dwim)
2196 (define-minor-mode my-keys-minor-mode
2197 "A minor mode so that my key settings override annoying major modes."
2198 t " my-keys" 'my-keys-minor-mode-map)
2200 (my-keys-minor-mode 1)
2201 (defun my-minibuffer-setup-hook ()
2202 (my-keys-minor-mode 0))
2204 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
2205 (defadvice load (after give-my-keybindings-priority)
2206 "Try to ensure that my keybindings always have priority."
2207 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
2208 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
2209 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
2210 (add-to-list 'minor-mode-map-alist mykeys))))
2212 (global-set-key "\M- " 'hippie-expand)
2217 #+BEGIN_SRC emacs-lisp
2218 (unless (server-running-p)
2225 #+BEGIN_SRC emacs-lisp
2226 (provide 'don-configuration)