chiark / gitweb /
dot/emacs, el/dot-emacs.el: Use Chrome as the default URL browser.
[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-generic-program "mdw-chrome"
272       browse-url-mozilla-program "firefox")
273
274 (setq w3m-default-display-inline-images t)
275
276 (eval-after-load "w3m"
277   '(let ((entries '(("application/pdf" "\\.pdf\\'" ("evince" file) nil)
278                     ("application/x-pdf" "\\.pdf\\'" ("evince" file) nil))))
279      (dolist (e entries)
280        (setq w3m-content-type-alist
281              (cons e (remove* (car e) w3m-content-type-alist
282                               :key #'car :test #'string=))))))
283
284 (setq w3-do-incremental-display t
285       w3-use-menus '(file edit view go bookmark options
286                      buffers style search emacs nil help)
287       w3-display-inline-image t
288       w3-keybinding 'info)
289
290 ;;;--------------------------------------------------------------------------
291 ;;; Calendar configuration.
292
293 (setq diary-file "~/etc/diary")
294
295 ;; Trivial stuff for the sunrise/sunset calculations.
296
297 (setq calendar-latitude 52.2)
298 (setq calendar-longitude 0.1)
299 (setq calendar-location-name "Cambridge, UK")
300
301 ;; Holidays.
302
303 (and (not mdw-fast-startup)
304      (trap
305        (require 'ew-hols)
306        (setq other-holidays (append english-and-welsh-bank-holidays
307                                     other-holidays))))
308
309 ;; Date format fiddling.
310
311 (setq european-calendar-style t)
312
313 (setq diary-date-forms '((day "[-/]" month "[^-/0-9]")
314                          (day " *" monthname "[ \t]*\\(\^M\\|\n\\)")
315                          (backup day " *" monthname "\\W+\\<[^*0-9]")
316                          (day "[-/]" month "[-/]" year "[^0-9]")
317                          (day " *" monthname " *" year "[^0-9]")
318                          (year "[-/]" month "[-/]" day "[^0-9]")
319                          (dayname "\\W")))
320
321 ;; Fancy diary handling.
322
323 (add-hook 'diary-display-hook 'fancy-diary-display)
324 (setq diary-list-include-blanks t)
325 (add-hook 'list-diary-entries-hook 'sort-diary-entries t)
326 (add-hook 'list-diary-entries-hook 'include-other-diary-files)
327 (add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
328
329 ;; Appointment management.
330
331 (add-hook 'diary-hook 'appt-make-list)
332 (setq appt-issue-message t)
333 (setq appt-display-interval 3)
334 (setq appt-message-warning-time 10)
335
336 ;; Org-mode agenda.
337
338 (setq org-agenda-include-diary t
339       org-tags-column -77)
340
341 ;; Cosmetic stuff.
342
343 (setq display-time-24hr-format t)
344 (display-time)
345 (column-number-mode 1)
346 (trap
347   (if window-system
348       (let ((view-diary-entries-initially t))
349         (calendar))))
350
351 ;;;--------------------------------------------------------------------------
352 ;;; MailCrypt.
353
354 ;; Define more mode hooks for MailCrypt.
355
356 (setq mdw-mc-modes
357       '((mdwmail-mode (encrypt . mdwmail-mc-encrypt)
358                       (sign . mdwmail-mc-sign))))
359
360 ;; Load the MailCrypt support.
361
362 (trap
363   (and (string-match "linux" (symbol-name system-type))
364        (not mdw-fast-startup)
365        (progn (require 'mailcrypt-init)
366               (require 'mailcrypt)
367               (setq mc-default-scheme 'mc-scheme-gpg)
368               (setq mc-pgp-user-id "mdw-nsict-pgp")
369               (setq mc-gpg-user-id "mdw-nsict-gpg")
370               (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
371               (setq mc-pgp-always-sign t)
372               (setq mc-gpg-always-sign t)
373               (setq mc-always-replace 'never)
374               (setq mc-passwd-timeout 3600)
375               (setq mc-temp-directory tmpdir)
376               (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
377               (define-key mc-write-mode-map "\C-c/S" 'mc-sign-region)
378               (define-key mc-write-mode-map "\C-c/E" 'mc-encrypt-region)
379               (add-hook 'text-mode-hook 'mc-install-write-mode))))
380
381 ;;;--------------------------------------------------------------------------
382 ;;; Other common declarations.
383
384 ;; Default frame size.
385
386 (setq default-frame-alist
387       (mdw-uniquify-alist
388        '((width . 78)
389          (height . 33)
390          (vertical-scroll-bars . right)
391          (cursor-type . bar)
392          (cursor-blink . t)
393          (left-fringe . 5)
394          (right-fringe . 5)
395          (scroll-bar-width . 15)
396          (cursor-color . "red"))
397        (if mdw-black-background
398            '((background-mode . dark))
399          '((background-mode . light)))))
400 (setq window-system-default-frame-alist
401       '((pm (font . "-os2-System VIO-medium-r-normal--*-40-*-*-m-*-cp850")
402             (menu-font . "8.Helv")
403             (background-color . "lightgrey"))
404         (nil (menu-bar-lines . 0))))
405
406 ;; Other frame fiddling.
407
408 (setq frame-title-format '("" invocation-name "@" system-name ": %b"))
409
410 ;; Global keymap changes.
411
412 (trap
413   (windmove-default-keybindings))
414 (setq windmove-wrap-around t)
415 (trap (iswitchb-mode))
416 (progn
417   (global-set-key [?\C-x ?w left] 'windmove-left)
418   (global-set-key [?\C-x ?w ?h] 'windmove-left)
419   (global-set-key [?\C-x ?w up] 'windmove-up)
420   (global-set-key [?\C-x ?w ?k] 'windmove-up)
421   (global-set-key [?\C-x ?w down] 'windmove-down)
422   (global-set-key [?\C-x ?w ?j] 'windmove-down)
423   (global-set-key [?\C-x ?w right] 'windmove-right)
424   (global-set-key [?\C-x ?w ?l] 'windmove-right)
425   (global-set-key [?\C-x ?g ?l] 'org-store-link)
426   (global-set-key [?\C-x ?g ?a] 'org-agenda)
427   (global-set-key [?\C-x ?g ?b] 'org-iswitchb)
428   (global-set-key [?\C-x ?t ?i] 'timeclock-in)
429   (global-set-key [?\C-x ?t ?c] 'timeclock-change)
430   (global-set-key [?\C-x ?t ?o] 'timeclock-out)
431   (global-set-key [?\C-x ?t ?r] 'timeclock-reread-log)
432   (global-set-key [?\C-x ?t ?w] 'timeclock-workday-remaining-string)
433   (global-set-key [?\C-x ?t ?s] 'timeclock-status-string)
434   (global-set-key [?\C-x ?t ?p] 'nc-timesheet-prepare)
435   (global-set-key [?\C-x ?t ?\C-m] 'nc-timesheet-submit)
436   (global-set-key [?\M-#] 'calc-dispatch)
437   (global-set-key [?\C-x ?/] 'auto-fill-mode)
438   (global-set-key [?\C-x ?w ?d] 'mdw-divvy-window)
439   (global-set-key [insertchar] 'overwrite-mode)
440   (global-set-key [?\C-x ?\C-n] 'skel-create-file)
441   (global-set-key [?\C-x ?4 ?n] 'skel-create-file-other-window)
442   (global-set-key [?\C-x ?5 ?n] 'skel-create-file-other-frame)
443   (global-set-key [delete] 'delete-char)
444   (global-set-key [?\M-q] 'mdw-fill-paragraph)
445   (global-set-key [?\C-h ?\C-m] 'manual-entry)
446   (global-set-key [C-M-backspace] 'backward-kill-sexp)
447   (global-set-key [mode-line C-mouse-1] 'mouse-tear-off-window)
448   (global-set-key [vertical-scroll-bar C-down-mouse-1]
449                   'mouse-drag-vertical-line)
450   (global-set-key [vertical-scroll-bar C-mouse-1]
451                   #'(lambda () (interactive)))
452   (global-set-key [XF86WakeUp] "")
453   (and (not mdw-fast-startup) (fboundp 'hippie-expand)
454        (global-set-key [?\M-/] 'hippie-expand)))
455
456 (eval-after-load "dired"
457   '(progn
458      (or (lookup-key dired-mode-map  [?\C-x ?\C-q])
459          (define-key dired-mode-map [?\C-x ?\C-q]
460            'wdired-change-to-wdired-mode))
461      (and (fboundp 'dired-do-relsymlink)
462           (define-key dired-mode-map [?\C-c ?\C-s] 'dired-do-relsymlink))))
463
464 (add-hook 'org-mode-hook
465           #'(lambda () (mdw-clobber-evil-keymap org-mode-map)))
466 (add-hook 'org-agenda-mode-hook
467           #'(lambda () (mdw-clobber-evil-keymap org-agenda-mode-map)))
468 (or mdw-fast-startup
469     (progn
470       (org-remember-insinuate)
471       (global-set-key [?\C-c ?r] 'org-remember)))
472
473 ;; Recognising types of files.
474
475 (setq auto-mode-alist
476       (append `(("\\.p[lm]$" . perl-mode)
477                 ("\\.m$" . objc-mode)
478                 ("\\.mxd$" . c-mode)
479                 ("\\.cs$" . csharp-mode)
480                 ("\\.go$" . go-mode)
481                 ("\\.org$" . org-mode)
482                 ;; ("/[ch]/" . c-mode)
483                 (,(concat "/\\("
484                           "\\.stgit\\.msg" "\\|"
485                           "\\.git/COMMIT_EDITMSG" "\\|"
486                           "svn-commit\\.tmp" "\\|"
487                           "svk-commit[^/.]*\\.tmp"
488                           "\\)$")
489                  . text-mode)
490                 (,(concat "^" tmpdir "/\\("
491                           "svk-commit[^/.]*\\.tmp" "\\|"
492                           "gitci\\.[^/.]*" "\\|"
493                           "cvs[^/.]\\{6\\}" "\\|"
494                           "quilt_header\.[^/.]\\{6\\}"
495                           "\\)$")
496                  . text-mode)
497                 ("\\.calc?$" . apcalc-mode)
498                 ("/src/linux/.*\\.\\(c\\|h\\|cc\\)$" . linux-c-mode)
499                 ("/\\(s\\|sh\\)/" . arm-assembler-mode)
500                 ("\\.\\(cmd\\|exec\\|rexx\\)$" . rexx-mode)
501                 ("\\.st$" . smalltalk-mode)
502                 ("\\.msgs$" . messages-mode)
503                 ("/all-cmds\\.in$" . cpp-messages-mode)
504                 ("\\.\\(tex\\|dtx\\)$" . latex-mode)
505                 ("\\.gc$" . haskell.-mode)
506                 (,(concat "^" (getenv "HOME") "/News/") . mdwmail-mode)
507                 (,(concat "^" tmpdir "/\\(SLRN\\|snd\\|pico\\|mutt\\)")
508                  . mdwmail-mode))
509               auto-mode-alist))
510
511 (setq interpreter-mode-alist
512       (append `(("runlisp" . lisp-mode))
513               interpreter-mode-alist))
514
515 (setq completion-ignored-extensions
516       (append `(".hc" ".hi") completion-ignored-extensions))
517 (dolist (dir (remove-if-not (lambda (ext)
518                               (= (aref ext (- (length ext) 1)) ?/))
519                             completion-ignored-extensions))
520   (if (/= (aref dir 0) ?/)
521       (setq completion-ignored-extensions
522             (cons (concat "/" dir)
523                   (remove dir completion-ignored-extensions)))))
524
525 ;; Some common local definitions.
526
527 (make-variable-buffer-local 'mdw-auto-indent)
528
529 (mapcar (lambda (hook) (add-hook hook 'mdw-misc-mode-config))
530         '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
531           csharp-mode-hook perl-mode-hook cperl-mode-hook
532           python-mode-hook pyrec-mode-hook icon-mode-hook awk-mode-hook
533           tcl-mode-hook go-mode-hook
534           asm-mode-hook TeX-mode-hook LaTeX-mode-hook
535           TeXinfo-mode-hook tex-mode-hook latex-mode-hook
536           texinfo-mode-hook emacs-lisp-mode-hook scheme-mode-hook
537           lisp-mode-hook lisp-interaction-mode-hook
538           inferior-lisp-mode-hook slime-repl-mode-hook
539           sml-mode-hook haskell-mode-hook erlang-mode-hook
540           smalltalk-mode-hook rexx-mode-hook
541           arm-assembler-mode-hook))
542
543 (global-font-lock-mode t)
544 (defalias 'perl-mode 'cperl-mode)
545
546 ;;;--------------------------------------------------------------------------
547 ;;; Rootly editingness.
548
549 (eval-after-load "tramp"
550   '(let ((fix-args (if (mdw-version-< tramp-version "2.1")
551                        #'append #'list)))
552      (setq tramp-methods
553            (mdw-uniquify-alist
554             `(("become"
555                (tramp-connection-function tramp-open-connection-su)
556                (tramp-remote-sh "/bin/sh")
557                (tramp-login-program "become")
558                (tramp-copy-program nil)
559                (tramp-copy-args nil)
560                (tramp-copy-keep-date-arg nil)
561                (tramp-login-args ,(funcall fix-args `("TERM=dumb" "%u"))))
562               ("really"
563                (tramp-connection-function tramp-open-connection-su)
564                (tramp-login-program "really")
565                (tramp-login-args ,(funcall fix-args
566                                            `("-u" "%u")
567                                            `("--")
568                                            `("env" "TERM=dumb" "/bin/sh")))
569                (tramp-copy-program nil)
570                (tramp-copy-args nil)
571                (tramp-copy-keep-date-arg nil)
572                (tramp-remote-sh "/bin/sh"))
573               ,@tramp-methods)))
574      (setq tramp-default-method "ssh")
575      (setq tramp-default-method-alist
576            `(("\\`\\(localhost\\|\\)\\'" ""
577               ,(cond ((executable-find "become") "become")
578                      ((executable-find "really") "really")
579                      (t "su")))))))
580
581 ;;;--------------------------------------------------------------------------
582 ;;; General fontification.
583
584 ;; Configure lazy fontification.
585
586 (and (fboundp 'lazy-lock-mode)
587      (setq font-lock-support-mode 'lazy-lock-mode))
588 ; (setq lazy-lock-defer-contextually t)
589 (setq lazy-lock-defer-time nil
590       font-lock-maximum-decoration 3
591       lazy-lock-minimum-size 0
592       lazy-lock-stealth-time 5
593       lazy-lock-stealth-lines 100
594       lazy-lock-stealth-verbose t)
595
596 (progn
597   (add-hook 'c-mode-hook 'mdw-fontify-c-and-c++ t)
598   (add-hook 'objc-mode-hook 'mdw-fontify-c-and-c++ t)
599   (add-hook 'c++-mode-hook 'mdw-fontify-c-and-c++ t)
600   (add-hook 'linux-c-mode-hook #'(lambda () (setq c-basic-offset 8)))
601   (add-hook 'asm-mode-hook 'mdw-fontify-asm t)
602   (add-hook 'go-mode-hook 'mdw-fontify-go t)
603
604   (add-hook 'icon-mode-hook 'mdw-fontify-icon t)
605
606   (add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t)
607   (add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
608
609   (add-hook 'java-mode-hook 'mdw-fontify-java t)
610   (add-hook 'csharp-mode-hook 'mdw-fontify-csharp t)
611
612   (add-hook 'awk-mode-hook 'mdw-fontify-awk t)
613
614   (add-hook 'perl-mode-hook 'mdw-fontify-perl t)
615   (add-hook 'cperl-mode-hook 'mdw-fontify-perl t))
616
617 (progn
618   (setq-default py-indent-offset 2
619                 py-python-command-args
620                 `("-i" "-colors" ,(if mdw-black-background
621                                       "Linux" "LightBG")))
622   (add-hook 'python-mode-hook 'mdw-fontify-python t)
623   (add-hook 'pyrex-mode-hook 'mdw-fontify-pyrex t))
624
625 (setq-default tcl-indent-level 2)
626 (add-hook 'tcl-mode-hook 'mdw-fontify-tcl t)
627
628 (add-hook 'rexx-mode-hook 'mdw-fontify-rexx t)
629
630 (setq sml-nested-if-indent t
631       sml-case-indent nil
632       sml-indent-level 4
633       sml-type-of-indent nil)
634 (add-hook 'sml-mode-hook 'mdw-fontify-sml t)
635
636 (add-hook 'haskell-mode-hook 'mdw-fontify-haskell t)
637 (setq-default haskell-indent-offset 2)
638
639 (add-hook 'erlang-mode-hook 'mdw-fontify-erlang t)
640
641 (add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t)
642 (add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t)
643
644 (setq LaTeX-table-label "tbl:")
645 (setq TeX-auto-untabify nil)
646 (add-hook 'TeX-mode-hook 'mdw-fontify-tex t)
647 (add-hook 'tex-mode-hook 'mdw-fontify-tex t)
648 (add-hook 'LaTeX-mode-hook 'mdw-fontify-tex t)
649 (add-hook 'latex-mode-hook 'mdw-fontify-tex t)
650
651 (add-hook 'sh-mode-hook #'mdw-setup-sh-script-mode)
652 (add-hook 'autoconf-mode-hook #'mdw-setup-m4)
653 (add-hook 'm4-mode-hook #'mdw-setup-m4)
654
655 (add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t)
656 (add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t)
657
658 (progn
659   (add-hook 'emacs-lisp-mode-hook 'mdw-fontify-lispy t)
660   (add-hook 'scheme-mode-hook 'mdw-fontify-lispy t)
661   (add-hook 'lisp-mode-hook 'mdw-fontify-lispy t)
662   (add-hook 'inferior-lisp-mode-hook 'mdw-fontify-lispy t)
663   (add-hook 'lisp-interaction-mode-hook 'mdw-fontify-lispy t)
664   (add-hook 'slime-repl-mode-hook 'mdw-fontify-lispy t)
665   (add-hook 'lisp-mode-hook 'mdw-common-lisp-indent t)
666   (add-hook 'inferior-lisp-mode-hook
667           #'(lambda ()
668               (local-set-key "\C-m" 'comint-send-and-indent)) t))
669
670 (add-hook 'text-mode-hook 'mdw-text-mode t)
671
672 ;;;--------------------------------------------------------------------------
673 ;;; TeX stuff.
674
675 (setq TeX-output-view-style
676       '(("^dvi$"
677          ("^landscape$" "^pstricks$\\|^pst-\\|^psfrag$")
678          "%(o?)dvips -t landscape %d -o && evince %f")
679         ("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$"
680          "%(o?)dvips %d -o && evince %f")
681         ("^dvi$"
682          ("^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "^landscape$")
683          "%(o?)xdvi %dS -paper a4r -s 0 %d")
684         ("^dvi$" "^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$"
685          "%(o?)xdvi %dS -paper a4 %d")
686         ("^dvi$"
687          ("^a5\\(?:comb\\|paper\\)$" "^landscape$")
688          "%(o?)xdvi %dS -paper a5r -s 0 %d")
689         ("^dvi$" "^a5\\(?:comb\\|paper\\)$" "%(o?)xdvi %dS -paper a5 %d")
690         ("^dvi$" "^b5paper$" "%(o?)xdvi %dS -paper b5 %d")
691         ("^dvi$" "^letterpaper$" "%(o?)xdvi %dS -paper us %d")
692         ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d")
693         ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d")
694         ("^dvi$" "." "%(o?)xdvi %dS %d")
695         ("^pdf$" "." "evince %o")
696         ("^html?$" "." "netscape %o")))
697
698 (setq TeX-open-quote "\""
699       TeX-close-quote "\"")
700
701 (setq reftex-use-external-file-finders t
702       reftex-auto-recenter-toc t)
703
704 (setq reftex-label-alist
705       '(("theorem" ?T "th:" "~\\ref{%s}" t ("theorems?" "th\\.") -2)
706         ("axiom" ?A "ax:" "~\\ref{%s}" t ("axioms?" "ax\\.") -2)
707         ("definition" ?D "def:" "~\\ref{%s}" t ("definitions?" "def\\.") -2)
708         ("proposition" ?P "prop:" "~\\ref{%s}" t
709          ("propositions?" "prop\\.") -2)
710         ("lemma" ?P "lem:" "~\\ref{%s}" t ("lemmas?" "lem\\.") -2)
711         ("example" ?X "eg:" "~\\ref{%s}" t ("examples?") -2)
712         ("exercise" ?E "ex:" "~\\ref{%s}" t ("exercises?" "ex\\.") -2)
713         ("enumerate" ?i "i:" "~\\ref{%s}" item ("items?"))))
714 (setq reftex-section-prefixes
715       '((0 . "part:")
716         (1 . "ch:")
717         (t . "sec:")))
718
719 (setq bibtex-field-delimiters 'double-quotes
720       bibtex-entry-format '(realign opts-or-alts required-fields
721                             numerical-fields last-comma delimiters
722                             unify-case)
723       bibtex-include-OPTkey nil)
724
725 ;;;--------------------------------------------------------------------------
726 ;;; SLIME setup.
727
728 (trap
729  (if (not mdw-fast-startup)
730      (progn
731        (require 'slime-autoloads)
732        (slime-setup '(slime-autodoc slime-c-p-c)))))
733
734 (let ((stuff '((cmucl ("cmucl"))
735                (sbcl ("sbcl") :coding-system utf-8-unix)
736                (clisp ("clisp") :coding-system utf-8-unix))))
737   (or (boundp 'slime-lisp-implementations)
738       (setq slime-lisp-implementations nil))
739   (while stuff
740     (let* ((head (car stuff))
741            (found (assq (car head) slime-lisp-implementations)))
742       (setq stuff (cdr stuff))
743       (if found
744           (rplacd found (cdr head))
745         (setq slime-lisp-implementations
746               (cons head slime-lisp-implementations))))))
747 (setq slime-default-lisp 'sbcl)
748
749 ;;;--------------------------------------------------------------------------
750 ;;; Blogging.
751
752 (setq weblogger-config-alist
753       '(("vox"
754          ("user" . "mdw")
755          ("server-url" . "http://vox.distorted.org.uk/admin/mt-xmlrpc.cgi")
756          ("weblog" . "1"))))
757
758 ;;;--------------------------------------------------------------------------
759 ;;; Shell mode.
760
761 ;; Make the shell mode aware of my prompt.
762
763 (setq shell-prompt-pattern "^[^]#$%>»}\n]*\\([]#$%»}]\\|>>?\\) *")
764 (setq comint-password-prompt-regexp
765       (concat "\\(\\([Ee]nter \\|[Oo]ld \\|[Nn]ew \\|[a-zA-Z0-9_]*'s \\|^\\)"
766               "[Pp]assword\\|pass phrase\\):"))
767
768 ;; Notice passwords, and make C-a work right.
769
770 (add-hook 'shell-mode-hook #'mdw-sh-mode-setup)
771 (add-hook 'shell-mode-hook #'ansi-color-for-comint-mode-on)
772 (setq shell-font-lock-keywords nil)
773
774 (add-hook 'term-mode-hook #'mdw-term-mode-setup)
775
776 ;;;--------------------------------------------------------------------------
777 ;;; Finishing touches.
778
779 (trap (select-window mdw-init-window))
780 (provide 'emacs-init)
781
782 ;;;----- That's all, folks --------------------------------------------------