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
32 ;; add /etc/ssl/ca-global/ca-certificates.crt so that we can
33 ;; download packages when we're on Debian hosts which chop down the
34 ;; list of available certificates
36 (add-to-list 'gnutls-trustfiles "/etc/ssl/ca-global/ca-certificates.crt")
37 (setq package-enable-at-startup nil)
38 (setq package--init-file-ensured t)
39 (setq package-user-dir "~/var/emacs/elpa")
40 (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
41 ("melpa" . "https://melpa.org/packages/")
42 ("org" . "http://orgmode.org/elpa/")))
43 (setq use-package-verbose (not (bound-and-true-p byte-compile-current-file))))
44 (mapc #'(lambda (add) (add-to-list 'load-path add))
47 (unless (package-installed-p 'use-package)
48 (package-refresh-contents)
49 (package-install 'use-package))
50 (let ((package-user-dir-real (file-truename package-user-dir)))
51 ;; The reverse is necessary, because outside we mapc
52 ;; add-to-list element-by-element, which reverses.
53 (nreverse (apply #'nconc
54 ;; Only keep package.el provided loadpaths.
55 (mapcar #'(lambda (path)
56 (if (string-prefix-p package-user-dir-real path)
61 ;;; fix up info paths for packages
62 (with-eval-after-load "info"
64 (dolist (dir (directory-files package-user-dir))
65 (let ((fdir (concat (file-name-as-directory package-user-dir) dir)))
66 (unless (or (member dir '("." ".." "archives" "gnupg"))
67 (not (file-directory-p fdir))
68 (not (file-exists-p (concat (file-name-as-directory fdir) "dir"))))
69 (add-to-list 'Info-directory-list fdir)))))
73 (require 'use-package))
78 #+BEGIN_SRC emacs-lisp
81 :commands (paradox-upgrade-packages paradox-list-packages)
83 (setq paradox-execute-asynchronously t)
84 (setq paradox-github-token t) ; I don't want to be prompted about this integration
89 #+BEGIN_SRC emacs-lisp
90 (add-to-list 'exec-path '"/usr/local/bin")
91 (add-to-list 'exec-path '"~/bin/")
95 #+BEGIN_SRC emacs-lisp
96 (add-to-list 'load-path '"~/lib/emacs_el/")
97 (add-to-list 'load-path '"~/lib/emacs_el/magit-annex")
100 #+BEGIN_SRC emacs-lisp
101 ;; Set the custom file to /dev/null and don't bother to load it
102 (setq custom-file "/dev/null")
106 #+BEGIN_SRC emacs-lisp
107 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
108 ;; execute conditional code when loading libraries
109 (defmacro with-library (symbol &rest body)
110 `(when (require ,symbol nil t)
112 (put 'with-library 'lisp-indent-function 1)
116 ** Safe Local Variables
117 #+BEGIN_SRC emacs-lisp
118 (setq safe-local-variable-values
119 (quote ((auto-save-default)
121 (cperl-indent-level . 4)
123 (indent-tabs-mode . f)
124 (vcl-indent-level . 4)
128 #+BEGIN_SRC emacs-lisp
129 (setq global-mark-ring-max 128
133 (defun don/minibuffer-setup-hook ()
134 (setq gc-cons-threshold most-positive-fixnum))
136 (defun don/minibuffer-exit-hook ()
137 (setq gc-cons-threshold 1048576))
139 (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
140 (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
144 #+BEGIN_SRC emacs-lisp
145 (use-package spacemacs-common
146 :ensure spacemacs-theme
148 (load-theme 'spacemacs-dark t)
152 #+BEGIN_SRC emacs-lisp
153 (use-package hippie-exp
154 :bind* (("M-<SPC>" . hippie-expand))
158 #+BEGIN_SRC emacs-lisp
159 (use-package flyspell
161 :diminish flyspell-mode 🐝
163 (add-hook 'text-mode-hook 'turn-on-flyspell)
164 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
165 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
166 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
168 (setq ispell-program-name "ispell")
173 #+begin_src emacs-lisp :tangle yes
179 #+BEGIN_SRC emacs-lisp
184 #+BEGIN_SRC emacs-lisp
185 (use-package eyebrowse
187 :diminish eyebrowse-mode
188 :init (setq eyebrowse-keymap-prefix (kbd "C-c e"))
190 (setq eyebrowse-wrap-around t)
193 (defun my/eyebrowse-new-window-config ()
197 ;; start at 1 run till 0
198 (let ((j (mod (+ i 1) 10)))
199 (when (and (not done)
200 (not (eyebrowse--window-config-present-p j)))
201 (eyebrowse-switch-to-window-config j)
202 (call-interactively 'eyebrowse-rename-window-config2 j)
207 ;; I don't use latex-preview-pane
208 ;; (require 'latex-preview-pane)
209 ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
210 ;; ;; latex-preview-pane uses window-parameters which are
211 ;; ;; not preserved by eyebrowse, so we close the preview
212 ;; ;; pane before switching, it will be regenerated when we
213 ;; ;; edit the TeX file.
214 ;; (when (lpp/window-containing-preview)
215 ;; (delete-window (lpp/window-containing-preview))))
217 ;; (add-to-list 'eyebrowse-pre-window-switch-hook
218 ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
220 ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
221 ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
222 ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
223 ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
224 ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
232 #+BEGIN_SRC emacs-lisp
233 (defun my/vsplit-last-buffer ()
234 "Split the window vertically and display the previous buffer."
236 (split-window-vertically)
238 (switch-to-next-buffer))
240 (defun my/hsplit-last-buffer ()
241 "Split the window horizontally and display the previous buffer."
243 (split-window-horizontally)
245 (switch-to-next-buffer))
247 (bind-key "C-x 2" 'my/vsplit-last-buffer)
248 (bind-key "C-x 3" 'my/hsplit-last-buffer)
250 (setq split-width-threshold 100)
251 (setq split-height-threshold 60)
253 (defun my/split-window-prefer-vertically (window)
254 "If there's only one window (excluding any possibly active
255 minibuffer), then split the current window horizontally."
256 (if (and (one-window-p t)
257 (not (active-minibuffer-window))
258 ( < (frame-width) (frame-height))
260 (let ((split-width-threshold nil))
261 (split-window-sensibly window))
262 (split-window-sensibly window)))
264 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
265 (setq window-combination-resize t)
268 *** Compilation window
270 If there is no compilation window, open one at the bottom, spanning
271 the complete width of the frame. Otherwise, reuse existing window. In
272 the former case, if there was no error the window closes
275 #+BEGIN_SRC emacs-lisp
276 (add-to-list 'display-buffer-alist
277 `(,(rx bos "*compilation*" eos)
278 (display-buffer-reuse-window
279 display-buffer-in-side-window)
280 (reusable-frames . visible)
282 (window-height . 0.4)))
285 #+BEGIN_SRC emacs-lisp
286 (defun my/compilation-exit-autoclose (status code msg)
287 ;; If M-x compile exists with a 0
288 (when (and (eq status 'exit) (zerop code))
289 ;; and delete the *compilation* window
290 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
291 (when (and (not (window-at-side-p compilation-window 'top))
292 (window-at-side-p compilation-window 'left)
293 (window-at-side-p compilation-window 'right))
294 (delete-window compilation-window))))
295 ;; Always return the anticipated result of compilation-exit-message-function
298 ;; Specify my function (maybe I should have done a lambda function)
299 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
302 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
303 value, the compilation buffer scrolls automatically to follow the
304 output. If the value is ~first-error~, scrolling stops when the first
305 error appears, leaving point at that error. For any other non-nil
306 value, scrolling continues until there is no more output.
308 #+BEGIN_SRC emacs-lisp
309 (setq compilation-scroll-output 'first-error)
312 ** Mode line cleaning
314 #+BEGIN_SRC emacs-lisp
315 (use-package diminish
320 #+BEGIN_SRC emacs-lisp
327 #+BEGIN_SRC emacs-lisp
329 :if (>= emacs-major-version 25)
331 :bind (("C-c C-<SPC>" . avy-goto-word-or-subword-1)
332 ("C-c j j" . avy-goto-word-or-subword-1)
333 ("M-g g" . avy-goto-line))
334 :config (progn (setq avy-background t))
337 *** Ace-link (jumping to links)
338 #+BEGIN_SRC emacs-lisp
339 (use-package ace-link
341 ; bind o in most modes
342 :config (ace-link-setup-default))
344 *** Jumping through edit points (goto-chg)
345 #+BEGIN_SRC emacs-lisp
346 (use-package goto-chg
348 :bind (("C-c j ," . goto-last-change)
349 ("C-c j ." . goto-last-change-reverse))
352 *** Jumping to bookmarks (visible bookmarks, bm)
353 #+BEGIN_SRC emacs-lisp
356 :bind (("C-c j b ." . bm-next)
357 ("C-c j b ," . bm-previous)
358 ("C-c j b SPC" . bm-toggle)))
363 #+BEGIN_SRC emacs-lisp
364 (use-package yasnippet
366 :diminish yas-minor-mode
369 (setq yas-verbosity 1)
370 (define-key yas-minor-mode-map (kbd "<tab>") nil)
371 (define-key yas-minor-mode-map (kbd "TAB") nil)
372 (define-key yas-minor-mode-map (kbd "<backtab>") nil)
373 (setq yas-snippet-dirs '("~/lib/emacs_el/snippets/"
374 "~/lib/emacs_el/yasnippet-snippets/snippets/"))
375 (add-to-list 'hippie-expand-try-functions-list
376 'yas-hippie-try-expand)
382 #+BEGIN_SRC emacs-lisp
383 (use-package auto-yasnippet
385 :bind (("H-w" . aya-create)
391 #+BEGIN_SRC emacs-lisp
394 :bind (("M-/" . company-complete))
396 (setq company-echo-delay 0 ; remove blinking
397 company-show-numbers t ; show numbers for easy selection
398 company-selection-wrap-around t
399 company-require-match nil
400 company-dabbrev-ignore-case t
401 company-dabbrev-ignore-invisible t
402 company-dabbrev-other-buffers t
403 company-dabbrev-downcase nil
404 company-dabbrev-code-everywhere t
405 company-tooltip-align-annotations t
406 company-minimum-prefix-length 1
407 company-global-modes '(not)
408 company-lighter-base "(C)")
409 (global-company-mode 1)
410 :bind (:map company-active-map
411 ("C-n" . company-select-next)
412 ("C-p" . company-select-previous)
413 ("M-?" . company-show-doc-buffer)
414 ("M-." . company-show-location)
419 #+BEGIN_SRC emacs-lisp
420 (use-package company-c-headers
423 (defun malb/ede-object-system-include-path ()
424 "Return the system include path for the current buffer."
426 (ede-system-include-path ede-object)))
428 (setq company-c-headers-path-system
429 #'malb/ede-object-system-include-path)
431 (add-to-list 'company-backends #'company-c-headers)))
434 #+BEGIN_SRC emacs-lisp
435 (use-package company-anaconda
437 :config (add-to-list 'company-backends #'company-anaconda))
440 #+BEGIN_SRC emacs-lisp
441 (use-package company-plsense
446 #+BEGIN_SRC emacs-lisp
447 (use-package company-math
450 #+BEGIN_SRC emacs-lisp
451 (use-package company-auctex
454 (defun company-auctex-labels (command &optional arg &rest ignored)
455 "company-auctex-labels backend"
456 (interactive (list 'interactive))
458 (interactive (company-begin-backend 'company-auctex-labels))
459 (prefix (company-auctex-prefix "\\\\.*ref{\\([^}]*\\)\\="))
460 (candidates (company-auctex-label-candidates arg))))
462 (add-to-list 'company-backends
463 '(company-auctex-macros
464 company-auctex-environments
465 company-math-symbols-unicode
466 company-math-symbols-latex))
468 (add-to-list 'company-backends #'company-auctex-labels)
469 (add-to-list 'company-backends #'company-auctex-bibs)
473 #+BEGIN_SRC emacs-lisp
474 (use-package company-bibtex
480 #+BEGIN_SRC emacs-lisp
481 (use-package company-shell
484 (setq company-shell-modes '(sh-mode shell-mode))
485 (add-to-list 'company-backends 'company-shell)))
490 Add YasSippet support for all company backends. ([[https://github.com/syl20bnr/spacemacs/pull/179][source]])
492 *Note:* Do this at the end of =company-mode= config.
494 #+BEGIN_SRC emacs-lisp
495 (defvar malb/company-mode/enable-yas t
496 "Enable yasnippet for all backends.")
498 (defun malb/company-mode/backend-with-yas (backend)
499 (if (or (not malb/company-mode/enable-yas)
501 (member 'company-yasnippet backend)))
503 (append (if (consp backend) backend (list backend))
504 '(:with company-yasnippet))))
506 (setq company-backends
507 (mapcar #'malb/company-mode/backend-with-yas company-backends))
512 Enable/disable company completion from ispell dictionaries ([[https://github.com/redguardtoo/emacs.d/blob/master/lisp/init-company.el][source]])
514 #+BEGIN_SRC emacs-lisp
515 (defun malb/toggle-company-ispell ()
518 ((member '(company-ispell :with company-yasnippet) company-backends)
519 (setq company-backends (delete '(company-ispell :with company-yasnippet) company-backends))
520 (add-to-list 'company-backends '(company-dabbrev :with company-yasnippet) t)
521 (message "company-ispell disabled"))
523 (setq company-backends (delete '(company-dabbrev :with company-yasnippet) company-backends))
524 (add-to-list 'company-backends '(company-ispell :with company-yasnippet) t)
525 (message "company-ispell enabled!"))))
527 (defun malb/company-ispell-setup ()
528 ;; @see https://github.com/company-mode/company-mode/issues/50
529 (when (boundp 'company-backends)
530 (make-local-variable 'company-backends)
531 (setq company-backends (delete '(company-dabbrev :with company-yasnippet) company-backends))
532 (add-to-list 'company-backends '(company-ispell :with company-yasnippet) t)
533 ;; https://github.com/redguardtoo/emacs.d/issues/473
534 (if (and (boundp 'ispell-alternate-dictionary)
535 ispell-alternate-dictionary)
536 (setq company-ispell-dictionary ispell-alternate-dictionary))))
541 1. =yas-expand= is run first and does what it has to, then it calls =malb/indent-fold-or-complete=.
543 2. This function then hopefully does what I want:
545 a. if a region is active, just indent
546 b. if we’re looking at a space after a non-whitespace character, we try some company-expansion
547 c. If =hs-minor-mode= or =outline-minor-mode= is active, try those next
548 d. otherwise call whatever would have been called otherwise.
550 ([[http://emacs.stackexchange.com/q/21182/8930][source]], [[http://emacs.stackexchange.com/q/7908/8930][source]])
552 #+BEGIN_SRC emacs-lisp
553 (defun malb/indent-fold-or-complete (&optional arg)
556 ;; if a region is active, indent
558 (indent-region (region-beginning)
560 ;; if the next char is space or eol, but prev char not whitespace
561 ((and (not (active-minibuffer-window))
564 (looking-back "[^[:space:]]")
565 (not (looking-back "^")))
567 (cond (company-mode (company-complete-common))
568 (auto-complete-mode (auto-complete))))
570 ;; no whitespace anywhere
571 ((and (not (active-minibuffer-window))
572 (looking-at "[^[:space:]]")
573 (looking-back "[^[:space:]]")
574 (not (looking-back "^")))
576 ((bound-and-true-p hs-minor-mode)
577 (save-excursion (end-of-line) (hs-toggle-hiding)))
578 ((bound-and-true-p outline-minor-mode)
579 (save-excursion (outline-cycle)))))
581 ;; by default just call whatever was bound
583 (let ((fn (or (if (current-local-map) (lookup-key (current-local-map) (kbd "TAB")))
584 'indent-for-tab-command)))
585 (if (not (called-interactively-p 'any))
587 (setq this-command fn)
588 (call-interactively fn))))))
590 (defun malb/toggle-fold ()
592 (cond ((eq major-mode 'org-mode)
593 (org-force-cycle-archived))
594 ((bound-and-true-p hs-minor-mode)
599 ((bound-and-true-p outline-minor-mode)
603 (bind-key "<tab>" #'malb/indent-fold-or-complete)
604 (bind-key "C-<tab>" #'malb/toggle-fold)
608 #+BEGIN_SRC emacs-lisp
610 (use-package tinyprocmail
611 :load-path "~/lib/emacs_el/tiny-tools/lisp/tiny"
612 :mode (".procmailrc" . turn-on-tinyprocmail-mode)
617 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
620 :bind (("C-x g" . magit-status)
621 ("C-x C-g" . magit-status))
623 ;; refine diffs always (hilight words)
624 (setq magit-diff-refine-hunk nil)
626 (use-package magit-annex
628 :load-path "~/lib/emacs_el/magit-annex/"
630 (use-package magit-vcsh
636 #+BEGIN_SRC emacs-lisp
637 (use-package cperl-mode
640 ;; Use c-mode for perl .xs files
641 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
642 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
643 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
644 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
645 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
648 cperl-auto-newline nil
649 cperl-auto-newline-after-colon nil
650 cperl-continued-statement-offset 4
651 cperl-brace-offset -1
652 cperl-continued-brace-offset 0
653 cperl-label-offset -4
654 cperl-highlight-variables-indiscriminately t
655 cperl-electric-lbrace-space nil
656 cperl-indent-parens-as-block nil
657 cperl-close-paren-offset -1
658 cperl-tab-always-indent t)
659 ;;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
664 #+BEGIN_SRC emacs-lisp
665 (use-package markdown-mode
667 :mode (("\\.md\\'" . markdown-mode)
668 ("\\.mdwn\\'" . markdown-mode)
669 ("README\\.md\\'" . gfm-mode)
672 (setq markdown-enable-math t)
673 (setq markdown-follow-wiki-link-on-enter nil)
674 (bind-key "M-." #'markdown-jump markdown-mode-map)
675 (add-hook 'markdown-mode-hook #'flyspell-mode)
676 (add-hook 'markdown-mode-hook #'outline-minor-mode)
677 (bind-key "C-<tab>" #'outline-cycle markdown-mode-map)
682 #+BEGIN_SRC emacs-lisp
683 ; load sql-indent when sql is loaded
684 (use-package sql-indent
688 :mode (("\\.sql\\'" . sql-mode))
692 #+BEGIN_SRC emacs-lisp
694 :commands ediff ediff3
697 ;; ediff configuration
698 ;; don't use the multi-window configuration
699 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
702 ** Do the Right Thing Indenting
703 Attempts to automatically identify the right indentation for a file
704 #+BEGIN_SRC emacs-lisp
705 (use-package dtrt-indent
709 ** VCL --editing varnish configuration files
710 #+BEGIN_SRC emacs-lisp
711 (use-package vcl-mode
718 #+BEGIN_SRC emacs-lisp
719 (defun malb/helm-omni (&rest arg)
720 ;; just in case someone decides to pass an argument, helm-omni won't fail.
722 (unless helm-source-buffers-list
723 (setq helm-source-buffers-list
724 (helm-make-source "Buffers" 'helm-source-buffers)))
728 (if (projectile-project-p)
729 '(helm-source-projectile-buffers-list
730 helm-source-buffers-list)
731 '(helm-source-buffers-list)) ;; list of all open buffers
733 `(((name . "Virtual Workspace")
734 (candidates . ,(--map (cons (eyebrowse-format-slot it) (car it))
735 (eyebrowse--get 'window-configs)))
736 (action . (lambda (candidate)
737 (eyebrowse-switch-to-window-config candidate)))))
739 (if (projectile-project-p)
740 '(helm-source-projectile-recentf-list
742 '(helm-source-recentf)) ;; all recent files
744 ;; always make some common files easily accessible
745 ;;'(((name . "Common Files")
746 ;; (candidates . malb/common-file-targets)
747 ;; (action . (("Open" . (lambda (x) (find-file (eval x))))))))
749 '(helm-source-files-in-current-dir
751 helm-source-bookmarks
752 helm-source-buffer-not-found ;; ask to create a buffer otherwise
754 "*Helm all the things*"))
758 :bind (("M-x" . helm-M-x)
759 ("C-x C-f" . helm-find-files)
760 ("C-x b" . helm-buffers-list) ; malb/helm-omni)
761 ("C-x C-b" . helm-buffers-list) ; malb/helm-omni)
762 ("C-c <SPC>" . helm-all-mark-rings))
764 (require 'helm-config)
765 (require 'helm-for-files)
766 (require 'helm-bookmark)
769 (define-key global-map [remap find-file] 'helm-find-files)
770 (define-key global-map [remap occur] 'helm-occur)
771 (define-key global-map [remap list-buffers] 'helm-buffers-list)
772 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
773 (unless (boundp 'completion-in-region-function)
774 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
775 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
776 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
781 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
783 #+BEGIN_SRC emacs-lisp
784 (use-package helm-flx
787 ;; these are helm configs, but they kind of fit here nicely
788 (setq helm-M-x-fuzzy-match t
789 helm-bookmark-show-location t
790 helm-buffers-fuzzy-matching t
791 helm-completion-in-region-fuzzy-match t
792 helm-file-cache-fuzzy-match t
793 helm-imenu-fuzzy-match t
794 helm-mode-fuzzy-match t
795 helm-locate-fuzzy-match nil
797 helm-recentf-fuzzy-match nil
798 helm-semantic-fuzzy-match t)
802 #+BEGIN_SRC emacs-lisp
804 ;;; stolen from https://github.com/malb/emacs.d/blob/master/malb.org
805 (defun malb/helm-swoop-pre-fill ()
806 (thing-at-point 'symbol))
807 (defvar malb/helm-swoop-ignore-major-mode "List of major modes to ignore for helm-swoop")
808 (setq malb/helm-swoop-ignore-major-mode '(dired-mode
809 paradox-menu-mode doc-view-mode pdf-view-mode
810 mu4e-headers-mode org-mode markdown-mode latex-mode
811 ein:notebook-multilang-mode))
813 (defun malb/swoop-or-search ()
815 (if (or (> (buffer-size) 1048576) ;; helm-swoop can be slow on big buffers
816 (memq major-mode malb/helm-swoop-ignore-major-mode))
820 (use-package helm-swoop
823 :bind (("C-c o" . helm-multi-swoop-org)
824 ("C-s" . malb/swoop-or-search)
825 ("C-M-s" . helm-multi-swoop-all))
828 (setq helm-swoop-pre-input-function #'malb/helm-swoop-pre-fill
829 helm-swoop-split-with-multiple-windows nil
830 helm-swoop-split-direction #'split-window-horizontally
831 helm-swoop-split-window-function 'helm-default-display-buffer
832 helm-swoop-speed-or-color t)
834 ;; https://emacs.stackexchange.com/questions/28790/helm-swoop-how-to-make-it-behave-more-like-isearch
835 (defun malb/helm-swoop-C-s ()
837 (if (boundp 'helm-swoop-pattern)
838 (if (equal helm-swoop-pattern "")
839 (previous-history-element 1)
843 (bind-key "C-S-s" #'helm-swoop-from-isearch isearch-mode-map)
844 (bind-key "C-S-s" #'helm-multi-swoop-all-from-helm-swoop helm-swoop-map)
845 (bind-key "C-r" #'helm-previous-line helm-swoop-map)
846 (bind-key "C-s" #'malb/helm-swoop-C-s helm-swoop-map)
847 (bind-key "C-r" #'helm-previous-line helm-multi-swoop-map)
848 (bind-key "C-s" #'malb/helm-swoop-C-s helm-multi-swoop-map))
853 #+BEGIN_SRC emacs-lisp
856 :config (setq helm-ag-base-command "ag --nocolor --nogroup"
857 helm-ag-command-option "--all-text"
858 helm-ag-insert-at-point 'symbol
859 helm-ag-fuzzy-match t
860 helm-ag-use-temp-buffer t
861 helm-ag-use-grep-ignore-list t
862 helm-ag-use-agignore t))
865 #+BEGIN_SRC emacs-lisp
866 (use-package helm-descbinds
868 :bind ("C-h b" . helm-descbinds)
869 :init (fset 'describe-bindings 'helm-descbinds))
873 #+BEGIN_SRC emacs-lisp
874 (use-package helm-c-yasnippet
876 :bind ("C-c h y" . helm-yas-complete)
878 (setq helm-yas-space-match-any-greedy t)))
881 #+BEGIN_SRC emacs-lisp
882 (use-package helm-org-rifle
885 (defun malb/helm-org-rifle-agenda-files (arg)
887 (let ((current-prefix-arg nil))
889 ((equal arg 4) (call-interactively #'helm-org-rifle-agenda-files nil))
890 ((equal arg 16) (helm-org-rifle-occur-agenda-files))
891 (t (helm-org-agenda-files-headings)))))))
894 This can be used to link things pretty quickly if necessary
895 #+BEGIN_SRC emacs-lisp
896 (use-package helm-google
898 :bind ("C-c h g" . helm-google)
900 (progn (add-to-list 'helm-google-actions
901 '("Copy URL" . (lambda (candidate)
903 (replace-regexp-in-string
904 "https://.*q=\\(.*\\)\&sa=.*"
910 (add-to-list 'helm-google-actions
911 '("Org Store Link" . (lambda (candidate)
912 (let ((title (car (split-string candidate "[\n]+")))
914 (replace-regexp-in-string
915 "https://.*q=\\(.*\\)\&sa=.*"
917 (push (list url title) org-stored-links))))
922 ** Projectile -- Project management
923 #+begin_src emacs-lisp
924 (use-package projectile
926 :bind (("<f5>" . projectile-compile-project)
927 ("<f6>" . next-error))
929 (use-package magit :ensure t)
930 (require 'helm-projectile)
933 (setq projectile-make-test-cmd "make check"
934 projectile-switch-project-action 'helm-projectile
935 projectile-mode-line '(:eval (format "»{%s}" (projectile-project-name))))
937 (projectile-global-mode)))
941 #+begin_src emacs-lisp
942 (use-package helm-projectile
945 (defvar malb/helm-source-file-not-found
946 (helm-build-dummy-source
951 'helm-projectile-sources-list
952 malb/helm-source-file-not-found t)
954 (helm-delete-action-from-source
955 "Grep in projects `C-s'"
956 helm-source-projectile-projects)
958 (helm-add-action-to-source
959 "Grep in projects `C-s'"
960 'helm-do-ag helm-source-projectile-projects 4)))
963 #+BEGIN_SRC emacs-lisp
966 :bind ("M-z" . avy-zap-up-to-char-dwim))
969 #+BEGIN_SRC emacs-lisp
971 :bind (("C-c 2" . my/hydra-orgmodes/body)
972 ("C-c @" . my/hydra-orgmodes/body)
973 ("C-c #" . my/hydra-outline/body)
974 ("C-c 3" . my/hydra-outline/body)
977 (defhydra my/hydra-orgmodes (:color blue :hint nil)
979 _n_: notes _c_: chaim _w_: wildman _o_: ool
980 _u_: uddin _s_: steve _r_: refile _f_: fh
981 _p_: read papers _R_: paper notes
986 ("n" (find-file "~/projects/org-notes/notes.org"))
987 ("c" (find-file "~/projects/org-notes/chaim.org"))
988 ("w" (find-file "~/projects/org-notes/wildman.org"))
989 ("u" (find-file "~/projects/org-notes/uddin.org"))
990 ("o" (find-file "~/projects/org-notes/ool.org"))
991 ("f" (find-file "~/projects/org-notes/fh.org"))
992 ("s" (find-file "~/projects/org-notes/sndservers.org"))
993 ("r" (find-file my/org-refile-file))
994 ("p" (find-file "~/projects/research/papers_to_read.org"))
995 ("R" (find-file "~/projects/research/paper_notes.org"))
996 ("h" (find-file "~/projects/org-notes/hpcbio.org"))
1001 ;; from https://github.com/abo-abo/hydra/wiki/Emacs
1002 (defhydra my/hydra-outline (:color pink :hint nil)
1005 ^^^^^^------------------------------------------------------
1006 _q_: sublevels _a_: all _u_: up
1007 _t_: body _e_: entry _n_: next visible
1008 _o_: other _i_: children _p_: previous visible
1009 _c_: entry _k_: branches _f_: forward same level
1010 _l_: leaves _s_: subtree _b_: backward same level
1015 ("q" outline-hide-sublevels) ; Hide everything but the top-level headings
1016 ("t" outline-hide-body) ; Hide everything but headings (all body lines)
1017 ("o" outline-hide-other) ; Hide other branches
1018 ("c" outline-hide-entry) ; Hide this entry's body
1019 ("l" outline-hide-leaves) ; Hide body lines in this entry and sub-entries
1020 ("d" outline-hide-subtree) ; Hide everything in this entry and sub-entries
1022 ("a" outline-show-all) ; Show (expand) everything
1023 ("e" outline-show-entry) ; Show this heading's body
1024 ("i" outline-show-children) ; Show this heading's immediate child sub-headings
1025 ("k" outline-show-branches) ; Show all sub-headings under this heading
1026 ("s" outline-show-subtree) ; Show (expand) everything in this heading & below
1028 ("u" outline-up-heading) ; Up
1029 ("n" outline-next-visible-heading) ; Next
1030 ("p" outline-previous-visible-heading) ; Previous
1031 ("f" outline-forward-same-level) ; Forward - same level
1032 ("b" outline-backward-same-level) ; Backward - same level
1038 #+BEGIN_SRC emacs-lisp
1041 (add-to-list 'tramp-methods '("vcsh"
1042 (tramp-login-program "vcsh")
1046 (tramp-remote-shell "/bin/sh")
1047 (tramp-remote-shell-args
1051 #+BEGIN_SRC emacs-lisp
1055 (setq-default reftex-default-bibliography
1056 '("~/projects/research/references.bib")))
1059 #+BEGIN_SRC emacs-lisp
1061 :config (setq bibtex-user-optional-fields
1062 (quote (("annote" "Personal annotation (ignored)")
1070 #+BEGIN_SRC emacs-lisp
1075 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
1076 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
1077 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
1078 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
1079 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
1080 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
1081 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
1082 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
1083 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
1084 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
1085 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
1087 (setq-default reftex-plug-into-AUCTeX t)
1088 ;; support fake section headers
1089 (setq TeX-outline-extra
1093 ("%subsubsection" 4)
1095 ;; add font locking to the headers
1096 (font-lock-add-keywords
1098 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
1099 0 'font-lock-keyword-face t)
1100 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
1101 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
1102 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
1103 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
1104 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
1106 ;; use smart quotes by default instead of `` and ''
1107 ;; taken from http://kieranhealy.org/esk/kjhealy.html
1108 (setq TeX-open-quote "“")
1109 (setq TeX-close-quote "”")
1111 ;; (TeX-add-style-hook
1116 ;; (custom-set-variables
1117 ;; '(font-latex-user-keyword-classes
1120 ;; font-lock-function-name-face 2 (command 1 t))))
1122 (setq-default TeX-parse-self t)
1123 (setq-default TeX-auto-save t)
1124 (setq-default TeX-master nil)
1125 (add-to-list 'LaTeX-font-list
1126 '(?\C-a "\\alert{","}"))
1129 '(TeX-add-style-hook
1132 (if (boundp 'reftex-ref-style-alist)
1134 'reftex-ref-style-alist
1135 '("Cleveref" "cleveref"
1136 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
1137 (reftex-ref-style-activate "Cleveref")
1139 '("cref" TeX-arg-ref)
1140 '("Cref" TeX-arg-ref)
1141 '("cpageref" TeX-arg-ref)
1142 '("Cpageref" TeX-arg-ref)))))
1145 '(add-to-list 'LaTeX-fill-excluded-macros
1148 (use-package font-latex
1150 (setq font-latex-match-reference-keywords
1172 (setq font-latex-fontify-script nil)
1173 (setq font-latex-fontify-sectioning (quote color))
1174 (setq font-latex-script-display (quote (nil)))
1179 #+BEGIN_SRC emacs-lisp
1183 :mode ("\\.R\\'" . ess-r-mode)
1184 :bind (:map ess-mode-map
1185 ("C-c C-R" . dla/ess-region-remote-eval))
1187 (autoload 'ess-r-mode "ess-site" nil t)
1188 (autoload 'R "ess-site" nil t)
1190 ; actually load the rest of ess
1192 (defun ess-change-directory (path)
1193 "Set the current working directory to PATH for both *R* and Emacs."
1194 (interactive "Directory to change to: ")
1196 (when (file-exists-p path)
1197 (ess-command (concat "setwd(\"" path "\")\n"))
1198 ;; use file-name-as-directory to ensure it has trailing /
1199 (setq default-directory (file-name-as-directory path))))
1200 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
1201 ;; outlining support for ess modes
1205 (outline-minor-mode)
1206 (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
1207 (defun outline-level ()
1208 (cond ((looking-at "^##### ") 1)
1209 ((looking-at "^#### ") 2)
1210 ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
1213 (defun dla/ess-region-remote-eval (start end)
1214 "Evaluate region in a remote ESS instance"
1216 (shell-command-on-region start end "eval_r" (get-buffer-create "***essregionremoteeval***") nil nil nil)
1217 (kill-buffer "***essregionremoteeval***"))
1218 ;; Don't restore history or save workspace image
1219 '(inferior-R-args "--no-restore-history --no-save")
1224 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
1226 #+BEGIN_SRC emacs-lisp
1227 (use-package rainbow-mode
1228 ;; add ess to the x major mode
1229 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
1230 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
1235 #+BEGIN_SRC emacs-lisp
1236 (use-package yaml-mode
1237 ;; add ess to the x major mode
1238 :mode ("\\.\\(yaml|yml\\)\\'" . yaml-mode)
1243 #+BEGIN_SRC emacs-lisp
1244 (use-package poly-noweb
1249 (use-package poly-markdown
1255 :after (:all polymode poly-markdown poly-noweb)
1256 ; :mode ("\\.Snw" . poly-noweb+r-mode)
1257 ; :mode ("\\.Rnw" . poly-noweb+r-mode)
1258 ; :mode ("\\.Rmd" . poly-markdown+r-mode)
1260 (use-package polymode
1268 #+BEGIN_SRC emacs-lisp
1269 (use-package outline-magic)
1272 #+BEGIN_SRC emacs-lisp
1273 ;; change the outline mode prefix from C-c @ to C-c C-2
1274 (setq outline-minor-mode-prefix "C-c C-2")
1275 ;;(add-hook 'outline-minor-mode-hook
1276 ;; (lambda () (local-set-key (kbd "C-c C-2")
1277 ;; outline-mode-prefix-map)))
1281 #+BEGIN_SRC emacs-lisp
1282 (use-package writeroom-mode
1284 (defun my/writing-mode ()
1285 "Start my writing mode; enable visual-line-mode and auto-fill-mode"
1290 (visual-line-mode -1)
1292 (visual-fill-column-mode -1)
1294 (visual-line-mode 1)
1296 (visual-fill-column-mode 1)
1301 ** GhostText/Atomic Chrome
1302 #+BEGIN_SRC emacs-lisp
1303 (use-package atomic-chrome
1305 (ignore-errors (atomic-chrome-start-server))
1306 (setq atomic-chrome-buffer-open-style 'full)
1310 #+BEGIN_SRC emacs-lisp
1311 (use-package edit-server
1313 :commands edit-server-start
1314 :init (if after-init-time
1316 (add-hook 'after-init-hook
1317 #'(lambda() (edit-server-start))))
1318 :config (setq edit-server-new-frame-alist
1319 '((name . "Edit with Emacs FRAME")
1325 (menu-bar-lines . t)
1326 (window-system . x)))
1331 :ID: 6fcf218b-a762-4c37-9339-a8202ddeb544
1333 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
1334 #+BEGIN_SRC emacs-lisp
1335 (use-package multiple-cursors
1336 :bind* (("C-;" . mc/mark-all-dwim)
1337 ("C-<" . mc/mark-previous-like-this)
1338 ("C->" . mc/mark-next-like-this)
1339 ("C-S-c C-S-c" . mc/edit-lines))
1343 #+BEGIN_SRC emacs-lisp
1344 (use-package web-mode
1345 :load-path "/home/don/projects/web-mode/"
1346 :mode ("\\.\\(tx|tmpl\\)\\'" . web-mode)
1348 (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . web-mode))
1349 (setq web-mode-enable-engine-detection t)
1350 (setq web-mode-engines-alist
1351 '(("template-toolkit" . "\\.tmpl\\'")))
1354 ** Spamassassin Mode
1355 #+BEGIN_SRC emacs-lisp
1356 (use-package spamassassin-mode
1357 :commands spamassassin-mode
1362 #+BEGIN_SRC emacs-lisp
1363 (use-package password-store
1365 :commands password-store-edit password-store-generate
1369 #+BEGIN_SRC emacs-lisp
1373 ;; fix up css mode to not be silly
1374 ;; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
1375 (setq cssm-indent-level 4)
1376 (setq cssm-newline-before-closing-bracket t)
1377 (setq cssm-indent-function #'cssm-c-style-indenter)
1378 (setq cssm-mirror-mode nil))
1381 #+BEGIN_SRC emacs-lisp
1383 :diminish abbrev-mode
1385 ;; load abbreviations from
1386 (setq abbrev-file-name
1387 "~/.emacs_abbrev_def")
1389 ;; read the abbrev file if it exists
1390 (if (file-exists-p abbrev-file-name)
1391 (quietly-read-abbrev-file))
1393 ;; for now, use abbrev mode everywhere
1394 (setq default-abbrev-mode t))
1397 ** Debugging (realgud)
1398 #+BEGIN_SRC emacs-lisp
1399 (use-package realgud
1403 ** Python Programming
1404 #+BEGIN_SRC emacs-lisp
1405 (use-package python-mode
1407 (python-mode . pyenv-mode)
1408 (python-mode . flycheck-mode)
1409 (python-mode . company-mode)
1410 (python-mode . blacken-mode)
1411 (python-mode . yas-minor-mode)
1412 (python-mode . anaconda-mode)
1417 (use-package blacken
1419 (setq-default blacken-fast-unsafe t)
1420 (setq-default blacken-line-length 80)
1422 (use-package anaconda-mode
1433 # #+BEGIN_SRC emacs-lisp
1434 # (use-package company-jedi
1436 # :hook (python-mode . (add-to-list 'company-backends 'company-jedi))
1437 # :hook (python-mode . 'jedi:setup)
1439 # (setq jedi:complete-on-dot t)
1443 #+begin_src emacs-lisp :tangle yes
1444 (use-package python-black
1448 *** Sphinx Documentation
1449 #+begin_src emacs-lisp :tangle yes
1450 (use-package numpydoc
1453 :bind (:map python-mode-map
1454 ("C-c C-n" . numpydoc-generate)))
1455 (use-package sphinx-doc
1459 (setq sphinx-doc-include-types t)
1463 #+BEGIN_SRC emacs-lisp
1464 (use-package go-mode
1471 #+BEGIN_SRC emacs-lisp
1472 (use-package expand-region
1473 :bind (("C-=" . 'er/expand-region))
1478 #+BEGIN_SRC emacs-lisp
1479 (use-package dockerfile-mode
1485 #+BEGIN_SRC emacs-lisp
1486 (use-package beancount
1487 :load-path "~/lib/emacs_el/beancount-mode/"
1489 :mode "\\.beancount\\'"
1496 #+BEGIN_SRC emacs-lisp
1497 (use-package message
1499 :diminish (message "✉")
1500 :mode ("muttng-[a-z0-9]+-[0-9]+-" . message-mode)
1501 :mode ("mutt-[a-z0-9]+-[0-9]+-" . message-mode)
1502 :hook 'my/message-mode-settings
1503 :hook 'turn-on-flyspell
1504 :bind (:map message-mode-map
1505 ("C-c C-a" . my/post-attach-file))
1506 :delight (message-mode "✉")
1508 (defun my/message-mode-settings ()
1509 (font-lock-add-keywords nil
1510 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1511 (0 'message-multiply-quoted-text-face))
1512 ("^[ \t]*>[ \t]*>.*$"
1513 (0 'message-double-quoted-text-face))))
1516 (defun my/post-attach-file ()
1517 "Prompt for an attachment."
1519 (let ((file (read-file-name "Attach file: " nil nil t nil)))
1520 (my/header-attach-file file "")))
1522 (defun my/header-attach-file (file description)
1523 "Attach a FILE to the current message (works with Mutt).
1524 Argument DESCRIPTION MIME description."
1525 (interactive "fAttach file: \nsDescription: ")
1526 (when (> (length file) 0)
1531 (goto-char (point-min))
1532 (search-forward-regexp "^$")
1533 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1535 (message (concat "Attached '" file "'."))
1536 (setq post-has-attachment t))))))
1538 (setq mail-yank-prefix "> ")
1539 (setq mail-header-separator "") ; fix broken header detection
1543 #+BEGIN_SRC emacs-lisp
1544 (use-package muttrc-mode
1551 ** Reverting buffers
1552 #+BEGIN_SRC emacs-lisp
1553 (use-package autorevert
1554 :diminish auto-revert-mode
1556 (setq global-auto-revert-non-file-buffers t
1557 global-auto-revert-ignore-modes '(pdf-view-mode)
1558 auto-revert-verbose nil)
1559 (global-auto-revert-mode 1))
1562 ** Use-package and load things
1563 #+BEGIN_SRC emacs-lisp
1566 :delight (org-mode "ø")
1567 :mode ("\\.\\(org\\|org_archive\\|txt\\)\\'" . org-mode)
1568 :bind (("C-c l" . org-store-link)
1569 ("C-c a" . org-agenda)
1570 ("C-c b" . org-iswitchb))
1572 ** Agenda Configuration
1573 #+BEGIN_SRC emacs-lisp
1575 (setq-default org-log-done 'time)
1576 (setq-default org-agenda-ndays 5)
1578 (setq org-agenda-sticky t)
1579 (defun dla/show-org-agenda ()
1584 (and (string-match-p
1592 (buffer-name agendabuffer))
1594 (delete-other-windows))
1596 ;; agenda configuration
1597 ;; Do not dim blocked tasks
1598 (setq org-agenda-dim-blocked-tasks nil)
1599 (setq org-agenda-inhibit-startup t)
1600 (setq org-agenda-use-tag-inheritance nil)
1602 ;; Compact the block agenda view
1603 (setq org-agenda-compact-blocks t)
1605 ;; Custom agenda command definitions
1606 (setq org-agenda-custom-commands
1607 (quote (("N" "Notes" tags "NOTE"
1608 ((org-agenda-overriding-header "Notes")
1609 (org-tags-match-list-sublevels t)))
1610 ("h" "Habits" tags-todo "STYLE=\"habit\""
1611 ((org-agenda-overriding-header "Habits")
1612 (org-agenda-sorting-strategy
1613 '(todo-state-down effort-up category-keep))))
1617 ((org-agenda-overriding-header "Tasks to Refile")
1618 (org-tags-match-list-sublevels nil)))
1619 (tags-todo "-CANCELLED/!"
1620 ((org-agenda-overriding-header "Stuck Projects")
1621 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
1622 (org-agenda-sorting-strategy
1624 (tags-todo "-HOLD-CANCELLED/!"
1625 ((org-agenda-overriding-header "Projects")
1626 (org-agenda-skip-function 'bh/skip-non-projects)
1627 (org-tags-match-list-sublevels 'indented)
1628 (org-agenda-sorting-strategy
1630 (tags-todo "-CANCELLED/!NEXT"
1631 ((org-agenda-overriding-header (concat "Project Next Tasks"
1632 (if bh/hide-scheduled-and-waiting-next-tasks
1634 " (including WAITING and SCHEDULED tasks)")))
1635 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1636 (org-tags-match-list-sublevels t)
1637 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1638 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1639 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1640 (org-agenda-sorting-strategy
1641 '(todo-state-down effort-up category-keep))))
1642 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1643 ((org-agenda-overriding-header (concat "Project Subtasks"
1644 (if bh/hide-scheduled-and-waiting-next-tasks
1646 " (including WAITING and SCHEDULED tasks)")))
1647 (org-agenda-skip-function 'bh/skip-non-project-tasks)
1648 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1649 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1650 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1651 (org-agenda-sorting-strategy
1653 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1654 ((org-agenda-overriding-header (concat "Standalone Tasks"
1655 (if bh/hide-scheduled-and-waiting-next-tasks
1657 " (including WAITING and SCHEDULED tasks)")))
1658 (org-agenda-skip-function 'bh/skip-project-tasks)
1659 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1660 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1661 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1662 (org-agenda-sorting-strategy
1664 (tags-todo "-CANCELLED+WAITING|HOLD/!"
1665 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
1666 (org-agenda-skip-function 'bh/skip-stuck-projects)
1667 (org-tags-match-list-sublevels nil)
1668 (org-agenda-todo-ignore-scheduled t)
1669 (org-agenda-todo-ignore-deadlines t)))
1671 ((org-agenda-overriding-header "Tasks to Archive")
1672 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1673 (org-tags-match-list-sublevels nil))))
1676 ; org mode agenda files
1677 (setq org-agenda-files
1679 (file-expand-wildcards "~/projects/org-notes/*.org")
1680 (file-expand-wildcards "~/org-mode/from-mobile.org")
1681 (file-expand-wildcards "~/org-notes-*/*.org")
1684 (setq my/org-refile-file
1686 (lambda (file) (string-match-p (regexp-quote "/refile.org") file))
1689 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
1690 (set-register ?r (cons 'file my/org-refile-file))
1691 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
1692 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
1693 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
1694 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
1695 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
1696 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
1697 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
1698 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
1699 (defun org-agenda-timeline-all (&optional arg)
1702 (dolist (org-agenda-file org-agenda-files)
1703 (insert-file-contents org-agenda-file nil)
1704 (goto-char (point-max))
1706 (write-file "/tmp/timeline.org")
1707 (org-agenda arg "L")))
1708 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
1712 #+BEGIN_SRC emacs-lisp
1713 (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")))
1714 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
1716 (setq org-default-notes-file "~/projects/org-notes/notes.org")
1717 (setq org-id-link-to-org-use-id 'use-existing)
1719 ** Capture Templates
1720 #+BEGIN_SRC emacs-lisp
1721 (setq org-capture-templates ;; mail-specific note template, identified by "m"
1722 `(("m" "Mail" entry (file my/org-refile-file)
1723 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
1724 ("t" "todo" entry (file my/org-refile-file)
1725 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
1726 ("r" "respond" entry (file my/org-refile-file)
1727 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
1728 ("n" "note" entry (file my/org-refile-file)
1729 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
1730 ("s" "schedule" entry (file my/org-refile-file)
1731 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
1732 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
1733 "* %?\n%U\n" :clock-in t :clock-resume t)
1734 ("w" "org-protocol" entry (file my/org-refile-file)
1735 "* TODO Review %c\n%U\n" :immediate-finish t)
1736 ("M" "Meeting" entry (file my/org-refile-file)
1737 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
1738 ("S" "Seminar" entry (file my/org-refile-file)
1739 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
1740 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
1741 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
1742 ("p" "Phone call" entry (file my/org-refile-file)
1743 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
1744 ("J" "job" entry (file+olp "~/projects/org-notes/notes.org"
1746 ,(format-time-string "Positions %Y"))
1747 "* TODO Apply for %? :job:\nSCHEDULED: <%<%Y-%m-%d>>\n%U\n%x\n" :clock-in t :clock-resume t)
1748 ("h" "Habit" entry (file my/org-refile-file)
1749 "* 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")
1753 ;; Remove empty LOGBOOK drawers on clock out
1754 (defun bh/remove-empty-drawer-on-clock-out ()
1757 (beginning-of-line 0)
1758 (org-remove-empty-drawer-at (point))))
1760 (defun my/org-add-id ()
1763 (if (org-current-level)
1772 ** Org mode key bindings
1773 #+BEGIN_SRC emacs-lisp
1774 ;; org mode configuration from http://doc.norang.ca/org-mode.html
1775 ;; Custom Key Bindings
1776 :bind* (("<f9> a" . org-agenda)
1777 ("<f9> I" . bh/punch-in)
1778 ("<f9> O" . bh/punch-out)
1779 ("<f9> SPC" . bh/clock-in-last-task)
1780 ("<f12>" . dla/show-org-agenda)
1781 ;; ("<f5>" . bh/org-todo)
1782 ("<S-f5>" . bh/widen)
1783 ("<f7>" . bh/set-truncate-lines)
1784 ("<f8>" . org-cycle-agenda-files)
1785 ("<f9> <f9>" . dla/show-org-agenda)
1787 ("<f9> c" . calendar)
1788 ("<f9> f" . boxquote-insert-file)
1789 ("<f9> h" . bh/hide-other)
1790 ("<f9> n" . bh/toggle-next-task-display)
1793 ("<f9> r" . boxquote-region)
1794 ("<f9> s" . bh/switch-to-scratch)
1796 ("<f9> t" . bh/insert-inactive-timestamp)
1797 ("<f9> T" . bh/toggle-insert-inactive-timestamp)
1799 ("<f9> v" . visible-mode)
1800 ("<f9> l" . org-toggle-link-display)
1801 ("<f9> SPC" . bh/clock-in-last-task)
1802 ("C-<f9>" . previous-buffer)
1803 ("M-<f9>" . org-toggle-inline-images)
1804 ("C-x n r" . narrow-to-region)
1805 ("C-<f10>" . next-buffer)
1806 ("<f11>" . org-clock-goto)
1807 ("C-<f11>" . org-clock-in)
1808 ("C-s-<f12>" . bh/save-then-publish)
1809 ("C-c c" . org-capture))
1812 ** Utility Functions
1813 #+BEGIN_SRC emacs-lisp
1814 (defun bh/hide-other ()
1817 (org-back-to-heading 'invisible-ok)
1818 (outline-hide-other)
1823 (defun bh/set-truncate-lines ()
1824 "Toggle value of truncate-lines and refresh window display."
1826 (setq truncate-lines (not truncate-lines))
1827 ;; now refresh window display (an idiom from simple.el):
1829 (set-window-start (selected-window)
1830 (window-start (selected-window)))))
1832 (defun bh/switch-to-scratch ()
1834 (switch-to-buffer "*scratch*"))
1836 (setq org-use-fast-todo-selection t)
1837 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1839 ; create function to create headlines in file. This comes from
1840 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
1841 (defun my/org-add-ids-to-headlines-in-file ()
1842 "Add ID properties to all headlines in the current file which
1843 do not already have one."
1845 (org-map-entries 'org-id-get-create))
1846 (defun dla/org-update-ids-to-headlines-in-file ()
1847 "Add or replace ID properties to all headlines in the current file
1848 (or narrowed region)."
1850 (org-map-entries '(lambda () (org-id-get-create t))))
1851 ; if we wanted to do this to every buffer, do the following:
1852 (add-hook 'org-mode-hook
1854 (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
1857 #+BEGIN_SRC emacs-lisp
1858 (use-package find-lisp
1860 (setq org-agenda-text-search-extra-files
1861 (append '(agenda-archives)
1862 (find-lisp-find-files "~/projects/org-notes" "\.org$")
1863 (find-lisp-find-files "~/projects/org-notes" "\.org_archive$")
1867 #+BEGIN_SRC emacs-lisp
1868 (setq org-todo-keywords
1869 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
1870 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
1872 (setq org-todo-keyword-faces
1873 (quote (("TODO" :foreground "red" :weight bold)
1874 ("NEXT" :foreground "blue" :weight bold)
1875 ("DONE" :foreground "forest green" :weight bold)
1876 ("WAITING" :foreground "orange" :weight bold)
1877 ("HOLD" :foreground "magenta" :weight bold)
1878 ("CANCELLED" :foreground "forest green" :weight bold)
1879 ("MEETING" :foreground "forest green" :weight bold)
1880 ("PHONE" :foreground "forest green" :weight bold))))
1882 (setq org-todo-state-tags-triggers
1883 (quote (("CANCELLED" ("CANCELLED" . t))
1884 ("WAITING" ("WAITING" . t))
1885 ("HOLD" ("WAITING") ("HOLD" . t))
1886 (done ("WAITING") ("HOLD"))
1887 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1888 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1889 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1893 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1894 ; add ids on creation of nodes
1895 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
1898 ; resolve clocks after 10 minutes of idle; use xprintidle
1899 ; (setq org-clock-idle-time 10)
1900 ; (setq org-clock-x11idle-program-name "xprintidle")
1902 ; this is from http://doc.norang.ca/org-mode.html#Capture
1903 ; use C-M-r for org mode capture
1904 (global-set-key (kbd "C-M-r") 'org-capture)
1906 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1907 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1908 (org-agenda-files :maxlevel . 9))))
1910 ; Use full outline paths for refile targets - we file directly with IDO
1911 (setq org-refile-use-outline-path t)
1913 ; Targets complete directly with IDO
1914 (setq org-outline-path-complete-in-steps nil)
1916 ; Allow refile to create parent tasks with confirmation
1917 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1919 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
1920 ; (setq org-completion-use-ido t)
1921 ; (setq ido-everywhere t)
1922 ; (setq ido-max-directory-size 100000)
1923 ; (ido-mode (quote both))
1924 ; ; Use the current window when visiting files and buffers with ido
1925 ; (setq ido-default-file-method 'selected-window)
1926 ; (setq ido-default-buffer-method 'selected-window)
1927 ; ; Use the current window for indirect buffer display
1928 ; (setq org-indirect-buffer-display 'current-window)
1931 ;;;; Refile settings
1932 ; Exclude DONE state tasks from refile targets
1933 (defun bh/verify-refile-target ()
1934 "Exclude todo keywords with a done state from refile targets"
1935 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
1937 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1939 ;; ensure that emacsclient will show just the note to be edited when invoked
1940 ;; from Mutt, and that it will shut down emacsclient once finished;
1941 ;; fallback to legacy behavior when not invoked via org-protocol.
1942 (require 'org-protocol)
1943 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
1944 (setq my-org-protocol-flag nil)
1945 (defadvice org-capture-finalize (after delete-frame-at-end activate)
1946 "Delete frame at remember finalization"
1947 (progn (if my-org-protocol-flag (delete-frame))
1948 (setq my-org-protocol-flag nil)))
1949 (defadvice org-capture-refile (around delete-frame-after-refile activate)
1950 "Delete frame at remember refile"
1951 (if my-org-protocol-flag
1953 (setq my-org-protocol-flag nil)
1958 (defadvice org-capture-kill (after delete-frame-at-end activate)
1959 "Delete frame at remember abort"
1960 (progn (if my-org-protocol-flag (delete-frame))
1961 (setq my-org-protocol-flag nil)))
1962 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
1963 (setq my-org-protocol-flag t))
1965 (defadvice org-insert-todo-heading (after dla/create-id activate)
1966 (unless (org-in-item-p)
1972 (add-to-list 'org-modules 'org-habit)
1974 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
1975 (defun open-mail-in-mutt (message)
1976 "Open a mail message in Mutt, using an external terminal.
1978 Message can be specified either by a path pointing inside a
1979 Maildir, or by Message-ID."
1980 (interactive "MPath or Message-ID: ")
1982 (format "faf xterm -e \"%s %s\""
1983 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
1985 ;; add support for "mutt:ID" links
1986 (org-add-link-type "mutt" 'open-mail-in-mutt)
1988 (defun my-org-mode-setup ()
1989 ; (load-library "reftex")
1990 (and (buffer-file-name)
1991 (file-exists-p (buffer-file-name))
1993 ; (reftex-parse-all)
1994 (reftex-set-cite-format
1995 '((?b . "[[bib:%l][%l-bib]]")
1996 (?n . "[[notes:%l][%l-notes]]")
1998 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
2000 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
2001 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
2002 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
2003 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
2005 (add-hook 'org-mode-hook 'my-org-mode-setup)
2007 (defun org-mode-reftex-search ()
2009 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
2011 (defun open-research-paper (bibtexkey)
2012 "Open a paper by bibtex key"
2013 (interactive "bibtex key: ")
2016 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
2017 (org-add-link-type "papers" 'open-research-paper)
2018 (defun open-research-paper-pdf (bibtexkey)
2019 "Open a paper pdf by bibtex key"
2020 (interactive "bibtex key: ")
2022 (format "%s -p evince_annot %s"
2023 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
2024 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
2026 (add-to-list 'org-link-abbrev-alist
2028 "~/projects/research/paper_notes.org::#%s"))
2030 ; I pretty much always want hiearchical checkboxes
2031 (setq org-hierachical-checkbox-statistics nil)
2033 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
2034 (add-to-list 'org-structure-template-alist
2035 '("E" "\\begin{equation}\n?\n\\end{equation}"))
2038 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
2039 (defun my-rtcite-export-handler (path desc format)
2040 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
2041 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
2042 (match-string 1 path)))
2043 (path (substring path 0 (match-beginning 0))))
2044 (cond ((eq format 'latex)
2046 (equal 0 (search "rtcite:" desc)))
2047 (format "\\cite{%s}" search)
2048 (format "\\cite[%s]{%s}" desc search))))))
2050 (org-add-link-type "rtcite"
2052 'my-rtcite-export-handler)
2056 ** Org Mobile Configuration
2057 #+BEGIN_SRC emacs-lisp
2058 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
2059 (when (string= system-name "linnode")
2060 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
2061 (setq-default org-directory "/home/don/org-mode/")
2062 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
2066 #+BEGIN_SRC emacs-lisp
2067 ;; org mode ical export
2068 (setq org-icalendar-timezone "America/Los_Angeles")
2069 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
2070 ;; we already add the id manually
2071 (setq org-icalendar-store-UID t)
2074 ** General Org Babel Configuration
2075 #+BEGIN_SRC emacs-lisp
2076 ;; org babel support
2077 (org-babel-do-load-languages
2078 'org-babel-load-languages
2085 ;; set the right path to ditaa.jar
2086 (setq org-ditaa-jar-path "/usr/share/ditaa/ditaa.jar")
2087 ;; use graphviz-dot for dot things
2088 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
2089 ;; do not indent begin_src blocks
2090 (setq org-edit-src-content-indentation 0)
2091 ;; org-babel-by-backend
2092 (defmacro org-babel-by-backend (&rest body)
2093 `(case (if (boundp 'backend)
2094 (org-export-backend-name backend)
2097 (defun my/fix-inline-images ()
2098 (when org-inline-image-overlays
2099 (org-redisplay-inline-images)))
2101 (add-hook 'org-babel-after-execute-hook
2102 'my/fix-inline-images)
2105 ** LaTeX configuration
2107 :ID: 7135ba17-6a50-4eed-84ca-b90afa5b12f8
2109 #+BEGIN_SRC emacs-lisp
2110 (use-package ox-extra
2112 (ox-extras-activate '(ignore-headlines)))
2114 (add-to-list 'org-latex-classes
2116 "\\documentclass[11pt,oneside,article]{memoir}\n"
2117 ("\\section{%s}" . "\\section*{%s}")
2118 ("\\subsection{%s}" . "\\subsection*{%s}")
2119 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2120 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2121 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2123 (setq org-beamer-outline-frame-options "")
2124 (add-to-list 'org-latex-classes
2126 "\\documentclass[ignorenonframetext]{beamer}
2127 [NO-DEFAULT-PACKAGES]
2130 ("\\section{%s}" . "\\section*{%s}")
2131 ("\\subsection{%s}" . "\\subsection*{%s}")
2132 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2133 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2134 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2136 (add-to-list 'org-latex-classes
2138 "\\documentclass[11pt,oneside]{memoir}\n"
2139 ("\\chapter{%s}" . "\\chapter*{%s}")
2140 ("\\section{%s}" . "\\section*{%s}")
2141 ("\\subsection{%s}" . "\\subsection*{%s}")
2142 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
2144 (add-to-list 'org-latex-classes
2146 "\\documentclass[11pt]{letter}
2147 [NO-DEFAULT-PACKAGES]
2150 ("\\section{%s}" . "\\section*{%s}")
2151 ("\\subsection{%s}" . "\\subsection*{%s}")
2152 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2153 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2154 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2156 (add-to-list 'org-latex-classes
2158 "\\documentclass{dlacv}
2159 [NO-DEFAULT-PACKAGES]
2162 ("\\section{%s}" . "\\section*{%s}")
2163 ("\\subsection{%s}" . "\\subsection*{%s}")
2164 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2165 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2166 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2169 (add-to-list 'org-latex-classes
2171 "\\documentclass{dlaresume}
2172 [NO-DEFAULT-PACKAGES]
2175 ("\\section{%s}" . "\\section*{%s}")
2176 ("\\subsection{%s}" . "\\subsection*{%s}")
2177 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2178 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2179 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2182 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
2183 ;; but adapted to use latexmk 4.22 or higher.
2184 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
2186 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
2187 (setq org-latex-default-packages-alist
2189 ("" "unicode-math" t)
2191 (setq org-latex-packages-alist
2198 ("" "longtable" nil)
2201 ;; make equations larger
2202 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
2204 (defun org-create-formula--latex-header ()
2205 "Return LaTeX header appropriate for previewing a LaTeX snippet."
2206 (let ((info (org-combine-plists (org-export--get-global-options
2207 (org-export-get-backend 'latex))
2208 (org-export--get-inbuffer-options
2209 (org-export-get-backend 'latex)))))
2210 (org-latex-guess-babel-language
2211 (org-latex-guess-inputenc
2212 (org-splice-latex-header
2213 org-format-latex-header
2214 org-latex-default-packages-alist
2216 (plist-get info :latex-header)))
2220 ; support ignoring headers in org mode export to latex
2221 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
2222 (defadvice org-latex-headline (around my-latex-skip-headlines
2223 (headline contents info) activate)
2224 (if (member "ignoreheading" (org-element-property :tags headline))
2225 (setq ad-return-value contents)
2228 ;; keep latex logfiles
2230 (setq org-latex-remove-logfiles nil)
2232 ;; Resume clocking task when emacs is restarted
2233 (org-clock-persistence-insinuate)
2235 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
2236 (setq org-clock-history-length 23)
2237 ;; Resume clocking task on clock-in if the clock is open
2238 (setq org-clock-in-resume t)
2239 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
2240 ;; there are things like PHONE calls
2241 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
2242 ;; Separate drawers for clocking and logs
2243 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
2244 ;; Save clock data and state changes and notes in the LOGBOOK drawer
2245 (setq org-clock-into-drawer t)
2246 (setq org-log-into-drawer t)
2247 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
2248 (setq org-clock-out-remove-zero-time-clocks t)
2249 ;; Clock out when moving task to a done state
2250 (setq org-clock-out-when-done t)
2251 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
2252 (setq org-clock-persist t)
2253 ;; Do not prompt to resume an active clock
2254 (setq org-clock-persist-query-resume nil)
2255 ;; Enable auto clock resolution for finding open clocks
2256 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
2257 ;; Include current clocking task in clock reports
2258 (setq org-clock-report-include-clocking-task t)
2260 ;; the cache seems to be broken
2261 (setq org-element-use-cache nil)
2263 (defvar bh/keep-clock-running nil)
2265 (defun bh/is-task-p ()
2266 "Any task with a todo keyword and no subtask"
2270 (subtree-end (save-excursion (org-end-of-subtree t)))
2271 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2274 (while (and (not has-subtask)
2275 (< (point) subtree-end)
2276 (re-search-forward "^\*+ " subtree-end t))
2277 (when (member (org-get-todo-state) org-todo-keywords-1)
2278 (setq has-subtask t))))
2279 (and is-a-task (not has-subtask)))))
2280 (defun bh/is-project-p ()
2281 "Any task with a todo keyword subtask"
2285 (subtree-end (save-excursion (org-end-of-subtree t)))
2286 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2289 (while (and (not has-subtask)
2290 (< (point) subtree-end)
2291 (re-search-forward "^\*+ " subtree-end t))
2292 (when (member (org-get-todo-state) org-todo-keywords-1)
2293 (setq has-subtask t))))
2294 (and is-a-task has-subtask))))
2296 (defun bh/is-subproject-p ()
2297 "Any task which is a subtask of another project"
2298 (let ((is-subproject)
2299 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2301 (while (and (not is-subproject) (org-up-heading-safe))
2302 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
2303 (setq is-subproject t))))
2304 (and is-a-task is-subproject)))
2307 (defun bh/clock-in-to-next (kw)
2308 "Switch a task from TODO to NEXT when clocking in.
2309 Skips capture tasks, projects, and subprojects.
2310 Switch projects and subprojects from NEXT back to TODO"
2311 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
2313 ((and (member (org-get-todo-state) (list "TODO"))
2316 ((and (member (org-get-todo-state) (list "NEXT"))
2320 (defun bh/punch-in (arg)
2321 "Start continuous clocking and set the default task to the
2322 selected task. If no task is selected set the Organization task
2323 as the default task."
2325 (setq bh/keep-clock-running t)
2326 (if (equal major-mode 'org-agenda-mode)
2328 ;; We're in the agenda
2330 (let* ((marker (org-get-at-bol 'org-hd-marker))
2331 (tags (org-with-point-at marker (org-get-tags))))
2332 (if (and (eq arg 4) tags)
2333 (org-agenda-clock-in '(16))
2334 (bh/clock-in-organization-task-as-default)))
2336 ;; We are not in the agenda
2340 ; Find the tags on the current task
2341 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
2342 (org-clock-in '(16))
2343 (bh/clock-in-organization-task-as-default)))))
2345 (defun bh/punch-out ()
2347 (setq bh/keep-clock-running nil)
2348 (when (org-clock-is-active)
2350 (org-agenda-remove-restriction-lock))
2352 (defun bh/clock-in-default-task ()
2354 (org-with-point-at org-clock-default-task
2357 (defun bh/clock-in-parent-task ()
2358 "Move point to the parent (project) task if any and clock in"
2359 (let ((parent-task))
2363 (while (and (not parent-task) (org-up-heading-safe))
2364 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
2365 (setq parent-task (point))))
2367 (org-with-point-at parent-task
2369 (when bh/keep-clock-running
2370 (bh/clock-in-default-task)))))))
2372 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
2374 (defun bh/clock-in-organization-task-as-default ()
2376 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
2377 (org-clock-in '(16))))
2379 (defun bh/clock-out-maybe ()
2380 (when (and bh/keep-clock-running
2381 (not org-clock-clocking-in)
2382 (marker-buffer org-clock-default-task)
2383 (not org-clock-resolving-clocks-due-to-idleness))
2384 (bh/clock-in-parent-task)))
2386 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
2389 (defun bh/clock-in-task-by-id (id)
2390 "Clock in a task by id"
2391 (org-with-point-at (org-id-find id 'marker)
2392 (org-clock-in nil)))
2394 (defun bh/clock-in-last-task (arg)
2395 "Clock in the interrupted task if there is one
2396 Skip the default task and get the next one.
2397 A prefix arg forces clock in of the default task."
2399 (let ((clock-in-to-task
2401 ((eq arg 4) org-clock-default-task)
2402 ((and (org-clock-is-active)
2403 (equal org-clock-default-task (cadr org-clock-history)))
2404 (caddr org-clock-history))
2405 ((org-clock-is-active) (cadr org-clock-history))
2406 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
2407 (t (car org-clock-history)))))
2409 (org-with-point-at clock-in-to-task
2410 (org-clock-in nil))))
2413 (defun org-export-to-ods ()
2415 (let ((csv-file "data.csv"))
2416 (org-table-export csv-file "orgtbl-to-csv")
2417 (org-odt-convert csv-file "ods" 'open)))
2419 ; allow for zero-width-space to be a break in regexp too
2420 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
2421 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
2422 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
2424 ;; support inserting screen shots
2425 (defun my/org-insert-screenshot ()
2426 "Take a screenshot into a time stamped unique-named file in the
2427 same directory as the org-buffer and insert a link to this file."
2429 (defvar my/org-insert-screenshot/filename)
2430 (setq my/org-insert-screenshot/filename
2432 "Screenshot to insert: "
2434 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
2437 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
2438 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
2439 (org-display-inline-images))
2441 (defun my/fix-inline-images ()
2442 (when org-inline-image-overlays
2443 (org-redisplay-inline-images)))
2445 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
2447 ;; use xelatex to preview with imagemagick
2448 (add-to-list 'org-preview-latex-process-alist
2449 '(xelateximagemagick
2450 :programs ("xelatex" "convert")
2451 :description "pdf > png"
2452 :message "you need to install xelatex and imagemagick"
2454 :image-input-type "pdf"
2455 :image-output-type "png"
2456 :image-size-adjust (1.0 . 1.0)
2457 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
2458 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
2460 ;; use xelatex by default
2461 (setq org-preview-latex-default-process 'xelateximagemagick)
2463 ; from http://orgmode.org/Changes.html
2464 (defun my/org-repair-property-drawers ()
2465 "Fix properties drawers in current buffer.
2466 Ignore non Org buffers."
2468 (when (eq major-mode 'org-mode)
2469 (org-with-wide-buffer
2470 (goto-char (point-min))
2471 (let ((case-fold-search t)
2472 (inline-re (and (featurep 'org-inlinetask)
2473 (concat (org-inlinetask-outline-regexp)
2477 (unless (and inline-re (org-looking-at-p inline-re))
2479 (let ((end (save-excursion (outline-next-heading) (point))))
2481 (when (org-looking-at-p org-planning-line-re) (forward-line))
2482 (when (and (< (point) end)
2483 (not (org-looking-at-p org-property-drawer-re))
2485 (and (re-search-forward org-property-drawer-re end t)
2486 (eq (org-element-type
2487 (save-match-data (org-element-at-point)))
2489 (insert (delete-and-extract-region
2491 (min (1+ (match-end 0)) end)))
2492 (unless (bolp) (insert "\n"))))))))))))
2496 #+BEGIN_SRC emacs-lisp
2500 (use-package calfw-org
2503 (use-package org-gcal
2504 :if (file-readable-p "~/.hide/org_gcal.el")
2506 :config '((if (file-readable-p "~/.hide/org_gcal.el")
2507 (load-file "~/.hide/org_gcal.el"))
2512 #+BEGIN_SRC emacs-lisp
2516 ;; Show notification 10 minutes before event
2517 (setq appt-message-warning-time 10)
2518 ;; Disable multiple reminders
2519 (setq appt-display-interval appt-message-warning-time)
2520 (setq appt-display-mode-line nil)
2522 ;; add automatic reminders for appointments
2523 (defun my/org-agenda-to-appt ()
2525 (setq appt-time-msg-list nil)
2526 (org-agenda-to-appt))
2527 ;; add reminders when starting emacs
2528 (my/org-agenda-to-appt)
2529 ;; when rebuilding the agenda
2530 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
2531 "Pressing `r' on the agenda will also add appointments."
2532 (my/org-agenda-to-appt)
2534 ;; when saving all org buffers
2535 (defadvice org-save-all-org-buffers (after org-save-all-org-buffers-add-appts)
2536 "Re-add appts after saving all org buffers"
2537 (my/org-agenda-to-appt))
2538 ;; Display appointments as a window manager notification
2539 (setq appt-disp-window-function 'my/appt-display)
2540 (setq appt-delete-window-function (lambda () t))
2542 (setq my/appt-notification-app (concat (getenv "HOME") "/bin/appt_notification"))
2544 (defun my/appt-display (min-to-app new-time msg)
2545 (if (atom min-to-app)
2546 (start-process "my/appt-notification-app" nil my/appt-notification-app min-to-app msg)
2547 (dolist (i (number-sequence 0 (1- (length min-to-app))))
2548 (start-process "my/appt-notification-app" nil my/appt-notification-app
2549 (nth i min-to-app) (nth i msg))))
2555 ** outshine (outlining) integration
2556 #+BEGIN_SRC emacs-lisp
2557 (use-package outshine
2559 :hook (outline-minor-mode . outshine-hook-function)
2563 #+BEGIN_SRC emacs-lisp
2567 ** Home/End Begining/End of line
2568 #+BEGIN_SRC emacs-lisp
2569 (global-set-key [home] 'move-beginning-of-line)
2570 (global-set-key [end] 'move-end-of-line)
2573 #+BEGIN_SRC emacs-lisp
2574 (global-unset-key "\M-g")
2575 (global-set-key (kbd "M-g l") 'goto-line)
2579 #+BEGIN_SRC emacs-lisp
2580 (use-package debian-changelog-mode
2581 :mode "debian/changelog"
2583 (setq debian-changelog-mailing-address "don@debian.org")
2584 (setq debian-changelog-full-name "Don Armstrong"))
2586 * Misc (uncharacterized)
2587 #+BEGIN_SRC emacs-lisp
2588 (setq calendar-latitude 38.6)
2589 (setq calendar-longitude -121.5)
2590 (setq case-fold-search t)
2591 (setq confirm-kill-emacs (quote y-or-n-p))
2592 (setq cperl-lazy-help-time nil)
2594 ** Turn on fontlock and icomplete
2595 #+BEGIN_SRC emacs-lisp
2596 (global-font-lock-mode 1)
2598 (setq log-edit-keep-buffer t)
2600 ** Set mail User agent
2601 #+BEGIN_SRC emacs-lisp
2602 (setq mail-user-agent (quote sendmail-user-agent))
2603 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
2606 #+BEGIN_SRC emacs-lisp
2607 (setq ps-footer-font-size (quote (8 . 10)))
2608 (setq ps-header-font-size (quote (8 . 10)))
2609 (setq ps-header-title-font-size (quote (10 . 10)))
2610 (setq ps-line-number-color "blue")
2611 (setq ps-print-footer t)
2612 (setq ps-print-footer-frame nil)
2613 (setq ps-print-only-one-header t)
2615 ** Only single spacing on sentences
2616 #+BEGIN_SRC emacs-lisp
2617 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
2619 (setq sentence-end-double-space nil)
2620 ; enable matching parenthesis
2622 ** Display paren mode
2623 #+BEGIN_SRC emacs-lisp
2625 (setq show-paren-delay 0.2)
2629 #+BEGIN_SRC emacs-lisp
2630 (setq user-mail-address "don@donarmstrong.com")
2633 ** Use primary selection on unix machines
2634 #+BEGIN_SRC emacs-lisp
2635 ;; switch back to the old primary selection method
2636 (if (or (string-equal system-type "darwin")
2637 (string-equal system-type "windows")
2640 (setq select-enable-clipboard t)
2641 (setq select-enable-primary nil)
2644 (setq select-enable-clipboard nil)
2645 (setq select-enable-primary t)
2647 ; (setq mouse-drag-copy-region t)
2649 ;; tramp configuration
2650 (setq tramp-use-ssh-controlmaster-options nil)
2652 (setq-default c-indent-level 4)
2653 (setq-default c-brace-imaginary-offset 0)
2654 (setq-default c-brace-offset -4)
2655 (setq-default c-argdecl-indent 4)
2656 (setq-default c-label-offset -4)
2657 (setq-default c-continued-statement-offset 4)
2659 (setq-default indent-tabs-mode nil)
2660 (setq-default tab-width 4)
2663 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
2664 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
2665 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
2666 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
2667 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
2670 (defun insert-date ()
2671 "Insert date at point."
2673 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
2674 (global-set-key "\C-[d" 'insert-date)
2676 (defun unfill-paragraph (arg)
2677 "Pull this whole paragraph up onto one line."
2679 (let ((fill-column 10000))
2680 (fill-paragraph arg))
2683 (column-number-mode t)
2686 ** Desktop-save-mode
2687 If the envvar EMACS_SERVER_NAME is set, consider this a separate
2688 emacs, and use a different desktop file to restore history
2689 #+BEGIN_SRC emacs-lisp
2690 (use-package desktop
2693 (setq desktop-base-file-name
2694 (convert-standard-filename
2696 (or (getenv "EMACS_SERVER_NAME")
2700 (setq desktop-base-lock-name
2701 (convert-standard-filename
2702 (concat desktop-base-file-name
2704 (setq desktop-auto-save-timeout 60)
2705 (setq desktop-restore-eager 5)
2706 (setq desktop-lazy-verbose nil)
2707 (desktop-save-mode 1)
2711 ** Misc (Uncharacterized)
2712 #+BEGIN_SRC emacs-lisp
2713 '(icomplete-mode on)
2715 ;; custom-set-faces was added by Custom.
2716 ;; If you edit it by hand, you could mess it up, so be careful.
2717 ;; Your init file should contain only one such instance.
2718 ;; If there is more than one, they won't work right.
2719 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
2722 (put 'upcase-region 'disabled nil)
2723 (put 'downcase-region 'disabled nil)
2724 (put 'narrow-to-region 'disabled nil)
2726 ; (defun turn-on-flyspell ()
2727 ; "Force flyspell-mode on using a positive arg. For use in hooks."
2729 ; (flyspell-mode 1))
2732 ; Outline-minor-mode key map
2733 (define-prefix-command 'cm-map nil "Outline-")
2735 (define-key cm-map "q" 'outline-hide-sublevels) ; Hide everything but the top-level headings
2736 (define-key cm-map "t" 'outline-hide-body) ; Hide everything but headings (all body lines)
2737 (define-key cm-map "o" 'outline-hide-other) ; Hide other branches
2738 (define-key cm-map "c" 'outline-hide-entry) ; Hide this entry's body
2739 (define-key cm-map "l" 'outline-hide-leaves) ; Hide body lines in this entry and sub-entries
2740 (define-key cm-map "d" 'outline-hide-subtree) ; Hide everything in this entry and sub-entries
2742 (define-key cm-map "a" 'outline-show-all) ; Show (expand) everything
2743 (define-key cm-map "e" 'outline-show-entry) ; Show this heading's body
2744 (define-key cm-map "i" 'outline-show-children) ; Show this heading's immediate child sub-headings
2745 (define-key cm-map "k" 'outline-show-branches) ; Show all sub-headings under this heading
2746 (define-key cm-map "s" 'outline-show-subtree) ; Show (expand) everything in this heading & below
2748 (define-key cm-map "u" 'outline-up-heading) ; Up
2749 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
2750 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
2751 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
2752 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
2753 (global-set-key "\M-o" cm-map)
2754 ; fix up tmux xterm keys
2755 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
2756 (defun fix-up-tmux-keys ()
2757 "Fix up tmux xterm keys"
2760 (let ((x 2) (tkey ""))
2780 ;; ctrl + alt + shift
2782 (setq tkey "C-M-S-"))
2785 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
2786 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
2787 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
2788 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
2790 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
2792 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
2794 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
2796 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
2798 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2800 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2802 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
2804 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
2806 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
2808 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
2810 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
2812 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
2814 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
2816 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
2818 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
2820 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
2822 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
2824 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
2826 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
2828 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
2830 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
2832 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
2834 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
2836 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
2838 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
2840 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
2847 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
2849 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
2850 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
2851 (if (or (buffer-modified-p)
2852 (verify-visited-file-modtime)
2853 (< (* 8 1024 1024) (buffer-size))
2854 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
2856 (clear-visited-file-modtime)
2858 (ad-activate 'ask-user-about-supersession-threat)
2862 #+BEGIN_SRC emacs-lisp
2866 (or (getenv "EMACS_SERVER_NAME")
2868 (unless (server-running-p)
2869 (global-set-key "\C-xp" 'server-edit)
2876 #+BEGIN_SRC emacs-lisp
2877 (provide 'don-configuration)