]> git.donarmstrong.com Git - lib.git/blob - emacs_el/configuration/don-configuration.org
require package
[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/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")
24 #+END_SRC
25
26 * Package management
27 ** package repositories and package manager
28 #+BEGIN_SRC emacs-lisp
29   (require 'package)
30   (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
31                            ("melpa" . "https://melpa.org/packages/")
32                            ("org" . "http://orgmode.org/elpa/") ))
33   (package-initialize)
34 #+END_SRC
35 ** [[https://github.com/jwiegley/use-package/][use-package]]
36 #+BEGIN_SRC emacs-lisp
37   (require 'use-package)
38 #+END_SRC
39 ** Paradox
40 #+BEGIN_SRC emacs-lisp
41   (use-package paradox
42     :ensure paradox
43   )
44 #+END_SRC
45 * Misc functions
46 ** with-library
47 #+BEGIN_SRC emacs-lisp
48 ;; From http://www.emacswiki.org/emacs/LoadingLispFiles
49 ;; execute conditional code when loading libraries
50 (defmacro with-library (symbol &rest body)
51   `(when (require ,symbol nil t)
52      ,@body))
53 (put 'with-library 'lisp-indent-function 1)
54 #+END_SRC
55
56
57 * Memory
58 #+BEGIN_SRC emacs-lisp
59   (setq global-mark-ring-max 128
60         mark-ring-max 128
61         kill-ring-max 128)
62
63   (defun don/minibuffer-setup-hook ()
64     (setq gc-cons-threshold most-positive-fixnum))
65
66   (defun don/minibuffer-exit-hook ()
67     (setq gc-cons-threshold 1048576))
68
69   (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
70   (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
71 #+END_SRC
72 * Modules
73 ** Winnermode
74 #+BEGIN_SRC emacs-lisp
75   (winner-mode 1)
76 #+END_SRC
77 ** Eyebrowse
78
79 #+BEGIN_SRC emacs-lisp
80   (use-package eyebrowse
81     :ensure t
82     :diminish eyebrowse-mode
83     :init (setq eyebrowse-keymap-prefix (kbd "C-c C-\\"))
84     :config (progn
85               (setq eyebrowse-wrap-around t)
86               (eyebrowse-mode t)
87
88               (defun my/eyebrowse-new-window-config ()
89                 (interactive)
90                 (let ((done nil))
91                   (dotimes (i 10)
92                     ;; start at 1 run till 0
93                     (let ((j (mod (+ i 1) 10)))
94                       (when (and (not done)
95                                  (not (eyebrowse--window-config-present-p j)))
96                         (eyebrowse-switch-to-window-config j)
97                         (call-interactively 'eyebrowse-rename-window-config2 j)
98                         (setq done t)
99                         ))
100                     )))
101
102               ;; I don't use latex-preview-pane
103               ;; (require 'latex-preview-pane)
104               ;; (defun my/close-latex-preview-pane-before-eyebrowse-switch ()
105               ;;   ;; latex-preview-pane uses window-parameters which are
106               ;;   ;; not preserved by eyebrowse, so we close the preview
107               ;;   ;; pane before switching, it will be regenerated when we
108               ;;   ;; edit the TeX file.
109               ;;   (when (lpp/window-containing-preview)
110               ;;     (delete-window (lpp/window-containing-preview))))
111
112               ;; (add-to-list 'eyebrowse-pre-window-switch-hook
113               ;;              #'my/close-latex-preview-pane-before-eyebrowse-switch)
114
115               ;; (my/set-menu-key "["  #'my/eyebrowse-new-window-config)
116               ;; (my/set-menu-key ";"  #'eyebrowse-prev-window-config)
117               ;; (my/set-menu-key "'"  #'eyebrowse-next-window-config)
118               ;; (my/set-menu-key "]"  #'eyebrowse-close-window-config)
119               ;; (my/set-menu-key "\\" #'eyebrowse-rename-window-config)
120               )
121     )
122 #+END_SRC
123
124 ** Window handling
125
126 *** Splitting
127 #+BEGIN_SRC emacs-lisp
128   (defun my/vsplit-last-buffer ()
129     "Split the window vertically and display the previous buffer."
130     (interactive)
131     (split-window-vertically)
132     (other-window 1 nil)
133     (switch-to-next-buffer))
134
135   (defun my/hsplit-last-buffer ()
136     "Split the window horizontally and display the previous buffer."
137     (interactive)
138     (split-window-horizontally)
139     (other-window 1 nil)
140     (switch-to-next-buffer))
141
142   (bind-key "C-x 2" 'my/vsplit-last-buffer)
143   (bind-key "C-x 3" 'my/hsplit-last-buffer)
144
145   (setq split-width-threshold  100)
146   (setq split-height-threshold 60)
147
148   (defun my/split-window-prefer-horizontally (window)
149     "If there's only one window (excluding any possibly active
150            minibuffer), then split the current window horizontally."
151     (if (and (one-window-p t)
152              (not (active-minibuffer-window))
153              ( > (frame-width) (frame-height))
154              )
155         (let ((split-height-threshold nil))
156           (split-window-sensibly window))
157       (split-window-sensibly window)))
158
159   (setq split-window-preferred-function #'my/split-window-prefer-horizontally)
160   (setq window-combination-resize t)
161 #+END_SRC
162
163 *** Compilation window
164
165 If there is no compilation window, open one at the bottom, spanning
166 the complete width of the frame. Otherwise, reuse existing window. In
167 the former case, if there was no error the window closes
168 automatically.
169
170 #+BEGIN_SRC emacs-lisp
171   (add-to-list 'display-buffer-alist
172                `(,(rx bos "*compilation*" eos)
173                  (display-buffer-reuse-window
174                   display-buffer-in-side-window)
175                  (reusable-frames . visible)
176                  (side            . bottom)
177                  (window-height   . 0.4)))
178 #+END_SRC
179
180 #+BEGIN_SRC emacs-lisp
181   (defun my/compilation-exit-autoclose (status code msg)
182     ;; If M-x compile exists with a 0
183     (when (and (eq status 'exit) (zerop code))
184       ;; and delete the *compilation* window
185       (let ((compilation-window (get-buffer-window (get-buffer "*compilation*"))))
186         (when (and (not (window-at-side-p compilation-window 'top))
187                    (window-at-side-p compilation-window 'left)
188                    (window-at-side-p compilation-window 'right))
189           (delete-window compilation-window))))
190     ;; Always return the anticipated result of compilation-exit-message-function
191     (cons msg code))
192
193   ;; Specify my function (maybe I should have done a lambda function)
194   (setq compilation-exit-message-function #'my/compilation-exit-autoclose)
195 #+END_SRC
196
197 If you change the variable ~compilation-scroll-output~ to a ~non-nil~
198 value, the compilation buffer scrolls automatically to follow the
199 output. If the value is ~first-error~, scrolling stops when the first
200 error appears, leaving point at that error. For any other non-nil
201 value, scrolling continues until there is no more output.
202
203 #+BEGIN_SRC emacs-lisp
204   (setq compilation-scroll-output 'first-error)
205 #+END_SRC
206
207 ** Mode line cleaning
208 *** Diminish
209 #+BEGIN_SRC emacs-lisp
210   (use-package diminish
211     :ensure t)
212 #+END_SRC
213
214 *** Delight 
215 #+BEGIN_SRC emacs-lisp
216   (use-package delight
217     :ensure t)
218 #+END_SRC
219
220 ** Tinyprocmail
221
222 #+BEGIN_SRC emacs-lisp
223   ;; load tinyprocmail
224   (with-library 'tinyprocmail
225     ; (setq tinyprocmail--procmail-version "v3.22")
226     (add-hook 'tinyprocmail--load-hook 'tinyprocmail-install))
227 #+END_SRC
228
229 ** Magit
230 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
231   ; don't verify where we are pushing
232   (setq magit-push-always-verify nil)
233   ;; refine diffs always (hilight words)
234   (setq magit-diff-refine-hunk nil)
235   ;; load magit-annex
236   (setq load-path
237         (append '("~/lib/emacs_el/magit-annex")
238                 load-path))
239   (require 'magit-annex)
240 #+END_SRC
241
242 ** Perl
243 #+BEGIN_SRC emacs-lisp
244   (require 'cperl-mode)
245   ;; Use c-mode for perl .xs files
246   (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
247   (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
248   (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
249   (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
250   (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
251   (setq cperl-hairy t
252         cperl-indent-level 4
253         cperl-auto-newline nil
254         cperl-auto-newline-after-colon nil
255         cperl-continued-statement-offset 4
256         cperl-brace-offset -1
257         cperl-continued-brace-offset 0
258         cperl-label-offset -4
259         cperl-highlight-variables-indiscriminately t
260         cperl-electric-lbrace-space nil
261         cperl-indent-parens-as-block nil
262         cperl-close-paren-offset -1
263         cperl-tab-always-indent t)
264   ;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
265 #+END_SRC
266
267 ** Helm
268 #+BEGIN_SRC emacs-lisp
269 (require 'don-helm)
270 #+END_SRC
271 ** Hydra
272 #+BEGIN_SRC emacs-lisp :tangle don-configuration.el
273 (require 'don-hydra)
274 #+END_SRC
275
276 ** Tramp
277 #+BEGIN_SRC emacs-lisp
278   (add-to-list 'tramp-methods '("vcsh"
279                                 (tramp-login-program "vcsh")
280                                 (tramp-login-args
281                                  (("enter")
282                                   ("%h")))
283                                 (tramp-remote-shell "/bin/sh")
284                                 (tramp-remote-shell-args
285                                  ("-c"))))
286 #+END_SRC
287 ** LaTeX
288 #+BEGIN_SRC emacs-lisp
289   (load "auctex.el" nil t t)
290   (load "preview-latex.el" nil t t)
291   (load "latex.el" nil t t)
292
293   ;; this is in the very newest auctex; avoid for now
294   (add-to-list 'LaTeX-fill-excluded-macros
295                '("Sexpr"))
296   ;; REFTEX (much enhanced management of cross-ref, labels, etc)
297   ;; http://www.strw.leidenuniv.nl/~dominik/Tools/reftex/
298   (autoload 'reftex-mode     "reftex" "RefTeX Minor Mode" t)
299   (autoload 'turn-on-reftex  "reftex" "RefTeX Minor Mode" nil)
300   (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
301   (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
302   (add-hook 'LaTeX-mode-hook 'turn-on-reftex)   ; with AUCTeX LaTeX mode
303   (add-hook 'latex-mode-hook 'turn-on-reftex)   ; with Emacs latex mode
304   (add-hook 'LaTeX-mode-hook 'outline-minor-mode)   ; with AUCTeX LaTeX mode
305   (add-hook 'latex-mode-hook 'outline-minor-mode)   ; with Emacs latex mode
306
307   ; use smart quotes by default instead of `` and ''
308   ; taken from http://kieranhealy.org/esk/kjhealy.html
309   (setq TeX-open-quote "“")
310   (setq TeX-close-quote "”")
311
312   ;; (TeX-add-style-hook
313   ;;  "latex"
314   ;;  (lambda ()
315   ;;    (TeX-add-symbols
316   ;;     '("DLA" 1))))
317   ;; (custom-set-variables
318   ;;  '(font-latex-user-keyword-classes 
319   ;;    '(("fixme" 
320   ;;       ("DLA" "RZ")
321   ;;       font-lock-function-name-face 2 (command 1 t))))
322   ;; ) 
323
324   (require 'font-latex)
325   (setq font-latex-match-reference-keywords
326         '(
327           ("fref" "{")
328           ("Fref" "{")
329           ("citep" "{")
330           ("citet" "{")
331           ("acs" "{")
332           ("acsp" "{")
333           ("ac" "{")
334           ("acp" "{")
335           ("acl" "{")
336           ("aclp" "{")
337           ("acsu" "{")
338           ("aclu" "{")
339           ("acused" "{")
340   ;         ))
341   ; (setq font-latex-match-warning-keywords
342   ;       '(
343           ("DLA" "{")
344           ("RZ" "{")
345           ("OM" "{")
346           ("DL" "{")
347           ("fixme" "{")))
348       
349   (setq-default TeX-parse-self t)
350   (setq-default TeX-auto-save t)
351   (setq-default TeX-master nil)
352   (eval-after-load
353       "latex"
354     '(TeX-add-style-hook
355       "cleveref"
356       (lambda ()
357         (if (boundp 'reftex-ref-style-alist)
358         (add-to-list
359          'reftex-ref-style-alist
360          '("Cleveref" "cleveref"
361            (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
362         (reftex-ref-style-activate "Cleveref")
363         (TeX-add-symbols
364          '("cref" TeX-arg-ref)
365          '("Cref" TeX-arg-ref)
366          '("cpageref" TeX-arg-ref)
367          '("Cpageref" TeX-arg-ref)))))
368   ;; this doesn't seem to work; not currently sure why
369   ; (setq font-latex-user-keyword-classes
370   ;       '(("my-warning-commands"
371   ;          (("DLA" "{")
372   ;           ("RZ" "{")
373   ;           ("OM" "{")
374   ;           ("DL" "{")
375   ;           ("fixme" "{")
376   ;           )
377   ;          (:foreground "red" :weight bold :underline (:color foreground-color :style line)))
378   ;         ))
379
380   (setq-default reftex-default-bibliography
381         '("~/projects/research/references.bib"))
382
383
384 #+END_SRC
385 ** Org
386 #+BEGIN_SRC emacs-lisp
387   (require 'org-mode-configuration)
388 #+END_SRC
389 ** ESS
390 #+BEGIN_SRC emacs-lisp
391   (require 'ess_configuration)
392 #+END_SRC
393
394
395 ** Polymode
396 #+BEGIN_SRC emacs-lisp
397   (setq load-path
398         (append '("~/lib/emacs_el/polymode/modes")
399                 load-path))
400   (require 'polymode)
401   (require 'poly-R)
402   (require 'poly-noweb)
403   (require 'poly-markdown)
404   (add-to-list 'auto-mode-alist '("\\.Snw" . poly-noweb+r-mode))
405   (add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+r-mode))
406   (add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode))
407 #+END_SRC
408
409 * Keybindings
410 ** Override other things
411 #+BEGIN_SRC emacs-lisp
412   ; apparently things like to step on C-;, so we'll use a hack from
413   ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
414
415   (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
416
417   ; use iedit everywhere
418   (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
419   ;; use outline mode keybindings everywhere
420   (define-key my-keys-minor-mode-map (kbd "C-;") 'my/mydra-outline/body)
421
422   (define-minor-mode my-keys-minor-mode
423     "A minor mode so that my key settings override annoying major modes."
424     t " my-keys" 'my-keys-minor-mode-map)
425
426   (my-keys-minor-mode 1)
427   (defun my-minibuffer-setup-hook ()
428     (my-keys-minor-mode 0))
429
430   (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
431   (defadvice load (after give-my-keybindings-priority)
432     "Try to ensure that my keybindings always have priority."
433     (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
434         (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
435           (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
436           (add-to-list 'minor-mode-map-alist mykeys))))
437   (ad-activate 'load)
438 #+END_SRC
439
440 * Mis1c (uncharacterized)
441 #+BEGIN_SRC emacs-lisp
442   (setq bibtex-user-optional-fields (quote (("annote" "Personal annotation (ignored)") ("abstract" "") ("pmid" "") ("doi" ""))))
443   (setq calendar-latitude 40.11)
444   (setq calendar-longitude -88.24)
445   (setq case-fold-search t)
446   (setq confirm-kill-emacs (quote y-or-n-p))
447   (setq cperl-lazy-help-time nil)
448   (setq debian-changelog-mailing-address "don@debian.org")
449   (display-time)
450   (setq display-time-24hr-format t)
451   (setq display-time-day-and-date t)
452   (display-time-mode 1)
453   (setq font-latex-fontify-script nil)
454   (setq font-latex-fontify-sectioning (quote color))
455   (setq font-latex-script-display (quote (nil)))
456   (global-auto-revert-mode 1)
457   (global-font-lock-mode 1)
458   (icomplete-mode 1)
459   (setq log-edit-keep-buffer t)
460   (setq mail-user-agent (quote sendmail-user-agent))
461   (setq markdown-enable-math t)
462   (setq markdown-follow-wiki-link-on-enter nil)
463   (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
464   (setq post-email-address "don@donarmstrong.com")
465   (setq post-kill-quoted-sig nil)
466   (setq post-mail-message "mutt\\(ng\\|\\)-[a-z0-9]+-[0-9]+-.*")
467   (setq post-uses-fill-mode nil)
468   (setq ps-footer-font-size (quote (8 . 10)))
469   (setq ps-header-font-size (quote (8 . 10)))
470   (setq ps-header-title-font-size (quote (10 . 10)))
471   (setq ps-line-number-color "blue")
472   (setq ps-print-footer t)
473   (setq ps-print-footer-frame nil)
474   (setq ps-print-only-one-header t)
475   (setq safe-local-variable-values (quote ((auto-save-default) (make-backup-files))))
476   (setq sentence-end "[.?!][]\"')]*\\($\\|   \\| \\)[    
477   ]*")
478   (setq sentence-end-double-space nil)
479   ; enable matching parenthesis
480   (show-paren-mode 1)
481   (tool-bar-mode -1)
482   (setq user-mail-address "don@donarmstrong.com")
483   (setq vc-delete-logbuf-window nil)
484   (setq vc-follow-symlinks t)
485
486   ;; use git before SVN; use CVS earlier, because I have CVS
487   ;; repositories inside of git directories
488   (setq vc-handled-backends (quote (CVS Git RCS SVN SCCS Bzr Hg Mtn Arch)))
489
490   ;; switch back to the old primary selection method
491   (setq x-select-enable-clipboard nil)
492   (setq x-select-enable-primary t)
493   ; (setq mouse-drag-copy-region t)
494
495   (fset 'perl-mode 'cperl-mode)
496   ;;(load-file "cperl-mode.el")
497
498   (require 'vcl-mode)
499
500   (require 'tex-site)
501   ;;(require 'psvn)
502   ;;(require 'ecasound)
503   ;;(require 'emacs-wiki)
504   (require 'bibtex)
505   (require 'post)
506   ;;(require 'fixme)
507   ; (require 'google-weather)
508   ; (require 'org-google-weather)
509   ; (setq-default org-google-weather-format "%i %c, [%l,%h] %s %C")
510
511   ; http://julien.danjou.info/projects/emacs-packages#rainbow-mode
512   ; this colorizes color strings
513   (require 'rainbow-mode)
514   ; add ess to the x major mode
515   (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
516   (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
517
518   (global-set-key "\C-xp" 'server-edit)
519
520   (setq-default auto-mode-alist (cons '("\.wml$" . 
521                     (lambda () (html-mode) (auto-fill-mode)))
522                   auto-mode-alist))
523
524
525   ; use markdown mode for mdwn files
526   (add-to-list 'auto-mode-alist '("\\.mdwn$" . markdown-mode))
527   (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
528
529
530   ;; tramp configuration
531   (setq tramp-use-ssh-controlmaster-options nil)
532
533   ; mail configuration
534   (add-to-list 'auto-mode-alist '("muttng-[a-z0-9]+-[0-9]+-" . message-mode))
535   (add-to-list 'auto-mode-alist '("muttngrc" . muttrc-mode))
536
537   (add-to-list 'auto-mode-alist '("mutt-[a-z0-9]+-[0-9]+-" . message-mode))
538   (add-to-list 'auto-mode-alist '("muttrc" . muttrc-mode))
539   (defun my-message-mode-settings ()
540     (font-lock-add-keywords nil
541                             '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
542                                (0 'message-multiply-quoted-text-face))
543                               ("^[ \t]*>[ \t]*>.*$"
544                                (0 'message-double-quoted-text-face))))
545     (local-set-key (kbd "C-c C-a") 'my-post-attach-file)
546     )
547   (add-hook 'message-mode-hook 'my-message-mode-settings)
548
549   (defun my-post-attach-file ()
550     "Prompt for an attachment."
551     (interactive)
552     (let ((file (read-file-name "Attach file: " nil nil t nil))
553           (description (string-read "Description: ")))
554       (my-header-attach-file file description)))
555
556   (symbol-function 'my-post-attach-file)
557
558   (defun my-header-attach-file (file description)
559     "Attach a FILE to the current message (works with Mutt).
560   Argument DESCRIPTION MIME description."
561     (interactive "fAttach file: \nsDescription: ")
562     (when (> (length file) 0)
563       (save-excursion
564         (save-match-data
565           (save-restriction
566             (widen)
567             (goto-char (point-min))
568             (search-forward-regexp "^$")
569             (insert (concat "Attach: " (replace-regexp-in-string "\\([[:space:]\\]\\)" "\\\\\\1" (file-truename file)) " "
570                             description "\n"))
571             (message (concat "Attached '" file "'."))
572             (setq post-has-attachment t))))))
573
574
575
576   (setq mail-yank-prefix "> ")
577
578   (global-unset-key "\M-g")
579   (global-set-key "\M-g" 'goto-line)
580
581   ;; self-insert-command hack.
582   ;;   Without this, "if<SP>" expands to
583   ;;   if ( -!-) {
584   ;;   }
585   ;;   which really should be,
586   ;;   if (-!-) {
587   ;;   }
588
589
590
591   ;(load-library "php-mode")
592
593   (setq-default c-indent-level 4)
594   (setq-default c-brace-imaginary-offset 0)
595   (setq-default c-brace-offset -4)
596   (setq-default c-argdecl-indent 4)
597   (setq-default c-label-offset -4)
598   (setq-default c-continued-statement-offset 4)
599   ; tabs are annoying
600   (setq-default indent-tabs-mode nil)
601   (setq-default tab-width 4)
602
603
604   ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
605   ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
606   ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
607   ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
608   ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
609
610
611   (defun insert-date ()
612     "Insert date at point."
613     (interactive)
614     (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
615   (global-set-key "\C-[d" 'insert-date)
616
617   (defun unfill-paragraph (arg)
618     "Pull this whole paragraph up onto one line."
619     (interactive "*p")
620     (let ((fill-column 10000))
621       (fill-paragraph arg))
622     )
623
624   (column-number-mode t)
625   (setq-default reftex-plug-into-AUCTeX t)
626
627   (server-start)
628
629   ; (require 'mode-compile)
630
631   (defadvice server-process-filter (after post-mode-message first activate)
632     "If the buffer is in post mode, overwrite the server-edit
633       message with a post-save-current-buffer-and-exit message."
634     (if (eq major-mode 'post-mode)
635         (message
636          (substitute-command-keys "Type \\[describe-mode] for help composing; \\[post-save-current-buffer-and-exit] when done."))))
637                       ; This is also needed to see the magic message.  Set to a higher
638                       ; number if you have a faster computer or read slower than me.
639   '(font-lock-verbose 1000)
640   ;(setq-default server-temp-file-regexp "mutt\(-\|ng-\)")
641   ; (add-hook 'server-switch-hook 
642   ;     (function (lambda()
643   ;             (cond ((string-match "Post" mode-name)
644   ;                (post-goto-body)))
645   ;             set-buffer-file-coding-system 'utf-8
646   ;             )))
647   ; 
648
649   (add-hook 'post-mode-hook
650         (auto-fill-mode nil)
651         )
652   ; abbrev mode settings
653   ; load abbreviations from 
654   (setq abbrev-file-name       
655         "~/.emacs_abbrev_def")
656
657   ; read the abbrev file if it exists
658   (if (file-exists-p abbrev-file-name)
659       (quietly-read-abbrev-file))
660
661   ; for now, use abbrev mode everywhere
662   (setq default-abbrev-mode t)
663
664
665   (defun insert-function-documentation ()
666     "Insert function documentation"
667     (interactive)
668     (insert-file-contents "/home/don/lib/templates/perl_function_documentation" nil))
669   (global-set-key "\M-f" 'insert-function-documentation)
670
671   (eval-after-load "lilypond-mode" 
672     '(progn
673        (load-library "lyqi-mode")
674        (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode)))
675
676   (autoload 'spamassassin-mode "spamassassin-mode" nil t)
677
678   (desktop-load-default)
679   (desktop-read)
680   '(icomplete-mode on)
681   (custom-set-faces
682    ;; custom-set-faces was added by Custom.
683    ;; If you edit it by hand, you could mess it up, so be careful.
684    ;; Your init file should contain only one such instance.
685    ;; If there is more than one, they won't work right.
686    '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
687
688
689   (put 'upcase-region 'disabled nil)
690   (put 'downcase-region 'disabled nil)
691   (put 'narrow-to-region 'disabled nil)
692
693
694   (autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
695   (add-hook 'message-mode-hook 'turn-on-flyspell)
696   (add-hook 'text-mode-hook 'turn-on-flyspell)
697   (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
698   (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
699   (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
700   ; (defun turn-on-flyspell ()
701   ;    "Force flyspell-mode on using a positive arg.  For use in hooks."
702   ;    (interactive)
703   ;    (flyspell-mode 1))
704
705
706    ; Outline-minor-mode key map
707    (define-prefix-command 'cm-map nil "Outline-")
708    ; HIDE
709    (define-key cm-map "q" 'hide-sublevels)    ; Hide everything but the top-level headings
710    (define-key cm-map "t" 'hide-body)         ; Hide everything but headings (all body lines)
711    (define-key cm-map "o" 'hide-other)        ; Hide other branches
712    (define-key cm-map "c" 'hide-entry)        ; Hide this entry's body
713    (define-key cm-map "l" 'hide-leaves)       ; Hide body lines in this entry and sub-entries
714    (define-key cm-map "d" 'hide-subtree)      ; Hide everything in this entry and sub-entries
715    ; SHOW
716    (define-key cm-map "a" 'show-all)          ; Show (expand) everything
717    (define-key cm-map "e" 'show-entry)        ; Show this heading's body
718    (define-key cm-map "i" 'show-children)     ; Show this heading's immediate child sub-headings
719    (define-key cm-map "k" 'show-branches)     ; Show all sub-headings under this heading
720    (define-key cm-map "s" 'show-subtree)      ; Show (expand) everything in this heading & below
721    ; MOVE
722    (define-key cm-map "u" 'outline-up-heading)                ; Up
723    (define-key cm-map "n" 'outline-next-visible-heading)      ; Next
724    (define-key cm-map "p" 'outline-previous-visible-heading)  ; Previous
725    (define-key cm-map "f" 'outline-forward-same-level)        ; Forward - same level
726    (define-key cm-map "b" 'outline-backward-same-level)       ; Backward - same level
727    (global-set-key "\M-o" cm-map)
728
729
730   ; debian stuff
731   (setq-default debian-changelog-mailing-address "don@debian.org")
732   (setq-default debian-changelog-full-name "Don Armstrong")
733
734   ; ediff configuration
735   ; don't use the multi-window configuration
736   (setq ediff-window-setup-function 'ediff-setup-windows-plain)
737
738   ; use iedit
739   (require 'iedit)
740   (define-key global-map (kbd "C-;") 'iedit-mode)
741   (global-set-key  (kbd "C-;") 'iedit-mode)
742
743   ; fix up css mode to not be silly
744   ; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
745   (setq cssm-indent-level 4)
746   (setq cssm-newline-before-closing-bracket t)
747   (setq cssm-indent-function #'cssm-c-style-indenter)
748   (setq cssm-mirror-mode nil)
749
750   (require 'multi-web-mode)
751   (setq mweb-default-major-mode 'html-mode)
752   (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
753                     (js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
754                     (css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
755   (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
756   (multi-web-global-mode 1)
757
758   ;;; alias the new `flymake-report-status-slim' to
759   ;;; `flymake-report-status'
760   (defalias 'flymake-report-status 'flymake-report-status-slim)
761   (defun flymake-report-status-slim (e-w &optional status)
762     "Show \"slim\" flymake status in mode line."
763     (when e-w
764       (setq flymake-mode-line-e-w e-w))
765     (when status
766       (setq flymake-mode-line-status status))
767     (let* ((mode-line " Φ"))
768       (when (> (length flymake-mode-line-e-w) 0)
769         (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
770       (setq mode-line (concat mode-line flymake-mode-line-status))
771       (setq flymake-mode-line mode-line)
772       (force-mode-line-update)))
773
774   ; load sql-indent when sql is loaded
775   (eval-after-load "sql"
776     '(load-library "sql-indent"))
777
778   ; fix up tmux xterm keys
779   ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
780   (if (getenv "TMUX")
781       (progn
782         (let ((x 2) (tkey ""))
783           (while (<= x 8)
784             ;; shift
785             (if (= x 2)
786                 (setq tkey "S-"))
787             ;; alt
788             (if (= x 3)
789                 (setq tkey "M-"))
790             ;; alt + shift
791             (if (= x 4)
792                 (setq tkey "M-S-"))
793             ;; ctrl
794             (if (= x 5)
795                 (setq tkey "C-"))
796             ;; ctrl + shift
797             (if (= x 6)
798                 (setq tkey "C-S-"))
799             ;; ctrl + alt
800             (if (= x 7)
801                 (setq tkey "C-M-"))
802             ;; ctrl + alt + shift
803             (if (= x 8)
804                 (setq tkey "C-M-S-"))
805   
806             ;; arrows
807             (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
808             (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
809             (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
810             (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
811             ;; home
812             (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
813             ;; end
814             (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
815             ;; page up
816             (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
817             ;; page down
818             (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
819             ;; insert
820             (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
821             ;; delete
822             (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
823             ;; f1
824             (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
825             ;; f2
826             (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
827             ;; f3
828             (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
829             ;; f4
830             (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
831             ;; f5
832             (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
833             ;; f6
834             (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
835             ;; f7
836             (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
837             ;; f8
838             (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
839             ;; f9
840             (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
841             ;; f10
842             (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
843             ;; f11
844             (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
845             ;; f12
846             (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
847             ;; f13
848             (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
849             ;; f14
850             (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
851             ;; f15
852             (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
853             ;; f16
854             (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
855             ;; f17
856             (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
857             ;; f18
858             (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
859             ;; f19
860             (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
861             ;; f20
862             (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
863
864             (setq x (+ x 1))
865             ))
866         )
867     )
868
869   ; procmailmode configuration
870   (load "procmail_mode")
871
872   (load "mode-line-cleaner")
873
874   (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
875     "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
876     (if (or (buffer-modified-p)
877             (verify-visited-file-modtime)
878             (< (* 8 1024 1024) (buffer-size))
879             (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
880         ad-do-it
881       (clear-visited-file-modtime)
882       (not-modified)))
883   (ad-activate 'ask-user-about-supersession-threat)
884
885   ; apparently things like to step on C-;, so we'll use a hack from
886   ; http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs/5340797#5340797 to fix this
887
888   (defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
889
890   ; use iedit everywhere
891   (define-key my-keys-minor-mode-map (kbd "C-;") 'iedit-mode)
892
893   (define-minor-mode my-keys-minor-mode
894     "A minor mode so that my key settings override annoying major modes."
895     t " my-keys" 'my-keys-minor-mode-map)
896
897   (my-keys-minor-mode 1)
898   (defun my-minibuffer-setup-hook ()
899     (my-keys-minor-mode 0))
900
901   (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
902   (defadvice load (after give-my-keybindings-priority)
903     "Try to ensure that my keybindings always have priority."
904     (if (not (eq (car (car minor-mode-map-alist)) 'my-keys-minor-mode))
905         (let ((mykeys (assq 'my-keys-minor-mode minor-mode-map-alist)))
906           (assq-delete-all 'my-keys-minor-mode minor-mode-map-alist)
907           (add-to-list 'minor-mode-map-alist mykeys))))
908   (ad-activate 'load)
909   (global-set-key "\M- " 'hippie-expand)
910
911 #+END_SRC
912
913 * END
914 #+BEGIN_SRC emacs-lisp
915   (provide 'don-configuration)
916 #+END_SRC