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