1 #+PROPERTY: header-args:emacs-lisp :tangle don-configuration.el
4 # if for some reason, things get pear-shaped, we want to be able to
5 # enter the debugger by sending -USR2 to emacs
8 (setq debug-on-event 'siguser2)
12 #+BEGIN_SRC emacs-lisp
13 (add-to-list 'load-path '"~/lib/emacs_el/")
14 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/tiny")
15 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/other")
16 (add-to-list 'load-path '"~/lib/emacs_el/magit-annex")
20 ** package repositories and package manager
21 #+BEGIN_SRC emacs-lisp
23 (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
24 ("melpa" . "https://melpa.org/packages/")
25 ("org" . "http://orgmode.org/elpa/") ))
27 ** [[https://github.com/jwiegley/use-package/][use-package]]
28 #+BEGIN_SRC emacs-lisp
30 (require 'use-package)
33 #+BEGIN_SRC emacs-lisp
39 #+BEGIN_SRC emacs-lisp
40 ;; Set the custom file to /dev/null and don't bother to load it
41 (setq custom-file "/dev/null")
45 #+BEGIN_SRC emacs-lisp
46 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
47 ;; execute conditional code when loading libraries
48 (defmacro with-library (symbol &rest body)
49 `(when (require ,symbol nil t)
51 (put 'with-library 'lisp-indent-function 1)
55 ** Safe Local Variables
56 #+BEGIN_SRC emacs-lisp
57 (setq safe-local-variable-values
58 (quote ((auto-save-default)
60 (cperl-indent-level . 4)
62 (indent-tabs-mode . f)
66 #+BEGIN_SRC emacs-lisp
67 (setq global-mark-ring-max 128
71 (defun don/minibuffer-setup-hook ()
72 (setq gc-cons-threshold most-positive-fixnum))
74 (defun don/minibuffer-exit-hook ()
75 (setq gc-cons-threshold 1048576))
77 (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
78 (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
82 #+BEGIN_SRC emacs-lisp
85 :diminish flyspell-mode 🐝
87 (add-hook 'message-mode-hook 'turn-on-flyspell)
88 (add-hook 'text-mode-hook 'turn-on-flyspell)
89 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
90 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
91 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
93 (setq ispell-program-name "ispell")
98 #+BEGIN_SRC emacs-lisp
103 #+BEGIN_SRC emacs-lisp
104 ;; (use-package eyebrowse
106 ;; :diminish eyebrowse-mode
107 ;; :init (setq eyebrowse-keymap-prefix (kbd "C-c C-\\"))
109 ;; (setq eyebrowse-wrap-around t)
110 ;; (eyebrowse-mode t)
112 ;; (defun my/eyebrowse-new-window-config ()
116 ;; ;; start at 1 run till 0
117 ;; (let ((j (mod (+ i 1) 10)))
118 ;; (when (and (not done)
119 ;; (not (eyebrowse--window-config-present-p j)))
120 ;; (eyebrowse-switch-to-window-config j)
121 ;; (call-interactively 'eyebrowse-rename-window-config2 j)
126 ;; ;; I don't use latex-preview-pane
127 ;; ;; (require 'latex-preview-pane)
128 ;; ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
129 ;; ;; ;; latex-preview-pane uses window-parameters which are
130 ;; ;; ;; not preserved by eyebrowse, so we close the preview
131 ;; ;; ;; pane before switching, it will be regenerated when we
132 ;; ;; ;; edit the TeX file.
133 ;; ;; (when (lpp/window-containing-preview)
134 ;; ;; (delete-window (lpp/window-containing-preview))))
136 ;; ;; (add-to-list 'eyebrowse-pre-window-switch-hook
137 ;; ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
139 ;; ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
140 ;; ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
141 ;; ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
142 ;; ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
143 ;; ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
151 #+BEGIN_SRC emacs-lisp
152 (defun my/vsplit-last-buffer ()
153 "Split the window vertically and display the previous buffer."
155 (split-window-vertically)
157 (switch-to-next-buffer))
159 (defun my/hsplit-last-buffer ()
160 "Split the window horizontally and display the previous buffer."
162 (split-window-horizontally)
164 (switch-to-next-buffer))
166 (bind-key "C-x 2" 'my/vsplit-last-buffer)
167 (bind-key "C-x 3" 'my/hsplit-last-buffer)
169 (setq split-width-threshold 100)
170 (setq split-height-threshold 60)
172 (defun my/split-window-prefer-vertically (window)
173 "If there's only one window (excluding any possibly active
174 minibuffer), then split the current window horizontally."
175 (if (and (one-window-p t)
176 (not (active-minibuffer-window))
177 ( < (frame-width) (frame-height))
179 (let ((split-width-threshold nil))
180 (split-window-sensibly window))
181 (split-window-sensibly window)))
183 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
184 (setq window-combination-resize t)
187 *** Compilation window
189 If there is no compilation window, open one at the bottom, spanning
190 the complete width of the frame. Otherwise, reuse existing window. In
191 the former case, if there was no error the window closes
194 #+BEGIN_SRC emacs-lisp
195 (add-to-list 'display-buffer-alist
196 `(,(rx bos "*compilation*" eos)
197 (display-buffer-reuse-window
198 display-buffer-in-side-window)
199 (reusable-frames . visible)
201 (window-height . 0.4)))
204 #+BEGIN_SRC emacs-lisp
205 (defun my/compilation-exit-autoclose (status code msg)
206 ;; If M-x compile exists with a 0
207 (when (and (eq status 'exit) (zerop code))
208 ;; and delete the *compilation* window
209 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
210 (when (and (not (window-at-side-p compilation-window 'top))
211 (window-at-side-p compilation-window 'left)
212 (window-at-side-p compilation-window 'right))
213 (delete-window compilation-window))))
214 ;; Always return the anticipated result of compilation-exit-message-function
217 ;; Specify my function (maybe I should have done a lambda function)
218 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
221 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
222 value, the compilation buffer scrolls automatically to follow the
223 output. If the value is ~first-error~, scrolling stops when the first
224 error appears, leaving point at that error. For any other non-nil
225 value, scrolling continues until there is no more output.
227 #+BEGIN_SRC emacs-lisp
228 (setq compilation-scroll-output 'first-error)
231 ** Mode line cleaning
233 #+BEGIN_SRC emacs-lisp
234 (use-package diminish
239 #+BEGIN_SRC emacs-lisp
246 #+BEGIN_SRC emacs-lisp
249 :bind (("C-c C-<SPC>" . avy-goto-word-or-subword-1)
250 ("C-c j j" . avy-goto-word-or-subword-1)
251 ("M-g g" . avy-goto-line))
252 :config (progn (setq avy-background t))
255 *** Ace-link (jumping to links)
256 #+BEGIN_SRC emacs-lisp
257 (use-package ace-link
259 ; bind o in most modes
260 :config (ace-link-setup-default))
262 *** Jumping through edit points (goto-chg)
263 #+BEGIN_SRC emacs-lisp
264 (use-package goto-chg
266 :bind (("C-c j ," . goto-last-change)
267 ("C-c j ." . goto-last-change-reverse))
269 *** Jumping to bookmarks (visible bookmarks, bm)
270 #+BEGIN_SRC emacs-lisp
273 :bind (("C-c j b ." . bm-next)
274 ("C-c j b ," . bm-previous)
275 ("C-c j b SPC" . bm-toggle)))
280 #+BEGIN_SRC emacs-lisp
281 (use-package yasnippet
283 :diminish yas-minor-mode
286 (setq yas-verbosity 1)
287 (define-key yas-minor-mode-map (kbd "<tab>") nil)
288 (define-key yas-minor-mode-map (kbd "TAB") nil)
289 (define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)
290 (setq yas-snippet-dirs '("~/lib/emacs_el/snippets/"
291 "~/lib/emacs_el/yasnippet-snippets/snippets/"))
292 (add-to-list 'hippie-expand-try-functions-list
293 'yas-hippie-try-expand)
298 #+BEGIN_SRC emacs-lisp
299 (use-package auto-yasnippet
300 :bind (("H-w" . aya-create)
307 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
309 #+BEGIN_SRC emacs-lisp
310 (use-package helm-flx
313 ;; these are helm configs, but they kind of fit here nicely
314 (setq helm-M-x-fuzzy-match t
315 helm-bookmark-show-location t
316 helm-buffers-fuzzy-matching t
317 helm-completion-in-region-fuzzy-match t
318 helm-file-cache-fuzzy-match t
319 helm-imenu-fuzzy-match t
320 helm-mode-fuzzy-match t
321 helm-locate-fuzzy-match nil
323 helm-recentf-fuzzy-match nil
324 helm-semantic-fuzzy-match t)
331 #+BEGIN_SRC emacs-lisp
333 (use-package tinyprocmail
335 :config (with-library 'tinyprocmail
336 ;; (setq tinyprocmail--procmail-version "v3.22")
337 (add-hook 'tinyprocmail--load-hook 'tinyprocmail-install))
342 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
345 :bind (("C-x g" . magit-status)
346 ("C-x C-g" . magit-status))
348 ;; don't verify where we are pushing
349 (setq magit-push-always-verify nil)
350 ;; refine diffs always (hilight words)
351 (setq magit-diff-refine-hunk nil)
354 (append '("~/lib/emacs_el/magit-annex")
358 (append '("~/lib/emacs_el/magit-vcsh")
361 (use-package magit-annex
364 (use-package magit-vcsh
365 :ensure f ; currently not in melpa, so don't try to install
370 #+BEGIN_SRC emacs-lisp
371 (require 'cperl-mode)
372 ;; Use c-mode for perl .xs files
373 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
374 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
375 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
376 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
377 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
380 cperl-auto-newline nil
381 cperl-auto-newline-after-colon nil
382 cperl-continued-statement-offset 4
383 cperl-brace-offset -1
384 cperl-continued-brace-offset 0
385 cperl-label-offset -4
386 cperl-highlight-variables-indiscriminately t
387 cperl-electric-lbrace-space nil
388 cperl-indent-parens-as-block nil
389 cperl-close-paren-offset -1
390 cperl-tab-always-indent t)
391 ;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
395 #+BEGIN_SRC emacs-lisp
400 (define-key global-map [remap find-file] 'helm-find-files)
401 (define-key global-map [remap occur] 'helm-occur)
402 (define-key global-map [remap list-buffers] 'helm-buffers-list)
403 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
404 (global-set-key (kbd "M-x") 'helm-M-x)
405 (unless (boundp 'completion-in-region-function)
406 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
407 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
408 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
412 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
417 #+BEGIN_SRC emacs-lisp
418 (add-to-list 'tramp-methods '("vcsh"
419 (tramp-login-program "vcsh")
423 (tramp-remote-shell "/bin/sh")
424 (tramp-remote-shell-args
428 #+BEGIN_SRC emacs-lisp
432 (setq-default reftex-default-bibliography
433 '("~/projects/research/references.bib")))
436 #+BEGIN_SRC emacs-lisp
441 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
442 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
443 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
444 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
445 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
446 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
447 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
448 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
449 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
450 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
451 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
453 (setq-default reftex-plug-into-AUCTeX t)
454 ;; support fake section headers
455 (setq TeX-outline-extra
461 ;; add font locking to the headers
462 (font-lock-add-keywords
464 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
465 0 'font-lock-keyword-face t)
466 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
467 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
468 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
469 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
470 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
472 ;; use smart quotes by default instead of `` and ''
473 ;; taken from http://kieranhealy.org/esk/kjhealy.html
474 (setq TeX-open-quote "“")
475 (setq TeX-close-quote "”")
477 ;; (TeX-add-style-hook
482 ;; (custom-set-variables
483 ;; '(font-latex-user-keyword-classes
486 ;; font-lock-function-name-face 2 (command 1 t))))
488 (setq-default TeX-parse-self t)
489 (setq-default TeX-auto-save t)
490 (setq-default TeX-master nil)
496 (if (boundp 'reftex-ref-style-alist)
498 'reftex-ref-style-alist
499 '("Cleveref" "cleveref"
500 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
501 (reftex-ref-style-activate "Cleveref")
503 '("cref" TeX-arg-ref)
504 '("Cref" TeX-arg-ref)
505 '("cpageref" TeX-arg-ref)
506 '("Cpageref" TeX-arg-ref)))))
509 '(add-to-list 'LaTeX-fill-excluded-macros
512 (use-package font-latex
514 (setq font-latex-match-reference-keywords
540 #+BEGIN_SRC emacs-lisp
544 (use-package calfw-org
547 (use-package org-gcal
549 :config '((if (file-readable-p "~/.hide/org_gcal.el")
550 (load-file "~/.hide/org_gcal.el"))
555 #+BEGIN_SRC emacs-lisp
559 (defun ess-change-directory (path)
560 "Set the current working directory to PATH for both *R* and Emacs."
561 (interactive "DDirectory to change to: ")
563 (when (file-exists-p path)
564 (ess-command (concat "setwd(\"" path "\")\n"))
565 ;; use file-name-as-directory to ensure it has trailing /
566 (setq default-directory (file-name-as-directory path))))
567 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
568 ;; outlining support for ess modes
573 (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
574 (defun outline-level ()
575 (cond ((looking-at "^##### ") 1)
576 ((looking-at "^#### ") 2)
577 ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
580 (add-hook 'ess-mode-hook
582 (local-set-key (kbd "C-c C-R")
583 'dla/ess-region-remote-eval)))
585 ;; Don't restore history or save workspace image
586 '(inferior-R-args "--no-restore-history --no-save")
591 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
593 #+BEGIN_SRC emacs-lisp
594 (use-package rainbow-mode
595 ;; add ess to the x major mode
596 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
597 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
602 #+BEGIN_SRC emacs-lisp
603 (use-package polymode
606 (use-package poly-noweb)
607 (use-package poly-markdown)
608 :mode ("\\.Snw" . poly-noweb+r-mode)
609 :mode ("\\.Rnw" . poly-noweb+r-mode)
610 :mode ("\\.Rmd" . poly-markdown+r-mode)
616 #+BEGIN_SRC emacs-lisp
617 (use-package outline-magic)
620 #+BEGIN_SRC emacs-lisp
621 (use-package writeroom-mode
623 (defun my/writing-mode ()
624 "Start my writing mode; enable visual-line-mode and auto-fill-mode"
629 (visual-line-mode -1)
631 (visual-fill-column-mode -1)
635 (visual-fill-column-mode 1)
640 ** GhostText/Atomic Chrome
641 #+BEGIN_SRC emacs-lisp
642 (use-package atomic-chrome
643 :config (atomic-chrome-start-server)
644 (setq atomic-chrome-buffer-open-style 'full)
649 :ID: 6fcf218b-a762-4c37-9339-a8202ddeb544
651 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
652 #+BEGIN_SRC emacs-lisp
653 (use-package multiple-cursors
654 :bind (("C-;" . mc/mark-all-dwim)
655 ("C-<" . mc/mark-previous-like-this)
656 ("C->" . mc/mark-next-like-this)
657 ("C-S-c C-S-c" . mc/edit-lines))
661 ** Use-package and load things
662 #+BEGIN_SRC emacs-lisp
668 ** Agenda Configuration
669 #+BEGIN_SRC emacs-lisp
670 ;; The following lines are always needed. Choose your own keys.
671 (add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode))
672 (global-set-key "\C-cl" 'org-store-link)
673 (global-set-key "\C-ca" 'org-agenda)
674 (global-set-key "\C-cb" 'org-iswitchb)
675 (setq-default org-log-done 'time)
676 (setq-default org-agenda-ndays 5)
678 ;; agenda configuration
679 ;; Do not dim blocked tasks
680 (setq org-agenda-dim-blocked-tasks nil)
681 (setq org-agenda-inhibit-startup t)
682 (setq org-agenda-use-tag-inheritance nil)
684 ;; Compact the block agenda view
685 (setq org-agenda-compact-blocks t)
687 ;; Custom agenda command definitions
688 (setq org-agenda-custom-commands
689 (quote (("N" "Notes" tags "NOTE"
690 ((org-agenda-overriding-header "Notes")
691 (org-tags-match-list-sublevels t)))
692 ("h" "Habits" tags-todo "STYLE=\"habit\""
693 ((org-agenda-overriding-header "Habits")
694 (org-agenda-sorting-strategy
695 '(todo-state-down effort-up category-keep))))
699 ((org-agenda-overriding-header "Tasks to Refile")
700 (org-tags-match-list-sublevels nil)))
701 (tags-todo "-CANCELLED/!"
702 ((org-agenda-overriding-header "Stuck Projects")
703 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
704 (org-agenda-sorting-strategy
706 (tags-todo "-HOLD-CANCELLED/!"
707 ((org-agenda-overriding-header "Projects")
708 (org-agenda-skip-function 'bh/skip-non-projects)
709 (org-tags-match-list-sublevels 'indented)
710 (org-agenda-sorting-strategy
712 (tags-todo "-CANCELLED/!NEXT"
713 ((org-agenda-overriding-header (concat "Project Next Tasks"
714 (if bh/hide-scheduled-and-waiting-next-tasks
716 " (including WAITING and SCHEDULED tasks)")))
717 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
718 (org-tags-match-list-sublevels t)
719 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
720 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
721 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
722 (org-agenda-sorting-strategy
723 '(todo-state-down effort-up category-keep))))
724 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
725 ((org-agenda-overriding-header (concat "Project Subtasks"
726 (if bh/hide-scheduled-and-waiting-next-tasks
728 " (including WAITING and SCHEDULED tasks)")))
729 (org-agenda-skip-function 'bh/skip-non-project-tasks)
730 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
731 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
732 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
733 (org-agenda-sorting-strategy
735 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
736 ((org-agenda-overriding-header (concat "Standalone Tasks"
737 (if bh/hide-scheduled-and-waiting-next-tasks
739 " (including WAITING and SCHEDULED tasks)")))
740 (org-agenda-skip-function 'bh/skip-project-tasks)
741 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
742 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
743 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
744 (org-agenda-sorting-strategy
746 (tags-todo "-CANCELLED+WAITING|HOLD/!"
747 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
748 (org-agenda-skip-function 'bh/skip-stuck-projects)
749 (org-tags-match-list-sublevels nil)
750 (org-agenda-todo-ignore-scheduled t)
751 (org-agenda-todo-ignore-deadlines t)))
753 ((org-agenda-overriding-header "Tasks to Archive")
754 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
755 (org-tags-match-list-sublevels nil))))
758 ; org mode agenda files
759 (setq org-agenda-files
760 (quote ("~/projects/org-notes/debbugs.org"
761 "~/projects/org-notes/notes.org"
762 "~/projects/org-notes/holidays.org"
763 "~/projects/org-notes/refile.org"
764 "~/projects/org-notes/diary.org"
765 "~/projects/org-notes/ool.org"
766 "~/projects/org-notes/sndservers.org"
767 "~/projects/org-notes/chaim.org"
768 "~/projects/org-notes/wildman.org"
769 "~/projects/org-notes/uddin.org"
770 "~/projects/org-notes/reviews.org"
771 "~/projects/org-notes/hpcbio.org"
772 "~/org-mode/from-mobile.org"
773 "~/projects/org-notes/fh.org")))
775 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
776 (set-register ?r (cons 'file "~/projects/org-notes/refile.org"))
777 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
778 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
779 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
780 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
781 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
782 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
783 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
784 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
785 (defun org-agenda-timeline-all (&optional arg)
788 (dolist (org-agenda-file org-agenda-files)
789 (insert-file-contents org-agenda-file nil)
792 (write-file "/tmp/timeline.org")
793 (org-agenda arg "L")))
794 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
795 ;; add automatic reminders for appointments
796 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
797 "Pressing `r' on the agenda will also add appointments."
799 (setq appt-time-msg-list nil)
800 (org-agenda-to-appt)))
804 #+BEGIN_SRC emacs-lisp
805 (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")))
806 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
808 (setq org-default-notes-file "~/projects/org-notes/notes.org")
809 (setq org-id-link-to-org-use-id t)
812 #+BEGIN_SRC emacs-lisp
813 (setq org-capture-templates ;; mail-specific note template, identified by "m"
814 '(("m" "Mail" entry (file "~/projects/org-notes/refile.org")
815 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
816 ("t" "todo" entry (file "~/projects/org-notes/refile.org")
817 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
818 ("r" "respond" entry (file "~/projects/org-notes/refile.org")
819 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
820 ("n" "note" entry (file "~/projects/org-notes/refile.org")
821 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
822 ("s" "schedule" entry (file "~/projects/org-notes/refile.org")
823 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
824 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
825 "* %?\n%U\n" :clock-in t :clock-resume t)
826 ("w" "org-protocol" entry (file "~/projects/org-notes/refile.org")
827 "* TODO Review %c\n%U\n" :immediate-finish t)
828 ("M" "Meeting" entry (file "~/projects/org-notes/refile.org")
829 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
830 ("S" "Seminar" entry (file "~/projects/org-notes/refile.org")
831 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
832 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
833 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
834 ("p" "Phone call" entry (file "~/projects/org-notes/refile.org")
835 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
836 ("J" "job" entry (file "~/projects/org-notes/refile.org")
837 "* 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)
838 ("h" "Habit" entry (file "~/projects/org-notes/refile.org")
839 "* 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")
843 ;; Remove empty LOGBOOK drawers on clock out
844 (defun bh/remove-empty-drawer-on-clock-out ()
847 (beginning-of-line 0)
848 (org-remove-empty-drawer-at (point))))
850 (defun my/org-add-id ()
853 (if (org-current-level)
862 ** Org mode key bindings
863 #+BEGIN_SRC emacs-lisp
864 ; org mode configuration from http://doc.norang.ca/org-mode.html
865 ;; Custom Key Bindings
866 (global-set-key (kbd "<f12>") 'org-agenda)
867 (global-set-key (kbd "<f5>") 'bh/org-todo)
868 (global-set-key (kbd "<S-f5>") 'bh/widen)
869 (global-set-key (kbd "<f7>") 'bh/set-truncate-lines)
870 (global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
871 (global-set-key (kbd "<f9> <f9>") 'bh/show-org-agenda)
872 (global-set-key (kbd "<f9> b") 'bbdb)
873 (global-set-key (kbd "<f9> c") 'calendar)
874 (global-set-key (kbd "<f9> f") 'boxquote-insert-file)
875 (global-set-key (kbd "<f9> h") 'bh/hide-other)
876 (global-set-key (kbd "<f9> n") 'bh/toggle-next-task-display)
877 (global-set-key (kbd "<f9> w") 'widen)
879 ; change the outline mode prefix from C-c @ to C-c C-2
880 (setq outline-minor-mode-prefix "C-c C-2")
881 ;(add-hook 'outline-minor-mode-hook
882 ; (lambda () (local-set-key (kbd "C-c C-2")
883 ; outline-mode-prefix-map)))
885 (global-set-key (kbd "<f9> I") 'bh/punch-in)
886 (global-set-key (kbd "<f9> O") 'bh/punch-out)
888 (global-set-key (kbd "<f9> o") 'bh/make-org-scratch)
890 (global-set-key (kbd "<f9> r") 'boxquote-region)
891 (global-set-key (kbd "<f9> s") 'bh/switch-to-scratch)
893 (global-set-key (kbd "<f9> t") 'bh/insert-inactive-timestamp)
894 (global-set-key (kbd "<f9> T") 'bh/toggle-insert-inactive-timestamp)
896 (global-set-key (kbd "<f9> v") 'visible-mode)
897 (global-set-key (kbd "<f9> l") 'org-toggle-link-display)
898 (global-set-key (kbd "<f9> SPC") 'bh/clock-in-last-task)
899 (global-set-key (kbd "C-<f9>") 'previous-buffer)
900 (global-set-key (kbd "M-<f9>") 'org-toggle-inline-images)
901 (global-set-key (kbd "C-x n r") 'narrow-to-region)
902 (global-set-key (kbd "C-<f10>") 'next-buffer)
903 (global-set-key (kbd "<f11>") 'org-clock-goto)
904 (global-set-key (kbd "C-<f11>") 'org-clock-in)
905 (global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)
906 (global-set-key (kbd "C-c c") 'org-capture)
910 #+BEGIN_SRC emacs-lisp
911 (defun bh/hide-other ()
914 (org-back-to-heading 'invisible-ok)
920 (defun bh/set-truncate-lines ()
921 "Toggle value of truncate-lines and refresh window display."
923 (setq truncate-lines (not truncate-lines))
924 ;; now refresh window display (an idiom from simple.el):
926 (set-window-start (selected-window)
927 (window-start (selected-window)))))
929 (defun bh/make-org-scratch ()
931 (find-file "/tmp/publish/scratch.org")
932 (gnus-make-directory "/tmp/publish"))
934 (defun bh/switch-to-scratch ()
936 (switch-to-buffer "*scratch*"))
938 (setq org-use-fast-todo-selection t)
939 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
941 ; create function to create headlines in file. This comes from
942 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
943 (defun my/org-add-ids-to-headlines-in-file ()
944 "Add ID properties to all headlines in the current file which
945 do not already have one."
947 (org-map-entries 'org-id-get-create))
948 ; if we wanted to do this to every buffer, do the following:
949 ; (add-hook 'org-mode-hook
951 ; (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
954 #+BEGIN_SRC emacs-lisp
955 (setq org-todo-keywords
956 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
957 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
959 (setq org-todo-keyword-faces
960 (quote (("TODO" :foreground "red" :weight bold)
961 ("NEXT" :foreground "blue" :weight bold)
962 ("DONE" :foreground "forest green" :weight bold)
963 ("WAITING" :foreground "orange" :weight bold)
964 ("HOLD" :foreground "magenta" :weight bold)
965 ("CANCELLED" :foreground "forest green" :weight bold)
966 ("MEETING" :foreground "forest green" :weight bold)
967 ("PHONE" :foreground "forest green" :weight bold))))
969 (setq org-todo-state-tags-triggers
970 (quote (("CANCELLED" ("CANCELLED" . t))
971 ("WAITING" ("WAITING" . t))
972 ("HOLD" ("WAITING") ("HOLD" . t))
973 (done ("WAITING") ("HOLD"))
974 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
975 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
976 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
980 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
981 ; add ids on creation of nodes
982 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
985 ; resolve clocks after 10 minutes of idle; use xprintidle
986 ; (setq org-clock-idle-time 10)
987 ; (setq org-clock-x11idle-program-name "xprintidle")
989 ; this is from http://doc.norang.ca/org-mode.html#Capture
990 ; use C-M-r for org mode capture
991 (global-set-key (kbd "C-M-r") 'org-capture)
993 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
994 (setq org-refile-targets (quote ((nil :maxlevel . 9)
995 (org-agenda-files :maxlevel . 9))))
997 ; Use full outline paths for refile targets - we file directly with IDO
998 (setq org-refile-use-outline-path t)
1000 ; Targets complete directly with IDO
1001 (setq org-outline-path-complete-in-steps nil)
1003 ; Allow refile to create parent tasks with confirmation
1004 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1006 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
1007 ; (setq org-completion-use-ido t)
1008 ; (setq ido-everywhere t)
1009 ; (setq ido-max-directory-size 100000)
1010 ; (ido-mode (quote both))
1011 ; ; Use the current window when visiting files and buffers with ido
1012 ; (setq ido-default-file-method 'selected-window)
1013 ; (setq ido-default-buffer-method 'selected-window)
1014 ; ; Use the current window for indirect buffer display
1015 ; (setq org-indirect-buffer-display 'current-window)
1018 ;;;; Refile settings
1019 ; Exclude DONE state tasks from refile targets
1020 (defun bh/verify-refile-target ()
1021 "Exclude todo keywords with a done state from refile targets"
1022 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
1024 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1026 ;; ensure that emacsclient will show just the note to be edited when invoked
1027 ;; from Mutt, and that it will shut down emacsclient once finished;
1028 ;; fallback to legacy behavior when not invoked via org-protocol.
1029 (require 'org-protocol)
1030 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
1031 (setq my-org-protocol-flag nil)
1032 (defadvice org-capture-finalize (after delete-frame-at-end activate)
1033 "Delete frame at remember finalization"
1034 (progn (if my-org-protocol-flag (delete-frame))
1035 (setq my-org-protocol-flag nil)))
1036 (defadvice org-capture-refile (around delete-frame-after-refile activate)
1037 "Delete frame at remember refile"
1038 (if my-org-protocol-flag
1040 (setq my-org-protocol-flag nil)
1045 (defadvice org-capture-kill (after delete-frame-at-end activate)
1046 "Delete frame at remember abort"
1047 (progn (if my-org-protocol-flag (delete-frame))
1048 (setq my-org-protocol-flag nil)))
1049 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
1050 (setq my-org-protocol-flag t))
1052 (defadvice org-insert-todo-heading (after dla/create-id activate)
1057 (add-to-list 'org-modules 'org-habit)
1059 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
1060 (defun open-mail-in-mutt (message)
1061 "Open a mail message in Mutt, using an external terminal.
1063 Message can be specified either by a path pointing inside a
1064 Maildir, or by Message-ID."
1065 (interactive "MPath or Message-ID: ")
1067 (format "faf xterm -e \"%s %s\""
1068 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
1070 ;; add support for "mutt:ID" links
1071 (org-add-link-type "mutt" 'open-mail-in-mutt)
1073 (defun my-org-mode-setup ()
1074 (load-library "reftex")
1075 (and (buffer-file-name)
1076 (file-exists-p (buffer-file-name))
1079 (reftex-set-cite-format
1080 '((?b . "[[bib:%l][%l-bib]]")
1081 (?n . "[[notes:%l][%l-notes]]")
1083 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
1085 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
1086 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
1087 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
1088 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
1090 (add-hook 'org-mode-hook 'my-org-mode-setup)
1092 (defun org-mode-reftex-search ()
1094 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
1096 (defun open-research-paper (bibtexkey)
1097 "Open a paper by bibtex key"
1098 (interactive "bibtex key: ")
1101 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1102 (org-add-link-type "papers" 'open-research-paper)
1103 (defun open-research-paper-pdf (bibtexkey)
1104 "Open a paper pdf by bibtex key"
1105 (interactive "bibtex key: ")
1107 (format "%s -p evince_annot %s"
1108 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1109 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
1111 (add-to-list 'org-link-abbrev-alist
1113 "~/projects/research/paper_notes.org::#%s"))
1115 ; I pretty much always want hiearchical checkboxes
1116 (setq org-hierachical-checkbox-statistics nil)
1118 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
1119 (add-to-list 'org-structure-template-alist
1120 '("E" "\\begin{equation}\n?\n\\end{equation}"))
1123 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
1124 (defun my-rtcite-export-handler (path desc format)
1125 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
1126 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
1127 (match-string 1 path)))
1128 (path (substring path 0 (match-beginning 0))))
1129 (cond ((eq format 'latex)
1131 (equal 0 (search "rtcite:" desc)))
1132 (format "\\cite{%s}" search)
1133 (format "\\cite[%s]{%s}" desc search))))))
1135 (org-add-link-type "rtcite"
1137 'my-rtcite-export-handler)
1141 ** Org Mobile Configuration
1142 #+BEGIN_SRC emacs-lisp
1143 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
1144 (when (string= system-name "linnode")
1145 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
1146 (setq-default org-directory "/home/don/org-mode/")
1147 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
1151 #+BEGIN_SRC emacs-lisp
1152 ;; org mode ical export
1153 (setq org-icalendar-timezone "America/Los_Angeles")
1154 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
1155 ;; we already add the id manually
1156 ;; (setq org-icalendar-store-UID t)
1159 ** General Org Babel Configuration
1160 #+BEGIN_SRC emacs-lisp
1161 ;; org babel support
1162 (org-babel-do-load-languages
1163 'org-babel-load-languages
1170 ;; use graphviz-dot for dot things
1171 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
1172 ;; org-babel-by-backend
1173 (defmacro org-babel-by-backend (&rest body)
1174 `(case (if (boundp 'backend)
1175 (org-export-backend-name backend)
1178 (defun my/fix-inline-images ()
1179 (when org-inline-image-overlays
1180 (org-redisplay-inline-images)))
1182 (add-hook 'org-babel-after-execute-hook
1183 'my/fix-inline-images)
1186 ** LaTeX configuration
1188 :ID: 7135ba17-6a50-4eed-84ca-b90afa5b12f8
1190 #+BEGIN_SRC emacs-lisp
1192 (add-to-list 'org-latex-classes
1194 "\\documentclass[11pt,oneside,article]{memoir}\n"
1195 ("\\section{%s}" . "\\section*{%s}")
1196 ("\\subsection{%s}" . "\\subsection*{%s}")
1197 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1198 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1199 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1201 (setq org-beamer-outline-frame-options "")
1202 (add-to-list 'org-latex-classes
1204 "\\documentclass[ignorenonframetext]{beamer}
1205 [NO-DEFAULT-PACKAGES]
1208 ("\\section{%s}" . "\\section*{%s}")
1209 ("\\subsection{%s}" . "\\subsection*{%s}")
1210 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1211 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1212 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1214 (add-to-list 'org-latex-classes
1216 "\\documentclass[11pt,oneside]{memoir}\n"
1217 ("\\chapter{%s}" . "\\chapter*{%s}")
1218 ("\\section{%s}" . "\\section*{%s}")
1219 ("\\subsection{%s}" . "\\subsection*{%s}")
1220 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
1222 (add-to-list 'org-latex-classes
1224 "\\documentclass[11pt]{letter}
1225 [NO-DEFAULT-PACKAGES]
1228 ("\\section{%s}" . "\\section*{%s}")
1229 ("\\subsection{%s}" . "\\subsection*{%s}")
1230 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1231 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1232 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1234 (add-to-list 'org-latex-classes
1236 "\\documentclass{dlacv}
1237 [NO-DEFAULT-PACKAGES]
1240 ("\\section{%s}" . "\\section*{%s}")
1241 ("\\subsection{%s}" . "\\subsection*{%s}")
1242 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1243 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1244 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1247 (add-to-list 'org-latex-classes
1249 "\\documentclass{dlaresume}
1250 [NO-DEFAULT-PACKAGES]
1253 ("\\section{%s}" . "\\section*{%s}")
1254 ("\\subsection{%s}" . "\\subsection*{%s}")
1255 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1256 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1257 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1260 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
1261 ;; but adapted to use latexmk 4.22 or higher.
1262 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
1264 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
1265 (setq org-latex-default-packages-alist
1267 ("" "unicode-math" t)
1269 (setq org-latex-packages-alist
1276 ("" "longtable" nil)
1279 ;; make equations larger
1280 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
1282 (defun org-create-formula--latex-header ()
1283 "Return LaTeX header appropriate for previewing a LaTeX snippet."
1284 (let ((info (org-combine-plists (org-export--get-global-options
1285 (org-export-get-backend 'latex))
1286 (org-export--get-inbuffer-options
1287 (org-export-get-backend 'latex)))))
1288 (org-latex-guess-babel-language
1289 (org-latex-guess-inputenc
1290 (org-splice-latex-header
1291 org-format-latex-header
1292 org-latex-default-packages-alist
1294 (plist-get info :latex-header)))
1298 ; support ignoring headers in org mode export to latex
1299 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
1300 (defadvice org-latex-headline (around my-latex-skip-headlines
1301 (headline contents info) activate)
1302 (if (member "ignoreheading" (org-element-property :tags headline))
1303 (setq ad-return-value contents)
1306 ;; keep latex logfiles
1308 (setq org-latex-remove-logfiles nil)
1310 ;; Resume clocking task when emacs is restarted
1311 (org-clock-persistence-insinuate)
1313 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
1314 (setq org-clock-history-length 23)
1315 ;; Resume clocking task on clock-in if the clock is open
1316 (setq org-clock-in-resume t)
1317 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
1318 ;; there are things like PHONE calls
1319 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
1320 ;; Separate drawers for clocking and logs
1321 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
1322 ;; Save clock data and state changes and notes in the LOGBOOK drawer
1323 (setq org-clock-into-drawer t)
1324 (setq org-log-into-drawer t)
1325 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
1326 (setq org-clock-out-remove-zero-time-clocks t)
1327 ;; Clock out when moving task to a done state
1328 (setq org-clock-out-when-done t)
1329 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
1330 (setq org-clock-persist t)
1331 ;; Do not prompt to resume an active clock
1332 (setq org-clock-persist-query-resume nil)
1333 ;; Enable auto clock resolution for finding open clocks
1334 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
1335 ;; Include current clocking task in clock reports
1336 (setq org-clock-report-include-clocking-task t)
1338 ;; the cache seems to be broken
1339 (setq org-element-use-cache nil)
1341 (defvar bh/keep-clock-running nil)
1343 (defun bh/is-task-p ()
1344 "Any task with a todo keyword and no subtask"
1348 (subtree-end (save-excursion (org-end-of-subtree t)))
1349 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1352 (while (and (not has-subtask)
1353 (< (point) subtree-end)
1354 (re-search-forward "^\*+ " subtree-end t))
1355 (when (member (org-get-todo-state) org-todo-keywords-1)
1356 (setq has-subtask t))))
1357 (and is-a-task (not has-subtask)))))
1358 (defun bh/is-project-p ()
1359 "Any task with a todo keyword subtask"
1363 (subtree-end (save-excursion (org-end-of-subtree t)))
1364 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1367 (while (and (not has-subtask)
1368 (< (point) subtree-end)
1369 (re-search-forward "^\*+ " subtree-end t))
1370 (when (member (org-get-todo-state) org-todo-keywords-1)
1371 (setq has-subtask t))))
1372 (and is-a-task has-subtask))))
1374 (defun bh/is-subproject-p ()
1375 "Any task which is a subtask of another project"
1376 (let ((is-subproject)
1377 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1379 (while (and (not is-subproject) (org-up-heading-safe))
1380 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1381 (setq is-subproject t))))
1382 (and is-a-task is-subproject)))
1385 (defun bh/clock-in-to-next (kw)
1386 "Switch a task from TODO to NEXT when clocking in.
1387 Skips capture tasks, projects, and subprojects.
1388 Switch projects and subprojects from NEXT back to TODO"
1389 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
1391 ((and (member (org-get-todo-state) (list "TODO"))
1394 ((and (member (org-get-todo-state) (list "NEXT"))
1398 (defun bh/punch-in (arg)
1399 "Start continuous clocking and set the default task to the
1400 selected task. If no task is selected set the Organization task
1401 as the default task."
1403 (setq bh/keep-clock-running t)
1404 (if (equal major-mode 'org-agenda-mode)
1406 ;; We're in the agenda
1408 (let* ((marker (org-get-at-bol 'org-hd-marker))
1409 (tags (org-with-point-at marker (org-get-tags-at))))
1410 (if (and (eq arg 4) tags)
1411 (org-agenda-clock-in '(16))
1412 (bh/clock-in-organization-task-as-default)))
1414 ;; We are not in the agenda
1418 ; Find the tags on the current task
1419 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
1420 (org-clock-in '(16))
1421 (bh/clock-in-organization-task-as-default)))))
1423 (defun bh/punch-out ()
1425 (setq bh/keep-clock-running nil)
1426 (when (org-clock-is-active)
1428 (org-agenda-remove-restriction-lock))
1430 (defun bh/clock-in-default-task ()
1432 (org-with-point-at org-clock-default-task
1435 (defun bh/clock-in-parent-task ()
1436 "Move point to the parent (project) task if any and clock in"
1437 (let ((parent-task))
1441 (while (and (not parent-task) (org-up-heading-safe))
1442 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1443 (setq parent-task (point))))
1445 (org-with-point-at parent-task
1447 (when bh/keep-clock-running
1448 (bh/clock-in-default-task)))))))
1450 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
1452 (defun bh/clock-in-organization-task-as-default ()
1454 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
1455 (org-clock-in '(16))))
1457 (defun bh/clock-out-maybe ()
1458 (when (and bh/keep-clock-running
1459 (not org-clock-clocking-in)
1460 (marker-buffer org-clock-default-task)
1461 (not org-clock-resolving-clocks-due-to-idleness))
1462 (bh/clock-in-parent-task)))
1464 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1467 (defun bh/clock-in-task-by-id (id)
1468 "Clock in a task by id"
1469 (org-with-point-at (org-id-find id 'marker)
1470 (org-clock-in nil)))
1472 (defun bh/clock-in-last-task (arg)
1473 "Clock in the interrupted task if there is one
1474 Skip the default task and get the next one.
1475 A prefix arg forces clock in of the default task."
1477 (let ((clock-in-to-task
1479 ((eq arg 4) org-clock-default-task)
1480 ((and (org-clock-is-active)
1481 (equal org-clock-default-task (cadr org-clock-history)))
1482 (caddr org-clock-history))
1483 ((org-clock-is-active) (cadr org-clock-history))
1484 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
1485 (t (car org-clock-history)))))
1487 (org-with-point-at clock-in-to-task
1488 (org-clock-in nil))))
1491 (defun org-export-to-ods ()
1493 (let ((csv-file "data.csv"))
1494 (org-table-export csv-file "orgtbl-to-csv")
1495 (org-odt-convert csv-file "ods" 'open)))
1497 ; allow for zero-width-space to be a break in regexp too
1498 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
1499 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
1500 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
1502 ;; support inserting screen shots
1503 (defun my/org-insert-screenshot ()
1504 "Take a screenshot into a time stamped unique-named file in the
1505 same directory as the org-buffer and insert a link to this file."
1507 (defvar my/org-insert-screenshot/filename)
1508 (setq my/org-insert-screenshot/filename
1510 "Screenshot to insert: "
1512 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
1515 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
1516 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
1517 (org-display-inline-images))
1519 (defun my/fix-inline-images ()
1520 (when org-inline-image-overlays
1521 (org-redisplay-inline-images)))
1523 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
1525 ;; use xelatex to preview with imagemagick
1526 (add-to-list 'org-preview-latex-process-alist
1527 '(xelateximagemagick
1528 :programs ("xelatex" "convert")
1529 :description "pdf > png"
1530 :message "you need to install xelatex and imagemagick"
1532 :image-input-type "pdf"
1533 :image-output-type "png"
1534 :image-size-adjust (1.0 . 1.0)
1535 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
1536 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
1538 ;; use xelatex by default
1539 (setq org-preview-latex-default-process 'xelateximagemagick)
1541 ; from http://orgmode.org/Changes.html
1542 (defun my/org-repair-property-drawers ()
1543 "Fix properties drawers in current buffer.
1544 Ignore non Org buffers."
1546 (when (eq major-mode 'org-mode)
1547 (org-with-wide-buffer
1548 (goto-char (point-min))
1549 (let ((case-fold-search t)
1550 (inline-re (and (featurep 'org-inlinetask)
1551 (concat (org-inlinetask-outline-regexp)
1555 (unless (and inline-re (org-looking-at-p inline-re))
1557 (let ((end (save-excursion (outline-next-heading) (point))))
1559 (when (org-looking-at-p org-planning-line-re) (forward-line))
1560 (when (and (< (point) end)
1561 (not (org-looking-at-p org-property-drawer-re))
1563 (and (re-search-forward org-property-drawer-re end t)
1564 (eq (org-element-type
1565 (save-match-data (org-element-at-point)))
1567 (insert (delete-and-extract-region
1569 (min (1+ (match-end 0)) end)))
1570 (unless (bolp) (insert "\n"))))))))))))
1574 #+BEGIN_SRC emacs-lisp
1578 ** Override other things
1579 #+BEGIN_SRC emacs-lisp
1580 ; apparently things like to step on C-;, so we'll use a hack from
1581 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
1583 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
1586 (define-key my-keys-minor-mode-map (kbd "C-;") 'mc/mark-all-dwim)
1587 ;; use outline mode keybindings everywhere
1588 ;; (define-key my-keys-minor-mode-map (kbd "C-;") 'my/mydra-outline/body)
1590 (define-minor-mode my-keys-minor-mode
1591 "A minor mode so that my key settings override annoying major modes."
1592 t " my-keys" 'my-keys-minor-mode-map)
1594 (my-keys-minor-mode 1)
1595 (defun my-minibuffer-setup-hook ()
1596 (my-keys-minor-mode 0))
1598 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
1599 (defadvice load (after give-my-keybindings-priority)
1600 "Try to ensure that my keybindings always have priority."
1601 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
1602 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
1603 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
1604 (add-to-list 'minor-mode-map-alist mykeys))))
1608 #+BEGIN_SRC emacs-lisp
1609 (global-unset-key "\M-g")
1610 (global-set-key (kbd "M-g l") 'goto-line)
1612 * Misc (uncharacterized)
1613 #+BEGIN_SRC emacs-lisp
1614 (setq bibtex-user-optional-fields (quote (("annote" "Personal annotation (ignored)") ("abstract" "") ("pmid" "") ("doi" ""))))
1615 (setq calendar-latitude 40.11)
1616 (setq calendar-longitude -88.24)
1617 (setq case-fold-search t)
1618 (setq confirm-kill-emacs (quote y-or-n-p))
1619 (setq cperl-lazy-help-time nil)
1620 (setq debian-changelog-mailing-address "don@debian.org")
1622 (setq display-time-24hr-format t)
1623 (setq display-time-day-and-date t)
1624 (display-time-mode 1)
1625 (setq font-latex-fontify-script nil)
1626 (setq font-latex-fontify-sectioning (quote color))
1627 (setq font-latex-script-display (quote (nil)))
1628 (global-auto-revert-mode 1)
1629 (global-font-lock-mode 1)
1631 (setq log-edit-keep-buffer t)
1632 (setq mail-user-agent (quote sendmail-user-agent))
1633 (setq markdown-enable-math t)
1634 (setq markdown-follow-wiki-link-on-enter nil)
1635 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
1636 (setq post-email-address "don@donarmstrong.com")
1637 (setq post-kill-quoted-sig nil)
1638 (setq post-mail-message "mutt\\(ng\\|\\)-[a-z0-9]+-[0-9]+-.*")
1639 (setq post-uses-fill-mode nil)
1640 (setq ps-footer-font-size (quote (8 . 10)))
1641 (setq ps-header-font-size (quote (8 . 10)))
1642 (setq ps-header-title-font-size (quote (10 . 10)))
1643 (setq ps-line-number-color "blue")
1644 (setq ps-print-footer t)
1645 (setq ps-print-footer-frame nil)
1646 (setq ps-print-only-one-header t)
1647 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
1649 (setq sentence-end-double-space nil)
1650 ; enable matching parenthesis
1653 (setq user-mail-address "don@donarmstrong.com")
1654 (setq vc-delete-logbuf-window nil)
1655 (setq vc-follow-symlinks t)
1657 ;; use git before SVN; use CVS earlier, because I have CVS
1658 ;; repositories inside of git directories
1659 (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
1661 ;; switch back to the old primary selection method
1662 (setq x-select-enable-clipboard nil)
1663 (setq x-select-enable-primary t)
1664 ; (setq mouse-drag-copy-region t)
1666 (fset 'perl-mode 'cperl-mode)
1667 ;;(load-file "cperl-mode.el")
1673 ;;(require 'ecasound)
1674 ;;(require 'emacs-wiki)
1678 ; (require 'google-weather)
1679 ; (require 'org-google-weather)
1680 ; (setq-default org-google-weather-format "%i %c, [%l,%h] %s %C")
1682 (global-set-key "\C-xp" 'server-edit)
1684 (setq-default auto-mode-alist (cons '("\.wml$" .
1685 (lambda () (html-mode) (auto-fill-mode)))
1689 ; use markdown mode for mdwn files
1690 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
1691 (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
1694 ;; tramp configuration
1695 (setq tramp-use-ssh-controlmaster-options nil)
1697 ; mail configuration
1698 (add-to-list 'auto-mode-alist '("muttng-[a-z0-9]+-[0-9]+-" . message-mode))
1699 (add-to-list 'auto-mode-alist '("muttngrc" . muttrc-mode))
1701 (add-to-list 'auto-mode-alist '("mutt-[a-z0-9]+-[0-9]+-" . message-mode))
1702 (add-to-list 'auto-mode-alist '("muttrc" . muttrc-mode))
1703 (defun my-message-mode-settings ()
1704 (font-lock-add-keywords nil
1705 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1706 (0 'message-multiply-quoted-text-face))
1707 ("^[ \t]*>[ \t]*>.*$"
1708 (0 'message-double-quoted-text-face))))
1709 (local-set-key (kbd "C-c C-a") 'my-post-attach-file)
1711 (add-hook 'message-mode-hook 'my-message-mode-settings)
1713 (defun my-post-attach-file ()
1714 "Prompt for an attachment."
1716 (let ((file (read-file-name "Attach file: " nil nil t nil))
1717 (description (string-read "Description: ")))
1718 (my-header-attach-file file description)))
1720 (symbol-function 'my-post-attach-file)
1722 (defun my-header-attach-file (file description)
1723 "Attach a FILE to the current message (works with Mutt).
1724 Argument DESCRIPTION MIME description."
1725 (interactive "fAttach file: \nsDescription: ")
1726 (when (> (length file) 0)
1731 (goto-char (point-min))
1732 (search-forward-regexp "^$")
1733 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1735 (message (concat "Attached '" file "'."))
1736 (setq post-has-attachment t))))))
1740 (setq mail-yank-prefix "> ")
1742 ;; self-insert-command hack.
1743 ;; Without this, "if<SP>" expands to
1746 ;; which really should be,
1752 ;(load-library "php-mode")
1754 (setq-default c-indent-level 4)
1755 (setq-default c-brace-imaginary-offset 0)
1756 (setq-default c-brace-offset -4)
1757 (setq-default c-argdecl-indent 4)
1758 (setq-default c-label-offset -4)
1759 (setq-default c-continued-statement-offset 4)
1761 (setq-default indent-tabs-mode nil)
1762 (setq-default tab-width 4)
1765 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
1766 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
1767 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
1768 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
1769 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
1772 (defun insert-date ()
1773 "Insert date at point."
1775 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
1776 (global-set-key "\C-[d" 'insert-date)
1778 (defun unfill-paragraph (arg)
1779 "Pull this whole paragraph up onto one line."
1781 (let ((fill-column 10000))
1782 (fill-paragraph arg))
1785 (column-number-mode t)
1789 ; (require 'mode-compile)
1791 (defadvice server-process-filter (after post-mode-message first activate)
1792 "If the buffer is in post mode, overwrite the server-edit
1793 message with a post-save-current-buffer-and-exit message."
1794 (if (eq major-mode 'post-mode)
1796 (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done."))))
1797 ; This is also needed to see the magic message. Set to a higher
1798 ; number if you have a faster computer or read slower than me.
1799 '(font-lock-verbose 1000)
1800 ;(setq-default server-temp-file-regexp "mutt\(-\|ng-\)")
1801 ; (add-hook 'server-switch-hook
1802 ; (function (lambda()
1803 ; (cond ((string-match "Post" mode-name)
1804 ; (post-goto-body)))
1805 ; set-buffer-file-coding-system 'utf-8
1809 (add-hook 'post-mode-hook
1810 (auto-fill-mode nil)
1812 ; abbrev mode settings
1813 ; load abbreviations from
1814 (setq abbrev-file-name
1815 "~/.emacs_abbrev_def")
1817 ; read the abbrev file if it exists
1818 (if (file-exists-p abbrev-file-name)
1819 (quietly-read-abbrev-file))
1821 ; for now, use abbrev mode everywhere
1822 (setq default-abbrev-mode t)
1825 (defun insert-function-documentation ()
1826 "Insert function documentation"
1828 (insert-file-contents "/home/don/lib/templates/perl_function_documentation" nil))
1829 (global-set-key "\M-f" 'insert-function-documentation)
1831 (eval-after-load "lilypond-mode"
1833 (load-library "lyqi-mode")
1834 (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
1836 (autoload 'spamassassin-mode "spamassassin-mode" nil t)
1838 (desktop-load-default)
1840 '(icomplete-mode on)
1842 ;; custom-set-faces was added by Custom.
1843 ;; If you edit it by hand, you could mess it up, so be careful.
1844 ;; Your init file should contain only one such instance.
1845 ;; If there is more than one, they won't work right.
1846 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
1849 (put 'upcase-region 'disabled nil)
1850 (put 'downcase-region 'disabled nil)
1851 (put 'narrow-to-region 'disabled nil)
1853 ; (defun turn-on-flyspell ()
1854 ; "Force flyspell-mode on using a positive arg. For use in hooks."
1856 ; (flyspell-mode 1))
1859 ; Outline-minor-mode key map
1860 (define-prefix-command 'cm-map nil "Outline-")
1862 (define-key cm-map "q" 'hide-sublevels) ; Hide everything but the top-level headings
1863 (define-key cm-map "t" 'hide-body) ; Hide everything but headings (all body lines)
1864 (define-key cm-map "o" 'hide-other) ; Hide other branches
1865 (define-key cm-map "c" 'hide-entry) ; Hide this entry's body
1866 (define-key cm-map "l" 'hide-leaves) ; Hide body lines in this entry and sub-entries
1867 (define-key cm-map "d" 'hide-subtree) ; Hide everything in this entry and sub-entries
1869 (define-key cm-map "a" 'show-all) ; Show (expand) everything
1870 (define-key cm-map "e" 'show-entry) ; Show this heading's body
1871 (define-key cm-map "i" 'show-children) ; Show this heading's immediate child sub-headings
1872 (define-key cm-map "k" 'show-branches) ; Show all sub-headings under this heading
1873 (define-key cm-map "s" 'show-subtree) ; Show (expand) everything in this heading & below
1875 (define-key cm-map "u" 'outline-up-heading) ; Up
1876 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
1877 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
1878 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
1879 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
1880 (global-set-key "\M-o" cm-map)
1884 (setq-default debian-changelog-mailing-address "don@debian.org")
1885 (setq-default debian-changelog-full-name "Don Armstrong")
1887 ; ediff configuration
1888 ; don't use the multi-window configuration
1889 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
1891 ; fix up css mode to not be silly
1892 ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
1893 (setq cssm-indent-level 4)
1894 (setq cssm-newline-before-closing-bracket t)
1895 (setq cssm-indent-function #'cssm-c-style-indenter)
1896 (setq cssm-mirror-mode nil)
1898 (require 'multi-web-mode)
1899 (setq mweb-default-major-mode 'html-mode)
1900 (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
1901 (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
1902 (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
1903 (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
1904 (multi-web-global-mode 1)
1906 ;;; alias the new `flymake-report-status-slim' to
1907 ;;; `flymake-report-status'
1908 (defalias 'flymake-report-status 'flymake-report-status-slim)
1909 (defun flymake-report-status-slim (e-w &optional status)
1910 "Show \"slim\" flymake status in mode line."
1912 (setq flymake-mode-line-e-w e-w))
1914 (setq flymake-mode-line-status status))
1915 (let* ((mode-line " Φ"))
1916 (when (> (length flymake-mode-line-e-w) 0)
1917 (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
1918 (setq mode-line (concat mode-line flymake-mode-line-status))
1919 (setq flymake-mode-line mode-line)
1920 (force-mode-line-update)))
1922 ; load sql-indent when sql is loaded
1923 (eval-after-load "sql"
1924 '(load-library "sql-indent"))
1926 ; fix up tmux xterm keys
1927 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
1928 (defun fix-up-tmux-keys ()
1929 "Fix up tmux xterm keys"
1932 (let ((x 2) (tkey ""))
1952 ;; ctrl + alt + shift
1954 (setq tkey "C-M-S-"))
1957 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
1958 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
1959 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
1960 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
1962 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
1964 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
1966 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
1968 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
1970 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
1972 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
1974 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
1976 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
1978 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
1980 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
1982 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
1984 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
1986 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
1988 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
1990 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
1992 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
1994 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
1996 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
1998 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
2000 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
2002 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
2004 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
2006 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
2008 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
2010 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
2012 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
2019 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
2021 ; procmailmode configuration
2022 (load "procmail_mode")
2024 (load "mode-line-cleaner")
2026 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
2027 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
2028 (if (or (buffer-modified-p)
2029 (verify-visited-file-modtime)
2030 (< (* 8 1024 1024) (buffer-size))
2031 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
2033 (clear-visited-file-modtime)
2035 (ad-activate 'ask-user-about-supersession-threat)
2037 ; apparently things like to step on C-;, so we'll use a hack from
2038 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
2040 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
2042 ; use iedit everywhere
2043 (define-key my-keys-minor-mode-map (kbd "C-;") 'mc/mark-all-dwim)
2045 (define-minor-mode my-keys-minor-mode
2046 "A minor mode so that my key settings override annoying major modes."
2047 t " my-keys" 'my-keys-minor-mode-map)
2049 (my-keys-minor-mode 1)
2050 (defun my-minibuffer-setup-hook ()
2051 (my-keys-minor-mode 0))
2053 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
2054 (defadvice load (after give-my-keybindings-priority)
2055 "Try to ensure that my keybindings always have priority."
2056 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
2057 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
2058 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
2059 (add-to-list 'minor-mode-map-alist mykeys))))
2061 (global-set-key "\M- " 'hippie-expand)
2066 #+BEGIN_SRC emacs-lisp
2067 (provide 'don-configuration)