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