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/helm")
15 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/tiny")
16 (add-to-list 'load-path '"~/lib/emacs_el/tiny-tools/lisp/other")
17 (add-to-list 'load-path '"~/lib/emacs_el/auctex/lisp")
18 (add-to-list 'load-path '"~/lib/emacs_el/auctex")
19 (add-to-list 'load-path '"~/lib/emacs_el/ESS/lisp")
20 (add-to-list 'load-path '"~/lib/emacs_el/org-mode/lisp")
21 (add-to-list 'load-path '"~/lib/emacs_el/auctex-beamer")
22 (add-to-list 'load-path '"~/lib/emacs_el/magit-annex")
23 (add-to-list 'load-path '"~/lib/emacs_el/polymode")
27 ** package repositories and package manager
28 #+BEGIN_SRC emacs-lisp
30 (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
31 ("melpa" . "https://melpa.org/packages/")
32 ("org" . "http://orgmode.org/elpa/") ))
34 ** [[https://github.com/jwiegley/use-package/][use-package]]
35 #+BEGIN_SRC emacs-lisp
36 (require 'use-package)
40 #+BEGIN_SRC emacs-lisp
48 #+BEGIN_SRC emacs-lisp
49 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
50 ;; execute conditional code when loading libraries
51 (defmacro with-library (symbol &rest body)
52 `(when (require ,symbol nil t)
54 (put 'with-library 'lisp-indent-function 1)
59 #+BEGIN_SRC emacs-lisp
60 (setq global-mark-ring-max 128
64 (defun don/minibuffer-setup-hook ()
65 (setq gc-cons-threshold most-positive-fixnum))
67 (defun don/minibuffer-exit-hook ()
68 (setq gc-cons-threshold 1048576))
70 (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
71 (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
75 #+BEGIN_SRC emacs-lisp
78 :diminish flyspell-mode 🐝
80 (add-hook 'message-mode-hook 'turn-on-flyspell)
81 (add-hook 'text-mode-hook 'turn-on-flyspell)
82 (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
83 (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
84 (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
86 (setq ispell-program-name "ispell")
91 #+BEGIN_SRC emacs-lisp
96 #+BEGIN_SRC emacs-lisp
97 ;; (use-package eyebrowse
99 ;; :diminish eyebrowse-mode
100 ;; :init (setq eyebrowse-keymap-prefix (kbd "C-c C-\\"))
102 ;; (setq eyebrowse-wrap-around t)
103 ;; (eyebrowse-mode t)
105 ;; (defun my/eyebrowse-new-window-config ()
109 ;; ;; start at 1 run till 0
110 ;; (let ((j (mod (+ i 1) 10)))
111 ;; (when (and (not done)
112 ;; (not (eyebrowse--window-config-present-p j)))
113 ;; (eyebrowse-switch-to-window-config j)
114 ;; (call-interactively 'eyebrowse-rename-window-config2 j)
119 ;; ;; I don't use latex-preview-pane
120 ;; ;; (require 'latex-preview-pane)
121 ;; ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
122 ;; ;; ;; latex-preview-pane uses window-parameters which are
123 ;; ;; ;; not preserved by eyebrowse, so we close the preview
124 ;; ;; ;; pane before switching, it will be regenerated when we
125 ;; ;; ;; edit the TeX file.
126 ;; ;; (when (lpp/window-containing-preview)
127 ;; ;; (delete-window (lpp/window-containing-preview))))
129 ;; ;; (add-to-list 'eyebrowse-pre-window-switch-hook
130 ;; ;; #'my/close-latex-preview-pane-before-eyebrowse-switch)
132 ;; ;; (my/set-menu-key "[" #'my/eyebrowse-new-window-config)
133 ;; ;; (my/set-menu-key ";" #'eyebrowse-prev-window-config)
134 ;; ;; (my/set-menu-key "'" #'eyebrowse-next-window-config)
135 ;; ;; (my/set-menu-key "]" #'eyebrowse-close-window-config)
136 ;; ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
144 #+BEGIN_SRC emacs-lisp
145 (defun my/vsplit-last-buffer ()
146 "Split the window vertically and display the previous buffer."
148 (split-window-vertically)
150 (switch-to-next-buffer))
152 (defun my/hsplit-last-buffer ()
153 "Split the window horizontally and display the previous buffer."
155 (split-window-horizontally)
157 (switch-to-next-buffer))
159 (bind-key "C-x 2" 'my/vsplit-last-buffer)
160 (bind-key "C-x 3" 'my/hsplit-last-buffer)
162 (setq split-width-threshold 100)
163 (setq split-height-threshold 60)
165 (defun my/split-window-prefer-vertically (window)
166 "If there's only one window (excluding any possibly active
167 minibuffer), then split the current window horizontally."
168 (if (and (one-window-p t)
169 (not (active-minibuffer-window))
170 ( < (frame-width) (frame-height))
172 (let ((split-width-threshold nil))
173 (split-window-sensibly window))
174 (split-window-sensibly window)))
176 (setq split-window-preferred-function #'my/split-window-prefer-vertically)
177 (setq window-combination-resize t)
180 *** Compilation window
182 If there is no compilation window, open one at the bottom, spanning
183 the complete width of the frame. Otherwise, reuse existing window. In
184 the former case, if there was no error the window closes
187 #+BEGIN_SRC emacs-lisp
188 (add-to-list 'display-buffer-alist
189 `(,(rx bos "*compilation*" eos)
190 (display-buffer-reuse-window
191 display-buffer-in-side-window)
192 (reusable-frames . visible)
194 (window-height . 0.4)))
197 #+BEGIN_SRC emacs-lisp
198 (defun my/compilation-exit-autoclose (status code msg)
199 ;; If M-x compile exists with a 0
200 (when (and (eq status 'exit) (zerop code))
201 ;; and delete the *compilation* window
202 (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
203 (when (and (not (window-at-side-p compilation-window 'top))
204 (window-at-side-p compilation-window 'left)
205 (window-at-side-p compilation-window 'right))
206 (delete-window compilation-window))))
207 ;; Always return the anticipated result of compilation-exit-message-function
210 ;; Specify my function (maybe I should have done a lambda function)
211 (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
214 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
215 value, the compilation buffer scrolls automatically to follow the
216 output. If the value is ~first-error~, scrolling stops when the first
217 error appears, leaving point at that error. For any other non-nil
218 value, scrolling continues until there is no more output.
220 #+BEGIN_SRC emacs-lisp
221 (setq compilation-scroll-output 'first-error)
224 ** Mode line cleaning
226 #+BEGIN_SRC emacs-lisp
227 (use-package diminish
232 #+BEGIN_SRC emacs-lisp
239 #+BEGIN_SRC emacs-lisp
242 :bind ("C-c C-SPC" . avy-goto-word-1)
244 (setq avy-background t)
245 (key-chord-define-global "jj" #'avy-goto-word-1)))
251 #+BEGIN_SRC emacs-lisp
252 (use-package yasnippet
254 :diminish yas-minor-mode
257 (setq yas-verbosity 1)
258 (define-key yas-minor-mode-map (kbd "<tab>") nil)
259 (define-key yas-minor-mode-map (kbd "TAB") nil)
260 (define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)
266 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
268 #+BEGIN_SRC emacs-lisp
269 (use-package helm-flx
272 ;; these are helm configs, but they kind of fit here nicely
273 (setq helm-M-x-fuzzy-match t
274 helm-bookmark-show-location t
275 helm-buffers-fuzzy-matching t
276 helm-completion-in-region-fuzzy-match t
277 helm-file-cache-fuzzy-match t
278 helm-imenu-fuzzy-match t
279 helm-mode-fuzzy-match t
280 helm-locate-fuzzy-match nil
282 helm-recentf-fuzzy-match nil
283 helm-semantic-fuzzy-match t)
290 #+BEGIN_SRC emacs-lisp
292 (use-package tinyprocmail
294 :config (with-library 'tinyprocmail
295 ;; (setq tinyprocmail--procmail-version "v3.22")
296 (add-hook 'tinyprocmail--load-hook 'tinyprocmail-install))
301 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
304 :bind (("C-x g" . magit-status)
305 ("C-x C-g" . magit-status))
307 ;; don't verify where we are pushing
308 (setq magit-push-always-verify nil)
309 ;; refine diffs always (hilight words)
310 (setq magit-diff-refine-hunk nil)
313 (append '("~/lib/emacs_el/magit-annex")
317 (append '("~/lib/emacs_el/magit-vcsh")
320 (use-package magit-annex
323 (use-package magit-vcsh
329 #+BEGIN_SRC emacs-lisp
330 (require 'cperl-mode)
331 ;; Use c-mode for perl .xs files
332 (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
333 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
334 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
335 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
336 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
339 cperl-auto-newline nil
340 cperl-auto-newline-after-colon nil
341 cperl-continued-statement-offset 4
342 cperl-brace-offset -1
343 cperl-continued-brace-offset 0
344 cperl-label-offset -4
345 cperl-highlight-variables-indiscriminately t
346 cperl-electric-lbrace-space nil
347 cperl-indent-parens-as-block nil
348 cperl-close-paren-offset -1
349 cperl-tab-always-indent t)
350 ;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
354 #+BEGIN_SRC emacs-lisp
359 (define-key global-map [remap find-file] 'helm-find-files)
360 (define-key global-map [remap occur] 'helm-occur)
361 (define-key global-map [remap list-buffers] 'helm-buffers-list)
362 (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
363 (global-set-key (kbd "M-x") 'helm-M-x)
364 (unless (boundp 'completion-in-region-function)
365 (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
366 (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
367 (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP"))))
371 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
376 #+BEGIN_SRC emacs-lisp
377 (add-to-list 'tramp-methods '("vcsh"
378 (tramp-login-program "vcsh")
382 (tramp-remote-shell "/bin/sh")
383 (tramp-remote-shell-args
387 #+BEGIN_SRC emacs-lisp
391 (setq-default reftex-default-bibliography
392 '("~/projects/research/references.bib")))
395 #+BEGIN_SRC emacs-lisp
400 (add-to-list 'LaTeX-fill-excluded-macros
402 (add-to-list 'TeX-style-path '"/home/don/lib/emacs_el/auctex/style")
403 ;; REFTEX (much enhanced management of cross-ref, labels, etc)
404 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
405 ; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
406 ; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
407 ; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
408 ; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
409 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
410 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
411 (add-hook 'LaTeX-mode-hook 'outline-minor-mode) ; with AUCTeX LaTeX mode
412 (add-hook 'latex-mode-hook 'outline-minor-mode) ; with Emacs latex mode
414 (setq-default reftex-plug-into-AUCTeX t)
415 ;; support fake section headers
416 (setq TeX-outline-extra
422 ;; add font locking to the headers
423 (font-lock-add-keywords
425 '(("^%\\(chapter\\|\\(sub\\|subsub\\)?section\\|paragraph\\)"
426 0 'font-lock-keyword-face t)
427 ("^%chapter{\\(.*\\)}" 1 'font-latex-sectioning-1-face t)
428 ("^%section{\\(.*\\)}" 1 'font-latex-sectioning-2-face t)
429 ("^%subsection{\\(.*\\)}" 1 'font-latex-sectioning-3-face t)
430 ("^%subsubsection{\\(.*\\)}" 1 'font-latex-sectioning-4-face t)
431 ("^%paragraph{\\(.*\\)}" 1 'font-latex-sectioning-5-face t)))
433 ;; use smart quotes by default instead of `` and ''
434 ;; taken from http://kieranhealy.org/esk/kjhealy.html
435 (setq TeX-open-quote "“")
436 (setq TeX-close-quote "”")
438 ;; (TeX-add-style-hook
443 ;; (custom-set-variables
444 ;; '(font-latex-user-keyword-classes
447 ;; font-lock-function-name-face 2 (command 1 t))))
449 (setq-default TeX-parse-self t)
450 (setq-default TeX-auto-save t)
451 (setq-default TeX-master nil)
457 (if (boundp 'reftex-ref-style-alist)
459 'reftex-ref-style-alist
460 '("Cleveref" "cleveref"
461 (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
462 (reftex-ref-style-activate "Cleveref")
464 '("cref" TeX-arg-ref)
465 '("Cref" TeX-arg-ref)
466 '("cpageref" TeX-arg-ref)
467 '("Cpageref" TeX-arg-ref)))))
469 (use-package font-latex
471 (setq font-latex-match-reference-keywords
497 #+BEGIN_SRC emacs-lisp
498 (require 'org-mode-configuration)
501 #+BEGIN_SRC emacs-lisp
505 (use-package calfw-org
508 (use-package org-gcal
510 :config '((if (file-readable-p "~/.hide/org_gcal.el")
511 (load-file "~/.hide/org_gcal.el"))
516 #+BEGIN_SRC emacs-lisp
519 :config (require 'ess_configuration))
523 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
525 #+BEGIN_SRC emacs-lisp
526 (use-package rainbow-mode
527 ;; add ess to the x major mode
528 :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
529 (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
534 #+BEGIN_SRC emacs-lisp
535 (use-package polymode
538 (use-package poly-noweb)
539 (use-package poly-markdown)
540 :mode ("\\.Snw" . poly-noweb+r-mode)
541 :mode ("\\.Rnw" . poly-noweb+r-mode)
542 :mode ("\\.Rmd" . poly-markdown+r-mode)
548 #+BEGIN_SRC emacs-lisp
549 (use-package outline-magic)
552 ** Override other things
553 #+BEGIN_SRC emacs-lisp
554 ; apparently things like to step on C-;, so we'll use a hack from
555 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
557 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
559 ; use iedit everywhere
560 (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
561 ;; use outline mode keybindings everywhere
562 ;; (define-key my-keys-minor-mode-map (kbd "C-;") 'my/mydra-outline/body)
564 (define-minor-mode my-keys-minor-mode
565 "A minor mode so that my key settings override annoying major modes."
566 t " my-keys" 'my-keys-minor-mode-map)
568 (my-keys-minor-mode 1)
569 (defun my-minibuffer-setup-hook ()
570 (my-keys-minor-mode 0))
572 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
573 (defadvice load (after give-my-keybindings-priority)
574 "Try to ensure that my keybindings always have priority."
575 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
576 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
577 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
578 (add-to-list 'minor-mode-map-alist mykeys))))
582 * Misc (uncharacterized)
583 #+BEGIN_SRC emacs-lisp
584 (setq bibtex-user-optional-fields (quote (("annote" "Personal annotation (ignored)") ("abstract" "") ("pmid" "") ("doi" ""))))
585 (setq calendar-latitude 40.11)
586 (setq calendar-longitude -88.24)
587 (setq case-fold-search t)
588 (setq confirm-kill-emacs (quote y-or-n-p))
589 (setq cperl-lazy-help-time nil)
590 (setq debian-changelog-mailing-address "don@debian.org")
592 (setq display-time-24hr-format t)
593 (setq display-time-day-and-date t)
594 (display-time-mode 1)
595 (setq font-latex-fontify-script nil)
596 (setq font-latex-fontify-sectioning (quote color))
597 (setq font-latex-script-display (quote (nil)))
598 (global-auto-revert-mode 1)
599 (global-font-lock-mode 1)
601 (setq log-edit-keep-buffer t)
602 (setq mail-user-agent (quote sendmail-user-agent))
603 (setq markdown-enable-math t)
604 (setq markdown-follow-wiki-link-on-enter nil)
605 (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
606 (setq post-email-address "don@donarmstrong.com")
607 (setq post-kill-quoted-sig nil)
608 (setq post-mail-message "mutt\\(ng\\|\\)-[a-z0-9]+-[0-9]+-.*")
609 (setq post-uses-fill-mode nil)
610 (setq ps-footer-font-size (quote (8 . 10)))
611 (setq ps-header-font-size (quote (8 . 10)))
612 (setq ps-header-title-font-size (quote (10 . 10)))
613 (setq ps-line-number-color "blue")
614 (setq ps-print-footer t)
615 (setq ps-print-footer-frame nil)
616 (setq ps-print-only-one-header t)
617 (setq safe-local-variable-values (quote ((auto-save-default) (make-backup-files))))
618 (setq sentence-end "[.?!][]\"')]*\\($\\| \\| \\)[
620 (setq sentence-end-double-space nil)
621 ; enable matching parenthesis
624 (setq user-mail-address "don@donarmstrong.com")
625 (setq vc-delete-logbuf-window nil)
626 (setq vc-follow-symlinks t)
628 ;; use git before SVN; use CVS earlier, because I have CVS
629 ;; repositories inside of git directories
630 (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
632 ;; switch back to the old primary selection method
633 (setq x-select-enable-clipboard nil)
634 (setq x-select-enable-primary t)
635 ; (setq mouse-drag-copy-region t)
637 (fset 'perl-mode 'cperl-mode)
638 ;;(load-file "cperl-mode.el")
644 ;;(require 'ecasound)
645 ;;(require 'emacs-wiki)
649 ; (require 'google-weather)
650 ; (require 'org-google-weather)
651 ; (setq-default org-google-weather-format "%i %c, [%l,%h] %s %C")
653 (global-set-key "\C-xp" 'server-edit)
655 (setq-default auto-mode-alist (cons '("\.wml$" .
656 (lambda () (html-mode) (auto-fill-mode)))
660 ; use markdown mode for mdwn files
661 (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
662 (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
665 ;; tramp configuration
666 (setq tramp-use-ssh-controlmaster-options nil)
669 (add-to-list 'auto-mode-alist '("muttng-[a-z0-9]+-[0-9]+-" . message-mode))
670 (add-to-list 'auto-mode-alist '("muttngrc" . muttrc-mode))
672 (add-to-list 'auto-mode-alist '("mutt-[a-z0-9]+-[0-9]+-" . message-mode))
673 (add-to-list 'auto-mode-alist '("muttrc" . muttrc-mode))
674 (defun my-message-mode-settings ()
675 (font-lock-add-keywords nil
676 '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
677 (0 'message-multiply-quoted-text-face))
678 ("^[ \t]*>[ \t]*>.*$"
679 (0 'message-double-quoted-text-face))))
680 (local-set-key (kbd "C-c C-a") 'my-post-attach-file)
682 (add-hook 'message-mode-hook 'my-message-mode-settings)
684 (defun my-post-attach-file ()
685 "Prompt for an attachment."
687 (let ((file (read-file-name "Attach file: " nil nil t nil))
688 (description (string-read "Description: ")))
689 (my-header-attach-file file description)))
691 (symbol-function 'my-post-attach-file)
693 (defun my-header-attach-file (file description)
694 "Attach a FILE to the current message (works with Mutt).
695 Argument DESCRIPTION MIME description."
696 (interactive "fAttach file: \nsDescription: ")
697 (when (> (length file) 0)
702 (goto-char (point-min))
703 (search-forward-regexp "^$")
704 (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
706 (message (concat "Attached '" file "'."))
707 (setq post-has-attachment t))))))
711 (setq mail-yank-prefix "> ")
713 (global-unset-key "\M-g")
714 (global-set-key "\M-g" 'goto-line)
716 ;; self-insert-command hack.
717 ;; Without this, "if<SP>" expands to
720 ;; which really should be,
726 ;(load-library "php-mode")
728 (setq-default c-indent-level 4)
729 (setq-default c-brace-imaginary-offset 0)
730 (setq-default c-brace-offset -4)
731 (setq-default c-argdecl-indent 4)
732 (setq-default c-label-offset -4)
733 (setq-default c-continued-statement-offset 4)
735 (setq-default indent-tabs-mode nil)
736 (setq-default tab-width 4)
739 ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
740 ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
741 ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
742 ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
743 ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
746 (defun insert-date ()
747 "Insert date at point."
749 (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
750 (global-set-key "\C-[d" 'insert-date)
752 (defun unfill-paragraph (arg)
753 "Pull this whole paragraph up onto one line."
755 (let ((fill-column 10000))
756 (fill-paragraph arg))
759 (column-number-mode t)
763 ; (require 'mode-compile)
765 (defadvice server-process-filter (after post-mode-message first activate)
766 "If the buffer is in post mode, overwrite the server-edit
767 message with a post-save-current-buffer-and-exit message."
768 (if (eq major-mode 'post-mode)
770 (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done."))))
771 ; This is also needed to see the magic message. Set to a higher
772 ; number if you have a faster computer or read slower than me.
773 '(font-lock-verbose 1000)
774 ;(setq-default server-temp-file-regexp "mutt\(-\|ng-\)")
775 ; (add-hook 'server-switch-hook
776 ; (function (lambda()
777 ; (cond ((string-match "Post" mode-name)
779 ; set-buffer-file-coding-system 'utf-8
783 (add-hook 'post-mode-hook
786 ; abbrev mode settings
787 ; load abbreviations from
788 (setq abbrev-file-name
789 "~/.emacs_abbrev_def")
791 ; read the abbrev file if it exists
792 (if (file-exists-p abbrev-file-name)
793 (quietly-read-abbrev-file))
795 ; for now, use abbrev mode everywhere
796 (setq default-abbrev-mode t)
799 (defun insert-function-documentation ()
800 "Insert function documentation"
802 (insert-file-contents "/home/don/lib/templates/perl_function_documentation" nil))
803 (global-set-key "\M-f" 'insert-function-documentation)
805 (eval-after-load "lilypond-mode"
807 (load-library "lyqi-mode")
808 (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
810 (autoload 'spamassassin-mode "spamassassin-mode" nil t)
812 (desktop-load-default)
816 ;; custom-set-faces was added by Custom.
817 ;; If you edit it by hand, you could mess it up, so be careful.
818 ;; Your init file should contain only one such instance.
819 ;; If there is more than one, they won't work right.
820 '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
823 (put 'upcase-region 'disabled nil)
824 (put 'downcase-region 'disabled nil)
825 (put 'narrow-to-region 'disabled nil)
827 ; (defun turn-on-flyspell ()
828 ; "Force flyspell-mode on using a positive arg. For use in hooks."
833 ; Outline-minor-mode key map
834 (define-prefix-command 'cm-map nil "Outline-")
836 (define-key cm-map "q" 'hide-sublevels) ; Hide everything but the top-level headings
837 (define-key cm-map "t" 'hide-body) ; Hide everything but headings (all body lines)
838 (define-key cm-map "o" 'hide-other) ; Hide other branches
839 (define-key cm-map "c" 'hide-entry) ; Hide this entry's body
840 (define-key cm-map "l" 'hide-leaves) ; Hide body lines in this entry and sub-entries
841 (define-key cm-map "d" 'hide-subtree) ; Hide everything in this entry and sub-entries
843 (define-key cm-map "a" 'show-all) ; Show (expand) everything
844 (define-key cm-map "e" 'show-entry) ; Show this heading's body
845 (define-key cm-map "i" 'show-children) ; Show this heading's immediate child sub-headings
846 (define-key cm-map "k" 'show-branches) ; Show all sub-headings under this heading
847 (define-key cm-map "s" 'show-subtree) ; Show (expand) everything in this heading & below
849 (define-key cm-map "u" 'outline-up-heading) ; Up
850 (define-key cm-map "n" 'outline-next-visible-heading) ; Next
851 (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
852 (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
853 (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
854 (global-set-key "\M-o" cm-map)
858 (setq-default debian-changelog-mailing-address "don@debian.org")
859 (setq-default debian-changelog-full-name "Don Armstrong")
861 ; ediff configuration
862 ; don't use the multi-window configuration
863 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
867 (define-key global-map (kbd "C-;") 'iedit-mode)
868 (global-set-key (kbd "C-;") 'iedit-mode)
870 ; fix up css mode to not be silly
871 ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
872 (setq cssm-indent-level 4)
873 (setq cssm-newline-before-closing-bracket t)
874 (setq cssm-indent-function #'cssm-c-style-indenter)
875 (setq cssm-mirror-mode nil)
877 (require 'multi-web-mode)
878 (setq mweb-default-major-mode 'html-mode)
879 (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
880 (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
881 (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
882 (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
883 (multi-web-global-mode 1)
885 ;;; alias the new `flymake-report-status-slim' to
886 ;;; `flymake-report-status'
887 (defalias 'flymake-report-status 'flymake-report-status-slim)
888 (defun flymake-report-status-slim (e-w &optional status)
889 "Show \"slim\" flymake status in mode line."
891 (setq flymake-mode-line-e-w e-w))
893 (setq flymake-mode-line-status status))
894 (let* ((mode-line " Φ"))
895 (when (> (length flymake-mode-line-e-w) 0)
896 (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
897 (setq mode-line (concat mode-line flymake-mode-line-status))
898 (setq flymake-mode-line mode-line)
899 (force-mode-line-update)))
901 ; load sql-indent when sql is loaded
902 (eval-after-load "sql"
903 '(load-library "sql-indent"))
905 ; fix up tmux xterm keys
906 ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
907 (defun fix-up-tmux-keys ()
908 "Fix up tmux xterm keys"
911 (let ((x 2) (tkey ""))
931 ;; ctrl + alt + shift
933 (setq tkey "C-M-S-"))
936 (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
937 (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
938 (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
939 (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
941 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
943 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
945 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
947 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
949 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
951 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
953 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
955 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
957 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
959 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
961 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
963 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
965 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
967 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
969 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
971 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
973 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
975 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
977 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
979 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
981 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
983 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
985 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
987 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
989 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
991 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
998 ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
1000 ; procmailmode configuration
1001 (load "procmail_mode")
1003 (load "mode-line-cleaner")
1005 (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
1006 "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
1007 (if (or (buffer-modified-p)
1008 (verify-visited-file-modtime)
1009 (< (* 8 1024 1024) (buffer-size))
1010 (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
1012 (clear-visited-file-modtime)
1014 (ad-activate 'ask-user-about-supersession-threat)
1016 ; apparently things like to step on C-;, so we'll use a hack from
1017 ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
1019 (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
1021 ; use iedit everywhere
1022 (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
1024 (define-minor-mode my-keys-minor-mode
1025 "A minor mode so that my key settings override annoying major modes."
1026 t " my-keys" 'my-keys-minor-mode-map)
1028 (my-keys-minor-mode 1)
1029 (defun my-minibuffer-setup-hook ()
1030 (my-keys-minor-mode 0))
1032 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
1033 (defadvice load (after give-my-keybindings-priority)
1034 "Try to ensure that my keybindings always have priority."
1035 (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
1036 (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
1037 (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
1038 (add-to-list 'minor-mode-map-alist mykeys))))
1040 (global-set-key "\M- " 'hippie-expand)
1045 #+BEGIN_SRC emacs-lisp
1046 (provide 'don-configuration)