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