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