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