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 (defun malb/helm-omni (&rest arg)
413 ;; just in case someone decides to pass an argument, helm-omni won't fail.
415 (unless helm-source-buffers-list
416 (setq helm-source-buffers-list
417 (helm-make-source "Buffers" 'helm-source-buffers)))
421 (if (projectile-project-p)
422 '(helm-source-projectile-buffers-list
423 helm-source-buffers-list)
424 '(helm-source-buffers-list)) ;; list of all open buffers
426 `(((name . "Virtual Workspace")
427 (candidates . ,(--map (cons (eyebrowse-format-slot it) (car it))
428 (eyebrowse--get 'window-configs)))
429 (action . (lambda (candidate)
430 (eyebrowse-switch-to-window-config candidate)))))
432 (if (projectile-project-p)
433 '(helm-source-projectile-recentf-list
435 '(helm-source-recentf)) ;; all recent files
437 ;; always make some common files easily accessible
438 ;;'(((name . "Common Files")
439 ;; (candidates . malb/common-file-targets)
440 ;; (action . (("Open" . (lambda (x) (find-file (eval x))))))))
442 '(helm-source-files-in-current-dir
444 helm-source-bookmarks
445 helm-source-buffer-not-found ;; ask to create a buffer otherwise
447 "*Helm all the things*"))
451 :bind (("M-x" . helm-M-x)
452 ("C-x C-f" . helm-find-files)
453 ("C-x b" . helm-buffers-list) ; malb/helm-omni)
454 ("C-x C-b" . helm-buffers-list) ; malb/helm-omni)
455 ("C-c <SPC>" . helm-all-mark-rings))
457 (require 'helm-config)
458 (require 'helm-for-files)
459 (require 'helm-bookmark)
462 (define-key global-map [remap find-file] 'helm-find-files)
463 (define-key global-map [remap occur] 'helm-occur)
464 (define-key global-map [remap list-buffers] 'helm-buffers-list)
465 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
466 (unless (boundp 'completion-in-region-function)
467 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
468 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
469 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
474 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
476 #+BEGIN_SRC emacs-lisp
477 (use-package helm-flx
480 ;; these are helm configs, but they kind of fit here nicely
481 (setq helm-M-x-fuzzy-match t
482 helm-bookmark-show-location t
483 helm-buffers-fuzzy-matching t
484 helm-completion-in-region-fuzzy-match t
485 helm-file-cache-fuzzy-match t
486 helm-imenu-fuzzy-match t
487 helm-mode-fuzzy-match t
488 helm-locate-fuzzy-match nil
490 helm-recentf-fuzzy-match nil
491 helm-semantic-fuzzy-match t)
495 #+BEGIN_SRC emacs-lisp
497 ;;; stolen from https://github.com/malb/emacs.d/blob/master/malb.org
498 (defun malb/helm-swoop-pre-fill ()
499 (thing-at-point 'symbol))
500 (defvar malb/helm-swoop-ignore-major-mode "List of major modes to ignore for helm-swoop")
501 (setq malb/helm-swoop-ignore-major-mode '(dired-mode
502 paradox-menu-mode doc-view-mode pdf-view-mode
503 mu4e-headers-mode org-mode markdown-mode latex-mode
504 ein:notebook-multilang-mode))
506 (defun malb/swoop-or-search ()
508 (if (or (> (buffer-size) 1048576) ;; helm-swoop can be slow on big buffers
509 (memq major-mode malb/helm-swoop-ignore-major-mode))
513 (use-package helm-swoop
516 :bind (("C-c o" . helm-multi-swoop-org)
517 ("C-s" . malb/swoop-or-search)
518 ("C-M-s" . helm-multi-swoop-all))
521 (setq helm-swoop-pre-input-function #'malb/helm-swoop-pre-fill
522 helm-swoop-split-with-multiple-windows nil
523 helm-swoop-split-direction #'split-window-horizontally
524 helm-swoop-split-window-function 'helm-default-display-buffer
525 helm-swoop-speed-or-color t)
527 ;; https://emacs.stackexchange.com/questions/28790/helm-swoop-how-to-make-it-behave-more-like-isearch
528 (defun malb/helm-swoop-C-s ()
530 (if (boundp 'helm-swoop-pattern)
531 (if (equal helm-swoop-pattern "")
532 (previous-history-element 1)
536 (bind-key "C-S-s" #'helm-swoop-from-isearch isearch-mode-map)
537 (bind-key "C-S-s" #'helm-multi-swoop-all-from-helm-swoop helm-swoop-map)
538 (bind-key "C-r" #'helm-previous-line helm-swoop-map)
539 (bind-key "C-s" #'malb/helm-swoop-C-s helm-swoop-map)
540 (bind-key "C-r" #'helm-previous-line helm-multi-swoop-map)
541 (bind-key "C-s" #'malb/helm-swoop-C-s helm-multi-swoop-map))
546 #+BEGIN_SRC emacs-lisp
549 :config (setq helm-ag-base-command "ag --nocolor --nogroup"
550 helm-ag-command-option "--all-text"
551 helm-ag-insert-at-point 'symbol
552 helm-ag-fuzzy-match t
553 helm-ag-use-temp-buffer t
554 helm-ag-use-grep-ignore-list t
555 helm-ag-use-agignore t))
558 #+BEGIN_SRC emacs-lisp
559 (use-package helm-descbinds
561 :bind ("C-h b" . helm-descbinds)
562 :init (fset 'describe-bindings 'helm-descbinds))
566 #+BEGIN_SRC emacs-lisp
567 (use-package helm-c-yasnippet
569 :bind ("C-c h y" . helm-yas-complete)
571 (setq helm-yas-space-match-any-greedy t)))
574 #+BEGIN_SRC emacs-lisp
575 (use-package helm-org-rifle
578 (defun malb/helm-org-rifle-agenda-files (arg)
580 (let ((current-prefix-arg nil))
582 ((equal arg 4) (call-interactively #'helm-org-rifle-agenda-files nil))
583 ((equal arg 16) (helm-org-rifle-occur-agenda-files))
584 (t (helm-org-agenda-files-headings)))))))
587 This can be used to link things pretty quickly if necessary
588 #+BEGIN_SRC emacs-lisp
589 (use-package helm-google
591 :bind ("C-c h g" . helm-google)
593 (progn (add-to-list 'helm-google-actions
594 '("Copy URL" . (lambda (candidate)
596 (replace-regexp-in-string
597 "https://.*q=\\(.*\\)\&sa=.*"
603 (add-to-list 'helm-google-actions
604 '("Org Store Link" . (lambda (candidate)
605 (let ((title (car (split-string candidate "[\n]+")))
607 (replace-regexp-in-string
608 "https://.*q=\\(.*\\)\&sa=.*"
610 (push (list url title) org-stored-links))))
615 ** Projectile -- Project management
616 #+begin_src emacs-lisp
617 (use-package projectile
619 :bind (("<f5>" . projectile-compile-project)
620 ("<f6>" . next-error))
622 (use-package magit :ensure t)
623 (require 'helm-projectile)
626 (setq projectile-make-test-cmd "make check"
627 projectile-switch-project-action 'helm-projectile
628 projectile-mode-line '(:eval (format "»{%s}" (projectile-project-name))))
630 (projectile-global-mode)))
634 #+begin_src emacs-lisp
635 (use-package helm-projectile
638 (defvar malb/helm-source-file-not-found
639 (helm-build-dummy-source
644 'helm-projectile-sources-list
645 malb/helm-source-file-not-found t)
647 (helm-delete-action-from-source
648 "Grep in projects `C-s'"
649 helm-source-projectile-projects)
651 (helm-add-action-to-source
652 "Grep in projects `C-s'"
653 'helm-do-ag helm-source-projectile-projects 4)))
656 #+BEGIN_SRC emacs-lisp
659 :bind ("M-z" . avy-zap-up-to-char-dwim))
662 #+BEGIN_SRC emacs-lisp
664 :bind (("C-c 2" . my/hydra-orgmodes/body)
665 ("C-c @" . my/hydra-orgmodes/body)
666 ("C-c #" . my/hydra-outline/body)
667 ("C-c 3" . my/hydra-outline/body)
670 (defhydra my/hydra-orgmodes (:color blue :hint nil)
672 _n_: notes _c_: chaim _w_: wildman _o_: ool
673 _u_: uddin _s_: steve _r_: refile _f_: fh
674 _p_: read papers _R_: paper notes
679 ("n" (find-file "~/projects/org-notes/notes.org"))
680 ("c" (find-file "~/projects/org-notes/chaim.org"))
681 ("w" (find-file "~/projects/org-notes/wildman.org"))
682 ("u" (find-file "~/projects/org-notes/uddin.org"))
683 ("o" (find-file "~/projects/org-notes/ool.org"))
684 ("f" (find-file "~/projects/org-notes/fh.org"))
685 ("s" (find-file "~/projects/org-notes/sndservers.org"))
686 ("r" (find-file "~/projects/org-notes/refile.org"))
687 ("p" (find-file "~/projects/research/papers_to_read.org"))
688 ("R" (find-file "~/projects/research/paper_notes.org"))
689 ("h" (find-file "~/projects/org-notes/hpcbio.org"))
694 ;; from https://github.com/abo-abo/hydra/wiki/Emacs
695 (defhydra my/hydra-outline (:color pink :hint nil)
698 ^^^^^^------------------------------------------------------
699 _q_: sublevels _a_: all _u_: up
700 _t_: body _e_: entry _n_: next visible
701 _o_: other _i_: children _p_: previous visible
702 _c_: entry _k_: branches _f_: forward same level
703 _l_: leaves _s_: subtree _b_: backward same level
708 ("q" outline-hide-sublevels) ; Hide everything but the top-level headings
709 ("t" outline-hide-body) ; Hide everything but headings (all body lines)
710 ("o" outline-hide-other) ; Hide other branches
711 ("c" outline-hide-entry) ; Hide this entry's body
712 ("l" outline-hide-leaves) ; Hide body lines in this entry and sub-entries
713 ("d" outline-hide-subtree) ; Hide everything in this entry and sub-entries
715 ("a" outline-show-all) ; Show (expand) everything
716 ("e" outline-show-entry) ; Show this heading's body
717 ("i" outline-show-children) ; Show this heading's immediate child sub-headings
718 ("k" outline-show-branches) ; Show all sub-headings under this heading
719 ("s" outline-show-subtree) ; Show (expand) everything in this heading & below
721 ("u" outline-up-heading) ; Up
722 ("n" outline-next-visible-heading) ; Next
723 ("p" outline-previous-visible-heading) ; Previous
724 ("f" outline-forward-same-level) ; Forward - same level
725 ("b" outline-backward-same-level) ; Backward - same level
731 #+BEGIN_SRC emacs-lisp
732 (add-to-list 'tramp-methods '("vcsh"
733 (tramp-login-program "vcsh")
737 (tramp-remote-shell "/bin/sh")
738 (tramp-remote-shell-args
742 #+BEGIN_SRC emacs-lisp
746 (setq-default reftex-default-bibliography
747 '("~/projects/research/references.bib")))
750 #+BEGIN_SRC emacs-lisp
752 :config (setq bibtex-user-optional-fields
753 (quote (("annote" "Personal annotation (ignored)")
761 #+BEGIN_SRC emacs-lisp
766 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
767 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
768 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
769 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
770 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
771 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
772 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
773 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
774 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
775 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
776 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
778 (setq-default reftex-plug-into-AUCTeX t)
779 ;; support fake section headers
780 (setq TeX-outline-extra
786 ;; add font locking to the headers
787 (font-lock-add-keywords
789 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
790 0 'font-lock-keyword-face t)
791 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
792 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
793 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
794 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
795 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
797 ;; use smart quotes by default instead of `` and ''
798 ;; taken from http://kieranhealy.org/esk/kjhealy.html
799 (setq TeX-open-quote "“")
800 (setq TeX-close-quote "”")
802 ;; (TeX-add-style-hook
807 ;; (custom-set-variables
808 ;; '(font-latex-user-keyword-classes
811 ;; font-lock-function-name-face 2 (command 1 t))))
813 (setq-default TeX-parse-self t)
814 (setq-default TeX-auto-save t)
815 (setq-default TeX-master nil)
821 (if (boundp 'reftex-ref-style-alist)
823 'reftex-ref-style-alist
824 '("Cleveref" "cleveref"
825 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
826 (reftex-ref-style-activate "Cleveref")
828 '("cref" TeX-arg-ref)
829 '("Cref" TeX-arg-ref)
830 '("cpageref" TeX-arg-ref)
831 '("Cpageref" TeX-arg-ref)))))
834 '(add-to-list 'LaTeX-fill-excluded-macros
837 (use-package font-latex
839 (setq font-latex-match-reference-keywords
861 (setq font-latex-fontify-script nil)
862 (setq font-latex-fontify-sectioning (quote color))
863 (setq font-latex-script-display (quote (nil)))
868 #+BEGIN_SRC emacs-lisp
873 :bind (:map ess-mode-map
874 ("C-c C-R" . dla/ess-region-remote-eval))
876 (defun ess-change-directory (path)
877 "Set the current working directory to PATH for both *R* and Emacs."
878 (interactive "DDirectory to change to: ")
880 (when (file-exists-p path)
881 (ess-command (concat "setwd(\"" path "\")\n"))
882 ;; use file-name-as-directory to ensure it has trailing /
883 (setq default-directory (file-name-as-directory path))))
884 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
885 ;; outlining support for ess modes
890 (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
891 (defun outline-level ()
892 (cond ((looking-at "^##### ") 1)
893 ((looking-at "^#### ") 2)
894 ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
897 (defun dla/ess-region-remote-eval (start end)
898 "Evaluate region in a remote ESS instance"
900 (shell-command-on-region start end "eval_r" (get-buffer-create "***essregionremoteeval***"))
901 kill-buffer "***essregionremoteeval***")
902 ;; Don't restore history or save workspace image
903 '(inferior-R-args "--no-restore-history --no-save")
908 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
910 #+BEGIN_SRC emacs-lisp
911 (use-package rainbow-mode
912 ;; add ess to the x major mode
913 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
914 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
919 #+BEGIN_SRC emacs-lisp
920 (use-package polymode
923 (use-package poly-noweb)
924 (use-package poly-markdown)
925 :mode ("\\.Snw" . poly-noweb+r-mode)
926 :mode ("\\.Rnw" . poly-noweb+r-mode)
927 :mode ("\\.Rmd" . poly-markdown+r-mode)
933 #+BEGIN_SRC emacs-lisp
934 (use-package outline-magic)
937 #+BEGIN_SRC emacs-lisp
938 (use-package writeroom-mode
940 (defun my/writing-mode ()
941 "Start my writing mode; enable visual-line-mode and auto-fill-mode"
946 (visual-line-mode -1)
948 (visual-fill-column-mode -1)
952 (visual-fill-column-mode 1)
957 ** GhostText/Atomic Chrome
958 #+BEGIN_SRC emacs-lisp
959 (use-package atomic-chrome
961 (ignore-errors (atomic-chrome-start-server))
962 (setq atomic-chrome-buffer-open-style 'full)
967 :ID: 6fcf218b-a762-4c37-9339-a8202ddeb544
969 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
970 #+BEGIN_SRC emacs-lisp
971 (use-package multiple-cursors
972 :bind (("C-;" . mc/mark-all-dwim)
973 ("C-<" . mc/mark-previous-like-this)
974 ("C->" . mc/mark-next-like-this)
975 ("C-S-c C-S-c" . mc/edit-lines))
979 #+BEGIN_SRC emacs-lisp
980 (use-package web-mode
982 (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . web-mode))
983 (setq web-mode-enable-engine-detection t)
984 (setq web-mode-engines-alist
985 '(("template-toolkit" . "\\.tmpl\\'")))
989 #+BEGIN_SRC emacs-lisp
990 (use-package spamassassin-mode
996 #+BEGIN_SRC emacs-lisp
997 (use-package password-store
999 :commands password-store-edit password-store-create
1005 #+BEGIN_SRC emacs-lisp
1006 (use-package message
1009 :mode "muttng-[a-z0-9]+-[0-9]+-"
1010 :mode "mutt-[a-z0-9]+-[0-9]+-"
1011 :hook 'my/message-mode-settings
1012 :hook 'turn-on-flyspell
1013 :bind (:map message-mode-map
1014 ("C-c C-a" . my/post-attach-file))
1016 (defun my/message-mode-settings ()
1017 (font-lock-add-keywords nil
1018 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1019 (0 'message-multiply-quoted-text-face))
1020 ("^[ \t]*>[ \t]*>.*$"
1021 (0 'message-double-quoted-text-face))))
1024 (defun my/post-attach-file ()
1025 "Prompt for an attachment."
1027 (let ((file (read-file-name "Attach file: " nil nil t nil))
1028 (description (string-read "Description: ")))
1029 (my/header-attach-file file description)))
1031 (defun my/header-attach-file (file description)
1032 "Attach a FILE to the current message (works with Mutt).
1033 Argument DESCRIPTION MIME description."
1034 (interactive "fAttach file: \nsDescription: ")
1035 (when (> (length file) 0)
1040 (goto-char (point-min))
1041 (search-forward-regexp "^$")
1042 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1044 (message (concat "Attached '" file "'."))
1045 (setq post-has-attachment t))))))
1047 (setq mail-yank-prefix "> ")
1051 #+BEGIN_SRC emacs-lisp
1052 (use-package muttrc-mode
1059 ** Reverting buffers
1060 #+BEGIN_SRC emacs-lisp
1061 (setq global-auto-revert-non-file-buffers t
1062 global-auto-revert-ignore-modes '(pdf-view-mode)
1063 auto-revert-verbose nil)
1064 (global-auto-revert-mode 1)
1067 ** Use-package and load things
1068 #+BEGIN_SRC emacs-lisp
1074 ** Agenda Configuration
1075 #+BEGIN_SRC emacs-lisp
1076 :mode ("\\.\\(org\\|org_archive\\|txt\\)\\'" . org-mode)
1077 :bind (("C-c l" . org-store-link)
1078 ("C-c a" . org-agenda)
1079 ("C-c b" . org-iswitchb))
1081 (setq-default org-log-done 'time)
1082 (setq-default org-agenda-ndays 5)
1084 ;; agenda configuration
1085 ;; Do not dim blocked tasks
1086 (setq org-agenda-dim-blocked-tasks nil)
1087 (setq org-agenda-inhibit-startup t)
1088 (setq org-agenda-use-tag-inheritance nil)
1090 ;; Compact the block agenda view
1091 (setq org-agenda-compact-blocks t)
1093 ;; Custom agenda command definitions
1094 (setq org-agenda-custom-commands
1095 (quote (("N" "Notes" tags "NOTE"
1096 ((org-agenda-overriding-header "Notes")
1097 (org-tags-match-list-sublevels t)))
1098 ("h" "Habits" tags-todo "STYLE=\"habit\""
1099 ((org-agenda-overriding-header "Habits")
1100 (org-agenda-sorting-strategy
1101 '(todo-state-down effort-up category-keep))))
1105 ((org-agenda-overriding-header "Tasks to Refile")
1106 (org-tags-match-list-sublevels nil)))
1107 (tags-todo "-CANCELLED/!"
1108 ((org-agenda-overriding-header "Stuck Projects")
1109 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
1110 (org-agenda-sorting-strategy
1112 (tags-todo "-HOLD-CANCELLED/!"
1113 ((org-agenda-overriding-header "Projects")
1114 (org-agenda-skip-function 'bh/skip-non-projects)
1115 (org-tags-match-list-sublevels 'indented)
1116 (org-agenda-sorting-strategy
1118 (tags-todo "-CANCELLED/!NEXT"
1119 ((org-agenda-overriding-header (concat "Project Next Tasks"
1120 (if bh/hide-scheduled-and-waiting-next-tasks
1122 " (including WAITING and SCHEDULED tasks)")))
1123 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1124 (org-tags-match-list-sublevels t)
1125 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1126 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1127 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1128 (org-agenda-sorting-strategy
1129 '(todo-state-down effort-up category-keep))))
1130 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1131 ((org-agenda-overriding-header (concat "Project Subtasks"
1132 (if bh/hide-scheduled-and-waiting-next-tasks
1134 " (including WAITING and SCHEDULED tasks)")))
1135 (org-agenda-skip-function 'bh/skip-non-project-tasks)
1136 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1137 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1138 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1139 (org-agenda-sorting-strategy
1141 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1142 ((org-agenda-overriding-header (concat "Standalone Tasks"
1143 (if bh/hide-scheduled-and-waiting-next-tasks
1145 " (including WAITING and SCHEDULED tasks)")))
1146 (org-agenda-skip-function 'bh/skip-project-tasks)
1147 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1148 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1149 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1150 (org-agenda-sorting-strategy
1152 (tags-todo "-CANCELLED+WAITING|HOLD/!"
1153 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
1154 (org-agenda-skip-function 'bh/skip-stuck-projects)
1155 (org-tags-match-list-sublevels nil)
1156 (org-agenda-todo-ignore-scheduled t)
1157 (org-agenda-todo-ignore-deadlines t)))
1159 ((org-agenda-overriding-header "Tasks to Archive")
1160 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1161 (org-tags-match-list-sublevels nil))))
1164 ; org mode agenda files
1165 (setq org-agenda-files
1166 (quote ("~/projects/org-notes/debbugs.org"
1167 "~/projects/org-notes/notes.org"
1168 "~/projects/org-notes/holidays.org"
1169 "~/projects/org-notes/refile.org"
1170 "~/projects/org-notes/diary.org"
1171 "~/projects/org-notes/ool.org"
1172 "~/projects/org-notes/sndservers.org"
1173 "~/projects/org-notes/chaim.org"
1174 "~/projects/org-notes/wildman.org"
1175 "~/projects/org-notes/uddin.org"
1176 "~/projects/org-notes/reviews.org"
1177 "~/org-mode/from-mobile.org"
1178 "~/projects/org-notes/fh.org")))
1180 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
1181 (set-register ?r (cons 'file "~/projects/org-notes/refile.org"))
1182 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
1183 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
1184 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
1185 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
1186 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
1187 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
1188 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
1189 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
1190 (defun org-agenda-timeline-all (&optional arg)
1193 (dolist (org-agenda-file org-agenda-files)
1194 (insert-file-contents org-agenda-file nil)
1195 (goto-char (point-max))
1197 (write-file "/tmp/timeline.org")
1198 (org-agenda arg "L")))
1199 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
1203 #+BEGIN_SRC emacs-lisp
1204 (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")))
1205 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
1207 (setq org-default-notes-file "~/projects/org-notes/notes.org")
1208 (setq org-id-link-to-org-use-id 'use-existing)
1210 ** Capture Templates
1211 #+BEGIN_SRC emacs-lisp
1212 (setq org-capture-templates ;; mail-specific note template, identified by "m"
1213 '(("m" "Mail" entry (file "~/projects/org-notes/refile.org")
1214 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
1215 ("t" "todo" entry (file "~/projects/org-notes/refile.org")
1216 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
1217 ("r" "respond" entry (file "~/projects/org-notes/refile.org")
1218 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
1219 ("n" "note" entry (file "~/projects/org-notes/refile.org")
1220 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
1221 ("s" "schedule" entry (file "~/projects/org-notes/refile.org")
1222 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
1223 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
1224 "* %?\n%U\n" :clock-in t :clock-resume t)
1225 ("w" "org-protocol" entry (file "~/projects/org-notes/refile.org")
1226 "* TODO Review %c\n%U\n" :immediate-finish t)
1227 ("M" "Meeting" entry (file "~/projects/org-notes/refile.org")
1228 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
1229 ("S" "Seminar" entry (file "~/projects/org-notes/refile.org")
1230 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
1231 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
1232 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
1233 ("p" "Phone call" entry (file "~/projects/org-notes/refile.org")
1234 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
1235 ("J" "job" entry (file "~/projects/org-notes/refile.org")
1236 "* 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)
1237 ("h" "Habit" entry (file "~/projects/org-notes/refile.org")
1238 "* 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")
1242 ;; Remove empty LOGBOOK drawers on clock out
1243 (defun bh/remove-empty-drawer-on-clock-out ()
1246 (beginning-of-line 0)
1247 (org-remove-empty-drawer-at (point))))
1249 (defun my/org-add-id ()
1252 (if (org-current-level)
1261 ** Org mode key bindings
1262 #+BEGIN_SRC emacs-lisp
1263 ; org mode configuration from http://doc.norang.ca/org-mode.html
1264 ;; Custom Key Bindings
1265 (global-set-key (kbd "<f12>") 'org-agenda)
1266 ; (global-set-key (kbd "<f5>") 'bh/org-todo)
1267 (global-set-key (kbd "<S-f5>") 'bh/widen)
1268 (global-set-key (kbd "<f7>") 'bh/set-truncate-lines)
1269 (global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
1270 (global-set-key (kbd "<f9> <f9>") 'bh/show-org-agenda)
1271 (global-set-key (kbd "<f9> b") 'bbdb)
1272 (global-set-key (kbd "<f9> c") 'calendar)
1273 (global-set-key (kbd "<f9> f") 'boxquote-insert-file)
1274 (global-set-key (kbd "<f9> h") 'bh/hide-other)
1275 (global-set-key (kbd "<f9> n") 'bh/toggle-next-task-display)
1276 (global-set-key (kbd "<f9> w") 'widen)
1278 ; change the outline mode prefix from C-c @ to C-c C-2
1279 (setq outline-minor-mode-prefix "C-c C-2")
1280 ;(add-hook 'outline-minor-mode-hook
1281 ; (lambda () (local-set-key (kbd "C-c C-2")
1282 ; outline-mode-prefix-map)))
1284 (global-set-key (kbd "<f9> I") 'bh/punch-in)
1285 (global-set-key (kbd "<f9> O") 'bh/punch-out)
1287 (global-set-key (kbd "<f9> o") 'bh/make-org-scratch)
1289 (global-set-key (kbd "<f9> r") 'boxquote-region)
1290 (global-set-key (kbd "<f9> s") 'bh/switch-to-scratch)
1292 (global-set-key (kbd "<f9> t") 'bh/insert-inactive-timestamp)
1293 (global-set-key (kbd "<f9> T") 'bh/toggle-insert-inactive-timestamp)
1295 (global-set-key (kbd "<f9> v") 'visible-mode)
1296 (global-set-key (kbd "<f9> l") 'org-toggle-link-display)
1297 (global-set-key (kbd "<f9> SPC") 'bh/clock-in-last-task)
1298 (global-set-key (kbd "C-<f9>") 'previous-buffer)
1299 (global-set-key (kbd "M-<f9>") 'org-toggle-inline-images)
1300 (global-set-key (kbd "C-x n r") 'narrow-to-region)
1301 (global-set-key (kbd "C-<f10>") 'next-buffer)
1302 (global-set-key (kbd "<f11>") 'org-clock-goto)
1303 (global-set-key (kbd "C-<f11>") 'org-clock-in)
1304 (global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)
1305 (global-set-key (kbd "C-c c") 'org-capture)
1308 ** Utility Functions
1309 #+BEGIN_SRC emacs-lisp
1310 (defun bh/hide-other ()
1313 (org-back-to-heading 'invisible-ok)
1319 (defun bh/set-truncate-lines ()
1320 "Toggle value of truncate-lines and refresh window display."
1322 (setq truncate-lines (not truncate-lines))
1323 ;; now refresh window display (an idiom from simple.el):
1325 (set-window-start (selected-window)
1326 (window-start (selected-window)))))
1328 (defun bh/make-org-scratch ()
1330 (find-file "/tmp/publish/scratch.org")
1331 (gnus-make-directory "/tmp/publish"))
1333 (defun bh/switch-to-scratch ()
1335 (switch-to-buffer "*scratch*"))
1337 (setq org-use-fast-todo-selection t)
1338 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1340 ; create function to create headlines in file. This comes from
1341 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
1342 (defun my/org-add-ids-to-headlines-in-file ()
1343 "Add ID properties to all headlines in the current file which
1344 do not already have one."
1346 (org-map-entries 'org-id-get-create))
1347 ; if we wanted to do this to every buffer, do the following:
1348 ; (add-hook 'org-mode-hook
1350 ; (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
1353 #+BEGIN_SRC emacs-lisp
1354 (setq org-todo-keywords
1355 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
1356 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
1358 (setq org-todo-keyword-faces
1359 (quote (("TODO" :foreground "red" :weight bold)
1360 ("NEXT" :foreground "blue" :weight bold)
1361 ("DONE" :foreground "forest green" :weight bold)
1362 ("WAITING" :foreground "orange" :weight bold)
1363 ("HOLD" :foreground "magenta" :weight bold)
1364 ("CANCELLED" :foreground "forest green" :weight bold)
1365 ("MEETING" :foreground "forest green" :weight bold)
1366 ("PHONE" :foreground "forest green" :weight bold))))
1368 (setq org-todo-state-tags-triggers
1369 (quote (("CANCELLED" ("CANCELLED" . t))
1370 ("WAITING" ("WAITING" . t))
1371 ("HOLD" ("WAITING") ("HOLD" . t))
1372 (done ("WAITING") ("HOLD"))
1373 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1374 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1375 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1379 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1380 ; add ids on creation of nodes
1381 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
1384 ; resolve clocks after 10 minutes of idle; use xprintidle
1385 ; (setq org-clock-idle-time 10)
1386 ; (setq org-clock-x11idle-program-name "xprintidle")
1388 ; this is from http://doc.norang.ca/org-mode.html#Capture
1389 ; use C-M-r for org mode capture
1390 (global-set-key (kbd "C-M-r") 'org-capture)
1392 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1393 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1394 (org-agenda-files :maxlevel . 9))))
1396 ; Use full outline paths for refile targets - we file directly with IDO
1397 (setq org-refile-use-outline-path t)
1399 ; Targets complete directly with IDO
1400 (setq org-outline-path-complete-in-steps nil)
1402 ; Allow refile to create parent tasks with confirmation
1403 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1405 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
1406 ; (setq org-completion-use-ido t)
1407 ; (setq ido-everywhere t)
1408 ; (setq ido-max-directory-size 100000)
1409 ; (ido-mode (quote both))
1410 ; ; Use the current window when visiting files and buffers with ido
1411 ; (setq ido-default-file-method 'selected-window)
1412 ; (setq ido-default-buffer-method 'selected-window)
1413 ; ; Use the current window for indirect buffer display
1414 ; (setq org-indirect-buffer-display 'current-window)
1417 ;;;; Refile settings
1418 ; Exclude DONE state tasks from refile targets
1419 (defun bh/verify-refile-target ()
1420 "Exclude todo keywords with a done state from refile targets"
1421 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
1423 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1425 ;; ensure that emacsclient will show just the note to be edited when invoked
1426 ;; from Mutt, and that it will shut down emacsclient once finished;
1427 ;; fallback to legacy behavior when not invoked via org-protocol.
1428 (require 'org-protocol)
1429 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
1430 (setq my-org-protocol-flag nil)
1431 (defadvice org-capture-finalize (after delete-frame-at-end activate)
1432 "Delete frame at remember finalization"
1433 (progn (if my-org-protocol-flag (delete-frame))
1434 (setq my-org-protocol-flag nil)))
1435 (defadvice org-capture-refile (around delete-frame-after-refile activate)
1436 "Delete frame at remember refile"
1437 (if my-org-protocol-flag
1439 (setq my-org-protocol-flag nil)
1444 (defadvice org-capture-kill (after delete-frame-at-end activate)
1445 "Delete frame at remember abort"
1446 (progn (if my-org-protocol-flag (delete-frame))
1447 (setq my-org-protocol-flag nil)))
1448 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
1449 (setq my-org-protocol-flag t))
1451 (defadvice org-insert-todo-heading (after dla/create-id activate)
1456 (add-to-list 'org-modules 'org-habit)
1458 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
1459 (defun open-mail-in-mutt (message)
1460 "Open a mail message in Mutt, using an external terminal.
1462 Message can be specified either by a path pointing inside a
1463 Maildir, or by Message-ID."
1464 (interactive "MPath or Message-ID: ")
1466 (format "faf xterm -e \"%s %s\""
1467 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
1469 ;; add support for "mutt:ID" links
1470 (org-add-link-type "mutt" 'open-mail-in-mutt)
1472 (defun my-org-mode-setup ()
1473 ; (load-library "reftex")
1474 (and (buffer-file-name)
1475 (file-exists-p (buffer-file-name))
1477 ; (reftex-parse-all)
1478 (reftex-set-cite-format
1479 '((?b . "[[bib:%l][%l-bib]]")
1480 (?n . "[[notes:%l][%l-notes]]")
1482 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
1484 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
1485 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
1486 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
1487 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
1489 (add-hook 'org-mode-hook 'my-org-mode-setup)
1491 (defun org-mode-reftex-search ()
1493 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
1495 (defun open-research-paper (bibtexkey)
1496 "Open a paper by bibtex key"
1497 (interactive "bibtex key: ")
1500 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1501 (org-add-link-type "papers" 'open-research-paper)
1502 (defun open-research-paper-pdf (bibtexkey)
1503 "Open a paper pdf by bibtex key"
1504 (interactive "bibtex key: ")
1506 (format "%s -p evince_annot %s"
1507 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1508 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
1510 (add-to-list 'org-link-abbrev-alist
1512 "~/projects/research/paper_notes.org::#%s"))
1514 ; I pretty much always want hiearchical checkboxes
1515 (setq org-hierachical-checkbox-statistics nil)
1517 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
1518 (add-to-list 'org-structure-template-alist
1519 '("E" "\\begin{equation}\n?\n\\end{equation}"))
1522 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
1523 (defun my-rtcite-export-handler (path desc format)
1524 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
1525 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
1526 (match-string 1 path)))
1527 (path (substring path 0 (match-beginning 0))))
1528 (cond ((eq format 'latex)
1530 (equal 0 (search "rtcite:" desc)))
1531 (format "\\cite{%s}" search)
1532 (format "\\cite[%s]{%s}" desc search))))))
1534 (org-add-link-type "rtcite"
1536 'my-rtcite-export-handler)
1540 ** Org Mobile Configuration
1541 #+BEGIN_SRC emacs-lisp
1542 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
1543 (when (string= system-name "linnode")
1544 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
1545 (setq-default org-directory "/home/don/org-mode/")
1546 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
1550 #+BEGIN_SRC emacs-lisp
1551 ;; org mode ical export
1552 (setq org-icalendar-timezone "America/Los_Angeles")
1553 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
1554 ;; we already add the id manually
1555 (setq org-icalendar-store-UID t)
1558 ** General Org Babel Configuration
1559 #+BEGIN_SRC emacs-lisp
1560 ;; org babel support
1561 (org-babel-do-load-languages
1562 'org-babel-load-languages
1569 ;; use graphviz-dot for dot things
1570 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
1571 ;; org-babel-by-backend
1572 (defmacro org-babel-by-backend (&rest body)
1573 `(case (if (boundp 'backend)
1574 (org-export-backend-name backend)
1577 (defun my/fix-inline-images ()
1578 (when org-inline-image-overlays
1579 (org-redisplay-inline-images)))
1581 (add-hook 'org-babel-after-execute-hook
1582 'my/fix-inline-images)
1585 ** LaTeX configuration
1587 :ID: 7135ba17-6a50-4eed-84ca-b90afa5b12f8
1589 #+BEGIN_SRC emacs-lisp
1591 (add-to-list 'org-latex-classes
1593 "\\documentclass[11pt,oneside,article]{memoir}\n"
1594 ("\\section{%s}" . "\\section*{%s}")
1595 ("\\subsection{%s}" . "\\subsection*{%s}")
1596 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1597 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1598 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1600 (setq org-beamer-outline-frame-options "")
1601 (add-to-list 'org-latex-classes
1603 "\\documentclass[ignorenonframetext]{beamer}
1604 [NO-DEFAULT-PACKAGES]
1607 ("\\section{%s}" . "\\section*{%s}")
1608 ("\\subsection{%s}" . "\\subsection*{%s}")
1609 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1610 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1611 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1613 (add-to-list 'org-latex-classes
1615 "\\documentclass[11pt,oneside]{memoir}\n"
1616 ("\\chapter{%s}" . "\\chapter*{%s}")
1617 ("\\section{%s}" . "\\section*{%s}")
1618 ("\\subsection{%s}" . "\\subsection*{%s}")
1619 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
1621 (add-to-list 'org-latex-classes
1623 "\\documentclass[11pt]{letter}
1624 [NO-DEFAULT-PACKAGES]
1627 ("\\section{%s}" . "\\section*{%s}")
1628 ("\\subsection{%s}" . "\\subsection*{%s}")
1629 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1630 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1631 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1633 (add-to-list 'org-latex-classes
1635 "\\documentclass{dlacv}
1636 [NO-DEFAULT-PACKAGES]
1639 ("\\section{%s}" . "\\section*{%s}")
1640 ("\\subsection{%s}" . "\\subsection*{%s}")
1641 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1642 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1643 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1646 (add-to-list 'org-latex-classes
1648 "\\documentclass{dlaresume}
1649 [NO-DEFAULT-PACKAGES]
1652 ("\\section{%s}" . "\\section*{%s}")
1653 ("\\subsection{%s}" . "\\subsection*{%s}")
1654 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1655 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1656 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1659 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
1660 ;; but adapted to use latexmk 4.22 or higher.
1661 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
1663 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
1664 (setq org-latex-default-packages-alist
1666 ("" "unicode-math" t)
1668 (setq org-latex-packages-alist
1675 ("" "longtable" nil)
1678 ;; make equations larger
1679 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
1681 (defun org-create-formula--latex-header ()
1682 "Return LaTeX header appropriate for previewing a LaTeX snippet."
1683 (let ((info (org-combine-plists (org-export--get-global-options
1684 (org-export-get-backend 'latex))
1685 (org-export--get-inbuffer-options
1686 (org-export-get-backend 'latex)))))
1687 (org-latex-guess-babel-language
1688 (org-latex-guess-inputenc
1689 (org-splice-latex-header
1690 org-format-latex-header
1691 org-latex-default-packages-alist
1693 (plist-get info :latex-header)))
1697 ; support ignoring headers in org mode export to latex
1698 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
1699 (defadvice org-latex-headline (around my-latex-skip-headlines
1700 (headline contents info) activate)
1701 (if (member "ignoreheading" (org-element-property :tags headline))
1702 (setq ad-return-value contents)
1705 ;; keep latex logfiles
1707 (setq org-latex-remove-logfiles nil)
1709 ;; Resume clocking task when emacs is restarted
1710 (org-clock-persistence-insinuate)
1712 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
1713 (setq org-clock-history-length 23)
1714 ;; Resume clocking task on clock-in if the clock is open
1715 (setq org-clock-in-resume t)
1716 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
1717 ;; there are things like PHONE calls
1718 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
1719 ;; Separate drawers for clocking and logs
1720 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
1721 ;; Save clock data and state changes and notes in the LOGBOOK drawer
1722 (setq org-clock-into-drawer t)
1723 (setq org-log-into-drawer t)
1724 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
1725 (setq org-clock-out-remove-zero-time-clocks t)
1726 ;; Clock out when moving task to a done state
1727 (setq org-clock-out-when-done t)
1728 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
1729 (setq org-clock-persist t)
1730 ;; Do not prompt to resume an active clock
1731 (setq org-clock-persist-query-resume nil)
1732 ;; Enable auto clock resolution for finding open clocks
1733 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
1734 ;; Include current clocking task in clock reports
1735 (setq org-clock-report-include-clocking-task t)
1737 ;; the cache seems to be broken
1738 (setq org-element-use-cache nil)
1740 (defvar bh/keep-clock-running nil)
1742 (defun bh/is-task-p ()
1743 "Any task with a todo keyword and no subtask"
1747 (subtree-end (save-excursion (org-end-of-subtree t)))
1748 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1751 (while (and (not has-subtask)
1752 (< (point) subtree-end)
1753 (re-search-forward "^\*+ " subtree-end t))
1754 (when (member (org-get-todo-state) org-todo-keywords-1)
1755 (setq has-subtask t))))
1756 (and is-a-task (not has-subtask)))))
1757 (defun bh/is-project-p ()
1758 "Any task with a todo keyword subtask"
1762 (subtree-end (save-excursion (org-end-of-subtree t)))
1763 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1766 (while (and (not has-subtask)
1767 (< (point) subtree-end)
1768 (re-search-forward "^\*+ " subtree-end t))
1769 (when (member (org-get-todo-state) org-todo-keywords-1)
1770 (setq has-subtask t))))
1771 (and is-a-task has-subtask))))
1773 (defun bh/is-subproject-p ()
1774 "Any task which is a subtask of another project"
1775 (let ((is-subproject)
1776 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1778 (while (and (not is-subproject) (org-up-heading-safe))
1779 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1780 (setq is-subproject t))))
1781 (and is-a-task is-subproject)))
1784 (defun bh/clock-in-to-next (kw)
1785 "Switch a task from TODO to NEXT when clocking in.
1786 Skips capture tasks, projects, and subprojects.
1787 Switch projects and subprojects from NEXT back to TODO"
1788 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
1790 ((and (member (org-get-todo-state) (list "TODO"))
1793 ((and (member (org-get-todo-state) (list "NEXT"))
1797 (defun bh/punch-in (arg)
1798 "Start continuous clocking and set the default task to the
1799 selected task. If no task is selected set the Organization task
1800 as the default task."
1802 (setq bh/keep-clock-running t)
1803 (if (equal major-mode 'org-agenda-mode)
1805 ;; We're in the agenda
1807 (let* ((marker (org-get-at-bol 'org-hd-marker))
1808 (tags (org-with-point-at marker (org-get-tags-at))))
1809 (if (and (eq arg 4) tags)
1810 (org-agenda-clock-in '(16))
1811 (bh/clock-in-organization-task-as-default)))
1813 ;; We are not in the agenda
1817 ; Find the tags on the current task
1818 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
1819 (org-clock-in '(16))
1820 (bh/clock-in-organization-task-as-default)))))
1822 (defun bh/punch-out ()
1824 (setq bh/keep-clock-running nil)
1825 (when (org-clock-is-active)
1827 (org-agenda-remove-restriction-lock))
1829 (defun bh/clock-in-default-task ()
1831 (org-with-point-at org-clock-default-task
1834 (defun bh/clock-in-parent-task ()
1835 "Move point to the parent (project) task if any and clock in"
1836 (let ((parent-task))
1840 (while (and (not parent-task) (org-up-heading-safe))
1841 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1842 (setq parent-task (point))))
1844 (org-with-point-at parent-task
1846 (when bh/keep-clock-running
1847 (bh/clock-in-default-task)))))))
1849 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
1851 (defun bh/clock-in-organization-task-as-default ()
1853 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
1854 (org-clock-in '(16))))
1856 (defun bh/clock-out-maybe ()
1857 (when (and bh/keep-clock-running
1858 (not org-clock-clocking-in)
1859 (marker-buffer org-clock-default-task)
1860 (not org-clock-resolving-clocks-due-to-idleness))
1861 (bh/clock-in-parent-task)))
1863 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1866 (defun bh/clock-in-task-by-id (id)
1867 "Clock in a task by id"
1868 (org-with-point-at (org-id-find id 'marker)
1869 (org-clock-in nil)))
1871 (defun bh/clock-in-last-task (arg)
1872 "Clock in the interrupted task if there is one
1873 Skip the default task and get the next one.
1874 A prefix arg forces clock in of the default task."
1876 (let ((clock-in-to-task
1878 ((eq arg 4) org-clock-default-task)
1879 ((and (org-clock-is-active)
1880 (equal org-clock-default-task (cadr org-clock-history)))
1881 (caddr org-clock-history))
1882 ((org-clock-is-active) (cadr org-clock-history))
1883 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
1884 (t (car org-clock-history)))))
1886 (org-with-point-at clock-in-to-task
1887 (org-clock-in nil))))
1890 (defun org-export-to-ods ()
1892 (let ((csv-file "data.csv"))
1893 (org-table-export csv-file "orgtbl-to-csv")
1894 (org-odt-convert csv-file "ods" 'open)))
1896 ; allow for zero-width-space to be a break in regexp too
1897 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
1898 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
1899 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
1901 ;; support inserting screen shots
1902 (defun my/org-insert-screenshot ()
1903 "Take a screenshot into a time stamped unique-named file in the
1904 same directory as the org-buffer and insert a link to this file."
1906 (defvar my/org-insert-screenshot/filename)
1907 (setq my/org-insert-screenshot/filename
1909 "Screenshot to insert: "
1911 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
1914 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
1915 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
1916 (org-display-inline-images))
1918 (defun my/fix-inline-images ()
1919 (when org-inline-image-overlays
1920 (org-redisplay-inline-images)))
1922 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
1924 ;; use xelatex to preview with imagemagick
1925 (add-to-list 'org-preview-latex-process-alist
1926 '(xelateximagemagick
1927 :programs ("xelatex" "convert")
1928 :description "pdf > png"
1929 :message "you need to install xelatex and imagemagick"
1931 :image-input-type "pdf"
1932 :image-output-type "png"
1933 :image-size-adjust (1.0 . 1.0)
1934 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
1935 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
1937 ;; use xelatex by default
1938 (setq org-preview-latex-default-process 'xelateximagemagick)
1940 ; from http://orgmode.org/Changes.html
1941 (defun my/org-repair-property-drawers ()
1942 "Fix properties drawers in current buffer.
1943 Ignore non Org buffers."
1945 (when (eq major-mode 'org-mode)
1946 (org-with-wide-buffer
1947 (goto-char (point-min))
1948 (let ((case-fold-search t)
1949 (inline-re (and (featurep 'org-inlinetask)
1950 (concat (org-inlinetask-outline-regexp)
1954 (unless (and inline-re (org-looking-at-p inline-re))
1956 (let ((end (save-excursion (outline-next-heading) (point))))
1958 (when (org-looking-at-p org-planning-line-re) (forward-line))
1959 (when (and (< (point) end)
1960 (not (org-looking-at-p org-property-drawer-re))
1962 (and (re-search-forward org-property-drawer-re end t)
1963 (eq (org-element-type
1964 (save-match-data (org-element-at-point)))
1966 (insert (delete-and-extract-region
1968 (min (1+ (match-end 0)) end)))
1969 (unless (bolp) (insert "\n"))))))))))))
1973 #+BEGIN_SRC emacs-lisp
1977 (use-package calfw-org
1980 (use-package org-gcal
1982 :config '((if (file-readable-p "~/.hide/org_gcal.el")
1983 (load-file "~/.hide/org_gcal.el"))
1988 #+BEGIN_SRC emacs-lisp
1992 ;; Show notification 10 minutes before event
1993 (setq appt-message-warning-time 10)
1994 ;; Disable multiple reminders
1995 (setq appt-display-interval appt-message-warning-time)
1996 (setq appt-display-mode-line nil)
1998 ;; add automatic reminders for appointments
1999 (defun my/org-agenda-to-appt ()
2001 (setq appt-time-msg-list nil)
2002 (org-agenda-to-appt))
2003 ;; add reminders when starting emacs
2004 (my/org-agenda-to-appt)
2005 ;; when rebuilding the agenda
2006 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
2007 "Pressing `r' on the agenda will also add appointments."
2008 (my/org-agenda-to-appt)
2010 ;; when saving all org buffers
2011 (defadvice org-save-all-org-buffers (after org-save-all-org-buffers-add-appts)
2012 "Re-add appts after saving all org buffers"
2013 (my/org-agenda-to-appt))
2014 ;; Display appointments as a window manager notification
2015 (setq appt-disp-window-function 'my/appt-display)
2016 (setq appt-delete-window-function (lambda () t))
2018 (setq my/appt-notification-app (concat (getenv "HOME") "/bin/appt_notification"))
2020 (defun my/appt-display (min-to-app new-time msg)
2021 (if (atom min-to-app)
2022 (start-process "my/appt-notification-app" nil my/appt-notification-app min-to-app msg)
2023 (dolist (i (number-sequence 0 (1- (length min-to-app))))
2024 (start-process "my/appt-notification-app" nil my/appt-notification-app
2025 (nth i min-to-app) (nth i msg))))
2032 #+BEGIN_SRC emacs-lisp
2037 #+BEGIN_SRC emacs-lisp
2038 (global-unset-key "\M-g")
2039 (global-set-key (kbd "M-g l") 'goto-line)
2043 #+BEGIN_SRC emacs-lisp
2044 (use-package debian-changelog
2046 :mode "debian/changelog"
2048 (setq debian-changelog-mailing-address "don@debian.org")
2049 (setq debian-changelog-full-name "Don Armstrong"))
2051 * Misc (uncharacterized)
2052 #+BEGIN_SRC emacs-lisp
2053 (setq calendar-latitude 38.6)
2054 (setq calendar-longitude -121.5)
2055 (setq case-fold-search t)
2056 (setq confirm-kill-emacs (quote y-or-n-p))
2057 (setq cperl-lazy-help-time nil)
2059 (setq display-time-24hr-format t)
2060 (setq display-time-day-and-date t)
2061 (display-time-mode 1)
2062 (global-font-lock-mode 1)
2064 (setq log-edit-keep-buffer t)
2065 (setq mail-user-agent (quote sendmail-user-agent))
2066 (setq markdown-enable-math t)
2067 (setq markdown-follow-wiki-link-on-enter nil)
2068 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
2069 (setq ps-footer-font-size (quote (8 . 10)))
2070 (setq ps-header-font-size (quote (8 . 10)))
2071 (setq ps-header-title-font-size (quote (10 . 10)))
2072 (setq ps-line-number-color "blue")
2073 (setq ps-print-footer t)
2074 (setq ps-print-footer-frame nil)
2075 (setq ps-print-only-one-header t)
2076 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
2078 (setq sentence-end-double-space nil)
2079 ; enable matching parenthesis
2082 (setq user-mail-address "don@donarmstrong.com")
2083 (setq vc-delete-logbuf-window nil)
2084 (setq vc-follow-symlinks t)
2086 ;; use git before SVN; use CVS earlier, because I have CVS
2087 ;; repositories inside of git directories
2088 (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
2090 ;; switch back to the old primary selection method
2091 (setq x-select-enable-clipboard nil)
2092 (setq x-select-enable-primary t)
2093 ; (setq mouse-drag-copy-region t)
2095 (fset 'perl-mode 'cperl-mode)
2096 ;;(load-file "cperl-mode.el")
2100 (global-set-key "\C-xp" 'server-edit)
2102 (setq-default auto-mode-alist (cons '("\.wml$" .
2103 (lambda () (html-mode) (auto-fill-mode)))
2107 ; use markdown mode for mdwn files
2108 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
2109 (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
2112 ;; tramp configuration
2113 (setq tramp-use-ssh-controlmaster-options nil)
2115 (setq-default c-indent-level 4)
2116 (setq-default c-brace-imaginary-offset 0)
2117 (setq-default c-brace-offset -4)
2118 (setq-default c-argdecl-indent 4)
2119 (setq-default c-label-offset -4)
2120 (setq-default c-continued-statement-offset 4)
2122 (setq-default indent-tabs-mode nil)
2123 (setq-default tab-width 4)
2126 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
2127 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
2128 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
2129 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
2130 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
2133 (defun insert-date ()
2134 "Insert date at point."
2136 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
2137 (global-set-key "\C-[d" 'insert-date)
2139 (defun unfill-paragraph (arg)
2140 "Pull this whole paragraph up onto one line."
2142 (let ((fill-column 10000))
2143 (fill-paragraph arg))
2146 (column-number-mode t)
2148 ; abbrev mode settings
2149 ; load abbreviations from
2150 (setq abbrev-file-name
2151 "~/.emacs_abbrev_def")
2153 ; read the abbrev file if it exists
2154 (if (file-exists-p abbrev-file-name)
2155 (quietly-read-abbrev-file))
2157 ; for now, use abbrev mode everywhere
2158 (setq default-abbrev-mode t)
2160 (desktop-load-default)
2162 '(icomplete-mode on)
2164 ;; custom-set-faces was added by Custom.
2165 ;; If you edit it by hand, you could mess it up, so be careful.
2166 ;; Your init file should contain only one such instance.
2167 ;; If there is more than one, they won't work right.
2168 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
2171 (put 'upcase-region 'disabled nil)
2172 (put 'downcase-region 'disabled nil)
2173 (put 'narrow-to-region 'disabled nil)
2175 ; (defun turn-on-flyspell ()
2176 ; "Force flyspell-mode on using a positive arg. For use in hooks."
2178 ; (flyspell-mode 1))
2181 ; Outline-minor-mode key map
2182 (define-prefix-command 'cm-map nil "Outline-")
2184 (define-key cm-map "q" 'outline-hide-sublevels) ; Hide everything but the top-level headings
2185 (define-key cm-map "t" 'outline-hide-body) ; Hide everything but headings (all body lines)
2186 (define-key cm-map "o" 'outline-hide-other) ; Hide other branches
2187 (define-key cm-map "c" 'outline-hide-entry) ; Hide this entry's body
2188 (define-key cm-map "l" 'outline-hide-leaves) ; Hide body lines in this entry and sub-entries
2189 (define-key cm-map "d" 'outline-hide-subtree) ; Hide everything in this entry and sub-entries
2191 (define-key cm-map "a" 'outline-show-all) ; Show (expand) everything
2192 (define-key cm-map "e" 'outline-show-entry) ; Show this heading's body
2193 (define-key cm-map "i" 'outline-show-children) ; Show this heading's immediate child sub-headings
2194 (define-key cm-map "k" 'outline-show-branches) ; Show all sub-headings under this heading
2195 (define-key cm-map "s" 'outline-show-subtree) ; Show (expand) everything in this heading & below
2197 (define-key cm-map "u" 'outline-up-heading) ; Up
2198 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
2199 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
2200 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
2201 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
2202 (global-set-key "\M-o" cm-map)
2204 ; ediff configuration
2205 ; don't use the multi-window configuration
2206 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
2208 ; fix up css mode to not be silly
2209 ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
2210 (setq cssm-indent-level 4)
2211 (setq cssm-newline-before-closing-bracket t)
2212 (setq cssm-indent-function #'cssm-c-style-indenter)
2213 (setq cssm-mirror-mode nil)
2215 (require 'multi-web-mode)
2216 (setq mweb-default-major-mode 'html-mode)
2217 (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
2218 (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
2219 (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
2220 (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
2221 (multi-web-global-mode 1)
2223 ; load sql-indent when sql is loaded
2224 (eval-after-load "sql"
2225 '(load-library "sql-indent"))
2227 ; fix up tmux xterm keys
2228 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
2229 (defun fix-up-tmux-keys ()
2230 "Fix up tmux xterm keys"
2233 (let ((x 2) (tkey ""))
2253 ;; ctrl + alt + shift
2255 (setq tkey "C-M-S-"))
2258 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
2259 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
2260 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
2261 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
2263 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
2265 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
2267 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
2269 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
2271 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2273 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2275 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
2277 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
2279 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
2281 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
2283 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
2285 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
2287 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
2289 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
2291 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
2293 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
2295 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
2297 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
2299 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
2301 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
2303 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
2305 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
2307 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
2309 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
2311 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
2313 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
2320 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
2322 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
2323 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
2324 (if (or (buffer-modified-p)
2325 (verify-visited-file-modtime)
2326 (< (* 8 1024 1024) (buffer-size))
2327 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
2329 (clear-visited-file-modtime)
2331 (ad-activate 'ask-user-about-supersession-threat)
2335 #+BEGIN_SRC emacs-lisp
2336 (unless (server-running-p)
2343 #+BEGIN_SRC emacs-lisp
2344 (provide 'don-configuration)