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