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)
10 * Initial startup stuff
11 ** Disable startup screen
12 #+BEGIN_SRC emacs-lisp
13 (setq inhibit-startup-screen t)
16 #+BEGIN_SRC emacs-lisp
17 ; (if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
18 (if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
19 (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
22 #+BEGIN_SRC emacs-lisp
23 (setq frame-resize-pixelwise t)
24 (add-to-list 'default-frame-alist '(fullscreen . maximixed))
27 ** package repositories and package manager
28 Borrowed from https://github.com/nilcons/emacs-use-package-fast/ to
29 load [[https://github.com/jwiegley/use-package/][use-package]] even faster
30 #+BEGIN_SRC emacs-lisp
31 (setq package-enable-at-startup nil)
32 (setq package--init-file-ensured t)
34 (setq use-package-verbose (not (bound-and-true-p byte-compile-current-file))))
35 (mapc #'(lambda (add) (add-to-list 'load-path add))
38 (unless (package-installed-p 'use-package)
39 (package-refresh-contents)
40 (package-install 'use-package))
41 (let ((package-user-dir-real (file-truename package-user-dir)))
42 ;; The reverse is necessary, because outside we mapc
43 ;; add-to-list element-by-element, which reverses.
44 (nreverse (apply #'nconc
45 ;; Only keep package.el provided loadpaths.
46 (mapcar #'(lambda (path)
47 (if (string-prefix-p package-user-dir-real path)
52 (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
53 ("melpa" . "https://melpa.org/packages/")
54 ("org" . "http://orgmode.org/elpa/") ))
55 (require 'use-package)
60 #+BEGIN_SRC emacs-lisp
63 :commands (paradox-upgrade-packages paradox-list-packages)
64 :config (setq paradox-execute-asynchronously t)
69 #+BEGIN_SRC emacs-lisp
70 (add-to-list 'load-path '"~/lib/emacs_el/")
71 (add-to-list 'load-path '"~/lib/emacs_el/magit-annex")
74 #+BEGIN_SRC emacs-lisp
75 ;; Set the custom file to /dev/null and don't bother to load it
76 (setq custom-file "/dev/null")
80 #+BEGIN_SRC emacs-lisp
81 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
82 ;; execute conditional code when loading libraries
83 (defmacro with-library (symbol &rest body)
84 `(when (require ,symbol nil t)
86 (put 'with-library 'lisp-indent-function 1)
90 ** Safe Local Variables
91 #+BEGIN_SRC emacs-lisp
92 (setq safe-local-variable-values
93 (quote ((auto-save-default)
95 (cperl-indent-level . 4)
97 (indent-tabs-mode . f)
101 #+BEGIN_SRC emacs-lisp
102 (setq global-mark-ring-max 128
106 (defun don/minibuffer-setup-hook ()
107 (setq gc-cons-threshold most-positive-fixnum))
109 (defun don/minibuffer-exit-hook ()
110 (setq gc-cons-threshold 1048576))
112 (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
113 (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
117 #+BEGIN_SRC emacs-lisp
118 (use-package hippie-expand
119 :bind* (("M-<SPC>" . hippie-expand))
123 #+BEGIN_SRC emacs-lisp
124 (use-package flyspell
126 :diminish flyspell-mode 🐝
128 (add-hook 'text-mode-hook 'turn-on-flyspell)
129 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
130 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
131 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
133 (setq ispell-program-name "ispell")
138 #+begin_src emacs-lisp :tangle yes
144 #+BEGIN_SRC emacs-lisp
149 #+BEGIN_SRC emacs-lisp
150 (use-package eyebrowse
152 :diminish eyebrowse-mode
153 :init (setq eyebrowse-keymap-prefix (kbd "C-c e"))
155 (setq eyebrowse-wrap-around t)
158 (defun my/eyebrowse-new-window-config ()
162 ;; start at 1 run till 0
163 (let ((j (mod (+ i 1) 10)))
164 (when (and (not done)
165 (not (eyebrowse--window-config-present-p j)))
166 (eyebrowse-switch-to-window-config j)
167 (call-interactively 'eyebrowse-rename-window-config2 j)
172 ;; I don't use latex-preview-pane
173 ;; (require 'latex-preview-pane)
174 ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
175 ;; ;; latex-preview-pane uses window-parameters which are
176 ;; ;; not preserved by eyebrowse, so we close the preview
177 ;; ;; pane before switching, it will be regenerated when we
178 ;; ;; edit the TeX file.
179 ;; (when (lpp/window-containing-preview)
180 ;; (delete-window (lpp/window-containing-preview))))
182 ;; (add-to-list 'eyebrowse-pre-window-switch-hook
183 ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
185 ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
186 ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
187 ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
188 ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
189 ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
197 #+BEGIN_SRC emacs-lisp
198 (defun my/vsplit-last-buffer ()
199 "Split the window vertically and display the previous buffer."
201 (split-window-vertically)
203 (switch-to-next-buffer))
205 (defun my/hsplit-last-buffer ()
206 "Split the window horizontally and display the previous buffer."
208 (split-window-horizontally)
210 (switch-to-next-buffer))
212 (bind-key "C-x 2" 'my/vsplit-last-buffer)
213 (bind-key "C-x 3" 'my/hsplit-last-buffer)
215 (setq split-width-threshold 100)
216 (setq split-height-threshold 60)
218 (defun my/split-window-prefer-vertically (window)
219 "If there's only one window (excluding any possibly active
220 minibuffer), then split the current window horizontally."
221 (if (and (one-window-p t)
222 (not (active-minibuffer-window))
223 ( < (frame-width) (frame-height))
225 (let ((split-width-threshold nil))
226 (split-window-sensibly window))
227 (split-window-sensibly window)))
229 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
230 (setq window-combination-resize t)
233 *** Compilation window
235 If there is no compilation window, open one at the bottom, spanning
236 the complete width of the frame. Otherwise, reuse existing window. In
237 the former case, if there was no error the window closes
240 #+BEGIN_SRC emacs-lisp
241 (add-to-list 'display-buffer-alist
242 `(,(rx bos "*compilation*" eos)
243 (display-buffer-reuse-window
244 display-buffer-in-side-window)
245 (reusable-frames . visible)
247 (window-height . 0.4)))
250 #+BEGIN_SRC emacs-lisp
251 (defun my/compilation-exit-autoclose (status code msg)
252 ;; If M-x compile exists with a 0
253 (when (and (eq status 'exit) (zerop code))
254 ;; and delete the *compilation* window
255 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
256 (when (and (not (window-at-side-p compilation-window 'top))
257 (window-at-side-p compilation-window 'left)
258 (window-at-side-p compilation-window 'right))
259 (delete-window compilation-window))))
260 ;; Always return the anticipated result of compilation-exit-message-function
263 ;; Specify my function (maybe I should have done a lambda function)
264 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
267 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
268 value, the compilation buffer scrolls automatically to follow the
269 output. If the value is ~first-error~, scrolling stops when the first
270 error appears, leaving point at that error. For any other non-nil
271 value, scrolling continues until there is no more output.
273 #+BEGIN_SRC emacs-lisp
274 (setq compilation-scroll-output 'first-error)
277 ** Mode line cleaning
279 #+BEGIN_SRC emacs-lisp
280 (use-package diminish
285 #+BEGIN_SRC emacs-lisp
292 #+BEGIN_SRC emacs-lisp
295 :bind (("C-c C-<SPC>" . avy-goto-word-or-subword-1)
296 ("C-c j j" . avy-goto-word-or-subword-1)
297 ("M-g g" . avy-goto-line))
298 :config (progn (setq avy-background t))
301 *** Ace-link (jumping to links)
302 #+BEGIN_SRC emacs-lisp
303 (use-package ace-link
305 ; bind o in most modes
306 :config (ace-link-setup-default))
308 *** Jumping through edit points (goto-chg)
309 #+BEGIN_SRC emacs-lisp
310 (use-package goto-chg
312 :bind (("C-c j ," . goto-last-change)
313 ("C-c j ." . goto-last-change-reverse))
316 *** Jumping to bookmarks (visible bookmarks, bm)
317 #+BEGIN_SRC emacs-lisp
320 :bind (("C-c j b ." . bm-next)
321 ("C-c j b ," . bm-previous)
322 ("C-c j b SPC" . bm-toggle)))
327 #+BEGIN_SRC emacs-lisp
328 (use-package yasnippet
330 :diminish yas-minor-mode
333 (setq yas-verbosity 1)
334 (define-key yas-minor-mode-map (kbd "<tab>") nil)
335 (define-key yas-minor-mode-map (kbd "TAB") nil)
336 (define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)
337 (setq yas-snippet-dirs '("~/lib/emacs_el/snippets/"
338 "~/lib/emacs_el/yasnippet-snippets/snippets/"))
339 (add-to-list 'hippie-expand-try-functions-list
340 'yas-hippie-try-expand)
345 #+BEGIN_SRC emacs-lisp
346 (use-package auto-yasnippet
347 :bind (("H-w" . aya-create)
354 #+BEGIN_SRC emacs-lisp
356 (use-package tinyprocmail
357 :load-path "~/lib/emacs_el/tiny-tools/lisp/tiny"
358 :mode (".procmailrc" . turn-on-tinyprocmail-mode)
363 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
366 :bind (("C-x g" . magit-status)
367 ("C-x C-g" . magit-status))
369 ;; refine diffs always (hilight words)
370 (setq magit-diff-refine-hunk nil)
372 (use-package magit-annex
374 :load-path "~/lib/emacs_el/magit-annex/"
376 (use-package magit-vcsh
377 :ensure f ; currently not in melpa, so don't try to install
378 :load-path "~/lib/emacs_el/magit-vcsh/"
383 #+BEGIN_SRC emacs-lisp
384 (use-package cperl-mode
387 ;; Use c-mode for perl .xs files
388 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
389 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
390 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
391 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
392 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
395 cperl-auto-newline nil
396 cperl-auto-newline-after-colon nil
397 cperl-continued-statement-offset 4
398 cperl-brace-offset -1
399 cperl-continued-brace-offset 0
400 cperl-label-offset -4
401 cperl-highlight-variables-indiscriminately t
402 cperl-electric-lbrace-space nil
403 cperl-indent-parens-as-block nil
404 cperl-close-paren-offset -1
405 cperl-tab-always-indent t)
406 ;;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
411 #+BEGIN_SRC emacs-lisp
412 (use-package markdown-mode
414 :mode (("\\.md\\'" . markdown-mode)
415 ("\\.mdwn\\'" . markdown-mode)
416 ("README\\.md\\'" . gfm-mode)
419 (setq markdown-enable-math t)
420 (setq markdown-follow-wiki-link-on-enter nil)
421 (bind-key "M-." #'markdown-jump markdown-mode-map)
422 (add-hook 'markdown-mode-hook #'flyspell-mode)
423 (add-hook 'markdown-mode-hook #'outline-minor-mode)
424 (bind-key "C-<tab>" #'outline-cycle markdown-mode-map)
429 #+BEGIN_SRC emacs-lisp
430 ; load sql-indent when sql is loaded
432 :mode (("\\.sql\\'" . sql-mode))
434 (require sql-indent))
437 #+BEGIN_SRC emacs-lisp
439 :commands ediff ediff3
442 ;; ediff configuration
443 ;; don't use the multi-window configuration
444 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
447 ** VCL --editing varnish configuration files
448 #+BEGIN_SRC emacs-lisp
449 (use-package vcl-mode
456 #+BEGIN_SRC emacs-lisp
457 (defun malb/helm-omni (&rest arg)
458 ;; just in case someone decides to pass an argument, helm-omni won't fail.
460 (unless helm-source-buffers-list
461 (setq helm-source-buffers-list
462 (helm-make-source "Buffers" 'helm-source-buffers)))
466 (if (projectile-project-p)
467 '(helm-source-projectile-buffers-list
468 helm-source-buffers-list)
469 '(helm-source-buffers-list)) ;; list of all open buffers
471 `(((name . "Virtual Workspace")
472 (candidates . ,(--map (cons (eyebrowse-format-slot it) (car it))
473 (eyebrowse--get 'window-configs)))
474 (action . (lambda (candidate)
475 (eyebrowse-switch-to-window-config candidate)))))
477 (if (projectile-project-p)
478 '(helm-source-projectile-recentf-list
480 '(helm-source-recentf)) ;; all recent files
482 ;; always make some common files easily accessible
483 ;;'(((name . "Common Files")
484 ;; (candidates . malb/common-file-targets)
485 ;; (action . (("Open" . (lambda (x) (find-file (eval x))))))))
487 '(helm-source-files-in-current-dir
489 helm-source-bookmarks
490 helm-source-buffer-not-found ;; ask to create a buffer otherwise
492 "*Helm all the things*"))
496 :bind (("M-x" . helm-M-x)
497 ("C-x C-f" . helm-find-files)
498 ("C-x b" . helm-buffers-list) ; malb/helm-omni)
499 ("C-x C-b" . helm-buffers-list) ; malb/helm-omni)
500 ("C-c <SPC>" . helm-all-mark-rings))
502 (require 'helm-config)
503 (require 'helm-for-files)
504 (require 'helm-bookmark)
507 (define-key global-map [remap find-file] 'helm-find-files)
508 (define-key global-map [remap occur] 'helm-occur)
509 (define-key global-map [remap list-buffers] 'helm-buffers-list)
510 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
511 (unless (boundp 'completion-in-region-function)
512 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
513 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
514 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
519 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
521 #+BEGIN_SRC emacs-lisp
522 (use-package helm-flx
525 ;; these are helm configs, but they kind of fit here nicely
526 (setq helm-M-x-fuzzy-match t
527 helm-bookmark-show-location t
528 helm-buffers-fuzzy-matching t
529 helm-completion-in-region-fuzzy-match t
530 helm-file-cache-fuzzy-match t
531 helm-imenu-fuzzy-match t
532 helm-mode-fuzzy-match t
533 helm-locate-fuzzy-match nil
535 helm-recentf-fuzzy-match nil
536 helm-semantic-fuzzy-match t)
540 #+BEGIN_SRC emacs-lisp
542 ;;; stolen from https://github.com/malb/emacs.d/blob/master/malb.org
543 (defun malb/helm-swoop-pre-fill ()
544 (thing-at-point 'symbol))
545 (defvar malb/helm-swoop-ignore-major-mode "List of major modes to ignore for helm-swoop")
546 (setq malb/helm-swoop-ignore-major-mode '(dired-mode
547 paradox-menu-mode doc-view-mode pdf-view-mode
548 mu4e-headers-mode org-mode markdown-mode latex-mode
549 ein:notebook-multilang-mode))
551 (defun malb/swoop-or-search ()
553 (if (or (> (buffer-size) 1048576) ;; helm-swoop can be slow on big buffers
554 (memq major-mode malb/helm-swoop-ignore-major-mode))
558 (use-package helm-swoop
561 :bind (("C-c o" . helm-multi-swoop-org)
562 ("C-s" . malb/swoop-or-search)
563 ("C-M-s" . helm-multi-swoop-all))
566 (setq helm-swoop-pre-input-function #'malb/helm-swoop-pre-fill
567 helm-swoop-split-with-multiple-windows nil
568 helm-swoop-split-direction #'split-window-horizontally
569 helm-swoop-split-window-function 'helm-default-display-buffer
570 helm-swoop-speed-or-color t)
572 ;; https://emacs.stackexchange.com/questions/28790/helm-swoop-how-to-make-it-behave-more-like-isearch
573 (defun malb/helm-swoop-C-s ()
575 (if (boundp 'helm-swoop-pattern)
576 (if (equal helm-swoop-pattern "")
577 (previous-history-element 1)
581 (bind-key "C-S-s" #'helm-swoop-from-isearch isearch-mode-map)
582 (bind-key "C-S-s" #'helm-multi-swoop-all-from-helm-swoop helm-swoop-map)
583 (bind-key "C-r" #'helm-previous-line helm-swoop-map)
584 (bind-key "C-s" #'malb/helm-swoop-C-s helm-swoop-map)
585 (bind-key "C-r" #'helm-previous-line helm-multi-swoop-map)
586 (bind-key "C-s" #'malb/helm-swoop-C-s helm-multi-swoop-map))
591 #+BEGIN_SRC emacs-lisp
594 :config (setq helm-ag-base-command "ag --nocolor --nogroup"
595 helm-ag-command-option "--all-text"
596 helm-ag-insert-at-point 'symbol
597 helm-ag-fuzzy-match t
598 helm-ag-use-temp-buffer t
599 helm-ag-use-grep-ignore-list t
600 helm-ag-use-agignore t))
603 #+BEGIN_SRC emacs-lisp
604 (use-package helm-descbinds
606 :bind ("C-h b" . helm-descbinds)
607 :init (fset 'describe-bindings 'helm-descbinds))
611 #+BEGIN_SRC emacs-lisp
612 (use-package helm-c-yasnippet
614 :bind ("C-c h y" . helm-yas-complete)
616 (setq helm-yas-space-match-any-greedy t)))
619 #+BEGIN_SRC emacs-lisp
620 (use-package helm-org-rifle
623 (defun malb/helm-org-rifle-agenda-files (arg)
625 (let ((current-prefix-arg nil))
627 ((equal arg 4) (call-interactively #'helm-org-rifle-agenda-files nil))
628 ((equal arg 16) (helm-org-rifle-occur-agenda-files))
629 (t (helm-org-agenda-files-headings)))))))
632 This can be used to link things pretty quickly if necessary
633 #+BEGIN_SRC emacs-lisp
634 (use-package helm-google
636 :bind ("C-c h g" . helm-google)
638 (progn (add-to-list 'helm-google-actions
639 '("Copy URL" . (lambda (candidate)
641 (replace-regexp-in-string
642 "https://.*q=\\(.*\\)\&sa=.*"
648 (add-to-list 'helm-google-actions
649 '("Org Store Link" . (lambda (candidate)
650 (let ((title (car (split-string candidate "[\n]+")))
652 (replace-regexp-in-string
653 "https://.*q=\\(.*\\)\&sa=.*"
655 (push (list url title) org-stored-links))))
660 ** Projectile -- Project management
661 #+begin_src emacs-lisp
662 (use-package projectile
664 :bind (("<f5>" . projectile-compile-project)
665 ("<f6>" . next-error))
667 (use-package magit :ensure t)
668 (require 'helm-projectile)
671 (setq projectile-make-test-cmd "make check"
672 projectile-switch-project-action 'helm-projectile
673 projectile-mode-line '(:eval (format "»{%s}" (projectile-project-name))))
675 (projectile-global-mode)))
679 #+begin_src emacs-lisp
680 (use-package helm-projectile
683 (defvar malb/helm-source-file-not-found
684 (helm-build-dummy-source
689 'helm-projectile-sources-list
690 malb/helm-source-file-not-found t)
692 (helm-delete-action-from-source
693 "Grep in projects `C-s'"
694 helm-source-projectile-projects)
696 (helm-add-action-to-source
697 "Grep in projects `C-s'"
698 'helm-do-ag helm-source-projectile-projects 4)))
701 #+BEGIN_SRC emacs-lisp
704 :bind ("M-z" . avy-zap-up-to-char-dwim))
707 #+BEGIN_SRC emacs-lisp
709 :bind (("C-c 2" . my/hydra-orgmodes/body)
710 ("C-c @" . my/hydra-orgmodes/body)
711 ("C-c #" . my/hydra-outline/body)
712 ("C-c 3" . my/hydra-outline/body)
715 (defhydra my/hydra-orgmodes (:color blue :hint nil)
717 _n_: notes _c_: chaim _w_: wildman _o_: ool
718 _u_: uddin _s_: steve _r_: refile _f_: fh
719 _p_: read papers _R_: paper notes
724 ("n" (find-file "~/projects/org-notes/notes.org"))
725 ("c" (find-file "~/projects/org-notes/chaim.org"))
726 ("w" (find-file "~/projects/org-notes/wildman.org"))
727 ("u" (find-file "~/projects/org-notes/uddin.org"))
728 ("o" (find-file "~/projects/org-notes/ool.org"))
729 ("f" (find-file "~/projects/org-notes/fh.org"))
730 ("s" (find-file "~/projects/org-notes/sndservers.org"))
731 ("r" (find-file "~/projects/org-notes/refile.org"))
732 ("p" (find-file "~/projects/research/papers_to_read.org"))
733 ("R" (find-file "~/projects/research/paper_notes.org"))
734 ("h" (find-file "~/projects/org-notes/hpcbio.org"))
739 ;; from https://github.com/abo-abo/hydra/wiki/Emacs
740 (defhydra my/hydra-outline (:color pink :hint nil)
743 ^^^^^^------------------------------------------------------
744 _q_: sublevels _a_: all _u_: up
745 _t_: body _e_: entry _n_: next visible
746 _o_: other _i_: children _p_: previous visible
747 _c_: entry _k_: branches _f_: forward same level
748 _l_: leaves _s_: subtree _b_: backward same level
753 ("q" outline-hide-sublevels) ; Hide everything but the top-level headings
754 ("t" outline-hide-body) ; Hide everything but headings (all body lines)
755 ("o" outline-hide-other) ; Hide other branches
756 ("c" outline-hide-entry) ; Hide this entry's body
757 ("l" outline-hide-leaves) ; Hide body lines in this entry and sub-entries
758 ("d" outline-hide-subtree) ; Hide everything in this entry and sub-entries
760 ("a" outline-show-all) ; Show (expand) everything
761 ("e" outline-show-entry) ; Show this heading's body
762 ("i" outline-show-children) ; Show this heading's immediate child sub-headings
763 ("k" outline-show-branches) ; Show all sub-headings under this heading
764 ("s" outline-show-subtree) ; Show (expand) everything in this heading & below
766 ("u" outline-up-heading) ; Up
767 ("n" outline-next-visible-heading) ; Next
768 ("p" outline-previous-visible-heading) ; Previous
769 ("f" outline-forward-same-level) ; Forward - same level
770 ("b" outline-backward-same-level) ; Backward - same level
776 #+BEGIN_SRC emacs-lisp
777 (add-to-list 'tramp-methods '("vcsh"
778 (tramp-login-program "vcsh")
782 (tramp-remote-shell "/bin/sh")
783 (tramp-remote-shell-args
787 #+BEGIN_SRC emacs-lisp
791 (setq-default reftex-default-bibliography
792 '("~/projects/research/references.bib")))
795 #+BEGIN_SRC emacs-lisp
797 :config (setq bibtex-user-optional-fields
798 (quote (("annote" "Personal annotation (ignored)")
806 #+BEGIN_SRC emacs-lisp
811 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
812 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
813 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
814 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
815 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
816 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
817 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
818 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
819 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
820 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
821 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
823 (setq-default reftex-plug-into-AUCTeX t)
824 ;; support fake section headers
825 (setq TeX-outline-extra
831 ;; add font locking to the headers
832 (font-lock-add-keywords
834 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
835 0 'font-lock-keyword-face t)
836 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
837 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
838 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
839 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
840 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
842 ;; use smart quotes by default instead of `` and ''
843 ;; taken from http://kieranhealy.org/esk/kjhealy.html
844 (setq TeX-open-quote "“")
845 (setq TeX-close-quote "”")
847 ;; (TeX-add-style-hook
852 ;; (custom-set-variables
853 ;; '(font-latex-user-keyword-classes
856 ;; font-lock-function-name-face 2 (command 1 t))))
858 (setq-default TeX-parse-self t)
859 (setq-default TeX-auto-save t)
860 (setq-default TeX-master nil)
866 (if (boundp 'reftex-ref-style-alist)
868 'reftex-ref-style-alist
869 '("Cleveref" "cleveref"
870 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
871 (reftex-ref-style-activate "Cleveref")
873 '("cref" TeX-arg-ref)
874 '("Cref" TeX-arg-ref)
875 '("cpageref" TeX-arg-ref)
876 '("Cpageref" TeX-arg-ref)))))
879 '(add-to-list 'LaTeX-fill-excluded-macros
882 (use-package font-latex
884 (setq font-latex-match-reference-keywords
906 (setq font-latex-fontify-script nil)
907 (setq font-latex-fontify-sectioning (quote color))
908 (setq font-latex-script-display (quote (nil)))
913 #+BEGIN_SRC emacs-lisp
917 :mode ("\\.R\\'" . ess-r-mode)
918 :bind (:map ess-mode-map
919 ("C-c C-R" . dla/ess-region-remote-eval))
921 (defun ess-change-directory (path)
922 "Set the current working directory to PATH for both *R* and Emacs."
923 (interactive "Directory to change to: ")
925 (when (file-exists-p path)
926 (ess-command (concat "setwd(\"" path "\")\n"))
927 ;; use file-name-as-directory to ensure it has trailing /
928 (setq default-directory (file-name-as-directory path))))
929 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
930 ;; outlining support for ess modes
935 (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
936 (defun outline-level ()
937 (cond ((looking-at "^##### ") 1)
938 ((looking-at "^#### ") 2)
939 ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
942 (defun dla/ess-region-remote-eval (start end)
943 "Evaluate region in a remote ESS instance"
945 (shell-command-on-region start end "eval_r" (get-buffer-create "***essregionremoteeval***"))
946 kill-buffer "***essregionremoteeval***")
947 ;; Don't restore history or save workspace image
948 '(inferior-R-args "--no-restore-history --no-save")
953 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
955 #+BEGIN_SRC emacs-lisp
956 (use-package rainbow-mode
957 ;; add ess to the x major mode
958 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
959 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
964 #+BEGIN_SRC emacs-lisp
965 (use-package polymode
968 (use-package poly-noweb)
969 (use-package poly-markdown)
970 :mode ("\\.Snw" . poly-noweb+r-mode)
971 :mode ("\\.Rnw" . poly-noweb+r-mode)
972 :mode ("\\.Rmd" . poly-markdown+r-mode)
978 #+BEGIN_SRC emacs-lisp
979 (use-package outline-magic)
982 #+BEGIN_SRC emacs-lisp
983 (use-package writeroom-mode
985 (defun my/writing-mode ()
986 "Start my writing mode; enable visual-line-mode and auto-fill-mode"
991 (visual-line-mode -1)
993 (visual-fill-column-mode -1)
997 (visual-fill-column-mode 1)
1002 ** GhostText/Atomic Chrome
1003 #+BEGIN_SRC emacs-lisp
1004 (use-package atomic-chrome
1006 (ignore-errors (atomic-chrome-start-server))
1007 (setq atomic-chrome-buffer-open-style 'full)
1012 :ID: 6fcf218b-a762-4c37-9339-a8202ddeb544
1014 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
1015 #+BEGIN_SRC emacs-lisp
1016 (use-package multiple-cursors
1017 :bind* (("C-;" . mc/mark-all-dwim)
1018 ("C-<" . mc/mark-previous-like-this)
1019 ("C->" . mc/mark-next-like-this)
1020 ("C-S-c C-S-c" . mc/edit-lines))
1024 #+BEGIN_SRC emacs-lisp
1025 (use-package web-mode
1027 (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . web-mode))
1028 (setq web-mode-enable-engine-detection t)
1029 (setq web-mode-engines-alist
1030 '(("template-toolkit" . "\\.tmpl\\'")))
1033 ** Spamassassin Mode
1034 #+BEGIN_SRC emacs-lisp
1035 (use-package spamassassin-mode
1036 :commands spamassassin-mode
1041 #+BEGIN_SRC emacs-lisp
1042 (use-package password-store
1044 :commands password-store-edit password-store-create
1048 #+BEGIN_SRC emacs-lisp
1052 ;; fix up css mode to not be silly
1053 ;; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
1054 (setq cssm-indent-level 4)
1055 (setq cssm-newline-before-closing-bracket t)
1056 (setq cssm-indent-function #'cssm-c-style-indenter)
1057 (setq cssm-mirror-mode nil))
1060 #+BEGIN_SRC emacs-lisp
1062 :diminish abbrev-mode
1064 ;; load abbreviations from
1065 (setq abbrev-file-name
1066 "~/.emacs_abbrev_def")
1068 ;; read the abbrev file if it exists
1069 (if (file-exists-p abbrev-file-name)
1070 (quietly-read-abbrev-file))
1072 ;; for now, use abbrev mode everywhere
1073 (setq default-abbrev-mode t))
1079 #+BEGIN_SRC emacs-lisp
1080 (use-package message
1082 :diminish (message "✉")
1083 :mode ("muttng-[a-z0-9]+-[0-9]+-" . message-mode)
1084 :mode ("mutt-[a-z0-9]+-[0-9]+-" . message-mode)
1085 :hook 'my/message-mode-settings
1086 :hook 'turn-on-flyspell
1087 :bind (:map message-mode-map
1088 ("C-c C-a" . my/post-attach-file))
1089 :delight (message-mode "✉")
1091 (defun my/message-mode-settings ()
1092 (font-lock-add-keywords nil
1093 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1094 (0 'message-multiply-quoted-text-face))
1095 ("^[ \t]*>[ \t]*>.*$"
1096 (0 'message-double-quoted-text-face))))
1099 (defun my/post-attach-file ()
1100 "Prompt for an attachment."
1102 (let ((file (read-file-name "Attach file: " nil nil t nil)))
1103 (my/header-attach-file file "")))
1105 (defun my/header-attach-file (file description)
1106 "Attach a FILE to the current message (works with Mutt).
1107 Argument DESCRIPTION MIME description."
1108 (interactive "fAttach file: \nsDescription: ")
1109 (when (> (length file) 0)
1114 (goto-char (point-min))
1115 (search-forward-regexp "^$")
1116 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1118 (message (concat "Attached '" file "'."))
1119 (setq post-has-attachment t))))))
1121 (setq mail-yank-prefix "> ")
1125 #+BEGIN_SRC emacs-lisp
1126 (use-package muttrc-mode
1133 ** Reverting buffers
1134 #+BEGIN_SRC emacs-lisp
1135 (use-package autorevert
1136 :diminish auto-revert-mode
1138 (setq global-auto-revert-non-file-buffers t
1139 global-auto-revert-ignore-modes '(pdf-view-mode)
1140 auto-revert-verbose nil)
1141 (global-auto-revert-mode 1))
1144 ** Use-package and load things
1145 #+BEGIN_SRC emacs-lisp
1148 :delight (org-mode "ø")
1152 ** Agenda Configuration
1153 #+BEGIN_SRC emacs-lisp
1154 :mode ("\\.\\(org\\|org_archive\\|txt\\)\\'" . org-mode)
1155 :bind (("C-c l" . org-store-link)
1156 ("C-c a" . org-agenda)
1157 ("C-c b" . org-iswitchb))
1159 (setq-default org-log-done 'time)
1160 (setq-default org-agenda-ndays 5)
1162 ;; agenda configuration
1163 ;; Do not dim blocked tasks
1164 (setq org-agenda-dim-blocked-tasks nil)
1165 (setq org-agenda-inhibit-startup t)
1166 (setq org-agenda-use-tag-inheritance nil)
1168 ;; Compact the block agenda view
1169 (setq org-agenda-compact-blocks t)
1171 ;; Custom agenda command definitions
1172 (setq org-agenda-custom-commands
1173 (quote (("N" "Notes" tags "NOTE"
1174 ((org-agenda-overriding-header "Notes")
1175 (org-tags-match-list-sublevels t)))
1176 ("h" "Habits" tags-todo "STYLE=\"habit\""
1177 ((org-agenda-overriding-header "Habits")
1178 (org-agenda-sorting-strategy
1179 '(todo-state-down effort-up category-keep))))
1183 ((org-agenda-overriding-header "Tasks to Refile")
1184 (org-tags-match-list-sublevels nil)))
1185 (tags-todo "-CANCELLED/!"
1186 ((org-agenda-overriding-header "Stuck Projects")
1187 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
1188 (org-agenda-sorting-strategy
1190 (tags-todo "-HOLD-CANCELLED/!"
1191 ((org-agenda-overriding-header "Projects")
1192 (org-agenda-skip-function 'bh/skip-non-projects)
1193 (org-tags-match-list-sublevels 'indented)
1194 (org-agenda-sorting-strategy
1196 (tags-todo "-CANCELLED/!NEXT"
1197 ((org-agenda-overriding-header (concat "Project Next Tasks"
1198 (if bh/hide-scheduled-and-waiting-next-tasks
1200 " (including WAITING and SCHEDULED tasks)")))
1201 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1202 (org-tags-match-list-sublevels t)
1203 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1204 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1205 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1206 (org-agenda-sorting-strategy
1207 '(todo-state-down effort-up category-keep))))
1208 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1209 ((org-agenda-overriding-header (concat "Project Subtasks"
1210 (if bh/hide-scheduled-and-waiting-next-tasks
1212 " (including WAITING and SCHEDULED tasks)")))
1213 (org-agenda-skip-function 'bh/skip-non-project-tasks)
1214 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1215 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1216 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1217 (org-agenda-sorting-strategy
1219 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1220 ((org-agenda-overriding-header (concat "Standalone Tasks"
1221 (if bh/hide-scheduled-and-waiting-next-tasks
1223 " (including WAITING and SCHEDULED tasks)")))
1224 (org-agenda-skip-function 'bh/skip-project-tasks)
1225 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1226 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1227 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1228 (org-agenda-sorting-strategy
1230 (tags-todo "-CANCELLED+WAITING|HOLD/!"
1231 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
1232 (org-agenda-skip-function 'bh/skip-stuck-projects)
1233 (org-tags-match-list-sublevels nil)
1234 (org-agenda-todo-ignore-scheduled t)
1235 (org-agenda-todo-ignore-deadlines t)))
1237 ((org-agenda-overriding-header "Tasks to Archive")
1238 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1239 (org-tags-match-list-sublevels nil))))
1242 ; org mode agenda files
1243 (setq org-agenda-files
1244 (quote ("~/projects/org-notes/debbugs.org"
1245 "~/projects/org-notes/notes.org"
1246 "~/projects/org-notes/holidays.org"
1247 "~/projects/org-notes/refile.org"
1248 "~/projects/org-notes/diary.org"
1249 "~/projects/org-notes/ool.org"
1250 "~/projects/org-notes/sndservers.org"
1251 "~/projects/org-notes/chaim.org"
1252 "~/projects/org-notes/wildman.org"
1253 "~/projects/org-notes/uddin.org"
1254 "~/projects/org-notes/reviews.org"
1255 "~/org-mode/from-mobile.org"
1256 "~/projects/org-notes/fh.org")))
1258 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
1259 (set-register ?r (cons 'file "~/projects/org-notes/refile.org"))
1260 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
1261 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
1262 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
1263 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
1264 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
1265 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
1266 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
1267 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
1268 (defun org-agenda-timeline-all (&optional arg)
1271 (dolist (org-agenda-file org-agenda-files)
1272 (insert-file-contents org-agenda-file nil)
1273 (goto-char (point-max))
1275 (write-file "/tmp/timeline.org")
1276 (org-agenda arg "L")))
1277 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
1281 #+BEGIN_SRC emacs-lisp
1282 (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")))
1283 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
1285 (setq org-default-notes-file "~/projects/org-notes/notes.org")
1286 (setq org-id-link-to-org-use-id 'use-existing)
1288 ** Capture Templates
1289 #+BEGIN_SRC emacs-lisp
1290 (setq org-capture-templates ;; mail-specific note template, identified by "m"
1291 '(("m" "Mail" entry (file "~/projects/org-notes/refile.org")
1292 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
1293 ("t" "todo" entry (file "~/projects/org-notes/refile.org")
1294 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
1295 ("r" "respond" entry (file "~/projects/org-notes/refile.org")
1296 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
1297 ("n" "note" entry (file "~/projects/org-notes/refile.org")
1298 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
1299 ("s" "schedule" entry (file "~/projects/org-notes/refile.org")
1300 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
1301 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
1302 "* %?\n%U\n" :clock-in t :clock-resume t)
1303 ("w" "org-protocol" entry (file "~/projects/org-notes/refile.org")
1304 "* TODO Review %c\n%U\n" :immediate-finish t)
1305 ("M" "Meeting" entry (file "~/projects/org-notes/refile.org")
1306 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
1307 ("S" "Seminar" entry (file "~/projects/org-notes/refile.org")
1308 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
1309 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
1310 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
1311 ("p" "Phone call" entry (file "~/projects/org-notes/refile.org")
1312 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
1313 ("J" "job" entry (file "~/projects/org-notes/refile.org")
1314 "* 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)
1315 ("h" "Habit" entry (file "~/projects/org-notes/refile.org")
1316 "* 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")
1320 ;; Remove empty LOGBOOK drawers on clock out
1321 (defun bh/remove-empty-drawer-on-clock-out ()
1324 (beginning-of-line 0)
1325 (org-remove-empty-drawer-at (point))))
1327 (defun my/org-add-id ()
1330 (if (org-current-level)
1339 ** Org mode key bindings
1340 #+BEGIN_SRC emacs-lisp
1341 ; org mode configuration from http://doc.norang.ca/org-mode.html
1342 ;; Custom Key Bindings
1343 (global-set-key (kbd "<f12>") 'org-agenda)
1344 ; (global-set-key (kbd "<f5>") 'bh/org-todo)
1345 (global-set-key (kbd "<S-f5>") 'bh/widen)
1346 (global-set-key (kbd "<f7>") 'bh/set-truncate-lines)
1347 (global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
1348 (global-set-key (kbd "<f9> <f9>") 'bh/show-org-agenda)
1349 (global-set-key (kbd "<f9> b") 'bbdb)
1350 (global-set-key (kbd "<f9> c") 'calendar)
1351 (global-set-key (kbd "<f9> f") 'boxquote-insert-file)
1352 (global-set-key (kbd "<f9> h") 'bh/hide-other)
1353 (global-set-key (kbd "<f9> n") 'bh/toggle-next-task-display)
1354 (global-set-key (kbd "<f9> w") 'widen)
1356 ; change the outline mode prefix from C-c @ to C-c C-2
1357 (setq outline-minor-mode-prefix "C-c C-2")
1358 ;(add-hook 'outline-minor-mode-hook
1359 ; (lambda () (local-set-key (kbd "C-c C-2")
1360 ; outline-mode-prefix-map)))
1362 (global-set-key (kbd "<f9> I") 'bh/punch-in)
1363 (global-set-key (kbd "<f9> O") 'bh/punch-out)
1365 (global-set-key (kbd "<f9> o") 'bh/make-org-scratch)
1367 (global-set-key (kbd "<f9> r") 'boxquote-region)
1368 (global-set-key (kbd "<f9> s") 'bh/switch-to-scratch)
1370 (global-set-key (kbd "<f9> t") 'bh/insert-inactive-timestamp)
1371 (global-set-key (kbd "<f9> T") 'bh/toggle-insert-inactive-timestamp)
1373 (global-set-key (kbd "<f9> v") 'visible-mode)
1374 (global-set-key (kbd "<f9> l") 'org-toggle-link-display)
1375 (global-set-key (kbd "<f9> SPC") 'bh/clock-in-last-task)
1376 (global-set-key (kbd "C-<f9>") 'previous-buffer)
1377 (global-set-key (kbd "M-<f9>") 'org-toggle-inline-images)
1378 (global-set-key (kbd "C-x n r") 'narrow-to-region)
1379 (global-set-key (kbd "C-<f10>") 'next-buffer)
1380 (global-set-key (kbd "<f11>") 'org-clock-goto)
1381 (global-set-key (kbd "C-<f11>") 'org-clock-in)
1382 (global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)
1383 (global-set-key (kbd "C-c c") 'org-capture)
1386 ** Utility Functions
1387 #+BEGIN_SRC emacs-lisp
1388 (defun bh/hide-other ()
1391 (org-back-to-heading 'invisible-ok)
1397 (defun bh/set-truncate-lines ()
1398 "Toggle value of truncate-lines and refresh window display."
1400 (setq truncate-lines (not truncate-lines))
1401 ;; now refresh window display (an idiom from simple.el):
1403 (set-window-start (selected-window)
1404 (window-start (selected-window)))))
1406 (defun bh/make-org-scratch ()
1408 (find-file "/tmp/publish/scratch.org")
1409 (gnus-make-directory "/tmp/publish"))
1411 (defun bh/switch-to-scratch ()
1413 (switch-to-buffer "*scratch*"))
1415 (setq org-use-fast-todo-selection t)
1416 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1418 ; create function to create headlines in file. This comes from
1419 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
1420 (defun my/org-add-ids-to-headlines-in-file ()
1421 "Add ID properties to all headlines in the current file which
1422 do not already have one."
1424 (org-map-entries 'org-id-get-create))
1425 ; if we wanted to do this to every buffer, do the following:
1426 ; (add-hook 'org-mode-hook
1428 ; (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
1431 #+BEGIN_SRC emacs-lisp
1432 (setq org-todo-keywords
1433 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
1434 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
1436 (setq org-todo-keyword-faces
1437 (quote (("TODO" :foreground "red" :weight bold)
1438 ("NEXT" :foreground "blue" :weight bold)
1439 ("DONE" :foreground "forest green" :weight bold)
1440 ("WAITING" :foreground "orange" :weight bold)
1441 ("HOLD" :foreground "magenta" :weight bold)
1442 ("CANCELLED" :foreground "forest green" :weight bold)
1443 ("MEETING" :foreground "forest green" :weight bold)
1444 ("PHONE" :foreground "forest green" :weight bold))))
1446 (setq org-todo-state-tags-triggers
1447 (quote (("CANCELLED" ("CANCELLED" . t))
1448 ("WAITING" ("WAITING" . t))
1449 ("HOLD" ("WAITING") ("HOLD" . t))
1450 (done ("WAITING") ("HOLD"))
1451 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1452 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1453 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1457 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1458 ; add ids on creation of nodes
1459 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
1462 ; resolve clocks after 10 minutes of idle; use xprintidle
1463 ; (setq org-clock-idle-time 10)
1464 ; (setq org-clock-x11idle-program-name "xprintidle")
1466 ; this is from http://doc.norang.ca/org-mode.html#Capture
1467 ; use C-M-r for org mode capture
1468 (global-set-key (kbd "C-M-r") 'org-capture)
1470 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1471 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1472 (org-agenda-files :maxlevel . 9))))
1474 ; Use full outline paths for refile targets - we file directly with IDO
1475 (setq org-refile-use-outline-path t)
1477 ; Targets complete directly with IDO
1478 (setq org-outline-path-complete-in-steps nil)
1480 ; Allow refile to create parent tasks with confirmation
1481 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1483 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
1484 ; (setq org-completion-use-ido t)
1485 ; (setq ido-everywhere t)
1486 ; (setq ido-max-directory-size 100000)
1487 ; (ido-mode (quote both))
1488 ; ; Use the current window when visiting files and buffers with ido
1489 ; (setq ido-default-file-method 'selected-window)
1490 ; (setq ido-default-buffer-method 'selected-window)
1491 ; ; Use the current window for indirect buffer display
1492 ; (setq org-indirect-buffer-display 'current-window)
1495 ;;;; Refile settings
1496 ; Exclude DONE state tasks from refile targets
1497 (defun bh/verify-refile-target ()
1498 "Exclude todo keywords with a done state from refile targets"
1499 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
1501 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1503 ;; ensure that emacsclient will show just the note to be edited when invoked
1504 ;; from Mutt, and that it will shut down emacsclient once finished;
1505 ;; fallback to legacy behavior when not invoked via org-protocol.
1506 (require 'org-protocol)
1507 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
1508 (setq my-org-protocol-flag nil)
1509 (defadvice org-capture-finalize (after delete-frame-at-end activate)
1510 "Delete frame at remember finalization"
1511 (progn (if my-org-protocol-flag (delete-frame))
1512 (setq my-org-protocol-flag nil)))
1513 (defadvice org-capture-refile (around delete-frame-after-refile activate)
1514 "Delete frame at remember refile"
1515 (if my-org-protocol-flag
1517 (setq my-org-protocol-flag nil)
1522 (defadvice org-capture-kill (after delete-frame-at-end activate)
1523 "Delete frame at remember abort"
1524 (progn (if my-org-protocol-flag (delete-frame))
1525 (setq my-org-protocol-flag nil)))
1526 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
1527 (setq my-org-protocol-flag t))
1529 (defadvice org-insert-todo-heading (after dla/create-id activate)
1534 (add-to-list 'org-modules 'org-habit)
1536 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
1537 (defun open-mail-in-mutt (message)
1538 "Open a mail message in Mutt, using an external terminal.
1540 Message can be specified either by a path pointing inside a
1541 Maildir, or by Message-ID."
1542 (interactive "MPath or Message-ID: ")
1544 (format "faf xterm -e \"%s %s\""
1545 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
1547 ;; add support for "mutt:ID" links
1548 (org-add-link-type "mutt" 'open-mail-in-mutt)
1550 (defun my-org-mode-setup ()
1551 ; (load-library "reftex")
1552 (and (buffer-file-name)
1553 (file-exists-p (buffer-file-name))
1555 ; (reftex-parse-all)
1556 (reftex-set-cite-format
1557 '((?b . "[[bib:%l][%l-bib]]")
1558 (?n . "[[notes:%l][%l-notes]]")
1560 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
1562 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
1563 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
1564 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
1565 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
1567 (add-hook 'org-mode-hook 'my-org-mode-setup)
1569 (defun org-mode-reftex-search ()
1571 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
1573 (defun open-research-paper (bibtexkey)
1574 "Open a paper by bibtex key"
1575 (interactive "bibtex key: ")
1578 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1579 (org-add-link-type "papers" 'open-research-paper)
1580 (defun open-research-paper-pdf (bibtexkey)
1581 "Open a paper pdf by bibtex key"
1582 (interactive "bibtex key: ")
1584 (format "%s -p evince_annot %s"
1585 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1586 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
1588 (add-to-list 'org-link-abbrev-alist
1590 "~/projects/research/paper_notes.org::#%s"))
1592 ; I pretty much always want hiearchical checkboxes
1593 (setq org-hierachical-checkbox-statistics nil)
1595 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
1596 (add-to-list 'org-structure-template-alist
1597 '("E" "\\begin{equation}\n?\n\\end{equation}"))
1600 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
1601 (defun my-rtcite-export-handler (path desc format)
1602 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
1603 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
1604 (match-string 1 path)))
1605 (path (substring path 0 (match-beginning 0))))
1606 (cond ((eq format 'latex)
1608 (equal 0 (search "rtcite:" desc)))
1609 (format "\\cite{%s}" search)
1610 (format "\\cite[%s]{%s}" desc search))))))
1612 (org-add-link-type "rtcite"
1614 'my-rtcite-export-handler)
1618 ** Org Mobile Configuration
1619 #+BEGIN_SRC emacs-lisp
1620 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
1621 (when (string= system-name "linnode")
1622 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
1623 (setq-default org-directory "/home/don/org-mode/")
1624 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
1628 #+BEGIN_SRC emacs-lisp
1629 ;; org mode ical export
1630 (setq org-icalendar-timezone "America/Los_Angeles")
1631 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
1632 ;; we already add the id manually
1633 (setq org-icalendar-store-UID t)
1636 ** General Org Babel Configuration
1637 #+BEGIN_SRC emacs-lisp
1638 ;; org babel support
1639 (org-babel-do-load-languages
1640 'org-babel-load-languages
1647 ;; use graphviz-dot for dot things
1648 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
1649 ;; org-babel-by-backend
1650 (defmacro org-babel-by-backend (&rest body)
1651 `(case (if (boundp 'backend)
1652 (org-export-backend-name backend)
1655 (defun my/fix-inline-images ()
1656 (when org-inline-image-overlays
1657 (org-redisplay-inline-images)))
1659 (add-hook 'org-babel-after-execute-hook
1660 'my/fix-inline-images)
1663 ** LaTeX configuration
1665 :ID: 7135ba17-6a50-4eed-84ca-b90afa5b12f8
1667 #+BEGIN_SRC emacs-lisp
1669 (add-to-list 'org-latex-classes
1671 "\\documentclass[11pt,oneside,article]{memoir}\n"
1672 ("\\section{%s}" . "\\section*{%s}")
1673 ("\\subsection{%s}" . "\\subsection*{%s}")
1674 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1675 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1676 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1678 (setq org-beamer-outline-frame-options "")
1679 (add-to-list 'org-latex-classes
1681 "\\documentclass[ignorenonframetext]{beamer}
1682 [NO-DEFAULT-PACKAGES]
1685 ("\\section{%s}" . "\\section*{%s}")
1686 ("\\subsection{%s}" . "\\subsection*{%s}")
1687 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1688 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1689 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1691 (add-to-list 'org-latex-classes
1693 "\\documentclass[11pt,oneside]{memoir}\n"
1694 ("\\chapter{%s}" . "\\chapter*{%s}")
1695 ("\\section{%s}" . "\\section*{%s}")
1696 ("\\subsection{%s}" . "\\subsection*{%s}")
1697 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
1699 (add-to-list 'org-latex-classes
1701 "\\documentclass[11pt]{letter}
1702 [NO-DEFAULT-PACKAGES]
1705 ("\\section{%s}" . "\\section*{%s}")
1706 ("\\subsection{%s}" . "\\subsection*{%s}")
1707 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1708 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1709 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1711 (add-to-list 'org-latex-classes
1713 "\\documentclass{dlacv}
1714 [NO-DEFAULT-PACKAGES]
1717 ("\\section{%s}" . "\\section*{%s}")
1718 ("\\subsection{%s}" . "\\subsection*{%s}")
1719 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1720 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1721 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1724 (add-to-list 'org-latex-classes
1726 "\\documentclass{dlaresume}
1727 [NO-DEFAULT-PACKAGES]
1730 ("\\section{%s}" . "\\section*{%s}")
1731 ("\\subsection{%s}" . "\\subsection*{%s}")
1732 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1733 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1734 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1737 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
1738 ;; but adapted to use latexmk 4.22 or higher.
1739 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
1741 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
1742 (setq org-latex-default-packages-alist
1744 ("" "unicode-math" t)
1746 (setq org-latex-packages-alist
1753 ("" "longtable" nil)
1756 ;; make equations larger
1757 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
1759 (defun org-create-formula--latex-header ()
1760 "Return LaTeX header appropriate for previewing a LaTeX snippet."
1761 (let ((info (org-combine-plists (org-export--get-global-options
1762 (org-export-get-backend 'latex))
1763 (org-export--get-inbuffer-options
1764 (org-export-get-backend 'latex)))))
1765 (org-latex-guess-babel-language
1766 (org-latex-guess-inputenc
1767 (org-splice-latex-header
1768 org-format-latex-header
1769 org-latex-default-packages-alist
1771 (plist-get info :latex-header)))
1775 ; support ignoring headers in org mode export to latex
1776 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
1777 (defadvice org-latex-headline (around my-latex-skip-headlines
1778 (headline contents info) activate)
1779 (if (member "ignoreheading" (org-element-property :tags headline))
1780 (setq ad-return-value contents)
1783 ;; keep latex logfiles
1785 (setq org-latex-remove-logfiles nil)
1787 ;; Resume clocking task when emacs is restarted
1788 (org-clock-persistence-insinuate)
1790 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
1791 (setq org-clock-history-length 23)
1792 ;; Resume clocking task on clock-in if the clock is open
1793 (setq org-clock-in-resume t)
1794 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
1795 ;; there are things like PHONE calls
1796 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
1797 ;; Separate drawers for clocking and logs
1798 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
1799 ;; Save clock data and state changes and notes in the LOGBOOK drawer
1800 (setq org-clock-into-drawer t)
1801 (setq org-log-into-drawer t)
1802 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
1803 (setq org-clock-out-remove-zero-time-clocks t)
1804 ;; Clock out when moving task to a done state
1805 (setq org-clock-out-when-done t)
1806 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
1807 (setq org-clock-persist t)
1808 ;; Do not prompt to resume an active clock
1809 (setq org-clock-persist-query-resume nil)
1810 ;; Enable auto clock resolution for finding open clocks
1811 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
1812 ;; Include current clocking task in clock reports
1813 (setq org-clock-report-include-clocking-task t)
1815 ;; the cache seems to be broken
1816 (setq org-element-use-cache nil)
1818 (defvar bh/keep-clock-running nil)
1820 (defun bh/is-task-p ()
1821 "Any task with a todo keyword and no subtask"
1825 (subtree-end (save-excursion (org-end-of-subtree t)))
1826 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1829 (while (and (not has-subtask)
1830 (< (point) subtree-end)
1831 (re-search-forward "^\*+ " subtree-end t))
1832 (when (member (org-get-todo-state) org-todo-keywords-1)
1833 (setq has-subtask t))))
1834 (and is-a-task (not has-subtask)))))
1835 (defun bh/is-project-p ()
1836 "Any task with a todo keyword subtask"
1840 (subtree-end (save-excursion (org-end-of-subtree t)))
1841 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1844 (while (and (not has-subtask)
1845 (< (point) subtree-end)
1846 (re-search-forward "^\*+ " subtree-end t))
1847 (when (member (org-get-todo-state) org-todo-keywords-1)
1848 (setq has-subtask t))))
1849 (and is-a-task has-subtask))))
1851 (defun bh/is-subproject-p ()
1852 "Any task which is a subtask of another project"
1853 (let ((is-subproject)
1854 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1856 (while (and (not is-subproject) (org-up-heading-safe))
1857 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1858 (setq is-subproject t))))
1859 (and is-a-task is-subproject)))
1862 (defun bh/clock-in-to-next (kw)
1863 "Switch a task from TODO to NEXT when clocking in.
1864 Skips capture tasks, projects, and subprojects.
1865 Switch projects and subprojects from NEXT back to TODO"
1866 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
1868 ((and (member (org-get-todo-state) (list "TODO"))
1871 ((and (member (org-get-todo-state) (list "NEXT"))
1875 (defun bh/punch-in (arg)
1876 "Start continuous clocking and set the default task to the
1877 selected task. If no task is selected set the Organization task
1878 as the default task."
1880 (setq bh/keep-clock-running t)
1881 (if (equal major-mode 'org-agenda-mode)
1883 ;; We're in the agenda
1885 (let* ((marker (org-get-at-bol 'org-hd-marker))
1886 (tags (org-with-point-at marker (org-get-tags-at))))
1887 (if (and (eq arg 4) tags)
1888 (org-agenda-clock-in '(16))
1889 (bh/clock-in-organization-task-as-default)))
1891 ;; We are not in the agenda
1895 ; Find the tags on the current task
1896 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
1897 (org-clock-in '(16))
1898 (bh/clock-in-organization-task-as-default)))))
1900 (defun bh/punch-out ()
1902 (setq bh/keep-clock-running nil)
1903 (when (org-clock-is-active)
1905 (org-agenda-remove-restriction-lock))
1907 (defun bh/clock-in-default-task ()
1909 (org-with-point-at org-clock-default-task
1912 (defun bh/clock-in-parent-task ()
1913 "Move point to the parent (project) task if any and clock in"
1914 (let ((parent-task))
1918 (while (and (not parent-task) (org-up-heading-safe))
1919 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1920 (setq parent-task (point))))
1922 (org-with-point-at parent-task
1924 (when bh/keep-clock-running
1925 (bh/clock-in-default-task)))))))
1927 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
1929 (defun bh/clock-in-organization-task-as-default ()
1931 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
1932 (org-clock-in '(16))))
1934 (defun bh/clock-out-maybe ()
1935 (when (and bh/keep-clock-running
1936 (not org-clock-clocking-in)
1937 (marker-buffer org-clock-default-task)
1938 (not org-clock-resolving-clocks-due-to-idleness))
1939 (bh/clock-in-parent-task)))
1941 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1944 (defun bh/clock-in-task-by-id (id)
1945 "Clock in a task by id"
1946 (org-with-point-at (org-id-find id 'marker)
1947 (org-clock-in nil)))
1949 (defun bh/clock-in-last-task (arg)
1950 "Clock in the interrupted task if there is one
1951 Skip the default task and get the next one.
1952 A prefix arg forces clock in of the default task."
1954 (let ((clock-in-to-task
1956 ((eq arg 4) org-clock-default-task)
1957 ((and (org-clock-is-active)
1958 (equal org-clock-default-task (cadr org-clock-history)))
1959 (caddr org-clock-history))
1960 ((org-clock-is-active) (cadr org-clock-history))
1961 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
1962 (t (car org-clock-history)))))
1964 (org-with-point-at clock-in-to-task
1965 (org-clock-in nil))))
1968 (defun org-export-to-ods ()
1970 (let ((csv-file "data.csv"))
1971 (org-table-export csv-file "orgtbl-to-csv")
1972 (org-odt-convert csv-file "ods" 'open)))
1974 ; allow for zero-width-space to be a break in regexp too
1975 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
1976 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
1977 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
1979 ;; support inserting screen shots
1980 (defun my/org-insert-screenshot ()
1981 "Take a screenshot into a time stamped unique-named file in the
1982 same directory as the org-buffer and insert a link to this file."
1984 (defvar my/org-insert-screenshot/filename)
1985 (setq my/org-insert-screenshot/filename
1987 "Screenshot to insert: "
1989 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
1992 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
1993 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
1994 (org-display-inline-images))
1996 (defun my/fix-inline-images ()
1997 (when org-inline-image-overlays
1998 (org-redisplay-inline-images)))
2000 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
2002 ;; use xelatex to preview with imagemagick
2003 (add-to-list 'org-preview-latex-process-alist
2004 '(xelateximagemagick
2005 :programs ("xelatex" "convert")
2006 :description "pdf > png"
2007 :message "you need to install xelatex and imagemagick"
2009 :image-input-type "pdf"
2010 :image-output-type "png"
2011 :image-size-adjust (1.0 . 1.0)
2012 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
2013 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
2015 ;; use xelatex by default
2016 (setq org-preview-latex-default-process 'xelateximagemagick)
2018 ; from http://orgmode.org/Changes.html
2019 (defun my/org-repair-property-drawers ()
2020 "Fix properties drawers in current buffer.
2021 Ignore non Org buffers."
2023 (when (eq major-mode 'org-mode)
2024 (org-with-wide-buffer
2025 (goto-char (point-min))
2026 (let ((case-fold-search t)
2027 (inline-re (and (featurep 'org-inlinetask)
2028 (concat (org-inlinetask-outline-regexp)
2032 (unless (and inline-re (org-looking-at-p inline-re))
2034 (let ((end (save-excursion (outline-next-heading) (point))))
2036 (when (org-looking-at-p org-planning-line-re) (forward-line))
2037 (when (and (< (point) end)
2038 (not (org-looking-at-p org-property-drawer-re))
2040 (and (re-search-forward org-property-drawer-re end t)
2041 (eq (org-element-type
2042 (save-match-data (org-element-at-point)))
2044 (insert (delete-and-extract-region
2046 (min (1+ (match-end 0)) end)))
2047 (unless (bolp) (insert "\n"))))))))))))
2051 #+BEGIN_SRC emacs-lisp
2055 (use-package calfw-org
2058 (use-package org-gcal
2060 :config '((if (file-readable-p "~/.hide/org_gcal.el")
2061 (load-file "~/.hide/org_gcal.el"))
2066 #+BEGIN_SRC emacs-lisp
2070 ;; Show notification 10 minutes before event
2071 (setq appt-message-warning-time 10)
2072 ;; Disable multiple reminders
2073 (setq appt-display-interval appt-message-warning-time)
2074 (setq appt-display-mode-line nil)
2076 ;; add automatic reminders for appointments
2077 (defun my/org-agenda-to-appt ()
2079 (setq appt-time-msg-list nil)
2080 (org-agenda-to-appt))
2081 ;; add reminders when starting emacs
2082 (my/org-agenda-to-appt)
2083 ;; when rebuilding the agenda
2084 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
2085 "Pressing `r' on the agenda will also add appointments."
2086 (my/org-agenda-to-appt)
2088 ;; when saving all org buffers
2089 (defadvice org-save-all-org-buffers (after org-save-all-org-buffers-add-appts)
2090 "Re-add appts after saving all org buffers"
2091 (my/org-agenda-to-appt))
2092 ;; Display appointments as a window manager notification
2093 (setq appt-disp-window-function 'my/appt-display)
2094 (setq appt-delete-window-function (lambda () t))
2096 (setq my/appt-notification-app (concat (getenv "HOME") "/bin/appt_notification"))
2098 (defun my/appt-display (min-to-app new-time msg)
2099 (if (atom min-to-app)
2100 (start-process "my/appt-notification-app" nil my/appt-notification-app min-to-app msg)
2101 (dolist (i (number-sequence 0 (1- (length min-to-app))))
2102 (start-process "my/appt-notification-app" nil my/appt-notification-app
2103 (nth i min-to-app) (nth i msg))))
2110 #+BEGIN_SRC emacs-lisp
2115 #+BEGIN_SRC emacs-lisp
2116 (global-unset-key "\M-g")
2117 (global-set-key (kbd "M-g l") 'goto-line)
2121 #+BEGIN_SRC emacs-lisp
2122 (use-package debian-changelog
2124 :mode "debian/changelog"
2126 (setq debian-changelog-mailing-address "don@debian.org")
2127 (setq debian-changelog-full-name "Don Armstrong"))
2129 * Misc (uncharacterized)
2130 #+BEGIN_SRC emacs-lisp
2131 (setq calendar-latitude 38.6)
2132 (setq calendar-longitude -121.5)
2133 (setq case-fold-search t)
2134 (setq confirm-kill-emacs (quote y-or-n-p))
2135 (setq cperl-lazy-help-time nil)
2137 (setq display-time-24hr-format t)
2138 (setq display-time-day-and-date t)
2139 (display-time-mode 1)
2140 (global-font-lock-mode 1)
2142 (setq log-edit-keep-buffer t)
2143 (setq mail-user-agent (quote sendmail-user-agent))
2144 (setq markdown-enable-math t)
2145 (setq markdown-follow-wiki-link-on-enter nil)
2146 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
2147 (setq ps-footer-font-size (quote (8 . 10)))
2148 (setq ps-header-font-size (quote (8 . 10)))
2149 (setq ps-header-title-font-size (quote (10 . 10)))
2150 (setq ps-line-number-color "blue")
2151 (setq ps-print-footer t)
2152 (setq ps-print-footer-frame nil)
2153 (setq ps-print-only-one-header t)
2154 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
2156 (setq sentence-end-double-space nil)
2157 ; enable matching parenthesis
2160 (setq user-mail-address "don@donarmstrong.com")
2161 (setq vc-delete-logbuf-window nil)
2162 (setq vc-follow-symlinks t)
2164 ;; use git before SVN; use CVS earlier, because I have CVS
2165 ;; repositories inside of git directories
2166 (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
2168 ;; switch back to the old primary selection method
2169 (setq x-select-enable-clipboard nil)
2170 (setq x-select-enable-primary t)
2171 ; (setq mouse-drag-copy-region t)
2173 (fset 'perl-mode 'cperl-mode)
2174 ;;(load-file "cperl-mode.el")
2176 ;; tramp configuration
2177 (setq tramp-use-ssh-controlmaster-options nil)
2179 (setq-default c-indent-level 4)
2180 (setq-default c-brace-imaginary-offset 0)
2181 (setq-default c-brace-offset -4)
2182 (setq-default c-argdecl-indent 4)
2183 (setq-default c-label-offset -4)
2184 (setq-default c-continued-statement-offset 4)
2186 (setq-default indent-tabs-mode nil)
2187 (setq-default tab-width 4)
2190 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
2191 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
2192 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
2193 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
2194 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
2197 (defun insert-date ()
2198 "Insert date at point."
2200 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
2201 (global-set-key "\C-[d" 'insert-date)
2203 (defun unfill-paragraph (arg)
2204 "Pull this whole paragraph up onto one line."
2206 (let ((fill-column 10000))
2207 (fill-paragraph arg))
2210 (column-number-mode t)
2213 ** Desktop-save-mode
2214 If the envvar EMACS_SERVER_NAME is set, consider this a separate
2215 emacs, and use a different desktop file to restore history
2216 #+BEGIN_SRC emacs-lisp
2220 (setq desktop-base-file-name
2221 (convert-standard-filename
2223 (or (getenv "EMACS_SERVER_NAME")
2227 (setq desktop-base-lock-name
2228 (convert-standard-filename
2229 (concat desktop-base-file-name
2231 (setq desktop-auto-save-timeout 60)
2232 (setq desktop-restore-eager 5)
2233 (setq desktop-lazy-verbose nil)
2234 (desktop-save-mode 1)
2238 ** Misc (Uncharacterized)
2239 #+BEGIN_SRC emacs-lisp
2240 '(icomplete-mode on)
2242 ;; custom-set-faces was added by Custom.
2243 ;; If you edit it by hand, you could mess it up, so be careful.
2244 ;; Your init file should contain only one such instance.
2245 ;; If there is more than one, they won't work right.
2246 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
2249 (put 'upcase-region 'disabled nil)
2250 (put 'downcase-region 'disabled nil)
2251 (put 'narrow-to-region 'disabled nil)
2253 ; (defun turn-on-flyspell ()
2254 ; "Force flyspell-mode on using a positive arg. For use in hooks."
2256 ; (flyspell-mode 1))
2259 ; Outline-minor-mode key map
2260 (define-prefix-command 'cm-map nil "Outline-")
2262 (define-key cm-map "q" 'outline-hide-sublevels) ; Hide everything but the top-level headings
2263 (define-key cm-map "t" 'outline-hide-body) ; Hide everything but headings (all body lines)
2264 (define-key cm-map "o" 'outline-hide-other) ; Hide other branches
2265 (define-key cm-map "c" 'outline-hide-entry) ; Hide this entry's body
2266 (define-key cm-map "l" 'outline-hide-leaves) ; Hide body lines in this entry and sub-entries
2267 (define-key cm-map "d" 'outline-hide-subtree) ; Hide everything in this entry and sub-entries
2269 (define-key cm-map "a" 'outline-show-all) ; Show (expand) everything
2270 (define-key cm-map "e" 'outline-show-entry) ; Show this heading's body
2271 (define-key cm-map "i" 'outline-show-children) ; Show this heading's immediate child sub-headings
2272 (define-key cm-map "k" 'outline-show-branches) ; Show all sub-headings under this heading
2273 (define-key cm-map "s" 'outline-show-subtree) ; Show (expand) everything in this heading & below
2275 (define-key cm-map "u" 'outline-up-heading) ; Up
2276 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
2277 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
2278 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
2279 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
2280 (global-set-key "\M-o" cm-map)
2281 ; fix up tmux xterm keys
2282 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
2283 (defun fix-up-tmux-keys ()
2284 "Fix up tmux xterm keys"
2287 (let ((x 2) (tkey ""))
2307 ;; ctrl + alt + shift
2309 (setq tkey "C-M-S-"))
2312 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
2313 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
2314 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
2315 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
2317 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
2319 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
2321 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
2323 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
2325 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2327 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2329 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
2331 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
2333 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
2335 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
2337 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
2339 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
2341 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
2343 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
2345 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
2347 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
2349 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
2351 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
2353 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
2355 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
2357 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
2359 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
2361 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
2363 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
2365 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
2367 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
2374 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
2376 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
2377 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
2378 (if (or (buffer-modified-p)
2379 (verify-visited-file-modtime)
2380 (< (* 8 1024 1024) (buffer-size))
2381 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
2383 (clear-visited-file-modtime)
2385 (ad-activate 'ask-user-about-supersession-threat)
2389 #+BEGIN_SRC emacs-lisp
2393 (or (getenv "EMACS_SERVER_NAME")
2395 (unless (server-running-p)
2396 (global-set-key "\C-xp" 'server-edit)
2403 #+BEGIN_SRC emacs-lisp
2404 (provide 'don-configuration)