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
29 (require 'use-package)
33 #+BEGIN_SRC emacs-lisp
41 #+BEGIN_SRC emacs-lisp
42 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
43 ;; execute conditional code when loading libraries
44 (defmacro with-library (symbol &rest body)
45 `(when (require ,symbol nil t)
47 (put 'with-library 'lisp-indent-function 1)
52 #+BEGIN_SRC emacs-lisp
53 (setq global-mark-ring-max 128
57 (defun don/minibuffer-setup-hook ()
58 (setq gc-cons-threshold most-positive-fixnum))
60 (defun don/minibuffer-exit-hook ()
61 (setq gc-cons-threshold 1048576))
63 (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
64 (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
68 #+BEGIN_SRC emacs-lisp
71 :diminish flyspell-mode 🐝
73 (add-hook 'message-mode-hook 'turn-on-flyspell)
74 (add-hook 'text-mode-hook 'turn-on-flyspell)
75 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
76 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
77 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
79 (setq ispell-program-name "ispell")
84 #+BEGIN_SRC emacs-lisp
89 #+BEGIN_SRC emacs-lisp
90 ;; (use-package eyebrowse
92 ;; :diminish eyebrowse-mode
93 ;; :init (setq eyebrowse-keymap-prefix (kbd "C-c C-\\"))
95 ;; (setq eyebrowse-wrap-around t)
98 ;; (defun my/eyebrowse-new-window-config ()
102 ;; ;; start at 1 run till 0
103 ;; (let ((j (mod (+ i 1) 10)))
104 ;; (when (and (not done)
105 ;; (not (eyebrowse--window-config-present-p j)))
106 ;; (eyebrowse-switch-to-window-config j)
107 ;; (call-interactively 'eyebrowse-rename-window-config2 j)
112 ;; ;; I don't use latex-preview-pane
113 ;; ;; (require 'latex-preview-pane)
114 ;; ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
115 ;; ;; ;; latex-preview-pane uses window-parameters which are
116 ;; ;; ;; not preserved by eyebrowse, so we close the preview
117 ;; ;; ;; pane before switching, it will be regenerated when we
118 ;; ;; ;; edit the TeX file.
119 ;; ;; (when (lpp/window-containing-preview)
120 ;; ;; (delete-window (lpp/window-containing-preview))))
122 ;; ;; (add-to-list 'eyebrowse-pre-window-switch-hook
123 ;; ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
125 ;; ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
126 ;; ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
127 ;; ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
128 ;; ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
129 ;; ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
137 #+BEGIN_SRC emacs-lisp
138 (defun my/vsplit-last-buffer ()
139 "Split the window vertically and display the previous buffer."
141 (split-window-vertically)
143 (switch-to-next-buffer))
145 (defun my/hsplit-last-buffer ()
146 "Split the window horizontally and display the previous buffer."
148 (split-window-horizontally)
150 (switch-to-next-buffer))
152 (bind-key "C-x 2" 'my/vsplit-last-buffer)
153 (bind-key "C-x 3" 'my/hsplit-last-buffer)
155 (setq split-width-threshold 100)
156 (setq split-height-threshold 60)
158 (defun my/split-window-prefer-vertically (window)
159 "If there's only one window (excluding any possibly active
160 minibuffer), then split the current window horizontally."
161 (if (and (one-window-p t)
162 (not (active-minibuffer-window))
163 ( < (frame-width) (frame-height))
165 (let ((split-width-threshold nil))
166 (split-window-sensibly window))
167 (split-window-sensibly window)))
169 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
170 (setq window-combination-resize t)
173 *** Compilation window
175 If there is no compilation window, open one at the bottom, spanning
176 the complete width of the frame. Otherwise, reuse existing window. In
177 the former case, if there was no error the window closes
180 #+BEGIN_SRC emacs-lisp
181 (add-to-list 'display-buffer-alist
182 `(,(rx bos "*compilation*" eos)
183 (display-buffer-reuse-window
184 display-buffer-in-side-window)
185 (reusable-frames . visible)
187 (window-height . 0.4)))
190 #+BEGIN_SRC emacs-lisp
191 (defun my/compilation-exit-autoclose (status code msg)
192 ;; If M-x compile exists with a 0
193 (when (and (eq status 'exit) (zerop code))
194 ;; and delete the *compilation* window
195 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
196 (when (and (not (window-at-side-p compilation-window 'top))
197 (window-at-side-p compilation-window 'left)
198 (window-at-side-p compilation-window 'right))
199 (delete-window compilation-window))))
200 ;; Always return the anticipated result of compilation-exit-message-function
203 ;; Specify my function (maybe I should have done a lambda function)
204 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
207 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
208 value, the compilation buffer scrolls automatically to follow the
209 output. If the value is ~first-error~, scrolling stops when the first
210 error appears, leaving point at that error. For any other non-nil
211 value, scrolling continues until there is no more output.
213 #+BEGIN_SRC emacs-lisp
214 (setq compilation-scroll-output 'first-error)
217 ** Mode line cleaning
219 #+BEGIN_SRC emacs-lisp
220 (use-package diminish
225 #+BEGIN_SRC emacs-lisp
232 #+BEGIN_SRC emacs-lisp
235 :bind ("C-c C-SPC" . avy-goto-word-1)
237 (setq avy-background t)
238 (key-chord-define-global "jj" #'avy-goto-word-1)))
244 #+BEGIN_SRC emacs-lisp
245 (use-package yasnippet
247 :diminish yas-minor-mode
250 (setq yas-verbosity 1)
251 (define-key yas-minor-mode-map (kbd "<tab>") nil)
252 (define-key yas-minor-mode-map (kbd "TAB") nil)
253 (define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)
259 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
261 #+BEGIN_SRC emacs-lisp
262 (use-package helm-flx
265 ;; these are helm configs, but they kind of fit here nicely
266 (setq helm-M-x-fuzzy-match t
267 helm-bookmark-show-location t
268 helm-buffers-fuzzy-matching t
269 helm-completion-in-region-fuzzy-match t
270 helm-file-cache-fuzzy-match t
271 helm-imenu-fuzzy-match t
272 helm-mode-fuzzy-match t
273 helm-locate-fuzzy-match nil
275 helm-recentf-fuzzy-match nil
276 helm-semantic-fuzzy-match t)
283 #+BEGIN_SRC emacs-lisp
285 (use-package tinyprocmail
287 :config (with-library 'tinyprocmail
288 ;; (setq tinyprocmail--procmail-version "v3.22")
289 (add-hook 'tinyprocmail--load-hook 'tinyprocmail-install))
294 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
297 :bind (("C-x g" . magit-status)
298 ("C-x C-g" . magit-status))
300 ;; don't verify where we are pushing
301 (setq magit-push-always-verify nil)
302 ;; refine diffs always (hilight words)
303 (setq magit-diff-refine-hunk nil)
306 (append '("~/lib/emacs_el/magit-annex")
310 (append '("~/lib/emacs_el/magit-vcsh")
313 (use-package magit-annex
316 (use-package magit-vcsh
317 :ensure f ; currently not in melpa, so don't try to install
322 #+BEGIN_SRC emacs-lisp
323 (require 'cperl-mode)
324 ;; Use c-mode for perl .xs files
325 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
326 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
327 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
328 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
329 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
332 cperl-auto-newline nil
333 cperl-auto-newline-after-colon nil
334 cperl-continued-statement-offset 4
335 cperl-brace-offset -1
336 cperl-continued-brace-offset 0
337 cperl-label-offset -4
338 cperl-highlight-variables-indiscriminately t
339 cperl-electric-lbrace-space nil
340 cperl-indent-parens-as-block nil
341 cperl-close-paren-offset -1
342 cperl-tab-always-indent t)
343 ;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
347 #+BEGIN_SRC emacs-lisp
352 (define-key global-map [remap find-file] 'helm-find-files)
353 (define-key global-map [remap occur] 'helm-occur)
354 (define-key global-map [remap list-buffers] 'helm-buffers-list)
355 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
356 (global-set-key (kbd "M-x") 'helm-M-x)
357 (unless (boundp 'completion-in-region-function)
358 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
359 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
360 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
364 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
369 #+BEGIN_SRC emacs-lisp
370 (add-to-list 'tramp-methods '("vcsh"
371 (tramp-login-program "vcsh")
375 (tramp-remote-shell "/bin/sh")
376 (tramp-remote-shell-args
380 #+BEGIN_SRC emacs-lisp
384 (setq-default reftex-default-bibliography
385 '("~/projects/research/references.bib")))
388 #+BEGIN_SRC emacs-lisp
393 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
394 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
395 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
396 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
397 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
398 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
399 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
400 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
401 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
402 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
403 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
405 (setq-default reftex-plug-into-AUCTeX t)
406 ;; support fake section headers
407 (setq TeX-outline-extra
413 ;; add font locking to the headers
414 (font-lock-add-keywords
416 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
417 0 'font-lock-keyword-face t)
418 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
419 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
420 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
421 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
422 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
424 ;; use smart quotes by default instead of `` and ''
425 ;; taken from http://kieranhealy.org/esk/kjhealy.html
426 (setq TeX-open-quote "“")
427 (setq TeX-close-quote "”")
429 ;; (TeX-add-style-hook
434 ;; (custom-set-variables
435 ;; '(font-latex-user-keyword-classes
438 ;; font-lock-function-name-face 2 (command 1 t))))
440 (setq-default TeX-parse-self t)
441 (setq-default TeX-auto-save t)
442 (setq-default TeX-master nil)
448 (if (boundp 'reftex-ref-style-alist)
450 'reftex-ref-style-alist
451 '("Cleveref" "cleveref"
452 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
453 (reftex-ref-style-activate "Cleveref")
455 '("cref" TeX-arg-ref)
456 '("Cref" TeX-arg-ref)
457 '("cpageref" TeX-arg-ref)
458 '("Cpageref" TeX-arg-ref)))))
461 '(add-to-list 'LaTeX-fill-excluded-macros
464 (use-package font-latex
466 (setq font-latex-match-reference-keywords
492 #+BEGIN_SRC emacs-lisp
493 (require 'org-mode-configuration)
496 #+BEGIN_SRC emacs-lisp
500 (use-package calfw-org
503 (use-package org-gcal
505 :config '((if (file-readable-p "~/.hide/org_gcal.el")
506 (load-file "~/.hide/org_gcal.el"))
511 #+BEGIN_SRC emacs-lisp
514 :config (require 'ess_configuration))
518 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
520 #+BEGIN_SRC emacs-lisp
521 (use-package rainbow-mode
522 ;; add ess to the x major mode
523 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
524 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
529 #+BEGIN_SRC emacs-lisp
530 (use-package polymode
533 (use-package poly-noweb)
534 (use-package poly-markdown)
535 :mode ("\\.Snw" . poly-noweb+r-mode)
536 :mode ("\\.Rnw" . poly-noweb+r-mode)
537 :mode ("\\.Rmd" . poly-markdown+r-mode)
543 #+BEGIN_SRC emacs-lisp
544 (use-package outline-magic)
547 #+BEGIN_SRC emacs-lisp
548 (use-package writeroom-mode
549 :config (add-hook 'writeroom-mode-hook 'auto-fill-mode)
552 ** GhostText/Atomic Chrome
553 #+BEGIN_SRC emacs-lisp
554 (use-package atomic-chrome
555 :config (atomic-chrome-start-server)
559 ** Use-package and load things
560 #+BEGIN_SRC emacs-lisp
566 ** Agenda Configuration
567 #+BEGIN_SRC emacs-lisp
568 ;; The following lines are always needed. Choose your own keys.
569 (add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode))
570 (global-set-key "\C-cl" 'org-store-link)
571 (global-set-key "\C-ca" 'org-agenda)
572 (global-set-key "\C-cb" 'org-iswitchb)
573 (setq-default org-log-done 'time)
574 (setq-default org-agenda-ndays 5)
576 ;; agenda configuration
577 ;; Do not dim blocked tasks
578 (setq org-agenda-dim-blocked-tasks nil)
579 (setq org-agenda-inhibit-startup t)
580 (setq org-agenda-use-tag-inheritance nil)
582 ;; Compact the block agenda view
583 (setq org-agenda-compact-blocks t)
585 ;; Custom agenda command definitions
586 (setq org-agenda-custom-commands
587 (quote (("N" "Notes" tags "NOTE"
588 ((org-agenda-overriding-header "Notes")
589 (org-tags-match-list-sublevels t)))
590 ("h" "Habits" tags-todo "STYLE=\"habit\""
591 ((org-agenda-overriding-header "Habits")
592 (org-agenda-sorting-strategy
593 '(todo-state-down effort-up category-keep))))
597 ((org-agenda-overriding-header "Tasks to Refile")
598 (org-tags-match-list-sublevels nil)))
599 (tags-todo "-CANCELLED/!"
600 ((org-agenda-overriding-header "Stuck Projects")
601 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
602 (org-agenda-sorting-strategy
604 (tags-todo "-HOLD-CANCELLED/!"
605 ((org-agenda-overriding-header "Projects")
606 (org-agenda-skip-function 'bh/skip-non-projects)
607 (org-tags-match-list-sublevels 'indented)
608 (org-agenda-sorting-strategy
610 (tags-todo "-CANCELLED/!NEXT"
611 ((org-agenda-overriding-header (concat "Project Next Tasks"
612 (if bh/hide-scheduled-and-waiting-next-tasks
614 " (including WAITING and SCHEDULED tasks)")))
615 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
616 (org-tags-match-list-sublevels t)
617 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
618 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
619 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
620 (org-agenda-sorting-strategy
621 '(todo-state-down effort-up category-keep))))
622 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
623 ((org-agenda-overriding-header (concat "Project Subtasks"
624 (if bh/hide-scheduled-and-waiting-next-tasks
626 " (including WAITING and SCHEDULED tasks)")))
627 (org-agenda-skip-function 'bh/skip-non-project-tasks)
628 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
629 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
630 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
631 (org-agenda-sorting-strategy
633 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
634 ((org-agenda-overriding-header (concat "Standalone Tasks"
635 (if bh/hide-scheduled-and-waiting-next-tasks
637 " (including WAITING and SCHEDULED tasks)")))
638 (org-agenda-skip-function 'bh/skip-project-tasks)
639 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
640 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
641 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
642 (org-agenda-sorting-strategy
644 (tags-todo "-CANCELLED+WAITING|HOLD/!"
645 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
646 (org-agenda-skip-function 'bh/skip-stuck-projects)
647 (org-tags-match-list-sublevels nil)
648 (org-agenda-todo-ignore-scheduled t)
649 (org-agenda-todo-ignore-deadlines t)))
651 ((org-agenda-overriding-header "Tasks to Archive")
652 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
653 (org-tags-match-list-sublevels nil))))
656 ; org mode agenda files
657 (setq org-agenda-files
658 (quote ("~/projects/org-notes/debbugs.org"
659 "~/projects/org-notes/notes.org"
660 "~/projects/org-notes/holidays.org"
661 "~/projects/org-notes/refile.org"
662 "~/projects/org-notes/diary.org"
663 "~/projects/org-notes/ool.org"
664 "~/projects/org-notes/sndservers.org"
665 "~/projects/org-notes/chaim.org"
666 "~/projects/org-notes/wildman.org"
667 "~/projects/org-notes/uddin.org"
668 "~/projects/org-notes/reviews.org"
669 "~/projects/org-notes/hpcbio.org"
670 "~/org-mode/from-mobile.org"
671 "~/projects/org-notes/fh.org")))
673 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
674 (set-register ?r (cons 'file "~/projects/org-notes/refile.org"))
675 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
676 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
677 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
678 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
679 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
680 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
681 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
682 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
683 (defun org-agenda-timeline-all (&optional arg)
686 (dolist (org-agenda-file org-agenda-files)
687 (insert-file-contents org-agenda-file nil)
690 (write-file "/tmp/timeline.org")
691 (org-agenda arg "L")))
692 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
693 ;; add automatic reminders for appointments
694 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
695 "Pressing `r' on the agenda will also add appointments."
697 (setq appt-time-msg-list nil)
698 (org-agenda-to-appt)))
702 #+BEGIN_SRC emacs-lisp
703 (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")))
704 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
706 (setq org-default-notes-file "~/projects/org-notes/notes.org")
707 (setq org-id-link-to-org-use-id t)
710 #+BEGIN_SRC emacs-lisp
711 (setq org-capture-templates ;; mail-specific note template, identified by "m"
712 '(("m" "Mail" entry (file "~/projects/org-notes/refile.org")
713 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
714 ("t" "todo" entry (file "~/projects/org-notes/refile.org")
715 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
716 ("r" "respond" entry (file "~/projects/org-notes/refile.org")
717 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
718 ("n" "note" entry (file "~/projects/org-notes/refile.org")
719 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
720 ("s" "schedule" entry (file "~/projects/org-notes/refile.org")
721 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
722 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
723 "* %?\n%U\n" :clock-in t :clock-resume t)
724 ("w" "org-protocol" entry (file "~/projects/org-notes/refile.org")
725 "* TODO Review %c\n%U\n" :immediate-finish t)
726 ("M" "Meeting" entry (file "~/projects/org-notes/refile.org")
727 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
728 ("S" "Seminar" entry (file "~/projects/org-notes/refile.org")
729 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
730 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
731 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
732 ("p" "Phone call" entry (file "~/projects/org-notes/refile.org")
733 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
734 ("J" "job" entry (file "~/projects/org-notes/refile.org")
735 "* 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)
736 ("h" "Habit" entry (file "~/projects/org-notes/refile.org")
737 "* 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")
741 ;; Remove empty LOGBOOK drawers on clock out
742 (defun bh/remove-empty-drawer-on-clock-out ()
745 (beginning-of-line 0)
746 (org-remove-empty-drawer-at (point))))
748 (defun my/org-add-id ()
751 (if (org-current-level)
760 ** Org mode key bindings
761 #+BEGIN_SRC emacs-lisp
762 ; org mode configuration from http://doc.norang.ca/org-mode.html
763 ;; Custom Key Bindings
764 (global-set-key (kbd "<f12>") 'org-agenda)
765 (global-set-key (kbd "<f5>") 'bh/org-todo)
766 (global-set-key (kbd "<S-f5>") 'bh/widen)
767 (global-set-key (kbd "<f7>") 'bh/set-truncate-lines)
768 (global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
769 (global-set-key (kbd "<f9> <f9>") 'bh/show-org-agenda)
770 (global-set-key (kbd "<f9> b") 'bbdb)
771 (global-set-key (kbd "<f9> c") 'calendar)
772 (global-set-key (kbd "<f9> f") 'boxquote-insert-file)
773 (global-set-key (kbd "<f9> h") 'bh/hide-other)
774 (global-set-key (kbd "<f9> n") 'bh/toggle-next-task-display)
775 (global-set-key (kbd "<f9> w") 'widen)
777 ; change the outline mode prefix from C-c @ to C-c C-2
778 (setq outline-minor-mode-prefix "C-c C-2")
779 ;(add-hook 'outline-minor-mode-hook
780 ; (lambda () (local-set-key (kbd "C-c C-2")
781 ; outline-mode-prefix-map)))
783 (global-set-key (kbd "<f9> I") 'bh/punch-in)
784 (global-set-key (kbd "<f9> O") 'bh/punch-out)
786 (global-set-key (kbd "<f9> o") 'bh/make-org-scratch)
788 (global-set-key (kbd "<f9> r") 'boxquote-region)
789 (global-set-key (kbd "<f9> s") 'bh/switch-to-scratch)
791 (global-set-key (kbd "<f9> t") 'bh/insert-inactive-timestamp)
792 (global-set-key (kbd "<f9> T") 'bh/toggle-insert-inactive-timestamp)
794 (global-set-key (kbd "<f9> v") 'visible-mode)
795 (global-set-key (kbd "<f9> l") 'org-toggle-link-display)
796 (global-set-key (kbd "<f9> SPC") 'bh/clock-in-last-task)
797 (global-set-key (kbd "C-<f9>") 'previous-buffer)
798 (global-set-key (kbd "M-<f9>") 'org-toggle-inline-images)
799 (global-set-key (kbd "C-x n r") 'narrow-to-region)
800 (global-set-key (kbd "C-<f10>") 'next-buffer)
801 (global-set-key (kbd "<f11>") 'org-clock-goto)
802 (global-set-key (kbd "C-<f11>") 'org-clock-in)
803 (global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)
804 (global-set-key (kbd "C-c c") 'org-capture)
808 #+BEGIN_SRC emacs-lisp
809 (defun bh/hide-other ()
812 (org-back-to-heading 'invisible-ok)
818 (defun bh/set-truncate-lines ()
819 "Toggle value of truncate-lines and refresh window display."
821 (setq truncate-lines (not truncate-lines))
822 ;; now refresh window display (an idiom from simple.el):
824 (set-window-start (selected-window)
825 (window-start (selected-window)))))
827 (defun bh/make-org-scratch ()
829 (find-file "/tmp/publish/scratch.org")
830 (gnus-make-directory "/tmp/publish"))
832 (defun bh/switch-to-scratch ()
834 (switch-to-buffer "*scratch*"))
836 (setq org-use-fast-todo-selection t)
837 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
839 ; create function to create headlines in file. This comes from
840 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
841 (defun my/org-add-ids-to-headlines-in-file ()
842 "Add ID properties to all headlines in the current file which
843 do not already have one."
845 (org-map-entries 'org-id-get-create))
846 ; if we wanted to do this to every buffer, do the following:
847 ; (add-hook 'org-mode-hook
849 ; (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
852 #+BEGIN_SRC emacs-lisp
853 (setq org-todo-keywords
854 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
855 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
857 (setq org-todo-keyword-faces
858 (quote (("TODO" :foreground "red" :weight bold)
859 ("NEXT" :foreground "blue" :weight bold)
860 ("DONE" :foreground "forest green" :weight bold)
861 ("WAITING" :foreground "orange" :weight bold)
862 ("HOLD" :foreground "magenta" :weight bold)
863 ("CANCELLED" :foreground "forest green" :weight bold)
864 ("MEETING" :foreground "forest green" :weight bold)
865 ("PHONE" :foreground "forest green" :weight bold))))
867 (setq org-todo-state-tags-triggers
868 (quote (("CANCELLED" ("CANCELLED" . t))
869 ("WAITING" ("WAITING" . t))
870 ("HOLD" ("WAITING") ("HOLD" . t))
871 (done ("WAITING") ("HOLD"))
872 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
873 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
874 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
878 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
879 ; add ids on creation of nodes
880 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
883 ; resolve clocks after 10 minutes of idle; use xprintidle
884 ; (setq org-clock-idle-time 10)
885 ; (setq org-clock-x11idle-program-name "xprintidle")
887 ; this is from http://doc.norang.ca/org-mode.html#Capture
888 ; use C-M-r for org mode capture
889 (global-set-key (kbd "C-M-r") 'org-capture)
891 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
892 (setq org-refile-targets (quote ((nil :maxlevel . 9)
893 (org-agenda-files :maxlevel . 9))))
895 ; Use full outline paths for refile targets - we file directly with IDO
896 (setq org-refile-use-outline-path t)
898 ; Targets complete directly with IDO
899 (setq org-outline-path-complete-in-steps nil)
901 ; Allow refile to create parent tasks with confirmation
902 (setq org-refile-allow-creating-parent-nodes (quote confirm))
904 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
905 ; (setq org-completion-use-ido t)
906 ; (setq ido-everywhere t)
907 ; (setq ido-max-directory-size 100000)
908 ; (ido-mode (quote both))
909 ; ; Use the current window when visiting files and buffers with ido
910 ; (setq ido-default-file-method 'selected-window)
911 ; (setq ido-default-buffer-method 'selected-window)
912 ; ; Use the current window for indirect buffer display
913 ; (setq org-indirect-buffer-display 'current-window)
917 ; Exclude DONE state tasks from refile targets
918 (defun bh/verify-refile-target ()
919 "Exclude todo keywords with a done state from refile targets"
920 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
922 (setq org-refile-target-verify-function 'bh/verify-refile-target)
924 ;; ensure that emacsclient will show just the note to be edited when invoked
925 ;; from Mutt, and that it will shut down emacsclient once finished;
926 ;; fallback to legacy behavior when not invoked via org-protocol.
927 (require 'org-protocol)
928 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
929 (setq my-org-protocol-flag nil)
930 (defadvice org-capture-finalize (after delete-frame-at-end activate)
931 "Delete frame at remember finalization"
932 (progn (if my-org-protocol-flag (delete-frame))
933 (setq my-org-protocol-flag nil)))
934 (defadvice org-capture-refile (around delete-frame-after-refile activate)
935 "Delete frame at remember refile"
936 (if my-org-protocol-flag
938 (setq my-org-protocol-flag nil)
943 (defadvice org-capture-kill (after delete-frame-at-end activate)
944 "Delete frame at remember abort"
945 (progn (if my-org-protocol-flag (delete-frame))
946 (setq my-org-protocol-flag nil)))
947 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
948 (setq my-org-protocol-flag t))
950 (defadvice org-insert-todo-heading (after dla/create-id activate)
955 (add-to-list 'org-modules 'org-habit)
957 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
958 (defun open-mail-in-mutt (message)
959 "Open a mail message in Mutt, using an external terminal.
961 Message can be specified either by a path pointing inside a
962 Maildir, or by Message-ID."
963 (interactive "MPath or Message-ID: ")
965 (format "faf xterm -e \"%s %s\""
966 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
968 ;; add support for "mutt:ID" links
969 (org-add-link-type "mutt" 'open-mail-in-mutt)
971 (defun my-org-mode-setup ()
972 (load-library "reftex")
973 (and (buffer-file-name)
974 (file-exists-p (buffer-file-name))
977 (reftex-set-cite-format
978 '((?b . "[[bib:%l][%l-bib]]")
979 (?n . "[[notes:%l][%l-notes]]")
981 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
983 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
984 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
985 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
986 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
988 (add-hook 'org-mode-hook 'my-org-mode-setup)
990 (defun org-mode-reftex-search ()
992 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
994 (defun open-research-paper (bibtexkey)
995 "Open a paper by bibtex key"
996 (interactive "bibtex key: ")
999 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1000 (org-add-link-type "papers" 'open-research-paper)
1001 (defun open-research-paper-pdf (bibtexkey)
1002 "Open a paper pdf by bibtex key"
1003 (interactive "bibtex key: ")
1005 (format "%s -p evince_annot %s"
1006 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1007 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
1009 (add-to-list 'org-link-abbrev-alist
1011 "~/projects/research/paper_notes.org::#%s"))
1013 ; I pretty much always want hiearchical checkboxes
1014 (setq org-hierachical-checkbox-statistics nil)
1016 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
1017 (add-to-list 'org-structure-template-alist
1018 '("E" "\\begin{equation}\n?\n\\end{equation}"))
1021 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
1022 (defun my-rtcite-export-handler (path desc format)
1023 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
1024 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
1025 (match-string 1 path)))
1026 (path (substring path 0 (match-beginning 0))))
1027 (cond ((eq format 'latex)
1029 (equal 0 (search "rtcite:" desc)))
1030 (format "\\cite{%s}" search)
1031 (format "\\cite[%s]{%s}" desc search))))))
1033 (org-add-link-type "rtcite"
1035 'my-rtcite-export-handler)
1039 ** Org Mobile Configuration
1040 #+BEGIN_SRC emacs-lisp
1041 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
1042 (when (string= system-name "linnode")
1043 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
1044 (setq-default org-directory "/home/don/org-mode/")
1045 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
1049 #+BEGIN_SRC emacs-lisp
1050 ;; org mode ical export
1051 (setq org-icalendar-timezone "America/Los_Angeles")
1052 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
1053 ;; we already add the id manually
1054 ;; (setq org-icalendar-store-UID t)
1057 ** General Org Babel Configuration
1058 #+BEGIN_SRC emacs-lisp
1059 ;; org babel support
1060 (org-babel-do-load-languages
1061 'org-babel-load-languages
1068 ;; use graphviz-dot for dot things
1069 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
1070 ;; org-babel-by-backend
1071 (defmacro org-babel-by-backend (&rest body)
1072 `(case (if (boundp 'backend)
1073 (org-export-backend-name backend)
1076 (defun my/fix-inline-images ()
1077 (when org-inline-image-overlays
1078 (org-redisplay-inline-images)))
1080 (add-hook 'org-babel-after-execute-hook
1081 'my/fix-inline-images)
1084 ** LaTeX configuration
1086 :ID: 7135ba17-6a50-4eed-84ca-b90afa5b12f8
1088 #+BEGIN_SRC emacs-lisp
1090 (add-to-list 'org-latex-classes
1092 "\\documentclass[11pt,oneside,article]{memoir}\n"
1093 ("\\section{%s}" . "\\section*{%s}")
1094 ("\\subsection{%s}" . "\\subsection*{%s}")
1095 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1096 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1097 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1099 (setq org-beamer-outline-frame-options "")
1100 (add-to-list 'org-latex-classes
1102 "\\documentclass[ignorenonframetext]{beamer}
1103 [NO-DEFAULT-PACKAGES]
1106 ("\\section{%s}" . "\\section*{%s}")
1107 ("\\subsection{%s}" . "\\subsection*{%s}")
1108 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1109 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1110 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1112 (add-to-list 'org-latex-classes
1114 "\\documentclass[11pt,oneside]{memoir}\n"
1115 ("\\chapter{%s}" . "\\chapter*{%s}")
1116 ("\\section{%s}" . "\\section*{%s}")
1117 ("\\subsection{%s}" . "\\subsection*{%s}")
1118 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
1120 (add-to-list 'org-latex-classes
1122 "\\documentclass[11pt]{letter}
1123 [NO-DEFAULT-PACKAGES]
1126 ("\\section{%s}" . "\\section*{%s}")
1127 ("\\subsection{%s}" . "\\subsection*{%s}")
1128 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1129 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1130 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1132 (add-to-list 'org-latex-classes
1134 "\\documentclass{dlacv}
1135 [NO-DEFAULT-PACKAGES]
1138 ("\\section{%s}" . "\\section*{%s}")
1139 ("\\subsection{%s}" . "\\subsection*{%s}")
1140 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1141 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1142 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1145 (add-to-list 'org-latex-classes
1147 "\\documentclass{dlaresume}
1148 [NO-DEFAULT-PACKAGES]
1151 ("\\section{%s}" . "\\section*{%s}")
1152 ("\\subsection{%s}" . "\\subsection*{%s}")
1153 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1154 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1155 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1158 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
1159 ;; but adapted to use latexmk 4.22 or higher.
1160 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
1162 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
1163 (setq org-latex-default-packages-alist
1165 ("" "unicode-math" t)
1167 (setq org-latex-packages-alist
1174 ("" "longtable" nil)
1177 ;; make equations larger
1178 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
1180 (defun org-create-formula--latex-header ()
1181 "Return LaTeX header appropriate for previewing a LaTeX snippet."
1182 (let ((info (org-combine-plists (org-export--get-global-options
1183 (org-export-get-backend 'latex))
1184 (org-export--get-inbuffer-options
1185 (org-export-get-backend 'latex)))))
1186 (org-latex-guess-babel-language
1187 (org-latex-guess-inputenc
1188 (org-splice-latex-header
1189 org-format-latex-header
1190 org-latex-default-packages-alist
1192 (plist-get info :latex-header)))
1196 ; support ignoring headers in org mode export to latex
1197 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
1198 (defadvice org-latex-headline (around my-latex-skip-headlines
1199 (headline contents info) activate)
1200 (if (member "ignoreheading" (org-element-property :tags headline))
1201 (setq ad-return-value contents)
1204 ;; keep latex logfiles
1206 (setq org-latex-remove-logfiles nil)
1208 ;; Resume clocking task when emacs is restarted
1209 (org-clock-persistence-insinuate)
1211 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
1212 (setq org-clock-history-length 23)
1213 ;; Resume clocking task on clock-in if the clock is open
1214 (setq org-clock-in-resume t)
1215 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
1216 ;; there are things like PHONE calls
1217 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
1218 ;; Separate drawers for clocking and logs
1219 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
1220 ;; Save clock data and state changes and notes in the LOGBOOK drawer
1221 (setq org-clock-into-drawer t)
1222 (setq org-log-into-drawer t)
1223 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
1224 (setq org-clock-out-remove-zero-time-clocks t)
1225 ;; Clock out when moving task to a done state
1226 (setq org-clock-out-when-done t)
1227 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
1228 (setq org-clock-persist t)
1229 ;; Do not prompt to resume an active clock
1230 (setq org-clock-persist-query-resume nil)
1231 ;; Enable auto clock resolution for finding open clocks
1232 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
1233 ;; Include current clocking task in clock reports
1234 (setq org-clock-report-include-clocking-task t)
1236 ;; the cache seems to be broken
1237 (setq org-element-use-cache nil)
1239 (defvar bh/keep-clock-running nil)
1241 (defun bh/is-task-p ()
1242 "Any task with a todo keyword and no subtask"
1246 (subtree-end (save-excursion (org-end-of-subtree t)))
1247 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1250 (while (and (not has-subtask)
1251 (< (point) subtree-end)
1252 (re-search-forward "^\*+ " subtree-end t))
1253 (when (member (org-get-todo-state) org-todo-keywords-1)
1254 (setq has-subtask t))))
1255 (and is-a-task (not has-subtask)))))
1257 (defun bh/is-subproject-p ()
1258 "Any task which is a subtask of another project"
1259 (let ((is-subproject)
1260 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1262 (while (and (not is-subproject) (org-up-heading-safe))
1263 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1264 (setq is-subproject t))))
1265 (and is-a-task is-subproject)))
1268 (defun bh/clock-in-to-next (kw)
1269 "Switch a task from TODO to NEXT when clocking in.
1270 Skips capture tasks, projects, and subprojects.
1271 Switch projects and subprojects from NEXT back to TODO"
1272 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
1274 ((and (member (org-get-todo-state) (list "TODO"))
1277 ((and (member (org-get-todo-state) (list "NEXT"))
1281 (defun bh/punch-in (arg)
1282 "Start continuous clocking and set the default task to the
1283 selected task. If no task is selected set the Organization task
1284 as the default task."
1286 (setq bh/keep-clock-running t)
1287 (if (equal major-mode 'org-agenda-mode)
1289 ;; We're in the agenda
1291 (let* ((marker (org-get-at-bol 'org-hd-marker))
1292 (tags (org-with-point-at marker (org-get-tags-at))))
1293 (if (and (eq arg 4) tags)
1294 (org-agenda-clock-in '(16))
1295 (bh/clock-in-organization-task-as-default)))
1297 ;; We are not in the agenda
1301 ; Find the tags on the current task
1302 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
1303 (org-clock-in '(16))
1304 (bh/clock-in-organization-task-as-default)))))
1306 (defun bh/punch-out ()
1308 (setq bh/keep-clock-running nil)
1309 (when (org-clock-is-active)
1311 (org-agenda-remove-restriction-lock))
1313 (defun bh/clock-in-default-task ()
1315 (org-with-point-at org-clock-default-task
1318 (defun bh/clock-in-parent-task ()
1319 "Move point to the parent (project) task if any and clock in"
1320 (let ((parent-task))
1324 (while (and (not parent-task) (org-up-heading-safe))
1325 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1326 (setq parent-task (point))))
1328 (org-with-point-at parent-task
1330 (when bh/keep-clock-running
1331 (bh/clock-in-default-task)))))))
1333 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
1335 (defun bh/clock-in-organization-task-as-default ()
1337 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
1338 (org-clock-in '(16))))
1340 (defun bh/clock-out-maybe ()
1341 (when (and bh/keep-clock-running
1342 (not org-clock-clocking-in)
1343 (marker-buffer org-clock-default-task)
1344 (not org-clock-resolving-clocks-due-to-idleness))
1345 (bh/clock-in-parent-task)))
1347 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1350 (defun bh/clock-in-task-by-id (id)
1351 "Clock in a task by id"
1352 (org-with-point-at (org-id-find id 'marker)
1353 (org-clock-in nil)))
1355 (defun bh/clock-in-last-task (arg)
1356 "Clock in the interrupted task if there is one
1357 Skip the default task and get the next one.
1358 A prefix arg forces clock in of the default task."
1360 (let ((clock-in-to-task
1362 ((eq arg 4) org-clock-default-task)
1363 ((and (org-clock-is-active)
1364 (equal org-clock-default-task (cadr org-clock-history)))
1365 (caddr org-clock-history))
1366 ((org-clock-is-active) (cadr org-clock-history))
1367 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
1368 (t (car org-clock-history)))))
1370 (org-with-point-at clock-in-to-task
1371 (org-clock-in nil))))
1374 (defun org-export-to-ods ()
1376 (let ((csv-file "data.csv"))
1377 (org-table-export csv-file "orgtbl-to-csv")
1378 (org-odt-convert csv-file "ods" 'open)))
1380 ; allow for zero-width-space to be a break in regexp too
1381 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
1382 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
1383 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
1385 ;; support inserting screen shots
1386 (defun my/org-insert-screenshot ()
1387 "Take a screenshot into a time stamped unique-named file in the
1388 same directory as the org-buffer and insert a link to this file."
1390 (defvar my/org-insert-screenshot/filename)
1391 (setq my/org-insert-screenshot/filename
1393 "Screenshot to insert: "
1395 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
1398 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
1399 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
1400 (org-display-inline-images))
1402 (defun my/fix-inline-images ()
1403 (when org-inline-image-overlays
1404 (org-redisplay-inline-images)))
1406 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
1408 ;; use xelatex to preview with imagemagick
1409 (add-to-list 'org-preview-latex-process-alist
1410 '(xelateximagemagick
1411 :programs ("xelatex" "convert")
1412 :description "pdf > png"
1413 :message "you need to install xelatex and imagemagick"
1415 :image-input-type "pdf"
1416 :image-output-type "png"
1417 :image-size-adjust (1.0 . 1.0)
1418 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
1419 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
1421 ;; use xelatex by default
1422 (setq org-preview-latex-default-process 'xelateximagemagick)
1424 ; from http://orgmode.org/Changes.html
1425 (defun my/org-repair-property-drawers ()
1426 "Fix properties drawers in current buffer.
1427 Ignore non Org buffers."
1429 (when (eq major-mode 'org-mode)
1430 (org-with-wide-buffer
1431 (goto-char (point-min))
1432 (let ((case-fold-search t)
1433 (inline-re (and (featurep 'org-inlinetask)
1434 (concat (org-inlinetask-outline-regexp)
1438 (unless (and inline-re (org-looking-at-p inline-re))
1440 (let ((end (save-excursion (outline-next-heading) (point))))
1442 (when (org-looking-at-p org-planning-line-re) (forward-line))
1443 (when (and (< (point) end)
1444 (not (org-looking-at-p org-property-drawer-re))
1446 (and (re-search-forward org-property-drawer-re end t)
1447 (eq (org-element-type
1448 (save-match-data (org-element-at-point)))
1450 (insert (delete-and-extract-region
1452 (min (1+ (match-end 0)) end)))
1453 (unless (bolp) (insert "\n"))))))))))))
1457 #+BEGIN_SRC emacs-lisp
1461 ** Override other things
1462 #+BEGIN_SRC emacs-lisp
1463 ; apparently things like to step on C-;, so we'll use a hack from
1464 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
1466 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
1468 ; use iedit everywhere
1469 (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
1470 ;; use outline mode keybindings everywhere
1471 ;; (define-key my-keys-minor-mode-map (kbd "C-;") 'my/mydra-outline/body)
1473 (define-minor-mode my-keys-minor-mode
1474 "A minor mode so that my key settings override annoying major modes."
1475 t " my-keys" 'my-keys-minor-mode-map)
1477 (my-keys-minor-mode 1)
1478 (defun my-minibuffer-setup-hook ()
1479 (my-keys-minor-mode 0))
1481 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
1482 (defadvice load (after give-my-keybindings-priority)
1483 "Try to ensure that my keybindings always have priority."
1484 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
1485 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
1486 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
1487 (add-to-list 'minor-mode-map-alist mykeys))))
1491 * Misc (uncharacterized)
1492 #+BEGIN_SRC emacs-lisp
1493 (setq bibtex-user-optional-fields (quote (("annote" "Personal annotation (ignored)") ("abstract" "") ("pmid" "") ("doi" ""))))
1494 (setq calendar-latitude 40.11)
1495 (setq calendar-longitude -88.24)
1496 (setq case-fold-search t)
1497 (setq confirm-kill-emacs (quote y-or-n-p))
1498 (setq cperl-lazy-help-time nil)
1499 (setq debian-changelog-mailing-address "don@debian.org")
1501 (setq display-time-24hr-format t)
1502 (setq display-time-day-and-date t)
1503 (display-time-mode 1)
1504 (setq font-latex-fontify-script nil)
1505 (setq font-latex-fontify-sectioning (quote color))
1506 (setq font-latex-script-display (quote (nil)))
1507 (global-auto-revert-mode 1)
1508 (global-font-lock-mode 1)
1510 (setq log-edit-keep-buffer t)
1511 (setq mail-user-agent (quote sendmail-user-agent))
1512 (setq markdown-enable-math t)
1513 (setq markdown-follow-wiki-link-on-enter nil)
1514 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
1515 (setq post-email-address "don@donarmstrong.com")
1516 (setq post-kill-quoted-sig nil)
1517 (setq post-mail-message "mutt\\(ng\\|\\)-[a-z0-9]+-[0-9]+-.*")
1518 (setq post-uses-fill-mode nil)
1519 (setq ps-footer-font-size (quote (8 . 10)))
1520 (setq ps-header-font-size (quote (8 . 10)))
1521 (setq ps-header-title-font-size (quote (10 . 10)))
1522 (setq ps-line-number-color "blue")
1523 (setq ps-print-footer t)
1524 (setq ps-print-footer-frame nil)
1525 (setq ps-print-only-one-header t)
1526 (setq safe-local-variable-values (quote ((auto-save-default) (make-backup-files))))
1527 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
1529 (setq sentence-end-double-space nil)
1530 ; enable matching parenthesis
1533 (setq user-mail-address "don@donarmstrong.com")
1534 (setq vc-delete-logbuf-window nil)
1535 (setq vc-follow-symlinks t)
1537 ;; use git before SVN; use CVS earlier, because I have CVS
1538 ;; repositories inside of git directories
1539 (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
1541 ;; switch back to the old primary selection method
1542 (setq x-select-enable-clipboard nil)
1543 (setq x-select-enable-primary t)
1544 ; (setq mouse-drag-copy-region t)
1546 (fset 'perl-mode 'cperl-mode)
1547 ;;(load-file "cperl-mode.el")
1553 ;;(require 'ecasound)
1554 ;;(require 'emacs-wiki)
1558 ; (require 'google-weather)
1559 ; (require 'org-google-weather)
1560 ; (setq-default org-google-weather-format "%i %c, [%l,%h] %s %C")
1562 (global-set-key "\C-xp" 'server-edit)
1564 (setq-default auto-mode-alist (cons '("\.wml$" .
1565 (lambda () (html-mode) (auto-fill-mode)))
1569 ; use markdown mode for mdwn files
1570 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
1571 (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
1574 ;; tramp configuration
1575 (setq tramp-use-ssh-controlmaster-options nil)
1577 ; mail configuration
1578 (add-to-list 'auto-mode-alist '("muttng-[a-z0-9]+-[0-9]+-" . message-mode))
1579 (add-to-list 'auto-mode-alist '("muttngrc" . muttrc-mode))
1581 (add-to-list 'auto-mode-alist '("mutt-[a-z0-9]+-[0-9]+-" . message-mode))
1582 (add-to-list 'auto-mode-alist '("muttrc" . muttrc-mode))
1583 (defun my-message-mode-settings ()
1584 (font-lock-add-keywords nil
1585 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1586 (0 'message-multiply-quoted-text-face))
1587 ("^[ \t]*>[ \t]*>.*$"
1588 (0 'message-double-quoted-text-face))))
1589 (local-set-key (kbd "C-c C-a") 'my-post-attach-file)
1591 (add-hook 'message-mode-hook 'my-message-mode-settings)
1593 (defun my-post-attach-file ()
1594 "Prompt for an attachment."
1596 (let ((file (read-file-name "Attach file: " nil nil t nil))
1597 (description (string-read "Description: ")))
1598 (my-header-attach-file file description)))
1600 (symbol-function 'my-post-attach-file)
1602 (defun my-header-attach-file (file description)
1603 "Attach a FILE to the current message (works with Mutt).
1604 Argument DESCRIPTION MIME description."
1605 (interactive "fAttach file: \nsDescription: ")
1606 (when (> (length file) 0)
1611 (goto-char (point-min))
1612 (search-forward-regexp "^$")
1613 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1615 (message (concat "Attached '" file "'."))
1616 (setq post-has-attachment t))))))
1620 (setq mail-yank-prefix "> ")
1622 (global-unset-key "\M-g")
1623 (global-set-key "\M-g" 'goto-line)
1625 ;; self-insert-command hack.
1626 ;; Without this, "if<SP>" expands to
1629 ;; which really should be,
1635 ;(load-library "php-mode")
1637 (setq-default c-indent-level 4)
1638 (setq-default c-brace-imaginary-offset 0)
1639 (setq-default c-brace-offset -4)
1640 (setq-default c-argdecl-indent 4)
1641 (setq-default c-label-offset -4)
1642 (setq-default c-continued-statement-offset 4)
1644 (setq-default indent-tabs-mode nil)
1645 (setq-default tab-width 4)
1648 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
1649 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
1650 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
1651 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
1652 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
1655 (defun insert-date ()
1656 "Insert date at point."
1658 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
1659 (global-set-key "\C-[d" 'insert-date)
1661 (defun unfill-paragraph (arg)
1662 "Pull this whole paragraph up onto one line."
1664 (let ((fill-column 10000))
1665 (fill-paragraph arg))
1668 (column-number-mode t)
1672 ; (require 'mode-compile)
1674 (defadvice server-process-filter (after post-mode-message first activate)
1675 "If the buffer is in post mode, overwrite the server-edit
1676 message with a post-save-current-buffer-and-exit message."
1677 (if (eq major-mode 'post-mode)
1679 (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done."))))
1680 ; This is also needed to see the magic message. Set to a higher
1681 ; number if you have a faster computer or read slower than me.
1682 '(font-lock-verbose 1000)
1683 ;(setq-default server-temp-file-regexp "mutt\(-\|ng-\)")
1684 ; (add-hook 'server-switch-hook
1685 ; (function (lambda()
1686 ; (cond ((string-match "Post" mode-name)
1687 ; (post-goto-body)))
1688 ; set-buffer-file-coding-system 'utf-8
1692 (add-hook 'post-mode-hook
1693 (auto-fill-mode nil)
1695 ; abbrev mode settings
1696 ; load abbreviations from
1697 (setq abbrev-file-name
1698 "~/.emacs_abbrev_def")
1700 ; read the abbrev file if it exists
1701 (if (file-exists-p abbrev-file-name)
1702 (quietly-read-abbrev-file))
1704 ; for now, use abbrev mode everywhere
1705 (setq default-abbrev-mode t)
1708 (defun insert-function-documentation ()
1709 "Insert function documentation"
1711 (insert-file-contents "/home/don/lib/templates/perl_function_documentation" nil))
1712 (global-set-key "\M-f" 'insert-function-documentation)
1714 (eval-after-load "lilypond-mode"
1716 (load-library "lyqi-mode")
1717 (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
1719 (autoload 'spamassassin-mode "spamassassin-mode" nil t)
1721 (desktop-load-default)
1723 '(icomplete-mode on)
1725 ;; custom-set-faces was added by Custom.
1726 ;; If you edit it by hand, you could mess it up, so be careful.
1727 ;; Your init file should contain only one such instance.
1728 ;; If there is more than one, they won't work right.
1729 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
1732 (put 'upcase-region 'disabled nil)
1733 (put 'downcase-region 'disabled nil)
1734 (put 'narrow-to-region 'disabled nil)
1736 ; (defun turn-on-flyspell ()
1737 ; "Force flyspell-mode on using a positive arg. For use in hooks."
1739 ; (flyspell-mode 1))
1742 ; Outline-minor-mode key map
1743 (define-prefix-command 'cm-map nil "Outline-")
1745 (define-key cm-map "q" 'hide-sublevels) ; Hide everything but the top-level headings
1746 (define-key cm-map "t" 'hide-body) ; Hide everything but headings (all body lines)
1747 (define-key cm-map "o" 'hide-other) ; Hide other branches
1748 (define-key cm-map "c" 'hide-entry) ; Hide this entry's body
1749 (define-key cm-map "l" 'hide-leaves) ; Hide body lines in this entry and sub-entries
1750 (define-key cm-map "d" 'hide-subtree) ; Hide everything in this entry and sub-entries
1752 (define-key cm-map "a" 'show-all) ; Show (expand) everything
1753 (define-key cm-map "e" 'show-entry) ; Show this heading's body
1754 (define-key cm-map "i" 'show-children) ; Show this heading's immediate child sub-headings
1755 (define-key cm-map "k" 'show-branches) ; Show all sub-headings under this heading
1756 (define-key cm-map "s" 'show-subtree) ; Show (expand) everything in this heading & below
1758 (define-key cm-map "u" 'outline-up-heading) ; Up
1759 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
1760 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
1761 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
1762 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
1763 (global-set-key "\M-o" cm-map)
1767 (setq-default debian-changelog-mailing-address "don@debian.org")
1768 (setq-default debian-changelog-full-name "Don Armstrong")
1770 ; ediff configuration
1771 ; don't use the multi-window configuration
1772 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
1776 (define-key global-map (kbd "C-;") 'iedit-mode)
1777 (global-set-key (kbd "C-;") 'iedit-mode)
1779 ; fix up css mode to not be silly
1780 ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
1781 (setq cssm-indent-level 4)
1782 (setq cssm-newline-before-closing-bracket t)
1783 (setq cssm-indent-function #'cssm-c-style-indenter)
1784 (setq cssm-mirror-mode nil)
1786 (require 'multi-web-mode)
1787 (setq mweb-default-major-mode 'html-mode)
1788 (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
1789 (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
1790 (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
1791 (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
1792 (multi-web-global-mode 1)
1794 ;;; alias the new `flymake-report-status-slim' to
1795 ;;; `flymake-report-status'
1796 (defalias 'flymake-report-status 'flymake-report-status-slim)
1797 (defun flymake-report-status-slim (e-w &optional status)
1798 "Show \"slim\" flymake status in mode line."
1800 (setq flymake-mode-line-e-w e-w))
1802 (setq flymake-mode-line-status status))
1803 (let* ((mode-line " Φ"))
1804 (when (> (length flymake-mode-line-e-w) 0)
1805 (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
1806 (setq mode-line (concat mode-line flymake-mode-line-status))
1807 (setq flymake-mode-line mode-line)
1808 (force-mode-line-update)))
1810 ; load sql-indent when sql is loaded
1811 (eval-after-load "sql"
1812 '(load-library "sql-indent"))
1814 ; fix up tmux xterm keys
1815 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
1816 (defun fix-up-tmux-keys ()
1817 "Fix up tmux xterm keys"
1820 (let ((x 2) (tkey ""))
1840 ;; ctrl + alt + shift
1842 (setq tkey "C-M-S-"))
1845 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
1846 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
1847 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
1848 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
1850 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
1852 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
1854 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
1856 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
1858 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
1860 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
1862 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
1864 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
1866 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
1868 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
1870 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
1872 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
1874 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
1876 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
1878 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
1880 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
1882 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
1884 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
1886 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
1888 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
1890 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
1892 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
1894 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
1896 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
1898 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
1900 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
1907 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
1909 ; procmailmode configuration
1910 (load "procmail_mode")
1912 (load "mode-line-cleaner")
1914 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
1915 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
1916 (if (or (buffer-modified-p)
1917 (verify-visited-file-modtime)
1918 (< (* 8 1024 1024) (buffer-size))
1919 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
1921 (clear-visited-file-modtime)
1923 (ad-activate 'ask-user-about-supersession-threat)
1925 ; apparently things like to step on C-;, so we'll use a hack from
1926 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
1928 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
1930 ; use iedit everywhere
1931 (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
1933 (define-minor-mode my-keys-minor-mode
1934 "A minor mode so that my key settings override annoying major modes."
1935 t " my-keys" 'my-keys-minor-mode-map)
1937 (my-keys-minor-mode 1)
1938 (defun my-minibuffer-setup-hook ()
1939 (my-keys-minor-mode 0))
1941 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
1942 (defadvice load (after give-my-keybindings-priority)
1943 "Try to ensure that my keybindings always have priority."
1944 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
1945 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
1946 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
1947 (add-to-list 'minor-mode-map-alist mykeys))))
1949 (global-set-key "\M- " 'hippie-expand)
1954 #+BEGIN_SRC emacs-lisp
1955 (provide 'don-configuration)