dot-emacs: Turn on gtags mode in general.
[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 ;; --- Recognising types of files ---
391
392 (setq auto-mode-alist
393 (append `(("\\.p[lm]$" . perl-mode)
394 ("\\.m$" . objc-mode)
395 ("\\.mxd$" . c-mode)
396 ("\\.cs" . csharp-mode)
397 ("\\.org$" . org-mode)
398 ;; ("/[ch]/" . c-mode)
399 (,(concat "/\\("
400 "\\.stgit\\.msg" "\\|"
401 "\\.git/COMMIT_EDITMSG" "\\|"
402 "svn-commit\\.tmp" "\\|"
403 "svk-commit[^/.]*\\.tmp"
404 "\\)$")
405 . text-mode)
406 (,(concat "^" tmpdir "/\\("
407 "svk-commit[^/.]*\\.tmp" "\\|"
408 "gitci\\.[^/.]*" "\\|"
409 "cvs[^/.]\\{6\\}" "\\|"
410 "quilt_header\.[^/.]\\{6\\}"
411 "\\)$")
412 . text-mode)
413 ("\\.calc?$" . apcalc-mode)
414 ("/src/linux/.*\\.\\(c\\|h\\|cc\\)$" . linux-c-mode)
415 ("/\\(s\\|sh\\)/" . arm-assembler-mode)
416 ("\\.\\(cmd\\|exec\\|rexx\\)$" . rexx-mode)
417 ("\\.st$" . smalltalk-mode)
418 ("\\.msgs$" . messages-mode)
419 ("/all-cmds\\.in$" . cpp-messages-mode)
420 ("\\.\\(tex\\|dtx\\)$" . latex-mode)
421 ("\\.gc$" . haskell.-mode)
422 (,(concat "^" (getenv "HOME") "/News/") . mdwmail-mode)
423 (,(concat "^" tmpdir "/\\(SLRN\\|snd\\|pico\\|mutt\\)")
424 . mdwmail-mode))
425 auto-mode-alist))
426
427 (setq interpreter-mode-alist
428 (append `(("runlisp" . lisp-mode))
429 interpreter-mode-alist))
430
431 (setq completion-ignored-extensions
432 (append `(".hc" ".hi") completion-ignored-extensions))
433
434 ;; --- Some common local definitions ---
435
436 (make-variable-buffer-local 'mdw-auto-indent)
437
438 (mapcar (lambda (hook) (add-hook hook 'mdw-misc-mode-config))
439 '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
440 csharp-mode-hook perl-mode-hook cperl-mode-hook
441 python-mode-hook awk-mode-hook tcl-mode-hook
442 asm-mode-hook TeX-mode-hook LaTeX-mode-hook
443 TeXinfo-mode-hook tex-mode-hook latex-mode-hook
444 texinfo-mode-hook emacs-lisp-mode-hook scheme-mode-hook
445 lisp-mode-hook lisp-interaction-mode-hook
446 inferior-lisp-mode-hook slime-repl-mode-hook
447 sml-mode-hook haskell-mode-hook erlang-mode-hook
448 smalltalk-mode-hook rexx-mode-hook
449 arm-assembler-mode-hook))
450
451 (global-font-lock-mode t)
452 (defalias 'perl-mode 'cperl-mode)
453
454 ;;;----- Rootly editingness -------------------------------------------------
455
456 (eval-after-load "tramp"
457 '(progn
458 (setq tramp-methods
459 (mdw-uniquify-alist
460 `(("become"
461 (tramp-connection-function tramp-open-connection-su)
462 (tramp-remote-sh "/bin/sh")
463 (tramp-login-program "become")
464 (tramp-copy-program nil)
465 (tramp-copy-args nil)
466 (tramp-copy-keep-date-arg nil)
467 (tramp-login-args ("TERM=dumb" "%u")))
468 ("really"
469 (tramp-connection-function tramp-open-connection-su)
470 (tramp-login-program "really")
471 (tramp-login-args ("-u" "%u" "--"
472 "env" "TERM=dumb" "/bin/sh"))
473 (tramp-copy-program nil)
474 (tramp-copy-args nil)
475 (tramp-copy-keep-date-arg nil)
476 (tramp-remote-sh "/bin/sh"))
477 ,@tramp-methods)))
478 (setq tramp-multi-connection-function-alist
479 (mdw-uniquify-alist
480 '(("bc" tramp-multi-connect-su "become TERM=dumb %u%n"))
481 '(("r" tramp-multi-connect-su "really -u %u%n"))
482 tramp-multi-connection-function-alist))
483 (setq tramp-default-method "ssh")
484 (setq tramp-default-method-alist
485 `(("\\`localhost\\'" ""
486 ,(cond ((executable-find "become") "become")
487 ((executable-find "really") "really")
488 (t "su")))))))
489
490 ;;;----- General fontification ----------------------------------------------
491
492 ;; --- Configure lazy fontification ---
493
494 (and (fboundp 'lazy-lock-mode)
495 (setq font-lock-support-mode 'lazy-lock-mode))
496 ; (setq lazy-lock-defer-contextually t)
497 (setq lazy-lock-defer-time nil)
498 (setq font-lock-maximum-decoration 3)
499 (setq lazy-lock-minimum-size 0)
500 (setq lazy-lock-stealth-time 5)
501 (setq lazy-lock-stealth-lines 100)
502 (setq lazy-lock-stealth-verbose t)
503
504 (add-hook 'after-make-frame-functions 'mdw-do-set-font)
505 (add-hook 'term-setup-hook (lambda () (mdw-do-set-font (selected-frame))))
506 (add-hook 'window-setup-hook (lambda () (mdw-do-set-font (selected-frame))))
507
508 (add-hook 'c-mode-hook 'mdw-fontify-c-and-c++ t)
509 (add-hook 'objc-mode-hook 'mdw-fontify-c-and-c++ t)
510 (add-hook 'c++-mode-hook 'mdw-fontify-c-and-c++ t)
511 (add-hook 'linux-c-mode-hook #'(lambda () (setq c-basic-offset 8)))
512 (add-hook 'asm-mode-hook 'mdw-fontify-asm t)
513
514 (add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t)
515 (add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
516
517 (add-hook 'java-mode-hook 'mdw-fontify-java t)
518 (add-hook 'csharp-mode-hook 'mdw-fontify-csharp t)
519
520 (add-hook 'awk-mode-hook 'mdw-fontify-awk t)
521
522 (add-hook 'perl-mode-hook 'mdw-fontify-perl t)
523 (add-hook 'cperl-mode-hook 'mdw-fontify-perl t)
524
525 (setq-default py-indent-offset 2)
526 (add-hook 'python-mode-hook 'mdw-fontify-python t)
527 (setq py-python-command-args `("-i" "-colors" ,(if mdw-black-background
528 "Linux"
529 "LightBG")))
530
531 (setq-default tcl-indent-level 2)
532 (add-hook 'tcl-mode-hook 'mdw-fontify-tcl t)
533
534 (add-hook 'rexx-mode-hook 'mdw-fontify-rexx t)
535
536 (setq sml-nested-if-indent t)
537 (setq sml-case-indent nil)
538 (setq sml-indent-level 4)
539 (setq sml-type-of-indent nil)
540 (add-hook 'sml-mode-hook 'mdw-fontify-sml t)
541
542 (add-hook 'haskell-mode-hook 'mdw-fontify-haskell t)
543 (setq-default haskell-indent-offset 2)
544
545 (add-hook 'erlang-mode-hook 'mdw-fontify-erlang t)
546
547 (add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t)
548 (add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t)
549
550 (setq LaTeX-table-label "tbl:")
551 (setq TeX-auto-untabify nil)
552 (add-hook 'TeX-mode-hook 'mdw-fontify-tex t)
553 (add-hook 'tex-mode-hook 'mdw-fontify-tex t)
554 (add-hook 'LaTeX-mode-hook 'mdw-fontify-tex t)
555 (add-hook 'latex-mode-hook 'mdw-fontify-tex t)
556
557 (add-hook 'sh-mode-hook #'mdw-setup-sh-script-mode)
558 (add-hook 'autoconf-mode-hook #'mdw-setup-m4)
559 (add-hook 'm4-mode-hook #'mdw-setup-m4)
560
561 (add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t)
562 (add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t)
563
564 (add-hook 'emacs-lisp-mode-hook 'mdw-fontify-lispy t)
565 (add-hook 'scheme-mode-hook 'mdw-fontify-lispy t)
566 (add-hook 'lisp-mode-hook 'mdw-fontify-lispy t)
567 (add-hook 'inferior-lisp-mode-hook 'mdw-fontify-lispy t)
568 (add-hook 'lisp-interaction-mode-hook 'mdw-fontify-lispy t)
569 (add-hook 'slime-repl-mode-hook 'mdw-fontify-lispy t)
570 (add-hook 'lisp-mode-hook 'mdw-common-lisp-indent t)
571 (add-hook 'inferior-lisp-mode-hook
572 #'(lambda ()
573 (local-set-key "\C-m" 'comint-send-and-indent)) t)
574
575 (add-hook 'text-mode-hook 'mdw-text-mode t)
576
577 ;;;----- TeX stuff ----------------------------------------------------------
578
579 (setq TeX-output-view-style
580 '(("^dvi$"
581 ("^landscape$" "^pstricks$\\|^pst-\\|^psfrag$")
582 "%(o?)dvips -t landscape %d -o && evince %f")
583 ("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$"
584 "%(o?)dvips %d -o && evince %f")
585 ("^dvi$"
586 ("^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "^landscape$")
587 "%(o?)xdvi %dS -paper a4r -s 0 %d")
588 ("^dvi$" "^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$"
589 "%(o?)xdvi %dS -paper a4 %d")
590 ("^dvi$"
591 ("^a5\\(?:comb\\|paper\\)$" "^landscape$")
592 "%(o?)xdvi %dS -paper a5r -s 0 %d")
593 ("^dvi$" "^a5\\(?:comb\\|paper\\)$" "%(o?)xdvi %dS -paper a5 %d")
594 ("^dvi$" "^b5paper$" "%(o?)xdvi %dS -paper b5 %d")
595 ("^dvi$" "^letterpaper$" "%(o?)xdvi %dS -paper us %d")
596 ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d")
597 ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d")
598 ("^dvi$" "." "%(o?)xdvi %dS %d")
599 ("^pdf$" "." "evince %o")
600 ("^html?$" "." "netscape %o")))
601
602 (setq reftex-use-external-file-finders t
603 reftex-auto-recenter-toc t)
604
605 (setq reftex-label-alist
606 '(("theorem" ?T "th:" "~\\ref{%s}" t ("theorems?" "th\\.") -2)
607 ("axiom" ?A "ax:" "~\\ref{%s}" t ("axioms?" "ax\\.") -2)
608 ("definition" ?D "def:" "~\\ref{%s}" t ("definitions?" "def\\.") -2)
609 ("proposition" ?P "prop:" "~\\ref{%s}" t
610 ("propositions?" "prop\\.") -2)
611 ("lemma" ?P "lem:" "~\\ref{%s}" t ("lemmas?" "lem\\.") -2)
612 ("example" ?X "eg:" "~\\ref{%s}" t ("examples?") -2)
613 ("exercise" ?E "ex:" "~\\ref{%s}" t ("exercises?" "ex\\.") -2)
614 ("enumerate" ?i "i:" "~\\ref{%s}" item ("items?"))))
615 (setq reftex-section-prefixes
616 '((0 . "part:")
617 (1 . "ch:")
618 (t . "sec:")))
619
620 (setq bibtex-field-delimiters 'double-quotes
621 bibtex-entry-format '(realign opts-or-alts required-fields
622 numerical-fields last-comma delimiters
623 unify-case)
624 bibtex-include-OPTkey nil)
625
626 ;;;----- SLIME setup --------------------------------------------------------
627
628 (trap
629 (if (not mdw-fast-startup)
630 (progn
631 (require 'slime-autoloads)
632 (slime-setup '(slime-autodoc slime-c-p-c)))))
633
634 (let ((stuff '((cmucl ("cmucl"))
635 (sbcl ("sbcl") :coding-system utf-8-unix)
636 (clisp ("clisp") :coding-system utf-8-unix))))
637 (or (boundp 'slime-lisp-implementations)
638 (setq slime-lisp-implementations nil))
639 (while stuff
640 (let* ((head (car stuff))
641 (found (assq (car head) slime-lisp-implementations)))
642 (setq stuff (cdr stuff))
643 (if found
644 (rplacd found (cdr head))
645 (setq slime-lisp-implementations
646 (cons head slime-lisp-implementations))))))
647 (setq slime-default-lisp 'sbcl)
648
649 ;;;----- Blogging -----------------------------------------------------------
650
651 (setq weblogger-config-alist
652 '(("vox"
653 ("user" . "mdw")
654 ("server-url" . "http://vox.distorted.org.uk/admin/mt-xmlrpc.cgi")
655 ("weblog" . "1"))))
656
657 ;;;----- Shell mode ---------------------------------------------------------
658
659 ;; --- Make the shell mode aware of my prompt ---
660
661 (setq shell-prompt-pattern "^[^]#$%>»}\n]*[]#$%>»}] *")
662 (setq comint-password-prompt-regexp
663 (concat "\\(\\([Oo]ld \\|[Nn]ew \\|[a-zA-Z0-9_]*'s \\|^\\)"
664 "[Pp]assword\\|pass phrase\\):\\s *\\'"))
665
666 ;; --- Notice passwords, and make C-a work right ---
667
668 (add-hook 'shell-mode-hook #'mdw-sh-mode-setup)
669 (add-hook 'shell-mode-hook #'ansi-color-for-comint-mode-on)
670 (setq shell-font-lock-keywords nil)
671
672 (add-hook 'term-mode-hook #'mdw-term-mode-setup)
673
674 ;;;----- Finishing touches --------------------------------------------------
675
676 (trap (select-window mdw-init-window))
677 (provide 'emacs-init)
678
679 ;;;----- That's all, folks --------------------------------------------------