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