1 #+PROPERTY: header-args:emacs-lisp :tangle don-configuration.el
4 # if for some reason, things get pear-shaped, we want to be able to
5 # enter the debugger by sending -USR2 to emacs
8 (setq debug-on-event 'siguser2)
12 #+BEGIN_SRC emacs-lisp
13 (add-to-list 'load-path '"~/lib/emacs_el/")
14 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/tiny")
15 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/other")
16 (add-to-list 'load-path '"~/lib/emacs_el/magit-annex")
20 ** package repositories and package manager
21 #+BEGIN_SRC emacs-lisp
23 (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
24 ("melpa" . "https://melpa.org/packages/")
25 ("org" . "http://orgmode.org/elpa/") ))
27 ** [[https://github.com/jwiegley/use-package/][use-package]]
28 #+BEGIN_SRC emacs-lisp
29 (require 'use-package)
33 #+BEGIN_SRC emacs-lisp
41 #+BEGIN_SRC emacs-lisp
42 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
43 ;; execute conditional code when loading libraries
44 (defmacro with-library (symbol &rest body)
45 `(when (require ,symbol nil t)
47 (put 'with-library 'lisp-indent-function 1)
51 ** Safe Local Variables
52 #+BEGIN_SRC emacs-lisp
53 (setq safe-local-variable-values
54 (quote ((auto-save-default)
56 (cperl-indent-level . 4)
58 (indent-tabs-mode . f)
62 #+BEGIN_SRC emacs-lisp
63 (setq global-mark-ring-max 128
67 (defun don/minibuffer-setup-hook ()
68 (setq gc-cons-threshold most-positive-fixnum))
70 (defun don/minibuffer-exit-hook ()
71 (setq gc-cons-threshold 1048576))
73 (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
74 (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
78 #+BEGIN_SRC emacs-lisp
81 :diminish flyspell-mode 🐝
83 (add-hook 'message-mode-hook 'turn-on-flyspell)
84 (add-hook 'text-mode-hook 'turn-on-flyspell)
85 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
86 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
87 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
89 (setq ispell-program-name "ispell")
94 #+BEGIN_SRC emacs-lisp
99 #+BEGIN_SRC emacs-lisp
100 ;; (use-package eyebrowse
102 ;; :diminish eyebrowse-mode
103 ;; :init (setq eyebrowse-keymap-prefix (kbd "C-c C-\\"))
105 ;; (setq eyebrowse-wrap-around t)
106 ;; (eyebrowse-mode t)
108 ;; (defun my/eyebrowse-new-window-config ()
112 ;; ;; start at 1 run till 0
113 ;; (let ((j (mod (+ i 1) 10)))
114 ;; (when (and (not done)
115 ;; (not (eyebrowse--window-config-present-p j)))
116 ;; (eyebrowse-switch-to-window-config j)
117 ;; (call-interactively 'eyebrowse-rename-window-config2 j)
122 ;; ;; I don't use latex-preview-pane
123 ;; ;; (require 'latex-preview-pane)
124 ;; ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
125 ;; ;; ;; latex-preview-pane uses window-parameters which are
126 ;; ;; ;; not preserved by eyebrowse, so we close the preview
127 ;; ;; ;; pane before switching, it will be regenerated when we
128 ;; ;; ;; edit the TeX file.
129 ;; ;; (when (lpp/window-containing-preview)
130 ;; ;; (delete-window (lpp/window-containing-preview))))
132 ;; ;; (add-to-list 'eyebrowse-pre-window-switch-hook
133 ;; ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
135 ;; ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
136 ;; ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
137 ;; ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
138 ;; ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
139 ;; ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
147 #+BEGIN_SRC emacs-lisp
148 (defun my/vsplit-last-buffer ()
149 "Split the window vertically and display the previous buffer."
151 (split-window-vertically)
153 (switch-to-next-buffer))
155 (defun my/hsplit-last-buffer ()
156 "Split the window horizontally and display the previous buffer."
158 (split-window-horizontally)
160 (switch-to-next-buffer))
162 (bind-key "C-x 2" 'my/vsplit-last-buffer)
163 (bind-key "C-x 3" 'my/hsplit-last-buffer)
165 (setq split-width-threshold 100)
166 (setq split-height-threshold 60)
168 (defun my/split-window-prefer-vertically (window)
169 "If there's only one window (excluding any possibly active
170 minibuffer), then split the current window horizontally."
171 (if (and (one-window-p t)
172 (not (active-minibuffer-window))
173 ( < (frame-width) (frame-height))
175 (let ((split-width-threshold nil))
176 (split-window-sensibly window))
177 (split-window-sensibly window)))
179 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
180 (setq window-combination-resize t)
183 *** Compilation window
185 If there is no compilation window, open one at the bottom, spanning
186 the complete width of the frame. Otherwise, reuse existing window. In
187 the former case, if there was no error the window closes
190 #+BEGIN_SRC emacs-lisp
191 (add-to-list 'display-buffer-alist
192 `(,(rx bos "*compilation*" eos)
193 (display-buffer-reuse-window
194 display-buffer-in-side-window)
195 (reusable-frames . visible)
197 (window-height . 0.4)))
200 #+BEGIN_SRC emacs-lisp
201 (defun my/compilation-exit-autoclose (status code msg)
202 ;; If M-x compile exists with a 0
203 (when (and (eq status 'exit) (zerop code))
204 ;; and delete the *compilation* window
205 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
206 (when (and (not (window-at-side-p compilation-window 'top))
207 (window-at-side-p compilation-window 'left)
208 (window-at-side-p compilation-window 'right))
209 (delete-window compilation-window))))
210 ;; Always return the anticipated result of compilation-exit-message-function
213 ;; Specify my function (maybe I should have done a lambda function)
214 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
217 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
218 value, the compilation buffer scrolls automatically to follow the
219 output. If the value is ~first-error~, scrolling stops when the first
220 error appears, leaving point at that error. For any other non-nil
221 value, scrolling continues until there is no more output.
223 #+BEGIN_SRC emacs-lisp
224 (setq compilation-scroll-output 'first-error)
227 ** Mode line cleaning
229 #+BEGIN_SRC emacs-lisp
230 (use-package diminish
235 #+BEGIN_SRC emacs-lisp
242 #+BEGIN_SRC emacs-lisp
245 :bind ("C-c C-SPC" . avy-goto-word-1)
247 (setq avy-background t)
248 (key-chord-define-global "jj" #'avy-goto-word-1)))
254 #+BEGIN_SRC emacs-lisp
255 (use-package yasnippet
257 :diminish yas-minor-mode
260 (setq yas-verbosity 1)
261 (define-key yas-minor-mode-map (kbd "<tab>") nil)
262 (define-key yas-minor-mode-map (kbd "TAB") nil)
263 (define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)
269 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
271 #+BEGIN_SRC emacs-lisp
272 (use-package helm-flx
275 ;; these are helm configs, but they kind of fit here nicely
276 (setq helm-M-x-fuzzy-match t
277 helm-bookmark-show-location t
278 helm-buffers-fuzzy-matching t
279 helm-completion-in-region-fuzzy-match t
280 helm-file-cache-fuzzy-match t
281 helm-imenu-fuzzy-match t
282 helm-mode-fuzzy-match t
283 helm-locate-fuzzy-match nil
285 helm-recentf-fuzzy-match nil
286 helm-semantic-fuzzy-match t)
293 #+BEGIN_SRC emacs-lisp
295 (use-package tinyprocmail
297 :config (with-library 'tinyprocmail
298 ;; (setq tinyprocmail--procmail-version "v3.22")
299 (add-hook 'tinyprocmail--load-hook 'tinyprocmail-install))
304 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
307 :bind (("C-x g" . magit-status)
308 ("C-x C-g" . magit-status))
310 ;; don't verify where we are pushing
311 (setq magit-push-always-verify nil)
312 ;; refine diffs always (hilight words)
313 (setq magit-diff-refine-hunk nil)
316 (append '("~/lib/emacs_el/magit-annex")
320 (append '("~/lib/emacs_el/magit-vcsh")
323 (use-package magit-annex
326 (use-package magit-vcsh
327 :ensure f ; currently not in melpa, so don't try to install
332 #+BEGIN_SRC emacs-lisp
333 (require 'cperl-mode)
334 ;; Use c-mode for perl .xs files
335 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
336 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
337 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
338 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
339 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
342 cperl-auto-newline nil
343 cperl-auto-newline-after-colon nil
344 cperl-continued-statement-offset 4
345 cperl-brace-offset -1
346 cperl-continued-brace-offset 0
347 cperl-label-offset -4
348 cperl-highlight-variables-indiscriminately t
349 cperl-electric-lbrace-space nil
350 cperl-indent-parens-as-block nil
351 cperl-close-paren-offset -1
352 cperl-tab-always-indent t)
353 ;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
357 #+BEGIN_SRC emacs-lisp
362 (define-key global-map [remap find-file] 'helm-find-files)
363 (define-key global-map [remap occur] 'helm-occur)
364 (define-key global-map [remap list-buffers] 'helm-buffers-list)
365 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
366 (global-set-key (kbd "M-x") 'helm-M-x)
367 (unless (boundp 'completion-in-region-function)
368 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
369 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
370 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
374 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
379 #+BEGIN_SRC emacs-lisp
380 (add-to-list 'tramp-methods '("vcsh"
381 (tramp-login-program "vcsh")
385 (tramp-remote-shell "/bin/sh")
386 (tramp-remote-shell-args
390 #+BEGIN_SRC emacs-lisp
394 (setq-default reftex-default-bibliography
395 '("~/projects/research/references.bib")))
398 #+BEGIN_SRC emacs-lisp
403 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
404 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
405 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
406 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
407 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
408 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
409 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
410 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
411 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
412 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
413 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
415 (setq-default reftex-plug-into-AUCTeX t)
416 ;; support fake section headers
417 (setq TeX-outline-extra
423 ;; add font locking to the headers
424 (font-lock-add-keywords
426 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
427 0 'font-lock-keyword-face t)
428 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
429 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
430 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
431 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
432 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
434 ;; use smart quotes by default instead of `` and ''
435 ;; taken from http://kieranhealy.org/esk/kjhealy.html
436 (setq TeX-open-quote "“")
437 (setq TeX-close-quote "”")
439 ;; (TeX-add-style-hook
444 ;; (custom-set-variables
445 ;; '(font-latex-user-keyword-classes
448 ;; font-lock-function-name-face 2 (command 1 t))))
450 (setq-default TeX-parse-self t)
451 (setq-default TeX-auto-save t)
452 (setq-default TeX-master nil)
458 (if (boundp 'reftex-ref-style-alist)
460 'reftex-ref-style-alist
461 '("Cleveref" "cleveref"
462 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
463 (reftex-ref-style-activate "Cleveref")
465 '("cref" TeX-arg-ref)
466 '("Cref" TeX-arg-ref)
467 '("cpageref" TeX-arg-ref)
468 '("Cpageref" TeX-arg-ref)))))
471 '(add-to-list 'LaTeX-fill-excluded-macros
474 (use-package font-latex
476 (setq font-latex-match-reference-keywords
502 #+BEGIN_SRC emacs-lisp
503 (require 'org-mode-configuration)
506 #+BEGIN_SRC emacs-lisp
510 (use-package calfw-org
513 (use-package org-gcal
515 :config '((if (file-readable-p "~/.hide/org_gcal.el")
516 (load-file "~/.hide/org_gcal.el"))
521 #+BEGIN_SRC emacs-lisp
524 :config (require 'ess_configuration))
528 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
530 #+BEGIN_SRC emacs-lisp
531 (use-package rainbow-mode
532 ;; add ess to the x major mode
533 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
534 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
539 #+BEGIN_SRC emacs-lisp
540 (use-package polymode
543 (use-package poly-noweb)
544 (use-package poly-markdown)
545 :mode ("\\.Snw" . poly-noweb+r-mode)
546 :mode ("\\.Rnw" . poly-noweb+r-mode)
547 :mode ("\\.Rmd" . poly-markdown+r-mode)
553 #+BEGIN_SRC emacs-lisp
554 (use-package outline-magic)
557 #+BEGIN_SRC emacs-lisp
558 (use-package writeroom-mode
559 :config (add-hook 'writeroom-mode-hook 'auto-fill-mode)
562 ** GhostText/Atomic Chrome
563 #+BEGIN_SRC emacs-lisp
564 (use-package atomic-chrome
565 :config (atomic-chrome-start-server)
569 ** Use-package and load things
570 #+BEGIN_SRC emacs-lisp
576 ** Agenda Configuration
577 #+BEGIN_SRC emacs-lisp
578 ;; The following lines are always needed. Choose your own keys.
579 (add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode))
580 (global-set-key "\C-cl" 'org-store-link)
581 (global-set-key "\C-ca" 'org-agenda)
582 (global-set-key "\C-cb" 'org-iswitchb)
583 (setq-default org-log-done 'time)
584 (setq-default org-agenda-ndays 5)
586 ;; agenda configuration
587 ;; Do not dim blocked tasks
588 (setq org-agenda-dim-blocked-tasks nil)
589 (setq org-agenda-inhibit-startup t)
590 (setq org-agenda-use-tag-inheritance nil)
592 ;; Compact the block agenda view
593 (setq org-agenda-compact-blocks t)
595 ;; Custom agenda command definitions
596 (setq org-agenda-custom-commands
597 (quote (("N" "Notes" tags "NOTE"
598 ((org-agenda-overriding-header "Notes")
599 (org-tags-match-list-sublevels t)))
600 ("h" "Habits" tags-todo "STYLE=\"habit\""
601 ((org-agenda-overriding-header "Habits")
602 (org-agenda-sorting-strategy
603 '(todo-state-down effort-up category-keep))))
607 ((org-agenda-overriding-header "Tasks to Refile")
608 (org-tags-match-list-sublevels nil)))
609 (tags-todo "-CANCELLED/!"
610 ((org-agenda-overriding-header "Stuck Projects")
611 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
612 (org-agenda-sorting-strategy
614 (tags-todo "-HOLD-CANCELLED/!"
615 ((org-agenda-overriding-header "Projects")
616 (org-agenda-skip-function 'bh/skip-non-projects)
617 (org-tags-match-list-sublevels 'indented)
618 (org-agenda-sorting-strategy
620 (tags-todo "-CANCELLED/!NEXT"
621 ((org-agenda-overriding-header (concat "Project Next Tasks"
622 (if bh/hide-scheduled-and-waiting-next-tasks
624 " (including WAITING and SCHEDULED tasks)")))
625 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
626 (org-tags-match-list-sublevels t)
627 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
628 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
629 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
630 (org-agenda-sorting-strategy
631 '(todo-state-down effort-up category-keep))))
632 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
633 ((org-agenda-overriding-header (concat "Project Subtasks"
634 (if bh/hide-scheduled-and-waiting-next-tasks
636 " (including WAITING and SCHEDULED tasks)")))
637 (org-agenda-skip-function 'bh/skip-non-project-tasks)
638 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
639 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
640 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
641 (org-agenda-sorting-strategy
643 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
644 ((org-agenda-overriding-header (concat "Standalone Tasks"
645 (if bh/hide-scheduled-and-waiting-next-tasks
647 " (including WAITING and SCHEDULED tasks)")))
648 (org-agenda-skip-function 'bh/skip-project-tasks)
649 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
650 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
651 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
652 (org-agenda-sorting-strategy
654 (tags-todo "-CANCELLED+WAITING|HOLD/!"
655 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
656 (org-agenda-skip-function 'bh/skip-stuck-projects)
657 (org-tags-match-list-sublevels nil)
658 (org-agenda-todo-ignore-scheduled t)
659 (org-agenda-todo-ignore-deadlines t)))
661 ((org-agenda-overriding-header "Tasks to Archive")
662 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
663 (org-tags-match-list-sublevels nil))))
666 ; org mode agenda files
667 (setq org-agenda-files
668 (quote ("~/projects/org-notes/debbugs.org"
669 "~/projects/org-notes/notes.org"
670 "~/projects/org-notes/holidays.org"
671 "~/projects/org-notes/refile.org"
672 "~/projects/org-notes/diary.org"
673 "~/projects/org-notes/ool.org"
674 "~/projects/org-notes/sndservers.org"
675 "~/projects/org-notes/chaim.org"
676 "~/projects/org-notes/wildman.org"
677 "~/projects/org-notes/uddin.org"
678 "~/projects/org-notes/reviews.org"
679 "~/projects/org-notes/hpcbio.org"
680 "~/org-mode/from-mobile.org"
681 "~/projects/org-notes/fh.org")))
683 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
684 (set-register ?r (cons 'file "~/projects/org-notes/refile.org"))
685 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
686 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
687 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
688 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
689 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
690 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
691 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
692 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
693 (defun org-agenda-timeline-all (&optional arg)
696 (dolist (org-agenda-file org-agenda-files)
697 (insert-file-contents org-agenda-file nil)
700 (write-file "/tmp/timeline.org")
701 (org-agenda arg "L")))
702 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
703 ;; add automatic reminders for appointments
704 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
705 "Pressing `r' on the agenda will also add appointments."
707 (setq appt-time-msg-list nil)
708 (org-agenda-to-appt)))
712 #+BEGIN_SRC emacs-lisp
713 (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")))
714 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
716 (setq org-default-notes-file "~/projects/org-notes/notes.org")
717 (setq org-id-link-to-org-use-id t)
720 #+BEGIN_SRC emacs-lisp
721 (setq org-capture-templates ;; mail-specific note template, identified by "m"
722 '(("m" "Mail" entry (file "~/projects/org-notes/refile.org")
723 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
724 ("t" "todo" entry (file "~/projects/org-notes/refile.org")
725 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
726 ("r" "respond" entry (file "~/projects/org-notes/refile.org")
727 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
728 ("n" "note" entry (file "~/projects/org-notes/refile.org")
729 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
730 ("s" "schedule" entry (file "~/projects/org-notes/refile.org")
731 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
732 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
733 "* %?\n%U\n" :clock-in t :clock-resume t)
734 ("w" "org-protocol" entry (file "~/projects/org-notes/refile.org")
735 "* TODO Review %c\n%U\n" :immediate-finish t)
736 ("M" "Meeting" entry (file "~/projects/org-notes/refile.org")
737 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
738 ("S" "Seminar" entry (file "~/projects/org-notes/refile.org")
739 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
740 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
741 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
742 ("p" "Phone call" entry (file "~/projects/org-notes/refile.org")
743 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
744 ("J" "job" entry (file "~/projects/org-notes/refile.org")
745 "* 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)
746 ("h" "Habit" entry (file "~/projects/org-notes/refile.org")
747 "* 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")
751 ;; Remove empty LOGBOOK drawers on clock out
752 (defun bh/remove-empty-drawer-on-clock-out ()
755 (beginning-of-line 0)
756 (org-remove-empty-drawer-at (point))))
758 (defun my/org-add-id ()
761 (if (org-current-level)
770 ** Org mode key bindings
771 #+BEGIN_SRC emacs-lisp
772 ; org mode configuration from http://doc.norang.ca/org-mode.html
773 ;; Custom Key Bindings
774 (global-set-key (kbd "<f12>") 'org-agenda)
775 (global-set-key (kbd "<f5>") 'bh/org-todo)
776 (global-set-key (kbd "<S-f5>") 'bh/widen)
777 (global-set-key (kbd "<f7>") 'bh/set-truncate-lines)
778 (global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
779 (global-set-key (kbd "<f9> <f9>") 'bh/show-org-agenda)
780 (global-set-key (kbd "<f9> b") 'bbdb)
781 (global-set-key (kbd "<f9> c") 'calendar)
782 (global-set-key (kbd "<f9> f") 'boxquote-insert-file)
783 (global-set-key (kbd "<f9> h") 'bh/hide-other)
784 (global-set-key (kbd "<f9> n") 'bh/toggle-next-task-display)
785 (global-set-key (kbd "<f9> w") 'widen)
787 ; change the outline mode prefix from C-c @ to C-c C-2
788 (setq outline-minor-mode-prefix "C-c C-2")
789 ;(add-hook 'outline-minor-mode-hook
790 ; (lambda () (local-set-key (kbd "C-c C-2")
791 ; outline-mode-prefix-map)))
793 (global-set-key (kbd "<f9> I") 'bh/punch-in)
794 (global-set-key (kbd "<f9> O") 'bh/punch-out)
796 (global-set-key (kbd "<f9> o") 'bh/make-org-scratch)
798 (global-set-key (kbd "<f9> r") 'boxquote-region)
799 (global-set-key (kbd "<f9> s") 'bh/switch-to-scratch)
801 (global-set-key (kbd "<f9> t") 'bh/insert-inactive-timestamp)
802 (global-set-key (kbd "<f9> T") 'bh/toggle-insert-inactive-timestamp)
804 (global-set-key (kbd "<f9> v") 'visible-mode)
805 (global-set-key (kbd "<f9> l") 'org-toggle-link-display)
806 (global-set-key (kbd "<f9> SPC") 'bh/clock-in-last-task)
807 (global-set-key (kbd "C-<f9>") 'previous-buffer)
808 (global-set-key (kbd "M-<f9>") 'org-toggle-inline-images)
809 (global-set-key (kbd "C-x n r") 'narrow-to-region)
810 (global-set-key (kbd "C-<f10>") 'next-buffer)
811 (global-set-key (kbd "<f11>") 'org-clock-goto)
812 (global-set-key (kbd "C-<f11>") 'org-clock-in)
813 (global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)
814 (global-set-key (kbd "C-c c") 'org-capture)
818 #+BEGIN_SRC emacs-lisp
819 (defun bh/hide-other ()
822 (org-back-to-heading 'invisible-ok)
828 (defun bh/set-truncate-lines ()
829 "Toggle value of truncate-lines and refresh window display."
831 (setq truncate-lines (not truncate-lines))
832 ;; now refresh window display (an idiom from simple.el):
834 (set-window-start (selected-window)
835 (window-start (selected-window)))))
837 (defun bh/make-org-scratch ()
839 (find-file "/tmp/publish/scratch.org")
840 (gnus-make-directory "/tmp/publish"))
842 (defun bh/switch-to-scratch ()
844 (switch-to-buffer "*scratch*"))
846 (setq org-use-fast-todo-selection t)
847 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
849 ; create function to create headlines in file. This comes from
850 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
851 (defun my/org-add-ids-to-headlines-in-file ()
852 "Add ID properties to all headlines in the current file which
853 do not already have one."
855 (org-map-entries 'org-id-get-create))
856 ; if we wanted to do this to every buffer, do the following:
857 ; (add-hook 'org-mode-hook
859 ; (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
862 #+BEGIN_SRC emacs-lisp
863 (setq org-todo-keywords
864 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
865 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
867 (setq org-todo-keyword-faces
868 (quote (("TODO" :foreground "red" :weight bold)
869 ("NEXT" :foreground "blue" :weight bold)
870 ("DONE" :foreground "forest green" :weight bold)
871 ("WAITING" :foreground "orange" :weight bold)
872 ("HOLD" :foreground "magenta" :weight bold)
873 ("CANCELLED" :foreground "forest green" :weight bold)
874 ("MEETING" :foreground "forest green" :weight bold)
875 ("PHONE" :foreground "forest green" :weight bold))))
877 (setq org-todo-state-tags-triggers
878 (quote (("CANCELLED" ("CANCELLED" . t))
879 ("WAITING" ("WAITING" . t))
880 ("HOLD" ("WAITING") ("HOLD" . t))
881 (done ("WAITING") ("HOLD"))
882 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
883 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
884 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
888 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
889 ; add ids on creation of nodes
890 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
893 ; resolve clocks after 10 minutes of idle; use xprintidle
894 ; (setq org-clock-idle-time 10)
895 ; (setq org-clock-x11idle-program-name "xprintidle")
897 ; this is from http://doc.norang.ca/org-mode.html#Capture
898 ; use C-M-r for org mode capture
899 (global-set-key (kbd "C-M-r") 'org-capture)
901 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
902 (setq org-refile-targets (quote ((nil :maxlevel . 9)
903 (org-agenda-files :maxlevel . 9))))
905 ; Use full outline paths for refile targets - we file directly with IDO
906 (setq org-refile-use-outline-path t)
908 ; Targets complete directly with IDO
909 (setq org-outline-path-complete-in-steps nil)
911 ; Allow refile to create parent tasks with confirmation
912 (setq org-refile-allow-creating-parent-nodes (quote confirm))
914 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
915 ; (setq org-completion-use-ido t)
916 ; (setq ido-everywhere t)
917 ; (setq ido-max-directory-size 100000)
918 ; (ido-mode (quote both))
919 ; ; Use the current window when visiting files and buffers with ido
920 ; (setq ido-default-file-method 'selected-window)
921 ; (setq ido-default-buffer-method 'selected-window)
922 ; ; Use the current window for indirect buffer display
923 ; (setq org-indirect-buffer-display 'current-window)
927 ; Exclude DONE state tasks from refile targets
928 (defun bh/verify-refile-target ()
929 "Exclude todo keywords with a done state from refile targets"
930 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
932 (setq org-refile-target-verify-function 'bh/verify-refile-target)
934 ;; ensure that emacsclient will show just the note to be edited when invoked
935 ;; from Mutt, and that it will shut down emacsclient once finished;
936 ;; fallback to legacy behavior when not invoked via org-protocol.
937 (require 'org-protocol)
938 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
939 (setq my-org-protocol-flag nil)
940 (defadvice org-capture-finalize (after delete-frame-at-end activate)
941 "Delete frame at remember finalization"
942 (progn (if my-org-protocol-flag (delete-frame))
943 (setq my-org-protocol-flag nil)))
944 (defadvice org-capture-refile (around delete-frame-after-refile activate)
945 "Delete frame at remember refile"
946 (if my-org-protocol-flag
948 (setq my-org-protocol-flag nil)
953 (defadvice org-capture-kill (after delete-frame-at-end activate)
954 "Delete frame at remember abort"
955 (progn (if my-org-protocol-flag (delete-frame))
956 (setq my-org-protocol-flag nil)))
957 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
958 (setq my-org-protocol-flag t))
960 (defadvice org-insert-todo-heading (after dla/create-id activate)
965 (add-to-list 'org-modules 'org-habit)
967 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
968 (defun open-mail-in-mutt (message)
969 "Open a mail message in Mutt, using an external terminal.
971 Message can be specified either by a path pointing inside a
972 Maildir, or by Message-ID."
973 (interactive "MPath or Message-ID: ")
975 (format "faf xterm -e \"%s %s\""
976 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
978 ;; add support for "mutt:ID" links
979 (org-add-link-type "mutt" 'open-mail-in-mutt)
981 (defun my-org-mode-setup ()
982 (load-library "reftex")
983 (and (buffer-file-name)
984 (file-exists-p (buffer-file-name))
987 (reftex-set-cite-format
988 '((?b . "[[bib:%l][%l-bib]]")
989 (?n . "[[notes:%l][%l-notes]]")
991 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
993 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
994 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
995 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
996 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
998 (add-hook 'org-mode-hook 'my-org-mode-setup)
1000 (defun org-mode-reftex-search ()
1002 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
1004 (defun open-research-paper (bibtexkey)
1005 "Open a paper by bibtex key"
1006 (interactive "bibtex key: ")
1009 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1010 (org-add-link-type "papers" 'open-research-paper)
1011 (defun open-research-paper-pdf (bibtexkey)
1012 "Open a paper pdf by bibtex key"
1013 (interactive "bibtex key: ")
1015 (format "%s -p evince_annot %s"
1016 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1017 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
1019 (add-to-list 'org-link-abbrev-alist
1021 "~/projects/research/paper_notes.org::#%s"))
1023 ; I pretty much always want hiearchical checkboxes
1024 (setq org-hierachical-checkbox-statistics nil)
1026 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
1027 (add-to-list 'org-structure-template-alist
1028 '("E" "\\begin{equation}\n?\n\\end{equation}"))
1031 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
1032 (defun my-rtcite-export-handler (path desc format)
1033 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
1034 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
1035 (match-string 1 path)))
1036 (path (substring path 0 (match-beginning 0))))
1037 (cond ((eq format 'latex)
1039 (equal 0 (search "rtcite:" desc)))
1040 (format "\\cite{%s}" search)
1041 (format "\\cite[%s]{%s}" desc search))))))
1043 (org-add-link-type "rtcite"
1045 'my-rtcite-export-handler)
1049 ** Org Mobile Configuration
1050 #+BEGIN_SRC emacs-lisp
1051 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
1052 (when (string= system-name "linnode")
1053 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
1054 (setq-default org-directory "/home/don/org-mode/")
1055 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
1059 #+BEGIN_SRC emacs-lisp
1060 ;; org mode ical export
1061 (setq org-icalendar-timezone "America/Los_Angeles")
1062 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
1063 ;; we already add the id manually
1064 ;; (setq org-icalendar-store-UID t)
1067 ** General Org Babel Configuration
1068 #+BEGIN_SRC emacs-lisp
1069 ;; org babel support
1070 (org-babel-do-load-languages
1071 'org-babel-load-languages
1078 ;; use graphviz-dot for dot things
1079 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
1080 ;; org-babel-by-backend
1081 (defmacro org-babel-by-backend (&rest body)
1082 `(case (if (boundp 'backend)
1083 (org-export-backend-name backend)
1086 (defun my/fix-inline-images ()
1087 (when org-inline-image-overlays
1088 (org-redisplay-inline-images)))
1090 (add-hook 'org-babel-after-execute-hook
1091 'my/fix-inline-images)
1094 ** LaTeX configuration
1096 :ID: 7135ba17-6a50-4eed-84ca-b90afa5b12f8
1098 #+BEGIN_SRC emacs-lisp
1100 (add-to-list 'org-latex-classes
1102 "\\documentclass[11pt,oneside,article]{memoir}\n"
1103 ("\\section{%s}" . "\\section*{%s}")
1104 ("\\subsection{%s}" . "\\subsection*{%s}")
1105 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1106 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1107 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1109 (setq org-beamer-outline-frame-options "")
1110 (add-to-list 'org-latex-classes
1112 "\\documentclass[ignorenonframetext]{beamer}
1113 [NO-DEFAULT-PACKAGES]
1116 ("\\section{%s}" . "\\section*{%s}")
1117 ("\\subsection{%s}" . "\\subsection*{%s}")
1118 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1119 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1120 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1122 (add-to-list 'org-latex-classes
1124 "\\documentclass[11pt,oneside]{memoir}\n"
1125 ("\\chapter{%s}" . "\\chapter*{%s}")
1126 ("\\section{%s}" . "\\section*{%s}")
1127 ("\\subsection{%s}" . "\\subsection*{%s}")
1128 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
1130 (add-to-list 'org-latex-classes
1132 "\\documentclass[11pt]{letter}
1133 [NO-DEFAULT-PACKAGES]
1136 ("\\section{%s}" . "\\section*{%s}")
1137 ("\\subsection{%s}" . "\\subsection*{%s}")
1138 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1139 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1140 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1142 (add-to-list 'org-latex-classes
1144 "\\documentclass{dlacv}
1145 [NO-DEFAULT-PACKAGES]
1148 ("\\section{%s}" . "\\section*{%s}")
1149 ("\\subsection{%s}" . "\\subsection*{%s}")
1150 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1151 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1152 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1155 (add-to-list 'org-latex-classes
1157 "\\documentclass{dlaresume}
1158 [NO-DEFAULT-PACKAGES]
1161 ("\\section{%s}" . "\\section*{%s}")
1162 ("\\subsection{%s}" . "\\subsection*{%s}")
1163 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1164 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1165 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1168 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
1169 ;; but adapted to use latexmk 4.22 or higher.
1170 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
1172 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
1173 (setq org-latex-default-packages-alist
1175 ("" "unicode-math" t)
1177 (setq org-latex-packages-alist
1184 ("" "longtable" nil)
1187 ;; make equations larger
1188 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
1190 (defun org-create-formula--latex-header ()
1191 "Return LaTeX header appropriate for previewing a LaTeX snippet."
1192 (let ((info (org-combine-plists (org-export--get-global-options
1193 (org-export-get-backend 'latex))
1194 (org-export--get-inbuffer-options
1195 (org-export-get-backend 'latex)))))
1196 (org-latex-guess-babel-language
1197 (org-latex-guess-inputenc
1198 (org-splice-latex-header
1199 org-format-latex-header
1200 org-latex-default-packages-alist
1202 (plist-get info :latex-header)))
1206 ; support ignoring headers in org mode export to latex
1207 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
1208 (defadvice org-latex-headline (around my-latex-skip-headlines
1209 (headline contents info) activate)
1210 (if (member "ignoreheading" (org-element-property :tags headline))
1211 (setq ad-return-value contents)
1214 ;; keep latex logfiles
1216 (setq org-latex-remove-logfiles nil)
1218 ;; Resume clocking task when emacs is restarted
1219 (org-clock-persistence-insinuate)
1221 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
1222 (setq org-clock-history-length 23)
1223 ;; Resume clocking task on clock-in if the clock is open
1224 (setq org-clock-in-resume t)
1225 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
1226 ;; there are things like PHONE calls
1227 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
1228 ;; Separate drawers for clocking and logs
1229 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
1230 ;; Save clock data and state changes and notes in the LOGBOOK drawer
1231 (setq org-clock-into-drawer t)
1232 (setq org-log-into-drawer t)
1233 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
1234 (setq org-clock-out-remove-zero-time-clocks t)
1235 ;; Clock out when moving task to a done state
1236 (setq org-clock-out-when-done t)
1237 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
1238 (setq org-clock-persist t)
1239 ;; Do not prompt to resume an active clock
1240 (setq org-clock-persist-query-resume nil)
1241 ;; Enable auto clock resolution for finding open clocks
1242 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
1243 ;; Include current clocking task in clock reports
1244 (setq org-clock-report-include-clocking-task t)
1246 ;; the cache seems to be broken
1247 (setq org-element-use-cache nil)
1249 (defvar bh/keep-clock-running nil)
1251 (defun bh/is-task-p ()
1252 "Any task with a todo keyword and no subtask"
1256 (subtree-end (save-excursion (org-end-of-subtree t)))
1257 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1260 (while (and (not has-subtask)
1261 (< (point) subtree-end)
1262 (re-search-forward "^\*+ " subtree-end t))
1263 (when (member (org-get-todo-state) org-todo-keywords-1)
1264 (setq has-subtask t))))
1265 (and is-a-task (not has-subtask)))))
1267 (defun bh/is-subproject-p ()
1268 "Any task which is a subtask of another project"
1269 (let ((is-subproject)
1270 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1272 (while (and (not is-subproject) (org-up-heading-safe))
1273 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1274 (setq is-subproject t))))
1275 (and is-a-task is-subproject)))
1278 (defun bh/clock-in-to-next (kw)
1279 "Switch a task from TODO to NEXT when clocking in.
1280 Skips capture tasks, projects, and subprojects.
1281 Switch projects and subprojects from NEXT back to TODO"
1282 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
1284 ((and (member (org-get-todo-state) (list "TODO"))
1287 ((and (member (org-get-todo-state) (list "NEXT"))
1291 (defun bh/punch-in (arg)
1292 "Start continuous clocking and set the default task to the
1293 selected task. If no task is selected set the Organization task
1294 as the default task."
1296 (setq bh/keep-clock-running t)
1297 (if (equal major-mode 'org-agenda-mode)
1299 ;; We're in the agenda
1301 (let* ((marker (org-get-at-bol 'org-hd-marker))
1302 (tags (org-with-point-at marker (org-get-tags-at))))
1303 (if (and (eq arg 4) tags)
1304 (org-agenda-clock-in '(16))
1305 (bh/clock-in-organization-task-as-default)))
1307 ;; We are not in the agenda
1311 ; Find the tags on the current task
1312 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
1313 (org-clock-in '(16))
1314 (bh/clock-in-organization-task-as-default)))))
1316 (defun bh/punch-out ()
1318 (setq bh/keep-clock-running nil)
1319 (when (org-clock-is-active)
1321 (org-agenda-remove-restriction-lock))
1323 (defun bh/clock-in-default-task ()
1325 (org-with-point-at org-clock-default-task
1328 (defun bh/clock-in-parent-task ()
1329 "Move point to the parent (project) task if any and clock in"
1330 (let ((parent-task))
1334 (while (and (not parent-task) (org-up-heading-safe))
1335 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1336 (setq parent-task (point))))
1338 (org-with-point-at parent-task
1340 (when bh/keep-clock-running
1341 (bh/clock-in-default-task)))))))
1343 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
1345 (defun bh/clock-in-organization-task-as-default ()
1347 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
1348 (org-clock-in '(16))))
1350 (defun bh/clock-out-maybe ()
1351 (when (and bh/keep-clock-running
1352 (not org-clock-clocking-in)
1353 (marker-buffer org-clock-default-task)
1354 (not org-clock-resolving-clocks-due-to-idleness))
1355 (bh/clock-in-parent-task)))
1357 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1360 (defun bh/clock-in-task-by-id (id)
1361 "Clock in a task by id"
1362 (org-with-point-at (org-id-find id 'marker)
1363 (org-clock-in nil)))
1365 (defun bh/clock-in-last-task (arg)
1366 "Clock in the interrupted task if there is one
1367 Skip the default task and get the next one.
1368 A prefix arg forces clock in of the default task."
1370 (let ((clock-in-to-task
1372 ((eq arg 4) org-clock-default-task)
1373 ((and (org-clock-is-active)
1374 (equal org-clock-default-task (cadr org-clock-history)))
1375 (caddr org-clock-history))
1376 ((org-clock-is-active) (cadr org-clock-history))
1377 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
1378 (t (car org-clock-history)))))
1380 (org-with-point-at clock-in-to-task
1381 (org-clock-in nil))))
1384 (defun org-export-to-ods ()
1386 (let ((csv-file "data.csv"))
1387 (org-table-export csv-file "orgtbl-to-csv")
1388 (org-odt-convert csv-file "ods" 'open)))
1390 ; allow for zero-width-space to be a break in regexp too
1391 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
1392 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
1393 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
1395 ;; support inserting screen shots
1396 (defun my/org-insert-screenshot ()
1397 "Take a screenshot into a time stamped unique-named file in the
1398 same directory as the org-buffer and insert a link to this file."
1400 (defvar my/org-insert-screenshot/filename)
1401 (setq my/org-insert-screenshot/filename
1403 "Screenshot to insert: "
1405 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
1408 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
1409 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
1410 (org-display-inline-images))
1412 (defun my/fix-inline-images ()
1413 (when org-inline-image-overlays
1414 (org-redisplay-inline-images)))
1416 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
1418 ;; use xelatex to preview with imagemagick
1419 (add-to-list 'org-preview-latex-process-alist
1420 '(xelateximagemagick
1421 :programs ("xelatex" "convert")
1422 :description "pdf > png"
1423 :message "you need to install xelatex and imagemagick"
1425 :image-input-type "pdf"
1426 :image-output-type "png"
1427 :image-size-adjust (1.0 . 1.0)
1428 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
1429 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
1431 ;; use xelatex by default
1432 (setq org-preview-latex-default-process 'xelateximagemagick)
1434 ; from http://orgmode.org/Changes.html
1435 (defun my/org-repair-property-drawers ()
1436 "Fix properties drawers in current buffer.
1437 Ignore non Org buffers."
1439 (when (eq major-mode 'org-mode)
1440 (org-with-wide-buffer
1441 (goto-char (point-min))
1442 (let ((case-fold-search t)
1443 (inline-re (and (featurep 'org-inlinetask)
1444 (concat (org-inlinetask-outline-regexp)
1448 (unless (and inline-re (org-looking-at-p inline-re))
1450 (let ((end (save-excursion (outline-next-heading) (point))))
1452 (when (org-looking-at-p org-planning-line-re) (forward-line))
1453 (when (and (< (point) end)
1454 (not (org-looking-at-p org-property-drawer-re))
1456 (and (re-search-forward org-property-drawer-re end t)
1457 (eq (org-element-type
1458 (save-match-data (org-element-at-point)))
1460 (insert (delete-and-extract-region
1462 (min (1+ (match-end 0)) end)))
1463 (unless (bolp) (insert "\n"))))))))))))
1467 #+BEGIN_SRC emacs-lisp
1471 ** Override other things
1472 #+BEGIN_SRC emacs-lisp
1473 ; apparently things like to step on C-;, so we'll use a hack from
1474 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
1476 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
1478 ; use iedit everywhere
1479 (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
1480 ;; use outline mode keybindings everywhere
1481 ;; (define-key my-keys-minor-mode-map (kbd "C-;") 'my/mydra-outline/body)
1483 (define-minor-mode my-keys-minor-mode
1484 "A minor mode so that my key settings override annoying major modes."
1485 t " my-keys" 'my-keys-minor-mode-map)
1487 (my-keys-minor-mode 1)
1488 (defun my-minibuffer-setup-hook ()
1489 (my-keys-minor-mode 0))
1491 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
1492 (defadvice load (after give-my-keybindings-priority)
1493 "Try to ensure that my keybindings always have priority."
1494 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
1495 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
1496 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
1497 (add-to-list 'minor-mode-map-alist mykeys))))
1501 * Misc (uncharacterized)
1502 #+BEGIN_SRC emacs-lisp
1503 (setq bibtex-user-optional-fields (quote (("annote" "Personal annotation (ignored)") ("abstract" "") ("pmid" "") ("doi" ""))))
1504 (setq calendar-latitude 40.11)
1505 (setq calendar-longitude -88.24)
1506 (setq case-fold-search t)
1507 (setq confirm-kill-emacs (quote y-or-n-p))
1508 (setq cperl-lazy-help-time nil)
1509 (setq debian-changelog-mailing-address "don@debian.org")
1511 (setq display-time-24hr-format t)
1512 (setq display-time-day-and-date t)
1513 (display-time-mode 1)
1514 (setq font-latex-fontify-script nil)
1515 (setq font-latex-fontify-sectioning (quote color))
1516 (setq font-latex-script-display (quote (nil)))
1517 (global-auto-revert-mode 1)
1518 (global-font-lock-mode 1)
1520 (setq log-edit-keep-buffer t)
1521 (setq mail-user-agent (quote sendmail-user-agent))
1522 (setq markdown-enable-math t)
1523 (setq markdown-follow-wiki-link-on-enter nil)
1524 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
1525 (setq post-email-address "don@donarmstrong.com")
1526 (setq post-kill-quoted-sig nil)
1527 (setq post-mail-message "mutt\\(ng\\|\\)-[a-z0-9]+-[0-9]+-.*")
1528 (setq post-uses-fill-mode nil)
1529 (setq ps-footer-font-size (quote (8 . 10)))
1530 (setq ps-header-font-size (quote (8 . 10)))
1531 (setq ps-header-title-font-size (quote (10 . 10)))
1532 (setq ps-line-number-color "blue")
1533 (setq ps-print-footer t)
1534 (setq ps-print-footer-frame nil)
1535 (setq ps-print-only-one-header t)
1536 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
1538 (setq sentence-end-double-space nil)
1539 ; enable matching parenthesis
1542 (setq user-mail-address "don@donarmstrong.com")
1543 (setq vc-delete-logbuf-window nil)
1544 (setq vc-follow-symlinks t)
1546 ;; use git before SVN; use CVS earlier, because I have CVS
1547 ;; repositories inside of git directories
1548 (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
1550 ;; switch back to the old primary selection method
1551 (setq x-select-enable-clipboard nil)
1552 (setq x-select-enable-primary t)
1553 ; (setq mouse-drag-copy-region t)
1555 (fset 'perl-mode 'cperl-mode)
1556 ;;(load-file "cperl-mode.el")
1562 ;;(require 'ecasound)
1563 ;;(require 'emacs-wiki)
1567 ; (require 'google-weather)
1568 ; (require 'org-google-weather)
1569 ; (setq-default org-google-weather-format "%i %c, [%l,%h] %s %C")
1571 (global-set-key "\C-xp" 'server-edit)
1573 (setq-default auto-mode-alist (cons '("\.wml$" .
1574 (lambda () (html-mode) (auto-fill-mode)))
1578 ; use markdown mode for mdwn files
1579 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
1580 (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
1583 ;; tramp configuration
1584 (setq tramp-use-ssh-controlmaster-options nil)
1586 ; mail configuration
1587 (add-to-list 'auto-mode-alist '("muttng-[a-z0-9]+-[0-9]+-" . message-mode))
1588 (add-to-list 'auto-mode-alist '("muttngrc" . muttrc-mode))
1590 (add-to-list 'auto-mode-alist '("mutt-[a-z0-9]+-[0-9]+-" . message-mode))
1591 (add-to-list 'auto-mode-alist '("muttrc" . muttrc-mode))
1592 (defun my-message-mode-settings ()
1593 (font-lock-add-keywords nil
1594 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1595 (0 'message-multiply-quoted-text-face))
1596 ("^[ \t]*>[ \t]*>.*$"
1597 (0 'message-double-quoted-text-face))))
1598 (local-set-key (kbd "C-c C-a") 'my-post-attach-file)
1600 (add-hook 'message-mode-hook 'my-message-mode-settings)
1602 (defun my-post-attach-file ()
1603 "Prompt for an attachment."
1605 (let ((file (read-file-name "Attach file: " nil nil t nil))
1606 (description (string-read "Description: ")))
1607 (my-header-attach-file file description)))
1609 (symbol-function 'my-post-attach-file)
1611 (defun my-header-attach-file (file description)
1612 "Attach a FILE to the current message (works with Mutt).
1613 Argument DESCRIPTION MIME description."
1614 (interactive "fAttach file: \nsDescription: ")
1615 (when (> (length file) 0)
1620 (goto-char (point-min))
1621 (search-forward-regexp "^$")
1622 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1624 (message (concat "Attached '" file "'."))
1625 (setq post-has-attachment t))))))
1629 (setq mail-yank-prefix "> ")
1631 (global-unset-key "\M-g")
1632 (global-set-key "\M-g" 'goto-line)
1634 ;; self-insert-command hack.
1635 ;; Without this, "if<SP>" expands to
1638 ;; which really should be,
1644 ;(load-library "php-mode")
1646 (setq-default c-indent-level 4)
1647 (setq-default c-brace-imaginary-offset 0)
1648 (setq-default c-brace-offset -4)
1649 (setq-default c-argdecl-indent 4)
1650 (setq-default c-label-offset -4)
1651 (setq-default c-continued-statement-offset 4)
1653 (setq-default indent-tabs-mode nil)
1654 (setq-default tab-width 4)
1657 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
1658 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
1659 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
1660 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
1661 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
1664 (defun insert-date ()
1665 "Insert date at point."
1667 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
1668 (global-set-key "\C-[d" 'insert-date)
1670 (defun unfill-paragraph (arg)
1671 "Pull this whole paragraph up onto one line."
1673 (let ((fill-column 10000))
1674 (fill-paragraph arg))
1677 (column-number-mode t)
1681 ; (require 'mode-compile)
1683 (defadvice server-process-filter (after post-mode-message first activate)
1684 "If the buffer is in post mode, overwrite the server-edit
1685 message with a post-save-current-buffer-and-exit message."
1686 (if (eq major-mode 'post-mode)
1688 (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done."))))
1689 ; This is also needed to see the magic message. Set to a higher
1690 ; number if you have a faster computer or read slower than me.
1691 '(font-lock-verbose 1000)
1692 ;(setq-default server-temp-file-regexp "mutt\(-\|ng-\)")
1693 ; (add-hook 'server-switch-hook
1694 ; (function (lambda()
1695 ; (cond ((string-match "Post" mode-name)
1696 ; (post-goto-body)))
1697 ; set-buffer-file-coding-system 'utf-8
1701 (add-hook 'post-mode-hook
1702 (auto-fill-mode nil)
1704 ; abbrev mode settings
1705 ; load abbreviations from
1706 (setq abbrev-file-name
1707 "~/.emacs_abbrev_def")
1709 ; read the abbrev file if it exists
1710 (if (file-exists-p abbrev-file-name)
1711 (quietly-read-abbrev-file))
1713 ; for now, use abbrev mode everywhere
1714 (setq default-abbrev-mode t)
1717 (defun insert-function-documentation ()
1718 "Insert function documentation"
1720 (insert-file-contents "/home/don/lib/templates/perl_function_documentation" nil))
1721 (global-set-key "\M-f" 'insert-function-documentation)
1723 (eval-after-load "lilypond-mode"
1725 (load-library "lyqi-mode")
1726 (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
1728 (autoload 'spamassassin-mode "spamassassin-mode" nil t)
1730 (desktop-load-default)
1732 '(icomplete-mode on)
1734 ;; custom-set-faces was added by Custom.
1735 ;; If you edit it by hand, you could mess it up, so be careful.
1736 ;; Your init file should contain only one such instance.
1737 ;; If there is more than one, they won't work right.
1738 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
1741 (put 'upcase-region 'disabled nil)
1742 (put 'downcase-region 'disabled nil)
1743 (put 'narrow-to-region 'disabled nil)
1745 ; (defun turn-on-flyspell ()
1746 ; "Force flyspell-mode on using a positive arg. For use in hooks."
1748 ; (flyspell-mode 1))
1751 ; Outline-minor-mode key map
1752 (define-prefix-command 'cm-map nil "Outline-")
1754 (define-key cm-map "q" 'hide-sublevels) ; Hide everything but the top-level headings
1755 (define-key cm-map "t" 'hide-body) ; Hide everything but headings (all body lines)
1756 (define-key cm-map "o" 'hide-other) ; Hide other branches
1757 (define-key cm-map "c" 'hide-entry) ; Hide this entry's body
1758 (define-key cm-map "l" 'hide-leaves) ; Hide body lines in this entry and sub-entries
1759 (define-key cm-map "d" 'hide-subtree) ; Hide everything in this entry and sub-entries
1761 (define-key cm-map "a" 'show-all) ; Show (expand) everything
1762 (define-key cm-map "e" 'show-entry) ; Show this heading's body
1763 (define-key cm-map "i" 'show-children) ; Show this heading's immediate child sub-headings
1764 (define-key cm-map "k" 'show-branches) ; Show all sub-headings under this heading
1765 (define-key cm-map "s" 'show-subtree) ; Show (expand) everything in this heading & below
1767 (define-key cm-map "u" 'outline-up-heading) ; Up
1768 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
1769 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
1770 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
1771 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
1772 (global-set-key "\M-o" cm-map)
1776 (setq-default debian-changelog-mailing-address "don@debian.org")
1777 (setq-default debian-changelog-full-name "Don Armstrong")
1779 ; ediff configuration
1780 ; don't use the multi-window configuration
1781 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
1785 (define-key global-map (kbd "C-;") 'iedit-mode)
1786 (global-set-key (kbd "C-;") 'iedit-mode)
1788 ; fix up css mode to not be silly
1789 ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
1790 (setq cssm-indent-level 4)
1791 (setq cssm-newline-before-closing-bracket t)
1792 (setq cssm-indent-function #'cssm-c-style-indenter)
1793 (setq cssm-mirror-mode nil)
1795 (require 'multi-web-mode)
1796 (setq mweb-default-major-mode 'html-mode)
1797 (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
1798 (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
1799 (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
1800 (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
1801 (multi-web-global-mode 1)
1803 ;;; alias the new `flymake-report-status-slim' to
1804 ;;; `flymake-report-status'
1805 (defalias 'flymake-report-status 'flymake-report-status-slim)
1806 (defun flymake-report-status-slim (e-w &optional status)
1807 "Show \"slim\" flymake status in mode line."
1809 (setq flymake-mode-line-e-w e-w))
1811 (setq flymake-mode-line-status status))
1812 (let* ((mode-line " Φ"))
1813 (when (> (length flymake-mode-line-e-w) 0)
1814 (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
1815 (setq mode-line (concat mode-line flymake-mode-line-status))
1816 (setq flymake-mode-line mode-line)
1817 (force-mode-line-update)))
1819 ; load sql-indent when sql is loaded
1820 (eval-after-load "sql"
1821 '(load-library "sql-indent"))
1823 ; fix up tmux xterm keys
1824 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
1825 (defun fix-up-tmux-keys ()
1826 "Fix up tmux xterm keys"
1829 (let ((x 2) (tkey ""))
1849 ;; ctrl + alt + shift
1851 (setq tkey "C-M-S-"))
1854 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
1855 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
1856 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
1857 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
1859 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
1861 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
1863 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
1865 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
1867 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
1869 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
1871 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
1873 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
1875 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
1877 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
1879 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
1881 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
1883 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
1885 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
1887 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
1889 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
1891 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
1893 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
1895 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
1897 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
1899 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
1901 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
1903 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
1905 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
1907 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
1909 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
1916 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
1918 ; procmailmode configuration
1919 (load "procmail_mode")
1921 (load "mode-line-cleaner")
1923 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
1924 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
1925 (if (or (buffer-modified-p)
1926 (verify-visited-file-modtime)
1927 (< (* 8 1024 1024) (buffer-size))
1928 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
1930 (clear-visited-file-modtime)
1932 (ad-activate 'ask-user-about-supersession-threat)
1934 ; apparently things like to step on C-;, so we'll use a hack from
1935 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
1937 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
1939 ; use iedit everywhere
1940 (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
1942 (define-minor-mode my-keys-minor-mode
1943 "A minor mode so that my key settings override annoying major modes."
1944 t " my-keys" 'my-keys-minor-mode-map)
1946 (my-keys-minor-mode 1)
1947 (defun my-minibuffer-setup-hook ()
1948 (my-keys-minor-mode 0))
1950 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
1951 (defadvice load (after give-my-keybindings-priority)
1952 "Try to ensure that my keybindings always have priority."
1953 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
1954 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
1955 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
1956 (add-to-list 'minor-mode-map-alist mykeys))))
1958 (global-set-key "\M- " 'hippie-expand)
1963 #+BEGIN_SRC emacs-lisp
1964 (provide 'don-configuration)