chiark / gitweb /
9c394b696cdf4986d7e7f8e1212866d861d12625
[profile] / dot / emacs
1 ;;; -*- mode: emacs-lisp; coding: utf-8 -*-
2 ;;;
3 ;;; Emacs configuration file
4 ;;;
5 ;;; (c) 1996-1999 Mark Wooding
6 ;;;
7
8 ;;;----- Licensing notice ---------------------------------------------------
9 ;;;
10 ;;; This program is free software; you can redistribute it and/or modify
11 ;;; it under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 2 of the License, or
13 ;;; (at your option) any later version.
14 ;;;
15 ;;; This program is distributed in the hope that it will be useful,
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;;; GNU General Public License for more details.
19 ;;;
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with this program; if not, write to the Free Software
22 ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
23
24 (setq load-path (nconc load-path (list "~/lib/emacs")))
25 (require 'dot-emacs)
26
27 ;;;--------------------------------------------------------------------------
28 ;;; Some random initialisation.
29
30 (setq mdw-init-window (selected-window))
31
32 ;; Load some other bits of code.
33
34 (maybe-autoload 'cc-mode "cc-mode" nil t)
35 (maybe-autoload 'rexx-mode "rexx-mode" nil t)
36 (maybe-autoload 'cvs-update "pcl-cvs" nil t)
37 (maybe-autoload 'debian-changelog-mode "debian-changelog-mode" nil t)
38 (maybe-autoload 'git-status "git" nil t)
39 (maybe-autoload 'git-blame-mode "git-blame" nil t)
40 (maybe-autoload 'stgit "stgit" nil t)
41 (maybe-autoload 'nc-timesheet-prepare "nc-timesheet" nil t nil)
42 (maybe-autoload 'nc-timesheet-submit "nc-timesheet" nil t nil)
43
44 (and (library-exists-p "debian-changelog-mode")
45      (add-to-list 'auto-mode-alist
46                   `(,(concat "/debian/"
47                                "\\("
48                                  "[" "[:lower:][:digit:]]"
49                                      "[[:lower:][:digit:].+-" "]+"
50                                  "\\."
51                                "\\)?"
52                                "changelog\\'")
53                     . debian-changelog-mode)))
54
55 (and (library-exists-p "vc-git")
56      (not (memq 'GIT vc-handled-backends))
57      (not (memq 'Git vc-handled-backends))
58      (not (memq 'git vc-handled-backends))
59      (setq vc-handled-backends (cons 'GIT vc-handled-backends)))
60
61 (trap (or mdw-fast-startup (require 'p4)))
62
63 (trap (or mdw-fast-startup (require 'tex-site)))
64
65 (trap (or mdw-fast-startup (semantic-load-enable-minimum-features)))
66 (setq semanticdb-default-save-directory "~/.emacs.d/semanticdb/")
67
68 ;; Skeleton stuff.
69
70 (trap (or mdw-fast-startup (require 'skel-init)))
71
72 ;; Window system-dependent things.
73
74 (require 'paren)
75 (trap (show-paren-mode t))
76 (or window-system (menu-bar-mode -1))
77
78 ;; Temporary directory handling.
79
80 (defun mdw-check-dir-exists (dir)
81   (and dir
82        (file-directory-p dir)
83        dir))
84 (setq tmpdir (or (mdw-check-dir-exists (getenv "TMPDIR"))
85                  (mdw-check-dir-exists (format "/tmp/%s" (user-login-name)))
86                  "/tmp"))
87
88 ;; Emacs server behaviour.
89
90 (and (or window-system (>= emacs-major-version 23))
91      (progn (setq server-temp-file-regexp (concat "^" tmpdir "\\|/draft$")
92                   gnuserv-frame t)
93             (trap (server-start))))
94
95 ;; Control backup behaviour.
96
97 (setq backup-by-copying nil)
98 (setq backup-by-copying-when-linked t)
99 (setq backup-by-copying-when-mismatch t)
100
101 (setq mdw-backup-disable-regexps
102       '("/\\.git/COMMIT_EDITMSG$"
103         "/\\.stgit\\(-edit\\.txt\\|msg\\.txt\\|\\.msg\\)$"))
104
105 ;; Safe variables.
106
107 (setq safe-local-variable-values
108       '((make-backup-files . nil)))
109
110 ;; Calculator fiddling.
111
112 (setq calc-settings-file "~/.emacs-calc")
113 (load calc-settings-file)
114
115 ;; ---- Some mail and news configuration ---
116
117 (setq mail-from-style 'parens)
118 (setq mail-signature t)
119 (setq mail-yank-prefix "> ")
120 (setq mail-archive-file-name "~/Mail/sent")
121
122 (setq rmail-display-summary t)
123 (setq rmail-file-name "~/Mail/rmail")
124
125 (setq sendmail-program "~/bin/sendmail-hack")
126
127 (setq mail-user-agent 'message-user-agent)
128 (setq message-signature-separator "^-- \\(\\|\\[mdw\\]\\)$"
129       message-yank-prefix "> "
130       message-yank-cited-prefix "> "
131       message-indent-citation-function '(message-indent-citation
132                                          mdw-trim-spaces-after-citing))
133
134 (defun mdw-trim-spaces-after-citing ()
135   (save-excursion
136     (save-restriction
137       (narrow-to-region (point) (mark t))
138       (while (re-search-forward "^> +$" nil t)
139         (replace-match ">")))))
140
141 (and (fboundp 'turn-on-gnus-dired-mode)
142      (not mdw-fast-startup)
143      (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode))
144
145 (or mdw-fast-startup
146     (trap (bbdb-initialize 'gnus 'sendmail 'message)))
147 (setq bbdb-north-american-phone-numbers-p nil)
148
149 ;; Customization.
150
151 (setq custom-file "~/.emacs-custom")
152 (trap (load custom-file))
153
154 (trap (load "~/.emacs-local"))
155
156 ;; Internationalization twiddling.
157
158 (trap
159   ;; Have top-bit-set characters work properly in terminals.
160   (let ((im (current-input-mode)))
161     (apply #'set-input-mode
162            (nconc (list (nth 0 im) (nth 1 im) 0) (nthcdr 3 im)))))
163
164 ;; Don't disable any commands.
165
166 (mapatoms #'(lambda (sym) (put sym 'disabled nil)))
167
168 ;; Split a wide window.
169
170 (mdw-divvy-window)
171
172 ;; Postscript printing.
173
174 (setq ps-paper-type 'a4
175       ps-print-color-p nil
176       ps-landscape-mode t
177       ps-number-of-columns 2
178       ps-font-family 'Courier
179       ps-font-size 6.5)
180
181 ;; Splash screen stuff.
182
183 (or window-system
184     (setq inhibit-splash-screen t
185           inhibit-startup-message t))
186
187 ;; Other goodies.
188
189 (trap (resize-minibuffer-mode 1))       ;Make minibuffer grow dynamically
190 (auto-compression-mode 1)               ;Enable automatic compression
191 (setq enable-local-variables :safe
192       enable-local-eval nil)
193 (setq dabbrev-case-replace nil)         ;Retain case when completing
194 (setq linum-format "%7d ")
195 (setq next-line-add-newlines nil)       ;Don't add weird newlines
196 (setq split-height-threshold 45)        ;Reuse windows where sensible
197 (setq display-buffer-reuse-frames nil   ;Don't confuse me by showing buffers
198       iswitchb-default-method 'samewindow) ;in other random frames
199 (setq dired-deletion-confirmer          ;Make deletion easier in dired
200       (symbol-function 'y-or-n-p))
201 (setq read-quoted-char-radix 16)        ;C-q HEX-STUFF [RET]
202 (setq dired-listing-switches "-alF")    ;Do `ls -F' things in dired windows
203 (setq wdired-allow-to-change-permissions t)
204 (setq case-fold-file-names nil)         ;Don't translate file names (grr...)
205 (setq scroll-step 5)                    ;Don't scroll too much at a time
206 (setq-default fill-column 77)           ;I use rather narrow windows
207 (setq-default comment-column 40)        ;Set a standard comment column
208 (setq-default truncate-partial-width-windows nil)
209 (setq default-indicate-empty-lines t)
210 (setq whitespace-style
211       '(trailing space-before-tab space-after-tab empty indentation))
212 (setq woman-use-own-frame nil           ;Keep man pages somewhere sensible
213       woman-fill-column 72)             ;Right margin position.
214 (setq diff-switches "-u"                ;I like reading unified diffs
215       cvs-diff-flags (list diff-switches))
216 (setq echo-keystrokes 10)               ;Long delay before keystrokes echo
217 (setq ange-ftp-ftp-program-name "pftp") ;Use passive FTP
218 (setq find-ls-option                    ;Build file lists efficiently
219       '("-print0 | xargs -0r ls -ld" . "ld"))
220 (setq bookmark-save-flag 0)             ;Save bookmarks automatically
221 (setq x-gtk-file-dialog-help-text nil)
222 (setq Info-fontify-maximum-menu-size 100000)
223 (setq set-mark-command-repeat-pop t)
224 (setq password-cache-expiry nil)
225 (setq-default proced-filter 'all
226               proced-sort 'user)
227 (setq ispell-program-name "aspell"
228       ispell-local-dictionary "en_GB-ize-w_accents"
229       flyspell-default-dictionary "en_GB-ize-w_accents"
230       ispell-silently-savep t)
231 (trap
232   (require 'uniquify)
233   (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
234   (setq uniquify-after-kill-buffer-p t))
235 (transient-mark-mode t)
236 (setq mark-even-if-inactive t)
237 (trap
238   (tooltip-mode 0)
239   (tool-bar-mode 0))
240 (trap (or mdw-fast-startup (global-auto-revert-mode t)))
241 (setq psgml-html-build-new-buffer nil)
242
243 (defvar mdw-black-background t)
244
245 (eval-after-load "outline"
246   '(progn
247      (trap (require 'foldout))
248      (define-key outline-mode-prefix-map [?\C-r] 'reveal-mode)
249      (define-key outline-mode-prefix-map [?\C--] 'mdw-outline-collapse-all)))
250
251 (setq cltl2-root-url (mdw-config 'cltl-url))
252 (setq common-lisp-hyperspec-root (mdw-config 'hyperspec-url))
253
254 ;;;--------------------------------------------------------------------------
255 ;;; W3 and URL fetching stuff.
256
257 (let ((proxy (mdw-config 'http-proxy)))
258   (setq url-proxy-services
259         `(("http" . ,proxy)
260           ("ftp" . ,proxy)
261           ("gopher" . ,proxy))))
262 (setq url-cookie-untrusted-urls '("."))
263
264 (setq browse-url-browser-function (mdw-good-url-browser)
265       browse-url-mozilla-program "firefox")
266
267 (setq w3m-default-display-inline-images t)
268
269 (setq w3-do-incremental-display t
270       w3-use-menus '(file edit view go bookmark options
271                      buffers style search emacs nil help)
272       w3-display-inline-image t
273       w3-keybinding 'info)
274
275 ;;;--------------------------------------------------------------------------
276 ;;; Calendar configuration.
277
278 (setq diary-file "~/etc/diary")
279
280 ;; Trivial stuff for the sunrise/sunset calculations.
281
282 (setq calendar-latitude 52.2)
283 (setq calendar-longitude 0.1)
284 (setq calendar-location-name "Cambridge, UK")
285
286 ;; Holidays.
287
288 (and (not mdw-fast-startup)
289      (trap
290        (require 'ew-hols)
291        (setq other-holidays (append english-and-welsh-bank-holidays
292                                     other-holidays))))
293
294 ;; Date format fiddling.
295
296 (setq european-calendar-style t)
297
298 (setq diary-date-forms '((day "[-/]" month "[^-/0-9]")
299                          (day " *" monthname "[ \t]*\\(\^M\\|\n\\)")
300                          (backup day " *" monthname "\\W+\\<[^*0-9]")
301                          (day "[-/]" month "[-/]" year "[^0-9]")
302                          (day " *" monthname " *" year "[^0-9]")
303                          (year "[-/]" month "[-/]" day "[^0-9]")
304                          (dayname "\\W")))
305
306 ;; Fancy diary handling.
307
308 (add-hook 'diary-display-hook 'fancy-diary-display)
309 (setq diary-list-include-blanks t)
310 (add-hook 'list-diary-entries-hook 'sort-diary-entries t)
311 (add-hook 'list-diary-entries-hook 'include-other-diary-files)
312 (add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
313
314 ;; Appointment management.
315
316 (add-hook 'diary-hook 'appt-make-list)
317 (setq appt-issue-message t)
318 (setq appt-display-interval 3)
319 (setq appt-message-warning-time 10)
320
321 ;; Org-mode agenda.
322
323 (setq org-agenda-include-diary t
324       org-tags-column -77)
325
326 ;; Cosmetic stuff.
327
328 (setq display-time-24hr-format t)
329 (display-time)
330 (trap
331   (if window-system
332       (let ((view-diary-entries-initially t))
333         (calendar))))
334
335 ;;;--------------------------------------------------------------------------
336 ;;; MailCrypt.
337
338 ;; Define more mode hooks for MailCrypt.
339
340 (setq mdw-mc-modes
341       '((mdwmail-mode (encrypt . mdwmail-mc-encrypt)
342                       (sign . mdwmail-mc-sign))))
343
344 ;; Load the MailCrypt support.
345
346 (trap
347   (and (string-match "linux" (symbol-name system-type))
348        (not mdw-fast-startup)
349        (progn (require 'mailcrypt-init)
350               (require 'mailcrypt)
351               (setq mc-default-scheme 'mc-scheme-gpg)
352               (setq mc-pgp-user-id "mdw-nsict-pgp")
353               (setq mc-gpg-user-id "mdw-nsict-gpg")
354               (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
355               (setq mc-pgp-always-sign t)
356               (setq mc-gpg-always-sign t)
357               (setq mc-always-replace 'never)
358               (setq mc-passwd-timeout 3600)
359               (setq mc-temp-directory tmpdir)
360               (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
361               (define-key mc-write-mode-map "\C-c/S" 'mc-sign-region)
362               (define-key mc-write-mode-map "\C-c/E" 'mc-encrypt-region)
363               (add-hook 'text-mode-hook 'mc-install-write-mode))))
364
365 ;;;--------------------------------------------------------------------------
366 ;;; Other common declarations.
367
368 ;; Default frame size.
369
370 (setq default-frame-alist
371       (mdw-uniquify-alist
372        '((width . 78)
373          (height . 33)
374          (vertical-scroll-bars . right)
375          (cursor-type . bar)
376          (cursor-blink . t)
377          (left-fringe . 5)
378          (right-fringe . 5)
379          (scroll-bar-width . 15)
380          (cursor-color . "red"))
381        (if mdw-black-background
382            '((background-mode . dark))
383          '((background-mode . light)))
384        (and (eq window-system 'pm)
385             '((font . "-os2-System VIO-medium-r-normal--*-40-*-*-m-*-cp850")
386               (menu-font . "8.Helv")
387               (background-color . "lightgrey")))
388        default-frame-alist))
389
390 ;; Other frame fiddling.
391
392 (setq frame-title-format '("" invocation-name "@" system-name ": %b"))
393
394 ;; Global keymap changes.
395
396 (trap
397   (windmove-default-keybindings))
398 (setq windmove-wrap-around t)
399 (trap (iswitchb-mode))
400 (progn
401   (global-set-key [?\C-x ?w left] 'windmove-left)
402   (global-set-key [?\C-x ?w ?h] 'windmove-left)
403   (global-set-key [?\C-x ?w up] 'windmove-up)
404   (global-set-key [?\C-x ?w ?k] 'windmove-up)
405   (global-set-key [?\C-x ?w down] 'windmove-down)
406   (global-set-key [?\C-x ?w ?j] 'windmove-down)
407   (global-set-key [?\C-x ?w right] 'windmove-right)
408   (global-set-key [?\C-x ?w ?l] 'windmove-right)
409   (global-set-key [?\C-x ?g ?l] 'org-store-link)
410   (global-set-key [?\C-x ?g ?a] 'org-agenda)
411   (global-set-key [?\C-x ?g ?b] 'org-iswitchb)
412   (global-set-key [?\C-x ?t ?i] 'timeclock-in)
413   (global-set-key [?\C-x ?t ?c] 'timeclock-change)
414   (global-set-key [?\C-x ?t ?o] 'timeclock-out)
415   (global-set-key [?\C-x ?t ?r] 'timeclock-reread-log)
416   (global-set-key [?\C-x ?t ?w] 'timeclock-workday-remaining-string)
417   (global-set-key [?\C-x ?t ?s] 'timeclock-status-string)
418   (global-set-key [?\C-x ?t ?p] 'nc-timesheet-prepare)
419   (global-set-key [?\C-x ?t ?\C-m] 'nc-timesheet-submit)
420   (global-set-key [?\M-#] 'calc-dispatch)
421   (global-set-key [?\C-x ?/] 'auto-fill-mode)
422   (global-set-key [?\C-x ?w ?d] 'mdw-divvy-window)
423   (global-set-key [insertchar] 'overwrite-mode)
424   (global-set-key [?\C-x ?\C-n] 'skel-create-file)
425   (global-set-key [?\C-x ?4 ?n] 'skel-create-file-other-window)
426   (global-set-key [?\C-x ?5 ?n] 'skel-create-file-other-frame)
427   (global-set-key [delete] 'delete-char)
428   (global-set-key [?\M-q] 'mdw-fill-paragraph)
429   (global-set-key [?\C-h ?\C-m] 'manual-entry)
430   (global-set-key [C-M-backspace] 'backward-kill-sexp)
431   (global-set-key [mode-line C-mouse-1] 'mouse-tear-off-window)
432   (global-set-key [vertical-scroll-bar C-down-mouse-1]
433                   'mouse-drag-vertical-line)
434   (global-set-key [vertical-scroll-bar C-mouse-1]
435                   #'(lambda () (interactive)))
436   (global-set-key [XF86WakeUp] "")
437   (and (not mdw-fast-startup) (fboundp 'hippie-expand)
438        (global-set-key [?\M-/] 'hippie-expand)))
439
440 (eval-after-load "dired"
441   '(progn
442      (define-key dired-mode-map [?\C-x ?\C-q]
443        'wdired-change-to-wdired-mode)))
444
445 (add-hook 'org-mode-hook
446           #'(lambda () (mdw-clobber-evil-keymap org-mode-map)))
447 (add-hook 'org-agenda-mode-hook
448           #'(lambda () (mdw-clobber-evil-keymap org-agenda-mode-map)))
449
450 ;; Recognising types of files.
451
452 (setq auto-mode-alist
453       (append `(("\\.p[lm]$" . perl-mode)
454                 ("\\.m$" . objc-mode)
455                 ("\\.mxd$" . c-mode)
456                 ("\\.cs$" . csharp-mode)
457                 ("\\.go$" . go-mode)
458                 ("\\.org$" . org-mode)
459                 ;; ("/[ch]/" . c-mode)
460                 (,(concat "/\\("
461                           "\\.stgit\\.msg" "\\|"
462                           "\\.git/COMMIT_EDITMSG" "\\|"
463                           "svn-commit\\.tmp" "\\|"
464                           "svk-commit[^/.]*\\.tmp"
465                           "\\)$")
466                  . text-mode)
467                 (,(concat "^" tmpdir "/\\("
468                           "svk-commit[^/.]*\\.tmp" "\\|"
469                           "gitci\\.[^/.]*" "\\|"
470                           "cvs[^/.]\\{6\\}" "\\|"
471                           "quilt_header\.[^/.]\\{6\\}"
472                           "\\)$")
473                  . text-mode)
474                 ("\\.calc?$" . apcalc-mode)
475                 ("/src/linux/.*\\.\\(c\\|h\\|cc\\)$" . linux-c-mode)
476                 ("/\\(s\\|sh\\)/" . arm-assembler-mode)
477                 ("\\.\\(cmd\\|exec\\|rexx\\)$" . rexx-mode)
478                 ("\\.st$" . smalltalk-mode)
479                 ("\\.msgs$" . messages-mode)
480                 ("/all-cmds\\.in$" . cpp-messages-mode)
481                 ("\\.\\(tex\\|dtx\\)$" . latex-mode)
482                 ("\\.gc$" . haskell.-mode)
483                 (,(concat "^" (getenv "HOME") "/News/") . mdwmail-mode)
484                 (,(concat "^" tmpdir "/\\(SLRN\\|snd\\|pico\\|mutt\\)")
485                  . mdwmail-mode))
486               auto-mode-alist))
487
488 (setq interpreter-mode-alist
489       (append `(("runlisp" . lisp-mode))
490               interpreter-mode-alist))
491
492 (setq completion-ignored-extensions
493       (append `(".hc" ".hi") completion-ignored-extensions))
494
495 ;; Some common local definitions.
496
497 (make-variable-buffer-local 'mdw-auto-indent)
498
499 (mapcar (lambda (hook) (add-hook hook 'mdw-misc-mode-config))
500         '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
501           csharp-mode-hook perl-mode-hook cperl-mode-hook
502           python-mode-hook pyrec-mode-hook icon-mode-hook awk-mode-hook
503           tcl-mode-hook go-mode-hook
504           asm-mode-hook TeX-mode-hook LaTeX-mode-hook
505           TeXinfo-mode-hook tex-mode-hook latex-mode-hook
506           texinfo-mode-hook emacs-lisp-mode-hook scheme-mode-hook
507           lisp-mode-hook lisp-interaction-mode-hook
508           inferior-lisp-mode-hook slime-repl-mode-hook
509           sml-mode-hook haskell-mode-hook erlang-mode-hook
510           smalltalk-mode-hook rexx-mode-hook
511           arm-assembler-mode-hook))
512
513 (global-font-lock-mode t)
514 (defalias 'perl-mode 'cperl-mode)
515
516 ;;;--------------------------------------------------------------------------
517 ;;; Rootly editingness.
518
519 (eval-after-load "tramp"
520   '(let ((fix-args (if (mdw-version-< tramp-version "2.1")
521                        #'append #'identity)))
522      (setq tramp-methods
523            (mdw-uniquify-alist
524             `(("become"
525                (tramp-connection-function tramp-open-connection-su)
526                (tramp-remote-sh "/bin/sh")
527                (tramp-login-program "become")
528                (tramp-copy-program nil)
529                (tramp-copy-args nil)
530                (tramp-copy-keep-date-arg nil)
531                (tramp-login-args ,(funcall fix-args `("TERM=dumb" "%u"))))
532               ("really"
533                (tramp-connection-function tramp-open-connection-su)
534                (tramp-login-program "really")
535                (tramp-login-args ,(funcall fix-args
536                                            `("-u" "%u")
537                                            `("--")
538                                            `("env" "TERM=dumb" "/bin/sh")))
539                (tramp-copy-program nil)
540                (tramp-copy-args nil)
541                (tramp-copy-keep-date-arg nil)
542                (tramp-remote-sh "/bin/sh"))
543               ,@tramp-methods)))
544      (setq tramp-default-method "ssh")
545      (setq tramp-default-method-alist
546            `(("\\`\\(localhost\\|\\)\\'" ""
547               ,(cond ((executable-find "become") "become")
548                      ((executable-find "really") "really")
549                      (t "su")))))))
550
551 ;;;--------------------------------------------------------------------------
552 ;;; General fontification.
553
554 ;; Configure lazy fontification.
555
556 (and (fboundp 'lazy-lock-mode)
557      (setq font-lock-support-mode 'lazy-lock-mode))
558 ; (setq lazy-lock-defer-contextually t)
559 (setq lazy-lock-defer-time nil
560       font-lock-maximum-decoration 3
561       lazy-lock-minimum-size 0
562       lazy-lock-stealth-time 5
563       lazy-lock-stealth-lines 100
564       lazy-lock-stealth-verbose t)
565
566 (progn
567   (add-hook 'c-mode-hook 'mdw-fontify-c-and-c++ t)
568   (add-hook 'objc-mode-hook 'mdw-fontify-c-and-c++ t)
569   (add-hook 'c++-mode-hook 'mdw-fontify-c-and-c++ t)
570   (add-hook 'linux-c-mode-hook #'(lambda () (setq c-basic-offset 8)))
571   (add-hook 'asm-mode-hook 'mdw-fontify-asm t)
572   (add-hook 'go-mode-hook 'mdw-fontify-go t)
573
574   (add-hook 'icon-mode-hook 'mdw-fontify-icon t)
575
576   (add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t)
577   (add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
578
579   (add-hook 'java-mode-hook 'mdw-fontify-java t)
580   (add-hook 'csharp-mode-hook 'mdw-fontify-csharp t)
581
582   (add-hook 'awk-mode-hook 'mdw-fontify-awk t)
583
584   (add-hook 'perl-mode-hook 'mdw-fontify-perl t)
585   (add-hook 'cperl-mode-hook 'mdw-fontify-perl t))
586
587 (progn
588   (setq-default py-indent-offset 2
589                 py-python-command-args
590                 `("-i" "-colors" ,(if mdw-black-background
591                                       "Linux" "LightBG")))
592   (add-hook 'python-mode-hook 'mdw-fontify-python t)
593   (add-hook 'pyrex-mode-hook 'mdw-fontify-pyrex t))
594
595 (setq-default tcl-indent-level 2)
596 (add-hook 'tcl-mode-hook 'mdw-fontify-tcl t)
597
598 (add-hook 'rexx-mode-hook 'mdw-fontify-rexx t)
599
600 (setq sml-nested-if-indent t
601       sml-case-indent nil
602       sml-indent-level 4
603       sml-type-of-indent nil)
604 (add-hook 'sml-mode-hook 'mdw-fontify-sml t)
605
606 (add-hook 'haskell-mode-hook 'mdw-fontify-haskell t)
607 (setq-default haskell-indent-offset 2)
608
609 (add-hook 'erlang-mode-hook 'mdw-fontify-erlang t)
610
611 (add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t)
612 (add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t)
613
614 (setq LaTeX-table-label "tbl:")
615 (setq TeX-auto-untabify nil)
616 (add-hook 'TeX-mode-hook 'mdw-fontify-tex t)
617 (add-hook 'tex-mode-hook 'mdw-fontify-tex t)
618 (add-hook 'LaTeX-mode-hook 'mdw-fontify-tex t)
619 (add-hook 'latex-mode-hook 'mdw-fontify-tex t)
620
621 (add-hook 'sh-mode-hook #'mdw-setup-sh-script-mode)
622 (add-hook 'autoconf-mode-hook #'mdw-setup-m4)
623 (add-hook 'm4-mode-hook #'mdw-setup-m4)
624
625 (add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t)
626 (add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t)
627
628 (progn
629   (add-hook 'emacs-lisp-mode-hook 'mdw-fontify-lispy t)
630   (add-hook 'scheme-mode-hook 'mdw-fontify-lispy t)
631   (add-hook 'lisp-mode-hook 'mdw-fontify-lispy t)
632   (add-hook 'inferior-lisp-mode-hook 'mdw-fontify-lispy t)
633   (add-hook 'lisp-interaction-mode-hook 'mdw-fontify-lispy t)
634   (add-hook 'slime-repl-mode-hook 'mdw-fontify-lispy t)
635   (add-hook 'lisp-mode-hook 'mdw-common-lisp-indent t)
636   (add-hook 'inferior-lisp-mode-hook
637           #'(lambda ()
638               (local-set-key "\C-m" 'comint-send-and-indent)) t))
639
640 (add-hook 'text-mode-hook 'mdw-text-mode t)
641
642 ;;;--------------------------------------------------------------------------
643 ;;; TeX stuff.
644
645 (setq TeX-output-view-style
646       '(("^dvi$"
647          ("^landscape$" "^pstricks$\\|^pst-\\|^psfrag$")
648          "%(o?)dvips -t landscape %d -o && evince %f")
649         ("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$"
650          "%(o?)dvips %d -o && evince %f")
651         ("^dvi$"
652          ("^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "^landscape$")
653          "%(o?)xdvi %dS -paper a4r -s 0 %d")
654         ("^dvi$" "^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$"
655          "%(o?)xdvi %dS -paper a4 %d")
656         ("^dvi$"
657          ("^a5\\(?:comb\\|paper\\)$" "^landscape$")
658          "%(o?)xdvi %dS -paper a5r -s 0 %d")
659         ("^dvi$" "^a5\\(?:comb\\|paper\\)$" "%(o?)xdvi %dS -paper a5 %d")
660         ("^dvi$" "^b5paper$" "%(o?)xdvi %dS -paper b5 %d")
661         ("^dvi$" "^letterpaper$" "%(o?)xdvi %dS -paper us %d")
662         ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d")
663         ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d")
664         ("^dvi$" "." "%(o?)xdvi %dS %d")
665         ("^pdf$" "." "evince %o")
666         ("^html?$" "." "netscape %o")))
667
668 (setq TeX-open-quote "\""
669       TeX-close-quote "\"")
670
671 (setq reftex-use-external-file-finders t
672       reftex-auto-recenter-toc t)
673
674 (setq reftex-label-alist
675       '(("theorem" ?T "th:" "~\\ref{%s}" t ("theorems?" "th\\.") -2)
676         ("axiom" ?A "ax:" "~\\ref{%s}" t ("axioms?" "ax\\.") -2)
677         ("definition" ?D "def:" "~\\ref{%s}" t ("definitions?" "def\\.") -2)
678         ("proposition" ?P "prop:" "~\\ref{%s}" t
679          ("propositions?" "prop\\.") -2)
680         ("lemma" ?P "lem:" "~\\ref{%s}" t ("lemmas?" "lem\\.") -2)
681         ("example" ?X "eg:" "~\\ref{%s}" t ("examples?") -2)
682         ("exercise" ?E "ex:" "~\\ref{%s}" t ("exercises?" "ex\\.") -2)
683         ("enumerate" ?i "i:" "~\\ref{%s}" item ("items?"))))
684 (setq reftex-section-prefixes
685       '((0 . "part:")
686         (1 . "ch:")
687         (t . "sec:")))
688
689 (setq bibtex-field-delimiters 'double-quotes
690       bibtex-entry-format '(realign opts-or-alts required-fields
691                             numerical-fields last-comma delimiters
692                             unify-case)
693       bibtex-include-OPTkey nil)
694
695 ;;;--------------------------------------------------------------------------
696 ;;; SLIME setup.
697
698 (trap
699  (if (not mdw-fast-startup)
700      (progn
701        (require 'slime-autoloads)
702        (slime-setup '(slime-autodoc slime-c-p-c)))))
703
704 (let ((stuff '((cmucl ("cmucl"))
705                (sbcl ("sbcl") :coding-system utf-8-unix)
706                (clisp ("clisp") :coding-system utf-8-unix))))
707   (or (boundp 'slime-lisp-implementations)
708       (setq slime-lisp-implementations nil))
709   (while stuff
710     (let* ((head (car stuff))
711            (found (assq (car head) slime-lisp-implementations)))
712       (setq stuff (cdr stuff))
713       (if found
714           (rplacd found (cdr head))
715         (setq slime-lisp-implementations
716               (cons head slime-lisp-implementations))))))
717 (setq slime-default-lisp 'sbcl)
718
719 ;;;--------------------------------------------------------------------------
720 ;;; Blogging.
721
722 (setq weblogger-config-alist
723       '(("vox"
724          ("user" . "mdw")
725          ("server-url" . "http://vox.distorted.org.uk/admin/mt-xmlrpc.cgi")
726          ("weblog" . "1"))))
727
728 ;;;--------------------------------------------------------------------------
729 ;;; Shell mode.
730
731 ;; Make the shell mode aware of my prompt.
732
733 (setq shell-prompt-pattern "^[^]#$%>»}\n]*\\([]#$%»}]\\|>>?\\) *")
734 (setq comint-password-prompt-regexp
735       (concat "\\(\\([Ee]nter \\|[Oo]ld \\|[Nn]ew \\|[a-zA-Z0-9_]*'s \\|^\\)"
736               "[Pp]assword\\|pass phrase\\):"))
737
738 ;; Notice passwords, and make C-a work right.
739
740 (add-hook 'shell-mode-hook #'mdw-sh-mode-setup)
741 (add-hook 'shell-mode-hook #'ansi-color-for-comint-mode-on)
742 (setq shell-font-lock-keywords nil)
743
744 (add-hook 'term-mode-hook #'mdw-term-mode-setup)
745
746 ;;;--------------------------------------------------------------------------
747 ;;; Finishing touches.
748
749 (trap (select-window mdw-init-window))
750 (provide 'emacs-init)
751
752 ;;;----- That's all, folks --------------------------------------------------