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
40 #+BEGIN_SRC emacs-lisp
41 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
42 ;; execute conditional code when loading libraries
43 (defmacro with-library (symbol &rest body)
44 `(when (require ,symbol nil t)
46 (put 'with-library 'lisp-indent-function 1)
50 ** Safe Local Variables
51 #+BEGIN_SRC emacs-lisp
52 (setq safe-local-variable-values
53 (quote ((auto-save-default)
55 (cperl-indent-level . 4)
57 (indent-tabs-mode . f)
61 #+BEGIN_SRC emacs-lisp
62 (setq global-mark-ring-max 128
66 (defun don/minibuffer-setup-hook ()
67 (setq gc-cons-threshold most-positive-fixnum))
69 (defun don/minibuffer-exit-hook ()
70 (setq gc-cons-threshold 1048576))
72 (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
73 (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
77 #+BEGIN_SRC emacs-lisp
80 :diminish flyspell-mode 🐝
82 (add-hook 'message-mode-hook 'turn-on-flyspell)
83 (add-hook 'text-mode-hook 'turn-on-flyspell)
84 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
85 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
86 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
88 (setq ispell-program-name "ispell")
93 #+BEGIN_SRC emacs-lisp
98 #+BEGIN_SRC emacs-lisp
99 ;; (use-package eyebrowse
101 ;; :diminish eyebrowse-mode
102 ;; :init (setq eyebrowse-keymap-prefix (kbd "C-c C-\\"))
104 ;; (setq eyebrowse-wrap-around t)
105 ;; (eyebrowse-mode t)
107 ;; (defun my/eyebrowse-new-window-config ()
111 ;; ;; start at 1 run till 0
112 ;; (let ((j (mod (+ i 1) 10)))
113 ;; (when (and (not done)
114 ;; (not (eyebrowse--window-config-present-p j)))
115 ;; (eyebrowse-switch-to-window-config j)
116 ;; (call-interactively 'eyebrowse-rename-window-config2 j)
121 ;; ;; I don't use latex-preview-pane
122 ;; ;; (require 'latex-preview-pane)
123 ;; ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
124 ;; ;; ;; latex-preview-pane uses window-parameters which are
125 ;; ;; ;; not preserved by eyebrowse, so we close the preview
126 ;; ;; ;; pane before switching, it will be regenerated when we
127 ;; ;; ;; edit the TeX file.
128 ;; ;; (when (lpp/window-containing-preview)
129 ;; ;; (delete-window (lpp/window-containing-preview))))
131 ;; ;; (add-to-list 'eyebrowse-pre-window-switch-hook
132 ;; ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
134 ;; ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
135 ;; ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
136 ;; ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
137 ;; ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
138 ;; ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
146 #+BEGIN_SRC emacs-lisp
147 (defun my/vsplit-last-buffer ()
148 "Split the window vertically and display the previous buffer."
150 (split-window-vertically)
152 (switch-to-next-buffer))
154 (defun my/hsplit-last-buffer ()
155 "Split the window horizontally and display the previous buffer."
157 (split-window-horizontally)
159 (switch-to-next-buffer))
161 (bind-key "C-x 2" 'my/vsplit-last-buffer)
162 (bind-key "C-x 3" 'my/hsplit-last-buffer)
164 (setq split-width-threshold 100)
165 (setq split-height-threshold 60)
167 (defun my/split-window-prefer-vertically (window)
168 "If there's only one window (excluding any possibly active
169 minibuffer), then split the current window horizontally."
170 (if (and (one-window-p t)
171 (not (active-minibuffer-window))
172 ( < (frame-width) (frame-height))
174 (let ((split-width-threshold nil))
175 (split-window-sensibly window))
176 (split-window-sensibly window)))
178 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
179 (setq window-combination-resize t)
182 *** Compilation window
184 If there is no compilation window, open one at the bottom, spanning
185 the complete width of the frame. Otherwise, reuse existing window. In
186 the former case, if there was no error the window closes
189 #+BEGIN_SRC emacs-lisp
190 (add-to-list 'display-buffer-alist
191 `(,(rx bos "*compilation*" eos)
192 (display-buffer-reuse-window
193 display-buffer-in-side-window)
194 (reusable-frames . visible)
196 (window-height . 0.4)))
199 #+BEGIN_SRC emacs-lisp
200 (defun my/compilation-exit-autoclose (status code msg)
201 ;; If M-x compile exists with a 0
202 (when (and (eq status 'exit) (zerop code))
203 ;; and delete the *compilation* window
204 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
205 (when (and (not (window-at-side-p compilation-window 'top))
206 (window-at-side-p compilation-window 'left)
207 (window-at-side-p compilation-window 'right))
208 (delete-window compilation-window))))
209 ;; Always return the anticipated result of compilation-exit-message-function
212 ;; Specify my function (maybe I should have done a lambda function)
213 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
216 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
217 value, the compilation buffer scrolls automatically to follow the
218 output. If the value is ~first-error~, scrolling stops when the first
219 error appears, leaving point at that error. For any other non-nil
220 value, scrolling continues until there is no more output.
222 #+BEGIN_SRC emacs-lisp
223 (setq compilation-scroll-output 'first-error)
226 ** Mode line cleaning
228 #+BEGIN_SRC emacs-lisp
229 (use-package diminish
234 #+BEGIN_SRC emacs-lisp
241 #+BEGIN_SRC emacs-lisp
244 :bind ("C-c C-SPC" . avy-goto-word-1)
246 (setq avy-background t)
247 (key-chord-define-global "jj" #'avy-goto-word-1)))
253 #+BEGIN_SRC emacs-lisp
254 (use-package yasnippet
256 :diminish yas-minor-mode
259 (setq yas-verbosity 1)
260 (define-key yas-minor-mode-map (kbd "<tab>") nil)
261 (define-key yas-minor-mode-map (kbd "TAB") nil)
262 (define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)
268 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
270 #+BEGIN_SRC emacs-lisp
271 (use-package helm-flx
274 ;; these are helm configs, but they kind of fit here nicely
275 (setq helm-M-x-fuzzy-match t
276 helm-bookmark-show-location t
277 helm-buffers-fuzzy-matching t
278 helm-completion-in-region-fuzzy-match t
279 helm-file-cache-fuzzy-match t
280 helm-imenu-fuzzy-match t
281 helm-mode-fuzzy-match t
282 helm-locate-fuzzy-match nil
284 helm-recentf-fuzzy-match nil
285 helm-semantic-fuzzy-match t)
292 #+BEGIN_SRC emacs-lisp
294 (use-package tinyprocmail
296 :config (with-library 'tinyprocmail
297 ;; (setq tinyprocmail--procmail-version "v3.22")
298 (add-hook 'tinyprocmail--load-hook 'tinyprocmail-install))
303 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
306 :bind (("C-x g" . magit-status)
307 ("C-x C-g" . magit-status))
309 ;; don't verify where we are pushing
310 (setq magit-push-always-verify nil)
311 ;; refine diffs always (hilight words)
312 (setq magit-diff-refine-hunk nil)
315 (append '("~/lib/emacs_el/magit-annex")
319 (append '("~/lib/emacs_el/magit-vcsh")
322 (use-package magit-annex
325 (use-package magit-vcsh
326 :ensure f ; currently not in melpa, so don't try to install
331 #+BEGIN_SRC emacs-lisp
332 (require 'cperl-mode)
333 ;; Use c-mode for perl .xs files
334 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
335 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
336 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
337 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
338 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
341 cperl-auto-newline nil
342 cperl-auto-newline-after-colon nil
343 cperl-continued-statement-offset 4
344 cperl-brace-offset -1
345 cperl-continued-brace-offset 0
346 cperl-label-offset -4
347 cperl-highlight-variables-indiscriminately t
348 cperl-electric-lbrace-space nil
349 cperl-indent-parens-as-block nil
350 cperl-close-paren-offset -1
351 cperl-tab-always-indent t)
352 ;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
356 #+BEGIN_SRC emacs-lisp
361 (define-key global-map [remap find-file] 'helm-find-files)
362 (define-key global-map [remap occur] 'helm-occur)
363 (define-key global-map [remap list-buffers] 'helm-buffers-list)
364 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
365 (global-set-key (kbd "M-x") 'helm-M-x)
366 (unless (boundp 'completion-in-region-function)
367 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
368 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
369 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
373 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
378 #+BEGIN_SRC emacs-lisp
379 (add-to-list 'tramp-methods '("vcsh"
380 (tramp-login-program "vcsh")
384 (tramp-remote-shell "/bin/sh")
385 (tramp-remote-shell-args
389 #+BEGIN_SRC emacs-lisp
393 (setq-default reftex-default-bibliography
394 '("~/projects/research/references.bib")))
397 #+BEGIN_SRC emacs-lisp
402 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
403 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
404 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
405 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
406 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
407 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
408 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
409 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
410 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
411 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
412 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
414 (setq-default reftex-plug-into-AUCTeX t)
415 ;; support fake section headers
416 (setq TeX-outline-extra
422 ;; add font locking to the headers
423 (font-lock-add-keywords
425 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
426 0 'font-lock-keyword-face t)
427 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
428 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
429 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
430 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
431 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
433 ;; use smart quotes by default instead of `` and ''
434 ;; taken from http://kieranhealy.org/esk/kjhealy.html
435 (setq TeX-open-quote "“")
436 (setq TeX-close-quote "”")
438 ;; (TeX-add-style-hook
443 ;; (custom-set-variables
444 ;; '(font-latex-user-keyword-classes
447 ;; font-lock-function-name-face 2 (command 1 t))))
449 (setq-default TeX-parse-self t)
450 (setq-default TeX-auto-save t)
451 (setq-default TeX-master nil)
457 (if (boundp 'reftex-ref-style-alist)
459 'reftex-ref-style-alist
460 '("Cleveref" "cleveref"
461 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
462 (reftex-ref-style-activate "Cleveref")
464 '("cref" TeX-arg-ref)
465 '("Cref" TeX-arg-ref)
466 '("cpageref" TeX-arg-ref)
467 '("Cpageref" TeX-arg-ref)))))
470 '(add-to-list 'LaTeX-fill-excluded-macros
473 (use-package font-latex
475 (setq font-latex-match-reference-keywords
501 #+BEGIN_SRC emacs-lisp
502 (require 'org-mode-configuration)
505 #+BEGIN_SRC emacs-lisp
509 (use-package calfw-org
512 (use-package org-gcal
514 :config '((if (file-readable-p "~/.hide/org_gcal.el")
515 (load-file "~/.hide/org_gcal.el"))
520 #+BEGIN_SRC emacs-lisp
523 :config (require 'ess_configuration))
527 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
529 #+BEGIN_SRC emacs-lisp
530 (use-package rainbow-mode
531 ;; add ess to the x major mode
532 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
533 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
538 #+BEGIN_SRC emacs-lisp
539 (use-package polymode
542 (use-package poly-noweb)
543 (use-package poly-markdown)
544 :mode ("\\.Snw" . poly-noweb+r-mode)
545 :mode ("\\.Rnw" . poly-noweb+r-mode)
546 :mode ("\\.Rmd" . poly-markdown+r-mode)
552 #+BEGIN_SRC emacs-lisp
553 (use-package outline-magic)
556 #+BEGIN_SRC emacs-lisp
557 (use-package writeroom-mode
558 :config (add-hook 'writeroom-mode-hook 'auto-fill-mode)
561 ** GhostText/Atomic Chrome
562 #+BEGIN_SRC emacs-lisp
563 (use-package atomic-chrome
564 :config (atomic-chrome-start-server)
568 ** Use-package and load things
569 #+BEGIN_SRC emacs-lisp
575 ** Agenda Configuration
576 #+BEGIN_SRC emacs-lisp
577 ;; The following lines are always needed. Choose your own keys.
578 (add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode))
579 (global-set-key "\C-cl" 'org-store-link)
580 (global-set-key "\C-ca" 'org-agenda)
581 (global-set-key "\C-cb" 'org-iswitchb)
582 (setq-default org-log-done 'time)
583 (setq-default org-agenda-ndays 5)
585 ;; agenda configuration
586 ;; Do not dim blocked tasks
587 (setq org-agenda-dim-blocked-tasks nil)
588 (setq org-agenda-inhibit-startup t)
589 (setq org-agenda-use-tag-inheritance nil)
591 ;; Compact the block agenda view
592 (setq org-agenda-compact-blocks t)
594 ;; Custom agenda command definitions
595 (setq org-agenda-custom-commands
596 (quote (("N" "Notes" tags "NOTE"
597 ((org-agenda-overriding-header "Notes")
598 (org-tags-match-list-sublevels t)))
599 ("h" "Habits" tags-todo "STYLE=\"habit\""
600 ((org-agenda-overriding-header "Habits")
601 (org-agenda-sorting-strategy
602 '(todo-state-down effort-up category-keep))))
606 ((org-agenda-overriding-header "Tasks to Refile")
607 (org-tags-match-list-sublevels nil)))
608 (tags-todo "-CANCELLED/!"
609 ((org-agenda-overriding-header "Stuck Projects")
610 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
611 (org-agenda-sorting-strategy
613 (tags-todo "-HOLD-CANCELLED/!"
614 ((org-agenda-overriding-header "Projects")
615 (org-agenda-skip-function 'bh/skip-non-projects)
616 (org-tags-match-list-sublevels 'indented)
617 (org-agenda-sorting-strategy
619 (tags-todo "-CANCELLED/!NEXT"
620 ((org-agenda-overriding-header (concat "Project Next Tasks"
621 (if bh/hide-scheduled-and-waiting-next-tasks
623 " (including WAITING and SCHEDULED tasks)")))
624 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
625 (org-tags-match-list-sublevels t)
626 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
627 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
628 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
629 (org-agenda-sorting-strategy
630 '(todo-state-down effort-up category-keep))))
631 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
632 ((org-agenda-overriding-header (concat "Project Subtasks"
633 (if bh/hide-scheduled-and-waiting-next-tasks
635 " (including WAITING and SCHEDULED tasks)")))
636 (org-agenda-skip-function 'bh/skip-non-project-tasks)
637 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
638 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
639 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
640 (org-agenda-sorting-strategy
642 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
643 ((org-agenda-overriding-header (concat "Standalone Tasks"
644 (if bh/hide-scheduled-and-waiting-next-tasks
646 " (including WAITING and SCHEDULED tasks)")))
647 (org-agenda-skip-function 'bh/skip-project-tasks)
648 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
649 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
650 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
651 (org-agenda-sorting-strategy
653 (tags-todo "-CANCELLED+WAITING|HOLD/!"
654 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
655 (org-agenda-skip-function 'bh/skip-stuck-projects)
656 (org-tags-match-list-sublevels nil)
657 (org-agenda-todo-ignore-scheduled t)
658 (org-agenda-todo-ignore-deadlines t)))
660 ((org-agenda-overriding-header "Tasks to Archive")
661 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
662 (org-tags-match-list-sublevels nil))))
665 ; org mode agenda files
666 (setq org-agenda-files
667 (quote ("~/projects/org-notes/debbugs.org"
668 "~/projects/org-notes/notes.org"
669 "~/projects/org-notes/holidays.org"
670 "~/projects/org-notes/refile.org"
671 "~/projects/org-notes/diary.org"
672 "~/projects/org-notes/ool.org"
673 "~/projects/org-notes/sndservers.org"
674 "~/projects/org-notes/chaim.org"
675 "~/projects/org-notes/wildman.org"
676 "~/projects/org-notes/uddin.org"
677 "~/projects/org-notes/reviews.org"
678 "~/projects/org-notes/hpcbio.org"
679 "~/org-mode/from-mobile.org"
680 "~/projects/org-notes/fh.org")))
682 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
683 (set-register ?r (cons 'file "~/projects/org-notes/refile.org"))
684 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
685 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
686 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
687 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
688 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
689 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
690 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
691 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
692 (defun org-agenda-timeline-all (&optional arg)
695 (dolist (org-agenda-file org-agenda-files)
696 (insert-file-contents org-agenda-file nil)
699 (write-file "/tmp/timeline.org")
700 (org-agenda arg "L")))
701 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
702 ;; add automatic reminders for appointments
703 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
704 "Pressing `r' on the agenda will also add appointments."
706 (setq appt-time-msg-list nil)
707 (org-agenda-to-appt)))
711 #+BEGIN_SRC emacs-lisp
712 (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")))
713 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
715 (setq org-default-notes-file "~/projects/org-notes/notes.org")
716 (setq org-id-link-to-org-use-id t)
719 #+BEGIN_SRC emacs-lisp
720 (setq org-capture-templates ;; mail-specific note template, identified by "m"
721 '(("m" "Mail" entry (file "~/projects/org-notes/refile.org")
722 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
723 ("t" "todo" entry (file "~/projects/org-notes/refile.org")
724 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
725 ("r" "respond" entry (file "~/projects/org-notes/refile.org")
726 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
727 ("n" "note" entry (file "~/projects/org-notes/refile.org")
728 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
729 ("s" "schedule" entry (file "~/projects/org-notes/refile.org")
730 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
731 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
732 "* %?\n%U\n" :clock-in t :clock-resume t)
733 ("w" "org-protocol" entry (file "~/projects/org-notes/refile.org")
734 "* TODO Review %c\n%U\n" :immediate-finish t)
735 ("M" "Meeting" entry (file "~/projects/org-notes/refile.org")
736 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
737 ("S" "Seminar" entry (file "~/projects/org-notes/refile.org")
738 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
739 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
740 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
741 ("p" "Phone call" entry (file "~/projects/org-notes/refile.org")
742 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
743 ("J" "job" entry (file "~/projects/org-notes/refile.org")
744 "* 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)
745 ("h" "Habit" entry (file "~/projects/org-notes/refile.org")
746 "* 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")
750 ;; Remove empty LOGBOOK drawers on clock out
751 (defun bh/remove-empty-drawer-on-clock-out ()
754 (beginning-of-line 0)
755 (org-remove-empty-drawer-at (point))))
757 (defun my/org-add-id ()
760 (if (org-current-level)
769 ** Org mode key bindings
770 #+BEGIN_SRC emacs-lisp
771 ; org mode configuration from http://doc.norang.ca/org-mode.html
772 ;; Custom Key Bindings
773 (global-set-key (kbd "<f12>") 'org-agenda)
774 (global-set-key (kbd "<f5>") 'bh/org-todo)
775 (global-set-key (kbd "<S-f5>") 'bh/widen)
776 (global-set-key (kbd "<f7>") 'bh/set-truncate-lines)
777 (global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
778 (global-set-key (kbd "<f9> <f9>") 'bh/show-org-agenda)
779 (global-set-key (kbd "<f9> b") 'bbdb)
780 (global-set-key (kbd "<f9> c") 'calendar)
781 (global-set-key (kbd "<f9> f") 'boxquote-insert-file)
782 (global-set-key (kbd "<f9> h") 'bh/hide-other)
783 (global-set-key (kbd "<f9> n") 'bh/toggle-next-task-display)
784 (global-set-key (kbd "<f9> w") 'widen)
786 ; change the outline mode prefix from C-c @ to C-c C-2
787 (setq outline-minor-mode-prefix "C-c C-2")
788 ;(add-hook 'outline-minor-mode-hook
789 ; (lambda () (local-set-key (kbd "C-c C-2")
790 ; outline-mode-prefix-map)))
792 (global-set-key (kbd "<f9> I") 'bh/punch-in)
793 (global-set-key (kbd "<f9> O") 'bh/punch-out)
795 (global-set-key (kbd "<f9> o") 'bh/make-org-scratch)
797 (global-set-key (kbd "<f9> r") 'boxquote-region)
798 (global-set-key (kbd "<f9> s") 'bh/switch-to-scratch)
800 (global-set-key (kbd "<f9> t") 'bh/insert-inactive-timestamp)
801 (global-set-key (kbd "<f9> T") 'bh/toggle-insert-inactive-timestamp)
803 (global-set-key (kbd "<f9> v") 'visible-mode)
804 (global-set-key (kbd "<f9> l") 'org-toggle-link-display)
805 (global-set-key (kbd "<f9> SPC") 'bh/clock-in-last-task)
806 (global-set-key (kbd "C-<f9>") 'previous-buffer)
807 (global-set-key (kbd "M-<f9>") 'org-toggle-inline-images)
808 (global-set-key (kbd "C-x n r") 'narrow-to-region)
809 (global-set-key (kbd "C-<f10>") 'next-buffer)
810 (global-set-key (kbd "<f11>") 'org-clock-goto)
811 (global-set-key (kbd "C-<f11>") 'org-clock-in)
812 (global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)
813 (global-set-key (kbd "C-c c") 'org-capture)
817 #+BEGIN_SRC emacs-lisp
818 (defun bh/hide-other ()
821 (org-back-to-heading 'invisible-ok)
827 (defun bh/set-truncate-lines ()
828 "Toggle value of truncate-lines and refresh window display."
830 (setq truncate-lines (not truncate-lines))
831 ;; now refresh window display (an idiom from simple.el):
833 (set-window-start (selected-window)
834 (window-start (selected-window)))))
836 (defun bh/make-org-scratch ()
838 (find-file "/tmp/publish/scratch.org")
839 (gnus-make-directory "/tmp/publish"))
841 (defun bh/switch-to-scratch ()
843 (switch-to-buffer "*scratch*"))
845 (setq org-use-fast-todo-selection t)
846 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
848 ; create function to create headlines in file. This comes from
849 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
850 (defun my/org-add-ids-to-headlines-in-file ()
851 "Add ID properties to all headlines in the current file which
852 do not already have one."
854 (org-map-entries 'org-id-get-create))
855 ; if we wanted to do this to every buffer, do the following:
856 ; (add-hook 'org-mode-hook
858 ; (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
861 #+BEGIN_SRC emacs-lisp
862 (setq org-todo-keywords
863 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
864 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
866 (setq org-todo-keyword-faces
867 (quote (("TODO" :foreground "red" :weight bold)
868 ("NEXT" :foreground "blue" :weight bold)
869 ("DONE" :foreground "forest green" :weight bold)
870 ("WAITING" :foreground "orange" :weight bold)
871 ("HOLD" :foreground "magenta" :weight bold)
872 ("CANCELLED" :foreground "forest green" :weight bold)
873 ("MEETING" :foreground "forest green" :weight bold)
874 ("PHONE" :foreground "forest green" :weight bold))))
876 (setq org-todo-state-tags-triggers
877 (quote (("CANCELLED" ("CANCELLED" . t))
878 ("WAITING" ("WAITING" . t))
879 ("HOLD" ("WAITING") ("HOLD" . t))
880 (done ("WAITING") ("HOLD"))
881 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
882 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
883 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
887 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
888 ; add ids on creation of nodes
889 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
892 ; resolve clocks after 10 minutes of idle; use xprintidle
893 ; (setq org-clock-idle-time 10)
894 ; (setq org-clock-x11idle-program-name "xprintidle")
896 ; this is from http://doc.norang.ca/org-mode.html#Capture
897 ; use C-M-r for org mode capture
898 (global-set-key (kbd "C-M-r") 'org-capture)
900 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
901 (setq org-refile-targets (quote ((nil :maxlevel . 9)
902 (org-agenda-files :maxlevel . 9))))
904 ; Use full outline paths for refile targets - we file directly with IDO
905 (setq org-refile-use-outline-path t)
907 ; Targets complete directly with IDO
908 (setq org-outline-path-complete-in-steps nil)
910 ; Allow refile to create parent tasks with confirmation
911 (setq org-refile-allow-creating-parent-nodes (quote confirm))
913 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
914 ; (setq org-completion-use-ido t)
915 ; (setq ido-everywhere t)
916 ; (setq ido-max-directory-size 100000)
917 ; (ido-mode (quote both))
918 ; ; Use the current window when visiting files and buffers with ido
919 ; (setq ido-default-file-method 'selected-window)
920 ; (setq ido-default-buffer-method 'selected-window)
921 ; ; Use the current window for indirect buffer display
922 ; (setq org-indirect-buffer-display 'current-window)
926 ; Exclude DONE state tasks from refile targets
927 (defun bh/verify-refile-target ()
928 "Exclude todo keywords with a done state from refile targets"
929 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
931 (setq org-refile-target-verify-function 'bh/verify-refile-target)
933 ;; ensure that emacsclient will show just the note to be edited when invoked
934 ;; from Mutt, and that it will shut down emacsclient once finished;
935 ;; fallback to legacy behavior when not invoked via org-protocol.
936 (require 'org-protocol)
937 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
938 (setq my-org-protocol-flag nil)
939 (defadvice org-capture-finalize (after delete-frame-at-end activate)
940 "Delete frame at remember finalization"
941 (progn (if my-org-protocol-flag (delete-frame))
942 (setq my-org-protocol-flag nil)))
943 (defadvice org-capture-refile (around delete-frame-after-refile activate)
944 "Delete frame at remember refile"
945 (if my-org-protocol-flag
947 (setq my-org-protocol-flag nil)
952 (defadvice org-capture-kill (after delete-frame-at-end activate)
953 "Delete frame at remember abort"
954 (progn (if my-org-protocol-flag (delete-frame))
955 (setq my-org-protocol-flag nil)))
956 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
957 (setq my-org-protocol-flag t))
959 (defadvice org-insert-todo-heading (after dla/create-id activate)
964 (add-to-list 'org-modules 'org-habit)
966 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
967 (defun open-mail-in-mutt (message)
968 "Open a mail message in Mutt, using an external terminal.
970 Message can be specified either by a path pointing inside a
971 Maildir, or by Message-ID."
972 (interactive "MPath or Message-ID: ")
974 (format "faf xterm -e \"%s %s\""
975 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
977 ;; add support for "mutt:ID" links
978 (org-add-link-type "mutt" 'open-mail-in-mutt)
980 (defun my-org-mode-setup ()
981 (load-library "reftex")
982 (and (buffer-file-name)
983 (file-exists-p (buffer-file-name))
986 (reftex-set-cite-format
987 '((?b . "[[bib:%l][%l-bib]]")
988 (?n . "[[notes:%l][%l-notes]]")
990 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
992 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
993 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
994 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
995 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
997 (add-hook 'org-mode-hook 'my-org-mode-setup)
999 (defun org-mode-reftex-search ()
1001 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
1003 (defun open-research-paper (bibtexkey)
1004 "Open a paper by bibtex key"
1005 (interactive "bibtex key: ")
1008 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1009 (org-add-link-type "papers" 'open-research-paper)
1010 (defun open-research-paper-pdf (bibtexkey)
1011 "Open a paper pdf by bibtex key"
1012 (interactive "bibtex key: ")
1014 (format "%s -p evince_annot %s"
1015 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1016 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
1018 (add-to-list 'org-link-abbrev-alist
1020 "~/projects/research/paper_notes.org::#%s"))
1022 ; I pretty much always want hiearchical checkboxes
1023 (setq org-hierachical-checkbox-statistics nil)
1025 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
1026 (add-to-list 'org-structure-template-alist
1027 '("E" "\\begin{equation}\n?\n\\end{equation}"))
1030 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
1031 (defun my-rtcite-export-handler (path desc format)
1032 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
1033 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
1034 (match-string 1 path)))
1035 (path (substring path 0 (match-beginning 0))))
1036 (cond ((eq format 'latex)
1038 (equal 0 (search "rtcite:" desc)))
1039 (format "\\cite{%s}" search)
1040 (format "\\cite[%s]{%s}" desc search))))))
1042 (org-add-link-type "rtcite"
1044 'my-rtcite-export-handler)
1048 ** Org Mobile Configuration
1049 #+BEGIN_SRC emacs-lisp
1050 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
1051 (when (string= system-name "linnode")
1052 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
1053 (setq-default org-directory "/home/don/org-mode/")
1054 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
1058 #+BEGIN_SRC emacs-lisp
1059 ;; org mode ical export
1060 (setq org-icalendar-timezone "America/Los_Angeles")
1061 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
1062 ;; we already add the id manually
1063 ;; (setq org-icalendar-store-UID t)
1066 ** General Org Babel Configuration
1067 #+BEGIN_SRC emacs-lisp
1068 ;; org babel support
1069 (org-babel-do-load-languages
1070 'org-babel-load-languages
1077 ;; use graphviz-dot for dot things
1078 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
1079 ;; org-babel-by-backend
1080 (defmacro org-babel-by-backend (&rest body)
1081 `(case (if (boundp 'backend)
1082 (org-export-backend-name backend)
1085 (defun my/fix-inline-images ()
1086 (when org-inline-image-overlays
1087 (org-redisplay-inline-images)))
1089 (add-hook 'org-babel-after-execute-hook
1090 'my/fix-inline-images)
1093 ** LaTeX configuration
1095 :ID: 7135ba17-6a50-4eed-84ca-b90afa5b12f8
1097 #+BEGIN_SRC emacs-lisp
1099 (add-to-list 'org-latex-classes
1101 "\\documentclass[11pt,oneside,article]{memoir}\n"
1102 ("\\section{%s}" . "\\section*{%s}")
1103 ("\\subsection{%s}" . "\\subsection*{%s}")
1104 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1105 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1106 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1108 (setq org-beamer-outline-frame-options "")
1109 (add-to-list 'org-latex-classes
1111 "\\documentclass[ignorenonframetext]{beamer}
1112 [NO-DEFAULT-PACKAGES]
1115 ("\\section{%s}" . "\\section*{%s}")
1116 ("\\subsection{%s}" . "\\subsection*{%s}")
1117 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1118 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1119 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1121 (add-to-list 'org-latex-classes
1123 "\\documentclass[11pt,oneside]{memoir}\n"
1124 ("\\chapter{%s}" . "\\chapter*{%s}")
1125 ("\\section{%s}" . "\\section*{%s}")
1126 ("\\subsection{%s}" . "\\subsection*{%s}")
1127 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
1129 (add-to-list 'org-latex-classes
1131 "\\documentclass[11pt]{letter}
1132 [NO-DEFAULT-PACKAGES]
1135 ("\\section{%s}" . "\\section*{%s}")
1136 ("\\subsection{%s}" . "\\subsection*{%s}")
1137 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1138 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1139 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1141 (add-to-list 'org-latex-classes
1143 "\\documentclass{dlacv}
1144 [NO-DEFAULT-PACKAGES]
1147 ("\\section{%s}" . "\\section*{%s}")
1148 ("\\subsection{%s}" . "\\subsection*{%s}")
1149 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1150 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1151 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1154 (add-to-list 'org-latex-classes
1156 "\\documentclass{dlaresume}
1157 [NO-DEFAULT-PACKAGES]
1160 ("\\section{%s}" . "\\section*{%s}")
1161 ("\\subsection{%s}" . "\\subsection*{%s}")
1162 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1163 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1164 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1167 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
1168 ;; but adapted to use latexmk 4.22 or higher.
1169 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
1171 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
1172 (setq org-latex-default-packages-alist
1174 ("" "unicode-math" t)
1176 (setq org-latex-packages-alist
1183 ("" "longtable" nil)
1186 ;; make equations larger
1187 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
1189 (defun org-create-formula--latex-header ()
1190 "Return LaTeX header appropriate for previewing a LaTeX snippet."
1191 (let ((info (org-combine-plists (org-export--get-global-options
1192 (org-export-get-backend 'latex))
1193 (org-export--get-inbuffer-options
1194 (org-export-get-backend 'latex)))))
1195 (org-latex-guess-babel-language
1196 (org-latex-guess-inputenc
1197 (org-splice-latex-header
1198 org-format-latex-header
1199 org-latex-default-packages-alist
1201 (plist-get info :latex-header)))
1205 ; support ignoring headers in org mode export to latex
1206 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
1207 (defadvice org-latex-headline (around my-latex-skip-headlines
1208 (headline contents info) activate)
1209 (if (member "ignoreheading" (org-element-property :tags headline))
1210 (setq ad-return-value contents)
1213 ;; keep latex logfiles
1215 (setq org-latex-remove-logfiles nil)
1217 ;; Resume clocking task when emacs is restarted
1218 (org-clock-persistence-insinuate)
1220 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
1221 (setq org-clock-history-length 23)
1222 ;; Resume clocking task on clock-in if the clock is open
1223 (setq org-clock-in-resume t)
1224 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
1225 ;; there are things like PHONE calls
1226 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
1227 ;; Separate drawers for clocking and logs
1228 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
1229 ;; Save clock data and state changes and notes in the LOGBOOK drawer
1230 (setq org-clock-into-drawer t)
1231 (setq org-log-into-drawer t)
1232 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
1233 (setq org-clock-out-remove-zero-time-clocks t)
1234 ;; Clock out when moving task to a done state
1235 (setq org-clock-out-when-done t)
1236 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
1237 (setq org-clock-persist t)
1238 ;; Do not prompt to resume an active clock
1239 (setq org-clock-persist-query-resume nil)
1240 ;; Enable auto clock resolution for finding open clocks
1241 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
1242 ;; Include current clocking task in clock reports
1243 (setq org-clock-report-include-clocking-task t)
1245 ;; the cache seems to be broken
1246 (setq org-element-use-cache nil)
1248 (defvar bh/keep-clock-running nil)
1250 (defun bh/is-task-p ()
1251 "Any task with a todo keyword and no subtask"
1255 (subtree-end (save-excursion (org-end-of-subtree t)))
1256 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1259 (while (and (not has-subtask)
1260 (< (point) subtree-end)
1261 (re-search-forward "^\*+ " subtree-end t))
1262 (when (member (org-get-todo-state) org-todo-keywords-1)
1263 (setq has-subtask t))))
1264 (and is-a-task (not has-subtask)))))
1266 (defun bh/is-subproject-p ()
1267 "Any task which is a subtask of another project"
1268 (let ((is-subproject)
1269 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1271 (while (and (not is-subproject) (org-up-heading-safe))
1272 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1273 (setq is-subproject t))))
1274 (and is-a-task is-subproject)))
1277 (defun bh/clock-in-to-next (kw)
1278 "Switch a task from TODO to NEXT when clocking in.
1279 Skips capture tasks, projects, and subprojects.
1280 Switch projects and subprojects from NEXT back to TODO"
1281 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
1283 ((and (member (org-get-todo-state) (list "TODO"))
1286 ((and (member (org-get-todo-state) (list "NEXT"))
1290 (defun bh/punch-in (arg)
1291 "Start continuous clocking and set the default task to the
1292 selected task. If no task is selected set the Organization task
1293 as the default task."
1295 (setq bh/keep-clock-running t)
1296 (if (equal major-mode 'org-agenda-mode)
1298 ;; We're in the agenda
1300 (let* ((marker (org-get-at-bol 'org-hd-marker))
1301 (tags (org-with-point-at marker (org-get-tags-at))))
1302 (if (and (eq arg 4) tags)
1303 (org-agenda-clock-in '(16))
1304 (bh/clock-in-organization-task-as-default)))
1306 ;; We are not in the agenda
1310 ; Find the tags on the current task
1311 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
1312 (org-clock-in '(16))
1313 (bh/clock-in-organization-task-as-default)))))
1315 (defun bh/punch-out ()
1317 (setq bh/keep-clock-running nil)
1318 (when (org-clock-is-active)
1320 (org-agenda-remove-restriction-lock))
1322 (defun bh/clock-in-default-task ()
1324 (org-with-point-at org-clock-default-task
1327 (defun bh/clock-in-parent-task ()
1328 "Move point to the parent (project) task if any and clock in"
1329 (let ((parent-task))
1333 (while (and (not parent-task) (org-up-heading-safe))
1334 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1335 (setq parent-task (point))))
1337 (org-with-point-at parent-task
1339 (when bh/keep-clock-running
1340 (bh/clock-in-default-task)))))))
1342 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
1344 (defun bh/clock-in-organization-task-as-default ()
1346 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
1347 (org-clock-in '(16))))
1349 (defun bh/clock-out-maybe ()
1350 (when (and bh/keep-clock-running
1351 (not org-clock-clocking-in)
1352 (marker-buffer org-clock-default-task)
1353 (not org-clock-resolving-clocks-due-to-idleness))
1354 (bh/clock-in-parent-task)))
1356 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1359 (defun bh/clock-in-task-by-id (id)
1360 "Clock in a task by id"
1361 (org-with-point-at (org-id-find id 'marker)
1362 (org-clock-in nil)))
1364 (defun bh/clock-in-last-task (arg)
1365 "Clock in the interrupted task if there is one
1366 Skip the default task and get the next one.
1367 A prefix arg forces clock in of the default task."
1369 (let ((clock-in-to-task
1371 ((eq arg 4) org-clock-default-task)
1372 ((and (org-clock-is-active)
1373 (equal org-clock-default-task (cadr org-clock-history)))
1374 (caddr org-clock-history))
1375 ((org-clock-is-active) (cadr org-clock-history))
1376 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
1377 (t (car org-clock-history)))))
1379 (org-with-point-at clock-in-to-task
1380 (org-clock-in nil))))
1383 (defun org-export-to-ods ()
1385 (let ((csv-file "data.csv"))
1386 (org-table-export csv-file "orgtbl-to-csv")
1387 (org-odt-convert csv-file "ods" 'open)))
1389 ; allow for zero-width-space to be a break in regexp too
1390 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
1391 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
1392 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
1394 ;; support inserting screen shots
1395 (defun my/org-insert-screenshot ()
1396 "Take a screenshot into a time stamped unique-named file in the
1397 same directory as the org-buffer and insert a link to this file."
1399 (defvar my/org-insert-screenshot/filename)
1400 (setq my/org-insert-screenshot/filename
1402 "Screenshot to insert: "
1404 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
1407 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
1408 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
1409 (org-display-inline-images))
1411 (defun my/fix-inline-images ()
1412 (when org-inline-image-overlays
1413 (org-redisplay-inline-images)))
1415 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
1417 ;; use xelatex to preview with imagemagick
1418 (add-to-list 'org-preview-latex-process-alist
1419 '(xelateximagemagick
1420 :programs ("xelatex" "convert")
1421 :description "pdf > png"
1422 :message "you need to install xelatex and imagemagick"
1424 :image-input-type "pdf"
1425 :image-output-type "png"
1426 :image-size-adjust (1.0 . 1.0)
1427 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
1428 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
1430 ;; use xelatex by default
1431 (setq org-preview-latex-default-process 'xelateximagemagick)
1433 ; from http://orgmode.org/Changes.html
1434 (defun my/org-repair-property-drawers ()
1435 "Fix properties drawers in current buffer.
1436 Ignore non Org buffers."
1438 (when (eq major-mode 'org-mode)
1439 (org-with-wide-buffer
1440 (goto-char (point-min))
1441 (let ((case-fold-search t)
1442 (inline-re (and (featurep 'org-inlinetask)
1443 (concat (org-inlinetask-outline-regexp)
1447 (unless (and inline-re (org-looking-at-p inline-re))
1449 (let ((end (save-excursion (outline-next-heading) (point))))
1451 (when (org-looking-at-p org-planning-line-re) (forward-line))
1452 (when (and (< (point) end)
1453 (not (org-looking-at-p org-property-drawer-re))
1455 (and (re-search-forward org-property-drawer-re end t)
1456 (eq (org-element-type
1457 (save-match-data (org-element-at-point)))
1459 (insert (delete-and-extract-region
1461 (min (1+ (match-end 0)) end)))
1462 (unless (bolp) (insert "\n"))))))))))))
1466 #+BEGIN_SRC emacs-lisp
1470 ** Override other things
1471 #+BEGIN_SRC emacs-lisp
1472 ; apparently things like to step on C-;, so we'll use a hack from
1473 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
1475 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
1477 ; use iedit everywhere
1478 (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
1479 ;; use outline mode keybindings everywhere
1480 ;; (define-key my-keys-minor-mode-map (kbd "C-;") 'my/mydra-outline/body)
1482 (define-minor-mode my-keys-minor-mode
1483 "A minor mode so that my key settings override annoying major modes."
1484 t " my-keys" 'my-keys-minor-mode-map)
1486 (my-keys-minor-mode 1)
1487 (defun my-minibuffer-setup-hook ()
1488 (my-keys-minor-mode 0))
1490 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
1491 (defadvice load (after give-my-keybindings-priority)
1492 "Try to ensure that my keybindings always have priority."
1493 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
1494 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
1495 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
1496 (add-to-list 'minor-mode-map-alist mykeys))))
1500 * Misc (uncharacterized)
1501 #+BEGIN_SRC emacs-lisp
1502 (setq bibtex-user-optional-fields (quote (("annote" "Personal annotation (ignored)") ("abstract" "") ("pmid" "") ("doi" ""))))
1503 (setq calendar-latitude 40.11)
1504 (setq calendar-longitude -88.24)
1505 (setq case-fold-search t)
1506 (setq confirm-kill-emacs (quote y-or-n-p))
1507 (setq cperl-lazy-help-time nil)
1508 (setq debian-changelog-mailing-address "don@debian.org")
1510 (setq display-time-24hr-format t)
1511 (setq display-time-day-and-date t)
1512 (display-time-mode 1)
1513 (setq font-latex-fontify-script nil)
1514 (setq font-latex-fontify-sectioning (quote color))
1515 (setq font-latex-script-display (quote (nil)))
1516 (global-auto-revert-mode 1)
1517 (global-font-lock-mode 1)
1519 (setq log-edit-keep-buffer t)
1520 (setq mail-user-agent (quote sendmail-user-agent))
1521 (setq markdown-enable-math t)
1522 (setq markdown-follow-wiki-link-on-enter nil)
1523 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
1524 (setq post-email-address "don@donarmstrong.com")
1525 (setq post-kill-quoted-sig nil)
1526 (setq post-mail-message "mutt\\(ng\\|\\)-[a-z0-9]+-[0-9]+-.*")
1527 (setq post-uses-fill-mode nil)
1528 (setq ps-footer-font-size (quote (8 . 10)))
1529 (setq ps-header-font-size (quote (8 . 10)))
1530 (setq ps-header-title-font-size (quote (10 . 10)))
1531 (setq ps-line-number-color "blue")
1532 (setq ps-print-footer t)
1533 (setq ps-print-footer-frame nil)
1534 (setq ps-print-only-one-header t)
1535 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
1537 (setq sentence-end-double-space nil)
1538 ; enable matching parenthesis
1541 (setq user-mail-address "don@donarmstrong.com")
1542 (setq vc-delete-logbuf-window nil)
1543 (setq vc-follow-symlinks t)
1545 ;; use git before SVN; use CVS earlier, because I have CVS
1546 ;; repositories inside of git directories
1547 (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
1549 ;; switch back to the old primary selection method
1550 (setq x-select-enable-clipboard nil)
1551 (setq x-select-enable-primary t)
1552 ; (setq mouse-drag-copy-region t)
1554 (fset 'perl-mode 'cperl-mode)
1555 ;;(load-file "cperl-mode.el")
1561 ;;(require 'ecasound)
1562 ;;(require 'emacs-wiki)
1566 ; (require 'google-weather)
1567 ; (require 'org-google-weather)
1568 ; (setq-default org-google-weather-format "%i %c, [%l,%h] %s %C")
1570 (global-set-key "\C-xp" 'server-edit)
1572 (setq-default auto-mode-alist (cons '("\.wml$" .
1573 (lambda () (html-mode) (auto-fill-mode)))
1577 ; use markdown mode for mdwn files
1578 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
1579 (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
1582 ;; tramp configuration
1583 (setq tramp-use-ssh-controlmaster-options nil)
1585 ; mail configuration
1586 (add-to-list 'auto-mode-alist '("muttng-[a-z0-9]+-[0-9]+-" . message-mode))
1587 (add-to-list 'auto-mode-alist '("muttngrc" . muttrc-mode))
1589 (add-to-list 'auto-mode-alist '("mutt-[a-z0-9]+-[0-9]+-" . message-mode))
1590 (add-to-list 'auto-mode-alist '("muttrc" . muttrc-mode))
1591 (defun my-message-mode-settings ()
1592 (font-lock-add-keywords nil
1593 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1594 (0 'message-multiply-quoted-text-face))
1595 ("^[ \t]*>[ \t]*>.*$"
1596 (0 'message-double-quoted-text-face))))
1597 (local-set-key (kbd "C-c C-a") 'my-post-attach-file)
1599 (add-hook 'message-mode-hook 'my-message-mode-settings)
1601 (defun my-post-attach-file ()
1602 "Prompt for an attachment."
1604 (let ((file (read-file-name "Attach file: " nil nil t nil))
1605 (description (string-read "Description: ")))
1606 (my-header-attach-file file description)))
1608 (symbol-function 'my-post-attach-file)
1610 (defun my-header-attach-file (file description)
1611 "Attach a FILE to the current message (works with Mutt).
1612 Argument DESCRIPTION MIME description."
1613 (interactive "fAttach file: \nsDescription: ")
1614 (when (> (length file) 0)
1619 (goto-char (point-min))
1620 (search-forward-regexp "^$")
1621 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1623 (message (concat "Attached '" file "'."))
1624 (setq post-has-attachment t))))))
1628 (setq mail-yank-prefix "> ")
1630 (global-unset-key "\M-g")
1631 (global-set-key "\M-g" 'goto-line)
1633 ;; self-insert-command hack.
1634 ;; Without this, "if<SP>" expands to
1637 ;; which really should be,
1643 ;(load-library "php-mode")
1645 (setq-default c-indent-level 4)
1646 (setq-default c-brace-imaginary-offset 0)
1647 (setq-default c-brace-offset -4)
1648 (setq-default c-argdecl-indent 4)
1649 (setq-default c-label-offset -4)
1650 (setq-default c-continued-statement-offset 4)
1652 (setq-default indent-tabs-mode nil)
1653 (setq-default tab-width 4)
1656 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
1657 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
1658 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
1659 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
1660 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
1663 (defun insert-date ()
1664 "Insert date at point."
1666 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
1667 (global-set-key "\C-[d" 'insert-date)
1669 (defun unfill-paragraph (arg)
1670 "Pull this whole paragraph up onto one line."
1672 (let ((fill-column 10000))
1673 (fill-paragraph arg))
1676 (column-number-mode t)
1680 ; (require 'mode-compile)
1682 (defadvice server-process-filter (after post-mode-message first activate)
1683 "If the buffer is in post mode, overwrite the server-edit
1684 message with a post-save-current-buffer-and-exit message."
1685 (if (eq major-mode 'post-mode)
1687 (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done."))))
1688 ; This is also needed to see the magic message. Set to a higher
1689 ; number if you have a faster computer or read slower than me.
1690 '(font-lock-verbose 1000)
1691 ;(setq-default server-temp-file-regexp "mutt\(-\|ng-\)")
1692 ; (add-hook 'server-switch-hook
1693 ; (function (lambda()
1694 ; (cond ((string-match "Post" mode-name)
1695 ; (post-goto-body)))
1696 ; set-buffer-file-coding-system 'utf-8
1700 (add-hook 'post-mode-hook
1701 (auto-fill-mode nil)
1703 ; abbrev mode settings
1704 ; load abbreviations from
1705 (setq abbrev-file-name
1706 "~/.emacs_abbrev_def")
1708 ; read the abbrev file if it exists
1709 (if (file-exists-p abbrev-file-name)
1710 (quietly-read-abbrev-file))
1712 ; for now, use abbrev mode everywhere
1713 (setq default-abbrev-mode t)
1716 (defun insert-function-documentation ()
1717 "Insert function documentation"
1719 (insert-file-contents "/home/don/lib/templates/perl_function_documentation" nil))
1720 (global-set-key "\M-f" 'insert-function-documentation)
1722 (eval-after-load "lilypond-mode"
1724 (load-library "lyqi-mode")
1725 (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
1727 (autoload 'spamassassin-mode "spamassassin-mode" nil t)
1729 (desktop-load-default)
1731 '(icomplete-mode on)
1733 ;; custom-set-faces was added by Custom.
1734 ;; If you edit it by hand, you could mess it up, so be careful.
1735 ;; Your init file should contain only one such instance.
1736 ;; If there is more than one, they won't work right.
1737 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
1740 (put 'upcase-region 'disabled nil)
1741 (put 'downcase-region 'disabled nil)
1742 (put 'narrow-to-region 'disabled nil)
1744 ; (defun turn-on-flyspell ()
1745 ; "Force flyspell-mode on using a positive arg. For use in hooks."
1747 ; (flyspell-mode 1))
1750 ; Outline-minor-mode key map
1751 (define-prefix-command 'cm-map nil "Outline-")
1753 (define-key cm-map "q" 'hide-sublevels) ; Hide everything but the top-level headings
1754 (define-key cm-map "t" 'hide-body) ; Hide everything but headings (all body lines)
1755 (define-key cm-map "o" 'hide-other) ; Hide other branches
1756 (define-key cm-map "c" 'hide-entry) ; Hide this entry's body
1757 (define-key cm-map "l" 'hide-leaves) ; Hide body lines in this entry and sub-entries
1758 (define-key cm-map "d" 'hide-subtree) ; Hide everything in this entry and sub-entries
1760 (define-key cm-map "a" 'show-all) ; Show (expand) everything
1761 (define-key cm-map "e" 'show-entry) ; Show this heading's body
1762 (define-key cm-map "i" 'show-children) ; Show this heading's immediate child sub-headings
1763 (define-key cm-map "k" 'show-branches) ; Show all sub-headings under this heading
1764 (define-key cm-map "s" 'show-subtree) ; Show (expand) everything in this heading & below
1766 (define-key cm-map "u" 'outline-up-heading) ; Up
1767 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
1768 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
1769 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
1770 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
1771 (global-set-key "\M-o" cm-map)
1775 (setq-default debian-changelog-mailing-address "don@debian.org")
1776 (setq-default debian-changelog-full-name "Don Armstrong")
1778 ; ediff configuration
1779 ; don't use the multi-window configuration
1780 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
1784 (define-key global-map (kbd "C-;") 'iedit-mode)
1785 (global-set-key (kbd "C-;") 'iedit-mode)
1787 ; fix up css mode to not be silly
1788 ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
1789 (setq cssm-indent-level 4)
1790 (setq cssm-newline-before-closing-bracket t)
1791 (setq cssm-indent-function #'cssm-c-style-indenter)
1792 (setq cssm-mirror-mode nil)
1794 (require 'multi-web-mode)
1795 (setq mweb-default-major-mode 'html-mode)
1796 (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
1797 (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
1798 (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
1799 (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
1800 (multi-web-global-mode 1)
1802 ;;; alias the new `flymake-report-status-slim' to
1803 ;;; `flymake-report-status'
1804 (defalias 'flymake-report-status 'flymake-report-status-slim)
1805 (defun flymake-report-status-slim (e-w &optional status)
1806 "Show \"slim\" flymake status in mode line."
1808 (setq flymake-mode-line-e-w e-w))
1810 (setq flymake-mode-line-status status))
1811 (let* ((mode-line " Φ"))
1812 (when (> (length flymake-mode-line-e-w) 0)
1813 (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
1814 (setq mode-line (concat mode-line flymake-mode-line-status))
1815 (setq flymake-mode-line mode-line)
1816 (force-mode-line-update)))
1818 ; load sql-indent when sql is loaded
1819 (eval-after-load "sql"
1820 '(load-library "sql-indent"))
1822 ; fix up tmux xterm keys
1823 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
1824 (defun fix-up-tmux-keys ()
1825 "Fix up tmux xterm keys"
1828 (let ((x 2) (tkey ""))
1848 ;; ctrl + alt + shift
1850 (setq tkey "C-M-S-"))
1853 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
1854 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
1855 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
1856 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
1858 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
1860 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
1862 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
1864 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
1866 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
1868 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
1870 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
1872 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
1874 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
1876 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
1878 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
1880 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
1882 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
1884 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
1886 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
1888 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
1890 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
1892 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
1894 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
1896 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
1898 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
1900 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
1902 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
1904 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
1906 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
1908 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
1915 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
1917 ; procmailmode configuration
1918 (load "procmail_mode")
1920 (load "mode-line-cleaner")
1922 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
1923 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
1924 (if (or (buffer-modified-p)
1925 (verify-visited-file-modtime)
1926 (< (* 8 1024 1024) (buffer-size))
1927 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
1929 (clear-visited-file-modtime)
1931 (ad-activate 'ask-user-about-supersession-threat)
1933 ; apparently things like to step on C-;, so we'll use a hack from
1934 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
1936 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
1938 ; use iedit everywhere
1939 (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
1941 (define-minor-mode my-keys-minor-mode
1942 "A minor mode so that my key settings override annoying major modes."
1943 t " my-keys" 'my-keys-minor-mode-map)
1945 (my-keys-minor-mode 1)
1946 (defun my-minibuffer-setup-hook ()
1947 (my-keys-minor-mode 0))
1949 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
1950 (defadvice load (after give-my-keybindings-priority)
1951 "Try to ensure that my keybindings always have priority."
1952 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
1953 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
1954 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
1955 (add-to-list 'minor-mode-map-alist mykeys))))
1957 (global-set-key "\M- " 'hippie-expand)
1962 #+BEGIN_SRC emacs-lisp
1963 (provide 'don-configuration)