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