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