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
685 :mode (("\\.sql\\'" . sql-mode))
687 (require sql-indent))
690 #+BEGIN_SRC emacs-lisp
692 :commands ediff ediff3
695 ;; ediff configuration
696 ;; don't use the multi-window configuration
697 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
700 ** Do the Right Thing Indenting
701 Attempts to automatically identify the right indentation for a file
702 #+BEGIN_SRC emacs-lisp
703 (use-package dtrt-indent
707 ** VCL --editing varnish configuration files
708 #+BEGIN_SRC emacs-lisp
709 (use-package vcl-mode
716 #+BEGIN_SRC emacs-lisp
717 (defun malb/helm-omni (&rest arg)
718 ;; just in case someone decides to pass an argument, helm-omni won't fail.
720 (unless helm-source-buffers-list
721 (setq helm-source-buffers-list
722 (helm-make-source "Buffers" 'helm-source-buffers)))
726 (if (projectile-project-p)
727 '(helm-source-projectile-buffers-list
728 helm-source-buffers-list)
729 '(helm-source-buffers-list)) ;; list of all open buffers
731 `(((name . "Virtual Workspace")
732 (candidates . ,(--map (cons (eyebrowse-format-slot it) (car it))
733 (eyebrowse--get 'window-configs)))
734 (action . (lambda (candidate)
735 (eyebrowse-switch-to-window-config candidate)))))
737 (if (projectile-project-p)
738 '(helm-source-projectile-recentf-list
740 '(helm-source-recentf)) ;; all recent files
742 ;; always make some common files easily accessible
743 ;;'(((name . "Common Files")
744 ;; (candidates . malb/common-file-targets)
745 ;; (action . (("Open" . (lambda (x) (find-file (eval x))))))))
747 '(helm-source-files-in-current-dir
749 helm-source-bookmarks
750 helm-source-buffer-not-found ;; ask to create a buffer otherwise
752 "*Helm all the things*"))
756 :bind (("M-x" . helm-M-x)
757 ("C-x C-f" . helm-find-files)
758 ("C-x b" . helm-buffers-list) ; malb/helm-omni)
759 ("C-x C-b" . helm-buffers-list) ; malb/helm-omni)
760 ("C-c <SPC>" . helm-all-mark-rings))
762 (require 'helm-config)
763 (require 'helm-for-files)
764 (require 'helm-bookmark)
767 (define-key global-map [remap find-file] 'helm-find-files)
768 (define-key global-map [remap occur] 'helm-occur)
769 (define-key global-map [remap list-buffers] 'helm-buffers-list)
770 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
771 (unless (boundp 'completion-in-region-function)
772 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
773 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
774 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
779 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
781 #+BEGIN_SRC emacs-lisp
782 (use-package helm-flx
785 ;; these are helm configs, but they kind of fit here nicely
786 (setq helm-M-x-fuzzy-match t
787 helm-bookmark-show-location t
788 helm-buffers-fuzzy-matching t
789 helm-completion-in-region-fuzzy-match t
790 helm-file-cache-fuzzy-match t
791 helm-imenu-fuzzy-match t
792 helm-mode-fuzzy-match t
793 helm-locate-fuzzy-match nil
795 helm-recentf-fuzzy-match nil
796 helm-semantic-fuzzy-match t)
800 #+BEGIN_SRC emacs-lisp
802 ;;; stolen from https://github.com/malb/emacs.d/blob/master/malb.org
803 (defun malb/helm-swoop-pre-fill ()
804 (thing-at-point 'symbol))
805 (defvar malb/helm-swoop-ignore-major-mode "List of major modes to ignore for helm-swoop")
806 (setq malb/helm-swoop-ignore-major-mode '(dired-mode
807 paradox-menu-mode doc-view-mode pdf-view-mode
808 mu4e-headers-mode org-mode markdown-mode latex-mode
809 ein:notebook-multilang-mode))
811 (defun malb/swoop-or-search ()
813 (if (or (> (buffer-size) 1048576) ;; helm-swoop can be slow on big buffers
814 (memq major-mode malb/helm-swoop-ignore-major-mode))
818 (use-package helm-swoop
821 :bind (("C-c o" . helm-multi-swoop-org)
822 ("C-s" . malb/swoop-or-search)
823 ("C-M-s" . helm-multi-swoop-all))
826 (setq helm-swoop-pre-input-function #'malb/helm-swoop-pre-fill
827 helm-swoop-split-with-multiple-windows nil
828 helm-swoop-split-direction #'split-window-horizontally
829 helm-swoop-split-window-function 'helm-default-display-buffer
830 helm-swoop-speed-or-color t)
832 ;; https://emacs.stackexchange.com/questions/28790/helm-swoop-how-to-make-it-behave-more-like-isearch
833 (defun malb/helm-swoop-C-s ()
835 (if (boundp 'helm-swoop-pattern)
836 (if (equal helm-swoop-pattern "")
837 (previous-history-element 1)
841 (bind-key "C-S-s" #'helm-swoop-from-isearch isearch-mode-map)
842 (bind-key "C-S-s" #'helm-multi-swoop-all-from-helm-swoop helm-swoop-map)
843 (bind-key "C-r" #'helm-previous-line helm-swoop-map)
844 (bind-key "C-s" #'malb/helm-swoop-C-s helm-swoop-map)
845 (bind-key "C-r" #'helm-previous-line helm-multi-swoop-map)
846 (bind-key "C-s" #'malb/helm-swoop-C-s helm-multi-swoop-map))
851 #+BEGIN_SRC emacs-lisp
854 :config (setq helm-ag-base-command "ag --nocolor --nogroup"
855 helm-ag-command-option "--all-text"
856 helm-ag-insert-at-point 'symbol
857 helm-ag-fuzzy-match t
858 helm-ag-use-temp-buffer t
859 helm-ag-use-grep-ignore-list t
860 helm-ag-use-agignore t))
863 #+BEGIN_SRC emacs-lisp
864 (use-package helm-descbinds
866 :bind ("C-h b" . helm-descbinds)
867 :init (fset 'describe-bindings 'helm-descbinds))
871 #+BEGIN_SRC emacs-lisp
872 (use-package helm-c-yasnippet
874 :bind ("C-c h y" . helm-yas-complete)
876 (setq helm-yas-space-match-any-greedy t)))
879 #+BEGIN_SRC emacs-lisp
880 (use-package helm-org-rifle
883 (defun malb/helm-org-rifle-agenda-files (arg)
885 (let ((current-prefix-arg nil))
887 ((equal arg 4) (call-interactively #'helm-org-rifle-agenda-files nil))
888 ((equal arg 16) (helm-org-rifle-occur-agenda-files))
889 (t (helm-org-agenda-files-headings)))))))
892 This can be used to link things pretty quickly if necessary
893 #+BEGIN_SRC emacs-lisp
894 (use-package helm-google
896 :bind ("C-c h g" . helm-google)
898 (progn (add-to-list 'helm-google-actions
899 '("Copy URL" . (lambda (candidate)
901 (replace-regexp-in-string
902 "https://.*q=\\(.*\\)\&sa=.*"
908 (add-to-list 'helm-google-actions
909 '("Org Store Link" . (lambda (candidate)
910 (let ((title (car (split-string candidate "[\n]+")))
912 (replace-regexp-in-string
913 "https://.*q=\\(.*\\)\&sa=.*"
915 (push (list url title) org-stored-links))))
920 ** Projectile -- Project management
921 #+begin_src emacs-lisp
922 (use-package projectile
924 :bind (("<f5>" . projectile-compile-project)
925 ("<f6>" . next-error))
927 (use-package magit :ensure t)
928 (require 'helm-projectile)
931 (setq projectile-make-test-cmd "make check"
932 projectile-switch-project-action 'helm-projectile
933 projectile-mode-line '(:eval (format "»{%s}" (projectile-project-name))))
935 (projectile-global-mode)))
939 #+begin_src emacs-lisp
940 (use-package helm-projectile
943 (defvar malb/helm-source-file-not-found
944 (helm-build-dummy-source
949 'helm-projectile-sources-list
950 malb/helm-source-file-not-found t)
952 (helm-delete-action-from-source
953 "Grep in projects `C-s'"
954 helm-source-projectile-projects)
956 (helm-add-action-to-source
957 "Grep in projects `C-s'"
958 'helm-do-ag helm-source-projectile-projects 4)))
961 #+BEGIN_SRC emacs-lisp
964 :bind ("M-z" . avy-zap-up-to-char-dwim))
967 #+BEGIN_SRC emacs-lisp
969 :bind (("C-c 2" . my/hydra-orgmodes/body)
970 ("C-c @" . my/hydra-orgmodes/body)
971 ("C-c #" . my/hydra-outline/body)
972 ("C-c 3" . my/hydra-outline/body)
975 (defhydra my/hydra-orgmodes (:color blue :hint nil)
977 _n_: notes _c_: chaim _w_: wildman _o_: ool
978 _u_: uddin _s_: steve _r_: refile _f_: fh
979 _p_: read papers _R_: paper notes
984 ("n" (find-file "~/projects/org-notes/notes.org"))
985 ("c" (find-file "~/projects/org-notes/chaim.org"))
986 ("w" (find-file "~/projects/org-notes/wildman.org"))
987 ("u" (find-file "~/projects/org-notes/uddin.org"))
988 ("o" (find-file "~/projects/org-notes/ool.org"))
989 ("f" (find-file "~/projects/org-notes/fh.org"))
990 ("s" (find-file "~/projects/org-notes/sndservers.org"))
991 ("r" (find-file my/org-refile-file))
992 ("p" (find-file "~/projects/research/papers_to_read.org"))
993 ("R" (find-file "~/projects/research/paper_notes.org"))
994 ("h" (find-file "~/projects/org-notes/hpcbio.org"))
999 ;; from https://github.com/abo-abo/hydra/wiki/Emacs
1000 (defhydra my/hydra-outline (:color pink :hint nil)
1003 ^^^^^^------------------------------------------------------
1004 _q_: sublevels _a_: all _u_: up
1005 _t_: body _e_: entry _n_: next visible
1006 _o_: other _i_: children _p_: previous visible
1007 _c_: entry _k_: branches _f_: forward same level
1008 _l_: leaves _s_: subtree _b_: backward same level
1013 ("q" outline-hide-sublevels) ; Hide everything but the top-level headings
1014 ("t" outline-hide-body) ; Hide everything but headings (all body lines)
1015 ("o" outline-hide-other) ; Hide other branches
1016 ("c" outline-hide-entry) ; Hide this entry's body
1017 ("l" outline-hide-leaves) ; Hide body lines in this entry and sub-entries
1018 ("d" outline-hide-subtree) ; Hide everything in this entry and sub-entries
1020 ("a" outline-show-all) ; Show (expand) everything
1021 ("e" outline-show-entry) ; Show this heading's body
1022 ("i" outline-show-children) ; Show this heading's immediate child sub-headings
1023 ("k" outline-show-branches) ; Show all sub-headings under this heading
1024 ("s" outline-show-subtree) ; Show (expand) everything in this heading & below
1026 ("u" outline-up-heading) ; Up
1027 ("n" outline-next-visible-heading) ; Next
1028 ("p" outline-previous-visible-heading) ; Previous
1029 ("f" outline-forward-same-level) ; Forward - same level
1030 ("b" outline-backward-same-level) ; Backward - same level
1036 #+BEGIN_SRC emacs-lisp
1039 (add-to-list 'tramp-methods '("vcsh"
1040 (tramp-login-program "vcsh")
1044 (tramp-remote-shell "/bin/sh")
1045 (tramp-remote-shell-args
1049 #+BEGIN_SRC emacs-lisp
1053 (setq-default reftex-default-bibliography
1054 '("~/projects/research/references.bib")))
1057 #+BEGIN_SRC emacs-lisp
1059 :config (setq bibtex-user-optional-fields
1060 (quote (("annote" "Personal annotation (ignored)")
1068 #+BEGIN_SRC emacs-lisp
1073 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
1074 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
1075 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
1076 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
1077 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
1078 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
1079 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
1080 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
1081 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
1082 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
1083 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
1085 (setq-default reftex-plug-into-AUCTeX t)
1086 ;; support fake section headers
1087 (setq TeX-outline-extra
1091 ("%subsubsection" 4)
1093 ;; add font locking to the headers
1094 (font-lock-add-keywords
1096 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
1097 0 'font-lock-keyword-face t)
1098 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
1099 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
1100 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
1101 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
1102 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
1104 ;; use smart quotes by default instead of `` and ''
1105 ;; taken from http://kieranhealy.org/esk/kjhealy.html
1106 (setq TeX-open-quote "“")
1107 (setq TeX-close-quote "”")
1109 ;; (TeX-add-style-hook
1114 ;; (custom-set-variables
1115 ;; '(font-latex-user-keyword-classes
1118 ;; font-lock-function-name-face 2 (command 1 t))))
1120 (setq-default TeX-parse-self t)
1121 (setq-default TeX-auto-save t)
1122 (setq-default TeX-master nil)
1123 (add-to-list 'LaTeX-font-list
1124 '(?\C-a "\\alert{","}"))
1127 '(TeX-add-style-hook
1130 (if (boundp 'reftex-ref-style-alist)
1132 'reftex-ref-style-alist
1133 '("Cleveref" "cleveref"
1134 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
1135 (reftex-ref-style-activate "Cleveref")
1137 '("cref" TeX-arg-ref)
1138 '("Cref" TeX-arg-ref)
1139 '("cpageref" TeX-arg-ref)
1140 '("Cpageref" TeX-arg-ref)))))
1143 '(add-to-list 'LaTeX-fill-excluded-macros
1146 (use-package font-latex
1148 (setq font-latex-match-reference-keywords
1170 (setq font-latex-fontify-script nil)
1171 (setq font-latex-fontify-sectioning (quote color))
1172 (setq font-latex-script-display (quote (nil)))
1177 #+BEGIN_SRC emacs-lisp
1181 :mode ("\\.R\\'" . ess-r-mode)
1182 :bind (:map ess-mode-map
1183 ("C-c C-R" . dla/ess-region-remote-eval))
1185 (autoload 'ess-r-mode "ess-site" nil t)
1186 (autoload 'R "ess-site" nil t)
1188 ; actually load the rest of ess
1190 (defun ess-change-directory (path)
1191 "Set the current working directory to PATH for both *R* and Emacs."
1192 (interactive "Directory to change to: ")
1194 (when (file-exists-p path)
1195 (ess-command (concat "setwd(\"" path "\")\n"))
1196 ;; use file-name-as-directory to ensure it has trailing /
1197 (setq default-directory (file-name-as-directory path))))
1198 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
1199 ;; outlining support for ess modes
1203 (outline-minor-mode)
1204 (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
1205 (defun outline-level ()
1206 (cond ((looking-at "^##### ") 1)
1207 ((looking-at "^#### ") 2)
1208 ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
1211 (defun dla/ess-region-remote-eval (start end)
1212 "Evaluate region in a remote ESS instance"
1214 (shell-command-on-region start end "eval_r" (get-buffer-create "***essregionremoteeval***") nil nil nil)
1215 (kill-buffer "***essregionremoteeval***"))
1216 ;; Don't restore history or save workspace image
1217 '(inferior-R-args "--no-restore-history --no-save")
1222 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
1224 #+BEGIN_SRC emacs-lisp
1225 (use-package rainbow-mode
1226 ;; add ess to the x major mode
1227 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
1228 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
1233 #+BEGIN_SRC emacs-lisp
1234 (use-package yaml-mode
1235 ;; add ess to the x major mode
1236 :mode ("\\.\\(yaml|yml\\)\\'" . yaml-mode)
1241 #+BEGIN_SRC emacs-lisp
1242 (use-package poly-noweb
1247 (use-package poly-markdown
1253 :after (:all polymode poly-markdown poly-noweb)
1254 ; :mode ("\\.Snw" . poly-noweb+r-mode)
1255 ; :mode ("\\.Rnw" . poly-noweb+r-mode)
1256 ; :mode ("\\.Rmd" . poly-markdown+r-mode)
1258 (use-package polymode
1266 #+BEGIN_SRC emacs-lisp
1267 (use-package outline-magic)
1270 #+BEGIN_SRC emacs-lisp
1271 ;; change the outline mode prefix from C-c @ to C-c C-2
1272 (setq outline-minor-mode-prefix "C-c C-2")
1273 ;;(add-hook 'outline-minor-mode-hook
1274 ;; (lambda () (local-set-key (kbd "C-c C-2")
1275 ;; outline-mode-prefix-map)))
1279 #+BEGIN_SRC emacs-lisp
1280 (use-package writeroom-mode
1282 (defun my/writing-mode ()
1283 "Start my writing mode; enable visual-line-mode and auto-fill-mode"
1288 (visual-line-mode -1)
1290 (visual-fill-column-mode -1)
1292 (visual-line-mode 1)
1294 (visual-fill-column-mode 1)
1299 ** GhostText/Atomic Chrome
1300 #+BEGIN_SRC emacs-lisp
1301 (use-package atomic-chrome
1303 (ignore-errors (atomic-chrome-start-server))
1304 (setq atomic-chrome-buffer-open-style 'full)
1308 #+BEGIN_SRC emacs-lisp
1309 (use-package edit-server
1311 :commands edit-server-start
1312 :init (if after-init-time
1314 (add-hook 'after-init-hook
1315 #'(lambda() (edit-server-start))))
1316 :config (setq edit-server-new-frame-alist
1317 '((name . "Edit with Emacs FRAME")
1323 (menu-bar-lines . t)
1324 (window-system . x)))
1329 :ID: 6fcf218b-a762-4c37-9339-a8202ddeb544
1331 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
1332 #+BEGIN_SRC emacs-lisp
1333 (use-package multiple-cursors
1334 :bind* (("C-;" . mc/mark-all-dwim)
1335 ("C-<" . mc/mark-previous-like-this)
1336 ("C->" . mc/mark-next-like-this)
1337 ("C-S-c C-S-c" . mc/edit-lines))
1341 #+BEGIN_SRC emacs-lisp
1342 (use-package web-mode
1343 :load-path "/home/don/projects/web-mode/"
1344 :mode ("\\.\\(tx|tmpl\\)\\'" . web-mode)
1346 (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . web-mode))
1347 (setq web-mode-enable-engine-detection t)
1348 (setq web-mode-engines-alist
1349 '(("template-toolkit" . "\\.tmpl\\'")))
1352 ** Spamassassin Mode
1353 #+BEGIN_SRC emacs-lisp
1354 (use-package spamassassin-mode
1355 :commands spamassassin-mode
1360 #+BEGIN_SRC emacs-lisp
1361 (use-package password-store
1363 :commands password-store-edit password-store-generate
1367 #+BEGIN_SRC emacs-lisp
1371 ;; fix up css mode to not be silly
1372 ;; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
1373 (setq cssm-indent-level 4)
1374 (setq cssm-newline-before-closing-bracket t)
1375 (setq cssm-indent-function #'cssm-c-style-indenter)
1376 (setq cssm-mirror-mode nil))
1379 #+BEGIN_SRC emacs-lisp
1381 :diminish abbrev-mode
1383 ;; load abbreviations from
1384 (setq abbrev-file-name
1385 "~/.emacs_abbrev_def")
1387 ;; read the abbrev file if it exists
1388 (if (file-exists-p abbrev-file-name)
1389 (quietly-read-abbrev-file))
1391 ;; for now, use abbrev mode everywhere
1392 (setq default-abbrev-mode t))
1395 ** Python Programming
1396 #+BEGIN_SRC emacs-lisp
1397 (use-package python-mode
1399 (python-mode . pyenv-mode)
1400 (python-mode . flycheck-mode)
1401 (python-mode . company-mode)
1402 (python-mode . blacken-mode)
1403 (python-mode . yas-minor-mode)
1408 (use-package blacken
1410 (setq-default blacken-fast-unsafe t)
1411 (setq-default blacken-line-length 80)
1422 #+BEGIN_SRC emacs-lisp
1423 (use-package company-jedi
1425 :hook (python-mode . (add-to-list 'company-backends 'company-jedi))
1426 :hook (python-mode . 'jedi:setup)
1428 (setq jedi:complete-on-dot t)
1432 #+begin_src emacs-lisp :tangle yes
1433 (use-package python-black
1437 *** Sphinx Documentation
1438 #+begin_src emacs-lisp :tangle yes
1439 (use-package numpydoc
1442 :bind (:map python-mode-map
1443 ("C-c C-n" . numpydoc-generate)))
1444 (use-package sphinx-doc
1448 (setq sphinx-doc-include-types t)
1452 #+BEGIN_SRC emacs-lisp
1453 (use-package go-mode
1460 #+BEGIN_SRC emacs-lisp
1461 (use-package expand-region
1462 :bind (("C-=" . 'er/expand-region))
1467 #+BEGIN_SRC emacs-lisp
1468 (use-package dockerfile-mode
1474 #+BEGIN_SRC emacs-lisp
1475 (use-package beancount
1476 :load-path "~/lib/emacs_el/beancount-mode/"
1478 :mode "\\.beancount\\'"
1485 #+BEGIN_SRC emacs-lisp
1486 (use-package message
1488 :diminish (message "✉")
1489 :mode ("muttng-[a-z0-9]+-[0-9]+-" . message-mode)
1490 :mode ("mutt-[a-z0-9]+-[0-9]+-" . message-mode)
1491 :hook 'my/message-mode-settings
1492 :hook 'turn-on-flyspell
1493 :bind (:map message-mode-map
1494 ("C-c C-a" . my/post-attach-file))
1495 :delight (message-mode "✉")
1497 (defun my/message-mode-settings ()
1498 (font-lock-add-keywords nil
1499 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1500 (0 'message-multiply-quoted-text-face))
1501 ("^[ \t]*>[ \t]*>.*$"
1502 (0 'message-double-quoted-text-face))))
1505 (defun my/post-attach-file ()
1506 "Prompt for an attachment."
1508 (let ((file (read-file-name "Attach file: " nil nil t nil)))
1509 (my/header-attach-file file "")))
1511 (defun my/header-attach-file (file description)
1512 "Attach a FILE to the current message (works with Mutt).
1513 Argument DESCRIPTION MIME description."
1514 (interactive "fAttach file: \nsDescription: ")
1515 (when (> (length file) 0)
1520 (goto-char (point-min))
1521 (search-forward-regexp "^$")
1522 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1524 (message (concat "Attached '" file "'."))
1525 (setq post-has-attachment t))))))
1527 (setq mail-yank-prefix "> ")
1528 (setq mail-header-separator "") ; fix broken header detection
1532 #+BEGIN_SRC emacs-lisp
1533 (use-package muttrc-mode
1540 ** Reverting buffers
1541 #+BEGIN_SRC emacs-lisp
1542 (use-package autorevert
1543 :diminish auto-revert-mode
1545 (setq global-auto-revert-non-file-buffers t
1546 global-auto-revert-ignore-modes '(pdf-view-mode)
1547 auto-revert-verbose nil)
1548 (global-auto-revert-mode 1))
1551 ** Use-package and load things
1552 #+BEGIN_SRC emacs-lisp
1555 :delight (org-mode "ø")
1556 :mode ("\\.\\(org\\|org_archive\\|txt\\)\\'" . org-mode)
1557 :bind (("C-c l" . org-store-link)
1558 ("C-c a" . org-agenda)
1559 ("C-c b" . org-iswitchb))
1561 ** Agenda Configuration
1562 #+BEGIN_SRC emacs-lisp
1564 (setq-default org-log-done 'time)
1565 (setq-default org-agenda-ndays 5)
1567 (setq org-agenda-sticky t)
1568 (defun dla/show-org-agenda ()
1573 (and (string-match-p
1581 (buffer-name agendabuffer))
1583 (delete-other-windows))
1585 ;; agenda configuration
1586 ;; Do not dim blocked tasks
1587 (setq org-agenda-dim-blocked-tasks nil)
1588 (setq org-agenda-inhibit-startup t)
1589 (setq org-agenda-use-tag-inheritance nil)
1591 ;; Compact the block agenda view
1592 (setq org-agenda-compact-blocks t)
1594 ;; Custom agenda command definitions
1595 (setq org-agenda-custom-commands
1596 (quote (("N" "Notes" tags "NOTE"
1597 ((org-agenda-overriding-header "Notes")
1598 (org-tags-match-list-sublevels t)))
1599 ("h" "Habits" tags-todo "STYLE=\"habit\""
1600 ((org-agenda-overriding-header "Habits")
1601 (org-agenda-sorting-strategy
1602 '(todo-state-down effort-up category-keep))))
1606 ((org-agenda-overriding-header "Tasks to Refile")
1607 (org-tags-match-list-sublevels nil)))
1608 (tags-todo "-CANCELLED/!"
1609 ((org-agenda-overriding-header "Stuck Projects")
1610 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
1611 (org-agenda-sorting-strategy
1613 (tags-todo "-HOLD-CANCELLED/!"
1614 ((org-agenda-overriding-header "Projects")
1615 (org-agenda-skip-function 'bh/skip-non-projects)
1616 (org-tags-match-list-sublevels 'indented)
1617 (org-agenda-sorting-strategy
1619 (tags-todo "-CANCELLED/!NEXT"
1620 ((org-agenda-overriding-header (concat "Project Next Tasks"
1621 (if bh/hide-scheduled-and-waiting-next-tasks
1623 " (including WAITING and SCHEDULED tasks)")))
1624 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1625 (org-tags-match-list-sublevels t)
1626 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1627 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1628 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1629 (org-agenda-sorting-strategy
1630 '(todo-state-down effort-up category-keep))))
1631 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1632 ((org-agenda-overriding-header (concat "Project Subtasks"
1633 (if bh/hide-scheduled-and-waiting-next-tasks
1635 " (including WAITING and SCHEDULED tasks)")))
1636 (org-agenda-skip-function 'bh/skip-non-project-tasks)
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
1642 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1643 ((org-agenda-overriding-header (concat "Standalone Tasks"
1644 (if bh/hide-scheduled-and-waiting-next-tasks
1646 " (including WAITING and SCHEDULED tasks)")))
1647 (org-agenda-skip-function 'bh/skip-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 "-CANCELLED+WAITING|HOLD/!"
1654 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
1655 (org-agenda-skip-function 'bh/skip-stuck-projects)
1656 (org-tags-match-list-sublevels nil)
1657 (org-agenda-todo-ignore-scheduled t)
1658 (org-agenda-todo-ignore-deadlines t)))
1660 ((org-agenda-overriding-header "Tasks to Archive")
1661 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1662 (org-tags-match-list-sublevels nil))))
1665 ; org mode agenda files
1666 (setq org-agenda-files
1668 (file-expand-wildcards "~/projects/org-notes/*.org")
1669 (file-expand-wildcards "~/org-mode/from-mobile.org")
1670 (file-expand-wildcards "~/org-notes-*/*.org")
1673 (setq my/org-refile-file
1675 (lambda (file) (string-match-p (regexp-quote "/refile.org") file))
1678 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
1679 (set-register ?r (cons 'file my/org-refile-file))
1680 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
1681 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
1682 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
1683 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
1684 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
1685 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
1686 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
1687 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
1688 (defun org-agenda-timeline-all (&optional arg)
1691 (dolist (org-agenda-file org-agenda-files)
1692 (insert-file-contents org-agenda-file nil)
1693 (goto-char (point-max))
1695 (write-file "/tmp/timeline.org")
1696 (org-agenda arg "L")))
1697 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
1701 #+BEGIN_SRC emacs-lisp
1702 (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")))
1703 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
1705 (setq org-default-notes-file "~/projects/org-notes/notes.org")
1706 (setq org-id-link-to-org-use-id 'use-existing)
1708 ** Capture Templates
1709 #+BEGIN_SRC emacs-lisp
1710 (setq org-capture-templates ;; mail-specific note template, identified by "m"
1711 `(("m" "Mail" entry (file my/org-refile-file)
1712 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
1713 ("t" "todo" entry (file my/org-refile-file)
1714 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
1715 ("r" "respond" entry (file my/org-refile-file)
1716 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
1717 ("n" "note" entry (file my/org-refile-file)
1718 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
1719 ("s" "schedule" entry (file my/org-refile-file)
1720 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
1721 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
1722 "* %?\n%U\n" :clock-in t :clock-resume t)
1723 ("w" "org-protocol" entry (file my/org-refile-file)
1724 "* TODO Review %c\n%U\n" :immediate-finish t)
1725 ("M" "Meeting" entry (file my/org-refile-file)
1726 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
1727 ("S" "Seminar" entry (file my/org-refile-file)
1728 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
1729 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
1730 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
1731 ("p" "Phone call" entry (file my/org-refile-file)
1732 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
1733 ("J" "job" entry (file+olp "~/projects/org-notes/notes.org"
1735 ,(format-time-string "Positions %Y"))
1736 "* TODO Apply for %? :job:\nSCHEDULED: <%<%Y-%m-%d>>\n%U\n%x\n" :clock-in t :clock-resume t)
1737 ("h" "Habit" entry (file my/org-refile-file)
1738 "* 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")
1742 ;; Remove empty LOGBOOK drawers on clock out
1743 (defun bh/remove-empty-drawer-on-clock-out ()
1746 (beginning-of-line 0)
1747 (org-remove-empty-drawer-at (point))))
1749 (defun my/org-add-id ()
1752 (if (org-current-level)
1761 ** Org mode key bindings
1762 #+BEGIN_SRC emacs-lisp
1763 ;; org mode configuration from http://doc.norang.ca/org-mode.html
1764 ;; Custom Key Bindings
1765 :bind* (("<f9> a" . org-agenda)
1766 ("<f9> I" . bh/punch-in)
1767 ("<f9> O" . bh/punch-out)
1768 ("<f9> SPC" . bh/clock-in-last-task)
1769 ("<f12>" . dla/show-org-agenda)
1770 ;; ("<f5>" . bh/org-todo)
1771 ("<S-f5>" . bh/widen)
1772 ("<f7>" . bh/set-truncate-lines)
1773 ("<f8>" . org-cycle-agenda-files)
1774 ("<f9> <f9>" . dla/show-org-agenda)
1776 ("<f9> c" . calendar)
1777 ("<f9> f" . boxquote-insert-file)
1778 ("<f9> h" . bh/hide-other)
1779 ("<f9> n" . bh/toggle-next-task-display)
1782 ("<f9> r" . boxquote-region)
1783 ("<f9> s" . bh/switch-to-scratch)
1785 ("<f9> t" . bh/insert-inactive-timestamp)
1786 ("<f9> T" . bh/toggle-insert-inactive-timestamp)
1788 ("<f9> v" . visible-mode)
1789 ("<f9> l" . org-toggle-link-display)
1790 ("<f9> SPC" . bh/clock-in-last-task)
1791 ("C-<f9>" . previous-buffer)
1792 ("M-<f9>" . org-toggle-inline-images)
1793 ("C-x n r" . narrow-to-region)
1794 ("C-<f10>" . next-buffer)
1795 ("<f11>" . org-clock-goto)
1796 ("C-<f11>" . org-clock-in)
1797 ("C-s-<f12>" . bh/save-then-publish)
1798 ("C-c c" . org-capture))
1801 ** Utility Functions
1802 #+BEGIN_SRC emacs-lisp
1803 (defun bh/hide-other ()
1806 (org-back-to-heading 'invisible-ok)
1807 (outline-hide-other)
1812 (defun bh/set-truncate-lines ()
1813 "Toggle value of truncate-lines and refresh window display."
1815 (setq truncate-lines (not truncate-lines))
1816 ;; now refresh window display (an idiom from simple.el):
1818 (set-window-start (selected-window)
1819 (window-start (selected-window)))))
1821 (defun bh/switch-to-scratch ()
1823 (switch-to-buffer "*scratch*"))
1825 (setq org-use-fast-todo-selection t)
1826 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1828 ; create function to create headlines in file. This comes from
1829 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
1830 (defun my/org-add-ids-to-headlines-in-file ()
1831 "Add ID properties to all headlines in the current file which
1832 do not already have one."
1834 (org-map-entries 'org-id-get-create))
1835 (defun dla/org-update-ids-to-headlines-in-file ()
1836 "Add or replace ID properties to all headlines in the current file
1837 (or narrowed region)."
1839 (org-map-entries '(lambda () (org-id-get-create t))))
1840 ; if we wanted to do this to every buffer, do the following:
1841 ; (add-hook 'org-mode-hook
1843 ; (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
1846 #+BEGIN_SRC emacs-lisp
1847 (use-package find-lisp
1849 (setq org-agenda-text-search-extra-files
1850 (append '(agenda-archives)
1851 (find-lisp-find-files "~/projects/org-notes" "\.org$")
1852 (find-lisp-find-files "~/projects/org-notes" "\.org_archive$")
1856 #+BEGIN_SRC emacs-lisp
1857 (setq org-todo-keywords
1858 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
1859 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
1861 (setq org-todo-keyword-faces
1862 (quote (("TODO" :foreground "red" :weight bold)
1863 ("NEXT" :foreground "blue" :weight bold)
1864 ("DONE" :foreground "forest green" :weight bold)
1865 ("WAITING" :foreground "orange" :weight bold)
1866 ("HOLD" :foreground "magenta" :weight bold)
1867 ("CANCELLED" :foreground "forest green" :weight bold)
1868 ("MEETING" :foreground "forest green" :weight bold)
1869 ("PHONE" :foreground "forest green" :weight bold))))
1871 (setq org-todo-state-tags-triggers
1872 (quote (("CANCELLED" ("CANCELLED" . t))
1873 ("WAITING" ("WAITING" . t))
1874 ("HOLD" ("WAITING") ("HOLD" . t))
1875 (done ("WAITING") ("HOLD"))
1876 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1877 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1878 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1882 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1883 ; add ids on creation of nodes
1884 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
1887 ; resolve clocks after 10 minutes of idle; use xprintidle
1888 ; (setq org-clock-idle-time 10)
1889 ; (setq org-clock-x11idle-program-name "xprintidle")
1891 ; this is from http://doc.norang.ca/org-mode.html#Capture
1892 ; use C-M-r for org mode capture
1893 (global-set-key (kbd "C-M-r") 'org-capture)
1895 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1896 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1897 (org-agenda-files :maxlevel . 9))))
1899 ; Use full outline paths for refile targets - we file directly with IDO
1900 (setq org-refile-use-outline-path t)
1902 ; Targets complete directly with IDO
1903 (setq org-outline-path-complete-in-steps nil)
1905 ; Allow refile to create parent tasks with confirmation
1906 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1908 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
1909 ; (setq org-completion-use-ido t)
1910 ; (setq ido-everywhere t)
1911 ; (setq ido-max-directory-size 100000)
1912 ; (ido-mode (quote both))
1913 ; ; Use the current window when visiting files and buffers with ido
1914 ; (setq ido-default-file-method 'selected-window)
1915 ; (setq ido-default-buffer-method 'selected-window)
1916 ; ; Use the current window for indirect buffer display
1917 ; (setq org-indirect-buffer-display 'current-window)
1920 ;;;; Refile settings
1921 ; Exclude DONE state tasks from refile targets
1922 (defun bh/verify-refile-target ()
1923 "Exclude todo keywords with a done state from refile targets"
1924 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
1926 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1928 ;; ensure that emacsclient will show just the note to be edited when invoked
1929 ;; from Mutt, and that it will shut down emacsclient once finished;
1930 ;; fallback to legacy behavior when not invoked via org-protocol.
1931 (require 'org-protocol)
1932 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
1933 (setq my-org-protocol-flag nil)
1934 (defadvice org-capture-finalize (after delete-frame-at-end activate)
1935 "Delete frame at remember finalization"
1936 (progn (if my-org-protocol-flag (delete-frame))
1937 (setq my-org-protocol-flag nil)))
1938 (defadvice org-capture-refile (around delete-frame-after-refile activate)
1939 "Delete frame at remember refile"
1940 (if my-org-protocol-flag
1942 (setq my-org-protocol-flag nil)
1947 (defadvice org-capture-kill (after delete-frame-at-end activate)
1948 "Delete frame at remember abort"
1949 (progn (if my-org-protocol-flag (delete-frame))
1950 (setq my-org-protocol-flag nil)))
1951 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
1952 (setq my-org-protocol-flag t))
1954 (defadvice org-insert-todo-heading (after dla/create-id activate)
1955 (unless (org-in-item-p)
1961 (add-to-list 'org-modules 'org-habit)
1963 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
1964 (defun open-mail-in-mutt (message)
1965 "Open a mail message in Mutt, using an external terminal.
1967 Message can be specified either by a path pointing inside a
1968 Maildir, or by Message-ID."
1969 (interactive "MPath or Message-ID: ")
1971 (format "faf xterm -e \"%s %s\""
1972 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
1974 ;; add support for "mutt:ID" links
1975 (org-add-link-type "mutt" 'open-mail-in-mutt)
1977 (defun my-org-mode-setup ()
1978 ; (load-library "reftex")
1979 (and (buffer-file-name)
1980 (file-exists-p (buffer-file-name))
1982 ; (reftex-parse-all)
1983 (reftex-set-cite-format
1984 '((?b . "[[bib:%l][%l-bib]]")
1985 (?n . "[[notes:%l][%l-notes]]")
1987 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
1989 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
1990 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
1991 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
1992 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
1994 (add-hook 'org-mode-hook 'my-org-mode-setup)
1996 (defun org-mode-reftex-search ()
1998 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
2000 (defun open-research-paper (bibtexkey)
2001 "Open a paper by bibtex key"
2002 (interactive "bibtex key: ")
2005 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
2006 (org-add-link-type "papers" 'open-research-paper)
2007 (defun open-research-paper-pdf (bibtexkey)
2008 "Open a paper pdf by bibtex key"
2009 (interactive "bibtex key: ")
2011 (format "%s -p evince_annot %s"
2012 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
2013 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
2015 (add-to-list 'org-link-abbrev-alist
2017 "~/projects/research/paper_notes.org::#%s"))
2019 ; I pretty much always want hiearchical checkboxes
2020 (setq org-hierachical-checkbox-statistics nil)
2022 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
2023 (add-to-list 'org-structure-template-alist
2024 '("E" "\\begin{equation}\n?\n\\end{equation}"))
2027 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
2028 (defun my-rtcite-export-handler (path desc format)
2029 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
2030 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
2031 (match-string 1 path)))
2032 (path (substring path 0 (match-beginning 0))))
2033 (cond ((eq format 'latex)
2035 (equal 0 (search "rtcite:" desc)))
2036 (format "\\cite{%s}" search)
2037 (format "\\cite[%s]{%s}" desc search))))))
2039 (org-add-link-type "rtcite"
2041 'my-rtcite-export-handler)
2045 ** Org Mobile Configuration
2046 #+BEGIN_SRC emacs-lisp
2047 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
2048 (when (string= system-name "linnode")
2049 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
2050 (setq-default org-directory "/home/don/org-mode/")
2051 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
2055 #+BEGIN_SRC emacs-lisp
2056 ;; org mode ical export
2057 (setq org-icalendar-timezone "America/Los_Angeles")
2058 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
2059 ;; we already add the id manually
2060 (setq org-icalendar-store-UID t)
2063 ** General Org Babel Configuration
2064 #+BEGIN_SRC emacs-lisp
2065 ;; org babel support
2066 (org-babel-do-load-languages
2067 'org-babel-load-languages
2074 ;; set the right path to ditaa.jar
2075 (setq org-ditaa-jar-path "/usr/share/ditaa/ditaa.jar")
2076 ;; use graphviz-dot for dot things
2077 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
2078 ;; do not indent begin_src blocks
2079 (setq org-edit-src-content-indentation 0)
2080 ;; org-babel-by-backend
2081 (defmacro org-babel-by-backend (&rest body)
2082 `(case (if (boundp 'backend)
2083 (org-export-backend-name backend)
2086 (defun my/fix-inline-images ()
2087 (when org-inline-image-overlays
2088 (org-redisplay-inline-images)))
2090 (add-hook 'org-babel-after-execute-hook
2091 'my/fix-inline-images)
2094 ** LaTeX configuration
2096 :ID: 7135ba17-6a50-4eed-84ca-b90afa5b12f8
2098 #+BEGIN_SRC emacs-lisp
2099 (use-package ox-extra
2101 (ox-extras-activate '(ignore-headlines)))
2103 (add-to-list 'org-latex-classes
2105 "\\documentclass[11pt,oneside,article]{memoir}\n"
2106 ("\\section{%s}" . "\\section*{%s}")
2107 ("\\subsection{%s}" . "\\subsection*{%s}")
2108 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2109 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2110 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2112 (setq org-beamer-outline-frame-options "")
2113 (add-to-list 'org-latex-classes
2115 "\\documentclass[ignorenonframetext]{beamer}
2116 [NO-DEFAULT-PACKAGES]
2119 ("\\section{%s}" . "\\section*{%s}")
2120 ("\\subsection{%s}" . "\\subsection*{%s}")
2121 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2122 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2123 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2125 (add-to-list 'org-latex-classes
2127 "\\documentclass[11pt,oneside]{memoir}\n"
2128 ("\\chapter{%s}" . "\\chapter*{%s}")
2129 ("\\section{%s}" . "\\section*{%s}")
2130 ("\\subsection{%s}" . "\\subsection*{%s}")
2131 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
2133 (add-to-list 'org-latex-classes
2135 "\\documentclass[11pt]{letter}
2136 [NO-DEFAULT-PACKAGES]
2139 ("\\section{%s}" . "\\section*{%s}")
2140 ("\\subsection{%s}" . "\\subsection*{%s}")
2141 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2142 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2143 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2145 (add-to-list 'org-latex-classes
2147 "\\documentclass{dlacv}
2148 [NO-DEFAULT-PACKAGES]
2151 ("\\section{%s}" . "\\section*{%s}")
2152 ("\\subsection{%s}" . "\\subsection*{%s}")
2153 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2154 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2155 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2158 (add-to-list 'org-latex-classes
2160 "\\documentclass{dlaresume}
2161 [NO-DEFAULT-PACKAGES]
2164 ("\\section{%s}" . "\\section*{%s}")
2165 ("\\subsection{%s}" . "\\subsection*{%s}")
2166 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2167 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2168 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2171 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
2172 ;; but adapted to use latexmk 4.22 or higher.
2173 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
2175 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
2176 (setq org-latex-default-packages-alist
2178 ("" "unicode-math" t)
2180 (setq org-latex-packages-alist
2187 ("" "longtable" nil)
2190 ;; make equations larger
2191 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
2193 (defun org-create-formula--latex-header ()
2194 "Return LaTeX header appropriate for previewing a LaTeX snippet."
2195 (let ((info (org-combine-plists (org-export--get-global-options
2196 (org-export-get-backend 'latex))
2197 (org-export--get-inbuffer-options
2198 (org-export-get-backend 'latex)))))
2199 (org-latex-guess-babel-language
2200 (org-latex-guess-inputenc
2201 (org-splice-latex-header
2202 org-format-latex-header
2203 org-latex-default-packages-alist
2205 (plist-get info :latex-header)))
2209 ; support ignoring headers in org mode export to latex
2210 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
2211 (defadvice org-latex-headline (around my-latex-skip-headlines
2212 (headline contents info) activate)
2213 (if (member "ignoreheading" (org-element-property :tags headline))
2214 (setq ad-return-value contents)
2217 ;; keep latex logfiles
2219 (setq org-latex-remove-logfiles nil)
2221 ;; Resume clocking task when emacs is restarted
2222 (org-clock-persistence-insinuate)
2224 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
2225 (setq org-clock-history-length 23)
2226 ;; Resume clocking task on clock-in if the clock is open
2227 (setq org-clock-in-resume t)
2228 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
2229 ;; there are things like PHONE calls
2230 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
2231 ;; Separate drawers for clocking and logs
2232 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
2233 ;; Save clock data and state changes and notes in the LOGBOOK drawer
2234 (setq org-clock-into-drawer t)
2235 (setq org-log-into-drawer t)
2236 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
2237 (setq org-clock-out-remove-zero-time-clocks t)
2238 ;; Clock out when moving task to a done state
2239 (setq org-clock-out-when-done t)
2240 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
2241 (setq org-clock-persist t)
2242 ;; Do not prompt to resume an active clock
2243 (setq org-clock-persist-query-resume nil)
2244 ;; Enable auto clock resolution for finding open clocks
2245 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
2246 ;; Include current clocking task in clock reports
2247 (setq org-clock-report-include-clocking-task t)
2249 ;; the cache seems to be broken
2250 (setq org-element-use-cache nil)
2252 (defvar bh/keep-clock-running nil)
2254 (defun bh/is-task-p ()
2255 "Any task with a todo keyword and no subtask"
2259 (subtree-end (save-excursion (org-end-of-subtree t)))
2260 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2263 (while (and (not has-subtask)
2264 (< (point) subtree-end)
2265 (re-search-forward "^\*+ " subtree-end t))
2266 (when (member (org-get-todo-state) org-todo-keywords-1)
2267 (setq has-subtask t))))
2268 (and is-a-task (not has-subtask)))))
2269 (defun bh/is-project-p ()
2270 "Any task with a todo keyword subtask"
2274 (subtree-end (save-excursion (org-end-of-subtree t)))
2275 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2278 (while (and (not has-subtask)
2279 (< (point) subtree-end)
2280 (re-search-forward "^\*+ " subtree-end t))
2281 (when (member (org-get-todo-state) org-todo-keywords-1)
2282 (setq has-subtask t))))
2283 (and is-a-task has-subtask))))
2285 (defun bh/is-subproject-p ()
2286 "Any task which is a subtask of another project"
2287 (let ((is-subproject)
2288 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2290 (while (and (not is-subproject) (org-up-heading-safe))
2291 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
2292 (setq is-subproject t))))
2293 (and is-a-task is-subproject)))
2296 (defun bh/clock-in-to-next (kw)
2297 "Switch a task from TODO to NEXT when clocking in.
2298 Skips capture tasks, projects, and subprojects.
2299 Switch projects and subprojects from NEXT back to TODO"
2300 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
2302 ((and (member (org-get-todo-state) (list "TODO"))
2305 ((and (member (org-get-todo-state) (list "NEXT"))
2309 (defun bh/punch-in (arg)
2310 "Start continuous clocking and set the default task to the
2311 selected task. If no task is selected set the Organization task
2312 as the default task."
2314 (setq bh/keep-clock-running t)
2315 (if (equal major-mode 'org-agenda-mode)
2317 ;; We're in the agenda
2319 (let* ((marker (org-get-at-bol 'org-hd-marker))
2320 (tags (org-with-point-at marker (org-get-tags-at))))
2321 (if (and (eq arg 4) tags)
2322 (org-agenda-clock-in '(16))
2323 (bh/clock-in-organization-task-as-default)))
2325 ;; We are not in the agenda
2329 ; Find the tags on the current task
2330 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
2331 (org-clock-in '(16))
2332 (bh/clock-in-organization-task-as-default)))))
2334 (defun bh/punch-out ()
2336 (setq bh/keep-clock-running nil)
2337 (when (org-clock-is-active)
2339 (org-agenda-remove-restriction-lock))
2341 (defun bh/clock-in-default-task ()
2343 (org-with-point-at org-clock-default-task
2346 (defun bh/clock-in-parent-task ()
2347 "Move point to the parent (project) task if any and clock in"
2348 (let ((parent-task))
2352 (while (and (not parent-task) (org-up-heading-safe))
2353 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
2354 (setq parent-task (point))))
2356 (org-with-point-at parent-task
2358 (when bh/keep-clock-running
2359 (bh/clock-in-default-task)))))))
2361 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
2363 (defun bh/clock-in-organization-task-as-default ()
2365 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
2366 (org-clock-in '(16))))
2368 (defun bh/clock-out-maybe ()
2369 (when (and bh/keep-clock-running
2370 (not org-clock-clocking-in)
2371 (marker-buffer org-clock-default-task)
2372 (not org-clock-resolving-clocks-due-to-idleness))
2373 (bh/clock-in-parent-task)))
2375 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
2378 (defun bh/clock-in-task-by-id (id)
2379 "Clock in a task by id"
2380 (org-with-point-at (org-id-find id 'marker)
2381 (org-clock-in nil)))
2383 (defun bh/clock-in-last-task (arg)
2384 "Clock in the interrupted task if there is one
2385 Skip the default task and get the next one.
2386 A prefix arg forces clock in of the default task."
2388 (let ((clock-in-to-task
2390 ((eq arg 4) org-clock-default-task)
2391 ((and (org-clock-is-active)
2392 (equal org-clock-default-task (cadr org-clock-history)))
2393 (caddr org-clock-history))
2394 ((org-clock-is-active) (cadr org-clock-history))
2395 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
2396 (t (car org-clock-history)))))
2398 (org-with-point-at clock-in-to-task
2399 (org-clock-in nil))))
2402 (defun org-export-to-ods ()
2404 (let ((csv-file "data.csv"))
2405 (org-table-export csv-file "orgtbl-to-csv")
2406 (org-odt-convert csv-file "ods" 'open)))
2408 ; allow for zero-width-space to be a break in regexp too
2409 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
2410 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
2411 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
2413 ;; support inserting screen shots
2414 (defun my/org-insert-screenshot ()
2415 "Take a screenshot into a time stamped unique-named file in the
2416 same directory as the org-buffer and insert a link to this file."
2418 (defvar my/org-insert-screenshot/filename)
2419 (setq my/org-insert-screenshot/filename
2421 "Screenshot to insert: "
2423 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
2426 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
2427 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
2428 (org-display-inline-images))
2430 (defun my/fix-inline-images ()
2431 (when org-inline-image-overlays
2432 (org-redisplay-inline-images)))
2434 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
2436 ;; use xelatex to preview with imagemagick
2437 (add-to-list 'org-preview-latex-process-alist
2438 '(xelateximagemagick
2439 :programs ("xelatex" "convert")
2440 :description "pdf > png"
2441 :message "you need to install xelatex and imagemagick"
2443 :image-input-type "pdf"
2444 :image-output-type "png"
2445 :image-size-adjust (1.0 . 1.0)
2446 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
2447 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
2449 ;; use xelatex by default
2450 (setq org-preview-latex-default-process 'xelateximagemagick)
2452 ; from http://orgmode.org/Changes.html
2453 (defun my/org-repair-property-drawers ()
2454 "Fix properties drawers in current buffer.
2455 Ignore non Org buffers."
2457 (when (eq major-mode 'org-mode)
2458 (org-with-wide-buffer
2459 (goto-char (point-min))
2460 (let ((case-fold-search t)
2461 (inline-re (and (featurep 'org-inlinetask)
2462 (concat (org-inlinetask-outline-regexp)
2466 (unless (and inline-re (org-looking-at-p inline-re))
2468 (let ((end (save-excursion (outline-next-heading) (point))))
2470 (when (org-looking-at-p org-planning-line-re) (forward-line))
2471 (when (and (< (point) end)
2472 (not (org-looking-at-p org-property-drawer-re))
2474 (and (re-search-forward org-property-drawer-re end t)
2475 (eq (org-element-type
2476 (save-match-data (org-element-at-point)))
2478 (insert (delete-and-extract-region
2480 (min (1+ (match-end 0)) end)))
2481 (unless (bolp) (insert "\n"))))))))))))
2485 #+BEGIN_SRC emacs-lisp
2489 (use-package calfw-org
2492 (use-package org-gcal
2493 :if (file-readable-p "~/.hide/org_gcal.el")
2495 :config '((if (file-readable-p "~/.hide/org_gcal.el")
2496 (load-file "~/.hide/org_gcal.el"))
2501 #+BEGIN_SRC emacs-lisp
2505 ;; Show notification 10 minutes before event
2506 (setq appt-message-warning-time 10)
2507 ;; Disable multiple reminders
2508 (setq appt-display-interval appt-message-warning-time)
2509 (setq appt-display-mode-line nil)
2511 ;; add automatic reminders for appointments
2512 (defun my/org-agenda-to-appt ()
2514 (setq appt-time-msg-list nil)
2515 (org-agenda-to-appt))
2516 ;; add reminders when starting emacs
2517 (my/org-agenda-to-appt)
2518 ;; when rebuilding the agenda
2519 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
2520 "Pressing `r' on the agenda will also add appointments."
2521 (my/org-agenda-to-appt)
2523 ;; when saving all org buffers
2524 (defadvice org-save-all-org-buffers (after org-save-all-org-buffers-add-appts)
2525 "Re-add appts after saving all org buffers"
2526 (my/org-agenda-to-appt))
2527 ;; Display appointments as a window manager notification
2528 (setq appt-disp-window-function 'my/appt-display)
2529 (setq appt-delete-window-function (lambda () t))
2531 (setq my/appt-notification-app (concat (getenv "HOME") "/bin/appt_notification"))
2533 (defun my/appt-display (min-to-app new-time msg)
2534 (if (atom min-to-app)
2535 (start-process "my/appt-notification-app" nil my/appt-notification-app min-to-app msg)
2536 (dolist (i (number-sequence 0 (1- (length min-to-app))))
2537 (start-process "my/appt-notification-app" nil my/appt-notification-app
2538 (nth i min-to-app) (nth i msg))))
2544 ** outshine (outlining) integration
2545 #+BEGIN_SRC emacs-lisp
2546 (use-package outshine
2548 :hook (outline-minor-mode . outshine-hook-function)
2552 #+BEGIN_SRC emacs-lisp
2556 ** Home/End Begining/End of line
2557 #+BEGIN_SRC emacs-lisp
2558 (global-set-key [home] 'move-beginning-of-line)
2559 (global-set-key [end] 'move-end-of-line)
2562 #+BEGIN_SRC emacs-lisp
2563 (global-unset-key "\M-g")
2564 (global-set-key (kbd "M-g l") 'goto-line)
2568 #+BEGIN_SRC emacs-lisp
2569 (use-package debian-changelog-mode
2570 :mode "debian/changelog"
2572 (setq debian-changelog-mailing-address "don@debian.org")
2573 (setq debian-changelog-full-name "Don Armstrong"))
2575 * Misc (uncharacterized)
2576 #+BEGIN_SRC emacs-lisp
2577 (setq calendar-latitude 38.6)
2578 (setq calendar-longitude -121.5)
2579 (setq case-fold-search t)
2580 (setq confirm-kill-emacs (quote y-or-n-p))
2581 (setq cperl-lazy-help-time nil)
2583 ** Turn on fontlock and icomplete
2584 #+BEGIN_SRC emacs-lisp
2585 (global-font-lock-mode 1)
2587 (setq log-edit-keep-buffer t)
2589 ** Set mail User agent
2590 #+BEGIN_SRC emacs-lisp
2591 (setq mail-user-agent (quote sendmail-user-agent))
2592 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
2595 #+BEGIN_SRC emacs-lisp
2596 (setq ps-footer-font-size (quote (8 . 10)))
2597 (setq ps-header-font-size (quote (8 . 10)))
2598 (setq ps-header-title-font-size (quote (10 . 10)))
2599 (setq ps-line-number-color "blue")
2600 (setq ps-print-footer t)
2601 (setq ps-print-footer-frame nil)
2602 (setq ps-print-only-one-header t)
2604 ** Only single spacing on sentences
2605 #+BEGIN_SRC emacs-lisp
2606 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
2608 (setq sentence-end-double-space nil)
2609 ; enable matching parenthesis
2611 ** Display paren mode
2612 #+BEGIN_SRC emacs-lisp
2614 (setq show-paren-delay 0.2)
2618 #+BEGIN_SRC emacs-lisp
2619 (setq user-mail-address "don@donarmstrong.com")
2622 ** Use primary selection on unix machines
2623 #+BEGIN_SRC emacs-lisp
2624 ;; switch back to the old primary selection method
2625 (if (or (string-equal system-type "darwin")
2626 (string-equal system-type "windows")
2629 (setq x-select-enable-clipboard t)
2630 (setq x-select-enable-primary nil)
2633 (setq x-select-enable-clipboard nil)
2634 (setq x-select-enable-primary t)
2636 ; (setq mouse-drag-copy-region t)
2638 (fset 'perl-mode 'cperl-mode)
2639 ;;(load-file "cperl-mode.el")
2641 ;; tramp configuration
2642 (setq tramp-use-ssh-controlmaster-options nil)
2644 (setq-default c-indent-level 4)
2645 (setq-default c-brace-imaginary-offset 0)
2646 (setq-default c-brace-offset -4)
2647 (setq-default c-argdecl-indent 4)
2648 (setq-default c-label-offset -4)
2649 (setq-default c-continued-statement-offset 4)
2651 (setq-default indent-tabs-mode nil)
2652 (setq-default tab-width 4)
2655 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
2656 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
2657 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
2658 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
2659 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
2662 (defun insert-date ()
2663 "Insert date at point."
2665 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
2666 (global-set-key "\C-[d" 'insert-date)
2668 (defun unfill-paragraph (arg)
2669 "Pull this whole paragraph up onto one line."
2671 (let ((fill-column 10000))
2672 (fill-paragraph arg))
2675 (column-number-mode t)
2678 ** Desktop-save-mode
2679 If the envvar EMACS_SERVER_NAME is set, consider this a separate
2680 emacs, and use a different desktop file to restore history
2681 #+BEGIN_SRC emacs-lisp
2682 (use-package desktop
2685 (setq desktop-base-file-name
2686 (convert-standard-filename
2688 (or (getenv "EMACS_SERVER_NAME")
2692 (setq desktop-base-lock-name
2693 (convert-standard-filename
2694 (concat desktop-base-file-name
2696 (setq desktop-auto-save-timeout 60)
2697 (setq desktop-restore-eager 5)
2698 (setq desktop-lazy-verbose nil)
2699 (desktop-save-mode 1)
2703 ** Misc (Uncharacterized)
2704 #+BEGIN_SRC emacs-lisp
2705 '(icomplete-mode on)
2707 ;; custom-set-faces was added by Custom.
2708 ;; If you edit it by hand, you could mess it up, so be careful.
2709 ;; Your init file should contain only one such instance.
2710 ;; If there is more than one, they won't work right.
2711 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
2714 (put 'upcase-region 'disabled nil)
2715 (put 'downcase-region 'disabled nil)
2716 (put 'narrow-to-region 'disabled nil)
2718 ; (defun turn-on-flyspell ()
2719 ; "Force flyspell-mode on using a positive arg. For use in hooks."
2721 ; (flyspell-mode 1))
2724 ; Outline-minor-mode key map
2725 (define-prefix-command 'cm-map nil "Outline-")
2727 (define-key cm-map "q" 'outline-hide-sublevels) ; Hide everything but the top-level headings
2728 (define-key cm-map "t" 'outline-hide-body) ; Hide everything but headings (all body lines)
2729 (define-key cm-map "o" 'outline-hide-other) ; Hide other branches
2730 (define-key cm-map "c" 'outline-hide-entry) ; Hide this entry's body
2731 (define-key cm-map "l" 'outline-hide-leaves) ; Hide body lines in this entry and sub-entries
2732 (define-key cm-map "d" 'outline-hide-subtree) ; Hide everything in this entry and sub-entries
2734 (define-key cm-map "a" 'outline-show-all) ; Show (expand) everything
2735 (define-key cm-map "e" 'outline-show-entry) ; Show this heading's body
2736 (define-key cm-map "i" 'outline-show-children) ; Show this heading's immediate child sub-headings
2737 (define-key cm-map "k" 'outline-show-branches) ; Show all sub-headings under this heading
2738 (define-key cm-map "s" 'outline-show-subtree) ; Show (expand) everything in this heading & below
2740 (define-key cm-map "u" 'outline-up-heading) ; Up
2741 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
2742 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
2743 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
2744 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
2745 (global-set-key "\M-o" cm-map)
2746 ; fix up tmux xterm keys
2747 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
2748 (defun fix-up-tmux-keys ()
2749 "Fix up tmux xterm keys"
2752 (let ((x 2) (tkey ""))
2772 ;; ctrl + alt + shift
2774 (setq tkey "C-M-S-"))
2777 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
2778 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
2779 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
2780 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
2782 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
2784 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
2786 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
2788 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
2790 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2792 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2794 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
2796 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
2798 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
2800 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
2802 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
2804 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
2806 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
2808 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
2810 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
2812 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
2814 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
2816 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
2818 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
2820 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
2822 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
2824 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
2826 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
2828 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
2830 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
2832 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
2839 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
2841 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
2842 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
2843 (if (or (buffer-modified-p)
2844 (verify-visited-file-modtime)
2845 (< (* 8 1024 1024) (buffer-size))
2846 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
2848 (clear-visited-file-modtime)
2850 (ad-activate 'ask-user-about-supersession-threat)
2854 #+BEGIN_SRC emacs-lisp
2858 (or (getenv "EMACS_SERVER_NAME")
2860 (unless (server-running-p)
2861 (global-set-key "\C-xp" 'server-edit)
2868 #+BEGIN_SRC emacs-lisp
2869 (provide 'don-configuration)