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