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