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