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)
13 #+BEGIN_SRC emacs-lisp
14 (add-to-list 'exec-path '"/usr/local/bin")
15 (add-to-list 'exec-path '"~/bin/")
18 #+BEGIN_SRC emacs-lisp
20 (let ((default-directory "~/var/emacs/elpa"))
21 (normal-top-level-add-subdirs-to-load-path))
23 (add-to-list 'load-path '"~/lib/emacs_el/")
24 (let ((default-directory "~/lib/emacs_el/"))
25 (normal-top-level-add-subdirs-to-load-path))
26 (let ((default-directory "~/var/emacs/elpa"))
27 (normal-top-level-add-subdirs-to-load-path))
28 (setq package-user-dir "~/var/emacs/elpa")
30 * Initial startup stuff
31 ** Disable startup screen
32 #+BEGIN_SRC emacs-lisp
33 (setq inhibit-startup-screen t)
36 #+BEGIN_SRC emacs-lisp
37 ; (if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
38 (if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
39 (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
42 #+BEGIN_SRC emacs-lisp
43 (setq frame-resize-pixelwise t)
44 (add-to-list 'default-frame-alist '(fullscreen . maximixed))
47 ** package repositories and package manager
48 #+BEGIN_SRC emacs-lisp
49 (require 'use-package)
51 (add-to-list 'gnutls-trustfiles "/etc/ssl/ca-global/ca-certificates.crt")
52 (setq package-enable-at-startup nil)
53 (setq package--init-file-ensured t)
54 (setq package-user-dir "~/var/emacs/elpa")
55 (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
56 ("melpa" . "https://melpa.org/packages/")
57 ("org" . "http://orgmode.org/elpa/")))
58 (setq use-package-verbose (not (bound-and-true-p byte-compile-current-file)))
62 #+BEGIN_SRC emacs-lisp
65 :commands (paradox-upgrade-packages paradox-list-packages)
67 (setq paradox-execute-asynchronously t)
68 (setq paradox-github-token t) ; I don't want to be prompted about this integration
72 #+BEGIN_SRC emacs-lisp
73 ;; Set the custom file to /dev/null and don't bother to load it
74 (setq custom-file "/dev/null")
78 #+BEGIN_SRC emacs-lisp
79 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
80 ;; execute conditional code when loading libraries
81 (defmacro with-library (symbol &rest body)
82 `(when (require ,symbol nil t)
84 (put 'with-library 'lisp-indent-function 1)
88 ** Safe Local Variables
89 #+BEGIN_SRC emacs-lisp
90 (setq safe-local-variable-values
91 (quote ((auto-save-default)
93 (cperl-indent-level . 4)
95 (indent-tabs-mode . f)
96 (vcl-indent-level . 4)
100 #+BEGIN_SRC emacs-lisp
101 (setq global-mark-ring-max 128
105 (defun don/minibuffer-setup-hook ()
106 (setq gc-cons-threshold most-positive-fixnum))
108 (defun don/minibuffer-exit-hook ()
109 (setq gc-cons-threshold 1048576))
111 (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
112 (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
116 #+BEGIN_SRC emacs-lisp
117 (use-package spacemacs-common
118 :ensure spacemacs-theme
120 (load-theme 'spacemacs-dark t)
124 #+BEGIN_SRC emacs-lisp
125 (use-package hippie-exp
126 :bind* (("M-<SPC>" . hippie-expand))
130 #+BEGIN_SRC emacs-lisp
131 (use-package flyspell
133 :diminish flyspell-mode 🐝
135 (add-hook 'text-mode-hook 'turn-on-flyspell)
136 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
137 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
138 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
140 (setq ispell-program-name "ispell")
146 #+begin_src emacs-lisp :tangle yes
147 (use-package flycheck
150 :if (version<= "24.4" emacs-version)
151 :commands flycheck-mode
152 :hook ((prog-mode . flycheck-mode)
156 (use-package flycheck-tip
158 :commands 'flycheck-tip-cycle
160 :bind (:map flycheck-mode-map
161 ("C-c C-n" . flycheck-tip-cycle)))
163 (use-package flycheck-package
166 (use-package flycheck-checkpatch
168 :config (flycheck-checkpatch-setup)
169 :config (setq flycheck-checkers (delete 'checkpatch
171 :config (add-to-list 'flycheck-checkers 'checkpatch t))
175 #+begin_src emacs-lisp :tangle yes
181 #+BEGIN_SRC emacs-lisp
186 #+BEGIN_SRC emacs-lisp
187 (use-package eyebrowse
189 :diminish eyebrowse-mode
190 :init (setq eyebrowse-keymap-prefix (kbd "C-c e"))
192 (setq eyebrowse-wrap-around t)
195 (defun my/eyebrowse-new-window-config ()
199 ;; start at 1 run till 0
200 (let ((j (mod (+ i 1) 10)))
201 (when (and (not done)
202 (not (eyebrowse--window-config-present-p j)))
203 (eyebrowse-switch-to-window-config j)
204 (call-interactively 'eyebrowse-rename-window-config2 j)
209 ;; I don't use latex-preview-pane
210 ;; (require 'latex-preview-pane)
211 ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
212 ;; ;; latex-preview-pane uses window-parameters which are
213 ;; ;; not preserved by eyebrowse, so we close the preview
214 ;; ;; pane before switching, it will be regenerated when we
215 ;; ;; edit the TeX file.
216 ;; (when (lpp/window-containing-preview)
217 ;; (delete-window (lpp/window-containing-preview))))
219 ;; (add-to-list 'eyebrowse-pre-window-switch-hook
220 ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
222 ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
223 ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
224 ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
225 ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
226 ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
234 #+BEGIN_SRC emacs-lisp
235 (defun my/vsplit-last-buffer ()
236 "Split the window vertically and display the previous buffer."
238 (split-window-vertically)
240 (switch-to-next-buffer))
242 (defun my/hsplit-last-buffer ()
243 "Split the window horizontally and display the previous buffer."
245 (split-window-horizontally)
247 (switch-to-next-buffer))
249 (bind-key "C-x 2" 'my/vsplit-last-buffer)
250 (bind-key "C-x 3" 'my/hsplit-last-buffer)
252 (setq split-width-threshold 100)
253 (setq split-height-threshold 60)
255 (defun my/split-window-prefer-vertically (window)
256 "If there's only one window (excluding any possibly active
257 minibuffer), then split the current window horizontally."
258 (if (and (one-window-p t)
259 (not (active-minibuffer-window))
260 ( < (frame-width) (frame-height))
262 (let ((split-width-threshold nil))
263 (split-window-sensibly window))
264 (split-window-sensibly window)))
266 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
267 (setq window-combination-resize t)
270 *** Compilation window
272 If there is no compilation window, open one at the bottom, spanning
273 the complete width of the frame. Otherwise, reuse existing window. In
274 the former case, if there was no error the window closes
277 #+BEGIN_SRC emacs-lisp
278 (add-to-list 'display-buffer-alist
279 `(,(rx bos "*compilation*" eos)
280 (display-buffer-reuse-window
281 display-buffer-in-side-window)
282 (reusable-frames . visible)
284 (window-height . 0.4)))
287 #+BEGIN_SRC emacs-lisp
288 (defun my/compilation-exit-autoclose (status code msg)
289 ;; If M-x compile exists with a 0
290 (when (and (eq status 'exit) (zerop code))
291 ;; and delete the *compilation* window
292 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
293 (when (and (not (window-at-side-p compilation-window 'top))
294 (window-at-side-p compilation-window 'left)
295 (window-at-side-p compilation-window 'right))
296 (delete-window compilation-window))))
297 ;; Always return the anticipated result of compilation-exit-message-function
300 ;; Specify my function (maybe I should have done a lambda function)
301 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
304 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
305 value, the compilation buffer scrolls automatically to follow the
306 output. If the value is ~first-error~, scrolling stops when the first
307 error appears, leaving point at that error. For any other non-nil
308 value, scrolling continues until there is no more output.
310 #+BEGIN_SRC emacs-lisp
311 (setq compilation-scroll-output 'first-error)
314 ** Mode line cleaning
316 #+BEGIN_SRC emacs-lisp
317 (use-package diminish
322 #+BEGIN_SRC emacs-lisp
329 #+BEGIN_SRC emacs-lisp
331 :if (>= emacs-major-version 25)
333 :bind (("C-c C-<SPC>" . avy-goto-word-or-subword-1)
334 ("C-c j j" . avy-goto-word-or-subword-1)
335 ("M-g g" . avy-goto-line))
336 :config (progn (setq avy-background t))
339 *** Ace-link (jumping to links)
340 #+BEGIN_SRC emacs-lisp
341 (use-package ace-link
343 ; bind o in most modes
344 :config (ace-link-setup-default))
346 *** Jumping through edit points (goto-chg)
347 #+BEGIN_SRC emacs-lisp
348 (use-package goto-chg
350 :bind (("C-c j ," . goto-last-change)
351 ("C-c j ." . goto-last-change-reverse))
354 *** Jumping to bookmarks (visible bookmarks, bm)
355 #+BEGIN_SRC emacs-lisp
358 :bind (("C-c j b ." . bm-next)
359 ("C-c j b ," . bm-previous)
360 ("C-c j b SPC" . bm-toggle)))
365 #+BEGIN_SRC emacs-lisp
366 (use-package yasnippet
368 :diminish yas-minor-mode
371 (setq yas-verbosity 1)
372 (define-key yas-minor-mode-map (kbd "<tab>") nil)
373 (define-key yas-minor-mode-map (kbd "TAB") nil)
374 (define-key yas-minor-mode-map (kbd "<backtab>") nil)
375 (setq yas-snippet-dirs '("~/lib/emacs_el/snippets/"
376 "~/lib/emacs_el/yasnippet-snippets/snippets/"))
377 (add-to-list 'hippie-expand-try-functions-list
378 'yas-hippie-try-expand)
384 #+BEGIN_SRC emacs-lisp
385 (use-package auto-yasnippet
387 :bind (("H-w" . aya-create)
393 #+BEGIN_SRC emacs-lisp
396 :bind (("M-/" . company-complete))
398 (setq company-echo-delay 0 ; remove blinking
399 company-show-numbers t ; show numbers for easy selection
400 company-selection-wrap-around t
401 company-require-match nil
402 company-dabbrev-ignore-case t
403 company-dabbrev-ignore-invisible t
404 company-dabbrev-other-buffers t
405 company-dabbrev-downcase nil
406 company-dabbrev-code-everywhere t
407 company-tooltip-align-annotations t
408 company-minimum-prefix-length 1
409 company-global-modes '(not)
410 company-lighter-base "(C)")
411 (global-company-mode 1)
412 :bind (:map company-active-map
413 ("C-n" . company-select-next)
414 ("C-p" . company-select-previous)
415 ("M-?" . company-show-doc-buffer)
416 ("M-." . company-show-location)
421 #+BEGIN_SRC emacs-lisp
422 (use-package company-c-headers
425 (defun malb/ede-object-system-include-path ()
426 "Return the system include path for the current buffer."
428 (ede-system-include-path ede-object)))
430 (setq company-c-headers-path-system
431 #'malb/ede-object-system-include-path)
433 (add-to-list 'company-backends #'company-c-headers)))
436 #+BEGIN_SRC emacs-lisp
437 (use-package company-anaconda
439 :config (add-to-list 'company-backends #'company-anaconda))
442 #+BEGIN_SRC emacs-lisp
443 (use-package company-plsense
448 #+BEGIN_SRC emacs-lisp
449 (use-package company-math
452 #+BEGIN_SRC emacs-lisp
453 (use-package company-auctex
456 (defun company-auctex-labels (command &optional arg &rest ignored)
457 "company-auctex-labels backend"
458 (interactive (list 'interactive))
460 (interactive (company-begin-backend 'company-auctex-labels))
461 (prefix (company-auctex-prefix "\\\\.*ref{\\([^}]*\\)\\="))
462 (candidates (company-auctex-label-candidates arg))))
464 (add-to-list 'company-backends
465 '(company-auctex-macros
466 company-auctex-environments
467 company-math-symbols-unicode
468 company-math-symbols-latex))
470 (add-to-list 'company-backends #'company-auctex-labels)
471 (add-to-list 'company-backends #'company-auctex-bibs)
475 #+BEGIN_SRC emacs-lisp
476 (use-package company-bibtex
482 #+BEGIN_SRC emacs-lisp
483 (use-package company-shell
486 (setq company-shell-modes '(sh-mode shell-mode))
487 (add-to-list 'company-backends 'company-shell)))
492 Add YasSippet support for all company backends. ([[https://github.com/syl20bnr/spacemacs/pull/179][source]])
494 *Note:* Do this at the end of =company-mode= config.
496 #+BEGIN_SRC emacs-lisp
497 (defvar malb/company-mode/enable-yas t
498 "Enable yasnippet for all backends.")
500 (defun malb/company-mode/backend-with-yas (backend)
501 (if (or (not malb/company-mode/enable-yas)
503 (member 'company-yasnippet backend)))
505 (append (if (consp backend) backend (list backend))
506 '(:with company-yasnippet))))
508 (setq company-backends
509 (mapcar #'malb/company-mode/backend-with-yas company-backends))
514 Enable/disable company completion from ispell dictionaries ([[https://github.com/redguardtoo/emacs.d/blob/master/lisp/init-company.el][source]])
516 #+BEGIN_SRC emacs-lisp
517 (defun malb/toggle-company-ispell ()
520 ((member '(company-ispell :with company-yasnippet) company-backends)
521 (setq company-backends (delete '(company-ispell :with company-yasnippet) company-backends))
522 (add-to-list 'company-backends '(company-dabbrev :with company-yasnippet) t)
523 (message "company-ispell disabled"))
525 (setq company-backends (delete '(company-dabbrev :with company-yasnippet) company-backends))
526 (add-to-list 'company-backends '(company-ispell :with company-yasnippet) t)
527 (message "company-ispell enabled!"))))
529 (defun malb/company-ispell-setup ()
530 ;; @see https://github.com/company-mode/company-mode/issues/50
531 (when (boundp 'company-backends)
532 (make-local-variable 'company-backends)
533 (setq company-backends (delete '(company-dabbrev :with company-yasnippet) company-backends))
534 (add-to-list 'company-backends '(company-ispell :with company-yasnippet) t)
535 ;; https://github.com/redguardtoo/emacs.d/issues/473
536 (if (and (boundp 'ispell-alternate-dictionary)
537 ispell-alternate-dictionary)
538 (setq company-ispell-dictionary ispell-alternate-dictionary))))
543 1. =yas-expand= is run first and does what it has to, then it calls =malb/indent-fold-or-complete=.
545 2. This function then hopefully does what I want:
547 a. if a region is active, just indent
548 b. if we’re looking at a space after a non-whitespace character, we try some company-expansion
549 c. If =hs-minor-mode= or =outline-minor-mode= is active, try those next
550 d. otherwise call whatever would have been called otherwise.
552 ([[http://emacs.stackexchange.com/q/21182/8930][source]], [[http://emacs.stackexchange.com/q/7908/8930][source]])
554 #+BEGIN_SRC emacs-lisp
555 (defun malb/indent-fold-or-complete (&optional arg)
558 ;; if a region is active, indent
560 (indent-region (region-beginning)
562 ;; if the next char is space or eol, but prev char not whitespace
563 ((and (not (active-minibuffer-window))
566 (looking-back "[^[:space:]]")
567 (not (looking-back "^")))
569 (cond (company-mode (company-complete-common))
570 (auto-complete-mode (auto-complete))))
572 ;; no whitespace anywhere
573 ((and (not (active-minibuffer-window))
574 (looking-at "[^[:space:]]")
575 (looking-back "[^[:space:]]")
576 (not (looking-back "^")))
578 ((bound-and-true-p hs-minor-mode)
579 (save-excursion (end-of-line) (hs-toggle-hiding)))
580 ((bound-and-true-p outline-minor-mode)
581 (save-excursion (outline-cycle)))))
583 ;; by default just call whatever was bound
585 (let ((fn (or (if (current-local-map) (lookup-key (current-local-map) (kbd "TAB")))
586 'indent-for-tab-command)))
587 (if (not (called-interactively-p 'any))
589 (setq this-command fn)
590 (call-interactively fn))))))
592 (defun malb/toggle-fold ()
594 (cond ((eq major-mode 'org-mode)
595 (org-force-cycle-archived))
596 ((bound-and-true-p hs-minor-mode)
601 ((bound-and-true-p outline-minor-mode)
605 (bind-key "<tab>" #'malb/indent-fold-or-complete)
606 (bind-key "C-<tab>" #'malb/toggle-fold)
610 #+BEGIN_SRC emacs-lisp
612 (use-package tinyprocmail
613 :load-path "~/lib/emacs_el/tiny-tools/lisp/tiny"
614 :mode (".procmailrc" . turn-on-tinyprocmail-mode)
619 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
622 :bind (("C-x g" . magit-status)
623 ("C-x C-g" . magit-status))
625 ;; refine diffs always (hilight words)
626 (setq magit-diff-refine-hunk nil)
628 (use-package magit-annex
630 :load-path "~/lib/emacs_el/magit-annex/"
632 (use-package magit-vcsh
638 #+BEGIN_SRC emacs-lisp
639 (use-package cperl-mode
642 ;; Use c-mode for perl .xs files
643 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
644 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
645 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
646 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
647 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
650 cperl-auto-newline nil
651 cperl-auto-newline-after-colon nil
652 cperl-continued-statement-offset 4
653 cperl-brace-offset -1
654 cperl-continued-brace-offset 0
655 cperl-label-offset -4
656 cperl-highlight-variables-indiscriminately t
657 cperl-electric-lbrace-space nil
658 cperl-indent-parens-as-block nil
659 cperl-close-paren-offset -1
660 cperl-tab-always-indent t)
661 ;;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
666 #+BEGIN_SRC emacs-lisp
667 (use-package markdown-mode
669 :mode (("\\.md\\'" . markdown-mode)
670 ("\\.mdwn\\'" . markdown-mode)
671 ("README\\.md\\'" . gfm-mode)
674 (setq markdown-enable-math t)
675 (setq markdown-follow-wiki-link-on-enter nil)
676 (bind-key "M-." #'markdown-jump markdown-mode-map)
677 (add-hook 'markdown-mode-hook #'flyspell-mode)
678 (add-hook 'markdown-mode-hook #'outline-minor-mode)
679 (bind-key "C-<tab>" #'outline-cycle markdown-mode-map)
684 #+BEGIN_SRC emacs-lisp
685 ; load sql-indent when sql is loaded
686 (use-package sql-indent
690 :mode (("\\.sql\\'" . sql-mode))
694 #+BEGIN_SRC emacs-lisp
696 :commands ediff ediff3
699 ;; ediff configuration
700 ;; don't use the multi-window configuration
701 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
704 ** Do the Right Thing Indenting
705 Attempts to automatically identify the right indentation for a file
706 #+BEGIN_SRC emacs-lisp
707 (use-package dtrt-indent
711 ** VCL --editing varnish configuration files
712 #+BEGIN_SRC emacs-lisp
713 (use-package vcl-mode
720 #+BEGIN_SRC emacs-lisp
721 (defun malb/helm-omni (&rest arg)
722 ;; just in case someone decides to pass an argument, helm-omni won't fail.
724 (unless helm-source-buffers-list
725 (setq helm-source-buffers-list
726 (helm-make-source "Buffers" 'helm-source-buffers)))
730 (if (projectile-project-p)
731 '(helm-source-projectile-buffers-list
732 helm-source-buffers-list)
733 '(helm-source-buffers-list)) ;; list of all open buffers
735 `(((name . "Virtual Workspace")
736 (candidates . ,(--map (cons (eyebrowse-format-slot it) (car it))
737 (eyebrowse--get 'window-configs)))
738 (action . (lambda (candidate)
739 (eyebrowse-switch-to-window-config candidate)))))
741 (if (projectile-project-p)
742 '(helm-source-projectile-recentf-list
744 '(helm-source-recentf)) ;; all recent files
746 ;; always make some common files easily accessible
747 ;;'(((name . "Common Files")
748 ;; (candidates . malb/common-file-targets)
749 ;; (action . (("Open" . (lambda (x) (find-file (eval x))))))))
751 '(helm-source-files-in-current-dir
753 helm-source-bookmarks
754 helm-source-buffer-not-found ;; ask to create a buffer otherwise
756 "*Helm all the things*"))
760 :bind (("M-x" . helm-M-x)
761 ("C-x C-f" . helm-find-files)
762 ("C-x b" . helm-buffers-list) ; malb/helm-omni)
763 ("C-x C-b" . helm-buffers-list) ; malb/helm-omni)
764 ("C-c <SPC>" . helm-all-mark-rings))
766 (require 'helm-config)
767 (require 'helm-for-files)
768 (require 'helm-bookmark)
771 (define-key global-map [remap find-file] 'helm-find-files)
772 (define-key global-map [remap occur] 'helm-occur)
773 (define-key global-map [remap list-buffers] 'helm-buffers-list)
774 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
775 (unless (boundp 'completion-in-region-function)
776 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
777 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
778 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
783 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
785 #+BEGIN_SRC emacs-lisp
786 (use-package helm-flx
789 ;; these are helm configs, but they kind of fit here nicely
790 (setq helm-M-x-fuzzy-match t
791 helm-bookmark-show-location t
792 helm-buffers-fuzzy-matching t
793 helm-completion-in-region-fuzzy-match t
794 helm-file-cache-fuzzy-match t
795 helm-imenu-fuzzy-match t
796 helm-mode-fuzzy-match t
797 helm-locate-fuzzy-match nil
799 helm-recentf-fuzzy-match nil
800 helm-semantic-fuzzy-match t)
804 #+BEGIN_SRC emacs-lisp
806 ;;; stolen from https://github.com/malb/emacs.d/blob/master/malb.org
807 (defun malb/helm-swoop-pre-fill ()
808 (thing-at-point 'symbol))
809 (defvar malb/helm-swoop-ignore-major-mode "List of major modes to ignore for helm-swoop")
810 (setq malb/helm-swoop-ignore-major-mode '(dired-mode
811 paradox-menu-mode doc-view-mode pdf-view-mode
812 mu4e-headers-mode org-mode markdown-mode latex-mode
813 ein:notebook-multilang-mode))
815 (defun malb/swoop-or-search ()
817 (if (or (> (buffer-size) 1048576) ;; helm-swoop can be slow on big buffers
818 (memq major-mode malb/helm-swoop-ignore-major-mode))
822 (use-package helm-swoop
825 :bind (("C-c o" . helm-multi-swoop-org)
826 ("C-s" . malb/swoop-or-search)
827 ("C-M-s" . helm-multi-swoop-all))
830 (setq helm-swoop-pre-input-function #'malb/helm-swoop-pre-fill
831 helm-swoop-split-with-multiple-windows nil
832 helm-swoop-split-direction #'split-window-horizontally
833 helm-swoop-split-window-function 'helm-default-display-buffer
834 helm-swoop-speed-or-color t)
836 ;; https://emacs.stackexchange.com/questions/28790/helm-swoop-how-to-make-it-behave-more-like-isearch
837 (defun malb/helm-swoop-C-s ()
839 (if (boundp 'helm-swoop-pattern)
840 (if (equal helm-swoop-pattern "")
841 (previous-history-element 1)
845 (bind-key "C-S-s" #'helm-swoop-from-isearch isearch-mode-map)
846 (bind-key "C-S-s" #'helm-multi-swoop-all-from-helm-swoop helm-swoop-map)
847 (bind-key "C-r" #'helm-previous-line helm-swoop-map)
848 (bind-key "C-s" #'malb/helm-swoop-C-s helm-swoop-map)
849 (bind-key "C-r" #'helm-previous-line helm-multi-swoop-map)
850 (bind-key "C-s" #'malb/helm-swoop-C-s helm-multi-swoop-map))
855 #+BEGIN_SRC emacs-lisp
858 :config (setq helm-ag-base-command "ag --nocolor --nogroup"
859 helm-ag-command-option "--all-text"
860 helm-ag-insert-at-point 'symbol
861 helm-ag-fuzzy-match t
862 helm-ag-use-temp-buffer t
863 helm-ag-use-grep-ignore-list t
864 helm-ag-use-agignore t))
867 #+BEGIN_SRC emacs-lisp
868 (use-package helm-descbinds
870 :bind ("C-h b" . helm-descbinds)
871 :init (fset 'describe-bindings 'helm-descbinds))
875 #+BEGIN_SRC emacs-lisp
876 (use-package helm-c-yasnippet
878 :bind ("C-c h y" . helm-yas-complete)
880 (setq helm-yas-space-match-any-greedy t)))
883 #+BEGIN_SRC emacs-lisp
884 (use-package helm-org-rifle
887 (defun malb/helm-org-rifle-agenda-files (arg)
889 (let ((current-prefix-arg nil))
891 ((equal arg 4) (call-interactively #'helm-org-rifle-agenda-files nil))
892 ((equal arg 16) (helm-org-rifle-occur-agenda-files))
893 (t (helm-org-agenda-files-headings)))))))
896 This can be used to link things pretty quickly if necessary
897 #+BEGIN_SRC emacs-lisp
898 (use-package helm-google
900 :bind ("C-c h g" . helm-google)
902 (progn (add-to-list 'helm-google-actions
903 '("Copy URL" . (lambda (candidate)
905 (replace-regexp-in-string
906 "https://.*q=\\(.*\\)\&sa=.*"
912 (add-to-list 'helm-google-actions
913 '("Org Store Link" . (lambda (candidate)
914 (let ((title (car (split-string candidate "[\n]+")))
916 (replace-regexp-in-string
917 "https://.*q=\\(.*\\)\&sa=.*"
919 (push (list url title) org-stored-links))))
924 ** Projectile -- Project management
925 #+begin_src emacs-lisp
926 (use-package projectile
928 :bind (("<f5>" . projectile-compile-project)
929 ("<f6>" . next-error))
931 (use-package magit :ensure t)
932 (require 'helm-projectile)
935 (setq projectile-make-test-cmd "make check"
936 projectile-switch-project-action 'helm-projectile
937 projectile-mode-line '(:eval (format "»{%s}" (projectile-project-name))))
939 (projectile-global-mode)))
943 #+begin_src emacs-lisp
944 (use-package helm-projectile
947 (defvar malb/helm-source-file-not-found
948 (helm-build-dummy-source
953 'helm-projectile-sources-list
954 malb/helm-source-file-not-found t)
956 (helm-delete-action-from-source
957 "Grep in projects `C-s'"
958 helm-source-projectile-projects)
960 (helm-add-action-to-source
961 "Grep in projects `C-s'"
962 'helm-do-ag helm-source-projectile-projects 4)))
965 #+BEGIN_SRC emacs-lisp
968 :bind ("M-z" . avy-zap-up-to-char-dwim))
971 #+BEGIN_SRC emacs-lisp
973 :bind (("C-c 2" . my/hydra-orgmodes/body)
974 ("C-c @" . my/hydra-orgmodes/body)
975 ("C-c #" . my/hydra-outline/body)
976 ("C-c 3" . my/hydra-outline/body)
979 (defhydra my/hydra-orgmodes (:color blue :hint nil)
981 _n_: notes _c_: chaim _w_: wildman _o_: ool
982 _u_: uddin _s_: steve _r_: refile _f_: fh
983 _p_: read papers _R_: paper notes
988 ("n" (find-file "~/projects/org-notes/notes.org"))
989 ("c" (find-file "~/projects/org-notes/chaim.org"))
990 ("w" (find-file "~/projects/org-notes/wildman.org"))
991 ("u" (find-file "~/projects/org-notes/uddin.org"))
992 ("o" (find-file "~/projects/org-notes/ool.org"))
993 ("f" (find-file "~/projects/org-notes/fh.org"))
994 ("s" (find-file "~/projects/org-notes/sndservers.org"))
995 ("r" (find-file my/org-refile-file))
996 ("p" (find-file "~/projects/research/papers_to_read.org"))
997 ("R" (find-file "~/projects/research/paper_notes.org"))
998 ("h" (find-file "~/projects/org-notes/hpcbio.org"))
1003 ;; from https://github.com/abo-abo/hydra/wiki/Emacs
1004 (defhydra my/hydra-outline (:color pink :hint nil)
1007 ^^^^^^------------------------------------------------------
1008 _q_: sublevels _a_: all _u_: up
1009 _t_: body _e_: entry _n_: next visible
1010 _o_: other _i_: children _p_: previous visible
1011 _c_: entry _k_: branches _f_: forward same level
1012 _l_: leaves _s_: subtree _b_: backward same level
1017 ("q" outline-hide-sublevels) ; Hide everything but the top-level headings
1018 ("t" outline-hide-body) ; Hide everything but headings (all body lines)
1019 ("o" outline-hide-other) ; Hide other branches
1020 ("c" outline-hide-entry) ; Hide this entry's body
1021 ("l" outline-hide-leaves) ; Hide body lines in this entry and sub-entries
1022 ("d" outline-hide-subtree) ; Hide everything in this entry and sub-entries
1024 ("a" outline-show-all) ; Show (expand) everything
1025 ("e" outline-show-entry) ; Show this heading's body
1026 ("i" outline-show-children) ; Show this heading's immediate child sub-headings
1027 ("k" outline-show-branches) ; Show all sub-headings under this heading
1028 ("s" outline-show-subtree) ; Show (expand) everything in this heading & below
1030 ("u" outline-up-heading) ; Up
1031 ("n" outline-next-visible-heading) ; Next
1032 ("p" outline-previous-visible-heading) ; Previous
1033 ("f" outline-forward-same-level) ; Forward - same level
1034 ("b" outline-backward-same-level) ; Backward - same level
1040 #+BEGIN_SRC emacs-lisp
1043 (add-to-list 'tramp-methods '("vcsh"
1044 (tramp-login-program "vcsh")
1048 (tramp-remote-shell "/bin/sh")
1049 (tramp-remote-shell-args
1053 #+BEGIN_SRC emacs-lisp
1057 (setq-default reftex-default-bibliography
1058 '("~/projects/research/references.bib")))
1061 #+BEGIN_SRC emacs-lisp
1063 :config (setq bibtex-user-optional-fields
1064 (quote (("annote" "Personal annotation (ignored)")
1072 #+BEGIN_SRC emacs-lisp
1077 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
1078 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
1079 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
1080 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
1081 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
1082 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
1083 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
1084 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
1085 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
1086 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
1087 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
1089 (setq-default reftex-plug-into-AUCTeX t)
1090 ;; support fake section headers
1091 (setq TeX-outline-extra
1095 ("%subsubsection" 4)
1097 ;; add font locking to the headers
1098 (font-lock-add-keywords
1100 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
1101 0 'font-lock-keyword-face t)
1102 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
1103 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
1104 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
1105 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
1106 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
1108 ;; use smart quotes by default instead of `` and ''
1109 ;; taken from http://kieranhealy.org/esk/kjhealy.html
1110 (setq TeX-open-quote "“")
1111 (setq TeX-close-quote "”")
1113 ;; (TeX-add-style-hook
1118 ;; (custom-set-variables
1119 ;; '(font-latex-user-keyword-classes
1122 ;; font-lock-function-name-face 2 (command 1 t))))
1124 (setq-default TeX-parse-self t)
1125 (setq-default TeX-auto-save t)
1126 (setq-default TeX-master nil)
1127 (add-to-list 'LaTeX-font-list
1128 '(?\C-a "\\alert{","}"))
1131 '(TeX-add-style-hook
1134 (if (boundp 'reftex-ref-style-alist)
1136 'reftex-ref-style-alist
1137 '("Cleveref" "cleveref"
1138 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
1139 (reftex-ref-style-activate "Cleveref")
1141 '("cref" TeX-arg-ref)
1142 '("Cref" TeX-arg-ref)
1143 '("cpageref" TeX-arg-ref)
1144 '("Cpageref" TeX-arg-ref)))))
1147 '(add-to-list 'LaTeX-fill-excluded-macros
1150 (use-package font-latex
1152 (setq font-latex-match-reference-keywords
1174 (setq font-latex-fontify-script nil)
1175 (setq font-latex-fontify-sectioning (quote color))
1176 (setq font-latex-script-display (quote (nil)))
1181 #+BEGIN_SRC emacs-lisp
1185 :mode ("\\.R\\'" . ess-r-mode)
1186 :bind (:map ess-mode-map
1187 ("C-c C-R" . dla/ess-region-remote-eval))
1189 (autoload 'ess-r-mode "ess-site" nil t)
1190 (autoload 'R "ess-site" nil t)
1192 ; actually load the rest of ess
1194 (defun ess-change-directory (path)
1195 "Set the current working directory to PATH for both *R* and Emacs."
1196 (interactive "Directory to change to: ")
1198 (when (file-exists-p path)
1199 (ess-command (concat "setwd(\"" path "\")\n"))
1200 ;; use file-name-as-directory to ensure it has trailing /
1201 (setq default-directory (file-name-as-directory path))))
1202 (add-hook 'ess-mode-hook 'flyspell-prog-mode)
1203 ;; outlining support for ess modes
1207 (outline-minor-mode)
1208 (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
1209 (defun outline-level ()
1210 (cond ((looking-at "^##### ") 1)
1211 ((looking-at "^#### ") 2)
1212 ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
1215 (defun dla/ess-region-remote-eval (start end)
1216 "Evaluate region in a remote ESS instance"
1218 (shell-command-on-region start end "eval_r" (get-buffer-create "***essregionremoteeval***") nil nil nil)
1219 (kill-buffer "***essregionremoteeval***"))
1220 ;; Don't restore history or save workspace image
1221 '(inferior-R-args "--no-restore-history --no-save")
1226 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
1228 #+BEGIN_SRC emacs-lisp
1229 (use-package rainbow-mode
1230 ;; add ess to the x major mode
1231 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
1232 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
1237 #+BEGIN_SRC emacs-lisp
1238 (use-package yaml-mode
1239 ;; add ess to the x major mode
1240 :mode ("\\.\\(yaml|yml\\)\\'" . yaml-mode)
1245 #+BEGIN_SRC emacs-lisp
1246 (use-package poly-noweb
1251 (use-package poly-markdown
1257 :after (:all polymode poly-markdown poly-noweb)
1258 ; :mode ("\\.Snw" . poly-noweb+r-mode)
1259 ; :mode ("\\.Rnw" . poly-noweb+r-mode)
1260 ; :mode ("\\.Rmd" . poly-markdown+r-mode)
1262 (use-package polymode
1270 #+BEGIN_SRC emacs-lisp
1271 (use-package outline-magic)
1274 #+BEGIN_SRC emacs-lisp
1275 ;; change the outline mode prefix from C-c @ to C-c C-2
1276 (setq outline-minor-mode-prefix "C-c C-2")
1277 ;;(add-hook 'outline-minor-mode-hook
1278 ;; (lambda () (local-set-key (kbd "C-c C-2")
1279 ;; outline-mode-prefix-map)))
1283 #+BEGIN_SRC emacs-lisp
1284 (use-package writeroom-mode
1286 (defun my/writing-mode ()
1287 "Start my writing mode; enable visual-line-mode and auto-fill-mode"
1292 (visual-line-mode -1)
1294 (visual-fill-column-mode -1)
1296 (visual-line-mode 1)
1298 (visual-fill-column-mode 1)
1303 ** GhostText/Atomic Chrome
1304 #+BEGIN_SRC emacs-lisp
1305 (use-package atomic-chrome
1307 (ignore-errors (atomic-chrome-start-server))
1308 (setq atomic-chrome-buffer-open-style 'full)
1312 #+BEGIN_SRC emacs-lisp
1313 (use-package edit-server
1315 :commands edit-server-start
1316 :init (if after-init-time
1318 (add-hook 'after-init-hook
1319 #'(lambda() (edit-server-start))))
1320 :config (setq edit-server-new-frame-alist
1321 '((name . "Edit with Emacs FRAME")
1327 (menu-bar-lines . t)
1328 (window-system . x)))
1332 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
1333 #+BEGIN_SRC emacs-lisp
1334 (use-package multiple-cursors
1335 :bind* (("C-;" . mc/mark-all-dwim)
1336 ("C-<" . mc/mark-previous-like-this)
1337 ("C->" . mc/mark-next-like-this)
1338 ("C-S-c C-S-c" . mc/edit-lines))
1342 #+BEGIN_SRC emacs-lisp
1343 (use-package web-mode
1344 :load-path "/home/don/projects/web-mode/"
1345 :mode ("\\.\\(tx|tmpl\\)\\'" . web-mode)
1347 (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . web-mode))
1348 (setq web-mode-enable-engine-detection t)
1349 (setq web-mode-engines-alist
1350 '(("template-toolkit" . "\\.tmpl\\'")))
1353 ** Spamassassin Mode
1354 #+BEGIN_SRC emacs-lisp
1355 (use-package spamassassin-mode
1356 :commands spamassassin-mode
1361 #+BEGIN_SRC emacs-lisp
1362 (use-package password-store
1364 :commands password-store-edit password-store-generate
1368 #+BEGIN_SRC emacs-lisp
1372 ;; fix up css mode to not be silly
1373 ;; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
1374 (setq cssm-indent-level 4)
1375 (setq cssm-newline-before-closing-bracket t)
1376 (setq cssm-indent-function #'cssm-c-style-indenter)
1377 (setq cssm-mirror-mode nil))
1380 #+BEGIN_SRC emacs-lisp
1382 :diminish abbrev-mode
1384 ;; load abbreviations from
1385 (setq abbrev-file-name
1386 "~/.emacs_abbrev_def")
1388 ;; read the abbrev file if it exists
1389 (if (file-exists-p abbrev-file-name)
1390 (quietly-read-abbrev-file))
1392 ;; for now, use abbrev mode everywhere
1393 (setq default-abbrev-mode t))
1396 ** Debugging (realgud)
1397 #+BEGIN_SRC emacs-lisp
1398 (use-package realgud
1402 ** Python Programming
1403 #+BEGIN_SRC emacs-lisp
1404 (use-package python-mode
1406 (python-mode . pyenv-mode)
1407 (python-mode . flycheck-mode)
1408 (python-mode . company-mode)
1409 (python-mode . blacken-mode)
1410 (python-mode . yas-minor-mode)
1411 (python-mode . anaconda-mode)
1416 (use-package blacken
1418 (setq-default blacken-fast-unsafe t)
1419 (setq-default blacken-line-length 80)
1421 (use-package anaconda-mode
1432 # #+BEGIN_SRC emacs-lisp
1433 # (use-package company-jedi
1435 # :hook (python-mode . (add-to-list 'company-backends 'company-jedi))
1436 # :hook (python-mode . 'jedi:setup)
1438 # (setq jedi:complete-on-dot t)
1442 #+begin_src emacs-lisp :tangle yes
1443 (use-package python-black
1447 *** Sphinx Documentation
1448 #+begin_src emacs-lisp :tangle yes
1449 (use-package numpydoc
1452 :bind (:map python-mode-map
1453 ("C-c C-n" . numpydoc-generate)))
1454 (use-package sphinx-doc
1458 (setq sphinx-doc-include-types t)
1462 #+BEGIN_SRC emacs-lisp
1463 (use-package go-mode
1470 #+BEGIN_SRC emacs-lisp
1471 (use-package expand-region
1472 :bind (("C-=" . 'er/expand-region))
1477 #+BEGIN_SRC emacs-lisp
1478 (use-package dockerfile-mode
1484 #+BEGIN_SRC emacs-lisp
1485 (use-package beancount
1486 :load-path "~/lib/emacs_el/beancount-mode/"
1488 :mode "\\.beancount\\'"
1495 #+BEGIN_SRC emacs-lisp
1496 (use-package message
1498 :diminish (message "✉")
1499 :mode ("muttng-[a-z0-9]+-[0-9]+-" . message-mode)
1500 :mode ("mutt-[a-z0-9]+-[0-9]+-" . message-mode)
1501 :hook 'my/message-mode-settings
1502 :hook 'turn-on-flyspell
1503 :bind (:map message-mode-map
1504 ("C-c C-a" . my/post-attach-file))
1505 :delight (message-mode "✉")
1507 (defun my/message-mode-settings ()
1508 (font-lock-add-keywords nil
1509 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
1510 (0 'message-multiply-quoted-text-face))
1511 ("^[ \t]*>[ \t]*>.*$"
1512 (0 'message-double-quoted-text-face))))
1515 (defun my/post-attach-file ()
1516 "Prompt for an attachment."
1518 (let ((file (read-file-name "Attach file: " nil nil t nil)))
1519 (my/header-attach-file file "")))
1521 (defun my/header-attach-file (file description)
1522 "Attach a FILE to the current message (works with Mutt).
1523 Argument DESCRIPTION MIME description."
1524 (interactive "fAttach file: \nsDescription: ")
1525 (when (> (length file) 0)
1530 (goto-char (point-min))
1531 (search-forward-regexp "^$")
1532 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
1534 (message (concat "Attached '" file "'."))
1535 (setq post-has-attachment t))))))
1537 (setq mail-yank-prefix "> ")
1538 (setq mail-header-separator "") ; fix broken header detection
1542 #+BEGIN_SRC emacs-lisp
1543 (use-package muttrc-mode
1550 ** Reverting buffers
1551 #+BEGIN_SRC emacs-lisp
1552 (use-package autorevert
1553 :diminish auto-revert-mode
1555 (setq global-auto-revert-non-file-buffers t
1556 global-auto-revert-ignore-modes '(pdf-view-mode)
1557 auto-revert-verbose nil)
1558 (global-auto-revert-mode 1))
1561 ** Use-package and load things
1562 #+BEGIN_SRC emacs-lisp
1565 :delight (org-mode "ø")
1566 :mode ("\\.\\(org\\|org_archive\\|txt\\)\\'" . org-mode)
1567 :bind (("C-c l" . org-store-link)
1568 ("C-c a" . org-agenda)
1569 ("C-c b" . org-iswitchb))
1571 ** Agenda Configuration
1572 #+BEGIN_SRC emacs-lisp
1574 (setq-default org-log-done 'time)
1575 (setq-default org-agenda-ndays 5)
1577 (setq org-agenda-sticky t)
1578 (defun dla/show-org-agenda ()
1583 (and (string-match-p
1591 (buffer-name agendabuffer))
1593 (delete-other-windows))
1595 ;; agenda configuration
1596 ;; Do not dim blocked tasks
1597 (setq org-agenda-dim-blocked-tasks nil)
1598 (setq org-agenda-inhibit-startup t)
1599 (setq org-agenda-use-tag-inheritance nil)
1601 ;; Compact the block agenda view
1602 (setq org-agenda-compact-blocks t)
1604 ;; Custom agenda command definitions
1605 (setq org-agenda-custom-commands
1606 (quote (("N" "Notes" tags "NOTE"
1607 ((org-agenda-overriding-header "Notes")
1608 (org-tags-match-list-sublevels t)))
1609 ("h" "Habits" tags-todo "STYLE=\"habit\""
1610 ((org-agenda-overriding-header "Habits")
1611 (org-agenda-sorting-strategy
1612 '(todo-state-down effort-up category-keep))))
1616 ((org-agenda-overriding-header "Tasks to Refile")
1617 (org-tags-match-list-sublevels nil)))
1618 (tags-todo "-CANCELLED/!"
1619 ((org-agenda-overriding-header "Stuck Projects")
1620 (org-agenda-skip-function 'bh/skip-non-stuck-projects)
1621 (org-agenda-sorting-strategy
1623 (tags-todo "-HOLD-CANCELLED/!"
1624 ((org-agenda-overriding-header "Projects")
1625 (org-agenda-skip-function 'bh/skip-non-projects)
1626 (org-tags-match-list-sublevels 'indented)
1627 (org-agenda-sorting-strategy
1629 (tags-todo "-CANCELLED/!NEXT"
1630 ((org-agenda-overriding-header (concat "Project Next Tasks"
1631 (if bh/hide-scheduled-and-waiting-next-tasks
1633 " (including WAITING and SCHEDULED tasks)")))
1634 (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
1635 (org-tags-match-list-sublevels t)
1636 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1637 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1638 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1639 (org-agenda-sorting-strategy
1640 '(todo-state-down effort-up category-keep))))
1641 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1642 ((org-agenda-overriding-header (concat "Project Subtasks"
1643 (if bh/hide-scheduled-and-waiting-next-tasks
1645 " (including WAITING and SCHEDULED tasks)")))
1646 (org-agenda-skip-function 'bh/skip-non-project-tasks)
1647 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1648 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1649 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1650 (org-agenda-sorting-strategy
1652 (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
1653 ((org-agenda-overriding-header (concat "Standalone Tasks"
1654 (if bh/hide-scheduled-and-waiting-next-tasks
1656 " (including WAITING and SCHEDULED tasks)")))
1657 (org-agenda-skip-function 'bh/skip-project-tasks)
1658 (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
1659 (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
1660 (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
1661 (org-agenda-sorting-strategy
1663 (tags-todo "-CANCELLED+WAITING|HOLD/!"
1664 ((org-agenda-overriding-header "Waiting and Postponed Tasks")
1665 (org-agenda-skip-function 'bh/skip-stuck-projects)
1666 (org-tags-match-list-sublevels nil)
1667 (org-agenda-todo-ignore-scheduled t)
1668 (org-agenda-todo-ignore-deadlines t)))
1670 ((org-agenda-overriding-header "Tasks to Archive")
1671 (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
1672 (org-tags-match-list-sublevels nil))))
1675 ; org mode agenda files
1676 (setq org-agenda-files
1678 (file-expand-wildcards "~/projects/org-notes/*.org")
1679 (file-expand-wildcards "~/org-mode/from-mobile.org")
1680 (file-expand-wildcards "~/org-notes-*/*.org")
1683 (setq my/org-refile-file
1685 (lambda (file) (string-match-p (regexp-quote "/refile.org") file))
1688 (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
1689 (set-register ?r (cons 'file my/org-refile-file))
1690 (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
1691 (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
1692 (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
1693 (set-register ?w (cons 'file "~/projects/org-notes/wildman.org"))
1694 (set-register ?u (cons 'file "~/projects/org-notes/uddin.org"))
1695 (set-register ?R (cons 'file "~/projects/reviews/reviews.org"))
1696 (set-register ?d (cons 'file "~/projects/org-notes/diary.org"))
1697 ; from https://emacs.stackexchange.com/questions/909/how-can-i-have-an-agenda-timeline-view-of-multiple-files
1698 (defun org-agenda-timeline-all (&optional arg)
1701 (dolist (org-agenda-file org-agenda-files)
1702 (insert-file-contents org-agenda-file nil)
1703 (goto-char (point-max))
1705 (write-file "/tmp/timeline.org")
1706 (org-agenda arg "L")))
1707 (define-key org-mode-map (kbd "C-c t") 'org-agenda-timeline-all)
1711 #+BEGIN_SRC emacs-lisp
1712 (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")))
1713 (setq org-columns-default-format "%40ITEM(Task) %6Effort{:} %CLOCKSUM %PRIORITY %TODO %13SCHEDULED %13DEADLINE %TAGS")
1715 (setq org-default-notes-file "~/projects/org-notes/notes.org")
1716 (setq org-id-link-to-org-use-id 'use-existing)
1718 ** Capture Templates
1719 #+BEGIN_SRC emacs-lisp
1720 (setq org-capture-templates ;; mail-specific note template, identified by "m"
1721 `(("m" "Mail" entry (file my/org-refile-file)
1722 "* %?\n\n Source: %u, [[%:link][%:description]]\n %:initial")
1723 ("t" "todo" entry (file my/org-refile-file)
1724 "* TODO %?\n :PROPERTIES:\n :END:\n :LOGBOOK:\n :END:\n%U\n%a\n" :clock-in t :clock-resume t)
1725 ("r" "respond" entry (file my/org-refile-file)
1726 "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
1727 ("n" "note" entry (file my/org-refile-file)
1728 "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
1729 ("s" "schedule" entry (file my/org-refile-file)
1730 "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
1731 ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
1732 "* %?\n%U\n" :clock-in t :clock-resume t)
1733 ("w" "org-protocol" entry (file my/org-refile-file)
1734 "* TODO Review %c\n%U\n" :immediate-finish t)
1735 ("M" "Meeting" entry (file my/org-refile-file)
1736 "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
1737 ("S" "Seminar" entry (file my/org-refile-file)
1738 "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
1739 ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
1740 "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
1741 ("p" "Phone call" entry (file my/org-refile-file)
1742 "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
1743 ("J" "job" entry (file+olp "~/projects/org-notes/notes.org"
1745 ,(format-time-string "Positions %Y"))
1746 "* TODO Apply for %? :job:\nSCHEDULED: <%<%Y-%m-%d>>\n%U\n%x\n" :clock-in t :clock-resume t)
1747 ("h" "Habit" entry (file my/org-refile-file)
1748 "* 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")
1752 ;; Remove empty LOGBOOK drawers on clock out
1753 (defun bh/remove-empty-drawer-on-clock-out ()
1756 (beginning-of-line 0)
1757 (org-remove-empty-drawer-at (point))))
1759 (defun my/org-add-id ()
1762 (if (org-current-level)
1771 ** Org mode key bindings
1772 #+BEGIN_SRC emacs-lisp
1773 ;; org mode configuration from http://doc.norang.ca/org-mode.html
1774 ;; Custom Key Bindings
1775 :bind* (("<f9> a" . org-agenda)
1776 ("<f9> I" . bh/punch-in)
1777 ("<f9> O" . bh/punch-out)
1778 ("<f9> SPC" . bh/clock-in-last-task)
1779 ("<f12>" . dla/show-org-agenda)
1780 ;; ("<f5>" . bh/org-todo)
1781 ("<S-f5>" . bh/widen)
1782 ("<f7>" . bh/set-truncate-lines)
1783 ("<f8>" . org-cycle-agenda-files)
1784 ("<f9> <f9>" . dla/show-org-agenda)
1786 ("<f9> c" . calendar)
1787 ("<f9> f" . boxquote-insert-file)
1788 ("<f9> h" . bh/hide-other)
1789 ("<f9> n" . bh/toggle-next-task-display)
1792 ("<f9> r" . boxquote-region)
1793 ("<f9> s" . bh/switch-to-scratch)
1795 ("<f9> t" . bh/insert-inactive-timestamp)
1796 ("<f9> T" . bh/toggle-insert-inactive-timestamp)
1798 ("<f9> v" . visible-mode)
1799 ("<f9> l" . org-toggle-link-display)
1800 ("<f9> SPC" . bh/clock-in-last-task)
1801 ("C-<f9>" . previous-buffer)
1802 ("M-<f9>" . org-toggle-inline-images)
1803 ("C-x n r" . narrow-to-region)
1804 ("C-<f10>" . next-buffer)
1805 ("<f11>" . org-clock-goto)
1806 ("C-<f11>" . org-clock-in)
1807 ("C-s-<f12>" . bh/save-then-publish)
1808 ("C-c c" . org-capture))
1811 ** Utility Functions
1812 #+BEGIN_SRC emacs-lisp
1813 (defun bh/hide-other ()
1816 (org-back-to-heading 'invisible-ok)
1817 (outline-hide-other)
1822 (defun bh/set-truncate-lines ()
1823 "Toggle value of truncate-lines and refresh window display."
1825 (setq truncate-lines (not truncate-lines))
1826 ;; now refresh window display (an idiom from simple.el):
1828 (set-window-start (selected-window)
1829 (window-start (selected-window)))))
1831 (defun bh/switch-to-scratch ()
1833 (switch-to-buffer "*scratch*"))
1835 (setq org-use-fast-todo-selection t)
1836 (setq org-treat-S-cursor-todo-selection-as-state-change nil)
1838 ; create function to create headlines in file. This comes from
1839 ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
1840 (defun my/org-add-ids-to-headlines-in-file ()
1841 "Add ID properties to all headlines in the current file which
1842 do not already have one."
1846 (goto-char (point-min))
1847 (when (not (re-search-forward "^#\\+OPTIONS:.*auto-id:f" (point-max) t))
1848 (org-map-entries 'org-id-get-create))))
1849 (defun dla/org-update-ids-to-headlines-in-file ()
1850 "Add or replace ID properties to all headlines in the current file
1851 (or narrowed region)."
1854 (org-map-entries '(lambda () (org-id-get-create t))))
1855 ; if we wanted to do this to every buffer, do the following:
1856 (add-hook 'org-mode-hook
1858 (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
1861 #+BEGIN_SRC emacs-lisp
1862 (use-package find-lisp
1864 (setq org-agenda-text-search-extra-files
1865 (append '(agenda-archives)
1866 (find-lisp-find-files "~/projects/org-notes" "\.org$")
1867 (find-lisp-find-files "~/projects/org-notes" "\.org_archive$")
1871 #+BEGIN_SRC emacs-lisp
1872 (setq org-todo-keywords
1873 (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
1874 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
1876 (setq org-todo-keyword-faces
1877 (quote (("TODO" :foreground "red" :weight bold)
1878 ("NEXT" :foreground "blue" :weight bold)
1879 ("DONE" :foreground "forest green" :weight bold)
1880 ("WAITING" :foreground "orange" :weight bold)
1881 ("HOLD" :foreground "magenta" :weight bold)
1882 ("CANCELLED" :foreground "forest green" :weight bold)
1883 ("MEETING" :foreground "forest green" :weight bold)
1884 ("PHONE" :foreground "forest green" :weight bold))))
1886 (setq org-todo-state-tags-triggers
1887 (quote (("CANCELLED" ("CANCELLED" . t))
1888 ("WAITING" ("WAITING" . t))
1889 ("HOLD" ("WAITING") ("HOLD" . t))
1890 (done ("WAITING") ("HOLD"))
1891 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
1892 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
1893 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
1897 ; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)
1898 ; add ids on creation of nodes
1899 (add-hook 'org-capture-prepare-finalize-hook 'my/org-add-id)
1902 ; resolve clocks after 10 minutes of idle; use xprintidle
1903 ; (setq org-clock-idle-time 10)
1904 ; (setq org-clock-x11idle-program-name "xprintidle")
1906 ; this is from http://doc.norang.ca/org-mode.html#Capture
1907 ; use C-M-r for org mode capture
1908 (global-set-key (kbd "C-M-r") 'org-capture)
1910 ; Targets include this file and any file contributing to the agenda - up to 9 levels deep
1911 (setq org-refile-targets (quote ((nil :maxlevel . 9)
1912 (org-agenda-files :maxlevel . 9))))
1914 ; Use full outline paths for refile targets - we file directly with IDO
1915 (setq org-refile-use-outline-path t)
1917 ; Targets complete directly with IDO
1918 (setq org-outline-path-complete-in-steps nil)
1920 ; Allow refile to create parent tasks with confirmation
1921 (setq org-refile-allow-creating-parent-nodes (quote confirm))
1923 ; ; Use IDO for both buffer and file completion and ido-everywhere to t
1924 ; (setq org-completion-use-ido t)
1925 ; (setq ido-everywhere t)
1926 ; (setq ido-max-directory-size 100000)
1927 ; (ido-mode (quote both))
1928 ; ; Use the current window when visiting files and buffers with ido
1929 ; (setq ido-default-file-method 'selected-window)
1930 ; (setq ido-default-buffer-method 'selected-window)
1931 ; ; Use the current window for indirect buffer display
1932 ; (setq org-indirect-buffer-display 'current-window)
1935 ;;;; Refile settings
1936 ; Exclude DONE state tasks from refile targets
1937 (defun bh/verify-refile-target ()
1938 "Exclude todo keywords with a done state from refile targets"
1939 (not (member (nth 2 (org-heading-components)) org-done-keywords)))
1941 (setq org-refile-target-verify-function 'bh/verify-refile-target)
1943 ;; ensure that emacsclient will show just the note to be edited when invoked
1944 ;; from Mutt, and that it will shut down emacsclient once finished;
1945 ;; fallback to legacy behavior when not invoked via org-protocol.
1946 (require 'org-protocol)
1947 ; (add-hook 'org-capture-mode-hook 'delete-other-windows)
1948 (setq my-org-protocol-flag nil)
1949 (defadvice org-capture-finalize (after delete-frame-at-end activate)
1950 "Delete frame at remember finalization"
1951 (progn (if my-org-protocol-flag (delete-frame))
1952 (setq my-org-protocol-flag nil)))
1953 (defadvice org-capture-refile (around delete-frame-after-refile activate)
1954 "Delete frame at remember refile"
1955 (if my-org-protocol-flag
1957 (setq my-org-protocol-flag nil)
1962 (defadvice org-capture-kill (after delete-frame-at-end activate)
1963 "Delete frame at remember abort"
1964 (progn (if my-org-protocol-flag (delete-frame))
1965 (setq my-org-protocol-flag nil)))
1966 (defadvice org-protocol-capture (before set-org-protocol-flag activate)
1967 (setq my-org-protocol-flag t))
1969 (defadvice org-insert-todo-heading (after dla/create-id activate)
1970 (unless (org-in-item-p)
1976 (add-to-list 'org-modules 'org-habit)
1978 ; this comes from http://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
1979 (defun open-mail-in-mutt (message)
1980 "Open a mail message in Mutt, using an external terminal.
1982 Message can be specified either by a path pointing inside a
1983 Maildir, or by Message-ID."
1984 (interactive "MPath or Message-ID: ")
1986 (format "faf xterm -e \"%s %s\""
1987 (substitute-in-file-name "$HOME/bin/mutt_open") message)))
1989 ;; add support for "mutt:ID" links
1990 (org-add-link-type "mutt" 'open-mail-in-mutt)
1992 (defun my-org-mode-setup ()
1993 ; (load-library "reftex")
1994 (and (buffer-file-name)
1995 (file-exists-p (buffer-file-name))
1997 ; (reftex-parse-all)
1998 (reftex-set-cite-format
1999 '((?b . "[[bib:%l][%l-bib]]")
2000 (?n . "[[notes:%l][%l-notes]]")
2002 (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]")))
2004 (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
2005 (define-key org-mode-map (kbd "C-c [") 'reftex-citation)
2006 (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)
2007 (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref)
2009 (add-hook 'org-mode-hook 'my-org-mode-setup)
2011 (defun org-mode-reftex-search ()
2013 (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))
2015 (defun open-research-paper (bibtexkey)
2016 "Open a paper by bibtex key"
2017 (interactive "bibtex key: ")
2020 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
2021 (org-add-link-type "papers" 'open-research-paper)
2022 (defun open-research-paper-pdf (bibtexkey)
2023 "Open a paper pdf by bibtex key"
2024 (interactive "bibtex key: ")
2026 (format "%s -p evince_annot %s"
2027 (substitute-in-file-name "$HOME/bin/bibtex_to_paper") bibtexkey)))
2028 (org-add-link-type "papers-pdf" 'open-research-paper-pdf)
2030 (add-to-list 'org-link-abbrev-alist
2032 "~/projects/research/paper_notes.org::#%s"))
2034 ; I pretty much always want hiearchical checkboxes
2035 (setq org-hierachical-checkbox-statistics nil)
2037 ;; Add \begin{equation}\end{equation} templates to the org mode easy templates
2038 (add-to-list 'org-structure-template-alist
2039 '("E" "\\begin{equation}\n?\n\\end{equation}"))
2042 ;; http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/
2043 (defun my-rtcite-export-handler (path desc format)
2044 (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
2045 (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
2046 (match-string 1 path)))
2047 (path (substring path 0 (match-beginning 0))))
2048 (cond ((eq format 'latex)
2050 (equal 0 (search "rtcite:" desc)))
2051 (format "\\cite{%s}" search)
2052 (format "\\cite[%s]{%s}" desc search))))))
2054 (org-add-link-type "rtcite"
2056 'my-rtcite-export-handler)
2060 ** Org Mobile Configuration
2061 #+BEGIN_SRC emacs-lisp
2062 (setq-default org-mobile-directory "/linnode.donarmstrong.com:/sites/dav.donarmstrong.com/root/org/")
2063 (when (string= system-name "linnode")
2064 (setq-default org-mobile-directory "/sites/dav.donarmstrong.com/root/org/"))
2065 (setq-default org-directory "/home/don/org-mode/")
2066 (setq-default org-mobile-inbox-for-pull "/home/don/org-mode/from-mobile.org")
2070 #+BEGIN_SRC emacs-lisp
2071 ;; org mode ical export
2072 (setq org-icalendar-timezone "America/Los_Angeles")
2073 (setq org-icalendar-use-scheduled '(todo-start event-if-todo))
2074 ;; we already add the id manually
2075 (setq org-icalendar-store-UID t)
2078 ** General Org Babel Configuration
2079 #+BEGIN_SRC emacs-lisp
2080 ;; org babel support
2081 (org-babel-do-load-languages
2082 'org-babel-load-languages
2089 ;; set the right path to ditaa.jar
2090 (setq org-ditaa-jar-path "/usr/share/ditaa/ditaa.jar")
2091 ;; use graphviz-dot for dot things
2092 (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
2093 ;; do not indent begin_src blocks
2094 (setq org-edit-src-content-indentation 0)
2095 ;; org-babel-by-backend
2096 (defmacro org-babel-by-backend (&rest body)
2097 `(case (if (boundp 'backend)
2098 (org-export-backend-name backend)
2101 (defun my/fix-inline-images ()
2102 (when org-inline-image-overlays
2103 (org-redisplay-inline-images)))
2105 (add-hook 'org-babel-after-execute-hook
2106 'my/fix-inline-images)
2109 ** LaTeX configuration
2110 #+BEGIN_SRC emacs-lisp
2111 (use-package ox-extra
2113 (ox-extras-activate '(ignore-headlines)))
2115 (add-to-list 'org-latex-classes
2117 "\\documentclass[11pt,oneside,article]{memoir}\n"
2118 ("\\section{%s}" . "\\section*{%s}")
2119 ("\\subsection{%s}" . "\\subsection*{%s}")
2120 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2121 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2122 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2124 (setq org-beamer-outline-frame-options "")
2125 (add-to-list 'org-latex-classes
2127 "\\documentclass[ignorenonframetext]{beamer}
2128 [NO-DEFAULT-PACKAGES]
2131 ("\\section{%s}" . "\\section*{%s}")
2132 ("\\subsection{%s}" . "\\subsection*{%s}")
2133 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2134 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2135 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2137 (add-to-list 'org-latex-classes
2139 "\\documentclass[11pt,oneside]{memoir}\n"
2140 ("\\chapter{%s}" . "\\chapter*{%s}")
2141 ("\\section{%s}" . "\\section*{%s}")
2142 ("\\subsection{%s}" . "\\subsection*{%s}")
2143 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
2145 (add-to-list 'org-latex-classes
2147 "\\documentclass[11pt]{letter}
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}")))
2157 (add-to-list 'org-latex-classes
2159 "\\documentclass{dlacv}
2160 [NO-DEFAULT-PACKAGES]
2163 ("\\section{%s}" . "\\section*{%s}")
2164 ("\\subsection{%s}" . "\\subsection*{%s}")
2165 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2166 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2167 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2170 (add-to-list 'org-latex-classes
2172 "\\documentclass{dlaresume}
2173 [NO-DEFAULT-PACKAGES]
2176 ("\\section{%s}" . "\\section*{%s}")
2177 ("\\subsection{%s}" . "\\subsection*{%s}")
2178 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
2179 ("\\paragraph{%s}" . "\\paragraph*{%s}")
2180 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
2183 ;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
2184 ;; but adapted to use latexmk 4.22 or higher.
2185 (setq org-latex-pdf-process '("latexmk -f -pdflatex=xelatex -bibtex -use-make -pdf %f"))
2187 ;; Default packages included in /every/ tex file, latex, pdflatex or xelatex
2188 (setq org-latex-default-packages-alist
2190 ("" "unicode-math" t)
2192 (setq org-latex-packages-alist
2199 ("" "longtable" nil)
2202 ;; make equations larger
2203 (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
2205 (defun org-create-formula--latex-header ()
2206 "Return LaTeX header appropriate for previewing a LaTeX snippet."
2207 (let ((info (org-combine-plists (org-export--get-global-options
2208 (org-export-get-backend 'latex))
2209 (org-export--get-inbuffer-options
2210 (org-export-get-backend 'latex)))))
2211 (org-latex-guess-babel-language
2212 (org-latex-guess-inputenc
2213 (org-splice-latex-header
2214 org-format-latex-header
2215 org-latex-default-packages-alist
2217 (plist-get info :latex-header)))
2221 ; support ignoring headers in org mode export to latex
2222 ; from http://article.gmane.org/gmane.emacs.orgmode/67692
2223 (defadvice org-latex-headline (around my-latex-skip-headlines
2224 (headline contents info) activate)
2225 (if (member "ignoreheading" (org-element-property :tags headline))
2226 (setq ad-return-value contents)
2229 ;; keep latex logfiles
2231 (setq org-latex-remove-logfiles nil)
2233 ;; Resume clocking task when emacs is restarted
2234 (org-clock-persistence-insinuate)
2236 ;; Show lot of clocking history so it's easy to pick items off the C-F11 list
2237 (setq org-clock-history-length 23)
2238 ;; Resume clocking task on clock-in if the clock is open
2239 (setq org-clock-in-resume t)
2240 ;; Change tasks to NEXT when clocking in; this avoids clocking in when
2241 ;; there are things like PHONE calls
2242 (setq org-clock-in-switch-to-state 'bh/clock-in-to-next)
2243 ;; Separate drawers for clocking and logs
2244 (setq org-drawers (quote ("PROPERTIES" "LOGBOOK")))
2245 ;; Save clock data and state changes and notes in the LOGBOOK drawer
2246 (setq org-clock-into-drawer t)
2247 (setq org-log-into-drawer t)
2248 ;; Sometimes I change tasks I'm clocking quickly - this removes clocked tasks with 0:00 duration
2249 (setq org-clock-out-remove-zero-time-clocks t)
2250 ;; Clock out when moving task to a done state
2251 (setq org-clock-out-when-done t)
2252 ;; Save the running clock and all clock history when exiting Emacs, load it on startup
2253 (setq org-clock-persist t)
2254 ;; Do not prompt to resume an active clock
2255 (setq org-clock-persist-query-resume nil)
2256 ;; Enable auto clock resolution for finding open clocks
2257 (setq org-clock-auto-clock-resolution (quote when-no-clock-is-running))
2258 ;; Include current clocking task in clock reports
2259 (setq org-clock-report-include-clocking-task t)
2261 ;; the cache seems to be broken
2262 (setq org-element-use-cache nil)
2264 (defvar bh/keep-clock-running nil)
2266 (defun bh/is-task-p ()
2267 "Any task with a todo keyword and no subtask"
2271 (subtree-end (save-excursion (org-end-of-subtree t)))
2272 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2275 (while (and (not has-subtask)
2276 (< (point) subtree-end)
2277 (re-search-forward "^\*+ " subtree-end t))
2278 (when (member (org-get-todo-state) org-todo-keywords-1)
2279 (setq has-subtask t))))
2280 (and is-a-task (not has-subtask)))))
2281 (defun bh/is-project-p ()
2282 "Any task with a todo keyword subtask"
2286 (subtree-end (save-excursion (org-end-of-subtree t)))
2287 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2290 (while (and (not has-subtask)
2291 (< (point) subtree-end)
2292 (re-search-forward "^\*+ " subtree-end t))
2293 (when (member (org-get-todo-state) org-todo-keywords-1)
2294 (setq has-subtask t))))
2295 (and is-a-task has-subtask))))
2297 (defun bh/is-subproject-p ()
2298 "Any task which is a subtask of another project"
2299 (let ((is-subproject)
2300 (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
2302 (while (and (not is-subproject) (org-up-heading-safe))
2303 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
2304 (setq is-subproject t))))
2305 (and is-a-task is-subproject)))
2308 (defun bh/clock-in-to-next (kw)
2309 "Switch a task from TODO to NEXT when clocking in.
2310 Skips capture tasks, projects, and subprojects.
2311 Switch projects and subprojects from NEXT back to TODO"
2312 (when (not (and (boundp 'org-capture-mode) org-capture-mode))
2314 ((and (member (org-get-todo-state) (list "TODO"))
2317 ((and (member (org-get-todo-state) (list "NEXT"))
2321 (defun bh/punch-in (arg)
2322 "Start continuous clocking and set the default task to the
2323 selected task. If no task is selected set the Organization task
2324 as the default task."
2326 (setq bh/keep-clock-running t)
2327 (if (equal major-mode 'org-agenda-mode)
2329 ;; We're in the agenda
2331 (let* ((marker (org-get-at-bol 'org-hd-marker))
2332 (tags (org-with-point-at marker (org-get-tags))))
2333 (if (and (eq arg 4) tags)
2334 (org-agenda-clock-in '(16))
2335 (bh/clock-in-organization-task-as-default)))
2337 ;; We are not in the agenda
2341 ; Find the tags on the current task
2342 (if (and (equal major-mode 'org-mode) (not (org-before-first-heading-p)) (eq arg 4))
2343 (org-clock-in '(16))
2344 (bh/clock-in-organization-task-as-default)))))
2346 (defun bh/punch-out ()
2348 (setq bh/keep-clock-running nil)
2349 (when (org-clock-is-active)
2351 (org-agenda-remove-restriction-lock))
2353 (defun bh/clock-in-default-task ()
2355 (org-with-point-at org-clock-default-task
2358 (defun bh/clock-in-parent-task ()
2359 "Move point to the parent (project) task if any and clock in"
2360 (let ((parent-task))
2364 (while (and (not parent-task) (org-up-heading-safe))
2365 (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
2366 (setq parent-task (point))))
2368 (org-with-point-at parent-task
2370 (when bh/keep-clock-running
2371 (bh/clock-in-default-task)))))))
2373 (defvar bh/organization-task-id "e22cb8bf-07c7-408b-8f60-ff3aadac95e4")
2375 (defun bh/clock-in-organization-task-as-default ()
2377 (org-with-point-at (org-id-find bh/organization-task-id 'marker)
2378 (org-clock-in '(16))))
2380 (defun bh/clock-out-maybe ()
2381 (when (and bh/keep-clock-running
2382 (not org-clock-clocking-in)
2383 (marker-buffer org-clock-default-task)
2384 (not org-clock-resolving-clocks-due-to-idleness))
2385 (bh/clock-in-parent-task)))
2387 ; (add-hook 'org-clock-out-hook 'bh/clock-out-maybe 'append)
2390 (defun bh/clock-in-task-by-id (id)
2391 "Clock in a task by id"
2392 (org-with-point-at (org-id-find id 'marker)
2393 (org-clock-in nil)))
2395 (defun bh/clock-in-last-task (arg)
2396 "Clock in the interrupted task if there is one
2397 Skip the default task and get the next one.
2398 A prefix arg forces clock in of the default task."
2400 (let ((clock-in-to-task
2402 ((eq arg 4) org-clock-default-task)
2403 ((and (org-clock-is-active)
2404 (equal org-clock-default-task (cadr org-clock-history)))
2405 (caddr org-clock-history))
2406 ((org-clock-is-active) (cadr org-clock-history))
2407 ((equal org-clock-default-task (car org-clock-history)) (cadr org-clock-history))
2408 (t (car org-clock-history)))))
2410 (org-with-point-at clock-in-to-task
2411 (org-clock-in nil))))
2414 (defun org-export-to-ods ()
2416 (let ((csv-file "data.csv"))
2417 (org-table-export csv-file "orgtbl-to-csv")
2418 (org-odt-convert csv-file "ods" 'open)))
2420 ; allow for zero-width-space to be a break in regexp too
2421 ; (setcar org-emphasis-regexp-components " [:space:] \t('\"{")
2422 ; (setcar (nthcdr 1 org-emphasis-regexp-components) " [:space:]- \t.,:!?;'\")}\\")
2423 ; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
2425 ;; support inserting screen shots
2426 (defun my/org-insert-screenshot ()
2427 "Take a screenshot into a time stamped unique-named file in the
2428 same directory as the org-buffer and insert a link to this file."
2430 (defvar my/org-insert-screenshot/filename)
2431 (setq my/org-insert-screenshot/filename
2433 "Screenshot to insert: "
2435 (concat (buffer-file-name) "_" (format-time-string "%Y%m%d_%H%M%S") ".png")
2438 (call-process "import" nil nil nil my/org-insert-screenshot/filename)
2439 (insert (concat "[[" my/org-insert-screenshot/filename "]]"))
2440 (org-display-inline-images))
2442 (defun my/fix-inline-images ()
2443 (when org-inline-image-overlays
2444 (org-redisplay-inline-images)))
2446 (add-hook 'org-babel-after-execute-hook 'my/fix-inline-images)
2448 ;; use xelatex to preview with imagemagick
2449 (add-to-list 'org-preview-latex-process-alist
2450 '(xelateximagemagick
2451 :programs ("xelatex" "convert")
2452 :description "pdf > png"
2453 :message "you need to install xelatex and imagemagick"
2455 :image-input-type "pdf"
2456 :image-output-type "png"
2457 :image-size-adjust (1.0 . 1.0)
2458 :latex-compiler ("xelatex -interaction nonstopmode -output-directory %o %f")
2459 :image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
2461 ;; use xelatex by default
2462 (setq org-preview-latex-default-process 'xelateximagemagick)
2464 ; from http://orgmode.org/Changes.html
2465 (defun my/org-repair-property-drawers ()
2466 "Fix properties drawers in current buffer.
2467 Ignore non Org buffers."
2469 (when (eq major-mode 'org-mode)
2470 (org-with-wide-buffer
2471 (goto-char (point-min))
2472 (let ((case-fold-search t)
2473 (inline-re (and (featurep 'org-inlinetask)
2474 (concat (org-inlinetask-outline-regexp)
2478 (unless (and inline-re (org-looking-at-p inline-re))
2480 (let ((end (save-excursion (outline-next-heading) (point))))
2482 (when (org-looking-at-p org-planning-line-re) (forward-line))
2483 (when (and (< (point) end)
2484 (not (org-looking-at-p org-property-drawer-re))
2486 (and (re-search-forward org-property-drawer-re end t)
2487 (eq (org-element-type
2488 (save-match-data (org-element-at-point)))
2490 (insert (delete-and-extract-region
2492 (min (1+ (match-end 0)) end)))
2493 (unless (bolp) (insert "\n"))))))))))))
2497 #+BEGIN_SRC emacs-lisp
2501 (use-package calfw-org
2504 (use-package org-gcal
2505 :if (file-readable-p "~/.hide/org_gcal.el")
2507 :config '((if (file-readable-p "~/.hide/org_gcal.el")
2508 (load-file "~/.hide/org_gcal.el"))
2513 #+BEGIN_SRC emacs-lisp
2517 ;; Show notification 10 minutes before event
2518 (setq appt-message-warning-time 10)
2519 ;; Disable multiple reminders
2520 (setq appt-display-interval appt-message-warning-time)
2521 (setq appt-display-mode-line nil)
2523 ;; add automatic reminders for appointments
2524 (defun my/org-agenda-to-appt ()
2526 (setq appt-time-msg-list nil)
2527 (org-agenda-to-appt))
2528 ;; add reminders when starting emacs
2529 (my/org-agenda-to-appt)
2530 ;; when rebuilding the agenda
2531 (defadvice org-agenda-redo (after org-agenda-redo-add-appts)
2532 "Pressing `r' on the agenda will also add appointments."
2533 (my/org-agenda-to-appt)
2535 ;; when saving all org buffers
2536 (defadvice org-save-all-org-buffers (after org-save-all-org-buffers-add-appts)
2537 "Re-add appts after saving all org buffers"
2538 (my/org-agenda-to-appt))
2539 ;; Display appointments as a window manager notification
2540 (setq appt-disp-window-function 'my/appt-display)
2541 (setq appt-delete-window-function (lambda () t))
2543 (setq my/appt-notification-app (concat (getenv "HOME") "/bin/appt_notification"))
2545 (defun my/appt-display (min-to-app new-time msg)
2546 (if (atom min-to-app)
2547 (start-process "my/appt-notification-app" nil my/appt-notification-app min-to-app msg)
2548 (dolist (i (number-sequence 0 (1- (length min-to-app))))
2549 (start-process "my/appt-notification-app" nil my/appt-notification-app
2550 (nth i min-to-app) (nth i msg))))
2556 ** outshine (outlining) integration
2557 #+BEGIN_SRC emacs-lisp
2558 (use-package outshine
2560 :hook (outline-minor-mode . outshine-hook-function)
2564 #+BEGIN_SRC emacs-lisp
2568 ** Home/End Begining/End of line
2569 #+BEGIN_SRC emacs-lisp
2570 (global-set-key [home] 'move-beginning-of-line)
2571 (global-set-key [end] 'move-end-of-line)
2574 #+BEGIN_SRC emacs-lisp
2575 (global-unset-key "\M-g")
2576 (global-set-key (kbd "M-g l") 'goto-line)
2580 #+BEGIN_SRC emacs-lisp
2581 (use-package debian-changelog-mode
2582 :mode "debian/changelog"
2584 (setq debian-changelog-mailing-address "don@debian.org")
2585 (setq debian-changelog-full-name "Don Armstrong"))
2587 * Misc (uncharacterized)
2588 #+BEGIN_SRC emacs-lisp
2589 (setq calendar-latitude 38.6)
2590 (setq calendar-longitude -121.5)
2591 (setq case-fold-search t)
2592 (setq confirm-kill-emacs (quote y-or-n-p))
2593 (setq cperl-lazy-help-time nil)
2595 ** Turn on fontlock and icomplete
2596 #+BEGIN_SRC emacs-lisp
2597 (global-font-lock-mode 1)
2599 (setq log-edit-keep-buffer t)
2601 ** Set mail User agent
2602 #+BEGIN_SRC emacs-lisp
2603 (setq mail-user-agent (quote sendmail-user-agent))
2604 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
2607 #+BEGIN_SRC emacs-lisp
2608 (setq ps-footer-font-size (quote (8 . 10)))
2609 (setq ps-header-font-size (quote (8 . 10)))
2610 (setq ps-header-title-font-size (quote (10 . 10)))
2611 (setq ps-line-number-color "blue")
2612 (setq ps-print-footer t)
2613 (setq ps-print-footer-frame nil)
2614 (setq ps-print-only-one-header t)
2616 ** Only single spacing on sentences
2617 #+BEGIN_SRC emacs-lisp
2618 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
2620 (setq sentence-end-double-space nil)
2621 ; enable matching parenthesis
2623 ** Display paren mode
2624 #+BEGIN_SRC emacs-lisp
2626 (setq show-paren-delay 0.2)
2630 #+BEGIN_SRC emacs-lisp
2631 (setq user-mail-address "don@donarmstrong.com")
2634 ** Use primary selection on unix machines
2635 #+BEGIN_SRC emacs-lisp
2636 ;; switch back to the old primary selection method
2637 (if (or (string-equal system-type "darwin")
2638 (string-equal system-type "windows")
2641 (setq select-enable-clipboard t)
2642 (setq select-enable-primary nil)
2645 (setq select-enable-clipboard nil)
2646 (setq select-enable-primary t)
2648 ; (setq mouse-drag-copy-region t)
2650 ;; tramp configuration
2651 (setq tramp-use-ssh-controlmaster-options nil)
2653 (setq-default c-indent-level 4)
2654 (setq-default c-brace-imaginary-offset 0)
2655 (setq-default c-brace-offset -4)
2656 (setq-default c-argdecl-indent 4)
2657 (setq-default c-label-offset -4)
2658 (setq-default c-continued-statement-offset 4)
2660 (setq-default indent-tabs-mode nil)
2661 (setq-default tab-width 4)
2664 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
2665 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
2666 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
2667 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
2668 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
2671 (defun insert-date ()
2672 "Insert date at point."
2674 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
2675 (global-set-key "\C-[d" 'insert-date)
2677 (defun unfill-paragraph (arg)
2678 "Pull this whole paragraph up onto one line."
2680 (let ((fill-column 10000))
2681 (fill-paragraph arg))
2684 (column-number-mode t)
2687 ** Desktop-save-mode
2688 If the envvar EMACS_SERVER_NAME is set, consider this a separate
2689 emacs, and use a different desktop file to restore history
2690 #+BEGIN_SRC emacs-lisp
2691 (use-package desktop
2694 (setq desktop-base-file-name
2695 (convert-standard-filename
2697 (or (getenv "EMACS_SERVER_NAME")
2701 (setq desktop-base-lock-name
2702 (convert-standard-filename
2703 (concat desktop-base-file-name
2705 (setq desktop-auto-save-timeout 60)
2706 (setq desktop-restore-eager 5)
2707 (setq desktop-lazy-verbose nil)
2708 (desktop-save-mode 1)
2712 ** Misc (Uncharacterized)
2713 #+BEGIN_SRC emacs-lisp
2714 '(icomplete-mode on)
2716 ;; custom-set-faces was added by Custom.
2717 ;; If you edit it by hand, you could mess it up, so be careful.
2718 ;; Your init file should contain only one such instance.
2719 ;; If there is more than one, they won't work right.
2720 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
2723 (put 'upcase-region 'disabled nil)
2724 (put 'downcase-region 'disabled nil)
2725 (put 'narrow-to-region 'disabled nil)
2727 ; (defun turn-on-flyspell ()
2728 ; "Force flyspell-mode on using a positive arg. For use in hooks."
2730 ; (flyspell-mode 1))
2733 ; Outline-minor-mode key map
2734 (define-prefix-command 'cm-map nil "Outline-")
2736 (define-key cm-map "q" 'outline-hide-sublevels) ; Hide everything but the top-level headings
2737 (define-key cm-map "t" 'outline-hide-body) ; Hide everything but headings (all body lines)
2738 (define-key cm-map "o" 'outline-hide-other) ; Hide other branches
2739 (define-key cm-map "c" 'outline-hide-entry) ; Hide this entry's body
2740 (define-key cm-map "l" 'outline-hide-leaves) ; Hide body lines in this entry and sub-entries
2741 (define-key cm-map "d" 'outline-hide-subtree) ; Hide everything in this entry and sub-entries
2743 (define-key cm-map "a" 'outline-show-all) ; Show (expand) everything
2744 (define-key cm-map "e" 'outline-show-entry) ; Show this heading's body
2745 (define-key cm-map "i" 'outline-show-children) ; Show this heading's immediate child sub-headings
2746 (define-key cm-map "k" 'outline-show-branches) ; Show all sub-headings under this heading
2747 (define-key cm-map "s" 'outline-show-subtree) ; Show (expand) everything in this heading & below
2749 (define-key cm-map "u" 'outline-up-heading) ; Up
2750 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
2751 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
2752 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
2753 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
2754 (global-set-key "\M-o" cm-map)
2755 ; fix up tmux xterm keys
2756 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
2757 (defun fix-up-tmux-keys ()
2758 "Fix up tmux xterm keys"
2761 (let ((x 2) (tkey ""))
2781 ;; ctrl + alt + shift
2783 (setq tkey "C-M-S-"))
2786 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
2787 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
2788 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
2789 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
2791 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
2793 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
2795 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
2797 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
2799 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2801 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
2803 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
2805 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
2807 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
2809 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
2811 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
2813 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
2815 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
2817 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
2819 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
2821 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
2823 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
2825 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
2827 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
2829 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
2831 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
2833 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
2835 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
2837 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
2839 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
2841 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
2848 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
2850 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
2851 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
2852 (if (or (buffer-modified-p)
2853 (verify-visited-file-modtime)
2854 (< (* 8 1024 1024) (buffer-size))
2855 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
2857 (clear-visited-file-modtime)
2859 (ad-activate 'ask-user-about-supersession-threat)
2863 #+BEGIN_SRC emacs-lisp
2867 (or (getenv "EMACS_SERVER_NAME")
2869 (unless (server-running-p)
2870 (global-set-key "\C-xp" 'server-edit)
2877 #+BEGIN_SRC emacs-lisp
2878 (provide 'don-configuration)