1 #+PROPERTY: header-args:emacs-lisp :tangle don-configuration.el
5 # if for some reason, things get pear-shaped, we want to be able to
6 # enter the debugger by sending -USR2 to emacs
9 (setq debug-on-event 'siguser2)
11 * Initial startup stuff
12 ** Disable startup screen
13 #+BEGIN_SRC emacs-lisp
14 (setq inhibit-startup-screen t)
17 #+BEGIN_SRC emacs-lisp
18 ; (if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
19 (if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
20 (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
23 #+BEGIN_SRC emacs-lisp
24 (setq frame-resize-pixelwise t)
25 (add-to-list 'default-frame-alist '(fullscreen . maximixed))
28 ** package repositories and package manager
29 Borrowed from https://github.com/nilcons/emacs-use-package-fast/ to
30 load [[https://github.com/jwiegley/use-package/][use-package]] even faster
31 #+BEGIN_SRC emacs-lisp
33 ;; add /etc/ssl/ca-global/ca-certificates.crt so that we can
34 ;; download packages when we're on Debian hosts which chop down the
35 ;; list of available certificates
37 (add-to-list 'gnutls-trustfiles "/etc/ssl/ca-global/ca-certificates.crt")
38 (setq package-enable-at-startup nil)
39 (setq package--init-file-ensured t)
40 (setq package-user-dir "~/var/emacs/elpa")
41 (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
42 ("melpa" . "https://melpa.org/packages/")
43 ("org" . "http://orgmode.org/elpa/")))
44 (setq use-package-verbose (not (bound-and-true-p byte-compile-current-file))))
45 (mapc #'(lambda (add) (add-to-list 'load-path add))
48 (unless (package-installed-p 'use-package)
49 (package-refresh-contents)
50 (package-install 'use-package))
51 (let ((package-user-dir-real (file-truename package-user-dir)))
52 ;; The reverse is necessary, because outside we mapc
53 ;; add-to-list element-by-element, which reverses.
54 (nreverse (apply #'nconc
55 ;; Only keep package.el provided loadpaths.
56 (mapcar #'(lambda (path)
57 (if (string-prefix-p package-user-dir-real path)
62 ;;; fix up info paths for packages
63 (with-eval-after-load "info"
65 (dolist (dir (directory-files package-user-dir))
66 (let ((fdir (concat (file-name-as-directory package-user-dir) dir)))
67 (unless (or (member dir '("." ".." "archives" "gnupg"))
68 (not (file-directory-p fdir))
69 (not (file-exists-p (concat (file-name-as-directory fdir) "dir"))))
70 (add-to-list 'Info-directory-list fdir)))))
74 (require 'use-package))
79 #+BEGIN_SRC emacs-lisp
82 :commands (paradox-upgrade-packages paradox-list-packages)
84 (setq paradox-execute-asynchronously t)
85 (setq paradox-github-token t) ; I don't want to be prompted about this integration
90 #+BEGIN_SRC emacs-lisp
91 (add-to-list 'exec-path '"/usr/local/bin")
92 (add-to-list 'exec-path '"~/bin/")
96 #+BEGIN_SRC emacs-lisp
97 (add-to-list 'load-path '"~/lib/emacs_el/")
98 (add-to-list 'load-path '"~/lib/emacs_el/magit-annex")
100 * Disable custom-vars
101 #+BEGIN_SRC emacs-lisp
102 ;; Set the custom file to /dev/null and don't bother to load it
103 (setq custom-file "/dev/null")
107 #+BEGIN_SRC emacs-lisp
108 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
109 ;; execute conditional code when loading libraries
110 (defmacro with-library (symbol &rest body)
111 `(when (require ,symbol nil t)
113 (put 'with-library 'lisp-indent-function 1)
117 ** Safe Local Variables
118 #+BEGIN_SRC emacs-lisp
119 (setq safe-local-variable-values
120 (quote ((auto-save-default)
122 (cperl-indent-level . 4)
124 (indent-tabs-mode . f)
125 (vcl-indent-level . 4)
129 #+BEGIN_SRC emacs-lisp
130 (setq global-mark-ring-max 128
134 (defun don/minibuffer-setup-hook ()
135 (setq gc-cons-threshold most-positive-fixnum))
137 (defun don/minibuffer-exit-hook ()
138 (setq gc-cons-threshold 1048576))
140 (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
141 (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
145 #+BEGIN_SRC emacs-lisp
146 (use-package spacemacs-common
147 :ensure spacemacs-theme
149 (load-theme 'spacemacs-dark t)
153 #+BEGIN_SRC emacs-lisp
154 (use-package hippie-exp
155 :bind* (("M-<SPC>" . hippie-expand))
159 #+BEGIN_SRC emacs-lisp
160 (use-package flyspell
162 :diminish flyspell-mode 🐝
164 (add-hook 'text-mode-hook 'turn-on-flyspell)
165 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
166 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
167 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
169 (setq ispell-program-name "ispell")
174 #+begin_src emacs-lisp :tangle yes
180 #+BEGIN_SRC emacs-lisp
185 #+BEGIN_SRC emacs-lisp
186 (use-package eyebrowse
188 :diminish eyebrowse-mode
189 :init (setq eyebrowse-keymap-prefix (kbd "C-c e"))
191 (setq eyebrowse-wrap-around t)
194 (defun my/eyebrowse-new-window-config ()
198 ;; start at 1 run till 0
199 (let ((j (mod (+ i 1) 10)))
200 (when (and (not done)
201 (not (eyebrowse--window-config-present-p j)))
202 (eyebrowse-switch-to-window-config j)
203 (call-interactively 'eyebrowse-rename-window-config2 j)
208 ;; I don't use latex-preview-pane
209 ;; (require 'latex-preview-pane)
210 ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
211 ;; ;; latex-preview-pane uses window-parameters which are
212 ;; ;; not preserved by eyebrowse, so we close the preview
213 ;; ;; pane before switching, it will be regenerated when we
214 ;; ;; edit the TeX file.
215 ;; (when (lpp/window-containing-preview)
216 ;; (delete-window (lpp/window-containing-preview))))
218 ;; (add-to-list 'eyebrowse-pre-window-switch-hook
219 ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
221 ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
222 ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
223 ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
224 ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
225 ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
233 #+BEGIN_SRC emacs-lisp
234 (defun my/vsplit-last-buffer ()
235 "Split the window vertically and display the previous buffer."
237 (split-window-vertically)
239 (switch-to-next-buffer))
241 (defun my/hsplit-last-buffer ()
242 "Split the window horizontally and display the previous buffer."
244 (split-window-horizontally)
246 (switch-to-next-buffer))
248 (bind-key "C-x 2" 'my/vsplit-last-buffer)
249 (bind-key "C-x 3" 'my/hsplit-last-buffer)
251 (setq split-width-threshold 100)
252 (setq split-height-threshold 60)
254 (defun my/split-window-prefer-vertically (window)
255 "If there's only one window (excluding any possibly active
256 minibuffer), then split the current window horizontally."
257 (if (and (one-window-p t)
258 (not (active-minibuffer-window))
259 ( < (frame-width) (frame-height))
261 (let ((split-width-threshold nil))
262 (split-window-sensibly window))
263 (split-window-sensibly window)))
265 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
266 (setq window-combination-resize t)
269 *** Compilation window
271 If there is no compilation window, open one at the bottom, spanning
272 the complete width of the frame. Otherwise, reuse existing window. In
273 the former case, if there was no error the window closes
276 #+BEGIN_SRC emacs-lisp
277 (add-to-list 'display-buffer-alist
278 `(,(rx bos "*compilation*" eos)
279 (display-buffer-reuse-window
280 display-buffer-in-side-window)
281 (reusable-frames . visible)
283 (window-height . 0.4)))
286 #+BEGIN_SRC emacs-lisp
287 (defun my/compilation-exit-autoclose (status code msg)
288 ;; If M-x compile exists with a 0
289 (when (and (eq status 'exit) (zerop code))
290 ;; and delete the *compilation* window
291 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
292 (when (and (not (window-at-side-p compilation-window 'top))
293 (window-at-side-p compilation-window 'left)
294 (window-at-side-p compilation-window 'right))
295 (delete-window compilation-window))))
296 ;; Always return the anticipated result of compilation-exit-message-function
299 ;; Specify my function (maybe I should have done a lambda function)
300 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
303 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
304 value, the compilation buffer scrolls automatically to follow the
305 output. If the value is ~first-error~, scrolling stops when the first
306 error appears, leaving point at that error. For any other non-nil
307 value, scrolling continues until there is no more output.
309 #+BEGIN_SRC emacs-lisp
310 (setq compilation-scroll-output 'first-error)
313 ** Mode line cleaning
315 #+BEGIN_SRC emacs-lisp
316 (use-package diminish
321 #+BEGIN_SRC emacs-lisp
328 #+BEGIN_SRC emacs-lisp
330 :if (>= emacs-major-version 25)
332 :bind (("C-c C-<SPC>" . avy-goto-word-or-subword-1)
333 ("C-c j j" . avy-goto-word-or-subword-1)
334 ("M-g g" . avy-goto-line))
335 :config (progn (setq avy-background t))
338 *** Ace-link (jumping to links)
339 #+BEGIN_SRC emacs-lisp
340 (use-package ace-link
342 ; bind o in most modes
343 :config (ace-link-setup-default))
345 *** Jumping through edit points (goto-chg)
346 #+BEGIN_SRC emacs-lisp
347 (use-package goto-chg
349 :bind (("C-c j ," . goto-last-change)
350 ("C-c j ." . goto-last-change-reverse))
353 *** Jumping to bookmarks (visible bookmarks, bm)
354 #+BEGIN_SRC emacs-lisp
357 :bind (("C-c j b ." . bm-next)
358 ("C-c j b ," . bm-previous)
359 ("C-c j b SPC" . bm-toggle)))
364 #+BEGIN_SRC emacs-lisp
365 (use-package yasnippet
367 :diminish yas-minor-mode
370 (setq yas-verbosity 1)
371 (define-key yas-minor-mode-map (kbd "<tab>") nil)
372 (define-key yas-minor-mode-map (kbd "TAB") nil)
373 (define-key yas-minor-mode-map (kbd "<backtab>") nil)
374 (setq yas-snippet-dirs '("~/lib/emacs_el/snippets/"
375 "~/lib/emacs_el/yasnippet-snippets/snippets/"))
376 (add-to-list 'hippie-expand-try-functions-list
377 'yas-hippie-try-expand)
383 #+BEGIN_SRC emacs-lisp
384 (use-package auto-yasnippet
386 :bind (("H-w" . aya-create)
392 #+BEGIN_SRC emacs-lisp
395 :bind (("M-/" . company-complete))
397 (setq company-echo-delay 0 ; remove blinking
398 company-show-numbers t ; show numbers for easy selection
399 company-selection-wrap-around t
400 company-require-match nil
401 company-dabbrev-ignore-case t
402 company-dabbrev-ignore-invisible t
403 company-dabbrev-other-buffers t
404 company-dabbrev-downcase nil
405 company-dabbrev-code-everywhere t
406 company-tooltip-align-annotations t
407 company-minimum-prefix-length 1
408 company-global-modes '(not)
409 company-lighter-base "(C)")
410 (global-company-mode 1)
411 :bind (:map company-active-map
412 ("C-n" . company-select-next)
413 ("C-p" . company-select-previous)
414 ("M-?" . company-show-doc-buffer)
415 ("M-." . company-show-location)
420 #+BEGIN_SRC emacs-lisp
421 (use-package company-c-headers
424 (defun malb/ede-object-system-include-path ()
425 "Return the system include path for the current buffer."
427 (ede-system-include-path ede-object)))
429 (setq company-c-headers-path-system
430 #'malb/ede-object-system-include-path)
432 (add-to-list 'company-backends #'company-c-headers)))
435 #+BEGIN_SRC emacs-lisp
436 (use-package company-anaconda
438 :config (add-to-list 'company-backends #'company-anaconda))
441 #+BEGIN_SRC emacs-lisp
442 (use-package company-plsense
447 #+BEGIN_SRC emacs-lisp
448 (use-package company-math
451 #+BEGIN_SRC emacs-lisp
452 (use-package company-auctex
455 (defun company-auctex-labels (command &optional arg &rest ignored)
456 "company-auctex-labels backend"
457 (interactive (list 'interactive))
459 (interactive (company-begin-backend 'company-auctex-labels))
460 (prefix (company-auctex-prefix "\\\\.*ref{\\([^}]*\\)\\="))
461 (candidates (company-auctex-label-candidates arg))))
463 (add-to-list 'company-backends
464 '(company-auctex-macros
465 company-auctex-environments
466 company-math-symbols-unicode
467 company-math-symbols-latex))
469 (add-to-list 'company-backends #'company-auctex-labels)
470 (add-to-list 'company-backends #'company-auctex-bibs)
474 #+BEGIN_SRC emacs-lisp
475 (use-package company-bibtex
481 #+BEGIN_SRC emacs-lisp
482 (use-package company-shell
485 (setq company-shell-modes '(sh-mode shell-mode))
486 (add-to-list 'company-backends 'company-shell)))
491 Add YasSippet support for all company backends. ([[https://github.com/syl20bnr/spacemacs/pull/179][source]])
493 *Note:* Do this at the end of =company-mode= config.
495 #+BEGIN_SRC emacs-lisp
496 (defvar malb/company-mode/enable-yas t
497 "Enable yasnippet for all backends.")
499 (defun malb/company-mode/backend-with-yas (backend)
500 (if (or (not malb/company-mode/enable-yas)
502 (member 'company-yasnippet backend)))
504 (append (if (consp backend) backend (list backend))
505 '(:with company-yasnippet))))
507 (setq company-backends
508 (mapcar #'malb/company-mode/backend-with-yas company-backends))
513 Enable/disable company completion from ispell dictionaries ([[https://github.com/redguardtoo/emacs.d/blob/master/lisp/init-company.el][source]])
515 #+BEGIN_SRC emacs-lisp
516 (defun malb/toggle-company-ispell ()
519 ((member '(company-ispell :with company-yasnippet) company-backends)
520 (setq company-backends (delete '(company-ispell :with company-yasnippet) company-backends))
521 (add-to-list 'company-backends '(company-dabbrev :with company-yasnippet) t)
522 (message "company-ispell disabled"))
524 (setq company-backends (delete '(company-dabbrev :with company-yasnippet) company-backends))
525 (add-to-list 'company-backends '(company-ispell :with company-yasnippet) t)
526 (message "company-ispell enabled!"))))
528 (defun malb/company-ispell-setup ()
529 ;; @see https://github.com/company-mode/company-mode/issues/50
530 (when (boundp 'company-backends)
531 (make-local-variable 'company-backends)
532 (setq company-backends (delete '(company-dabbrev :with company-yasnippet) company-backends))
533 (add-to-list 'company-backends '(company-ispell :with company-yasnippet) t)
534 ;; https://github.com/redguardtoo/emacs.d/issues/473
535 (if (and (boundp 'ispell-alternate-dictionary)
536 ispell-alternate-dictionary)
537 (setq company-ispell-dictionary ispell-alternate-dictionary))))
542 1. =yas-expand= is run first and does what it has to, then it calls =malb/indent-fold-or-complete=.
544 2. This function then hopefully does what I want:
546 a. if a region is active, just indent
547 b. if we’re looking at a space after a non-whitespace character, we try some company-expansion
548 c. If =hs-minor-mode= or =outline-minor-mode= is active, try those next
549 d. otherwise call whatever would have been called otherwise.
551 ([[http://emacs.stackexchange.com/q/21182/8930][source]], [[http://emacs.stackexchange.com/q/7908/8930][source]])
553 #+BEGIN_SRC emacs-lisp
554 (defun malb/indent-fold-or-complete (&optional arg)
557 ;; if a region is active, indent
559 (indent-region (region-beginning)
561 ;; if the next char is space or eol, but prev char not whitespace
562 ((and (not (active-minibuffer-window))
565 (looking-back "[^[:space:]]")
566 (not (looking-back "^")))
568 (cond (company-mode (company-complete-common))
569 (auto-complete-mode (auto-complete))))
571 ;; no whitespace anywhere
572 ((and (not (active-minibuffer-window))
573 (looking-at "[^[:space:]]")
574 (looking-back "[^[:space:]]")
575 (not (looking-back "^")))
577 ((bound-and-true-p hs-minor-mode)
578 (save-excursion (end-of-line) (hs-toggle-hiding)))
579 ((bound-and-true-p outline-minor-mode)
580 (save-excursion (outline-cycle)))))
582 ;; by default just call whatever was bound
584 (let ((fn (or (if (current-local-map) (lookup-key (current-local-map) (kbd "TAB")))
585 'indent-for-tab-command)))
586 (if (not (called-interactively-p 'any))
588 (setq this-command fn)
589 (call-interactively fn))))))
591 (defun malb/toggle-fold ()
593 (cond ((eq major-mode 'org-mode)
594 (org-force-cycle-archived))
595 ((bound-and-true-p hs-minor-mode)
600 ((bound-and-true-p outline-minor-mode)
604 (bind-key "<tab>" #'malb/indent-fold-or-complete)
605 (bind-key "C-<tab>" #'malb/toggle-fold)
609 #+BEGIN_SRC emacs-lisp
611 (use-package tinyprocmail
612 :load-path "~/lib/emacs_el/tiny-tools/lisp/tiny"
613 :mode (".procmailrc" . turn-on-tinyprocmail-mode)
618 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
621 :bind (("C-x g" . magit-status)
622 ("C-x C-g" . magit-status))
624 ;; refine diffs always (hilight words)
625 (setq magit-diff-refine-hunk nil)
627 (use-package magit-annex
629 :load-path "~/lib/emacs_el/magit-annex/"
631 (use-package magit-vcsh
637 #+BEGIN_SRC emacs-lisp
638 (use-package cperl-mode
641 ;; Use c-mode for perl .xs files
642 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
643 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
644 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
645 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
646 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
649 cperl-auto-newline nil
650 cperl-auto-newline-after-colon nil
651 cperl-continued-statement-offset 4
652 cperl-brace-offset -1
653 cperl-continued-brace-offset 0
654 cperl-label-offset -4
655 cperl-highlight-variables-indiscriminately t
656 cperl-electric-lbrace-space nil
657 cperl-indent-parens-as-block nil
658 cperl-close-paren-offset -1
659 cperl-tab-always-indent t)
660 ;;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
665 #+BEGIN_SRC emacs-lisp
666 (use-package markdown-mode
668 :mode (("\\.md\\'" . markdown-mode)
669 ("\\.mdwn\\'" . markdown-mode)
670 ("README\\.md\\'" . gfm-mode)
673 (setq markdown-enable-math t)
674 (setq markdown-follow-wiki-link-on-enter nil)
675 (bind-key "M-." #'markdown-jump markdown-mode-map)
676 (add-hook 'markdown-mode-hook #'flyspell-mode)
677 (add-hook 'markdown-mode-hook #'outline-minor-mode)
678 (bind-key "C-<tab>" #'outline-cycle markdown-mode-map)
683 #+BEGIN_SRC emacs-lisp
684 ; load sql-indent when sql is loaded
685 (use-package sql-indent
689 :mode (("\\.sql\\'" . sql-mode))
693 #+BEGIN_SRC emacs-lisp
695 :commands ediff ediff3
698 ;; ediff configuration
699 ;; don't use the multi-window configuration
700 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
703 ** Do the Right Thing Indenting
704 Attempts to automatically identify the right indentation for a file
705 #+BEGIN_SRC emacs-lisp
706 (use-package dtrt-indent
710 ** VCL --editing varnish configuration files
711 #+BEGIN_SRC emacs-lisp
712 (use-package vcl-mode
719 #+BEGIN_SRC emacs-lisp
720 (defun malb/helm-omni (&rest arg)
721 ;; just in case someone decides to pass an argument, helm-omni won't fail.
723 (unless helm-source-buffers-list
724 (setq helm-source-buffers-list
725 (helm-make-source "Buffers" 'helm-source-buffers)))
729 (if (projectile-project-p)
730 '(helm-source-projectile-buffers-list
731 helm-source-buffers-list)
732 '(helm-source-buffers-list)) ;; list of all open buffers
734 `(((name . "Virtual Workspace")
735 (candidates . ,(--map (cons (eyebrowse-format-slot it) (car it))
736 (eyebrowse--get 'window-configs)))
737 (action . (lambda (candidate)
738 (eyebrowse-switch-to-window-config candidate)))))
740 (if (projectile-project-p)
741 '(helm-source-projectile-recentf-list
743 '(helm-source-recentf)) ;; all recent files
745 ;; always make some common files easily accessible
746 ;;'(((name . "Common Files")
747 ;; (candidates . malb/common-file-targets)
748 ;; (action . (("Open" . (lambda (x) (find-file (eval x))))))))
750 '(helm-source-files-in-current-dir
752 helm-source-bookmarks
753 helm-source-buffer-not-found ;; ask to create a buffer otherwise
755 "*Helm all the things*"))
759 :bind (("M-x" . helm-M-x)
760 ("C-x C-f" . helm-find-files)
761 ("C-x b" . helm-buffers-list) ; malb/helm-omni)
762 ("C-x C-b" . helm-buffers-list) ; malb/helm-omni)
763 ("C-c <SPC>" . helm-all-mark-rings))
765 (require 'helm-config)
766 (require 'helm-for-files)
767 (require 'helm-bookmark)
770 (define-key global-map [remap find-file] 'helm-find-files)
771 (define-key global-map [remap occur] 'helm-occur)
772 (define-key global-map [remap list-buffers] 'helm-buffers-list)
773 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
774 (unless (boundp 'completion-in-region-function)
775 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
776 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
777 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
782 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
784 #+BEGIN_SRC emacs-lisp
785 (use-package helm-flx
788 ;; these are helm configs, but they kind of fit here nicely
789 (setq helm-M-x-fuzzy-match t
790 helm-bookmark-show-location t
791 helm-buffers-fuzzy-matching t
792 helm-completion-in-region-fuzzy-match t
793 helm-file-cache-fuzzy-match t
794 helm-imenu-fuzzy-match t
795 helm-mode-fuzzy-match t
796 helm-locate-fuzzy-match nil
798 helm-recentf-fuzzy-match nil
799 helm-semantic-fuzzy-match t)
803 #+BEGIN_SRC emacs-lisp
805 ;;; stolen from https://github.com/malb/emacs.d/blob/master/malb.org
806 (defun malb/helm-swoop-pre-fill ()
807 (thing-at-point 'symbol))
808 (defvar malb/helm-swoop-ignore-major-mode "List of major modes to ignore for helm-swoop")
809 (setq malb/helm-swoop-ignore-major-mode '(dired-mode
810 paradox-menu-mode doc-view-mode pdf-view-mode
811 mu4e-headers-mode org-mode markdown-mode latex-mode
812 ein:notebook-multilang-mode))
814 (defun malb/swoop-or-search ()
816 (if (or (> (buffer-size) 1048576) ;; helm-swoop can be slow on big buffers
817 (memq major-mode malb/helm-swoop-ignore-major-mode))
821 (use-package helm-swoop
824 :bind (("C-c o" . helm-multi-swoop-org)
825 ("C-s" . malb/swoop-or-search)
826 ("C-M-s" . helm-multi-swoop-all))
829 (setq helm-swoop-pre-input-function #'malb/helm-swoop-pre-fill
830 helm-swoop-split-with-multiple-windows nil
831 helm-swoop-split-direction #'split-window-horizontally
832 helm-swoop-split-window-function 'helm-default-display-buffer
833 helm-swoop-speed-or-color t)
835 ;; https://emacs.stackexchange.com/questions/28790/helm-swoop-how-to-make-it-behave-more-like-isearch
836 (defun malb/helm-swoop-C-s ()
838 (if (boundp 'helm-swoop-pattern)
839 (if (equal helm-swoop-pattern "")
840 (previous-history-element 1)
844 (bind-key "C-S-s" #'helm-swoop-from-isearch isearch-mode-map)
845 (bind-key "C-S-s" #'helm-multi-swoop-all-from-helm-swoop helm-swoop-map)
846 (bind-key "C-r" #'helm-previous-line helm-swoop-map)
847 (bind-key "C-s" #'malb/helm-swoop-C-s helm-swoop-map)
848 (bind-key "C-r" #'helm-previous-line helm-multi-swoop-map)
849 (bind-key "C-s" #'malb/helm-swoop-C-s helm-multi-swoop-map))
854 #+BEGIN_SRC emacs-lisp
857 :config (setq helm-ag-base-command "ag --nocolor --nogroup"
858 helm-ag-command-option "--all-text"
859 helm-ag-insert-at-point 'symbol
860 helm-ag-fuzzy-match t
861 helm-ag-use-temp-buffer t
862 helm-ag-use-grep-ignore-list t
863 helm-ag-use-agignore t))
866 #+BEGIN_SRC emacs-lisp
867 (use-package helm-descbinds
869 :bind ("C-h b" . helm-descbinds)
870 :init (fset 'describe-bindings 'helm-descbinds))
874 #+BEGIN_SRC emacs-lisp
875 (use-package helm-c-yasnippet
877 :bind ("C-c h y" . helm-yas-complete)
879 (setq helm-yas-space-match-any-greedy t)))
882 #+BEGIN_SRC emacs-lisp
883 (use-package helm-org-rifle
886 (defun malb/helm-org-rifle-agenda-files (arg)
888 (let ((current-prefix-arg nil))
890 ((equal arg 4) (call-interactively #'helm-org-rifle-agenda-files nil))
891 ((equal arg 16) (helm-org-rifle-occur-agenda-files))
892 (t (helm-org-agenda-files-headings)))))))
895 This can be used to link things pretty quickly if necessary
896 #+BEGIN_SRC emacs-lisp
897 (use-package helm-google
899 :bind ("C-c h g" . helm-google)
901 (progn (add-to-list 'helm-google-actions
902 '("Copy URL" . (lambda (candidate)
904 (replace-regexp-in-string
905 "https://.*q=\\(.*\\)\&sa=.*"
911 (add-to-list 'helm-google-actions
912 '("Org Store Link" . (lambda (candidate)
913 (let ((title (car (split-string candidate "[\n]+")))
915 (replace-regexp-in-string
916 "https://.*q=\\(.*\\)\&sa=.*"
918 (push (list url title) org-stored-links))))
923 ** Projectile -- Project management
924 #+begin_src emacs-lisp
925 (use-package projectile
927 :bind (("<f5>" . projectile-compile-project)
928 ("<f6>" . next-error))
930 (use-package magit :ensure t)
931 (require 'helm-projectile)
934 (setq projectile-make-test-cmd "make check"
935 projectile-switch-project-action 'helm-projectile
936 projectile-mode-line '(:eval (format "»{%s}" (projectile-project-name))))
938 (projectile-global-mode)))
942 #+begin_src emacs-lisp
943 (use-package helm-projectile
946 (defvar malb/helm-source-file-not-found
947 (helm-build-dummy-source
952 'helm-projectile-sources-list
953 malb/helm-source-file-not-found t)
955 (helm-delete-action-from-source
956 "Grep in projects `C-s'"
957 helm-source-projectile-projects)
959 (helm-add-action-to-source
960 "Grep in projects `C-s'"
961 'helm-do-ag helm-source-projectile-projects 4)))
964 #+BEGIN_SRC emacs-lisp
967 :bind ("M-z" . avy-zap-up-to-char-dwim))
970 #+BEGIN_SRC emacs-lisp
972 :bind (("C-c 2" . my/hydra-orgmodes/body)
973 ("C-c @" . my/hydra-orgmodes/body)
974 ("C-c #" . my/hydra-outline/body)
975 ("C-c 3" . my/hydra-outline/body)
978 (defhydra my/hydra-orgmodes (:color blue :hint nil)
980 _n_: notes _c_: chaim _w_: wildman _o_: ool
981 _u_: uddin _s_: steve _r_: refile _f_: fh
982 _p_: read papers _R_: paper notes
987 ("n" (find-file "~/projects/org-notes/notes.org"))
988 ("c" (find-file "~/projects/org-notes/chaim.org"))
989 ("w" (find-file "~/projects/org-notes/wildman.org"))
990 ("u" (find-file "~/projects/org-notes/uddin.org"))
991 ("o" (find-file "~/projects/org-notes/ool.org"))
992 ("f" (find-file "~/projects/org-notes/fh.org"))
993 ("s" (find-file "~/projects/org-notes/sndservers.org"))
994 ("r" (find-file my/org-refile-file))
995 ("p" (find-file "~/projects/research/papers_to_read.org"))
996 ("R" (find-file "~/projects/research/paper_notes.org"))
997 ("h" (find-file "~/projects/org-notes/hpcbio.org"))
1002 ;; from https://github.com/abo-abo/hydra/wiki/Emacs
1003 (defhydra my/hydra-outline (:color pink :hint nil)
1006 ^^^^^^------------------------------------------------------
1007 _q_: sublevels _a_: all _u_: up
1008 _t_: body _e_: entry _n_: next visible
1009 _o_: other _i_: children _p_: previous visible
1010 _c_: entry _k_: branches _f_: forward same level
1011 _l_: leaves _s_: subtree _b_: backward same level
1016 ("q" outline-hide-sublevels) ; Hide everything but the top-level headings
1017 ("t" outline-hide-body) ; Hide everything but headings (all body lines)
1018 ("o" outline-hide-other) ; Hide other branches
1019 ("c" outline-hide-entry) ; Hide this entry's body
1020 ("l" outline-hide-leaves) ; Hide body lines in this entry and sub-entries
1021 ("d" outline-hide-subtree) ; Hide everything in this entry and sub-entries
1023 ("a" outline-show-all) ; Show (expand) everything
1024 ("e" outline-show-entry) ; Show this heading's body
1025 ("i" outline-show-children) ; Show this heading's immediate child sub-headings
1026 ("k" outline-show-branches) ; Show all sub-headings under this heading
1027 ("s" outline-show-subtree) ; Show (expand) everything in this heading & below
1029 ("u" outline-up-heading) ; Up
1030 ("n" outline-next-visible-heading) ; Next
1031 ("p" outline-previous-visible-heading) ; Previous
1032 ("f" outline-forward-same-level) ; Forward - same level
1033 ("b" outline-backward-same-level) ; Backward - same level
1039 #+BEGIN_SRC emacs-lisp
1042 (add-to-list 'tramp-methods '("vcsh"
1043 (tramp-login-program "vcsh")
1047 (tramp-remote-shell "/bin/sh")
1048 (tramp-remote-shell-args
1052 #+BEGIN_SRC emacs-lisp
1056 (setq-default reftex-default-bibliography
1057 '("~/projects/research/references.bib")))
1060 #+BEGIN_SRC emacs-lisp
1062 :config (setq bibtex-user-optional-fields
1063 (quote (("annote" "Personal annotation (ignored)")
1071 #+BEGIN_SRC emacs-lisp
1076 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
1077 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
1078 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
1079 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
1080 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
1081 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
1082 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
1083 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
1084 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
1085 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
1086 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
1088 (setq-default reftex-plug-into-AUCTeX t)
1089 ;; support fake section headers
1090 (setq TeX-outline-extra
1094 ("%subsubsection" 4)
1096 ;; add font locking to the headers
1097 (font-lock-add-keywords
1099 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
1100 0 'font-lock-keyword-face t)
1101 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
1102 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
1103 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
1104 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
1105 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
1107 ;; use smart quotes by default instead of `` and ''
1108 ;; taken from http://kieranhealy.org/esk/kjhealy.html
1109 (setq TeX-open-quote "“")
1110 (setq TeX-close-quote "”")
1112 ;; (TeX-add-style-hook
1117 ;; (custom-set-variables
1118 ;; '(font-latex-user-keyword-classes
1121 ;; font-lock-function-name-face 2 (command 1 t))))
1123 (setq-default TeX-parse-self t)
1124 (setq-default TeX-auto-save t)
1125 (setq-default TeX-master nil)
1126 (add-to-list 'LaTeX-font-list
1127 '(?\C-a "\\alert{","}"))
1130 '(TeX-add-style-hook
1133 (if (boundp 'reftex-ref-style-alist)
1135 'reftex-ref-style-alist
1136 '("Cleveref" "cleveref"
1137 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
1138 (reftex-ref-style-activate "Cleveref")
1140 '("cref" TeX-arg-ref)
1141 '("Cref" TeX-arg-ref)
1142 '("cpageref" TeX-arg-ref)
1143 '("Cpageref" TeX-arg-ref)))))
1146 '(add-to-list 'LaTeX-fill-excluded-macros
1149 (use-package font-latex
1151 (setq font-latex-match-reference-keywords
1173 (setq font-latex-fontify-script nil)
1174 (setq font-latex-fontify-sectioning (quote color))
1175 (setq font-latex-script-display (quote (nil)))
1180 #+BEGIN_SRC emacs-lisp
1184 :mode ("\\.R\\'" . ess-r-mode)
1185 :bind (:map ess-mode-map
1186 ("C-c C-R" . dla/ess-region-remote-eval))
1188 (autoload 'ess-r-mode "ess-site" nil t)
1189 (autoload 'R "ess-site" nil t)
1191 ; actually load the rest of ess
1193 (defun ess-change-directory (path)
1194 "Set the current working directory to PATH for both *R* and Emacs."
1195 (interactive "Directory to change to: ")
1197 (when (file-exists-p path)
1198 (ess-command (concat "setwd(\"" path "\")\n"))
1199 ;; use file-name-as-directory to ensure it has trailing /
1200 (setq default-directory (file-name-as-directory path))))
1201 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
1202 ;; outlining support for ess modes
1206 (outline-minor-mode)
1207 (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
1208 (defun outline-level ()
1209 (cond ((looking-at "^##### ") 1)
1210 ((looking-at "^#### ") 2)
1211 ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
1214 (defun dla/ess-region-remote-eval (start end)
1215 "Evaluate region in a remote ESS instance"
1217 (shell-command-on-region start end "eval_r" (get-buffer-create "***essregionremoteeval***") nil nil nil)
1218 (kill-buffer "***essregionremoteeval***"))
1219 ;; Don't restore history or save workspace image
1220 '(inferior-R-args "--no-restore-history --no-save")
1225 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
1227 #+BEGIN_SRC emacs-lisp
1228 (use-package rainbow-mode
1229 ;; add ess to the x major mode
1230 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
1231 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
1236 #+BEGIN_SRC emacs-lisp
1237 (use-package yaml-mode
1238 ;; add ess to the x major mode
1239 :mode ("\\.\\(yaml|yml\\)\\'" . yaml-mode)
1244 #+BEGIN_SRC emacs-lisp
1245 (use-package poly-noweb
1250 (use-package poly-markdown
1256 :after (:all polymode poly-markdown poly-noweb)
1257 ; :mode ("\\.Snw" . poly-noweb+r-mode)
1258 ; :mode ("\\.Rnw" . poly-noweb+r-mode)
1259 ; :mode ("\\.Rmd" . poly-markdown+r-mode)
1261 (use-package polymode
1269 #+BEGIN_SRC emacs-lisp
1270 (use-package outline-magic)
1273 #+BEGIN_SRC emacs-lisp
1274 ;; change the outline mode prefix from C-c @ to C-c C-2
1275 (setq outline-minor-mode-prefix "C-c C-2")
1276 ;;(add-hook 'outline-minor-mode-hook
1277 ;; (lambda () (local-set-key (kbd "C-c C-2")
1278 ;; outline-mode-prefix-map)))
1282 #+BEGIN_SRC emacs-lisp
1283 (use-package writeroom-mode
1285 (defun my/writing-mode ()
1286 "Start my writing mode; enable visual-line-mode and auto-fill-mode"
1291 (visual-line-mode -1)
1293 (visual-fill-column-mode -1)
1295 (visual-line-mode 1)
1297 (visual-fill-column-mode 1)
1302 ** GhostText/Atomic Chrome
1303 #+BEGIN_SRC emacs-lisp
1304 (use-package atomic-chrome
1306 (ignore-errors (atomic-chrome-start-server))
1307 (setq atomic-chrome-buffer-open-style 'full)
1311 #+BEGIN_SRC emacs-lisp
1312 (use-package edit-server
1314 :commands edit-server-start
1315 :init (if after-init-time
1317 (add-hook 'after-init-hook
1318 #'(lambda() (edit-server-start))))
1319 :config (setq edit-server-new-frame-alist
1320 '((name . "Edit with Emacs FRAME")
1326 (menu-bar-lines . t)
1327 (window-system . x)))
1332 :ID: 6fcf218b-a762-4c37-9339-a8202ddeb544
1334 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
1335 #+BEGIN_SRC emacs-lisp
1336 (use-package multiple-cursors
1337 :bind* (("C-;" . mc/mark-all-dwim)
1338 ("C-<" . mc/mark-previous-like-this)
1339 ("C->" . mc/mark-next-like-this)
1340 ("C-S-c C-S-c" . mc/edit-lines))
1344 #+BEGIN_SRC emacs-lisp
1345 (use-package web-mode
1346 :load-path "/home/don/projects/web-mode/"
1347 :mode ("\\.\\(tx|tmpl\\)\\'" . web-mode)
1349 (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . web-mode))
1350 (setq web-mode-enable-engine-detection t)
1351 (setq web-mode-engines-alist
1352 '(("template-toolkit" . "\\.tmpl\\'")))
1355 ** Spamassassin Mode
1356 #+BEGIN_SRC emacs-lisp
1357 (use-package spamassassin-mode
1358 :commands spamassassin-mode
1363 #+BEGIN_SRC emacs-lisp
1364 (use-package password-store
1366 :commands password-store-edit password-store-generate
1370 #+BEGIN_SRC emacs-lisp
1374 ;; fix up css mode to not be silly
1375 ;; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
1376 (setq cssm-indent-level 4)
1377 (setq cssm-newline-before-closing-bracket t)
1378 (setq cssm-indent-function #'cssm-c-style-indenter)
1379 (setq cssm-mirror-mode nil))
1382 #+BEGIN_SRC emacs-lisp
1384 :diminish abbrev-mode
1386 ;; load abbreviations from
1387 (setq abbrev-file-name
1388 "~/.emacs_abbrev_def")
1390 ;; read the abbrev file if it exists
1391 (if (file-exists-p abbrev-file-name)
1392 (quietly-read-abbrev-file))
1394 ;; for now, use abbrev mode everywhere
1395 (setq default-abbrev-mode t))
1398 ** Debugging (realgud)
1399 #+BEGIN_SRC emacs-lisp
1400 (use-package realgud
1404 ** Python Programming
1405 #+BEGIN_SRC emacs-lisp
1406 (use-package python-mode
1408 (python-mode . pyenv-mode)
1409 (python-mode . flycheck-mode)
1410 (python-mode . company-mode)
1411 (python-mode . blacken-mode)
1412 (python-mode . yas-minor-mode)
1413 (python-mode . anaconda-mode)
1418 (use-package blacken
1420 (setq-default blacken-fast-unsafe t)
1421 (setq-default blacken-line-length 80)
1423 (use-package anaconda-mode
1434 # #+BEGIN_SRC emacs-lisp
1435 # (use-package company-jedi
1437 # :hook (python-mode . (add-to-list 'company-backends 'company-jedi))
1438 # :hook (python-mode . 'jedi:setup)
1440 # (setq jedi:complete-on-dot t)
1444 #+begin_src emacs-lisp :tangle yes
1445 (use-package python-black
1449 *** Sphinx Documentation
1450 #+begin_src emacs-lisp :tangle yes
1451 (use-package numpydoc
1454 :bind (:map python-mode-map
1455 ("C-c C-n" . numpydoc-generate)))
1456 (use-package sphinx-doc
1460 (setq sphinx-doc-include-types t)
1464 #+BEGIN_SRC emacs-lisp
1465 (use-package go-mode
1472 #+BEGIN_SRC emacs-lisp
1473 (use-package expand-region
1474 :bind (("C-=" . 'er/expand-region))
1479 #+BEGIN_SRC emacs-lisp
1480 (use-package dockerfile-mode
1486 #+BEGIN_SRC emacs-lisp
1487 (use-package beancount
1488 :load-path "~/lib/emacs_el/beancount-mode/"
1490 :mode "\\.beancount\\'"
1497 #+BEGIN_SRC emacs-lisp
1498 (use-package message
1500 :diminish (message "✉")
1501 :mode ("muttng-[a-z0-9]+-[0-9]+-" . message-mode)
1502 :mode ("mutt-[a-z0-9]+-[0-9]+-" . message-mode)
1503 :hook 'my/message-mode-settings
1504 :hook 'turn-on-flyspell
1505 :bind (:map message-mode-map
1506 ("C-c C-a" . my/post-attach-file))
1507 :delight (message-mode "✉")
1509 (defun my/message-mode-settings ()
1510 (font-lock-add-keywords nil
1511 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1512 (0 'message-multiply-quoted-text-face))
1513 ("^[ \t]*>[ \t]*>.*$"
1514 (0 'message-double-quoted-text-face))))
1517 (defun my/post-attach-file ()
1518 "Prompt for an attachment."
1520 (let ((file (read-file-name "Attach file: " nil nil t nil)))
1521 (my/header-attach-file file "")))
1523 (defun my/header-attach-file (file description)
1524 "Attach a FILE to the current message (works with Mutt).
1525 Argument DESCRIPTION MIME description."
1526 (interactive "fAttach file: \nsDescription: ")
1527 (when (> (length file) 0)
1532 (goto-char (point-min))
1533 (search-forward-regexp "^$")
1534 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1536 (message (concat "Attached '" file "'."))
1537 (setq post-has-attachment t))))))
1539 (setq mail-yank-prefix "> ")
1540 (setq mail-header-separator "") ; fix broken header detection
1544 #+BEGIN_SRC emacs-lisp
1545 (use-package muttrc-mode
1552 ** Reverting buffers
1553 #+BEGIN_SRC emacs-lisp
1554 (use-package autorevert
1555 :diminish auto-revert-mode
1557 (setq global-auto-revert-non-file-buffers t
1558 global-auto-revert-ignore-modes '(pdf-view-mode)
1559 auto-revert-verbose nil)
1560 (global-auto-revert-mode 1))
1563 ** Use-package and load things
1564 #+BEGIN_SRC emacs-lisp
1567 :delight (org-mode "ø")
1568 :mode ("\\.\\(org\\|org_archive\\|txt\\)\\'" . org-mode)
1569 :bind (("C-c l" . org-store-link)
1570 ("C-c a" . org-agenda)
1571 ("C-c b" . org-iswitchb))
1573 ** Agenda Configuration
1574 #+BEGIN_SRC emacs-lisp
1576 (setq-default org-log-done 'time)
1577 (setq-default org-agenda-ndays 5)
1579 (setq org-agenda-sticky t)
1580 (defun dla/show-org-agenda ()
1585 (and (string-match-p
1593 (buffer-name agendabuffer))
1595 (delete-other-windows))
1597 ;; agenda configuration
1598 ;; Do not dim blocked tasks
1599 (setq org-agenda-dim-blocked-tasks nil)
1600 (setq org-agenda-inhibit-startup t)
1601 (setq org-agenda-use-tag-inheritance nil)
1603 ;; Compact the block agenda view
1604 (setq org-agenda-compact-blocks t)
1606 ;; Custom agenda command definitions
1607 (setq org-agenda-custom-commands
1608 (quote (("N" "Notes" tags "NOTE"
1609 ((org-agenda-overriding-header "Notes")
1610 (org-tags-match-list-sublevels t)))
1611 ("h" "Habits" tags-todo "STYLE=\"habit\""
1612 ((org-agenda-overriding-header "Habits")
1613 (org-agenda-sorting-strategy
1614 '(todo-state-down effort-up category-keep))))
1618 ((org-agenda-overriding-header "Tasks to Refile")
1619 (org-tags-match-list-sublevels nil)))
1620 (tags-todo "-CANCELLED/!"
1621 ((org-agenda-overriding-header "Stuck Projects")
1622 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
1623 (org-agenda-sorting-strategy
1625 (tags-todo "-HOLD-CANCELLED/!"
1626 ((org-agenda-overriding-header "Projects")
1627 (org-agenda-skip-function 'bh/skip-non-projects)
1628 (org-tags-match-list-sublevels 'indented)
1629 (org-agenda-sorting-strategy
1631 (tags-todo "-CANCELLED/!NEXT"
1632 ((org-agenda-overriding-header (concat "Project Next Tasks"
1633 (if bh/hide-scheduled-and-waiting-next-tasks
1635 " (including WAITING and SCHEDULED tasks)")))
1636 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1637 (org-tags-match-list-sublevels t)
1638 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1639 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1640 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1641 (org-agenda-sorting-strategy
1642 '(todo-state-down effort-up category-keep))))
1643 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1644 ((org-agenda-overriding-header (concat "Project Subtasks"
1645 (if bh/hide-scheduled-and-waiting-next-tasks
1647 " (including WAITING and SCHEDULED tasks)")))
1648 (org-agenda-skip-function 'bh/skip-non-project-tasks)
1649 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1650 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1651 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1652 (org-agenda-sorting-strategy
1654 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1655 ((org-agenda-overriding-header (concat "Standalone Tasks"
1656 (if bh/hide-scheduled-and-waiting-next-tasks
1658 " (including WAITING and SCHEDULED tasks)")))
1659 (org-agenda-skip-function 'bh/skip-project-tasks)
1660 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1661 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1662 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1663 (org-agenda-sorting-strategy
1665 (tags-todo "-CANCELLED+WAITING|HOLD/!"
1666 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
1667 (org-agenda-skip-function 'bh/skip-stuck-projects)
1668 (org-tags-match-list-sublevels nil)
1669 (org-agenda-todo-ignore-scheduled t)
1670 (org-agenda-todo-ignore-deadlines t)))
1672 ((org-agenda-overriding-header "Tasks to Archive")
1673 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1674 (org-tags-match-list-sublevels nil))))
1677 ; org mode agenda files
1678 (setq org-agenda-files
1680 (file-expand-wildcards "~/projects/org-notes/*.org")
1681 (file-expand-wildcards "~/org-mode/from-mobile.org")
1682 (file-expand-wildcards "~/org-notes-*/*.org")
1685 (setq my/org-refile-file
1687 (lambda (file) (string-match-p (regexp-quote "/refile.org") file))
1690 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
1691 (set-register ?r (cons 'file my/org-refile-file))
1692 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
1693 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
1694 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
1695 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
1696 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
1697 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
1698 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
1699 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
1700 (defun org-agenda-timeline-all (&optional arg)
1703 (dolist (org-agenda-file org-agenda-files)
1704 (insert-file-contents org-agenda-file nil)
1705 (goto-char (point-max))
1707 (write-file "/tmp/timeline.org")
1708 (org-agenda arg "L")))
1709 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
1713 #+BEGIN_SRC emacs-lisp
1714 (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")))
1715 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
1717 (setq org-default-notes-file "~/projects/org-notes/notes.org")
1718 (setq org-id-link-to-org-use-id 'use-existing)
1720 ** Capture Templates
1721 #+BEGIN_SRC emacs-lisp
1722 (setq org-capture-templates ;; mail-specific note template, identified by "m"
1723 `(("m" "Mail" entry (file my/org-refile-file)
1724 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
1725 ("t" "todo" entry (file my/org-refile-file)
1726 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
1727 ("r" "respond" entry (file my/org-refile-file)
1728 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
1729 ("n" "note" entry (file my/org-refile-file)
1730 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
1731 ("s" "schedule" entry (file my/org-refile-file)
1732 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
1733 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
1734 "* %?\n%U\n" :clock-in t :clock-resume t)
1735 ("w" "org-protocol" entry (file my/org-refile-file)
1736 "* TODO Review %c\n%U\n" :immediate-finish t)
1737 ("M" "Meeting" entry (file my/org-refile-file)
1738 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
1739 ("S" "Seminar" entry (file my/org-refile-file)
1740 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
1741 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
1742 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
1743 ("p" "Phone call" entry (file my/org-refile-file)
1744 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
1745 ("J" "job" entry (file+olp "~/projects/org-notes/notes.org"
1747 ,(format-time-string "Positions %Y"))
1748 "* TODO Apply for %? :job:\nSCHEDULED: <%<%Y-%m-%d>>\n%U\n%x\n" :clock-in t :clock-resume t)
1749 ("h" "Habit" entry (file my/org-refile-file)
1750 "* 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")
1754 ;; Remove empty LOGBOOK drawers on clock out
1755 (defun bh/remove-empty-drawer-on-clock-out ()
1758 (beginning-of-line 0)
1759 (org-remove-empty-drawer-at (point))))
1761 (defun my/org-add-id ()
1764 (if (org-current-level)
1773 ** Org mode key bindings
1774 #+BEGIN_SRC emacs-lisp
1775 ;; org mode configuration from http://doc.norang.ca/org-mode.html
1776 ;; Custom Key Bindings
1777 :bind* (("<f9> a" . org-agenda)
1778 ("<f9> I" . bh/punch-in)
1779 ("<f9> O" . bh/punch-out)
1780 ("<f9> SPC" . bh/clock-in-last-task)
1781 ("<f12>" . dla/show-org-agenda)
1782 ;; ("<f5>" . bh/org-todo)
1783 ("<S-f5>" . bh/widen)
1784 ("<f7>" . bh/set-truncate-lines)
1785 ("<f8>" . org-cycle-agenda-files)
1786 ("<f9> <f9>" . dla/show-org-agenda)
1788 ("<f9> c" . calendar)
1789 ("<f9> f" . boxquote-insert-file)
1790 ("<f9> h" . bh/hide-other)
1791 ("<f9> n" . bh/toggle-next-task-display)
1794 ("<f9> r" . boxquote-region)
1795 ("<f9> s" . bh/switch-to-scratch)
1797 ("<f9> t" . bh/insert-inactive-timestamp)
1798 ("<f9> T" . bh/toggle-insert-inactive-timestamp)
1800 ("<f9> v" . visible-mode)
1801 ("<f9> l" . org-toggle-link-display)
1802 ("<f9> SPC" . bh/clock-in-last-task)
1803 ("C-<f9>" . previous-buffer)
1804 ("M-<f9>" . org-toggle-inline-images)
1805 ("C-x n r" . narrow-to-region)
1806 ("C-<f10>" . next-buffer)
1807 ("<f11>" . org-clock-goto)
1808 ("C-<f11>" . org-clock-in)
1809 ("C-s-<f12>" . bh/save-then-publish)
1810 ("C-c c" . org-capture))
1813 ** Utility Functions
1814 #+BEGIN_SRC emacs-lisp
1815 (defun bh/hide-other ()
1818 (org-back-to-heading 'invisible-ok)
1819 (outline-hide-other)
1824 (defun bh/set-truncate-lines ()
1825 "Toggle value of truncate-lines and refresh window display."
1827 (setq truncate-lines (not truncate-lines))
1828 ;; now refresh window display (an idiom from simple.el):
1830 (set-window-start (selected-window)
1831 (window-start (selected-window)))))
1833 (defun bh/switch-to-scratch ()
1835 (switch-to-buffer "*scratch*"))
1837 (setq org-use-fast-todo-selection t)
1838 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1840 ; create function to create headlines in file. This comes from
1841 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
1842 (defun my/org-add-ids-to-headlines-in-file ()
1843 "Add ID properties to all headlines in the current file which
1844 do not already have one."
1848 (goto-char (point-min))
1849 (when (not (re-search-forward "^#\\+OPTIONS:.*auto-id:f" (point-max) t))
1850 (org-map-entries 'org-id-get-create))))
1851 (defun dla/org-update-ids-to-headlines-in-file ()
1852 "Add or replace ID properties to all headlines in the current file
1853 (or narrowed region)."
1856 (org-map-entries '(lambda () (org-id-get-create t))))
1857 ; if we wanted to do this to every buffer, do the following:
1858 (add-hook 'org-mode-hook
1860 (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
1863 #+BEGIN_SRC emacs-lisp
1864 (use-package find-lisp
1866 (setq org-agenda-text-search-extra-files
1867 (append '(agenda-archives)
1868 (find-lisp-find-files "~/projects/org-notes" "\.org$")
1869 (find-lisp-find-files "~/projects/org-notes" "\.org_archive$")
1873 #+BEGIN_SRC emacs-lisp
1874 (setq org-todo-keywords
1875 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
1876 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
1878 (setq org-todo-keyword-faces
1879 (quote (("TODO" :foreground "red" :weight bold)
1880 ("NEXT" :foreground "blue" :weight bold)
1881 ("DONE" :foreground "forest green" :weight bold)
1882 ("WAITING" :foreground "orange" :weight bold)
1883 ("HOLD" :foreground "magenta" :weight bold)
1884 ("CANCELLED" :foreground "forest green" :weight bold)
1885 ("MEETING" :foreground "forest green" :weight bold)
1886 ("PHONE" :foreground "forest green" :weight bold))))
1888 (setq org-todo-state-tags-triggers
1889 (quote (("CANCELLED" ("CANCELLED" . t))
1890 ("WAITING" ("WAITING" . t))
1891 ("HOLD" ("WAITING") ("HOLD" . t))
1892 (done ("WAITING") ("HOLD"))
1893 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1894 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1895 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1899 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1900 ; add ids on creation of nodes
1901 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
1904 ; resolve clocks after 10 minutes of idle; use xprintidle
1905 ; (setq org-clock-idle-time 10)
1906 ; (setq org-clock-x11idle-program-name "xprintidle")
1908 ; this is from http://doc.norang.ca/org-mode.html#Capture
1909 ; use C-M-r for org mode capture
1910 (global-set-key (kbd "C-M-r") 'org-capture)
1912 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1913 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1914 (org-agenda-files :maxlevel . 9))))
1916 ; Use full outline paths for refile targets - we file directly with IDO
1917 (setq org-refile-use-outline-path t)
1919 ; Targets complete directly with IDO
1920 (setq org-outline-path-complete-in-steps nil)
1922 ; Allow refile to create parent tasks with confirmation
1923 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1925 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
1926 ; (setq org-completion-use-ido t)
1927 ; (setq ido-everywhere t)
1928 ; (setq ido-max-directory-size 100000)
1929 ; (ido-mode (quote both))
1930 ; ; Use the current window when visiting files and buffers with ido
1931 ; (setq ido-default-file-method 'selected-window)
1932 ; (setq ido-default-buffer-method 'selected-window)
1933 ; ; Use the current window for indirect buffer display
1934 ; (setq org-indirect-buffer-display 'current-window)
1937 ;;;; Refile settings
1938 ; Exclude DONE state tasks from refile targets
1939 (defun bh/verify-refile-target ()
1940 "Exclude todo keywords with a done state from refile targets"
1941 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
1943 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1945 ;; ensure that emacsclient will show just the note to be edited when invoked
1946 ;; from Mutt, and that it will shut down emacsclient once finished;
1947 ;; fallback to legacy behavior when not invoked via org-protocol.
1948 (require 'org-protocol)
1949 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
1950 (setq my-org-protocol-flag nil)
1951 (defadvice org-capture-finalize (after delete-frame-at-end activate)
1952 "Delete frame at remember finalization"
1953 (progn (if my-org-protocol-flag (delete-frame))
1954 (setq my-org-protocol-flag nil)))
1955 (defadvice org-capture-refile (around delete-frame-after-refile activate)
1956 "Delete frame at remember refile"
1957 (if my-org-protocol-flag
1959 (setq my-org-protocol-flag nil)
1964 (defadvice org-capture-kill (after delete-frame-at-end activate)
1965 "Delete frame at remember abort"
1966 (progn (if my-org-protocol-flag (delete-frame))
1967 (setq my-org-protocol-flag nil)))
1968 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
1969 (setq my-org-protocol-flag t))
1971 (defadvice org-insert-todo-heading (after dla/create-id activate)
1972 (unless (org-in-item-p)
1978 (add-to-list 'org-modules 'org-habit)
1980 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
1981 (defun open-mail-in-mutt (message)
1982 "Open a mail message in Mutt, using an external terminal.
1984 Message can be specified either by a path pointing inside a
1985 Maildir, or by Message-ID."
1986 (interactive "MPath or Message-ID: ")
1988 (format "faf xterm -e \"%s %s\""
1989 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
1991 ;; add support for "mutt:ID" links
1992 (org-add-link-type "mutt" 'open-mail-in-mutt)
1994 (defun my-org-mode-setup ()
1995 ; (load-library "reftex")
1996 (and (buffer-file-name)
1997 (file-exists-p (buffer-file-name))
1999 ; (reftex-parse-all)
2000 (reftex-set-cite-format
2001 '((?b . "[[bib:%l][%l-bib]]")
2002 (?n . "[[notes:%l][%l-notes]]")
2004 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
2006 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
2007 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
2008 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
2009 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
2011 (add-hook 'org-mode-hook 'my-org-mode-setup)
2013 (defun org-mode-reftex-search ()
2015 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
2017 (defun open-research-paper (bibtexkey)
2018 "Open a paper by bibtex key"
2019 (interactive "bibtex key: ")
2022 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
2023 (org-add-link-type "papers" 'open-research-paper)
2024 (defun open-research-paper-pdf (bibtexkey)
2025 "Open a paper pdf by bibtex key"
2026 (interactive "bibtex key: ")
2028 (format "%s -p evince_annot %s"
2029 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
2030 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
2032 (add-to-list 'org-link-abbrev-alist
2034 "~/projects/research/paper_notes.org::#%s"))
2036 ; I pretty much always want hiearchical checkboxes
2037 (setq org-hierachical-checkbox-statistics nil)
2039 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
2040 (add-to-list 'org-structure-template-alist
2041 '("E" "\\begin{equation}\n?\n\\end{equation}"))
2044 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
2045 (defun my-rtcite-export-handler (path desc format)
2046 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
2047 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
2048 (match-string 1 path)))
2049 (path (substring path 0 (match-beginning 0))))
2050 (cond ((eq format 'latex)
2052 (equal 0 (search "rtcite:" desc)))
2053 (format "\\cite{%s}" search)
2054 (format "\\cite[%s]{%s}" desc search))))))
2056 (org-add-link-type "rtcite"
2058 'my-rtcite-export-handler)
2062 ** Org Mobile Configuration
2063 #+BEGIN_SRC emacs-lisp
2064 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
2065 (when (string= system-name "linnode")
2066 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
2067 (setq-default org-directory "/home/don/org-mode/")
2068 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
2072 #+BEGIN_SRC emacs-lisp
2073 ;; org mode ical export
2074 (setq org-icalendar-timezone "America/Los_Angeles")
2075 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
2076 ;; we already add the id manually
2077 (setq org-icalendar-store-UID t)
2080 ** General Org Babel Configuration
2081 #+BEGIN_SRC emacs-lisp
2082 ;; org babel support
2083 (org-babel-do-load-languages
2084 'org-babel-load-languages
2091 ;; set the right path to ditaa.jar
2092 (setq org-ditaa-jar-path "/usr/share/ditaa/ditaa.jar")
2093 ;; use graphviz-dot for dot things
2094 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
2095 ;; do not indent begin_src blocks
2096 (setq org-edit-src-content-indentation 0)
2097 ;; org-babel-by-backend
2098 (defmacro org-babel-by-backend (&rest body)
2099 `(case (if (boundp 'backend)
2100 (org-export-backend-name backend)
2103 (defun my/fix-inline-images ()
2104 (when org-inline-image-overlays
2105 (org-redisplay-inline-images)))
2107 (add-hook 'org-babel-after-execute-hook
2108 'my/fix-inline-images)
2111 ** LaTeX configuration
2113 :ID: 7135ba17-6a50-4eed-84ca-b90afa5b12f8
2115 #+BEGIN_SRC emacs-lisp
2116 (use-package ox-extra
2118 (ox-extras-activate '(ignore-headlines)))
2120 (add-to-list 'org-latex-classes
2122 "\\documentclass[11pt,oneside,article]{memoir}\n"
2123 ("\\section{%s}" . "\\section*{%s}")
2124 ("\\subsection{%s}" . "\\subsection*{%s}")
2125 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2126 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2127 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2129 (setq org-beamer-outline-frame-options "")
2130 (add-to-list 'org-latex-classes
2132 "\\documentclass[ignorenonframetext]{beamer}
2133 [NO-DEFAULT-PACKAGES]
2136 ("\\section{%s}" . "\\section*{%s}")
2137 ("\\subsection{%s}" . "\\subsection*{%s}")
2138 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2139 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2140 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2142 (add-to-list 'org-latex-classes
2144 "\\documentclass[11pt,oneside]{memoir}\n"
2145 ("\\chapter{%s}" . "\\chapter*{%s}")
2146 ("\\section{%s}" . "\\section*{%s}")
2147 ("\\subsection{%s}" . "\\subsection*{%s}")
2148 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
2150 (add-to-list 'org-latex-classes
2152 "\\documentclass[11pt]{letter}
2153 [NO-DEFAULT-PACKAGES]
2156 ("\\section{%s}" . "\\section*{%s}")
2157 ("\\subsection{%s}" . "\\subsection*{%s}")
2158 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2159 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2160 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2162 (add-to-list 'org-latex-classes
2164 "\\documentclass{dlacv}
2165 [NO-DEFAULT-PACKAGES]
2168 ("\\section{%s}" . "\\section*{%s}")
2169 ("\\subsection{%s}" . "\\subsection*{%s}")
2170 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2171 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2172 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2175 (add-to-list 'org-latex-classes
2177 "\\documentclass{dlaresume}
2178 [NO-DEFAULT-PACKAGES]
2181 ("\\section{%s}" . "\\section*{%s}")
2182 ("\\subsection{%s}" . "\\subsection*{%s}")
2183 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2184 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2185 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2188 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
2189 ;; but adapted to use latexmk 4.22 or higher.
2190 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
2192 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
2193 (setq org-latex-default-packages-alist
2195 ("" "unicode-math" t)
2197 (setq org-latex-packages-alist
2204 ("" "longtable" nil)
2207 ;; make equations larger
2208 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
2210 (defun org-create-formula--latex-header ()
2211 "Return LaTeX header appropriate for previewing a LaTeX snippet."
2212 (let ((info (org-combine-plists (org-export--get-global-options
2213 (org-export-get-backend 'latex))
2214 (org-export--get-inbuffer-options
2215 (org-export-get-backend 'latex)))))
2216 (org-latex-guess-babel-language
2217 (org-latex-guess-inputenc
2218 (org-splice-latex-header
2219 org-format-latex-header
2220 org-latex-default-packages-alist
2222 (plist-get info :latex-header)))
2226 ; support ignoring headers in org mode export to latex
2227 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
2228 (defadvice org-latex-headline (around my-latex-skip-headlines
2229 (headline contents info) activate)
2230 (if (member "ignoreheading" (org-element-property :tags headline))
2231 (setq ad-return-value contents)
2234 ;; keep latex logfiles
2236 (setq org-latex-remove-logfiles nil)
2238 ;; Resume clocking task when emacs is restarted
2239 (org-clock-persistence-insinuate)
2241 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
2242 (setq org-clock-history-length 23)
2243 ;; Resume clocking task on clock-in if the clock is open
2244 (setq org-clock-in-resume t)
2245 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
2246 ;; there are things like PHONE calls
2247 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
2248 ;; Separate drawers for clocking and logs
2249 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
2250 ;; Save clock data and state changes and notes in the LOGBOOK drawer
2251 (setq org-clock-into-drawer t)
2252 (setq org-log-into-drawer t)
2253 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
2254 (setq org-clock-out-remove-zero-time-clocks t)
2255 ;; Clock out when moving task to a done state
2256 (setq org-clock-out-when-done t)
2257 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
2258 (setq org-clock-persist t)
2259 ;; Do not prompt to resume an active clock
2260 (setq org-clock-persist-query-resume nil)
2261 ;; Enable auto clock resolution for finding open clocks
2262 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
2263 ;; Include current clocking task in clock reports
2264 (setq org-clock-report-include-clocking-task t)
2266 ;; the cache seems to be broken
2267 (setq org-element-use-cache nil)
2269 (defvar bh/keep-clock-running nil)
2271 (defun bh/is-task-p ()
2272 "Any task with a todo keyword and no subtask"
2276 (subtree-end (save-excursion (org-end-of-subtree t)))
2277 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2280 (while (and (not has-subtask)
2281 (< (point) subtree-end)
2282 (re-search-forward "^\*+ " subtree-end t))
2283 (when (member (org-get-todo-state) org-todo-keywords-1)
2284 (setq has-subtask t))))
2285 (and is-a-task (not has-subtask)))))
2286 (defun bh/is-project-p ()
2287 "Any task with a todo keyword subtask"
2291 (subtree-end (save-excursion (org-end-of-subtree t)))
2292 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2295 (while (and (not has-subtask)
2296 (< (point) subtree-end)
2297 (re-search-forward "^\*+ " subtree-end t))
2298 (when (member (org-get-todo-state) org-todo-keywords-1)
2299 (setq has-subtask t))))
2300 (and is-a-task has-subtask))))
2302 (defun bh/is-subproject-p ()
2303 "Any task which is a subtask of another project"
2304 (let ((is-subproject)
2305 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2307 (while (and (not is-subproject) (org-up-heading-safe))
2308 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
2309 (setq is-subproject t))))
2310 (and is-a-task is-subproject)))
2313 (defun bh/clock-in-to-next (kw)
2314 "Switch a task from TODO to NEXT when clocking in.
2315 Skips capture tasks, projects, and subprojects.
2316 Switch projects and subprojects from NEXT back to TODO"
2317 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
2319 ((and (member (org-get-todo-state) (list "TODO"))
2322 ((and (member (org-get-todo-state) (list "NEXT"))
2326 (defun bh/punch-in (arg)
2327 "Start continuous clocking and set the default task to the
2328 selected task. If no task is selected set the Organization task
2329 as the default task."
2331 (setq bh/keep-clock-running t)
2332 (if (equal major-mode 'org-agenda-mode)
2334 ;; We're in the agenda
2336 (let* ((marker (org-get-at-bol 'org-hd-marker))
2337 (tags (org-with-point-at marker (org-get-tags))))
2338 (if (and (eq arg 4) tags)
2339 (org-agenda-clock-in '(16))
2340 (bh/clock-in-organization-task-as-default)))
2342 ;; We are not in the agenda
2346 ; Find the tags on the current task
2347 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
2348 (org-clock-in '(16))
2349 (bh/clock-in-organization-task-as-default)))))
2351 (defun bh/punch-out ()
2353 (setq bh/keep-clock-running nil)
2354 (when (org-clock-is-active)
2356 (org-agenda-remove-restriction-lock))
2358 (defun bh/clock-in-default-task ()
2360 (org-with-point-at org-clock-default-task
2363 (defun bh/clock-in-parent-task ()
2364 "Move point to the parent (project) task if any and clock in"
2365 (let ((parent-task))
2369 (while (and (not parent-task) (org-up-heading-safe))
2370 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
2371 (setq parent-task (point))))
2373 (org-with-point-at parent-task
2375 (when bh/keep-clock-running
2376 (bh/clock-in-default-task)))))))
2378 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
2380 (defun bh/clock-in-organization-task-as-default ()
2382 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
2383 (org-clock-in '(16))))
2385 (defun bh/clock-out-maybe ()
2386 (when (and bh/keep-clock-running
2387 (not org-clock-clocking-in)
2388 (marker-buffer org-clock-default-task)
2389 (not org-clock-resolving-clocks-due-to-idleness))
2390 (bh/clock-in-parent-task)))
2392 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
2395 (defun bh/clock-in-task-by-id (id)
2396 "Clock in a task by id"
2397 (org-with-point-at (org-id-find id 'marker)
2398 (org-clock-in nil)))
2400 (defun bh/clock-in-last-task (arg)
2401 "Clock in the interrupted task if there is one
2402 Skip the default task and get the next one.
2403 A prefix arg forces clock in of the default task."
2405 (let ((clock-in-to-task
2407 ((eq arg 4) org-clock-default-task)
2408 ((and (org-clock-is-active)
2409 (equal org-clock-default-task (cadr org-clock-history)))
2410 (caddr org-clock-history))
2411 ((org-clock-is-active) (cadr org-clock-history))
2412 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
2413 (t (car org-clock-history)))))
2415 (org-with-point-at clock-in-to-task
2416 (org-clock-in nil))))
2419 (defun org-export-to-ods ()
2421 (let ((csv-file "data.csv"))
2422 (org-table-export csv-file "orgtbl-to-csv")
2423 (org-odt-convert csv-file "ods" 'open)))
2425 ; allow for zero-width-space to be a break in regexp too
2426 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
2427 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
2428 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
2430 ;; support inserting screen shots
2431 (defun my/org-insert-screenshot ()
2432 "Take a screenshot into a time stamped unique-named file in the
2433 same directory as the org-buffer and insert a link to this file."
2435 (defvar my/org-insert-screenshot/filename)
2436 (setq my/org-insert-screenshot/filename
2438 "Screenshot to insert: "
2440 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
2443 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
2444 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
2445 (org-display-inline-images))
2447 (defun my/fix-inline-images ()
2448 (when org-inline-image-overlays
2449 (org-redisplay-inline-images)))
2451 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
2453 ;; use xelatex to preview with imagemagick
2454 (add-to-list 'org-preview-latex-process-alist
2455 '(xelateximagemagick
2456 :programs ("xelatex" "convert")
2457 :description "pdf > png"
2458 :message "you need to install xelatex and imagemagick"
2460 :image-input-type "pdf"
2461 :image-output-type "png"
2462 :image-size-adjust (1.0 . 1.0)
2463 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
2464 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
2466 ;; use xelatex by default
2467 (setq org-preview-latex-default-process 'xelateximagemagick)
2469 ; from http://orgmode.org/Changes.html
2470 (defun my/org-repair-property-drawers ()
2471 "Fix properties drawers in current buffer.
2472 Ignore non Org buffers."
2474 (when (eq major-mode 'org-mode)
2475 (org-with-wide-buffer
2476 (goto-char (point-min))
2477 (let ((case-fold-search t)
2478 (inline-re (and (featurep 'org-inlinetask)
2479 (concat (org-inlinetask-outline-regexp)
2483 (unless (and inline-re (org-looking-at-p inline-re))
2485 (let ((end (save-excursion (outline-next-heading) (point))))
2487 (when (org-looking-at-p org-planning-line-re) (forward-line))
2488 (when (and (< (point) end)
2489 (not (org-looking-at-p org-property-drawer-re))
2491 (and (re-search-forward org-property-drawer-re end t)
2492 (eq (org-element-type
2493 (save-match-data (org-element-at-point)))
2495 (insert (delete-and-extract-region
2497 (min (1+ (match-end 0)) end)))
2498 (unless (bolp) (insert "\n"))))))))))))
2502 #+BEGIN_SRC emacs-lisp
2506 (use-package calfw-org
2509 (use-package org-gcal
2510 :if (file-readable-p "~/.hide/org_gcal.el")
2512 :config '((if (file-readable-p "~/.hide/org_gcal.el")
2513 (load-file "~/.hide/org_gcal.el"))
2518 #+BEGIN_SRC emacs-lisp
2522 ;; Show notification 10 minutes before event
2523 (setq appt-message-warning-time 10)
2524 ;; Disable multiple reminders
2525 (setq appt-display-interval appt-message-warning-time)
2526 (setq appt-display-mode-line nil)
2528 ;; add automatic reminders for appointments
2529 (defun my/org-agenda-to-appt ()
2531 (setq appt-time-msg-list nil)
2532 (org-agenda-to-appt))
2533 ;; add reminders when starting emacs
2534 (my/org-agenda-to-appt)
2535 ;; when rebuilding the agenda
2536 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
2537 "Pressing `r' on the agenda will also add appointments."
2538 (my/org-agenda-to-appt)
2540 ;; when saving all org buffers
2541 (defadvice org-save-all-org-buffers (after org-save-all-org-buffers-add-appts)
2542 "Re-add appts after saving all org buffers"
2543 (my/org-agenda-to-appt))
2544 ;; Display appointments as a window manager notification
2545 (setq appt-disp-window-function 'my/appt-display)
2546 (setq appt-delete-window-function (lambda () t))
2548 (setq my/appt-notification-app (concat (getenv "HOME") "/bin/appt_notification"))
2550 (defun my/appt-display (min-to-app new-time msg)
2551 (if (atom min-to-app)
2552 (start-process "my/appt-notification-app" nil my/appt-notification-app min-to-app msg)
2553 (dolist (i (number-sequence 0 (1- (length min-to-app))))
2554 (start-process "my/appt-notification-app" nil my/appt-notification-app
2555 (nth i min-to-app) (nth i msg))))
2561 ** outshine (outlining) integration
2562 #+BEGIN_SRC emacs-lisp
2563 (use-package outshine
2565 :hook (outline-minor-mode . outshine-hook-function)
2569 #+BEGIN_SRC emacs-lisp
2573 ** Home/End Begining/End of line
2574 #+BEGIN_SRC emacs-lisp
2575 (global-set-key [home] 'move-beginning-of-line)
2576 (global-set-key [end] 'move-end-of-line)
2579 #+BEGIN_SRC emacs-lisp
2580 (global-unset-key "\M-g")
2581 (global-set-key (kbd "M-g l") 'goto-line)
2585 #+BEGIN_SRC emacs-lisp
2586 (use-package debian-changelog-mode
2587 :mode "debian/changelog"
2589 (setq debian-changelog-mailing-address "don@debian.org")
2590 (setq debian-changelog-full-name "Don Armstrong"))
2592 * Misc (uncharacterized)
2593 #+BEGIN_SRC emacs-lisp
2594 (setq calendar-latitude 38.6)
2595 (setq calendar-longitude -121.5)
2596 (setq case-fold-search t)
2597 (setq confirm-kill-emacs (quote y-or-n-p))
2598 (setq cperl-lazy-help-time nil)
2600 ** Turn on fontlock and icomplete
2601 #+BEGIN_SRC emacs-lisp
2602 (global-font-lock-mode 1)
2604 (setq log-edit-keep-buffer t)
2606 ** Set mail User agent
2607 #+BEGIN_SRC emacs-lisp
2608 (setq mail-user-agent (quote sendmail-user-agent))
2609 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
2612 #+BEGIN_SRC emacs-lisp
2613 (setq ps-footer-font-size (quote (8 . 10)))
2614 (setq ps-header-font-size (quote (8 . 10)))
2615 (setq ps-header-title-font-size (quote (10 . 10)))
2616 (setq ps-line-number-color "blue")
2617 (setq ps-print-footer t)
2618 (setq ps-print-footer-frame nil)
2619 (setq ps-print-only-one-header t)
2621 ** Only single spacing on sentences
2622 #+BEGIN_SRC emacs-lisp
2623 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
2625 (setq sentence-end-double-space nil)
2626 ; enable matching parenthesis
2628 ** Display paren mode
2629 #+BEGIN_SRC emacs-lisp
2631 (setq show-paren-delay 0.2)
2635 #+BEGIN_SRC emacs-lisp
2636 (setq user-mail-address "don@donarmstrong.com")
2639 ** Use primary selection on unix machines
2640 #+BEGIN_SRC emacs-lisp
2641 ;; switch back to the old primary selection method
2642 (if (or (string-equal system-type "darwin")
2643 (string-equal system-type "windows")
2646 (setq select-enable-clipboard t)
2647 (setq select-enable-primary nil)
2650 (setq select-enable-clipboard nil)
2651 (setq select-enable-primary t)
2653 ; (setq mouse-drag-copy-region t)
2655 ;; tramp configuration
2656 (setq tramp-use-ssh-controlmaster-options nil)
2658 (setq-default c-indent-level 4)
2659 (setq-default c-brace-imaginary-offset 0)
2660 (setq-default c-brace-offset -4)
2661 (setq-default c-argdecl-indent 4)
2662 (setq-default c-label-offset -4)
2663 (setq-default c-continued-statement-offset 4)
2665 (setq-default indent-tabs-mode nil)
2666 (setq-default tab-width 4)
2669 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
2670 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
2671 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
2672 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
2673 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
2676 (defun insert-date ()
2677 "Insert date at point."
2679 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
2680 (global-set-key "\C-[d" 'insert-date)
2682 (defun unfill-paragraph (arg)
2683 "Pull this whole paragraph up onto one line."
2685 (let ((fill-column 10000))
2686 (fill-paragraph arg))
2689 (column-number-mode t)
2692 ** Desktop-save-mode
2693 If the envvar EMACS_SERVER_NAME is set, consider this a separate
2694 emacs, and use a different desktop file to restore history
2695 #+BEGIN_SRC emacs-lisp
2696 (use-package desktop
2699 (setq desktop-base-file-name
2700 (convert-standard-filename
2702 (or (getenv "EMACS_SERVER_NAME")
2706 (setq desktop-base-lock-name
2707 (convert-standard-filename
2708 (concat desktop-base-file-name
2710 (setq desktop-auto-save-timeout 60)
2711 (setq desktop-restore-eager 5)
2712 (setq desktop-lazy-verbose nil)
2713 (desktop-save-mode 1)
2717 ** Misc (Uncharacterized)
2718 #+BEGIN_SRC emacs-lisp
2719 '(icomplete-mode on)
2721 ;; custom-set-faces was added by Custom.
2722 ;; If you edit it by hand, you could mess it up, so be careful.
2723 ;; Your init file should contain only one such instance.
2724 ;; If there is more than one, they won't work right.
2725 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
2728 (put 'upcase-region 'disabled nil)
2729 (put 'downcase-region 'disabled nil)
2730 (put 'narrow-to-region 'disabled nil)
2732 ; (defun turn-on-flyspell ()
2733 ; "Force flyspell-mode on using a positive arg. For use in hooks."
2735 ; (flyspell-mode 1))
2738 ; Outline-minor-mode key map
2739 (define-prefix-command 'cm-map nil "Outline-")
2741 (define-key cm-map "q" 'outline-hide-sublevels) ; Hide everything but the top-level headings
2742 (define-key cm-map "t" 'outline-hide-body) ; Hide everything but headings (all body lines)
2743 (define-key cm-map "o" 'outline-hide-other) ; Hide other branches
2744 (define-key cm-map "c" 'outline-hide-entry) ; Hide this entry's body
2745 (define-key cm-map "l" 'outline-hide-leaves) ; Hide body lines in this entry and sub-entries
2746 (define-key cm-map "d" 'outline-hide-subtree) ; Hide everything in this entry and sub-entries
2748 (define-key cm-map "a" 'outline-show-all) ; Show (expand) everything
2749 (define-key cm-map "e" 'outline-show-entry) ; Show this heading's body
2750 (define-key cm-map "i" 'outline-show-children) ; Show this heading's immediate child sub-headings
2751 (define-key cm-map "k" 'outline-show-branches) ; Show all sub-headings under this heading
2752 (define-key cm-map "s" 'outline-show-subtree) ; Show (expand) everything in this heading & below
2754 (define-key cm-map "u" 'outline-up-heading) ; Up
2755 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
2756 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
2757 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
2758 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
2759 (global-set-key "\M-o" cm-map)
2760 ; fix up tmux xterm keys
2761 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
2762 (defun fix-up-tmux-keys ()
2763 "Fix up tmux xterm keys"
2766 (let ((x 2) (tkey ""))
2786 ;; ctrl + alt + shift
2788 (setq tkey "C-M-S-"))
2791 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
2792 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
2793 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
2794 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
2796 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
2798 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
2800 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
2802 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
2804 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2806 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2808 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
2810 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
2812 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
2814 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
2816 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
2818 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
2820 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
2822 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
2824 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
2826 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
2828 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
2830 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
2832 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
2834 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
2836 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
2838 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
2840 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
2842 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
2844 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
2846 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
2853 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
2855 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
2856 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
2857 (if (or (buffer-modified-p)
2858 (verify-visited-file-modtime)
2859 (< (* 8 1024 1024) (buffer-size))
2860 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
2862 (clear-visited-file-modtime)
2864 (ad-activate 'ask-user-about-supersession-threat)
2868 #+BEGIN_SRC emacs-lisp
2872 (or (getenv "EMACS_SERVER_NAME")
2874 (unless (server-running-p)
2875 (global-set-key "\C-xp" 'server-edit)
2882 #+BEGIN_SRC emacs-lisp
2883 (provide 'don-configuration)