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