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)
12 #+BEGIN_SRC emacs-lisp
13 (add-to-list 'load-path '"~/lib/emacs_el/")
14 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/tiny")
15 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/other")
16 (add-to-list 'load-path '"~/lib/emacs_el/magit-annex")
20 ** package repositories and package manager
21 #+BEGIN_SRC emacs-lisp
23 (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
24 ("melpa" . "https://melpa.org/packages/")
25 ("org" . "http://orgmode.org/elpa/") ))
27 ** [[https://github.com/jwiegley/use-package/][use-package]]
28 #+BEGIN_SRC emacs-lisp
29 (require 'use-package)
33 #+BEGIN_SRC emacs-lisp
41 #+BEGIN_SRC emacs-lisp
42 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
43 ;; execute conditional code when loading libraries
44 (defmacro with-library (symbol &rest body)
45 `(when (require ,symbol nil t)
47 (put 'with-library 'lisp-indent-function 1)
52 #+BEGIN_SRC emacs-lisp
53 (setq global-mark-ring-max 128
57 (defun don/minibuffer-setup-hook ()
58 (setq gc-cons-threshold most-positive-fixnum))
60 (defun don/minibuffer-exit-hook ()
61 (setq gc-cons-threshold 1048576))
63 (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
64 (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
68 #+BEGIN_SRC emacs-lisp
71 :diminish flyspell-mode 🐝
73 (add-hook 'message-mode-hook 'turn-on-flyspell)
74 (add-hook 'text-mode-hook 'turn-on-flyspell)
75 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
76 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
77 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
79 (setq ispell-program-name "ispell")
84 #+BEGIN_SRC emacs-lisp
89 #+BEGIN_SRC emacs-lisp
90 ;; (use-package eyebrowse
92 ;; :diminish eyebrowse-mode
93 ;; :init (setq eyebrowse-keymap-prefix (kbd "C-c C-\\"))
95 ;; (setq eyebrowse-wrap-around t)
98 ;; (defun my/eyebrowse-new-window-config ()
102 ;; ;; start at 1 run till 0
103 ;; (let ((j (mod (+ i 1) 10)))
104 ;; (when (and (not done)
105 ;; (not (eyebrowse--window-config-present-p j)))
106 ;; (eyebrowse-switch-to-window-config j)
107 ;; (call-interactively 'eyebrowse-rename-window-config2 j)
112 ;; ;; I don't use latex-preview-pane
113 ;; ;; (require 'latex-preview-pane)
114 ;; ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
115 ;; ;; ;; latex-preview-pane uses window-parameters which are
116 ;; ;; ;; not preserved by eyebrowse, so we close the preview
117 ;; ;; ;; pane before switching, it will be regenerated when we
118 ;; ;; ;; edit the TeX file.
119 ;; ;; (when (lpp/window-containing-preview)
120 ;; ;; (delete-window (lpp/window-containing-preview))))
122 ;; ;; (add-to-list 'eyebrowse-pre-window-switch-hook
123 ;; ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
125 ;; ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
126 ;; ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
127 ;; ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
128 ;; ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
129 ;; ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
137 #+BEGIN_SRC emacs-lisp
138 (defun my/vsplit-last-buffer ()
139 "Split the window vertically and display the previous buffer."
141 (split-window-vertically)
143 (switch-to-next-buffer))
145 (defun my/hsplit-last-buffer ()
146 "Split the window horizontally and display the previous buffer."
148 (split-window-horizontally)
150 (switch-to-next-buffer))
152 (bind-key "C-x 2" 'my/vsplit-last-buffer)
153 (bind-key "C-x 3" 'my/hsplit-last-buffer)
155 (setq split-width-threshold 100)
156 (setq split-height-threshold 60)
158 (defun my/split-window-prefer-vertically (window)
159 "If there's only one window (excluding any possibly active
160 minibuffer), then split the current window horizontally."
161 (if (and (one-window-p t)
162 (not (active-minibuffer-window))
163 ( < (frame-width) (frame-height))
165 (let ((split-width-threshold nil))
166 (split-window-sensibly window))
167 (split-window-sensibly window)))
169 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
170 (setq window-combination-resize t)
173 *** Compilation window
175 If there is no compilation window, open one at the bottom, spanning
176 the complete width of the frame. Otherwise, reuse existing window. In
177 the former case, if there was no error the window closes
180 #+BEGIN_SRC emacs-lisp
181 (add-to-list 'display-buffer-alist
182 `(,(rx bos "*compilation*" eos)
183 (display-buffer-reuse-window
184 display-buffer-in-side-window)
185 (reusable-frames . visible)
187 (window-height . 0.4)))
190 #+BEGIN_SRC emacs-lisp
191 (defun my/compilation-exit-autoclose (status code msg)
192 ;; If M-x compile exists with a 0
193 (when (and (eq status 'exit) (zerop code))
194 ;; and delete the *compilation* window
195 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
196 (when (and (not (window-at-side-p compilation-window 'top))
197 (window-at-side-p compilation-window 'left)
198 (window-at-side-p compilation-window 'right))
199 (delete-window compilation-window))))
200 ;; Always return the anticipated result of compilation-exit-message-function
203 ;; Specify my function (maybe I should have done a lambda function)
204 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
207 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
208 value, the compilation buffer scrolls automatically to follow the
209 output. If the value is ~first-error~, scrolling stops when the first
210 error appears, leaving point at that error. For any other non-nil
211 value, scrolling continues until there is no more output.
213 #+BEGIN_SRC emacs-lisp
214 (setq compilation-scroll-output 'first-error)
217 ** Mode line cleaning
219 #+BEGIN_SRC emacs-lisp
220 (use-package diminish
225 #+BEGIN_SRC emacs-lisp
232 #+BEGIN_SRC emacs-lisp
235 :bind ("C-c C-SPC" . avy-goto-word-1)
237 (setq avy-background t)
238 (key-chord-define-global "jj" #'avy-goto-word-1)))
244 #+BEGIN_SRC emacs-lisp
245 (use-package yasnippet
247 :diminish yas-minor-mode
250 (setq yas-verbosity 1)
251 (define-key yas-minor-mode-map (kbd "<tab>") nil)
252 (define-key yas-minor-mode-map (kbd "TAB") nil)
253 (define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)
259 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
261 #+BEGIN_SRC emacs-lisp
262 (use-package helm-flx
265 ;; these are helm configs, but they kind of fit here nicely
266 (setq helm-M-x-fuzzy-match t
267 helm-bookmark-show-location t
268 helm-buffers-fuzzy-matching t
269 helm-completion-in-region-fuzzy-match t
270 helm-file-cache-fuzzy-match t
271 helm-imenu-fuzzy-match t
272 helm-mode-fuzzy-match t
273 helm-locate-fuzzy-match nil
275 helm-recentf-fuzzy-match nil
276 helm-semantic-fuzzy-match t)
283 #+BEGIN_SRC emacs-lisp
285 (use-package tinyprocmail
287 :config (with-library 'tinyprocmail
288 ;; (setq tinyprocmail--procmail-version "v3.22")
289 (add-hook 'tinyprocmail--load-hook 'tinyprocmail-install))
294 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
297 :bind (("C-x g" . magit-status)
298 ("C-x C-g" . magit-status))
300 ;; don't verify where we are pushing
301 (setq magit-push-always-verify nil)
302 ;; refine diffs always (hilight words)
303 (setq magit-diff-refine-hunk nil)
306 (append '("~/lib/emacs_el/magit-annex")
310 (append '("~/lib/emacs_el/magit-vcsh")
313 (use-package magit-annex
316 (use-package magit-vcsh
317 :ensure f ; currently not in melpa, so don't try to install
322 #+BEGIN_SRC emacs-lisp
323 (require 'cperl-mode)
324 ;; Use c-mode for perl .xs files
325 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
326 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
327 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
328 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
329 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
332 cperl-auto-newline nil
333 cperl-auto-newline-after-colon nil
334 cperl-continued-statement-offset 4
335 cperl-brace-offset -1
336 cperl-continued-brace-offset 0
337 cperl-label-offset -4
338 cperl-highlight-variables-indiscriminately t
339 cperl-electric-lbrace-space nil
340 cperl-indent-parens-as-block nil
341 cperl-close-paren-offset -1
342 cperl-tab-always-indent t)
343 ;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
347 #+BEGIN_SRC emacs-lisp
352 (define-key global-map [remap find-file] 'helm-find-files)
353 (define-key global-map [remap occur] 'helm-occur)
354 (define-key global-map [remap list-buffers] 'helm-buffers-list)
355 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
356 (global-set-key (kbd "M-x") 'helm-M-x)
357 (unless (boundp 'completion-in-region-function)
358 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
359 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
360 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
364 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
369 #+BEGIN_SRC emacs-lisp
370 (add-to-list 'tramp-methods '("vcsh"
371 (tramp-login-program "vcsh")
375 (tramp-remote-shell "/bin/sh")
376 (tramp-remote-shell-args
380 #+BEGIN_SRC emacs-lisp
384 (setq-default reftex-default-bibliography
385 '("~/projects/research/references.bib")))
388 #+BEGIN_SRC emacs-lisp
393 ; (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
394 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
395 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
396 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
397 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
398 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
399 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
400 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
401 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
402 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
403 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
405 (setq-default reftex-plug-into-AUCTeX t)
406 ;; support fake section headers
407 (setq TeX-outline-extra
413 ;; add font locking to the headers
414 (font-lock-add-keywords
416 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
417 0 'font-lock-keyword-face t)
418 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
419 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
420 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
421 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
422 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
424 ;; use smart quotes by default instead of `` and ''
425 ;; taken from http://kieranhealy.org/esk/kjhealy.html
426 (setq TeX-open-quote "“")
427 (setq TeX-close-quote "”")
429 ;; (TeX-add-style-hook
434 ;; (custom-set-variables
435 ;; '(font-latex-user-keyword-classes
438 ;; font-lock-function-name-face 2 (command 1 t))))
440 (setq-default TeX-parse-self t)
441 (setq-default TeX-auto-save t)
442 (setq-default TeX-master nil)
448 (if (boundp 'reftex-ref-style-alist)
450 'reftex-ref-style-alist
451 '("Cleveref" "cleveref"
452 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
453 (reftex-ref-style-activate "Cleveref")
455 '("cref" TeX-arg-ref)
456 '("Cref" TeX-arg-ref)
457 '("cpageref" TeX-arg-ref)
458 '("Cpageref" TeX-arg-ref)))))
461 '(add-to-list 'LaTeX-fill-excluded-macros
464 (use-package font-latex
466 (setq font-latex-match-reference-keywords
492 #+BEGIN_SRC emacs-lisp
493 (require 'org-mode-configuration)
496 #+BEGIN_SRC emacs-lisp
500 (use-package calfw-org
503 (use-package org-gcal
505 :config '((if (file-readable-p "~/.hide/org_gcal.el")
506 (load-file "~/.hide/org_gcal.el"))
511 #+BEGIN_SRC emacs-lisp
514 :config (require 'ess_configuration))
518 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
520 #+BEGIN_SRC emacs-lisp
521 (use-package rainbow-mode
522 ;; add ess to the x major mode
523 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
524 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
529 #+BEGIN_SRC emacs-lisp
530 (use-package polymode
533 (use-package poly-noweb)
534 (use-package poly-markdown)
535 :mode ("\\.Snw" . poly-noweb+r-mode)
536 :mode ("\\.Rnw" . poly-noweb+r-mode)
537 :mode ("\\.Rmd" . poly-markdown+r-mode)
543 #+BEGIN_SRC emacs-lisp
544 (use-package outline-magic)
547 #+BEGIN_SRC emacs-lisp
548 (use-package writeroom-mode
549 :config (add-hook 'writeroom-mode-hook 'auto-fill-mode)
552 ** GhostText/Atomic Chrome
553 #+BEGIN_SRC emacs-lisp
554 (use-package atomic-chrome
555 :config (atomic-chrome-start-server)
559 ** Override other things
560 #+BEGIN_SRC emacs-lisp
561 ; apparently things like to step on C-;, so we'll use a hack from
562 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
564 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
566 ; use iedit everywhere
567 (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
568 ;; use outline mode keybindings everywhere
569 ;; (define-key my-keys-minor-mode-map (kbd "C-;") 'my/mydra-outline/body)
571 (define-minor-mode my-keys-minor-mode
572 "A minor mode so that my key settings override annoying major modes."
573 t " my-keys" 'my-keys-minor-mode-map)
575 (my-keys-minor-mode 1)
576 (defun my-minibuffer-setup-hook ()
577 (my-keys-minor-mode 0))
579 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
580 (defadvice load (after give-my-keybindings-priority)
581 "Try to ensure that my keybindings always have priority."
582 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
583 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
584 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
585 (add-to-list 'minor-mode-map-alist mykeys))))
589 * Misc (uncharacterized)
590 #+BEGIN_SRC emacs-lisp
591 (setq bibtex-user-optional-fields (quote (("annote" "Personal annotation (ignored)") ("abstract" "") ("pmid" "") ("doi" ""))))
592 (setq calendar-latitude 40.11)
593 (setq calendar-longitude -88.24)
594 (setq case-fold-search t)
595 (setq confirm-kill-emacs (quote y-or-n-p))
596 (setq cperl-lazy-help-time nil)
597 (setq debian-changelog-mailing-address "don@debian.org")
599 (setq display-time-24hr-format t)
600 (setq display-time-day-and-date t)
601 (display-time-mode 1)
602 (setq font-latex-fontify-script nil)
603 (setq font-latex-fontify-sectioning (quote color))
604 (setq font-latex-script-display (quote (nil)))
605 (global-auto-revert-mode 1)
606 (global-font-lock-mode 1)
608 (setq log-edit-keep-buffer t)
609 (setq mail-user-agent (quote sendmail-user-agent))
610 (setq markdown-enable-math t)
611 (setq markdown-follow-wiki-link-on-enter nil)
612 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
613 (setq post-email-address "don@donarmstrong.com")
614 (setq post-kill-quoted-sig nil)
615 (setq post-mail-message "mutt\\(ng\\|\\)-[a-z0-9]+-[0-9]+-.*")
616 (setq post-uses-fill-mode nil)
617 (setq ps-footer-font-size (quote (8 . 10)))
618 (setq ps-header-font-size (quote (8 . 10)))
619 (setq ps-header-title-font-size (quote (10 . 10)))
620 (setq ps-line-number-color "blue")
621 (setq ps-print-footer t)
622 (setq ps-print-footer-frame nil)
623 (setq ps-print-only-one-header t)
624 (setq safe-local-variable-values (quote ((auto-save-default) (make-backup-files))))
625 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
627 (setq sentence-end-double-space nil)
628 ; enable matching parenthesis
631 (setq user-mail-address "don@donarmstrong.com")
632 (setq vc-delete-logbuf-window nil)
633 (setq vc-follow-symlinks t)
635 ;; use git before SVN; use CVS earlier, because I have CVS
636 ;; repositories inside of git directories
637 (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
639 ;; switch back to the old primary selection method
640 (setq x-select-enable-clipboard nil)
641 (setq x-select-enable-primary t)
642 ; (setq mouse-drag-copy-region t)
644 (fset 'perl-mode 'cperl-mode)
645 ;;(load-file "cperl-mode.el")
651 ;;(require 'ecasound)
652 ;;(require 'emacs-wiki)
656 ; (require 'google-weather)
657 ; (require 'org-google-weather)
658 ; (setq-default org-google-weather-format "%i %c, [%l,%h] %s %C")
660 (global-set-key "\C-xp" 'server-edit)
662 (setq-default auto-mode-alist (cons '("\.wml$" .
663 (lambda () (html-mode) (auto-fill-mode)))
667 ; use markdown mode for mdwn files
668 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
669 (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
672 ;; tramp configuration
673 (setq tramp-use-ssh-controlmaster-options nil)
676 (add-to-list 'auto-mode-alist '("muttng-[a-z0-9]+-[0-9]+-" . message-mode))
677 (add-to-list 'auto-mode-alist '("muttngrc" . muttrc-mode))
679 (add-to-list 'auto-mode-alist '("mutt-[a-z0-9]+-[0-9]+-" . message-mode))
680 (add-to-list 'auto-mode-alist '("muttrc" . muttrc-mode))
681 (defun my-message-mode-settings ()
682 (font-lock-add-keywords nil
683 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
684 (0 'message-multiply-quoted-text-face))
685 ("^[ \t]*>[ \t]*>.*$"
686 (0 'message-double-quoted-text-face))))
687 (local-set-key (kbd "C-c C-a") 'my-post-attach-file)
689 (add-hook 'message-mode-hook 'my-message-mode-settings)
691 (defun my-post-attach-file ()
692 "Prompt for an attachment."
694 (let ((file (read-file-name "Attach file: " nil nil t nil))
695 (description (string-read "Description: ")))
696 (my-header-attach-file file description)))
698 (symbol-function 'my-post-attach-file)
700 (defun my-header-attach-file (file description)
701 "Attach a FILE to the current message (works with Mutt).
702 Argument DESCRIPTION MIME description."
703 (interactive "fAttach file: \nsDescription: ")
704 (when (> (length file) 0)
709 (goto-char (point-min))
710 (search-forward-regexp "^$")
711 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
713 (message (concat "Attached '" file "'."))
714 (setq post-has-attachment t))))))
718 (setq mail-yank-prefix "> ")
720 (global-unset-key "\M-g")
721 (global-set-key "\M-g" 'goto-line)
723 ;; self-insert-command hack.
724 ;; Without this, "if<SP>" expands to
727 ;; which really should be,
733 ;(load-library "php-mode")
735 (setq-default c-indent-level 4)
736 (setq-default c-brace-imaginary-offset 0)
737 (setq-default c-brace-offset -4)
738 (setq-default c-argdecl-indent 4)
739 (setq-default c-label-offset -4)
740 (setq-default c-continued-statement-offset 4)
742 (setq-default indent-tabs-mode nil)
743 (setq-default tab-width 4)
746 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
747 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
748 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
749 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
750 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
753 (defun insert-date ()
754 "Insert date at point."
756 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
757 (global-set-key "\C-[d" 'insert-date)
759 (defun unfill-paragraph (arg)
760 "Pull this whole paragraph up onto one line."
762 (let ((fill-column 10000))
763 (fill-paragraph arg))
766 (column-number-mode t)
770 ; (require 'mode-compile)
772 (defadvice server-process-filter (after post-mode-message first activate)
773 "If the buffer is in post mode, overwrite the server-edit
774 message with a post-save-current-buffer-and-exit message."
775 (if (eq major-mode 'post-mode)
777 (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done."))))
778 ; This is also needed to see the magic message. Set to a higher
779 ; number if you have a faster computer or read slower than me.
780 '(font-lock-verbose 1000)
781 ;(setq-default server-temp-file-regexp "mutt\(-\|ng-\)")
782 ; (add-hook 'server-switch-hook
783 ; (function (lambda()
784 ; (cond ((string-match "Post" mode-name)
786 ; set-buffer-file-coding-system 'utf-8
790 (add-hook 'post-mode-hook
793 ; abbrev mode settings
794 ; load abbreviations from
795 (setq abbrev-file-name
796 "~/.emacs_abbrev_def")
798 ; read the abbrev file if it exists
799 (if (file-exists-p abbrev-file-name)
800 (quietly-read-abbrev-file))
802 ; for now, use abbrev mode everywhere
803 (setq default-abbrev-mode t)
806 (defun insert-function-documentation ()
807 "Insert function documentation"
809 (insert-file-contents "/home/don/lib/templates/perl_function_documentation" nil))
810 (global-set-key "\M-f" 'insert-function-documentation)
812 (eval-after-load "lilypond-mode"
814 (load-library "lyqi-mode")
815 (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
817 (autoload 'spamassassin-mode "spamassassin-mode" nil t)
819 (desktop-load-default)
823 ;; custom-set-faces was added by Custom.
824 ;; If you edit it by hand, you could mess it up, so be careful.
825 ;; Your init file should contain only one such instance.
826 ;; If there is more than one, they won't work right.
827 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
830 (put 'upcase-region 'disabled nil)
831 (put 'downcase-region 'disabled nil)
832 (put 'narrow-to-region 'disabled nil)
834 ; (defun turn-on-flyspell ()
835 ; "Force flyspell-mode on using a positive arg. For use in hooks."
840 ; Outline-minor-mode key map
841 (define-prefix-command 'cm-map nil "Outline-")
843 (define-key cm-map "q" 'hide-sublevels) ; Hide everything but the top-level headings
844 (define-key cm-map "t" 'hide-body) ; Hide everything but headings (all body lines)
845 (define-key cm-map "o" 'hide-other) ; Hide other branches
846 (define-key cm-map "c" 'hide-entry) ; Hide this entry's body
847 (define-key cm-map "l" 'hide-leaves) ; Hide body lines in this entry and sub-entries
848 (define-key cm-map "d" 'hide-subtree) ; Hide everything in this entry and sub-entries
850 (define-key cm-map "a" 'show-all) ; Show (expand) everything
851 (define-key cm-map "e" 'show-entry) ; Show this heading's body
852 (define-key cm-map "i" 'show-children) ; Show this heading's immediate child sub-headings
853 (define-key cm-map "k" 'show-branches) ; Show all sub-headings under this heading
854 (define-key cm-map "s" 'show-subtree) ; Show (expand) everything in this heading & below
856 (define-key cm-map "u" 'outline-up-heading) ; Up
857 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
858 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
859 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
860 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
861 (global-set-key "\M-o" cm-map)
865 (setq-default debian-changelog-mailing-address "don@debian.org")
866 (setq-default debian-changelog-full-name "Don Armstrong")
868 ; ediff configuration
869 ; don't use the multi-window configuration
870 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
874 (define-key global-map (kbd "C-;") 'iedit-mode)
875 (global-set-key (kbd "C-;") 'iedit-mode)
877 ; fix up css mode to not be silly
878 ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
879 (setq cssm-indent-level 4)
880 (setq cssm-newline-before-closing-bracket t)
881 (setq cssm-indent-function #'cssm-c-style-indenter)
882 (setq cssm-mirror-mode nil)
884 (require 'multi-web-mode)
885 (setq mweb-default-major-mode 'html-mode)
886 (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
887 (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
888 (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
889 (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
890 (multi-web-global-mode 1)
892 ;;; alias the new `flymake-report-status-slim' to
893 ;;; `flymake-report-status'
894 (defalias 'flymake-report-status 'flymake-report-status-slim)
895 (defun flymake-report-status-slim (e-w &optional status)
896 "Show \"slim\" flymake status in mode line."
898 (setq flymake-mode-line-e-w e-w))
900 (setq flymake-mode-line-status status))
901 (let* ((mode-line " Φ"))
902 (when (> (length flymake-mode-line-e-w) 0)
903 (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
904 (setq mode-line (concat mode-line flymake-mode-line-status))
905 (setq flymake-mode-line mode-line)
906 (force-mode-line-update)))
908 ; load sql-indent when sql is loaded
909 (eval-after-load "sql"
910 '(load-library "sql-indent"))
912 ; fix up tmux xterm keys
913 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
914 (defun fix-up-tmux-keys ()
915 "Fix up tmux xterm keys"
918 (let ((x 2) (tkey ""))
938 ;; ctrl + alt + shift
940 (setq tkey "C-M-S-"))
943 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
944 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
945 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
946 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
948 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
950 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
952 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
954 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
956 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
958 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
960 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
962 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
964 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
966 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
968 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
970 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
972 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
974 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
976 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
978 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
980 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
982 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
984 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
986 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
988 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
990 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
992 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
994 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
996 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
998 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
1005 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
1007 ; procmailmode configuration
1008 (load "procmail_mode")
1010 (load "mode-line-cleaner")
1012 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
1013 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
1014 (if (or (buffer-modified-p)
1015 (verify-visited-file-modtime)
1016 (< (* 8 1024 1024) (buffer-size))
1017 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
1019 (clear-visited-file-modtime)
1021 (ad-activate 'ask-user-about-supersession-threat)
1023 ; apparently things like to step on C-;, so we'll use a hack from
1024 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
1026 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
1028 ; use iedit everywhere
1029 (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
1031 (define-minor-mode my-keys-minor-mode
1032 "A minor mode so that my key settings override annoying major modes."
1033 t " my-keys" 'my-keys-minor-mode-map)
1035 (my-keys-minor-mode 1)
1036 (defun my-minibuffer-setup-hook ()
1037 (my-keys-minor-mode 0))
1039 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
1040 (defadvice load (after give-my-keybindings-priority)
1041 "Try to ensure that my keybindings always have priority."
1042 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
1043 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
1044 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
1045 (add-to-list 'minor-mode-map-alist mykeys))))
1047 (global-set-key "\M- " 'hippie-expand)
1052 #+BEGIN_SRC emacs-lisp
1053 (provide 'don-configuration)