1 #+PROPERTY: header-args:emacs-lisp :tangle don-configuration.el
4 # if for some reason, things get pear-shaped, we want to be able to
5 # enter the debugger by sending -USR2 to emacs
8 (setq debug-on-event 'siguser2)
12 #+BEGIN_SRC emacs-lisp
13 (add-to-list 'load-path '"~/lib/emacs_el/")
14 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/tiny")
15 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/other")
16 (add-to-list 'load-path '"~/lib/emacs_el/magit-annex")
20 ** package repositories and package manager
21 #+BEGIN_SRC emacs-lisp
23 (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
24 ("melpa" . "https://melpa.org/packages/")
25 ("org" . "http://orgmode.org/elpa/") ))
27 ** [[https://github.com/jwiegley/use-package/][use-package]]
28 #+BEGIN_SRC emacs-lisp
30 (require 'use-package)
33 #+BEGIN_SRC emacs-lisp
39 #+BEGIN_SRC emacs-lisp
40 ;; Set the custom file to /dev/null and don't bother to load it
41 (setq custom-file "/dev/null")
45 #+BEGIN_SRC emacs-lisp
46 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
47 ;; execute conditional code when loading libraries
48 (defmacro with-library (symbol &rest body)
49 `(when (require ,symbol nil t)
51 (put 'with-library 'lisp-indent-function 1)
55 ** Safe Local Variables
56 #+BEGIN_SRC emacs-lisp
57 (setq safe-local-variable-values
58 (quote ((auto-save-default)
60 (cperl-indent-level . 4)
62 (indent-tabs-mode . f)
66 #+BEGIN_SRC emacs-lisp
67 (setq global-mark-ring-max 128
71 (defun don/minibuffer-setup-hook ()
72 (setq gc-cons-threshold most-positive-fixnum))
74 (defun don/minibuffer-exit-hook ()
75 (setq gc-cons-threshold 1048576))
77 (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
78 (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
82 #+BEGIN_SRC emacs-lisp
85 :diminish flyspell-mode 🐝
87 (add-hook 'message-mode-hook 'turn-on-flyspell)
88 (add-hook 'text-mode-hook 'turn-on-flyspell)
89 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
90 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
91 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
93 (setq ispell-program-name "ispell")
98 #+BEGIN_SRC emacs-lisp
103 #+BEGIN_SRC emacs-lisp
104 ;; (use-package eyebrowse
106 ;; :diminish eyebrowse-mode
107 ;; :init (setq eyebrowse-keymap-prefix (kbd "C-c C-\\"))
109 ;; (setq eyebrowse-wrap-around t)
110 ;; (eyebrowse-mode t)
112 ;; (defun my/eyebrowse-new-window-config ()
116 ;; ;; start at 1 run till 0
117 ;; (let ((j (mod (+ i 1) 10)))
118 ;; (when (and (not done)
119 ;; (not (eyebrowse--window-config-present-p j)))
120 ;; (eyebrowse-switch-to-window-config j)
121 ;; (call-interactively 'eyebrowse-rename-window-config2 j)
126 ;; ;; I don't use latex-preview-pane
127 ;; ;; (require 'latex-preview-pane)
128 ;; ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
129 ;; ;; ;; latex-preview-pane uses window-parameters which are
130 ;; ;; ;; not preserved by eyebrowse, so we close the preview
131 ;; ;; ;; pane before switching, it will be regenerated when we
132 ;; ;; ;; edit the TeX file.
133 ;; ;; (when (lpp/window-containing-preview)
134 ;; ;; (delete-window (lpp/window-containing-preview))))
136 ;; ;; (add-to-list 'eyebrowse-pre-window-switch-hook
137 ;; ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
139 ;; ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
140 ;; ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
141 ;; ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
142 ;; ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
143 ;; ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
151 #+BEGIN_SRC emacs-lisp
152 (defun my/vsplit-last-buffer ()
153 "Split the window vertically and display the previous buffer."
155 (split-window-vertically)
157 (switch-to-next-buffer))
159 (defun my/hsplit-last-buffer ()
160 "Split the window horizontally and display the previous buffer."
162 (split-window-horizontally)
164 (switch-to-next-buffer))
166 (bind-key "C-x 2" 'my/vsplit-last-buffer)
167 (bind-key "C-x 3" 'my/hsplit-last-buffer)
169 (setq split-width-threshold 100)
170 (setq split-height-threshold 60)
172 (defun my/split-window-prefer-vertically (window)
173 "If there's only one window (excluding any possibly active
174 minibuffer), then split the current window horizontally."
175 (if (and (one-window-p t)
176 (not (active-minibuffer-window))
177 ( < (frame-width) (frame-height))
179 (let ((split-width-threshold nil))
180 (split-window-sensibly window))
181 (split-window-sensibly window)))
183 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
184 (setq window-combination-resize t)
187 *** Compilation window
189 If there is no compilation window, open one at the bottom, spanning
190 the complete width of the frame. Otherwise, reuse existing window. In
191 the former case, if there was no error the window closes
194 #+BEGIN_SRC emacs-lisp
195 (add-to-list 'display-buffer-alist
196 `(,(rx bos "*compilation*" eos)
197 (display-buffer-reuse-window
198 display-buffer-in-side-window)
199 (reusable-frames . visible)
201 (window-height . 0.4)))
204 #+BEGIN_SRC emacs-lisp
205 (defun my/compilation-exit-autoclose (status code msg)
206 ;; If M-x compile exists with a 0
207 (when (and (eq status 'exit) (zerop code))
208 ;; and delete the *compilation* window
209 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
210 (when (and (not (window-at-side-p compilation-window 'top))
211 (window-at-side-p compilation-window 'left)
212 (window-at-side-p compilation-window 'right))
213 (delete-window compilation-window))))
214 ;; Always return the anticipated result of compilation-exit-message-function
217 ;; Specify my function (maybe I should have done a lambda function)
218 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
221 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
222 value, the compilation buffer scrolls automatically to follow the
223 output. If the value is ~first-error~, scrolling stops when the first
224 error appears, leaving point at that error. For any other non-nil
225 value, scrolling continues until there is no more output.
227 #+BEGIN_SRC emacs-lisp
228 (setq compilation-scroll-output 'first-error)
231 ** Mode line cleaning
233 #+BEGIN_SRC emacs-lisp
234 (use-package diminish
239 #+BEGIN_SRC emacs-lisp
246 #+BEGIN_SRC emacs-lisp
249 :bind ("C-c C-SPC" . avy-goto-word-1)
251 (setq avy-background t)
252 (key-chord-define-global "jj" #'avy-goto-word-1)))
257 #+BEGIN_SRC emacs-lisp
258 (use-package yasnippet
260 :diminish yas-minor-mode
263 (setq yas-verbosity 1)
264 (define-key yas-minor-mode-map (kbd "<tab>") nil)
265 (define-key yas-minor-mode-map (kbd "TAB") nil)
266 (define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)
267 (setq yas-snippet-dirs '("~/lib/emacs_el/snippets/"
268 "~/lib/emacs_el/yasnippet-snippets/snippets/"))
269 (add-to-list 'hippie-expand-try-functions-list
270 'yas-hippie-try-expand)
275 #+BEGIN_SRC emacs-lisp
276 (use-package auto-yasnippet
277 :bind (("H-w" . aya-create)
284 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
286 #+BEGIN_SRC emacs-lisp
287 (use-package helm-flx
290 ;; these are helm configs, but they kind of fit here nicely
291 (setq helm-M-x-fuzzy-match t
292 helm-bookmark-show-location t
293 helm-buffers-fuzzy-matching t
294 helm-completion-in-region-fuzzy-match t
295 helm-file-cache-fuzzy-match t
296 helm-imenu-fuzzy-match t
297 helm-mode-fuzzy-match t
298 helm-locate-fuzzy-match nil
300 helm-recentf-fuzzy-match nil
301 helm-semantic-fuzzy-match t)
308 #+BEGIN_SRC emacs-lisp
310 (use-package tinyprocmail
312 :config (with-library 'tinyprocmail
313 ;; (setq tinyprocmail--procmail-version "v3.22")
314 (add-hook 'tinyprocmail--load-hook 'tinyprocmail-install))
319 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
322 :bind (("C-x g" . magit-status)
323 ("C-x C-g" . magit-status))
325 ;; don't verify where we are pushing
326 (setq magit-push-always-verify nil)
327 ;; refine diffs always (hilight words)
328 (setq magit-diff-refine-hunk nil)
331 (append '("~/lib/emacs_el/magit-annex")
335 (append '("~/lib/emacs_el/magit-vcsh")
338 (use-package magit-annex
341 (use-package magit-vcsh
342 :ensure f ; currently not in melpa, so don't try to install
347 #+BEGIN_SRC emacs-lisp
348 (require 'cperl-mode)
349 ;; Use c-mode for perl .xs files
350 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
351 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
352 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
353 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
354 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
357 cperl-auto-newline nil
358 cperl-auto-newline-after-colon nil
359 cperl-continued-statement-offset 4
360 cperl-brace-offset -1
361 cperl-continued-brace-offset 0
362 cperl-label-offset -4
363 cperl-highlight-variables-indiscriminately t
364 cperl-electric-lbrace-space nil
365 cperl-indent-parens-as-block nil
366 cperl-close-paren-offset -1
367 cperl-tab-always-indent t)
368 ;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
372 #+BEGIN_SRC emacs-lisp
377 (define-key global-map [remap find-file] 'helm-find-files)
378 (define-key global-map [remap occur] 'helm-occur)
379 (define-key global-map [remap list-buffers] 'helm-buffers-list)
380 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
381 (global-set-key (kbd "M-x") 'helm-M-x)
382 (unless (boundp 'completion-in-region-function)
383 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
384 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
385 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
389 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
394 #+BEGIN_SRC emacs-lisp
395 (add-to-list 'tramp-methods '("vcsh"
396 (tramp-login-program "vcsh")
400 (tramp-remote-shell "/bin/sh")
401 (tramp-remote-shell-args
405 #+BEGIN_SRC emacs-lisp
409 (setq-default reftex-default-bibliography
410 '("~/projects/research/references.bib")))
413 #+BEGIN_SRC emacs-lisp
418 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
419 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
420 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
421 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
422 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
423 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
424 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
425 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
426 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
427 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
428 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
430 (setq-default reftex-plug-into-AUCTeX t)
431 ;; support fake section headers
432 (setq TeX-outline-extra
438 ;; add font locking to the headers
439 (font-lock-add-keywords
441 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
442 0 'font-lock-keyword-face t)
443 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
444 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
445 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
446 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
447 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
449 ;; use smart quotes by default instead of `` and ''
450 ;; taken from http://kieranhealy.org/esk/kjhealy.html
451 (setq TeX-open-quote "“")
452 (setq TeX-close-quote "”")
454 ;; (TeX-add-style-hook
459 ;; (custom-set-variables
460 ;; '(font-latex-user-keyword-classes
463 ;; font-lock-function-name-face 2 (command 1 t))))
465 (setq-default TeX-parse-self t)
466 (setq-default TeX-auto-save t)
467 (setq-default TeX-master nil)
473 (if (boundp 'reftex-ref-style-alist)
475 'reftex-ref-style-alist
476 '("Cleveref" "cleveref"
477 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
478 (reftex-ref-style-activate "Cleveref")
480 '("cref" TeX-arg-ref)
481 '("Cref" TeX-arg-ref)
482 '("cpageref" TeX-arg-ref)
483 '("Cpageref" TeX-arg-ref)))))
486 '(add-to-list 'LaTeX-fill-excluded-macros
489 (use-package font-latex
491 (setq font-latex-match-reference-keywords
517 #+BEGIN_SRC emacs-lisp
518 (require 'org-mode-configuration)
521 #+BEGIN_SRC emacs-lisp
525 (use-package calfw-org
528 (use-package org-gcal
530 :config '((if (file-readable-p "~/.hide/org_gcal.el")
531 (load-file "~/.hide/org_gcal.el"))
536 #+BEGIN_SRC emacs-lisp
539 :config (require 'ess_configuration))
543 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
545 #+BEGIN_SRC emacs-lisp
546 (use-package rainbow-mode
547 ;; add ess to the x major mode
548 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
549 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
554 #+BEGIN_SRC emacs-lisp
555 (use-package polymode
558 (use-package poly-noweb)
559 (use-package poly-markdown)
560 :mode ("\\.Snw" . poly-noweb+r-mode)
561 :mode ("\\.Rnw" . poly-noweb+r-mode)
562 :mode ("\\.Rmd" . poly-markdown+r-mode)
568 #+BEGIN_SRC emacs-lisp
569 (use-package outline-magic)
572 #+BEGIN_SRC emacs-lisp
573 (use-package writeroom-mode
574 :config (add-hook 'writeroom-mode-hook 'auto-fill-mode)
577 ** GhostText/Atomic Chrome
578 #+BEGIN_SRC emacs-lisp
579 (use-package atomic-chrome
580 :config (atomic-chrome-start-server)
584 ** Use-package and load things
585 #+BEGIN_SRC emacs-lisp
591 ** Agenda Configuration
592 #+BEGIN_SRC emacs-lisp
593 ;; The following lines are always needed. Choose your own keys.
594 (add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode))
595 (global-set-key "\C-cl" 'org-store-link)
596 (global-set-key "\C-ca" 'org-agenda)
597 (global-set-key "\C-cb" 'org-iswitchb)
598 (setq-default org-log-done 'time)
599 (setq-default org-agenda-ndays 5)
601 ;; agenda configuration
602 ;; Do not dim blocked tasks
603 (setq org-agenda-dim-blocked-tasks nil)
604 (setq org-agenda-inhibit-startup t)
605 (setq org-agenda-use-tag-inheritance nil)
607 ;; Compact the block agenda view
608 (setq org-agenda-compact-blocks t)
610 ;; Custom agenda command definitions
611 (setq org-agenda-custom-commands
612 (quote (("N" "Notes" tags "NOTE"
613 ((org-agenda-overriding-header "Notes")
614 (org-tags-match-list-sublevels t)))
615 ("h" "Habits" tags-todo "STYLE=\"habit\""
616 ((org-agenda-overriding-header "Habits")
617 (org-agenda-sorting-strategy
618 '(todo-state-down effort-up category-keep))))
622 ((org-agenda-overriding-header "Tasks to Refile")
623 (org-tags-match-list-sublevels nil)))
624 (tags-todo "-CANCELLED/!"
625 ((org-agenda-overriding-header "Stuck Projects")
626 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
627 (org-agenda-sorting-strategy
629 (tags-todo "-HOLD-CANCELLED/!"
630 ((org-agenda-overriding-header "Projects")
631 (org-agenda-skip-function 'bh/skip-non-projects)
632 (org-tags-match-list-sublevels 'indented)
633 (org-agenda-sorting-strategy
635 (tags-todo "-CANCELLED/!NEXT"
636 ((org-agenda-overriding-header (concat "Project Next Tasks"
637 (if bh/hide-scheduled-and-waiting-next-tasks
639 " (including WAITING and SCHEDULED tasks)")))
640 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
641 (org-tags-match-list-sublevels t)
642 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
643 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
644 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
645 (org-agenda-sorting-strategy
646 '(todo-state-down effort-up category-keep))))
647 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
648 ((org-agenda-overriding-header (concat "Project Subtasks"
649 (if bh/hide-scheduled-and-waiting-next-tasks
651 " (including WAITING and SCHEDULED tasks)")))
652 (org-agenda-skip-function 'bh/skip-non-project-tasks)
653 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
654 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
655 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
656 (org-agenda-sorting-strategy
658 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
659 ((org-agenda-overriding-header (concat "Standalone Tasks"
660 (if bh/hide-scheduled-and-waiting-next-tasks
662 " (including WAITING and SCHEDULED tasks)")))
663 (org-agenda-skip-function 'bh/skip-project-tasks)
664 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
665 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
666 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
667 (org-agenda-sorting-strategy
669 (tags-todo "-CANCELLED+WAITING|HOLD/!"
670 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
671 (org-agenda-skip-function 'bh/skip-stuck-projects)
672 (org-tags-match-list-sublevels nil)
673 (org-agenda-todo-ignore-scheduled t)
674 (org-agenda-todo-ignore-deadlines t)))
676 ((org-agenda-overriding-header "Tasks to Archive")
677 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
678 (org-tags-match-list-sublevels nil))))
681 ; org mode agenda files
682 (setq org-agenda-files
683 (quote ("~/projects/org-notes/debbugs.org"
684 "~/projects/org-notes/notes.org"
685 "~/projects/org-notes/holidays.org"
686 "~/projects/org-notes/refile.org"
687 "~/projects/org-notes/diary.org"
688 "~/projects/org-notes/ool.org"
689 "~/projects/org-notes/sndservers.org"
690 "~/projects/org-notes/chaim.org"
691 "~/projects/org-notes/wildman.org"
692 "~/projects/org-notes/uddin.org"
693 "~/projects/org-notes/reviews.org"
694 "~/projects/org-notes/hpcbio.org"
695 "~/org-mode/from-mobile.org"
696 "~/projects/org-notes/fh.org")))
698 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
699 (set-register ?r (cons 'file "~/projects/org-notes/refile.org"))
700 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
701 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
702 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
703 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
704 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
705 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
706 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
707 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
708 (defun org-agenda-timeline-all (&optional arg)
711 (dolist (org-agenda-file org-agenda-files)
712 (insert-file-contents org-agenda-file nil)
715 (write-file "/tmp/timeline.org")
716 (org-agenda arg "L")))
717 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
718 ;; add automatic reminders for appointments
719 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
720 "Pressing `r' on the agenda will also add appointments."
722 (setq appt-time-msg-list nil)
723 (org-agenda-to-appt)))
727 #+BEGIN_SRC emacs-lisp
728 (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")))
729 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
731 (setq org-default-notes-file "~/projects/org-notes/notes.org")
732 (setq org-id-link-to-org-use-id t)
735 #+BEGIN_SRC emacs-lisp
736 (setq org-capture-templates ;; mail-specific note template, identified by "m"
737 '(("m" "Mail" entry (file "~/projects/org-notes/refile.org")
738 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
739 ("t" "todo" entry (file "~/projects/org-notes/refile.org")
740 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
741 ("r" "respond" entry (file "~/projects/org-notes/refile.org")
742 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
743 ("n" "note" entry (file "~/projects/org-notes/refile.org")
744 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
745 ("s" "schedule" entry (file "~/projects/org-notes/refile.org")
746 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
747 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
748 "* %?\n%U\n" :clock-in t :clock-resume t)
749 ("w" "org-protocol" entry (file "~/projects/org-notes/refile.org")
750 "* TODO Review %c\n%U\n" :immediate-finish t)
751 ("M" "Meeting" entry (file "~/projects/org-notes/refile.org")
752 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
753 ("S" "Seminar" entry (file "~/projects/org-notes/refile.org")
754 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
755 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
756 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
757 ("p" "Phone call" entry (file "~/projects/org-notes/refile.org")
758 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
759 ("J" "job" entry (file "~/projects/org-notes/refile.org")
760 "* 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)
761 ("h" "Habit" entry (file "~/projects/org-notes/refile.org")
762 "* 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")
766 ;; Remove empty LOGBOOK drawers on clock out
767 (defun bh/remove-empty-drawer-on-clock-out ()
770 (beginning-of-line 0)
771 (org-remove-empty-drawer-at (point))))
773 (defun my/org-add-id ()
776 (if (org-current-level)
785 ** Org mode key bindings
786 #+BEGIN_SRC emacs-lisp
787 ; org mode configuration from http://doc.norang.ca/org-mode.html
788 ;; Custom Key Bindings
789 (global-set-key (kbd "<f12>") 'org-agenda)
790 (global-set-key (kbd "<f5>") 'bh/org-todo)
791 (global-set-key (kbd "<S-f5>") 'bh/widen)
792 (global-set-key (kbd "<f7>") 'bh/set-truncate-lines)
793 (global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
794 (global-set-key (kbd "<f9> <f9>") 'bh/show-org-agenda)
795 (global-set-key (kbd "<f9> b") 'bbdb)
796 (global-set-key (kbd "<f9> c") 'calendar)
797 (global-set-key (kbd "<f9> f") 'boxquote-insert-file)
798 (global-set-key (kbd "<f9> h") 'bh/hide-other)
799 (global-set-key (kbd "<f9> n") 'bh/toggle-next-task-display)
800 (global-set-key (kbd "<f9> w") 'widen)
802 ; change the outline mode prefix from C-c @ to C-c C-2
803 (setq outline-minor-mode-prefix "C-c C-2")
804 ;(add-hook 'outline-minor-mode-hook
805 ; (lambda () (local-set-key (kbd "C-c C-2")
806 ; outline-mode-prefix-map)))
808 (global-set-key (kbd "<f9> I") 'bh/punch-in)
809 (global-set-key (kbd "<f9> O") 'bh/punch-out)
811 (global-set-key (kbd "<f9> o") 'bh/make-org-scratch)
813 (global-set-key (kbd "<f9> r") 'boxquote-region)
814 (global-set-key (kbd "<f9> s") 'bh/switch-to-scratch)
816 (global-set-key (kbd "<f9> t") 'bh/insert-inactive-timestamp)
817 (global-set-key (kbd "<f9> T") 'bh/toggle-insert-inactive-timestamp)
819 (global-set-key (kbd "<f9> v") 'visible-mode)
820 (global-set-key (kbd "<f9> l") 'org-toggle-link-display)
821 (global-set-key (kbd "<f9> SPC") 'bh/clock-in-last-task)
822 (global-set-key (kbd "C-<f9>") 'previous-buffer)
823 (global-set-key (kbd "M-<f9>") 'org-toggle-inline-images)
824 (global-set-key (kbd "C-x n r") 'narrow-to-region)
825 (global-set-key (kbd "C-<f10>") 'next-buffer)
826 (global-set-key (kbd "<f11>") 'org-clock-goto)
827 (global-set-key (kbd "C-<f11>") 'org-clock-in)
828 (global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)
829 (global-set-key (kbd "C-c c") 'org-capture)
833 #+BEGIN_SRC emacs-lisp
834 (defun bh/hide-other ()
837 (org-back-to-heading 'invisible-ok)
843 (defun bh/set-truncate-lines ()
844 "Toggle value of truncate-lines and refresh window display."
846 (setq truncate-lines (not truncate-lines))
847 ;; now refresh window display (an idiom from simple.el):
849 (set-window-start (selected-window)
850 (window-start (selected-window)))))
852 (defun bh/make-org-scratch ()
854 (find-file "/tmp/publish/scratch.org")
855 (gnus-make-directory "/tmp/publish"))
857 (defun bh/switch-to-scratch ()
859 (switch-to-buffer "*scratch*"))
861 (setq org-use-fast-todo-selection t)
862 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
864 ; create function to create headlines in file. This comes from
865 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
866 (defun my/org-add-ids-to-headlines-in-file ()
867 "Add ID properties to all headlines in the current file which
868 do not already have one."
870 (org-map-entries 'org-id-get-create))
871 ; if we wanted to do this to every buffer, do the following:
872 ; (add-hook 'org-mode-hook
874 ; (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
877 #+BEGIN_SRC emacs-lisp
878 (setq org-todo-keywords
879 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
880 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
882 (setq org-todo-keyword-faces
883 (quote (("TODO" :foreground "red" :weight bold)
884 ("NEXT" :foreground "blue" :weight bold)
885 ("DONE" :foreground "forest green" :weight bold)
886 ("WAITING" :foreground "orange" :weight bold)
887 ("HOLD" :foreground "magenta" :weight bold)
888 ("CANCELLED" :foreground "forest green" :weight bold)
889 ("MEETING" :foreground "forest green" :weight bold)
890 ("PHONE" :foreground "forest green" :weight bold))))
892 (setq org-todo-state-tags-triggers
893 (quote (("CANCELLED" ("CANCELLED" . t))
894 ("WAITING" ("WAITING" . t))
895 ("HOLD" ("WAITING") ("HOLD" . t))
896 (done ("WAITING") ("HOLD"))
897 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
898 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
899 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
903 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
904 ; add ids on creation of nodes
905 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
908 ; resolve clocks after 10 minutes of idle; use xprintidle
909 ; (setq org-clock-idle-time 10)
910 ; (setq org-clock-x11idle-program-name "xprintidle")
912 ; this is from http://doc.norang.ca/org-mode.html#Capture
913 ; use C-M-r for org mode capture
914 (global-set-key (kbd "C-M-r") 'org-capture)
916 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
917 (setq org-refile-targets (quote ((nil :maxlevel . 9)
918 (org-agenda-files :maxlevel . 9))))
920 ; Use full outline paths for refile targets - we file directly with IDO
921 (setq org-refile-use-outline-path t)
923 ; Targets complete directly with IDO
924 (setq org-outline-path-complete-in-steps nil)
926 ; Allow refile to create parent tasks with confirmation
927 (setq org-refile-allow-creating-parent-nodes (quote confirm))
929 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
930 ; (setq org-completion-use-ido t)
931 ; (setq ido-everywhere t)
932 ; (setq ido-max-directory-size 100000)
933 ; (ido-mode (quote both))
934 ; ; Use the current window when visiting files and buffers with ido
935 ; (setq ido-default-file-method 'selected-window)
936 ; (setq ido-default-buffer-method 'selected-window)
937 ; ; Use the current window for indirect buffer display
938 ; (setq org-indirect-buffer-display 'current-window)
942 ; Exclude DONE state tasks from refile targets
943 (defun bh/verify-refile-target ()
944 "Exclude todo keywords with a done state from refile targets"
945 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
947 (setq org-refile-target-verify-function 'bh/verify-refile-target)
949 ;; ensure that emacsclient will show just the note to be edited when invoked
950 ;; from Mutt, and that it will shut down emacsclient once finished;
951 ;; fallback to legacy behavior when not invoked via org-protocol.
952 (require 'org-protocol)
953 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
954 (setq my-org-protocol-flag nil)
955 (defadvice org-capture-finalize (after delete-frame-at-end activate)
956 "Delete frame at remember finalization"
957 (progn (if my-org-protocol-flag (delete-frame))
958 (setq my-org-protocol-flag nil)))
959 (defadvice org-capture-refile (around delete-frame-after-refile activate)
960 "Delete frame at remember refile"
961 (if my-org-protocol-flag
963 (setq my-org-protocol-flag nil)
968 (defadvice org-capture-kill (after delete-frame-at-end activate)
969 "Delete frame at remember abort"
970 (progn (if my-org-protocol-flag (delete-frame))
971 (setq my-org-protocol-flag nil)))
972 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
973 (setq my-org-protocol-flag t))
975 (defadvice org-insert-todo-heading (after dla/create-id activate)
980 (add-to-list 'org-modules 'org-habit)
982 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
983 (defun open-mail-in-mutt (message)
984 "Open a mail message in Mutt, using an external terminal.
986 Message can be specified either by a path pointing inside a
987 Maildir, or by Message-ID."
988 (interactive "MPath or Message-ID: ")
990 (format "faf xterm -e \"%s %s\""
991 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
993 ;; add support for "mutt:ID" links
994 (org-add-link-type "mutt" 'open-mail-in-mutt)
996 (defun my-org-mode-setup ()
997 (load-library "reftex")
998 (and (buffer-file-name)
999 (file-exists-p (buffer-file-name))
1002 (reftex-set-cite-format
1003 '((?b . "[[bib:%l][%l-bib]]")
1004 (?n . "[[notes:%l][%l-notes]]")
1006 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
1008 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
1009 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
1010 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
1011 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
1013 (add-hook 'org-mode-hook 'my-org-mode-setup)
1015 (defun org-mode-reftex-search ()
1017 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
1019 (defun open-research-paper (bibtexkey)
1020 "Open a paper by bibtex key"
1021 (interactive "bibtex key: ")
1024 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1025 (org-add-link-type "papers" 'open-research-paper)
1026 (defun open-research-paper-pdf (bibtexkey)
1027 "Open a paper pdf by bibtex key"
1028 (interactive "bibtex key: ")
1030 (format "%s -p evince_annot %s"
1031 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1032 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
1034 (add-to-list 'org-link-abbrev-alist
1036 "~/projects/research/paper_notes.org::#%s"))
1038 ; I pretty much always want hiearchical checkboxes
1039 (setq org-hierachical-checkbox-statistics nil)
1041 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
1042 (add-to-list 'org-structure-template-alist
1043 '("E" "\\begin{equation}\n?\n\\end{equation}"))
1046 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
1047 (defun my-rtcite-export-handler (path desc format)
1048 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
1049 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
1050 (match-string 1 path)))
1051 (path (substring path 0 (match-beginning 0))))
1052 (cond ((eq format 'latex)
1054 (equal 0 (search "rtcite:" desc)))
1055 (format "\\cite{%s}" search)
1056 (format "\\cite[%s]{%s}" desc search))))))
1058 (org-add-link-type "rtcite"
1060 'my-rtcite-export-handler)
1064 ** Org Mobile Configuration
1065 #+BEGIN_SRC emacs-lisp
1066 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
1067 (when (string= system-name "linnode")
1068 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
1069 (setq-default org-directory "/home/don/org-mode/")
1070 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
1074 #+BEGIN_SRC emacs-lisp
1075 ;; org mode ical export
1076 (setq org-icalendar-timezone "America/Los_Angeles")
1077 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
1078 ;; we already add the id manually
1079 ;; (setq org-icalendar-store-UID t)
1082 ** General Org Babel Configuration
1083 #+BEGIN_SRC emacs-lisp
1084 ;; org babel support
1085 (org-babel-do-load-languages
1086 'org-babel-load-languages
1093 ;; use graphviz-dot for dot things
1094 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
1095 ;; org-babel-by-backend
1096 (defmacro org-babel-by-backend (&rest body)
1097 `(case (if (boundp 'backend)
1098 (org-export-backend-name backend)
1101 (defun my/fix-inline-images ()
1102 (when org-inline-image-overlays
1103 (org-redisplay-inline-images)))
1105 (add-hook 'org-babel-after-execute-hook
1106 'my/fix-inline-images)
1109 ** LaTeX configuration
1111 :ID: 7135ba17-6a50-4eed-84ca-b90afa5b12f8
1113 #+BEGIN_SRC emacs-lisp
1115 (add-to-list 'org-latex-classes
1117 "\\documentclass[11pt,oneside,article]{memoir}\n"
1118 ("\\section{%s}" . "\\section*{%s}")
1119 ("\\subsection{%s}" . "\\subsection*{%s}")
1120 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1121 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1122 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1124 (setq org-beamer-outline-frame-options "")
1125 (add-to-list 'org-latex-classes
1127 "\\documentclass[ignorenonframetext]{beamer}
1128 [NO-DEFAULT-PACKAGES]
1131 ("\\section{%s}" . "\\section*{%s}")
1132 ("\\subsection{%s}" . "\\subsection*{%s}")
1133 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1134 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1135 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1137 (add-to-list 'org-latex-classes
1139 "\\documentclass[11pt,oneside]{memoir}\n"
1140 ("\\chapter{%s}" . "\\chapter*{%s}")
1141 ("\\section{%s}" . "\\section*{%s}")
1142 ("\\subsection{%s}" . "\\subsection*{%s}")
1143 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
1145 (add-to-list 'org-latex-classes
1147 "\\documentclass[11pt]{letter}
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}")))
1157 (add-to-list 'org-latex-classes
1159 "\\documentclass{dlacv}
1160 [NO-DEFAULT-PACKAGES]
1163 ("\\section{%s}" . "\\section*{%s}")
1164 ("\\subsection{%s}" . "\\subsection*{%s}")
1165 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1166 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1167 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1170 (add-to-list 'org-latex-classes
1172 "\\documentclass{dlaresume}
1173 [NO-DEFAULT-PACKAGES]
1176 ("\\section{%s}" . "\\section*{%s}")
1177 ("\\subsection{%s}" . "\\subsection*{%s}")
1178 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1179 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1180 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1183 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
1184 ;; but adapted to use latexmk 4.22 or higher.
1185 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
1187 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
1188 (setq org-latex-default-packages-alist
1190 ("" "unicode-math" t)
1192 (setq org-latex-packages-alist
1199 ("" "longtable" nil)
1202 ;; make equations larger
1203 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
1205 (defun org-create-formula--latex-header ()
1206 "Return LaTeX header appropriate for previewing a LaTeX snippet."
1207 (let ((info (org-combine-plists (org-export--get-global-options
1208 (org-export-get-backend 'latex))
1209 (org-export--get-inbuffer-options
1210 (org-export-get-backend 'latex)))))
1211 (org-latex-guess-babel-language
1212 (org-latex-guess-inputenc
1213 (org-splice-latex-header
1214 org-format-latex-header
1215 org-latex-default-packages-alist
1217 (plist-get info :latex-header)))
1221 ; support ignoring headers in org mode export to latex
1222 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
1223 (defadvice org-latex-headline (around my-latex-skip-headlines
1224 (headline contents info) activate)
1225 (if (member "ignoreheading" (org-element-property :tags headline))
1226 (setq ad-return-value contents)
1229 ;; keep latex logfiles
1231 (setq org-latex-remove-logfiles nil)
1233 ;; Resume clocking task when emacs is restarted
1234 (org-clock-persistence-insinuate)
1236 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
1237 (setq org-clock-history-length 23)
1238 ;; Resume clocking task on clock-in if the clock is open
1239 (setq org-clock-in-resume t)
1240 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
1241 ;; there are things like PHONE calls
1242 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
1243 ;; Separate drawers for clocking and logs
1244 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
1245 ;; Save clock data and state changes and notes in the LOGBOOK drawer
1246 (setq org-clock-into-drawer t)
1247 (setq org-log-into-drawer t)
1248 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
1249 (setq org-clock-out-remove-zero-time-clocks t)
1250 ;; Clock out when moving task to a done state
1251 (setq org-clock-out-when-done t)
1252 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
1253 (setq org-clock-persist t)
1254 ;; Do not prompt to resume an active clock
1255 (setq org-clock-persist-query-resume nil)
1256 ;; Enable auto clock resolution for finding open clocks
1257 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
1258 ;; Include current clocking task in clock reports
1259 (setq org-clock-report-include-clocking-task t)
1261 ;; the cache seems to be broken
1262 (setq org-element-use-cache nil)
1264 (defvar bh/keep-clock-running nil)
1266 (defun bh/is-task-p ()
1267 "Any task with a todo keyword and no subtask"
1271 (subtree-end (save-excursion (org-end-of-subtree t)))
1272 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1275 (while (and (not has-subtask)
1276 (< (point) subtree-end)
1277 (re-search-forward "^\*+ " subtree-end t))
1278 (when (member (org-get-todo-state) org-todo-keywords-1)
1279 (setq has-subtask t))))
1280 (and is-a-task (not has-subtask)))))
1282 (defun bh/is-subproject-p ()
1283 "Any task which is a subtask of another project"
1284 (let ((is-subproject)
1285 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1287 (while (and (not is-subproject) (org-up-heading-safe))
1288 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1289 (setq is-subproject t))))
1290 (and is-a-task is-subproject)))
1293 (defun bh/clock-in-to-next (kw)
1294 "Switch a task from TODO to NEXT when clocking in.
1295 Skips capture tasks, projects, and subprojects.
1296 Switch projects and subprojects from NEXT back to TODO"
1297 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
1299 ((and (member (org-get-todo-state) (list "TODO"))
1302 ((and (member (org-get-todo-state) (list "NEXT"))
1306 (defun bh/punch-in (arg)
1307 "Start continuous clocking and set the default task to the
1308 selected task. If no task is selected set the Organization task
1309 as the default task."
1311 (setq bh/keep-clock-running t)
1312 (if (equal major-mode 'org-agenda-mode)
1314 ;; We're in the agenda
1316 (let* ((marker (org-get-at-bol 'org-hd-marker))
1317 (tags (org-with-point-at marker (org-get-tags-at))))
1318 (if (and (eq arg 4) tags)
1319 (org-agenda-clock-in '(16))
1320 (bh/clock-in-organization-task-as-default)))
1322 ;; We are not in the agenda
1326 ; Find the tags on the current task
1327 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
1328 (org-clock-in '(16))
1329 (bh/clock-in-organization-task-as-default)))))
1331 (defun bh/punch-out ()
1333 (setq bh/keep-clock-running nil)
1334 (when (org-clock-is-active)
1336 (org-agenda-remove-restriction-lock))
1338 (defun bh/clock-in-default-task ()
1340 (org-with-point-at org-clock-default-task
1343 (defun bh/clock-in-parent-task ()
1344 "Move point to the parent (project) task if any and clock in"
1345 (let ((parent-task))
1349 (while (and (not parent-task) (org-up-heading-safe))
1350 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1351 (setq parent-task (point))))
1353 (org-with-point-at parent-task
1355 (when bh/keep-clock-running
1356 (bh/clock-in-default-task)))))))
1358 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
1360 (defun bh/clock-in-organization-task-as-default ()
1362 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
1363 (org-clock-in '(16))))
1365 (defun bh/clock-out-maybe ()
1366 (when (and bh/keep-clock-running
1367 (not org-clock-clocking-in)
1368 (marker-buffer org-clock-default-task)
1369 (not org-clock-resolving-clocks-due-to-idleness))
1370 (bh/clock-in-parent-task)))
1372 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1375 (defun bh/clock-in-task-by-id (id)
1376 "Clock in a task by id"
1377 (org-with-point-at (org-id-find id 'marker)
1378 (org-clock-in nil)))
1380 (defun bh/clock-in-last-task (arg)
1381 "Clock in the interrupted task if there is one
1382 Skip the default task and get the next one.
1383 A prefix arg forces clock in of the default task."
1385 (let ((clock-in-to-task
1387 ((eq arg 4) org-clock-default-task)
1388 ((and (org-clock-is-active)
1389 (equal org-clock-default-task (cadr org-clock-history)))
1390 (caddr org-clock-history))
1391 ((org-clock-is-active) (cadr org-clock-history))
1392 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
1393 (t (car org-clock-history)))))
1395 (org-with-point-at clock-in-to-task
1396 (org-clock-in nil))))
1399 (defun org-export-to-ods ()
1401 (let ((csv-file "data.csv"))
1402 (org-table-export csv-file "orgtbl-to-csv")
1403 (org-odt-convert csv-file "ods" 'open)))
1405 ; allow for zero-width-space to be a break in regexp too
1406 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
1407 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
1408 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
1410 ;; support inserting screen shots
1411 (defun my/org-insert-screenshot ()
1412 "Take a screenshot into a time stamped unique-named file in the
1413 same directory as the org-buffer and insert a link to this file."
1415 (defvar my/org-insert-screenshot/filename)
1416 (setq my/org-insert-screenshot/filename
1418 "Screenshot to insert: "
1420 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
1423 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
1424 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
1425 (org-display-inline-images))
1427 (defun my/fix-inline-images ()
1428 (when org-inline-image-overlays
1429 (org-redisplay-inline-images)))
1431 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
1433 ;; use xelatex to preview with imagemagick
1434 (add-to-list 'org-preview-latex-process-alist
1435 '(xelateximagemagick
1436 :programs ("xelatex" "convert")
1437 :description "pdf > png"
1438 :message "you need to install xelatex and imagemagick"
1440 :image-input-type "pdf"
1441 :image-output-type "png"
1442 :image-size-adjust (1.0 . 1.0)
1443 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
1444 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
1446 ;; use xelatex by default
1447 (setq org-preview-latex-default-process 'xelateximagemagick)
1449 ; from http://orgmode.org/Changes.html
1450 (defun my/org-repair-property-drawers ()
1451 "Fix properties drawers in current buffer.
1452 Ignore non Org buffers."
1454 (when (eq major-mode 'org-mode)
1455 (org-with-wide-buffer
1456 (goto-char (point-min))
1457 (let ((case-fold-search t)
1458 (inline-re (and (featurep 'org-inlinetask)
1459 (concat (org-inlinetask-outline-regexp)
1463 (unless (and inline-re (org-looking-at-p inline-re))
1465 (let ((end (save-excursion (outline-next-heading) (point))))
1467 (when (org-looking-at-p org-planning-line-re) (forward-line))
1468 (when (and (< (point) end)
1469 (not (org-looking-at-p org-property-drawer-re))
1471 (and (re-search-forward org-property-drawer-re end t)
1472 (eq (org-element-type
1473 (save-match-data (org-element-at-point)))
1475 (insert (delete-and-extract-region
1477 (min (1+ (match-end 0)) end)))
1478 (unless (bolp) (insert "\n"))))))))))))
1482 #+BEGIN_SRC emacs-lisp
1486 ** Override other things
1487 #+BEGIN_SRC emacs-lisp
1488 ; apparently things like to step on C-;, so we'll use a hack from
1489 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
1491 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
1493 ; use iedit everywhere
1494 (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
1495 ;; use outline mode keybindings everywhere
1496 ;; (define-key my-keys-minor-mode-map (kbd "C-;") 'my/mydra-outline/body)
1498 (define-minor-mode my-keys-minor-mode
1499 "A minor mode so that my key settings override annoying major modes."
1500 t " my-keys" 'my-keys-minor-mode-map)
1502 (my-keys-minor-mode 1)
1503 (defun my-minibuffer-setup-hook ()
1504 (my-keys-minor-mode 0))
1506 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
1507 (defadvice load (after give-my-keybindings-priority)
1508 "Try to ensure that my keybindings always have priority."
1509 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
1510 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
1511 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
1512 (add-to-list 'minor-mode-map-alist mykeys))))
1516 * Misc (uncharacterized)
1517 #+BEGIN_SRC emacs-lisp
1518 (setq bibtex-user-optional-fields (quote (("annote" "Personal annotation (ignored)") ("abstract" "") ("pmid" "") ("doi" ""))))
1519 (setq calendar-latitude 40.11)
1520 (setq calendar-longitude -88.24)
1521 (setq case-fold-search t)
1522 (setq confirm-kill-emacs (quote y-or-n-p))
1523 (setq cperl-lazy-help-time nil)
1524 (setq debian-changelog-mailing-address "don@debian.org")
1526 (setq display-time-24hr-format t)
1527 (setq display-time-day-and-date t)
1528 (display-time-mode 1)
1529 (setq font-latex-fontify-script nil)
1530 (setq font-latex-fontify-sectioning (quote color))
1531 (setq font-latex-script-display (quote (nil)))
1532 (global-auto-revert-mode 1)
1533 (global-font-lock-mode 1)
1535 (setq log-edit-keep-buffer t)
1536 (setq mail-user-agent (quote sendmail-user-agent))
1537 (setq markdown-enable-math t)
1538 (setq markdown-follow-wiki-link-on-enter nil)
1539 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
1540 (setq post-email-address "don@donarmstrong.com")
1541 (setq post-kill-quoted-sig nil)
1542 (setq post-mail-message "mutt\\(ng\\|\\)-[a-z0-9]+-[0-9]+-.*")
1543 (setq post-uses-fill-mode nil)
1544 (setq ps-footer-font-size (quote (8 . 10)))
1545 (setq ps-header-font-size (quote (8 . 10)))
1546 (setq ps-header-title-font-size (quote (10 . 10)))
1547 (setq ps-line-number-color "blue")
1548 (setq ps-print-footer t)
1549 (setq ps-print-footer-frame nil)
1550 (setq ps-print-only-one-header t)
1551 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
1553 (setq sentence-end-double-space nil)
1554 ; enable matching parenthesis
1557 (setq user-mail-address "don@donarmstrong.com")
1558 (setq vc-delete-logbuf-window nil)
1559 (setq vc-follow-symlinks t)
1561 ;; use git before SVN; use CVS earlier, because I have CVS
1562 ;; repositories inside of git directories
1563 (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
1565 ;; switch back to the old primary selection method
1566 (setq x-select-enable-clipboard nil)
1567 (setq x-select-enable-primary t)
1568 ; (setq mouse-drag-copy-region t)
1570 (fset 'perl-mode 'cperl-mode)
1571 ;;(load-file "cperl-mode.el")
1577 ;;(require 'ecasound)
1578 ;;(require 'emacs-wiki)
1582 ; (require 'google-weather)
1583 ; (require 'org-google-weather)
1584 ; (setq-default org-google-weather-format "%i %c, [%l,%h] %s %C")
1586 (global-set-key "\C-xp" 'server-edit)
1588 (setq-default auto-mode-alist (cons '("\.wml$" .
1589 (lambda () (html-mode) (auto-fill-mode)))
1593 ; use markdown mode for mdwn files
1594 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
1595 (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
1598 ;; tramp configuration
1599 (setq tramp-use-ssh-controlmaster-options nil)
1601 ; mail configuration
1602 (add-to-list 'auto-mode-alist '("muttng-[a-z0-9]+-[0-9]+-" . message-mode))
1603 (add-to-list 'auto-mode-alist '("muttngrc" . muttrc-mode))
1605 (add-to-list 'auto-mode-alist '("mutt-[a-z0-9]+-[0-9]+-" . message-mode))
1606 (add-to-list 'auto-mode-alist '("muttrc" . muttrc-mode))
1607 (defun my-message-mode-settings ()
1608 (font-lock-add-keywords nil
1609 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1610 (0 'message-multiply-quoted-text-face))
1611 ("^[ \t]*>[ \t]*>.*$"
1612 (0 'message-double-quoted-text-face))))
1613 (local-set-key (kbd "C-c C-a") 'my-post-attach-file)
1615 (add-hook 'message-mode-hook 'my-message-mode-settings)
1617 (defun my-post-attach-file ()
1618 "Prompt for an attachment."
1620 (let ((file (read-file-name "Attach file: " nil nil t nil))
1621 (description (string-read "Description: ")))
1622 (my-header-attach-file file description)))
1624 (symbol-function 'my-post-attach-file)
1626 (defun my-header-attach-file (file description)
1627 "Attach a FILE to the current message (works with Mutt).
1628 Argument DESCRIPTION MIME description."
1629 (interactive "fAttach file: \nsDescription: ")
1630 (when (> (length file) 0)
1635 (goto-char (point-min))
1636 (search-forward-regexp "^$")
1637 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1639 (message (concat "Attached '" file "'."))
1640 (setq post-has-attachment t))))))
1644 (setq mail-yank-prefix "> ")
1646 (global-unset-key "\M-g")
1647 (global-set-key "\M-g" 'goto-line)
1649 ;; self-insert-command hack.
1650 ;; Without this, "if<SP>" expands to
1653 ;; which really should be,
1659 ;(load-library "php-mode")
1661 (setq-default c-indent-level 4)
1662 (setq-default c-brace-imaginary-offset 0)
1663 (setq-default c-brace-offset -4)
1664 (setq-default c-argdecl-indent 4)
1665 (setq-default c-label-offset -4)
1666 (setq-default c-continued-statement-offset 4)
1668 (setq-default indent-tabs-mode nil)
1669 (setq-default tab-width 4)
1672 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
1673 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
1674 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
1675 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
1676 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
1679 (defun insert-date ()
1680 "Insert date at point."
1682 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
1683 (global-set-key "\C-[d" 'insert-date)
1685 (defun unfill-paragraph (arg)
1686 "Pull this whole paragraph up onto one line."
1688 (let ((fill-column 10000))
1689 (fill-paragraph arg))
1692 (column-number-mode t)
1696 ; (require 'mode-compile)
1698 (defadvice server-process-filter (after post-mode-message first activate)
1699 "If the buffer is in post mode, overwrite the server-edit
1700 message with a post-save-current-buffer-and-exit message."
1701 (if (eq major-mode 'post-mode)
1703 (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done."))))
1704 ; This is also needed to see the magic message. Set to a higher
1705 ; number if you have a faster computer or read slower than me.
1706 '(font-lock-verbose 1000)
1707 ;(setq-default server-temp-file-regexp "mutt\(-\|ng-\)")
1708 ; (add-hook 'server-switch-hook
1709 ; (function (lambda()
1710 ; (cond ((string-match "Post" mode-name)
1711 ; (post-goto-body)))
1712 ; set-buffer-file-coding-system 'utf-8
1716 (add-hook 'post-mode-hook
1717 (auto-fill-mode nil)
1719 ; abbrev mode settings
1720 ; load abbreviations from
1721 (setq abbrev-file-name
1722 "~/.emacs_abbrev_def")
1724 ; read the abbrev file if it exists
1725 (if (file-exists-p abbrev-file-name)
1726 (quietly-read-abbrev-file))
1728 ; for now, use abbrev mode everywhere
1729 (setq default-abbrev-mode t)
1732 (defun insert-function-documentation ()
1733 "Insert function documentation"
1735 (insert-file-contents "/home/don/lib/templates/perl_function_documentation" nil))
1736 (global-set-key "\M-f" 'insert-function-documentation)
1738 (eval-after-load "lilypond-mode"
1740 (load-library "lyqi-mode")
1741 (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
1743 (autoload 'spamassassin-mode "spamassassin-mode" nil t)
1745 (desktop-load-default)
1747 '(icomplete-mode on)
1749 ;; custom-set-faces was added by Custom.
1750 ;; If you edit it by hand, you could mess it up, so be careful.
1751 ;; Your init file should contain only one such instance.
1752 ;; If there is more than one, they won't work right.
1753 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
1756 (put 'upcase-region 'disabled nil)
1757 (put 'downcase-region 'disabled nil)
1758 (put 'narrow-to-region 'disabled nil)
1760 ; (defun turn-on-flyspell ()
1761 ; "Force flyspell-mode on using a positive arg. For use in hooks."
1763 ; (flyspell-mode 1))
1766 ; Outline-minor-mode key map
1767 (define-prefix-command 'cm-map nil "Outline-")
1769 (define-key cm-map "q" 'hide-sublevels) ; Hide everything but the top-level headings
1770 (define-key cm-map "t" 'hide-body) ; Hide everything but headings (all body lines)
1771 (define-key cm-map "o" 'hide-other) ; Hide other branches
1772 (define-key cm-map "c" 'hide-entry) ; Hide this entry's body
1773 (define-key cm-map "l" 'hide-leaves) ; Hide body lines in this entry and sub-entries
1774 (define-key cm-map "d" 'hide-subtree) ; Hide everything in this entry and sub-entries
1776 (define-key cm-map "a" 'show-all) ; Show (expand) everything
1777 (define-key cm-map "e" 'show-entry) ; Show this heading's body
1778 (define-key cm-map "i" 'show-children) ; Show this heading's immediate child sub-headings
1779 (define-key cm-map "k" 'show-branches) ; Show all sub-headings under this heading
1780 (define-key cm-map "s" 'show-subtree) ; Show (expand) everything in this heading & below
1782 (define-key cm-map "u" 'outline-up-heading) ; Up
1783 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
1784 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
1785 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
1786 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
1787 (global-set-key "\M-o" cm-map)
1791 (setq-default debian-changelog-mailing-address "don@debian.org")
1792 (setq-default debian-changelog-full-name "Don Armstrong")
1794 ; ediff configuration
1795 ; don't use the multi-window configuration
1796 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
1800 (define-key global-map (kbd "C-;") 'iedit-mode)
1801 (global-set-key (kbd "C-;") 'iedit-mode)
1803 ; fix up css mode to not be silly
1804 ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
1805 (setq cssm-indent-level 4)
1806 (setq cssm-newline-before-closing-bracket t)
1807 (setq cssm-indent-function #'cssm-c-style-indenter)
1808 (setq cssm-mirror-mode nil)
1810 (require 'multi-web-mode)
1811 (setq mweb-default-major-mode 'html-mode)
1812 (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
1813 (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
1814 (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
1815 (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
1816 (multi-web-global-mode 1)
1818 ;;; alias the new `flymake-report-status-slim' to
1819 ;;; `flymake-report-status'
1820 (defalias 'flymake-report-status 'flymake-report-status-slim)
1821 (defun flymake-report-status-slim (e-w &optional status)
1822 "Show \"slim\" flymake status in mode line."
1824 (setq flymake-mode-line-e-w e-w))
1826 (setq flymake-mode-line-status status))
1827 (let* ((mode-line " Φ"))
1828 (when (> (length flymake-mode-line-e-w) 0)
1829 (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
1830 (setq mode-line (concat mode-line flymake-mode-line-status))
1831 (setq flymake-mode-line mode-line)
1832 (force-mode-line-update)))
1834 ; load sql-indent when sql is loaded
1835 (eval-after-load "sql"
1836 '(load-library "sql-indent"))
1838 ; fix up tmux xterm keys
1839 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
1840 (defun fix-up-tmux-keys ()
1841 "Fix up tmux xterm keys"
1844 (let ((x 2) (tkey ""))
1864 ;; ctrl + alt + shift
1866 (setq tkey "C-M-S-"))
1869 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
1870 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
1871 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
1872 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
1874 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
1876 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
1878 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
1880 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
1882 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
1884 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
1886 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
1888 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
1890 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
1892 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
1894 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
1896 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
1898 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
1900 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
1902 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
1904 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
1906 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
1908 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
1910 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
1912 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
1914 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
1916 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
1918 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
1920 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
1922 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
1924 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
1931 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
1933 ; procmailmode configuration
1934 (load "procmail_mode")
1936 (load "mode-line-cleaner")
1938 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
1939 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
1940 (if (or (buffer-modified-p)
1941 (verify-visited-file-modtime)
1942 (< (* 8 1024 1024) (buffer-size))
1943 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
1945 (clear-visited-file-modtime)
1947 (ad-activate 'ask-user-about-supersession-threat)
1949 ; apparently things like to step on C-;, so we'll use a hack from
1950 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
1952 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
1954 ; use iedit everywhere
1955 (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
1957 (define-minor-mode my-keys-minor-mode
1958 "A minor mode so that my key settings override annoying major modes."
1959 t " my-keys" 'my-keys-minor-mode-map)
1961 (my-keys-minor-mode 1)
1962 (defun my-minibuffer-setup-hook ()
1963 (my-keys-minor-mode 0))
1965 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
1966 (defadvice load (after give-my-keybindings-priority)
1967 "Try to ensure that my keybindings always have priority."
1968 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
1969 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
1970 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
1971 (add-to-list 'minor-mode-map-alist mykeys))))
1973 (global-set-key "\M- " 'hippie-expand)
1978 #+BEGIN_SRC emacs-lisp
1979 (provide 'don-configuration)