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