Merge branch 'master' of metalzone: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 (defun mdw-clobber-org-mode-map ()
402 (dolist (key '([S-up] [S-down] [S-left] [S-right]
403 [?\e left] [?\e right]
404 [M-left] [M-right]))
405 (define-key org-mode-map key nil))
406 (define-key org-mode-map [?\C-c left] 'org-shiftleft)
407 (define-key org-mode-map [?\C-c right] 'org-shiftright)
408 (define-key org-mode-map [?\C-c up] 'org-shiftup)
409 (define-key org-mode-map [?\C-c down] 'org-shiftdown)
410 (define-key org-mode-map [C-left] 'org-metaleft)
411 (define-key org-mode-map [C-right] 'org-metaright)
412 (define-key org-mode-map [C-up] 'org-metaup)
413 (define-key org-mode-map [C-down] 'org-metadown))
414 (add-hook 'org-mode-hook 'mdw-clobber-org-mode-map)
415
416 ;; --- Recognising types of files ---
417
418 (setq auto-mode-alist
419 (append `(("\\.p[lm]$" . perl-mode)
420 ("\\.m$" . objc-mode)
421 ("\\.mxd$" . c-mode)
422 ("\\.cs" . csharp-mode)
423 ("\\.org$" . org-mode)
424 ;; ("/[ch]/" . c-mode)
425 (,(concat "/\\("
426 "\\.stgit\\.msg" "\\|"
427 "\\.git/COMMIT_EDITMSG" "\\|"
428 "svn-commit\\.tmp" "\\|"
429 "svk-commit[^/.]*\\.tmp"
430 "\\)$")
431 . text-mode)
432 (,(concat "^" tmpdir "/\\("
433 "svk-commit[^/.]*\\.tmp" "\\|"
434 "gitci\\.[^/.]*" "\\|"
435 "cvs[^/.]\\{6\\}" "\\|"
436 "quilt_header\.[^/.]\\{6\\}"
437 "\\)$")
438 . text-mode)
439 ("\\.calc?$" . apcalc-mode)
440 ("/src/linux/.*\\.\\(c\\|h\\|cc\\)$" . linux-c-mode)
441 ("/\\(s\\|sh\\)/" . arm-assembler-mode)
442 ("\\.\\(cmd\\|exec\\|rexx\\)$" . rexx-mode)
443 ("\\.st$" . smalltalk-mode)
444 ("\\.msgs$" . messages-mode)
445 ("/all-cmds\\.in$" . cpp-messages-mode)
446 ("\\.\\(tex\\|dtx\\)$" . latex-mode)
447 ("\\.gc$" . haskell.-mode)
448 (,(concat "^" (getenv "HOME") "/News/") . mdwmail-mode)
449 (,(concat "^" tmpdir "/\\(SLRN\\|snd\\|pico\\|mutt\\)")
450 . mdwmail-mode))
451 auto-mode-alist))
452
453 (setq interpreter-mode-alist
454 (append `(("runlisp" . lisp-mode))
455 interpreter-mode-alist))
456
457 (setq completion-ignored-extensions
458 (append `(".hc" ".hi") completion-ignored-extensions))
459
460 ;; --- Some common local definitions ---
461
462 (make-variable-buffer-local 'mdw-auto-indent)
463
464 (mapcar (lambda (hook) (add-hook hook 'mdw-misc-mode-config))
465 '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
466 csharp-mode-hook perl-mode-hook cperl-mode-hook
467 python-mode-hook awk-mode-hook tcl-mode-hook
468 asm-mode-hook TeX-mode-hook LaTeX-mode-hook
469 TeXinfo-mode-hook tex-mode-hook latex-mode-hook
470 texinfo-mode-hook emacs-lisp-mode-hook scheme-mode-hook
471 lisp-mode-hook lisp-interaction-mode-hook
472 inferior-lisp-mode-hook slime-repl-mode-hook
473 sml-mode-hook haskell-mode-hook erlang-mode-hook
474 smalltalk-mode-hook rexx-mode-hook
475 arm-assembler-mode-hook))
476
477 (global-font-lock-mode t)
478 (defalias 'perl-mode 'cperl-mode)
479
480 ;;;----- Rootly editingness -------------------------------------------------
481
482 (eval-after-load "tramp"
483 '(progn
484 (setq tramp-methods
485 (mdw-uniquify-alist
486 `(("become"
487 (tramp-connection-function tramp-open-connection-su)
488 (tramp-remote-sh "/bin/sh")
489 (tramp-login-program "become")
490 (tramp-copy-program nil)
491 (tramp-copy-args nil)
492 (tramp-copy-keep-date-arg nil)
493 (tramp-login-args ("TERM=dumb" "%u")))
494 ("really"
495 (tramp-connection-function tramp-open-connection-su)
496 (tramp-login-program "really")
497 (tramp-login-args ("-u" "%u" "--"
498 "env" "TERM=dumb" "/bin/sh"))
499 (tramp-copy-program nil)
500 (tramp-copy-args nil)
501 (tramp-copy-keep-date-arg nil)
502 (tramp-remote-sh "/bin/sh"))
503 ,@tramp-methods)))
504 (setq tramp-multi-connection-function-alist
505 (mdw-uniquify-alist
506 '(("bc" tramp-multi-connect-su "become TERM=dumb %u%n"))
507 '(("r" tramp-multi-connect-su "really -u %u%n"))
508 tramp-multi-connection-function-alist))
509 (setq tramp-default-method "ssh")
510 (setq tramp-default-method-alist
511 `(("\\`localhost\\'" ""
512 ,(cond ((executable-find "become") "become")
513 ((executable-find "really") "really")
514 (t "su")))))))
515
516 ;;;----- General fontification ----------------------------------------------
517
518 ;; --- Configure lazy fontification ---
519
520 (and (fboundp 'lazy-lock-mode)
521 (setq font-lock-support-mode 'lazy-lock-mode))
522 ; (setq lazy-lock-defer-contextually t)
523 (setq lazy-lock-defer-time nil)
524 (setq font-lock-maximum-decoration 3)
525 (setq lazy-lock-minimum-size 0)
526 (setq lazy-lock-stealth-time 5)
527 (setq lazy-lock-stealth-lines 100)
528 (setq lazy-lock-stealth-verbose t)
529
530 (add-hook 'after-make-frame-functions 'mdw-do-set-font)
531 (add-hook 'term-setup-hook (lambda () (mdw-do-set-font (selected-frame))))
532 (add-hook 'window-setup-hook (lambda () (mdw-do-set-font (selected-frame))))
533
534 (add-hook 'c-mode-hook 'mdw-fontify-c-and-c++ t)
535 (add-hook 'objc-mode-hook 'mdw-fontify-c-and-c++ t)
536 (add-hook 'c++-mode-hook 'mdw-fontify-c-and-c++ t)
537 (add-hook 'linux-c-mode-hook #'(lambda () (setq c-basic-offset 8)))
538 (add-hook 'asm-mode-hook 'mdw-fontify-asm t)
539
540 (add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t)
541 (add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
542
543 (add-hook 'java-mode-hook 'mdw-fontify-java t)
544 (add-hook 'csharp-mode-hook 'mdw-fontify-csharp t)
545
546 (add-hook 'awk-mode-hook 'mdw-fontify-awk t)
547
548 (add-hook 'perl-mode-hook 'mdw-fontify-perl t)
549 (add-hook 'cperl-mode-hook 'mdw-fontify-perl t)
550
551 (setq-default py-indent-offset 2)
552 (add-hook 'python-mode-hook 'mdw-fontify-python t)
553 (setq py-python-command-args `("-i" "-colors" ,(if mdw-black-background
554 "Linux"
555 "LightBG")))
556
557 (setq-default tcl-indent-level 2)
558 (add-hook 'tcl-mode-hook 'mdw-fontify-tcl t)
559
560 (add-hook 'rexx-mode-hook 'mdw-fontify-rexx t)
561
562 (setq sml-nested-if-indent t)
563 (setq sml-case-indent nil)
564 (setq sml-indent-level 4)
565 (setq sml-type-of-indent nil)
566 (add-hook 'sml-mode-hook 'mdw-fontify-sml t)
567
568 (add-hook 'haskell-mode-hook 'mdw-fontify-haskell t)
569 (setq-default haskell-indent-offset 2)
570
571 (add-hook 'erlang-mode-hook 'mdw-fontify-erlang t)
572
573 (add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t)
574 (add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t)
575
576 (setq LaTeX-table-label "tbl:")
577 (setq TeX-auto-untabify nil)
578 (add-hook 'TeX-mode-hook 'mdw-fontify-tex t)
579 (add-hook 'tex-mode-hook 'mdw-fontify-tex t)
580 (add-hook 'LaTeX-mode-hook 'mdw-fontify-tex t)
581 (add-hook 'latex-mode-hook 'mdw-fontify-tex t)
582
583 (add-hook 'sh-mode-hook #'mdw-setup-sh-script-mode)
584 (add-hook 'autoconf-mode-hook #'mdw-setup-m4)
585 (add-hook 'm4-mode-hook #'mdw-setup-m4)
586
587 (add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t)
588 (add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t)
589
590 (add-hook 'emacs-lisp-mode-hook 'mdw-fontify-lispy t)
591 (add-hook 'scheme-mode-hook 'mdw-fontify-lispy t)
592 (add-hook 'lisp-mode-hook 'mdw-fontify-lispy t)
593 (add-hook 'inferior-lisp-mode-hook 'mdw-fontify-lispy t)
594 (add-hook 'lisp-interaction-mode-hook 'mdw-fontify-lispy t)
595 (add-hook 'slime-repl-mode-hook 'mdw-fontify-lispy t)
596 (add-hook 'lisp-mode-hook 'mdw-common-lisp-indent t)
597 (add-hook 'inferior-lisp-mode-hook
598 #'(lambda ()
599 (local-set-key "\C-m" 'comint-send-and-indent)) t)
600
601 (add-hook 'text-mode-hook 'mdw-text-mode t)
602
603 ;;;----- TeX stuff ----------------------------------------------------------
604
605 (setq TeX-output-view-style
606 '(("^dvi$"
607 ("^landscape$" "^pstricks$\\|^pst-\\|^psfrag$")
608 "%(o?)dvips -t landscape %d -o && evince %f")
609 ("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$"
610 "%(o?)dvips %d -o && evince %f")
611 ("^dvi$"
612 ("^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "^landscape$")
613 "%(o?)xdvi %dS -paper a4r -s 0 %d")
614 ("^dvi$" "^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$"
615 "%(o?)xdvi %dS -paper a4 %d")
616 ("^dvi$"
617 ("^a5\\(?:comb\\|paper\\)$" "^landscape$")
618 "%(o?)xdvi %dS -paper a5r -s 0 %d")
619 ("^dvi$" "^a5\\(?:comb\\|paper\\)$" "%(o?)xdvi %dS -paper a5 %d")
620 ("^dvi$" "^b5paper$" "%(o?)xdvi %dS -paper b5 %d")
621 ("^dvi$" "^letterpaper$" "%(o?)xdvi %dS -paper us %d")
622 ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d")
623 ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d")
624 ("^dvi$" "." "%(o?)xdvi %dS %d")
625 ("^pdf$" "." "evince %o")
626 ("^html?$" "." "netscape %o")))
627
628 (setq reftex-use-external-file-finders t
629 reftex-auto-recenter-toc t)
630
631 (setq reftex-label-alist
632 '(("theorem" ?T "th:" "~\\ref{%s}" t ("theorems?" "th\\.") -2)
633 ("axiom" ?A "ax:" "~\\ref{%s}" t ("axioms?" "ax\\.") -2)
634 ("definition" ?D "def:" "~\\ref{%s}" t ("definitions?" "def\\.") -2)
635 ("proposition" ?P "prop:" "~\\ref{%s}" t
636 ("propositions?" "prop\\.") -2)
637 ("lemma" ?P "lem:" "~\\ref{%s}" t ("lemmas?" "lem\\.") -2)
638 ("example" ?X "eg:" "~\\ref{%s}" t ("examples?") -2)
639 ("exercise" ?E "ex:" "~\\ref{%s}" t ("exercises?" "ex\\.") -2)
640 ("enumerate" ?i "i:" "~\\ref{%s}" item ("items?"))))
641 (setq reftex-section-prefixes
642 '((0 . "part:")
643 (1 . "ch:")
644 (t . "sec:")))
645
646 (setq bibtex-field-delimiters 'double-quotes
647 bibtex-entry-format '(realign opts-or-alts required-fields
648 numerical-fields last-comma delimiters
649 unify-case)
650 bibtex-include-OPTkey nil)
651
652 ;;;----- SLIME setup --------------------------------------------------------
653
654 (trap
655 (if (not mdw-fast-startup)
656 (progn
657 (require 'slime-autoloads)
658 (slime-setup '(slime-autodoc slime-c-p-c)))))
659
660 (let ((stuff '((cmucl ("cmucl"))
661 (sbcl ("sbcl") :coding-system utf-8-unix)
662 (clisp ("clisp") :coding-system utf-8-unix))))
663 (or (boundp 'slime-lisp-implementations)
664 (setq slime-lisp-implementations nil))
665 (while stuff
666 (let* ((head (car stuff))
667 (found (assq (car head) slime-lisp-implementations)))
668 (setq stuff (cdr stuff))
669 (if found
670 (rplacd found (cdr head))
671 (setq slime-lisp-implementations
672 (cons head slime-lisp-implementations))))))
673 (setq slime-default-lisp 'sbcl)
674
675 ;;;----- Blogging -----------------------------------------------------------
676
677 (setq weblogger-config-alist
678 '(("vox"
679 ("user" . "mdw")
680 ("server-url" . "http://vox.distorted.org.uk/admin/mt-xmlrpc.cgi")
681 ("weblog" . "1"))))
682
683 ;;;----- Shell mode ---------------------------------------------------------
684
685 ;; --- Make the shell mode aware of my prompt ---
686
687 (setq shell-prompt-pattern "^[^]#$%>»}\n]*[]#$%>»}] *")
688 (setq comint-password-prompt-regexp
689 (concat "\\(\\([Oo]ld \\|[Nn]ew \\|[a-zA-Z0-9_]*'s \\|^\\)"
690 "[Pp]assword\\|pass phrase\\):\\s *\\'"))
691
692 ;; --- Notice passwords, and make C-a work right ---
693
694 (add-hook 'shell-mode-hook #'mdw-sh-mode-setup)
695 (add-hook 'shell-mode-hook #'ansi-color-for-comint-mode-on)
696 (setq shell-font-lock-keywords nil)
697
698 (add-hook 'term-mode-hook #'mdw-term-mode-setup)
699
700 ;;;----- Finishing touches --------------------------------------------------
701
702 (trap (select-window mdw-init-window))
703 (provide 'emacs-init)
704
705 ;;;----- That's all, folks --------------------------------------------------