chiark / gitweb /
43be90f2228c923d89a710ba73bb56e07a3d536a
[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 next-line-add-newlines nil)       ;Don't add weird newlines
195 (setq split-height-threshold 45)        ;Reuse windows where sensible
196 (setq display-buffer-reuse-frames nil   ;Don't confuse me by showing buffers
197       iswitchb-default-method 'samewindow) ;in other random frames
198 (setq dired-deletion-confirmer          ;Make deletion easier in dired
199       (symbol-function 'y-or-n-p))
200 (setq read-quoted-char-radix 16)        ;C-q HEX-STUFF [RET]
201 (setq dired-listing-switches "-alF")    ;Do `ls -F' things in dired windows
202 (setq wdired-allow-to-change-permissions t)
203 (setq case-fold-file-names nil)         ;Don't translate file names (grr...)
204 (setq scroll-step 5)                    ;Don't scroll too much at a time
205 (setq-default fill-column 77)           ;I use rather narrow windows
206 (setq-default comment-column 40)        ;Set a standard comment column
207 (setq-default truncate-partial-width-windows nil)
208 (setq default-indicate-empty-lines t)
209 (setq whitespace-style
210       '(trailing space-before-tab space-after-tab empty indentation))
211 (setq woman-use-own-frame nil           ;Keep man pages somewhere sensible
212       woman-fill-column 72)             ;Right margin position.
213 (setq diff-switches "-u"                ;I like reading unified diffs
214       cvs-diff-flags (list diff-switches))
215 (setq echo-keystrokes 10)               ;Long delay before keystrokes echo
216 (setq ange-ftp-ftp-program-name "pftp") ;Use passive FTP
217 (setq find-ls-option                    ;Build file lists efficiently
218       '("-print0 | xargs -0r ls -ld" . "ld"))
219 (setq bookmark-save-flag 0)             ;Save bookmarks automatically
220 (setq x-gtk-file-dialog-help-text nil)
221 (setq Info-fontify-maximum-menu-size 100000)
222 (setq set-mark-command-repeat-pop t)
223 (setq-default proced-filter 'all
224               proced-sort 'user)
225 (setq ispell-program-name "aspell"
226       ispell-local-dictionary "en_GB-ize-w_accents"
227       flyspell-default-dictionary "en_GB-ize-w_accents"
228       ispell-silently-savep t)
229 (trap
230   (require 'uniquify)
231   (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
232   (setq uniquify-after-kill-buffer-p t))
233 (transient-mark-mode t)
234 (setq mark-even-if-inactive t)
235 (trap
236   (tooltip-mode 0)
237   (tool-bar-mode 0))
238 (trap (or mdw-fast-startup (global-auto-revert-mode t)))
239 (setq psgml-html-build-new-buffer nil)
240
241 (defvar mdw-black-background t)
242
243 (eval-after-load "outline"
244   '(progn
245      (trap (require 'foldout))
246      (define-key outline-mode-prefix-map [?\C-r] 'reveal-mode)
247      (define-key outline-mode-prefix-map [?\C--] 'mdw-outline-collapse-all)))
248
249 (setq cltl2-root-url (mdw-config 'cltl-url))
250 (setq common-lisp-hyperspec-root (mdw-config 'hyperspec-url))
251
252 ;;;--------------------------------------------------------------------------
253 ;;; W3 and URL fetching stuff.
254
255 (let ((proxy (mdw-config 'http-proxy)))
256   (setq url-proxy-services
257         `(("http" . ,proxy)
258           ("ftp" . ,proxy)
259           ("gopher" . ,proxy))))
260 (setq url-cookie-untrusted-urls '("."))
261
262 (setq browse-url-browser-function (mdw-good-url-browser)
263       browse-url-mozilla-program "firefox")
264
265 (setq w3m-default-display-inline-images t)
266
267 (setq w3-do-incremental-display t
268       w3-use-menus '(file edit view go bookmark options
269                      buffers style search emacs nil help)
270       w3-display-inline-image t
271       w3-keybinding 'info)
272
273 ;;;--------------------------------------------------------------------------
274 ;;; Calendar configuration.
275
276 (setq diary-file "~/etc/diary")
277
278 ;; Trivial stuff for the sunrise/sunset calculations.
279
280 (setq calendar-latitude 52.2)
281 (setq calendar-longitude 0.1)
282 (setq calendar-location-name "Cambridge, UK")
283
284 ;; Holidays.
285
286 (and (not mdw-fast-startup)
287      (trap
288        (require 'ew-hols)
289        (setq other-holidays (append english-and-welsh-bank-holidays
290                                     other-holidays))))
291
292 ;; Date format fiddling.
293
294 (setq european-calendar-style t)
295
296 (setq diary-date-forms '((day "[-/]" month "[^-/0-9]")
297                          (day " *" monthname "[ \t]*\\(\^M\\|\n\\)")
298                          (backup day " *" monthname "\\W+\\<[^*0-9]")
299                          (day "[-/]" month "[-/]" year "[^0-9]")
300                          (day " *" monthname " *" year "[^0-9]")
301                          (year "[-/]" month "[-/]" day "[^0-9]")
302                          (dayname "\\W")))
303
304 ;; Fancy diary handling.
305
306 (add-hook 'diary-display-hook 'fancy-diary-display)
307 (setq diary-list-include-blanks t)
308 (add-hook 'list-diary-entries-hook 'sort-diary-entries t)
309 (add-hook 'list-diary-entries-hook 'include-other-diary-files)
310 (add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
311
312 ;; Appointment management.
313
314 (add-hook 'diary-hook 'appt-make-list)
315 (setq appt-issue-message t)
316 (setq appt-display-interval 3)
317 (setq appt-message-warning-time 10)
318
319 ;; Org-mode agenda.
320
321 (setq org-agenda-include-diary t
322       org-tags-column -77)
323
324 ;; Cosmetic stuff.
325
326 (setq display-time-24hr-format t)
327 (display-time)
328 (trap
329   (if window-system
330       (let ((view-diary-entries-initially t))
331         (calendar))))
332
333 ;;;--------------------------------------------------------------------------
334 ;;; MailCrypt.
335
336 ;; Define more mode hooks for MailCrypt.
337
338 (setq mdw-mc-modes
339       '((mdwmail-mode (encrypt . mdwmail-mc-encrypt)
340                       (sign . mdwmail-mc-sign))))
341
342 ;; Load the MailCrypt support.
343
344 (trap
345   (and (string-match "linux" (symbol-name system-type))
346        (not mdw-fast-startup)
347        (progn (require 'mailcrypt-init)
348               (require 'mailcrypt)
349               (setq mc-default-scheme 'mc-scheme-gpg)
350               (setq mc-pgp-user-id "mdw-nsict-pgp")
351               (setq mc-gpg-user-id "mdw-nsict-gpg")
352               (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
353               (setq mc-pgp-always-sign t)
354               (setq mc-gpg-always-sign t)
355               (setq mc-always-replace 'never)
356               (setq mc-passwd-timeout 3600)
357               (setq mc-temp-directory tmpdir)
358               (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
359               (define-key mc-write-mode-map "\C-c/S" 'mc-sign-region)
360               (define-key mc-write-mode-map "\C-c/E" 'mc-encrypt-region)
361               (add-hook 'text-mode-hook 'mc-install-write-mode))))
362
363 ;;;--------------------------------------------------------------------------
364 ;;; Other common declarations.
365
366 ;; Default frame size.
367
368 (setq default-frame-alist
369       (mdw-uniquify-alist
370        '((width . 78)
371          (height . 33)
372          (vertical-scroll-bars . right)
373          (cursor-type . bar)
374          (cursor-blink . t)
375          (left-fringe . 5)
376          (right-fringe . 5)
377          (scroll-bar-width . 15)
378          (cursor-color . "red"))
379        (if mdw-black-background
380            '((background-mode . dark))
381          '((background-mode . light)))
382        (and (eq window-system 'pm)
383             '((font . "-os2-System VIO-medium-r-normal--*-40-*-*-m-*-cp850")
384               (menu-font . "8.Helv")
385               (background-color . "lightgrey")))
386        default-frame-alist))
387
388 ;; Other frame fiddling.
389
390 (setq frame-title-format '("" invocation-name "@" system-name ": %b"))
391
392 ;; Global keymap changes.
393
394 (trap
395   (windmove-default-keybindings))
396 (setq windmove-wrap-around t)
397 (trap (iswitchb-mode))
398 (progn
399   (global-set-key [?\C-x ?w left] 'windmove-left)
400   (global-set-key [?\C-x ?w ?h] 'windmove-left)
401   (global-set-key [?\C-x ?w up] 'windmove-up)
402   (global-set-key [?\C-x ?w ?k] 'windmove-up)
403   (global-set-key [?\C-x ?w down] 'windmove-down)
404   (global-set-key [?\C-x ?w ?j] 'windmove-down)
405   (global-set-key [?\C-x ?w right] 'windmove-right)
406   (global-set-key [?\C-x ?w ?l] 'windmove-right)
407   (global-set-key [?\C-x ?g ?l] 'org-store-link)
408   (global-set-key [?\C-x ?g ?a] 'org-agenda)
409   (global-set-key [?\C-x ?g ?b] 'org-iswitchb)
410   (global-set-key [?\C-x ?t ?i] 'timeclock-in)
411   (global-set-key [?\C-x ?t ?c] 'timeclock-change)
412   (global-set-key [?\C-x ?t ?o] 'timeclock-out)
413   (global-set-key [?\C-x ?t ?r] 'timeclock-reread-log)
414   (global-set-key [?\C-x ?t ?w] 'timeclock-workday-remaining-string)
415   (global-set-key [?\C-x ?t ?s] 'timeclock-status-string)
416   (global-set-key [?\C-x ?t ?p] 'nc-timesheet-prepare)
417   (global-set-key [?\C-x ?t ?\C-m] 'nc-timesheet-submit)
418   (global-set-key [?\M-#] 'calc-dispatch)
419   (global-set-key [?\C-x ?/] 'auto-fill-mode)
420   (global-set-key [?\C-x ?w ?d] 'mdw-divvy-window)
421   (global-set-key [insertchar] 'overwrite-mode)
422   (global-set-key [?\C-x ?\C-n] 'skel-create-file)
423   (global-set-key [?\C-x ?4 ?n] 'skel-create-file-other-window)
424   (global-set-key [?\C-x ?5 ?n] 'skel-create-file-other-frame)
425   (global-set-key [delete] 'delete-char)
426   (global-set-key [?\M-q] 'mdw-fill-paragraph)
427   (global-set-key [?\C-h ?\C-m] 'manual-entry)
428   (global-set-key [C-M-backspace] 'backward-kill-sexp)
429   (global-set-key [mode-line C-mouse-1] 'mouse-tear-off-window)
430   (global-set-key [vertical-scroll-bar C-down-mouse-1]
431                   'mouse-drag-vertical-line)
432   (global-set-key [vertical-scroll-bar C-mouse-1]
433                   #'(lambda () (interactive)))
434   (global-set-key [XF86WakeUp] "")
435   (and (not mdw-fast-startup) (fboundp 'hippie-expand)
436        (global-set-key [?\M-/] 'hippie-expand)))
437
438 (eval-after-load "dired"
439   '(progn
440      (define-key dired-mode-map [?\C-x ?\C-q]
441        'wdired-change-to-wdired-mode)))
442
443 (add-hook 'org-mode-hook
444           #'(lambda () (mdw-clobber-evil-keymap org-mode-map)))
445 (add-hook 'org-agenda-mode-hook
446           #'(lambda () (mdw-clobber-evil-keymap org-agenda-mode-map)))
447
448 ;; Recognising types of files.
449
450 (setq auto-mode-alist
451       (append `(("\\.p[lm]$" . perl-mode)
452                 ("\\.m$" . objc-mode)
453                 ("\\.mxd$" . c-mode)
454                 ("\\.cs$" . csharp-mode)
455                 ("\\.go$" . go-mode)
456                 ("\\.org$" . org-mode)
457                 ;; ("/[ch]/" . c-mode)
458                 (,(concat "/\\("
459                           "\\.stgit\\.msg" "\\|"
460                           "\\.git/COMMIT_EDITMSG" "\\|"
461                           "svn-commit\\.tmp" "\\|"
462                           "svk-commit[^/.]*\\.tmp"
463                           "\\)$")
464                  . text-mode)
465                 (,(concat "^" tmpdir "/\\("
466                           "svk-commit[^/.]*\\.tmp" "\\|"
467                           "gitci\\.[^/.]*" "\\|"
468                           "cvs[^/.]\\{6\\}" "\\|"
469                           "quilt_header\.[^/.]\\{6\\}"
470                           "\\)$")
471                  . text-mode)
472                 ("\\.calc?$" . apcalc-mode)
473                 ("/src/linux/.*\\.\\(c\\|h\\|cc\\)$" . linux-c-mode)
474                 ("/\\(s\\|sh\\)/" . arm-assembler-mode)
475                 ("\\.\\(cmd\\|exec\\|rexx\\)$" . rexx-mode)
476                 ("\\.st$" . smalltalk-mode)
477                 ("\\.msgs$" . messages-mode)
478                 ("/all-cmds\\.in$" . cpp-messages-mode)
479                 ("\\.\\(tex\\|dtx\\)$" . latex-mode)
480                 ("\\.gc$" . haskell.-mode)
481                 (,(concat "^" (getenv "HOME") "/News/") . mdwmail-mode)
482                 (,(concat "^" tmpdir "/\\(SLRN\\|snd\\|pico\\|mutt\\)")
483                  . mdwmail-mode))
484               auto-mode-alist))
485
486 (setq interpreter-mode-alist
487       (append `(("runlisp" . lisp-mode))
488               interpreter-mode-alist))
489
490 (setq completion-ignored-extensions
491       (append `(".hc" ".hi") completion-ignored-extensions))
492
493 ;; Some common local definitions.
494
495 (make-variable-buffer-local 'mdw-auto-indent)
496
497 (mapcar (lambda (hook) (add-hook hook 'mdw-misc-mode-config))
498         '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
499           csharp-mode-hook perl-mode-hook cperl-mode-hook
500           python-mode-hook pyrec-mode-hook icon-mode-hook awk-mode-hook
501           tcl-mode-hook go-mode-hook
502           asm-mode-hook TeX-mode-hook LaTeX-mode-hook
503           TeXinfo-mode-hook tex-mode-hook latex-mode-hook
504           texinfo-mode-hook emacs-lisp-mode-hook scheme-mode-hook
505           lisp-mode-hook lisp-interaction-mode-hook
506           inferior-lisp-mode-hook slime-repl-mode-hook
507           sml-mode-hook haskell-mode-hook erlang-mode-hook
508           smalltalk-mode-hook rexx-mode-hook
509           arm-assembler-mode-hook))
510
511 (global-font-lock-mode t)
512 (defalias 'perl-mode 'cperl-mode)
513
514 ;;;--------------------------------------------------------------------------
515 ;;; Rootly editingness.
516
517 (eval-after-load "tramp"
518   '(let ((fix-args (if (mdw-version-< tramp-version "2.1")
519                        #'append #'identity)))
520      (setq tramp-methods
521            (mdw-uniquify-alist
522             `(("become"
523                (tramp-connection-function tramp-open-connection-su)
524                (tramp-remote-sh "/bin/sh")
525                (tramp-login-program "become")
526                (tramp-copy-program nil)
527                (tramp-copy-args nil)
528                (tramp-copy-keep-date-arg nil)
529                (tramp-login-args ,(funcall fix-args `("TERM=dumb" "%u"))))
530               ("really"
531                (tramp-connection-function tramp-open-connection-su)
532                (tramp-login-program "really")
533                (tramp-login-args ,(funcall fix-args
534                                            `("-u" "%u")
535                                            `("--")
536                                            `("env" "TERM=dumb" "/bin/sh")))
537                (tramp-copy-program nil)
538                (tramp-copy-args nil)
539                (tramp-copy-keep-date-arg nil)
540                (tramp-remote-sh "/bin/sh"))
541               ,@tramp-methods)))
542      (setq tramp-default-method "ssh")
543      (setq tramp-default-method-alist
544            `(("\\`\\(localhost\\|\\)\\'" ""
545               ,(cond ((executable-find "become") "become")
546                      ((executable-find "really") "really")
547                      (t "su")))))))
548
549 ;;;--------------------------------------------------------------------------
550 ;;; General fontification.
551
552 ;; Configure lazy fontification.
553
554 (and (fboundp 'lazy-lock-mode)
555      (setq font-lock-support-mode 'lazy-lock-mode))
556 ; (setq lazy-lock-defer-contextually t)
557 (setq lazy-lock-defer-time nil
558       font-lock-maximum-decoration 3
559       lazy-lock-minimum-size 0
560       lazy-lock-stealth-time 5
561       lazy-lock-stealth-lines 100
562       lazy-lock-stealth-verbose t)
563
564 (progn
565   (add-hook 'c-mode-hook 'mdw-fontify-c-and-c++ t)
566   (add-hook 'objc-mode-hook 'mdw-fontify-c-and-c++ t)
567   (add-hook 'c++-mode-hook 'mdw-fontify-c-and-c++ t)
568   (add-hook 'linux-c-mode-hook #'(lambda () (setq c-basic-offset 8)))
569   (add-hook 'asm-mode-hook 'mdw-fontify-asm t)
570   (add-hook 'go-mode-hook 'mdw-fontify-go t)
571
572   (add-hook 'icon-mode-hook 'mdw-fontify-icon t)
573
574   (add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t)
575   (add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
576
577   (add-hook 'java-mode-hook 'mdw-fontify-java t)
578   (add-hook 'csharp-mode-hook 'mdw-fontify-csharp t)
579
580   (add-hook 'awk-mode-hook 'mdw-fontify-awk t)
581
582   (add-hook 'perl-mode-hook 'mdw-fontify-perl t)
583   (add-hook 'cperl-mode-hook 'mdw-fontify-perl t))
584
585 (progn
586   (setq-default py-indent-offset 2
587                 py-python-command-args
588                 `("-i" "-colors" ,(if mdw-black-background
589                                       "Linux" "LightBG")))
590   (add-hook 'python-mode-hook 'mdw-fontify-python t)
591   (add-hook 'pyrex-mode-hook 'mdw-fontify-pyrex t))
592
593 (setq-default tcl-indent-level 2)
594 (add-hook 'tcl-mode-hook 'mdw-fontify-tcl t)
595
596 (add-hook 'rexx-mode-hook 'mdw-fontify-rexx t)
597
598 (setq sml-nested-if-indent t
599       sml-case-indent nil
600       sml-indent-level 4
601       sml-type-of-indent nil)
602 (add-hook 'sml-mode-hook 'mdw-fontify-sml t)
603
604 (add-hook 'haskell-mode-hook 'mdw-fontify-haskell t)
605 (setq-default haskell-indent-offset 2)
606
607 (add-hook 'erlang-mode-hook 'mdw-fontify-erlang t)
608
609 (add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t)
610 (add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t)
611
612 (setq LaTeX-table-label "tbl:")
613 (setq TeX-auto-untabify nil)
614 (add-hook 'TeX-mode-hook 'mdw-fontify-tex t)
615 (add-hook 'tex-mode-hook 'mdw-fontify-tex t)
616 (add-hook 'LaTeX-mode-hook 'mdw-fontify-tex t)
617 (add-hook 'latex-mode-hook 'mdw-fontify-tex t)
618
619 (add-hook 'sh-mode-hook #'mdw-setup-sh-script-mode)
620 (add-hook 'autoconf-mode-hook #'mdw-setup-m4)
621 (add-hook 'm4-mode-hook #'mdw-setup-m4)
622
623 (add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t)
624 (add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t)
625
626 (progn
627   (add-hook 'emacs-lisp-mode-hook 'mdw-fontify-lispy t)
628   (add-hook 'scheme-mode-hook 'mdw-fontify-lispy t)
629   (add-hook 'lisp-mode-hook 'mdw-fontify-lispy t)
630   (add-hook 'inferior-lisp-mode-hook 'mdw-fontify-lispy t)
631   (add-hook 'lisp-interaction-mode-hook 'mdw-fontify-lispy t)
632   (add-hook 'slime-repl-mode-hook 'mdw-fontify-lispy t)
633   (add-hook 'lisp-mode-hook 'mdw-common-lisp-indent t)
634   (add-hook 'inferior-lisp-mode-hook
635           #'(lambda ()
636               (local-set-key "\C-m" 'comint-send-and-indent)) t))
637
638 (add-hook 'text-mode-hook 'mdw-text-mode t)
639
640 ;;;--------------------------------------------------------------------------
641 ;;; TeX stuff.
642
643 (setq TeX-output-view-style
644       '(("^dvi$"
645          ("^landscape$" "^pstricks$\\|^pst-\\|^psfrag$")
646          "%(o?)dvips -t landscape %d -o && evince %f")
647         ("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$"
648          "%(o?)dvips %d -o && evince %f")
649         ("^dvi$"
650          ("^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "^landscape$")
651          "%(o?)xdvi %dS -paper a4r -s 0 %d")
652         ("^dvi$" "^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$"
653          "%(o?)xdvi %dS -paper a4 %d")
654         ("^dvi$"
655          ("^a5\\(?:comb\\|paper\\)$" "^landscape$")
656          "%(o?)xdvi %dS -paper a5r -s 0 %d")
657         ("^dvi$" "^a5\\(?:comb\\|paper\\)$" "%(o?)xdvi %dS -paper a5 %d")
658         ("^dvi$" "^b5paper$" "%(o?)xdvi %dS -paper b5 %d")
659         ("^dvi$" "^letterpaper$" "%(o?)xdvi %dS -paper us %d")
660         ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d")
661         ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d")
662         ("^dvi$" "." "%(o?)xdvi %dS %d")
663         ("^pdf$" "." "evince %o")
664         ("^html?$" "." "netscape %o")))
665
666 (setq TeX-open-quote "\""
667       TeX-close-quote "\"")
668
669 (setq reftex-use-external-file-finders t
670       reftex-auto-recenter-toc t)
671
672 (setq reftex-label-alist
673       '(("theorem" ?T "th:" "~\\ref{%s}" t ("theorems?" "th\\.") -2)
674         ("axiom" ?A "ax:" "~\\ref{%s}" t ("axioms?" "ax\\.") -2)
675         ("definition" ?D "def:" "~\\ref{%s}" t ("definitions?" "def\\.") -2)
676         ("proposition" ?P "prop:" "~\\ref{%s}" t
677          ("propositions?" "prop\\.") -2)
678         ("lemma" ?P "lem:" "~\\ref{%s}" t ("lemmas?" "lem\\.") -2)
679         ("example" ?X "eg:" "~\\ref{%s}" t ("examples?") -2)
680         ("exercise" ?E "ex:" "~\\ref{%s}" t ("exercises?" "ex\\.") -2)
681         ("enumerate" ?i "i:" "~\\ref{%s}" item ("items?"))))
682 (setq reftex-section-prefixes
683       '((0 . "part:")
684         (1 . "ch:")
685         (t . "sec:")))
686
687 (setq bibtex-field-delimiters 'double-quotes
688       bibtex-entry-format '(realign opts-or-alts required-fields
689                             numerical-fields last-comma delimiters
690                             unify-case)
691       bibtex-include-OPTkey nil)
692
693 ;;;--------------------------------------------------------------------------
694 ;;; SLIME setup.
695
696 (trap
697  (if (not mdw-fast-startup)
698      (progn
699        (require 'slime-autoloads)
700        (slime-setup '(slime-autodoc slime-c-p-c)))))
701
702 (let ((stuff '((cmucl ("cmucl"))
703                (sbcl ("sbcl") :coding-system utf-8-unix)
704                (clisp ("clisp") :coding-system utf-8-unix))))
705   (or (boundp 'slime-lisp-implementations)
706       (setq slime-lisp-implementations nil))
707   (while stuff
708     (let* ((head (car stuff))
709            (found (assq (car head) slime-lisp-implementations)))
710       (setq stuff (cdr stuff))
711       (if found
712           (rplacd found (cdr head))
713         (setq slime-lisp-implementations
714               (cons head slime-lisp-implementations))))))
715 (setq slime-default-lisp 'sbcl)
716
717 ;;;--------------------------------------------------------------------------
718 ;;; Blogging.
719
720 (setq weblogger-config-alist
721       '(("vox"
722          ("user" . "mdw")
723          ("server-url" . "http://vox.distorted.org.uk/admin/mt-xmlrpc.cgi")
724          ("weblog" . "1"))))
725
726 ;;;--------------------------------------------------------------------------
727 ;;; Shell mode.
728
729 ;; Make the shell mode aware of my prompt.
730
731 (setq shell-prompt-pattern "^[^]#$%>»}\n]*\\([]#$%»}]\\|>>?\\) *")
732 (setq comint-password-prompt-regexp
733       (concat "\\(\\([Ee]nter \\|[Oo]ld \\|[Nn]ew \\|[a-zA-Z0-9_]*'s \\|^\\)"
734               "[Pp]assword\\|pass phrase\\):"))
735
736 ;; Notice passwords, and make C-a work right.
737
738 (add-hook 'shell-mode-hook #'mdw-sh-mode-setup)
739 (add-hook 'shell-mode-hook #'ansi-color-for-comint-mode-on)
740 (setq shell-font-lock-keywords nil)
741
742 (add-hook 'term-mode-hook #'mdw-term-mode-setup)
743
744 ;;;--------------------------------------------------------------------------
745 ;;; Finishing touches.
746
747 (trap (select-window mdw-init-window))
748 (provide 'emacs-init)
749
750 ;;;----- That's all, folks --------------------------------------------------