]> git.donarmstrong.com Git - lib.git/blob - emacs_el/configuration/don-configuration.org
remove outdated library paths
[lib.git] / emacs_el / configuration / don-configuration.org
1 #+PROPERTY: header-args:emacs-lisp :tangle don-configuration.el
2 * Load debugger
3
4 # if for some reason, things get pear-shaped, we want to be able to
5 # enter the debugger by sending -USR2 to emacs
6
7 #+BEGIN_SRC emacs-lisp
8 (setq debug-on-event 'siguser2)
9 #+END_SRC
10 * Add library paths
11
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")
17 #+END_SRC
18
19 * Package management
20 ** package repositories and package manager
21 #+BEGIN_SRC emacs-lisp
22   (require 'package)
23   (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
24                            ("melpa" . "https://melpa.org/packages/")
25                            ("org" . "http://orgmode.org/elpa/") ))
26 #+END_SRC
27 ** [[https://github.com/jwiegley/use-package/][use-package]]
28 #+BEGIN_SRC emacs-lisp
29   (require 'use-package)
30   (package-initialize)
31 #+END_SRC
32 ** Paradox
33 #+BEGIN_SRC emacs-lisp
34   (package-initialize)
35   (use-package paradox
36     :ensure paradox
37   )
38 #+END_SRC
39 * Misc functions
40 ** with-library
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)
46      ,@body))
47 (put 'with-library 'lisp-indent-function 1)
48 #+END_SRC
49
50
51 * Memory
52 #+BEGIN_SRC emacs-lisp
53   (setq global-mark-ring-max 128
54         mark-ring-max 128
55         kill-ring-max 128)
56
57   (defun don/minibuffer-setup-hook ()
58     (setq gc-cons-threshold most-positive-fixnum))
59
60   (defun don/minibuffer-exit-hook ()
61     (setq gc-cons-threshold 1048576))
62
63   (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
64   (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
65 #+END_SRC
66 * Modules
67 ** Flyspell 🐝 
68 #+BEGIN_SRC emacs-lisp
69   (use-package flyspell
70     :ensure t
71     :diminish flyspell-mode 🐝
72     :config
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)
78     :init
79     (setq ispell-program-name "ispell")
80     )
81
82 #+END_SRC
83 ** Winnermode
84 #+BEGIN_SRC emacs-lisp
85   (winner-mode 1)
86 #+END_SRC
87 ** Eyebrowse
88
89 #+BEGIN_SRC emacs-lisp
90   ;; (use-package eyebrowse
91   ;;   :ensure t
92   ;;   :diminish eyebrowse-mode
93   ;;   :init (setq eyebrowse-keymap-prefix (kbd "C-c C-\\"))
94   ;;   :config (progn
95   ;;             (setq eyebrowse-wrap-around t)
96   ;;             (eyebrowse-mode t)
97   ;; 
98   ;;             (defun my/eyebrowse-new-window-config ()
99   ;;               (interactive)
100   ;;               (let ((done nil))
101   ;;                 (dotimes (i 10)
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)
108   ;;                       (setq done t)
109   ;;                       ))
110   ;;                   )))
111   ;; 
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))))
121   ;; 
122   ;;             ;; (add-to-list 'eyebrowse-pre-window-switch-hook
123   ;;             ;;              #'my/close-latex-preview-pane-before-eyebrowse-switch)
124   ;; 
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)
130   ;;             )
131   ;;   )
132 #+END_SRC
133
134 ** Window handling
135
136 *** Splitting
137 #+BEGIN_SRC emacs-lisp
138   (defun my/vsplit-last-buffer ()
139     "Split the window vertically and display the previous buffer."
140     (interactive)
141     (split-window-vertically)
142     (other-window 1 nil)
143     (switch-to-next-buffer))
144
145   (defun my/hsplit-last-buffer ()
146     "Split the window horizontally and display the previous buffer."
147     (interactive)
148     (split-window-horizontally)
149     (other-window 1 nil)
150     (switch-to-next-buffer))
151
152   (bind-key "C-x 2" 'my/vsplit-last-buffer)
153   (bind-key "C-x 3" 'my/hsplit-last-buffer)
154
155   (setq split-width-threshold  100)
156   (setq split-height-threshold 60)
157
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))
164              )
165         (let ((split-width-threshold nil))
166           (split-window-sensibly window))
167       (split-window-sensibly window)))
168
169   (setq split-window-preferred-function #'my/split-window-prefer-vertically)
170   (setq window-combination-resize t)
171 #+END_SRC
172
173 *** Compilation window
174
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
178 automatically.
179
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)
186                  (side            . bottom)
187                  (window-height   . 0.4)))
188 #+END_SRC
189
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
201     (cons msg code))
202
203   ;; Specify my function (maybe I should have done a lambda function)
204   (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
205 #+END_SRC
206
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.
212
213 #+BEGIN_SRC emacs-lisp
214   (setq compilation-scroll-output 'first-error)
215 #+END_SRC
216
217 ** Mode line cleaning
218 *** Diminish
219 #+BEGIN_SRC emacs-lisp
220   (use-package diminish
221     :ensure t)
222 #+END_SRC
223
224 *** Delight 
225 #+BEGIN_SRC emacs-lisp
226   (use-package delight
227     :ensure t)
228 #+END_SRC
229
230 ** Jumping
231 *** Avy
232 #+BEGIN_SRC emacs-lisp
233 (use-package avy
234   :ensure t
235   :bind ("C-c C-SPC" . avy-goto-word-1)
236   :config (progn
237             (setq avy-background t)
238             (key-chord-define-global "jj"  #'avy-goto-word-1)))
239 #+END_SRC
240
241 ** Snippets
242
243 *** Yasnippet
244 #+BEGIN_SRC emacs-lisp
245   (use-package yasnippet
246     :ensure t
247     :diminish yas-minor-mode
248     :config (progn
249               (yas-global-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)
254               ))
255 #+END_SRC
256
257 ** Helm Flx
258
259 [[https://github.com/PythonNut/helm-flx][helm-flx]] implements intelligent helm fuzzy sorting, provided by [[https://github.com/lewang/flx][flx]].
260
261 #+BEGIN_SRC emacs-lisp
262 (use-package helm-flx
263   :ensure t
264   :config (progn
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
274                   helm-quick-update                     t
275                   helm-recentf-fuzzy-match              nil
276                   helm-semantic-fuzzy-match             t)
277             (helm-flx-mode +1)))
278 #+END_SRC
279
280
281 ** Tinyprocmail
282
283 #+BEGIN_SRC emacs-lisp
284   ;; load tinyprocmail
285   (use-package tinyprocmail
286     :ensure f
287     :config (with-library 'tinyprocmail
288               ;; (setq tinyprocmail--procmail-version "v3.22")
289               (add-hook 'tinyprocmail--load-hook 'tinyprocmail-install))
290   )
291 #+END_SRC
292
293 ** Magit
294 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
295   (use-package magit
296     :ensure t
297     :bind (("C-x g" . magit-status)
298            ("C-x C-g" . magit-status))
299     :config
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)
304     ;; load magit-annex
305     (setq load-path
306           (append '("~/lib/emacs_el/magit-annex")
307                   load-path))
308     ;; load magit-vcsh
309     (setq load-path
310           (append '("~/lib/emacs_el/magit-vcsh")
311                   load-path))
312     )
313   (use-package magit-annex
314     :ensure t
315   )
316   (use-package magit-vcsh
317     :ensure f ; currently not in melpa, so don't try to install
318   )
319 #+END_SRC
320
321 ** Perl
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))
330   (setq cperl-hairy t
331         cperl-indent-level 4
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")))
344 #+END_SRC
345
346 ** Helm
347 #+BEGIN_SRC emacs-lisp
348   (use-package helm
349     :ensure t
350     :config
351     (helm-mode 1)
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"))))
361   )
362 #+END_SRC
363 ** Hydra
364 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
365 (require 'don-hydra)
366 #+END_SRC
367
368 ** Tramp
369 #+BEGIN_SRC emacs-lisp
370   (add-to-list 'tramp-methods '("vcsh"
371                                 (tramp-login-program "vcsh")
372                                 (tramp-login-args
373                                  (("enter")
374                                   ("%h")))
375                                 (tramp-remote-shell "/bin/sh")
376                                 (tramp-remote-shell-args
377                                  ("-c"))))
378 #+END_SRC
379 ** Reftex
380 #+BEGIN_SRC emacs-lisp
381   (use-package reftex
382     :ensure t
383     :config
384     (setq-default reftex-default-bibliography
385                     '("~/projects/research/references.bib")))
386 #+END_SRC
387 ** LaTeX
388 #+BEGIN_SRC emacs-lisp
389   (use-package tex
390     :defer t
391     :ensure auctex
392     :config
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
404
405     (setq-default reftex-plug-into-AUCTeX t)
406     ;; support fake section headers
407     (setq TeX-outline-extra
408           '(("%chapter" 1)
409             ("%section" 2)
410             ("%subsection" 3)
411             ("%subsubsection" 4)
412             ("%paragraph" 5)))
413     ;; add font locking to the headers
414     (font-lock-add-keywords
415      'latex-mode
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)))
423
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 "”")
428
429     ;; (TeX-add-style-hook
430     ;;  "latex"
431     ;;  (lambda ()
432     ;;    (TeX-add-symbols
433     ;;     '("DLA" 1))))
434     ;; (custom-set-variables
435     ;;  '(font-latex-user-keyword-classes 
436     ;;    '(("fixme" 
437     ;;       ("DLA" "RZ")
438     ;;       font-lock-function-name-face 2 (command 1 t))))
439     ;; ) 
440     (setq-default TeX-parse-self t)
441     (setq-default TeX-auto-save t)
442     (setq-default TeX-master nil)
443     (eval-after-load
444         "latex"
445       '(TeX-add-style-hook
446         "cleveref"
447         (lambda ()
448           (if (boundp 'reftex-ref-style-alist)
449               (add-to-list
450                'reftex-ref-style-alist
451                '("Cleveref" "cleveref"
452                  (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
453           (reftex-ref-style-activate "Cleveref")
454           (TeX-add-symbols
455            '("cref" TeX-arg-ref)
456            '("Cref" TeX-arg-ref)
457            '("cpageref" TeX-arg-ref)
458            '("Cpageref" TeX-arg-ref)))))
459     (eval-after-load
460         "latex"
461       '(add-to-list 'LaTeX-fill-excluded-macros
462                     '("Sexpr")))
463
464     (use-package font-latex
465       :config
466       (setq font-latex-match-reference-keywords
467             '(
468               ("fref" "{")
469               ("Fref" "{")
470               ("citep" "{")
471               ("citet" "{")
472               ("acs" "{")
473               ("acsp" "{")
474               ("ac" "{")
475               ("acp" "{")
476               ("acl" "{")
477               ("aclp" "{")
478               ("acsu" "{")
479               ("aclu" "{")
480               ("acused" "{")
481               ("DLA" "{")
482               ("RZ" "{")
483               ("OM" "{")
484               ("DL" "{")
485               ("fixme" "{"))
486             )
487       )
488   )
489
490 #+END_SRC
491 ** Org
492 #+BEGIN_SRC emacs-lisp
493   (require 'org-mode-configuration)
494 #+END_SRC
495 *** Org-Gcal
496 #+BEGIN_SRC emacs-lisp
497   (use-package calfw
498     :ensure f
499     )
500   (use-package calfw-org
501     :ensure f
502     )
503   (use-package org-gcal
504     :ensure f
505     :config '((if (file-readable-p "~/.hide/org_gcal.el")
506                   (load-file "~/.hide/org_gcal.el"))
507               )
508     )
509 #+END_SRC
510 ** ESS
511 #+BEGIN_SRC emacs-lisp
512   (use-package ess
513     :ensure t
514     :config (require 'ess_configuration))
515 #+END_SRC
516
517 ** Rainbowmode
518 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
519
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])
525   )
526 #+END_SRC
527
528 ** Polymode
529 #+BEGIN_SRC emacs-lisp
530   (use-package polymode
531     :config
532     (use-package poly-R)
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)
538     )
539 #+END_SRC
540
541 ** Outlining
542 *** Outline magic
543 #+BEGIN_SRC emacs-lisp
544   (use-package outline-magic)
545 #+END_SRC
546 ** Writeroom Mode
547 #+BEGIN_SRC emacs-lisp
548   (use-package writeroom-mode
549     :config (add-hook 'writeroom-mode-hook 'auto-fill-mode)
550     )
551 #+END_SRC
552 ** GhostText/Atomic Chrome
553 #+BEGIN_SRC emacs-lisp
554   (use-package atomic-chrome
555     :config (atomic-chrome-start-server)
556     )
557 #+END_SRC
558 * Keybindings
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
563
564   (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
565
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)
570
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)
574
575   (my-keys-minor-mode 1)
576   (defun my-minibuffer-setup-hook ()
577     (my-keys-minor-mode 0))
578
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))))
586   (ad-activate 'load)
587 #+END_SRC
588
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")
598   (display-time)
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)
607   (icomplete-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 "[.?!][]\"')]*\\($\\|   \\| \\)[    
626   ]*")
627   (setq sentence-end-double-space nil)
628   ; enable matching parenthesis
629   (show-paren-mode 1)
630   (tool-bar-mode -1)
631   (setq user-mail-address "don@donarmstrong.com")
632   (setq vc-delete-logbuf-window nil)
633   (setq vc-follow-symlinks t)
634
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)))
638
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)
643
644   (fset 'perl-mode 'cperl-mode)
645   ;;(load-file "cperl-mode.el")
646
647   (require 'vcl-mode)
648
649   (require 'tex-site)
650   ;;(require 'psvn)
651   ;;(require 'ecasound)
652   ;;(require 'emacs-wiki)
653   (require 'bibtex)
654   (require 'post)
655   ;;(require 'fixme)
656   ; (require 'google-weather)
657   ; (require 'org-google-weather)
658   ; (setq-default org-google-weather-format "%i %c, [%l,%h] %s %C")
659   
660   (global-set-key "\C-xp" 'server-edit)
661
662   (setq-default auto-mode-alist (cons '("\.wml$" . 
663                     (lambda () (html-mode) (auto-fill-mode)))
664                   auto-mode-alist))
665
666
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))
670
671
672   ;; tramp configuration
673   (setq tramp-use-ssh-controlmaster-options nil)
674
675   ; mail configuration
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))
678
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)
688     )
689   (add-hook 'message-mode-hook 'my-message-mode-settings)
690
691   (defun my-post-attach-file ()
692     "Prompt for an attachment."
693     (interactive)
694     (let ((file (read-file-name "Attach file: " nil nil t nil))
695           (description (string-read "Description: ")))
696       (my-header-attach-file file description)))
697
698   (symbol-function 'my-post-attach-file)
699
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)
705       (save-excursion
706         (save-match-data
707           (save-restriction
708             (widen)
709             (goto-char (point-min))
710             (search-forward-regexp "^$")
711             (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
712                             description "\n"))
713             (message (concat "Attached '" file "'."))
714             (setq post-has-attachment t))))))
715
716
717
718   (setq mail-yank-prefix "> ")
719
720   (global-unset-key "\M-g")
721   (global-set-key "\M-g" 'goto-line)
722
723   ;; self-insert-command hack.
724   ;;   Without this, "if<SP>" expands to
725   ;;   if ( -!-) {
726   ;;   }
727   ;;   which really should be,
728   ;;   if (-!-) {
729   ;;   }
730
731
732
733   ;(load-library "php-mode")
734
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)
741   ; tabs are annoying
742   (setq-default indent-tabs-mode nil)
743   (setq-default tab-width 4)
744
745
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))
751
752
753   (defun insert-date ()
754     "Insert date at point."
755     (interactive)
756     (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
757   (global-set-key "\C-[d" 'insert-date)
758
759   (defun unfill-paragraph (arg)
760     "Pull this whole paragraph up onto one line."
761     (interactive "*p")
762     (let ((fill-column 10000))
763       (fill-paragraph arg))
764     )
765
766   (column-number-mode t)
767
768   (server-start)
769
770   ; (require 'mode-compile)
771
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)
776         (message
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)
785   ;                (post-goto-body)))
786   ;             set-buffer-file-coding-system 'utf-8
787   ;             )))
788   ; 
789
790   (add-hook 'post-mode-hook
791         (auto-fill-mode nil)
792         )
793   ; abbrev mode settings
794   ; load abbreviations from 
795   (setq abbrev-file-name       
796         "~/.emacs_abbrev_def")
797
798   ; read the abbrev file if it exists
799   (if (file-exists-p abbrev-file-name)
800       (quietly-read-abbrev-file))
801
802   ; for now, use abbrev mode everywhere
803   (setq default-abbrev-mode t)
804
805
806   (defun insert-function-documentation ()
807     "Insert function documentation"
808     (interactive)
809     (insert-file-contents "/home/don/lib/templates/perl_function_documentation" nil))
810   (global-set-key "\M-f" 'insert-function-documentation)
811
812   (eval-after-load "lilypond-mode" 
813     '(progn
814        (load-library "lyqi-mode")
815        (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
816
817   (autoload 'spamassassin-mode "spamassassin-mode" nil t)
818
819   (desktop-load-default)
820   (desktop-read)
821   '(icomplete-mode on)
822   (custom-set-faces
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")))))
828
829
830   (put 'upcase-region 'disabled nil)
831   (put 'downcase-region 'disabled nil)
832   (put 'narrow-to-region 'disabled nil)
833
834   ; (defun turn-on-flyspell ()
835   ;    "Force flyspell-mode on using a positive arg.  For use in hooks."
836   ;    (interactive)
837   ;    (flyspell-mode 1))
838
839
840    ; Outline-minor-mode key map
841    (define-prefix-command 'cm-map nil "Outline-")
842    ; HIDE
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
849    ; SHOW
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
855    ; MOVE
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)
862
863
864   ; debian stuff
865   (setq-default debian-changelog-mailing-address "don@debian.org")
866   (setq-default debian-changelog-full-name "Don Armstrong")
867
868   ; ediff configuration
869   ; don't use the multi-window configuration
870   (setq ediff-window-setup-function 'ediff-setup-windows-plain)
871
872   ; use iedit
873   (require 'iedit)
874   (define-key global-map (kbd "C-;") 'iedit-mode)
875   (global-set-key  (kbd "C-;") 'iedit-mode)
876
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)
883
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)
891
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."
897     (when e-w
898       (setq flymake-mode-line-e-w e-w))
899     (when status
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)))
907
908   ; load sql-indent when sql is loaded
909   (eval-after-load "sql"
910     '(load-library "sql-indent"))
911
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"
916       (if (getenv "TMUX")
917           (progn
918             (let ((x 2) (tkey ""))
919               (while (<= x 8)
920                 ;; shift
921                 (if (= x 2)
922                     (setq tkey "S-"))
923                 ;; alt
924                 (if (= x 3)
925                     (setq tkey "M-"))
926                 ;; alt + shift
927                 (if (= x 4)
928                     (setq tkey "M-S-"))
929                 ;; ctrl
930                 (if (= x 5)
931                     (setq tkey "C-"))
932                 ;; ctrl + shift
933                 (if (= x 6)
934                     (setq tkey "C-S-"))
935                 ;; ctrl + alt
936                 (if (= x 7)
937                     (setq tkey "C-M-"))
938                 ;; ctrl + alt + shift
939                 (if (= x 8)
940                     (setq tkey "C-M-S-"))
941
942                 ;; arrows
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)))
947                 ;; home
948                 (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
949                 ;; end
950                 (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
951                 ;; page up
952                 (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
953                 ;; page down
954                 (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
955                 ;; insert
956                 (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
957                 ;; delete
958                 (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
959                 ;; f1
960                 (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
961                 ;; f2
962                 (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
963                 ;; f3
964                 (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
965                 ;; f4
966                 (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
967                 ;; f5
968                 (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
969                 ;; f6
970                 (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
971                 ;; f7
972                 (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
973                 ;; f8
974                 (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
975                 ;; f9
976                 (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
977                 ;; f10
978                 (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
979                 ;; f11
980                 (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
981                 ;; f12
982                 (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
983                 ;; f13
984                 (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
985                 ;; f14
986                 (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
987                 ;; f15
988                 (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
989                 ;; f16
990                 (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
991                 ;; f17
992                 (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
993                 ;; f18
994                 (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
995                 ;; f19
996                 (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
997                 ;; f20
998                 (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
999
1000                 (setq x (+ x 1))
1001                 ))
1002             )
1003         )
1004       )
1005   ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
1006
1007   ; procmailmode configuration
1008   (load "procmail_mode")
1009
1010   (load "mode-line-cleaner")
1011
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) "-")))
1018         ad-do-it
1019       (clear-visited-file-modtime)
1020       (not-modified)))
1021   (ad-activate 'ask-user-about-supersession-threat)
1022
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
1025
1026   (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
1027
1028   ; use iedit everywhere
1029   (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
1030
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)
1034
1035   (my-keys-minor-mode 1)
1036   (defun my-minibuffer-setup-hook ()
1037     (my-keys-minor-mode 0))
1038
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))))
1046   (ad-activate 'load)
1047   (global-set-key "\M- " 'hippie-expand)
1048
1049 #+END_SRC
1050
1051 * END
1052 #+BEGIN_SRC emacs-lisp
1053   (provide 'don-configuration)
1054 #+END_SRC