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