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 flyspell
120 :diminish flyspell-mode 🐝
122 (add-hook 'text-mode-hook 'turn-on-flyspell)
123 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
124 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
125 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
127 (setq ispell-program-name "ispell")
132 #+begin_src emacs-lisp :tangle yes
138 #+BEGIN_SRC emacs-lisp
143 #+BEGIN_SRC emacs-lisp
144 (use-package eyebrowse
146 :diminish eyebrowse-mode
147 :init (setq eyebrowse-keymap-prefix (kbd "C-c e"))
149 (setq eyebrowse-wrap-around t)
152 (defun my/eyebrowse-new-window-config ()
156 ;; start at 1 run till 0
157 (let ((j (mod (+ i 1) 10)))
158 (when (and (not done)
159 (not (eyebrowse--window-config-present-p j)))
160 (eyebrowse-switch-to-window-config j)
161 (call-interactively 'eyebrowse-rename-window-config2 j)
166 ;; I don't use latex-preview-pane
167 ;; (require 'latex-preview-pane)
168 ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
169 ;; ;; latex-preview-pane uses window-parameters which are
170 ;; ;; not preserved by eyebrowse, so we close the preview
171 ;; ;; pane before switching, it will be regenerated when we
172 ;; ;; edit the TeX file.
173 ;; (when (lpp/window-containing-preview)
174 ;; (delete-window (lpp/window-containing-preview))))
176 ;; (add-to-list 'eyebrowse-pre-window-switch-hook
177 ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
179 ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
180 ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
181 ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
182 ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
183 ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
191 #+BEGIN_SRC emacs-lisp
192 (defun my/vsplit-last-buffer ()
193 "Split the window vertically and display the previous buffer."
195 (split-window-vertically)
197 (switch-to-next-buffer))
199 (defun my/hsplit-last-buffer ()
200 "Split the window horizontally and display the previous buffer."
202 (split-window-horizontally)
204 (switch-to-next-buffer))
206 (bind-key "C-x 2" 'my/vsplit-last-buffer)
207 (bind-key "C-x 3" 'my/hsplit-last-buffer)
209 (setq split-width-threshold 100)
210 (setq split-height-threshold 60)
212 (defun my/split-window-prefer-vertically (window)
213 "If there's only one window (excluding any possibly active
214 minibuffer), then split the current window horizontally."
215 (if (and (one-window-p t)
216 (not (active-minibuffer-window))
217 ( < (frame-width) (frame-height))
219 (let ((split-width-threshold nil))
220 (split-window-sensibly window))
221 (split-window-sensibly window)))
223 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
224 (setq window-combination-resize t)
227 *** Compilation window
229 If there is no compilation window, open one at the bottom, spanning
230 the complete width of the frame. Otherwise, reuse existing window. In
231 the former case, if there was no error the window closes
234 #+BEGIN_SRC emacs-lisp
235 (add-to-list 'display-buffer-alist
236 `(,(rx bos "*compilation*" eos)
237 (display-buffer-reuse-window
238 display-buffer-in-side-window)
239 (reusable-frames . visible)
241 (window-height . 0.4)))
244 #+BEGIN_SRC emacs-lisp
245 (defun my/compilation-exit-autoclose (status code msg)
246 ;; If M-x compile exists with a 0
247 (when (and (eq status 'exit) (zerop code))
248 ;; and delete the *compilation* window
249 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
250 (when (and (not (window-at-side-p compilation-window 'top))
251 (window-at-side-p compilation-window 'left)
252 (window-at-side-p compilation-window 'right))
253 (delete-window compilation-window))))
254 ;; Always return the anticipated result of compilation-exit-message-function
257 ;; Specify my function (maybe I should have done a lambda function)
258 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
261 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
262 value, the compilation buffer scrolls automatically to follow the
263 output. If the value is ~first-error~, scrolling stops when the first
264 error appears, leaving point at that error. For any other non-nil
265 value, scrolling continues until there is no more output.
267 #+BEGIN_SRC emacs-lisp
268 (setq compilation-scroll-output 'first-error)
271 ** Mode line cleaning
273 #+BEGIN_SRC emacs-lisp
274 (use-package diminish
279 #+BEGIN_SRC emacs-lisp
286 #+BEGIN_SRC emacs-lisp
289 :bind (("C-c C-<SPC>" . avy-goto-word-or-subword-1)
290 ("C-c j j" . avy-goto-word-or-subword-1)
291 ("M-g g" . avy-goto-line))
292 :config (progn (setq avy-background t))
295 *** Ace-link (jumping to links)
296 #+BEGIN_SRC emacs-lisp
297 (use-package ace-link
299 ; bind o in most modes
300 :config (ace-link-setup-default))
302 *** Jumping through edit points (goto-chg)
303 #+BEGIN_SRC emacs-lisp
304 (use-package goto-chg
306 :bind (("C-c j ," . goto-last-change)
307 ("C-c j ." . goto-last-change-reverse))
310 *** Jumping to bookmarks (visible bookmarks, bm)
311 #+BEGIN_SRC emacs-lisp
314 :bind (("C-c j b ." . bm-next)
315 ("C-c j b ," . bm-previous)
316 ("C-c j b SPC" . bm-toggle)))
321 #+BEGIN_SRC emacs-lisp
322 (use-package yasnippet
324 :diminish yas-minor-mode
327 (setq yas-verbosity 1)
328 (define-key yas-minor-mode-map (kbd "<tab>") nil)
329 (define-key yas-minor-mode-map (kbd "TAB") nil)
330 (define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)
331 (setq yas-snippet-dirs '("~/lib/emacs_el/snippets/"
332 "~/lib/emacs_el/yasnippet-snippets/snippets/"))
333 (add-to-list 'hippie-expand-try-functions-list
334 'yas-hippie-try-expand)
339 #+BEGIN_SRC emacs-lisp
340 (use-package auto-yasnippet
341 :bind (("H-w" . aya-create)
348 #+BEGIN_SRC emacs-lisp
350 (use-package tinyprocmail
351 :load-path "~/lib/emacs_el/tiny-tools/lisp/tiny"
352 :mode (".procmailrc" . turn-on-tinyprocmail-mode)
357 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
360 :bind (("C-x g" . magit-status)
361 ("C-x C-g" . magit-status))
363 ;; refine diffs always (hilight words)
364 (setq magit-diff-refine-hunk nil)
366 (use-package magit-annex
368 :load-path "~/lib/emacs_el/magit-annex/"
370 (use-package magit-vcsh
371 :ensure f ; currently not in melpa, so don't try to install
372 :load-path "~/lib/emacs_el/magit-vcsh/"
377 #+BEGIN_SRC emacs-lisp
378 (use-package cperl-mode
381 ;; Use c-mode for perl .xs files
382 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
383 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
384 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
385 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
386 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
389 cperl-auto-newline nil
390 cperl-auto-newline-after-colon nil
391 cperl-continued-statement-offset 4
392 cperl-brace-offset -1
393 cperl-continued-brace-offset 0
394 cperl-label-offset -4
395 cperl-highlight-variables-indiscriminately t
396 cperl-electric-lbrace-space nil
397 cperl-indent-parens-as-block nil
398 cperl-close-paren-offset -1
399 cperl-tab-always-indent t)
400 ;;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
405 #+BEGIN_SRC emacs-lisp
406 (defun malb/helm-omni (&rest arg)
407 ;; just in case someone decides to pass an argument, helm-omni won't fail.
409 (unless helm-source-buffers-list
410 (setq helm-source-buffers-list
411 (helm-make-source "Buffers" 'helm-source-buffers)))
415 (if (projectile-project-p)
416 '(helm-source-projectile-buffers-list
417 helm-source-buffers-list)
418 '(helm-source-buffers-list)) ;; list of all open buffers
420 `(((name . "Virtual Workspace")
421 (candidates . ,(--map (cons (eyebrowse-format-slot it) (car it))
422 (eyebrowse--get 'window-configs)))
423 (action . (lambda (candidate)
424 (eyebrowse-switch-to-window-config candidate)))))
426 (if (projectile-project-p)
427 '(helm-source-projectile-recentf-list
429 '(helm-source-recentf)) ;; all recent files
431 ;; always make some common files easily accessible
432 ;;'(((name . "Common Files")
433 ;; (candidates . malb/common-file-targets)
434 ;; (action . (("Open" . (lambda (x) (find-file (eval x))))))))
436 '(helm-source-files-in-current-dir
438 helm-source-bookmarks
439 helm-source-buffer-not-found ;; ask to create a buffer otherwise
441 "*Helm all the things*"))
445 :bind (("M-x" . helm-M-x)
446 ("C-x C-f" . helm-find-files)
447 ("C-x b" . helm-buffers-list) ; malb/helm-omni)
448 ("C-x C-b" . helm-buffers-list) ; malb/helm-omni)
449 ("C-c <SPC>" . helm-all-mark-rings))
451 (require 'helm-config)
452 (require 'helm-for-files)
453 (require 'helm-bookmark)
456 (define-key global-map [remap find-file] 'helm-find-files)
457 (define-key global-map [remap occur] 'helm-occur)
458 (define-key global-map [remap list-buffers] 'helm-buffers-list)
459 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
460 (unless (boundp 'completion-in-region-function)
461 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
462 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
463 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
468 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
470 #+BEGIN_SRC emacs-lisp
471 (use-package helm-flx
474 ;; these are helm configs, but they kind of fit here nicely
475 (setq helm-M-x-fuzzy-match t
476 helm-bookmark-show-location t
477 helm-buffers-fuzzy-matching t
478 helm-completion-in-region-fuzzy-match t
479 helm-file-cache-fuzzy-match t
480 helm-imenu-fuzzy-match t
481 helm-mode-fuzzy-match t
482 helm-locate-fuzzy-match nil
484 helm-recentf-fuzzy-match nil
485 helm-semantic-fuzzy-match t)
489 #+BEGIN_SRC emacs-lisp
491 ;;; stolen from https://github.com/malb/emacs.d/blob/master/malb.org
492 (defun malb/helm-swoop-pre-fill ()
493 (thing-at-point 'symbol))
494 (defvar malb/helm-swoop-ignore-major-mode "List of major modes to ignore for helm-swoop")
495 (setq malb/helm-swoop-ignore-major-mode '(dired-mode
496 paradox-menu-mode doc-view-mode pdf-view-mode
497 mu4e-headers-mode org-mode markdown-mode latex-mode
498 ein:notebook-multilang-mode))
500 (defun malb/swoop-or-search ()
502 (if (or (> (buffer-size) 1048576) ;; helm-swoop can be slow on big buffers
503 (memq major-mode malb/helm-swoop-ignore-major-mode))
507 (use-package helm-swoop
510 :bind (("C-c o" . helm-multi-swoop-org)
511 ("C-s" . malb/swoop-or-search)
512 ("C-M-s" . helm-multi-swoop-all))
515 (setq helm-swoop-pre-input-function #'malb/helm-swoop-pre-fill
516 helm-swoop-split-with-multiple-windows nil
517 helm-swoop-split-direction #'split-window-horizontally
518 helm-swoop-split-window-function 'helm-default-display-buffer
519 helm-swoop-speed-or-color t)
521 ;; https://emacs.stackexchange.com/questions/28790/helm-swoop-how-to-make-it-behave-more-like-isearch
522 (defun malb/helm-swoop-C-s ()
524 (if (boundp 'helm-swoop-pattern)
525 (if (equal helm-swoop-pattern "")
526 (previous-history-element 1)
530 (bind-key "C-S-s" #'helm-swoop-from-isearch isearch-mode-map)
531 (bind-key "C-S-s" #'helm-multi-swoop-all-from-helm-swoop helm-swoop-map)
532 (bind-key "C-r" #'helm-previous-line helm-swoop-map)
533 (bind-key "C-s" #'malb/helm-swoop-C-s helm-swoop-map)
534 (bind-key "C-r" #'helm-previous-line helm-multi-swoop-map)
535 (bind-key "C-s" #'malb/helm-swoop-C-s helm-multi-swoop-map))
540 #+BEGIN_SRC emacs-lisp
543 :config (setq helm-ag-base-command "ag --nocolor --nogroup"
544 helm-ag-command-option "--all-text"
545 helm-ag-insert-at-point 'symbol
546 helm-ag-fuzzy-match t
547 helm-ag-use-temp-buffer t
548 helm-ag-use-grep-ignore-list t
549 helm-ag-use-agignore t))
552 #+BEGIN_SRC emacs-lisp
553 (use-package helm-descbinds
555 :bind ("C-h b" . helm-descbinds)
556 :init (fset 'describe-bindings 'helm-descbinds))
560 #+BEGIN_SRC emacs-lisp
561 (use-package helm-c-yasnippet
563 :bind ("C-c h y" . helm-yas-complete)
565 (setq helm-yas-space-match-any-greedy t)))
568 #+BEGIN_SRC emacs-lisp
569 (use-package helm-org-rifle
572 (defun malb/helm-org-rifle-agenda-files (arg)
574 (let ((current-prefix-arg nil))
576 ((equal arg 4) (call-interactively #'helm-org-rifle-agenda-files nil))
577 ((equal arg 16) (helm-org-rifle-occur-agenda-files))
578 (t (helm-org-agenda-files-headings)))))))
581 This can be used to link things pretty quickly if necessary
582 #+BEGIN_SRC emacs-lisp
583 (use-package helm-google
585 :bind ("C-c h g" . helm-google)
587 (progn (add-to-list 'helm-google-actions
588 '("Copy URL" . (lambda (candidate)
590 (replace-regexp-in-string
591 "https://.*q=\\(.*\\)\&sa=.*"
597 (add-to-list 'helm-google-actions
598 '("Org Store Link" . (lambda (candidate)
599 (let ((title (car (split-string candidate "[\n]+")))
601 (replace-regexp-in-string
602 "https://.*q=\\(.*\\)\&sa=.*"
604 (push (list url title) org-stored-links))))
609 ** Projectile -- Project management
610 #+begin_src emacs-lisp
611 (use-package projectile
613 :bind (("<f5>" . projectile-compile-project)
614 ("<f6>" . next-error))
616 (use-package magit :ensure t)
617 (require 'helm-projectile)
620 (setq projectile-make-test-cmd "make check"
621 projectile-switch-project-action 'helm-projectile
622 projectile-mode-line '(:eval (format "»{%s}" (projectile-project-name))))
624 (projectile-global-mode)))
628 #+begin_src emacs-lisp
629 (use-package helm-projectile
632 (defvar malb/helm-source-file-not-found
633 (helm-build-dummy-source
638 'helm-projectile-sources-list
639 malb/helm-source-file-not-found t)
641 (helm-delete-action-from-source
642 "Grep in projects `C-s'"
643 helm-source-projectile-projects)
645 (helm-add-action-to-source
646 "Grep in projects `C-s'"
647 'helm-do-ag helm-source-projectile-projects 4)))
650 #+BEGIN_SRC emacs-lisp
653 :bind ("M-z" . avy-zap-up-to-char-dwim))
656 #+BEGIN_SRC emacs-lisp
658 :bind (("C-c 2" . my/hydra-orgmodes/body)
659 ("C-c @" . my/hydra-orgmodes/body)
660 ("C-c #" . my/hydra-outline/body)
661 ("C-c 3" . my/hydra-outline/body)
664 (defhydra my/hydra-orgmodes (:color blue :hint nil)
666 _n_: notes _c_: chaim _w_: wildman _o_: ool
667 _u_: uddin _s_: steve _r_: refile _f_: fh
668 _p_: read papers _R_: paper notes
673 ("n" (find-file "~/projects/org-notes/notes.org"))
674 ("c" (find-file "~/projects/org-notes/chaim.org"))
675 ("w" (find-file "~/projects/org-notes/wildman.org"))
676 ("u" (find-file "~/projects/org-notes/uddin.org"))
677 ("o" (find-file "~/projects/org-notes/ool.org"))
678 ("f" (find-file "~/projects/org-notes/fh.org"))
679 ("s" (find-file "~/projects/org-notes/sndservers.org"))
680 ("r" (find-file "~/projects/org-notes/refile.org"))
681 ("p" (find-file "~/projects/research/papers_to_read.org"))
682 ("R" (find-file "~/projects/research/paper_notes.org"))
683 ("h" (find-file "~/projects/org-notes/hpcbio.org"))
688 ;; from https://github.com/abo-abo/hydra/wiki/Emacs
689 (defhydra my/hydra-outline (:color pink :hint nil)
692 ^^^^^^------------------------------------------------------
693 _q_: sublevels _a_: all _u_: up
694 _t_: body _e_: entry _n_: next visible
695 _o_: other _i_: children _p_: previous visible
696 _c_: entry _k_: branches _f_: forward same level
697 _l_: leaves _s_: subtree _b_: backward same level
702 ("q" outline-hide-sublevels) ; Hide everything but the top-level headings
703 ("t" outline-hide-body) ; Hide everything but headings (all body lines)
704 ("o" outline-hide-other) ; Hide other branches
705 ("c" outline-hide-entry) ; Hide this entry's body
706 ("l" outline-hide-leaves) ; Hide body lines in this entry and sub-entries
707 ("d" outline-hide-subtree) ; Hide everything in this entry and sub-entries
709 ("a" outline-show-all) ; Show (expand) everything
710 ("e" outline-show-entry) ; Show this heading's body
711 ("i" outline-show-children) ; Show this heading's immediate child sub-headings
712 ("k" outline-show-branches) ; Show all sub-headings under this heading
713 ("s" outline-show-subtree) ; Show (expand) everything in this heading & below
715 ("u" outline-up-heading) ; Up
716 ("n" outline-next-visible-heading) ; Next
717 ("p" outline-previous-visible-heading) ; Previous
718 ("f" outline-forward-same-level) ; Forward - same level
719 ("b" outline-backward-same-level) ; Backward - same level
725 #+BEGIN_SRC emacs-lisp
726 (add-to-list 'tramp-methods '("vcsh"
727 (tramp-login-program "vcsh")
731 (tramp-remote-shell "/bin/sh")
732 (tramp-remote-shell-args
736 #+BEGIN_SRC emacs-lisp
740 (setq-default reftex-default-bibliography
741 '("~/projects/research/references.bib")))
744 #+BEGIN_SRC emacs-lisp
746 :config (setq bibtex-user-optional-fields
747 (quote (("annote" "Personal annotation (ignored)")
755 #+BEGIN_SRC emacs-lisp
760 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
761 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
762 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
763 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
764 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
765 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
766 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
767 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
768 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
769 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
770 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
772 (setq-default reftex-plug-into-AUCTeX t)
773 ;; support fake section headers
774 (setq TeX-outline-extra
780 ;; add font locking to the headers
781 (font-lock-add-keywords
783 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
784 0 'font-lock-keyword-face t)
785 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
786 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
787 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
788 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
789 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
791 ;; use smart quotes by default instead of `` and ''
792 ;; taken from http://kieranhealy.org/esk/kjhealy.html
793 (setq TeX-open-quote "“")
794 (setq TeX-close-quote "”")
796 ;; (TeX-add-style-hook
801 ;; (custom-set-variables
802 ;; '(font-latex-user-keyword-classes
805 ;; font-lock-function-name-face 2 (command 1 t))))
807 (setq-default TeX-parse-self t)
808 (setq-default TeX-auto-save t)
809 (setq-default TeX-master nil)
815 (if (boundp 'reftex-ref-style-alist)
817 'reftex-ref-style-alist
818 '("Cleveref" "cleveref"
819 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
820 (reftex-ref-style-activate "Cleveref")
822 '("cref" TeX-arg-ref)
823 '("Cref" TeX-arg-ref)
824 '("cpageref" TeX-arg-ref)
825 '("Cpageref" TeX-arg-ref)))))
828 '(add-to-list 'LaTeX-fill-excluded-macros
831 (use-package font-latex
833 (setq font-latex-match-reference-keywords
855 (setq font-latex-fontify-script nil)
856 (setq font-latex-fontify-sectioning (quote color))
857 (setq font-latex-script-display (quote (nil)))
862 #+BEGIN_SRC emacs-lisp
866 (defun ess-change-directory (path)
867 "Set the current working directory to PATH for both *R* and Emacs."
868 (interactive "DDirectory to change to: ")
870 (when (file-exists-p path)
871 (ess-command (concat "setwd(\"" path "\")\n"))
872 ;; use file-name-as-directory to ensure it has trailing /
873 (setq default-directory (file-name-as-directory path))))
874 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
875 ;; outlining support for ess modes
880 (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
881 (defun outline-level ()
882 (cond ((looking-at "^##### ") 1)
883 ((looking-at "^#### ") 2)
884 ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
887 (add-hook 'ess-mode-hook
889 (local-set-key (kbd "C-c C-R")
890 'dla/ess-region-remote-eval)))
892 ;; Don't restore history or save workspace image
893 '(inferior-R-args "--no-restore-history --no-save")
898 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
900 #+BEGIN_SRC emacs-lisp
901 (use-package rainbow-mode
902 ;; add ess to the x major mode
903 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
904 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
909 #+BEGIN_SRC emacs-lisp
910 (use-package polymode
913 (use-package poly-noweb)
914 (use-package poly-markdown)
915 :mode ("\\.Snw" . poly-noweb+r-mode)
916 :mode ("\\.Rnw" . poly-noweb+r-mode)
917 :mode ("\\.Rmd" . poly-markdown+r-mode)
923 #+BEGIN_SRC emacs-lisp
924 (use-package outline-magic)
927 #+BEGIN_SRC emacs-lisp
928 (use-package writeroom-mode
930 (defun my/writing-mode ()
931 "Start my writing mode; enable visual-line-mode and auto-fill-mode"
936 (visual-line-mode -1)
938 (visual-fill-column-mode -1)
942 (visual-fill-column-mode 1)
947 ** GhostText/Atomic Chrome
948 #+BEGIN_SRC emacs-lisp
949 (use-package atomic-chrome
951 (ignore-errors (atomic-chrome-start-server))
952 (setq atomic-chrome-buffer-open-style 'full)
957 :ID: 6fcf218b-a762-4c37-9339-a8202ddeb544
959 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
960 #+BEGIN_SRC emacs-lisp
961 (use-package multiple-cursors
962 :bind (("C-;" . mc/mark-all-dwim)
963 ("C-<" . mc/mark-previous-like-this)
964 ("C->" . mc/mark-next-like-this)
965 ("C-S-c C-S-c" . mc/edit-lines))
969 #+BEGIN_SRC emacs-lisp
970 (use-package web-mode
972 (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . web-mode))
973 (setq web-mode-enable-engine-detection t)
974 (setq web-mode-engines-alist
975 '(("template-toolkit" . "\\.tmpl\\'")))
979 #+BEGIN_SRC emacs-lisp
980 (use-package spamassassin-mode
986 #+BEGIN_SRC emacs-lisp
987 (use-package password-store
989 :commands password-store-edit password-store-create
995 #+BEGIN_SRC emacs-lisp
999 :mode "muttng-[a-z0-9]+-[0-9]+-"
1000 :mode "mutt-[a-z0-9]+-[0-9]+-"
1001 :hook 'my/message-mode-settings
1002 :hook 'turn-on-flyspell
1003 :bind (:map message-mode-map
1004 ("C-c C-a" . my/post-attach-file))
1006 (defun my/message-mode-settings ()
1007 (font-lock-add-keywords nil
1008 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1009 (0 'message-multiply-quoted-text-face))
1010 ("^[ \t]*>[ \t]*>.*$"
1011 (0 'message-double-quoted-text-face))))
1014 (defun my/post-attach-file ()
1015 "Prompt for an attachment."
1017 (let ((file (read-file-name "Attach file: " nil nil t nil))
1018 (description (string-read "Description: ")))
1019 (my/header-attach-file file description)))
1021 (defun my/header-attach-file (file description)
1022 "Attach a FILE to the current message (works with Mutt).
1023 Argument DESCRIPTION MIME description."
1024 (interactive "fAttach file: \nsDescription: ")
1025 (when (> (length file) 0)
1030 (goto-char (point-min))
1031 (search-forward-regexp "^$")
1032 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1034 (message (concat "Attached '" file "'."))
1035 (setq post-has-attachment t))))))
1037 (setq mail-yank-prefix "> ")
1041 #+BEGIN_SRC emacs-lisp
1042 (use-package muttrc-mode
1049 ** Reverting buffers
1050 #+BEGIN_SRC emacs-lisp
1051 (setq global-auto-revert-non-file-buffers t
1052 global-auto-revert-ignore-modes '(pdf-view-mode)
1053 auto-revert-verbose nil)
1054 (global-auto-revert-mode 1)
1057 ** Use-package and load things
1058 #+BEGIN_SRC emacs-lisp
1064 ** Agenda Configuration
1065 #+BEGIN_SRC emacs-lisp
1066 :mode ("\\.\\(org\\|org_archive\\|txt\\)\\'" . org-mode)
1067 :bind (("C-c l" . org-store-link)
1068 ("C-c a" . org-agenda)
1069 ("C-c b" . org-iswitchb))
1071 (setq-default org-log-done 'time)
1072 (setq-default org-agenda-ndays 5)
1074 ;; agenda configuration
1075 ;; Do not dim blocked tasks
1076 (setq org-agenda-dim-blocked-tasks nil)
1077 (setq org-agenda-inhibit-startup t)
1078 (setq org-agenda-use-tag-inheritance nil)
1080 ;; Compact the block agenda view
1081 (setq org-agenda-compact-blocks t)
1083 ;; Custom agenda command definitions
1084 (setq org-agenda-custom-commands
1085 (quote (("N" "Notes" tags "NOTE"
1086 ((org-agenda-overriding-header "Notes")
1087 (org-tags-match-list-sublevels t)))
1088 ("h" "Habits" tags-todo "STYLE=\"habit\""
1089 ((org-agenda-overriding-header "Habits")
1090 (org-agenda-sorting-strategy
1091 '(todo-state-down effort-up category-keep))))
1095 ((org-agenda-overriding-header "Tasks to Refile")
1096 (org-tags-match-list-sublevels nil)))
1097 (tags-todo "-CANCELLED/!"
1098 ((org-agenda-overriding-header "Stuck Projects")
1099 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
1100 (org-agenda-sorting-strategy
1102 (tags-todo "-HOLD-CANCELLED/!"
1103 ((org-agenda-overriding-header "Projects")
1104 (org-agenda-skip-function 'bh/skip-non-projects)
1105 (org-tags-match-list-sublevels 'indented)
1106 (org-agenda-sorting-strategy
1108 (tags-todo "-CANCELLED/!NEXT"
1109 ((org-agenda-overriding-header (concat "Project Next Tasks"
1110 (if bh/hide-scheduled-and-waiting-next-tasks
1112 " (including WAITING and SCHEDULED tasks)")))
1113 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1114 (org-tags-match-list-sublevels t)
1115 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1116 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1117 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1118 (org-agenda-sorting-strategy
1119 '(todo-state-down effort-up category-keep))))
1120 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1121 ((org-agenda-overriding-header (concat "Project Subtasks"
1122 (if bh/hide-scheduled-and-waiting-next-tasks
1124 " (including WAITING and SCHEDULED tasks)")))
1125 (org-agenda-skip-function 'bh/skip-non-project-tasks)
1126 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1127 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1128 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1129 (org-agenda-sorting-strategy
1131 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1132 ((org-agenda-overriding-header (concat "Standalone Tasks"
1133 (if bh/hide-scheduled-and-waiting-next-tasks
1135 " (including WAITING and SCHEDULED tasks)")))
1136 (org-agenda-skip-function 'bh/skip-project-tasks)
1137 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1138 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1139 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1140 (org-agenda-sorting-strategy
1142 (tags-todo "-CANCELLED+WAITING|HOLD/!"
1143 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
1144 (org-agenda-skip-function 'bh/skip-stuck-projects)
1145 (org-tags-match-list-sublevels nil)
1146 (org-agenda-todo-ignore-scheduled t)
1147 (org-agenda-todo-ignore-deadlines t)))
1149 ((org-agenda-overriding-header "Tasks to Archive")
1150 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1151 (org-tags-match-list-sublevels nil))))
1154 ; org mode agenda files
1155 (setq org-agenda-files
1156 (quote ("~/projects/org-notes/debbugs.org"
1157 "~/projects/org-notes/notes.org"
1158 "~/projects/org-notes/holidays.org"
1159 "~/projects/org-notes/refile.org"
1160 "~/projects/org-notes/diary.org"
1161 "~/projects/org-notes/ool.org"
1162 "~/projects/org-notes/sndservers.org"
1163 "~/projects/org-notes/chaim.org"
1164 "~/projects/org-notes/wildman.org"
1165 "~/projects/org-notes/uddin.org"
1166 "~/projects/org-notes/reviews.org"
1167 "~/org-mode/from-mobile.org"
1168 "~/projects/org-notes/fh.org")))
1170 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
1171 (set-register ?r (cons 'file "~/projects/org-notes/refile.org"))
1172 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
1173 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
1174 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
1175 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
1176 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
1177 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
1178 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
1179 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
1180 (defun org-agenda-timeline-all (&optional arg)
1183 (dolist (org-agenda-file org-agenda-files)
1184 (insert-file-contents org-agenda-file nil)
1185 (goto-char (point-max))
1187 (write-file "/tmp/timeline.org")
1188 (org-agenda arg "L")))
1189 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
1193 #+BEGIN_SRC emacs-lisp
1194 (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")))
1195 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
1197 (setq org-default-notes-file "~/projects/org-notes/notes.org")
1198 (setq org-id-link-to-org-use-id 'use-existing)
1200 ** Capture Templates
1201 #+BEGIN_SRC emacs-lisp
1202 (setq org-capture-templates ;; mail-specific note template, identified by "m"
1203 '(("m" "Mail" entry (file "~/projects/org-notes/refile.org")
1204 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
1205 ("t" "todo" entry (file "~/projects/org-notes/refile.org")
1206 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
1207 ("r" "respond" entry (file "~/projects/org-notes/refile.org")
1208 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
1209 ("n" "note" entry (file "~/projects/org-notes/refile.org")
1210 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
1211 ("s" "schedule" entry (file "~/projects/org-notes/refile.org")
1212 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
1213 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
1214 "* %?\n%U\n" :clock-in t :clock-resume t)
1215 ("w" "org-protocol" entry (file "~/projects/org-notes/refile.org")
1216 "* TODO Review %c\n%U\n" :immediate-finish t)
1217 ("M" "Meeting" entry (file "~/projects/org-notes/refile.org")
1218 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
1219 ("S" "Seminar" entry (file "~/projects/org-notes/refile.org")
1220 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
1221 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
1222 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
1223 ("p" "Phone call" entry (file "~/projects/org-notes/refile.org")
1224 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
1225 ("J" "job" entry (file "~/projects/org-notes/refile.org")
1226 "* 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)
1227 ("h" "Habit" entry (file "~/projects/org-notes/refile.org")
1228 "* 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")
1232 ;; Remove empty LOGBOOK drawers on clock out
1233 (defun bh/remove-empty-drawer-on-clock-out ()
1236 (beginning-of-line 0)
1237 (org-remove-empty-drawer-at (point))))
1239 (defun my/org-add-id ()
1242 (if (org-current-level)
1251 ** Org mode key bindings
1252 #+BEGIN_SRC emacs-lisp
1253 ; org mode configuration from http://doc.norang.ca/org-mode.html
1254 ;; Custom Key Bindings
1255 (global-set-key (kbd "<f12>") 'org-agenda)
1256 ; (global-set-key (kbd "<f5>") 'bh/org-todo)
1257 (global-set-key (kbd "<S-f5>") 'bh/widen)
1258 (global-set-key (kbd "<f7>") 'bh/set-truncate-lines)
1259 (global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
1260 (global-set-key (kbd "<f9> <f9>") 'bh/show-org-agenda)
1261 (global-set-key (kbd "<f9> b") 'bbdb)
1262 (global-set-key (kbd "<f9> c") 'calendar)
1263 (global-set-key (kbd "<f9> f") 'boxquote-insert-file)
1264 (global-set-key (kbd "<f9> h") 'bh/hide-other)
1265 (global-set-key (kbd "<f9> n") 'bh/toggle-next-task-display)
1266 (global-set-key (kbd "<f9> w") 'widen)
1268 ; change the outline mode prefix from C-c @ to C-c C-2
1269 (setq outline-minor-mode-prefix "C-c C-2")
1270 ;(add-hook 'outline-minor-mode-hook
1271 ; (lambda () (local-set-key (kbd "C-c C-2")
1272 ; outline-mode-prefix-map)))
1274 (global-set-key (kbd "<f9> I") 'bh/punch-in)
1275 (global-set-key (kbd "<f9> O") 'bh/punch-out)
1277 (global-set-key (kbd "<f9> o") 'bh/make-org-scratch)
1279 (global-set-key (kbd "<f9> r") 'boxquote-region)
1280 (global-set-key (kbd "<f9> s") 'bh/switch-to-scratch)
1282 (global-set-key (kbd "<f9> t") 'bh/insert-inactive-timestamp)
1283 (global-set-key (kbd "<f9> T") 'bh/toggle-insert-inactive-timestamp)
1285 (global-set-key (kbd "<f9> v") 'visible-mode)
1286 (global-set-key (kbd "<f9> l") 'org-toggle-link-display)
1287 (global-set-key (kbd "<f9> SPC") 'bh/clock-in-last-task)
1288 (global-set-key (kbd "C-<f9>") 'previous-buffer)
1289 (global-set-key (kbd "M-<f9>") 'org-toggle-inline-images)
1290 (global-set-key (kbd "C-x n r") 'narrow-to-region)
1291 (global-set-key (kbd "C-<f10>") 'next-buffer)
1292 (global-set-key (kbd "<f11>") 'org-clock-goto)
1293 (global-set-key (kbd "C-<f11>") 'org-clock-in)
1294 (global-set-key (kbd "C-s-<f12>") 'bh/save-then-publish)
1295 (global-set-key (kbd "C-c c") 'org-capture)
1298 ** Utility Functions
1299 #+BEGIN_SRC emacs-lisp
1300 (defun bh/hide-other ()
1303 (org-back-to-heading 'invisible-ok)
1309 (defun bh/set-truncate-lines ()
1310 "Toggle value of truncate-lines and refresh window display."
1312 (setq truncate-lines (not truncate-lines))
1313 ;; now refresh window display (an idiom from simple.el):
1315 (set-window-start (selected-window)
1316 (window-start (selected-window)))))
1318 (defun bh/make-org-scratch ()
1320 (find-file "/tmp/publish/scratch.org")
1321 (gnus-make-directory "/tmp/publish"))
1323 (defun bh/switch-to-scratch ()
1325 (switch-to-buffer "*scratch*"))
1327 (setq org-use-fast-todo-selection t)
1328 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1330 ; create function to create headlines in file. This comes from
1331 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
1332 (defun my/org-add-ids-to-headlines-in-file ()
1333 "Add ID properties to all headlines in the current file which
1334 do not already have one."
1336 (org-map-entries 'org-id-get-create))
1337 ; if we wanted to do this to every buffer, do the following:
1338 ; (add-hook 'org-mode-hook
1340 ; (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
1343 #+BEGIN_SRC emacs-lisp
1344 (setq org-todo-keywords
1345 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
1346 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
1348 (setq org-todo-keyword-faces
1349 (quote (("TODO" :foreground "red" :weight bold)
1350 ("NEXT" :foreground "blue" :weight bold)
1351 ("DONE" :foreground "forest green" :weight bold)
1352 ("WAITING" :foreground "orange" :weight bold)
1353 ("HOLD" :foreground "magenta" :weight bold)
1354 ("CANCELLED" :foreground "forest green" :weight bold)
1355 ("MEETING" :foreground "forest green" :weight bold)
1356 ("PHONE" :foreground "forest green" :weight bold))))
1358 (setq org-todo-state-tags-triggers
1359 (quote (("CANCELLED" ("CANCELLED" . t))
1360 ("WAITING" ("WAITING" . t))
1361 ("HOLD" ("WAITING") ("HOLD" . t))
1362 (done ("WAITING") ("HOLD"))
1363 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1364 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1365 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1369 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1370 ; add ids on creation of nodes
1371 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
1374 ; resolve clocks after 10 minutes of idle; use xprintidle
1375 ; (setq org-clock-idle-time 10)
1376 ; (setq org-clock-x11idle-program-name "xprintidle")
1378 ; this is from http://doc.norang.ca/org-mode.html#Capture
1379 ; use C-M-r for org mode capture
1380 (global-set-key (kbd "C-M-r") 'org-capture)
1382 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1383 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1384 (org-agenda-files :maxlevel . 9))))
1386 ; Use full outline paths for refile targets - we file directly with IDO
1387 (setq org-refile-use-outline-path t)
1389 ; Targets complete directly with IDO
1390 (setq org-outline-path-complete-in-steps nil)
1392 ; Allow refile to create parent tasks with confirmation
1393 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1395 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
1396 ; (setq org-completion-use-ido t)
1397 ; (setq ido-everywhere t)
1398 ; (setq ido-max-directory-size 100000)
1399 ; (ido-mode (quote both))
1400 ; ; Use the current window when visiting files and buffers with ido
1401 ; (setq ido-default-file-method 'selected-window)
1402 ; (setq ido-default-buffer-method 'selected-window)
1403 ; ; Use the current window for indirect buffer display
1404 ; (setq org-indirect-buffer-display 'current-window)
1407 ;;;; Refile settings
1408 ; Exclude DONE state tasks from refile targets
1409 (defun bh/verify-refile-target ()
1410 "Exclude todo keywords with a done state from refile targets"
1411 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
1413 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1415 ;; ensure that emacsclient will show just the note to be edited when invoked
1416 ;; from Mutt, and that it will shut down emacsclient once finished;
1417 ;; fallback to legacy behavior when not invoked via org-protocol.
1418 (require 'org-protocol)
1419 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
1420 (setq my-org-protocol-flag nil)
1421 (defadvice org-capture-finalize (after delete-frame-at-end activate)
1422 "Delete frame at remember finalization"
1423 (progn (if my-org-protocol-flag (delete-frame))
1424 (setq my-org-protocol-flag nil)))
1425 (defadvice org-capture-refile (around delete-frame-after-refile activate)
1426 "Delete frame at remember refile"
1427 (if my-org-protocol-flag
1429 (setq my-org-protocol-flag nil)
1434 (defadvice org-capture-kill (after delete-frame-at-end activate)
1435 "Delete frame at remember abort"
1436 (progn (if my-org-protocol-flag (delete-frame))
1437 (setq my-org-protocol-flag nil)))
1438 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
1439 (setq my-org-protocol-flag t))
1441 (defadvice org-insert-todo-heading (after dla/create-id activate)
1446 (add-to-list 'org-modules 'org-habit)
1448 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
1449 (defun open-mail-in-mutt (message)
1450 "Open a mail message in Mutt, using an external terminal.
1452 Message can be specified either by a path pointing inside a
1453 Maildir, or by Message-ID."
1454 (interactive "MPath or Message-ID: ")
1456 (format "faf xterm -e \"%s %s\""
1457 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
1459 ;; add support for "mutt:ID" links
1460 (org-add-link-type "mutt" 'open-mail-in-mutt)
1462 (defun my-org-mode-setup ()
1463 ; (load-library "reftex")
1464 (and (buffer-file-name)
1465 (file-exists-p (buffer-file-name))
1467 ; (reftex-parse-all)
1468 (reftex-set-cite-format
1469 '((?b . "[[bib:%l][%l-bib]]")
1470 (?n . "[[notes:%l][%l-notes]]")
1472 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
1474 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
1475 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
1476 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
1477 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
1479 (add-hook 'org-mode-hook 'my-org-mode-setup)
1481 (defun org-mode-reftex-search ()
1483 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
1485 (defun open-research-paper (bibtexkey)
1486 "Open a paper by bibtex key"
1487 (interactive "bibtex key: ")
1490 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1491 (org-add-link-type "papers" 'open-research-paper)
1492 (defun open-research-paper-pdf (bibtexkey)
1493 "Open a paper pdf by bibtex key"
1494 (interactive "bibtex key: ")
1496 (format "%s -p evince_annot %s"
1497 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
1498 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
1500 (add-to-list 'org-link-abbrev-alist
1502 "~/projects/research/paper_notes.org::#%s"))
1504 ; I pretty much always want hiearchical checkboxes
1505 (setq org-hierachical-checkbox-statistics nil)
1507 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
1508 (add-to-list 'org-structure-template-alist
1509 '("E" "\\begin{equation}\n?\n\\end{equation}"))
1512 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
1513 (defun my-rtcite-export-handler (path desc format)
1514 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
1515 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
1516 (match-string 1 path)))
1517 (path (substring path 0 (match-beginning 0))))
1518 (cond ((eq format 'latex)
1520 (equal 0 (search "rtcite:" desc)))
1521 (format "\\cite{%s}" search)
1522 (format "\\cite[%s]{%s}" desc search))))))
1524 (org-add-link-type "rtcite"
1526 'my-rtcite-export-handler)
1530 ** Org Mobile Configuration
1531 #+BEGIN_SRC emacs-lisp
1532 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
1533 (when (string= system-name "linnode")
1534 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
1535 (setq-default org-directory "/home/don/org-mode/")
1536 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
1540 #+BEGIN_SRC emacs-lisp
1541 ;; org mode ical export
1542 (setq org-icalendar-timezone "America/Los_Angeles")
1543 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
1544 ;; we already add the id manually
1545 (setq org-icalendar-store-UID t)
1548 ** General Org Babel Configuration
1549 #+BEGIN_SRC emacs-lisp
1550 ;; org babel support
1551 (org-babel-do-load-languages
1552 'org-babel-load-languages
1559 ;; use graphviz-dot for dot things
1560 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
1561 ;; org-babel-by-backend
1562 (defmacro org-babel-by-backend (&rest body)
1563 `(case (if (boundp 'backend)
1564 (org-export-backend-name backend)
1567 (defun my/fix-inline-images ()
1568 (when org-inline-image-overlays
1569 (org-redisplay-inline-images)))
1571 (add-hook 'org-babel-after-execute-hook
1572 'my/fix-inline-images)
1575 ** LaTeX configuration
1577 :ID: 7135ba17-6a50-4eed-84ca-b90afa5b12f8
1579 #+BEGIN_SRC emacs-lisp
1581 (add-to-list 'org-latex-classes
1583 "\\documentclass[11pt,oneside,article]{memoir}\n"
1584 ("\\section{%s}" . "\\section*{%s}")
1585 ("\\subsection{%s}" . "\\subsection*{%s}")
1586 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1587 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1588 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1590 (setq org-beamer-outline-frame-options "")
1591 (add-to-list 'org-latex-classes
1593 "\\documentclass[ignorenonframetext]{beamer}
1594 [NO-DEFAULT-PACKAGES]
1597 ("\\section{%s}" . "\\section*{%s}")
1598 ("\\subsection{%s}" . "\\subsection*{%s}")
1599 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1600 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1601 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1603 (add-to-list 'org-latex-classes
1605 "\\documentclass[11pt,oneside]{memoir}\n"
1606 ("\\chapter{%s}" . "\\chapter*{%s}")
1607 ("\\section{%s}" . "\\section*{%s}")
1608 ("\\subsection{%s}" . "\\subsection*{%s}")
1609 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
1611 (add-to-list 'org-latex-classes
1613 "\\documentclass[11pt]{letter}
1614 [NO-DEFAULT-PACKAGES]
1617 ("\\section{%s}" . "\\section*{%s}")
1618 ("\\subsection{%s}" . "\\subsection*{%s}")
1619 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1620 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1621 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1623 (add-to-list 'org-latex-classes
1625 "\\documentclass{dlacv}
1626 [NO-DEFAULT-PACKAGES]
1629 ("\\section{%s}" . "\\section*{%s}")
1630 ("\\subsection{%s}" . "\\subsection*{%s}")
1631 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1632 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1633 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1636 (add-to-list 'org-latex-classes
1638 "\\documentclass{dlaresume}
1639 [NO-DEFAULT-PACKAGES]
1642 ("\\section{%s}" . "\\section*{%s}")
1643 ("\\subsection{%s}" . "\\subsection*{%s}")
1644 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
1645 ("\\paragraph{%s}" . "\\paragraph*{%s}")
1646 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
1649 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
1650 ;; but adapted to use latexmk 4.22 or higher.
1651 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
1653 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
1654 (setq org-latex-default-packages-alist
1656 ("" "unicode-math" t)
1658 (setq org-latex-packages-alist
1665 ("" "longtable" nil)
1668 ;; make equations larger
1669 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
1671 (defun org-create-formula--latex-header ()
1672 "Return LaTeX header appropriate for previewing a LaTeX snippet."
1673 (let ((info (org-combine-plists (org-export--get-global-options
1674 (org-export-get-backend 'latex))
1675 (org-export--get-inbuffer-options
1676 (org-export-get-backend 'latex)))))
1677 (org-latex-guess-babel-language
1678 (org-latex-guess-inputenc
1679 (org-splice-latex-header
1680 org-format-latex-header
1681 org-latex-default-packages-alist
1683 (plist-get info :latex-header)))
1687 ; support ignoring headers in org mode export to latex
1688 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
1689 (defadvice org-latex-headline (around my-latex-skip-headlines
1690 (headline contents info) activate)
1691 (if (member "ignoreheading" (org-element-property :tags headline))
1692 (setq ad-return-value contents)
1695 ;; keep latex logfiles
1697 (setq org-latex-remove-logfiles nil)
1699 ;; Resume clocking task when emacs is restarted
1700 (org-clock-persistence-insinuate)
1702 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
1703 (setq org-clock-history-length 23)
1704 ;; Resume clocking task on clock-in if the clock is open
1705 (setq org-clock-in-resume t)
1706 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
1707 ;; there are things like PHONE calls
1708 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
1709 ;; Separate drawers for clocking and logs
1710 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
1711 ;; Save clock data and state changes and notes in the LOGBOOK drawer
1712 (setq org-clock-into-drawer t)
1713 (setq org-log-into-drawer t)
1714 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
1715 (setq org-clock-out-remove-zero-time-clocks t)
1716 ;; Clock out when moving task to a done state
1717 (setq org-clock-out-when-done t)
1718 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
1719 (setq org-clock-persist t)
1720 ;; Do not prompt to resume an active clock
1721 (setq org-clock-persist-query-resume nil)
1722 ;; Enable auto clock resolution for finding open clocks
1723 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
1724 ;; Include current clocking task in clock reports
1725 (setq org-clock-report-include-clocking-task t)
1727 ;; the cache seems to be broken
1728 (setq org-element-use-cache nil)
1730 (defvar bh/keep-clock-running nil)
1732 (defun bh/is-task-p ()
1733 "Any task with a todo keyword and no subtask"
1737 (subtree-end (save-excursion (org-end-of-subtree t)))
1738 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1741 (while (and (not has-subtask)
1742 (< (point) subtree-end)
1743 (re-search-forward "^\*+ " subtree-end t))
1744 (when (member (org-get-todo-state) org-todo-keywords-1)
1745 (setq has-subtask t))))
1746 (and is-a-task (not has-subtask)))))
1747 (defun bh/is-project-p ()
1748 "Any task with a todo keyword subtask"
1752 (subtree-end (save-excursion (org-end-of-subtree t)))
1753 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1756 (while (and (not has-subtask)
1757 (< (point) subtree-end)
1758 (re-search-forward "^\*+ " subtree-end t))
1759 (when (member (org-get-todo-state) org-todo-keywords-1)
1760 (setq has-subtask t))))
1761 (and is-a-task has-subtask))))
1763 (defun bh/is-subproject-p ()
1764 "Any task which is a subtask of another project"
1765 (let ((is-subproject)
1766 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
1768 (while (and (not is-subproject) (org-up-heading-safe))
1769 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1770 (setq is-subproject t))))
1771 (and is-a-task is-subproject)))
1774 (defun bh/clock-in-to-next (kw)
1775 "Switch a task from TODO to NEXT when clocking in.
1776 Skips capture tasks, projects, and subprojects.
1777 Switch projects and subprojects from NEXT back to TODO"
1778 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
1780 ((and (member (org-get-todo-state) (list "TODO"))
1783 ((and (member (org-get-todo-state) (list "NEXT"))
1787 (defun bh/punch-in (arg)
1788 "Start continuous clocking and set the default task to the
1789 selected task. If no task is selected set the Organization task
1790 as the default task."
1792 (setq bh/keep-clock-running t)
1793 (if (equal major-mode 'org-agenda-mode)
1795 ;; We're in the agenda
1797 (let* ((marker (org-get-at-bol 'org-hd-marker))
1798 (tags (org-with-point-at marker (org-get-tags-at))))
1799 (if (and (eq arg 4) tags)
1800 (org-agenda-clock-in '(16))
1801 (bh/clock-in-organization-task-as-default)))
1803 ;; We are not in the agenda
1807 ; Find the tags on the current task
1808 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
1809 (org-clock-in '(16))
1810 (bh/clock-in-organization-task-as-default)))))
1812 (defun bh/punch-out ()
1814 (setq bh/keep-clock-running nil)
1815 (when (org-clock-is-active)
1817 (org-agenda-remove-restriction-lock))
1819 (defun bh/clock-in-default-task ()
1821 (org-with-point-at org-clock-default-task
1824 (defun bh/clock-in-parent-task ()
1825 "Move point to the parent (project) task if any and clock in"
1826 (let ((parent-task))
1830 (while (and (not parent-task) (org-up-heading-safe))
1831 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
1832 (setq parent-task (point))))
1834 (org-with-point-at parent-task
1836 (when bh/keep-clock-running
1837 (bh/clock-in-default-task)))))))
1839 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
1841 (defun bh/clock-in-organization-task-as-default ()
1843 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
1844 (org-clock-in '(16))))
1846 (defun bh/clock-out-maybe ()
1847 (when (and bh/keep-clock-running
1848 (not org-clock-clocking-in)
1849 (marker-buffer org-clock-default-task)
1850 (not org-clock-resolving-clocks-due-to-idleness))
1851 (bh/clock-in-parent-task)))
1853 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
1856 (defun bh/clock-in-task-by-id (id)
1857 "Clock in a task by id"
1858 (org-with-point-at (org-id-find id 'marker)
1859 (org-clock-in nil)))
1861 (defun bh/clock-in-last-task (arg)
1862 "Clock in the interrupted task if there is one
1863 Skip the default task and get the next one.
1864 A prefix arg forces clock in of the default task."
1866 (let ((clock-in-to-task
1868 ((eq arg 4) org-clock-default-task)
1869 ((and (org-clock-is-active)
1870 (equal org-clock-default-task (cadr org-clock-history)))
1871 (caddr org-clock-history))
1872 ((org-clock-is-active) (cadr org-clock-history))
1873 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
1874 (t (car org-clock-history)))))
1876 (org-with-point-at clock-in-to-task
1877 (org-clock-in nil))))
1880 (defun org-export-to-ods ()
1882 (let ((csv-file "data.csv"))
1883 (org-table-export csv-file "orgtbl-to-csv")
1884 (org-odt-convert csv-file "ods" 'open)))
1886 ; allow for zero-width-space to be a break in regexp too
1887 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
1888 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
1889 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
1891 ;; support inserting screen shots
1892 (defun my/org-insert-screenshot ()
1893 "Take a screenshot into a time stamped unique-named file in the
1894 same directory as the org-buffer and insert a link to this file."
1896 (defvar my/org-insert-screenshot/filename)
1897 (setq my/org-insert-screenshot/filename
1899 "Screenshot to insert: "
1901 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
1904 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
1905 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
1906 (org-display-inline-images))
1908 (defun my/fix-inline-images ()
1909 (when org-inline-image-overlays
1910 (org-redisplay-inline-images)))
1912 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
1914 ;; use xelatex to preview with imagemagick
1915 (add-to-list 'org-preview-latex-process-alist
1916 '(xelateximagemagick
1917 :programs ("xelatex" "convert")
1918 :description "pdf > png"
1919 :message "you need to install xelatex and imagemagick"
1921 :image-input-type "pdf"
1922 :image-output-type "png"
1923 :image-size-adjust (1.0 . 1.0)
1924 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
1925 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
1927 ;; use xelatex by default
1928 (setq org-preview-latex-default-process 'xelateximagemagick)
1930 ; from http://orgmode.org/Changes.html
1931 (defun my/org-repair-property-drawers ()
1932 "Fix properties drawers in current buffer.
1933 Ignore non Org buffers."
1935 (when (eq major-mode 'org-mode)
1936 (org-with-wide-buffer
1937 (goto-char (point-min))
1938 (let ((case-fold-search t)
1939 (inline-re (and (featurep 'org-inlinetask)
1940 (concat (org-inlinetask-outline-regexp)
1944 (unless (and inline-re (org-looking-at-p inline-re))
1946 (let ((end (save-excursion (outline-next-heading) (point))))
1948 (when (org-looking-at-p org-planning-line-re) (forward-line))
1949 (when (and (< (point) end)
1950 (not (org-looking-at-p org-property-drawer-re))
1952 (and (re-search-forward org-property-drawer-re end t)
1953 (eq (org-element-type
1954 (save-match-data (org-element-at-point)))
1956 (insert (delete-and-extract-region
1958 (min (1+ (match-end 0)) end)))
1959 (unless (bolp) (insert "\n"))))))))))))
1963 #+BEGIN_SRC emacs-lisp
1967 (use-package calfw-org
1970 (use-package org-gcal
1972 :config '((if (file-readable-p "~/.hide/org_gcal.el")
1973 (load-file "~/.hide/org_gcal.el"))
1978 #+BEGIN_SRC emacs-lisp
1982 ;; Show notification 10 minutes before event
1983 (setq appt-message-warning-time 10)
1984 ;; Disable multiple reminders
1985 (setq appt-display-interval appt-message-warning-time)
1986 (setq appt-display-mode-line nil)
1988 ;; add automatic reminders for appointments
1989 (defun my/org-agenda-to-appt ()
1991 (setq appt-time-msg-list nil)
1992 (org-agenda-to-appt))
1993 ;; add reminders when starting emacs
1994 (my/org-agenda-to-appt)
1995 ;; when rebuilding the agenda
1996 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
1997 "Pressing `r' on the agenda will also add appointments."
1998 (my/org-agenda-to-appt)
2000 ;; when saving all org buffers
2001 (defadvice org-save-all-org-buffers (after org-save-all-org-buffers-add-appts)
2002 "Re-add appts after saving all org buffers"
2003 (my/org-agenda-to-appt))
2004 ;; Display appointments as a window manager notification
2005 (setq appt-disp-window-function 'my/appt-display)
2006 (setq appt-delete-window-function (lambda () t))
2008 (setq my/appt-notification-app (concat (getenv "HOME") "/bin/appt_notification"))
2010 (defun my/appt-display (min-to-app new-time msg)
2011 (if (atom min-to-app)
2012 (start-process "my/appt-notification-app" nil my/appt-notification-app min-to-app msg)
2013 (dolist (i (number-sequence 0 (1- (length min-to-app))))
2014 (start-process "my/appt-notification-app" nil my/appt-notification-app
2015 (nth i min-to-app) (nth i msg))))
2022 #+BEGIN_SRC emacs-lisp
2027 #+BEGIN_SRC emacs-lisp
2028 (global-unset-key "\M-g")
2029 (global-set-key (kbd "M-g l") 'goto-line)
2033 #+BEGIN_SRC emacs-lisp
2034 (use-package debian-changelog
2036 :mode "debian/changelog"
2038 (setq debian-changelog-mailing-address "don@debian.org")
2039 (setq debian-changelog-full-name "Don Armstrong"))
2041 * Misc (uncharacterized)
2042 #+BEGIN_SRC emacs-lisp
2043 (setq calendar-latitude 38.6)
2044 (setq calendar-longitude -121.5)
2045 (setq case-fold-search t)
2046 (setq confirm-kill-emacs (quote y-or-n-p))
2047 (setq cperl-lazy-help-time nil)
2049 (setq display-time-24hr-format t)
2050 (setq display-time-day-and-date t)
2051 (display-time-mode 1)
2052 (global-font-lock-mode 1)
2054 (setq log-edit-keep-buffer t)
2055 (setq mail-user-agent (quote sendmail-user-agent))
2056 (setq markdown-enable-math t)
2057 (setq markdown-follow-wiki-link-on-enter nil)
2058 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
2059 (setq ps-footer-font-size (quote (8 . 10)))
2060 (setq ps-header-font-size (quote (8 . 10)))
2061 (setq ps-header-title-font-size (quote (10 . 10)))
2062 (setq ps-line-number-color "blue")
2063 (setq ps-print-footer t)
2064 (setq ps-print-footer-frame nil)
2065 (setq ps-print-only-one-header t)
2066 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
2068 (setq sentence-end-double-space nil)
2069 ; enable matching parenthesis
2072 (setq user-mail-address "don@donarmstrong.com")
2073 (setq vc-delete-logbuf-window nil)
2074 (setq vc-follow-symlinks t)
2076 ;; use git before SVN; use CVS earlier, because I have CVS
2077 ;; repositories inside of git directories
2078 (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
2080 ;; switch back to the old primary selection method
2081 (setq x-select-enable-clipboard nil)
2082 (setq x-select-enable-primary t)
2083 ; (setq mouse-drag-copy-region t)
2085 (fset 'perl-mode 'cperl-mode)
2086 ;;(load-file "cperl-mode.el")
2090 (global-set-key "\C-xp" 'server-edit)
2092 (setq-default auto-mode-alist (cons '("\.wml$" .
2093 (lambda () (html-mode) (auto-fill-mode)))
2097 ; use markdown mode for mdwn files
2098 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
2099 (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
2102 ;; tramp configuration
2103 (setq tramp-use-ssh-controlmaster-options nil)
2105 (setq-default c-indent-level 4)
2106 (setq-default c-brace-imaginary-offset 0)
2107 (setq-default c-brace-offset -4)
2108 (setq-default c-argdecl-indent 4)
2109 (setq-default c-label-offset -4)
2110 (setq-default c-continued-statement-offset 4)
2112 (setq-default indent-tabs-mode nil)
2113 (setq-default tab-width 4)
2116 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
2117 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
2118 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
2119 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
2120 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
2123 (defun insert-date ()
2124 "Insert date at point."
2126 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
2127 (global-set-key "\C-[d" 'insert-date)
2129 (defun unfill-paragraph (arg)
2130 "Pull this whole paragraph up onto one line."
2132 (let ((fill-column 10000))
2133 (fill-paragraph arg))
2136 (column-number-mode t)
2138 ; abbrev mode settings
2139 ; load abbreviations from
2140 (setq abbrev-file-name
2141 "~/.emacs_abbrev_def")
2143 ; read the abbrev file if it exists
2144 (if (file-exists-p abbrev-file-name)
2145 (quietly-read-abbrev-file))
2147 ; for now, use abbrev mode everywhere
2148 (setq default-abbrev-mode t)
2150 (desktop-load-default)
2152 '(icomplete-mode on)
2154 ;; custom-set-faces was added by Custom.
2155 ;; If you edit it by hand, you could mess it up, so be careful.
2156 ;; Your init file should contain only one such instance.
2157 ;; If there is more than one, they won't work right.
2158 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
2161 (put 'upcase-region 'disabled nil)
2162 (put 'downcase-region 'disabled nil)
2163 (put 'narrow-to-region 'disabled nil)
2165 ; (defun turn-on-flyspell ()
2166 ; "Force flyspell-mode on using a positive arg. For use in hooks."
2168 ; (flyspell-mode 1))
2171 ; Outline-minor-mode key map
2172 (define-prefix-command 'cm-map nil "Outline-")
2174 (define-key cm-map "q" 'outline-hide-sublevels) ; Hide everything but the top-level headings
2175 (define-key cm-map "t" 'outline-hide-body) ; Hide everything but headings (all body lines)
2176 (define-key cm-map "o" 'outline-hide-other) ; Hide other branches
2177 (define-key cm-map "c" 'outline-hide-entry) ; Hide this entry's body
2178 (define-key cm-map "l" 'outline-hide-leaves) ; Hide body lines in this entry and sub-entries
2179 (define-key cm-map "d" 'outline-hide-subtree) ; Hide everything in this entry and sub-entries
2181 (define-key cm-map "a" 'outline-show-all) ; Show (expand) everything
2182 (define-key cm-map "e" 'outline-show-entry) ; Show this heading's body
2183 (define-key cm-map "i" 'outline-show-children) ; Show this heading's immediate child sub-headings
2184 (define-key cm-map "k" 'outline-show-branches) ; Show all sub-headings under this heading
2185 (define-key cm-map "s" 'outline-show-subtree) ; Show (expand) everything in this heading & below
2187 (define-key cm-map "u" 'outline-up-heading) ; Up
2188 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
2189 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
2190 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
2191 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
2192 (global-set-key "\M-o" cm-map)
2194 ; ediff configuration
2195 ; don't use the multi-window configuration
2196 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
2198 ; fix up css mode to not be silly
2199 ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
2200 (setq cssm-indent-level 4)
2201 (setq cssm-newline-before-closing-bracket t)
2202 (setq cssm-indent-function #'cssm-c-style-indenter)
2203 (setq cssm-mirror-mode nil)
2205 (require 'multi-web-mode)
2206 (setq mweb-default-major-mode 'html-mode)
2207 (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
2208 (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
2209 (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
2210 (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
2211 (multi-web-global-mode 1)
2213 ; load sql-indent when sql is loaded
2214 (eval-after-load "sql"
2215 '(load-library "sql-indent"))
2217 ; fix up tmux xterm keys
2218 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
2219 (defun fix-up-tmux-keys ()
2220 "Fix up tmux xterm keys"
2223 (let ((x 2) (tkey ""))
2243 ;; ctrl + alt + shift
2245 (setq tkey "C-M-S-"))
2248 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
2249 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
2250 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
2251 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
2253 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
2255 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
2257 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
2259 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
2261 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2263 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2265 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
2267 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
2269 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
2271 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
2273 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
2275 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
2277 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
2279 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
2281 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
2283 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
2285 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
2287 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
2289 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
2291 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
2293 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
2295 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
2297 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
2299 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
2301 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
2303 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
2310 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
2312 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
2313 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
2314 (if (or (buffer-modified-p)
2315 (verify-visited-file-modtime)
2316 (< (* 8 1024 1024) (buffer-size))
2317 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
2319 (clear-visited-file-modtime)
2321 (ad-activate 'ask-user-about-supersession-threat)
2323 (global-set-key "\M- " 'hippie-expand)
2328 #+BEGIN_SRC emacs-lisp
2329 (unless (server-running-p)
2336 #+BEGIN_SRC emacs-lisp
2337 (provide 'don-configuration)