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