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