el/dot-emacs.el: Use `make-local-variable'.
[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 "\\("
43036e3a 48 "[" "[:lower:][:digit:]]"
eac7b622
MW
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))
8d244e27 57 (not (memq 'Git vc-handled-backends))
79ba2d35 58 (not (memq 'git vc-handled-backends))
308b0b57 59 (setq vc-handled-backends (cons 'GIT vc-handled-backends)))
f617db13 60
ab9e097f
MW
61(trap (or mdw-fast-startup (require 'p4)))
62
c7a8da49 63(trap (or mdw-fast-startup (require 'tex-site)))
f617db13 64
eff13a73 65(trap (or mdw-fast-startup (semantic-load-enable-minimum-features)))
33abafd2 66(setq semanticdb-default-save-directory "~/.emacs.d/semanticdb/")
75bd2d66 67
6132bc01 68;; Skeleton stuff.
f617db13 69
c7a8da49 70(trap (or mdw-fast-startup (require 'skel-init)))
f617db13 71
6132bc01 72;; Window system-dependent things.
f617db13
MW
73
74(require 'paren)
75(trap (show-paren-mode t))
76(or window-system (menu-bar-mode -1))
77
6132bc01 78;; Temporary directory handling.
f617db13
MW
79
80(defun mdw-check-dir-exists (dir)
81 (and dir
82 (file-directory-p dir)
83 dir))
84(setq tmpdir (or (mdw-check-dir-exists (getenv "TMPDIR"))
85 (mdw-check-dir-exists (format "/tmp/%s" (user-login-name)))
86 "/tmp"))
87
6132bc01 88;; Emacs server behaviour.
f617db13 89
ccc2e1fa
MW
90(and (or window-system (>= emacs-major-version 23))
91 (progn (setq server-temp-file-regexp (concat "^" tmpdir "\\|/draft$")
92 gnuserv-frame t)
782c3e35 93 (trap (server-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)
3459d2cb
MW
206(setq default-indicate-empty-lines t)
207(setq whitespace-style
208 '(trailing space-before-tab space-after-tab empty indentation))
4d4f9ad1
MW
209(setq woman-use-own-frame nil ;Keep man pages somewhere sensible
210 woman-fill-column 72) ;Right margin position.
f617db13
MW
211(setq diff-switches "-u" ;I like reading unified diffs
212 cvs-diff-flags (list diff-switches))
213(setq echo-keystrokes 10) ;Long delay before keystrokes echo
214(setq ange-ftp-ftp-program-name "pftp") ;Use passive FTP
215(setq find-ls-option ;Build file lists efficiently
216 '("-print0 | xargs -0r ls -ld" . "ld"))
6006518e 217(setq bookmark-save-flag 0) ;Save bookmarks automatically
91dba4e4 218(setq x-gtk-file-dialog-help-text nil)
e34a133f 219(setq Info-fontify-maximum-menu-size 100000)
3af826d8 220(setq set-mark-command-repeat-pop t)
9de66169
MW
221(setq-default proced-filter 'all
222 proced-sort 'user)
cbffcf2b
MW
223(setq ispell-program-name "aspell"
224 ispell-local-dictionary "en_GB-ize-w_accents"
225 flyspell-default-dictionary "en_GB-ize-w_accents"
689009c0 226 ispell-silently-savep t)
f617db13
MW
227(trap
228 (require 'uniquify)
229 (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
230 (setq uniquify-after-kill-buffer-p t))
231(transient-mark-mode t)
9958af68 232(setq mark-even-if-inactive t)
f617db13
MW
233(trap
234 (tooltip-mode 0)
235 (tool-bar-mode 0))
4ae85887 236(trap (or mdw-fast-startup (global-auto-revert-mode t)))
f617db13
MW
237(setq psgml-html-build-new-buffer nil)
238
3d6a7d27
MW
239(defvar mdw-black-background t)
240
5de5db48
MW
241(eval-after-load "outline"
242 '(progn
243 (trap (require 'foldout))
244 (define-key outline-mode-prefix-map [?\C-r] 'reveal-mode)
245 (define-key outline-mode-prefix-map [?\C--] 'mdw-outline-collapse-all)))
8fd1960c 246
f141fe0f
MW
247(setq cltl2-root-url (mdw-config 'cltl-url))
248(setq common-lisp-hyperspec-root (mdw-config 'hyperspec-url))
249
6132bc01
MW
250;;;--------------------------------------------------------------------------
251;;; W3 and URL fetching stuff.
f141fe0f 252
45d17e24 253(let ((proxy (mdw-config 'http-proxy)))
f141fe0f
MW
254 (setq url-proxy-services
255 `(("http" . ,proxy)
256 ("ftp" . ,proxy)
257 ("gopher" . ,proxy))))
258(setq url-cookie-untrusted-urls '("."))
852cd5fb 259
a203fba8
MW
260(setq browse-url-browser-function (mdw-good-url-browser)
261 browse-url-mozilla-program "firefox")
9b72460c
MW
262
263(setq w3m-default-display-inline-images t)
264
f141fe0f
MW
265(setq w3-do-incremental-display t
266 w3-use-menus '(file edit view go bookmark options
267 buffers style search emacs nil help)
268 w3-display-inline-image t
269 w3-keybinding 'info)
f617db13 270
6132bc01
MW
271;;;--------------------------------------------------------------------------
272;;; Calendar configuration.
f617db13 273
ea09c6cb
MW
274(setq diary-file "~/etc/diary")
275
6132bc01 276;; Trivial stuff for the sunrise/sunset calculations.
f617db13
MW
277
278(setq calendar-latitude 52.2)
279(setq calendar-longitude 0.1)
280(setq calendar-location-name "Cambridge, UK")
281
6132bc01 282;; Holidays.
a1293ade
MW
283
284(and (not mdw-fast-startup)
285 (trap
286 (require 'ew-hols)
287 (setq other-holidays (append english-and-welsh-bank-holidays
288 other-holidays))))
289
6132bc01 290;; Date format fiddling.
f617db13
MW
291
292(setq european-calendar-style t)
293
294(setq diary-date-forms '((day "[-/]" month "[^-/0-9]")
295 (day " *" monthname "[ \t]*\\(\^M\\|\n\\)")
296 (backup day " *" monthname "\\W+\\<[^*0-9]")
297 (day "[-/]" month "[-/]" year "[^0-9]")
298 (day " *" monthname " *" year "[^0-9]")
299 (year "[-/]" month "[-/]" day "[^0-9]")
300 (dayname "\\W")))
301
6132bc01 302;; Fancy diary handling.
f617db13
MW
303
304(add-hook 'diary-display-hook 'fancy-diary-display)
305(setq diary-list-include-blanks t)
306(add-hook 'list-diary-entries-hook 'sort-diary-entries t)
307(add-hook 'list-diary-entries-hook 'include-other-diary-files)
308(add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
309
6132bc01 310;; Appointment management.
f617db13
MW
311
312(add-hook 'diary-hook 'appt-make-list)
313(setq appt-issue-message t)
314(setq appt-display-interval 3)
315(setq appt-message-warning-time 10)
316
6132bc01 317;; Org-mode agenda.
2d6b9d95 318
e3f433a2
MW
319(setq org-agenda-include-diary t
320 org-tags-column -77)
2d6b9d95 321
6132bc01 322;; Cosmetic stuff.
f617db13
MW
323
324(setq display-time-24hr-format t)
325(display-time)
326(trap
327 (if window-system
328 (let ((view-diary-entries-initially t))
329 (calendar))))
330
6132bc01
MW
331;;;--------------------------------------------------------------------------
332;;; MailCrypt.
f617db13 333
6132bc01 334;; Define more mode hooks for MailCrypt.
f617db13
MW
335
336(setq mdw-mc-modes
337 '((mdwmail-mode (encrypt . mdwmail-mc-encrypt)
338 (sign . mdwmail-mc-sign))))
339
6132bc01 340;; Load the MailCrypt support.
f617db13
MW
341
342(trap
343 (and (string-match "linux" (symbol-name system-type))
c7a8da49 344 (not mdw-fast-startup)
f617db13
MW
345 (progn (require 'mailcrypt-init)
346 (require 'mailcrypt)
347 (setq mc-default-scheme 'mc-scheme-gpg)
348 (setq mc-pgp-user-id "mdw-nsict-pgp")
349 (setq mc-gpg-user-id "mdw-nsict-gpg")
350 (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
351 (setq mc-pgp-always-sign t)
352 (setq mc-gpg-always-sign t)
353 (setq mc-always-replace 'never)
354 (setq mc-passwd-timeout 3600)
355 (setq mc-temp-directory tmpdir)
356 (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
357 (define-key mc-write-mode-map "\C-c/S" 'mc-sign-region)
358 (define-key mc-write-mode-map "\C-c/E" 'mc-encrypt-region)
359 (add-hook 'text-mode-hook 'mc-install-write-mode))))
360
6132bc01
MW
361;;;--------------------------------------------------------------------------
362;;; Other common declarations.
f617db13 363
6132bc01 364;; Default frame size.
f617db13
MW
365
366(setq default-frame-alist
367 (mdw-uniquify-alist
368 '((width . 78)
369 (height . 33)
c14ce5af
MW
370 (vertical-scroll-bars . right)
371 (cursor-type . bar)
372 (cursor-blink . t)
373 (left-fringe . 5)
374 (right-fringe . 5)
375 (scroll-bar-width . 15)
376 (cursor-color . "red"))
f617db13 377 (if mdw-black-background
6dc0fd06 378 '((background-mode . dark))
f617db13
MW
379 '((background-mode . light)))
380 (and (eq window-system 'pm)
381 '((font . "-os2-System VIO-medium-r-normal--*-40-*-*-m-*-cp850")
382 (menu-font . "8.Helv")
383 (background-color . "lightgrey")))
f617db13
MW
384 default-frame-alist))
385
6132bc01 386;; Other frame fiddling.
f617db13
MW
387
388(setq frame-title-format '("" invocation-name "@" system-name ": %b"))
389
6132bc01 390;; Global keymap changes.
f617db13
MW
391
392(trap
f110f932
MW
393 (windmove-default-keybindings))
394(setq windmove-wrap-around t)
f617db13 395(trap (iswitchb-mode))
f9d83bff
MW
396(progn
397 (global-set-key [?\C-x ?w left] 'windmove-left)
398 (global-set-key [?\C-x ?w ?h] 'windmove-left)
399 (global-set-key [?\C-x ?w up] 'windmove-up)
400 (global-set-key [?\C-x ?w ?k] 'windmove-up)
401 (global-set-key [?\C-x ?w down] 'windmove-down)
402 (global-set-key [?\C-x ?w ?j] 'windmove-down)
403 (global-set-key [?\C-x ?w right] 'windmove-right)
404 (global-set-key [?\C-x ?w ?l] 'windmove-right)
405 (global-set-key [?\C-x ?g ?l] 'org-store-link)
406 (global-set-key [?\C-x ?g ?a] 'org-agenda)
407 (global-set-key [?\C-x ?g ?b] 'org-iswitchb)
408 (global-set-key [?\C-x ?t ?i] 'timeclock-in)
409 (global-set-key [?\C-x ?t ?c] 'timeclock-change)
410 (global-set-key [?\C-x ?t ?o] 'timeclock-out)
411 (global-set-key [?\C-x ?t ?r] 'timeclock-reread-log)
412 (global-set-key [?\C-x ?t ?w] 'timeclock-workday-remaining-string)
413 (global-set-key [?\C-x ?t ?s] 'timeclock-status-string)
414 (global-set-key [?\C-x ?t ?p] 'nc-timesheet-prepare)
415 (global-set-key [?\C-x ?t ?\C-m] 'nc-timesheet-submit)
416 (global-set-key [?\M-#] 'calc-dispatch)
417 (global-set-key [?\C-x ?/] 'auto-fill-mode)
418 (global-set-key [?\C-x ?w ?d] 'mdw-divvy-window)
419 (global-set-key [insertchar] 'overwrite-mode)
420 (global-set-key [?\C-x ?\C-n] 'skel-create-file)
421 (global-set-key [?\C-x ?4 ?n] 'skel-create-file-other-window)
422 (global-set-key [?\C-x ?5 ?n] 'skel-create-file-other-frame)
423 (global-set-key [delete] 'delete-char)
424 (global-set-key [?\M-q] 'mdw-fill-paragraph)
425 (global-set-key [?\C-h ?\C-m] 'manual-entry)
426 (global-set-key [C-M-backspace] 'backward-kill-sexp)
427 (global-set-key [mode-line C-mouse-1] 'mouse-tear-off-window)
428 (global-set-key [vertical-scroll-bar C-down-mouse-1]
429 'mouse-drag-vertical-line)
430 (global-set-key [vertical-scroll-bar C-mouse-1]
431 #'(lambda () (interactive)))
432 (global-set-key [XF86WakeUp] "")
433 (and (not mdw-fast-startup) (fboundp 'hippie-expand)
434 (global-set-key [?\M-/] 'hippie-expand)))
f617db13 435
cadc9736
MW
436(eval-after-load "dired"
437 '(progn
438 (define-key dired-mode-map [?\C-x ?\C-q]
439 'wdired-change-to-wdired-mode)))
440
16fe7c41
MW
441(add-hook 'org-mode-hook
442 #'(lambda () (mdw-clobber-evil-keymap org-mode-map)))
443(add-hook 'org-agenda-mode-hook
444 #'(lambda () (mdw-clobber-evil-keymap org-agenda-mode-map)))
4849ea18 445
6132bc01 446;; Recognising types of files.
f617db13
MW
447
448(setq auto-mode-alist
449 (append `(("\\.p[lm]$" . perl-mode)
450 ("\\.m$" . objc-mode)
451 ("\\.mxd$" . c-mode)
e6cb5770 452 ("\\.cs$" . csharp-mode)
07965a39 453 ("\\.go$" . go-mode)
133cf81d 454 ("\\.org$" . org-mode)
f617db13
MW
455 ;; ("/[ch]/" . c-mode)
456 (,(concat "/\\("
457 "\\.stgit\\.msg" "\\|"
458 "\\.git/COMMIT_EDITMSG" "\\|"
459 "svn-commit\\.tmp" "\\|"
460 "svk-commit[^/.]*\\.tmp"
461 "\\)$")
462 . text-mode)
463 (,(concat "^" tmpdir "/\\("
464 "svk-commit[^/.]*\\.tmp" "\\|"
465 "gitci\\.[^/.]*" "\\|"
466 "cvs[^/.]\\{6\\}" "\\|"
400223a1 467 "quilt_header\.[^/.]\\{6\\}"
f617db13
MW
468 "\\)$")
469 . text-mode)
470 ("\\.calc?$" . apcalc-mode)
471 ("/src/linux/.*\\.\\(c\\|h\\|cc\\)$" . linux-c-mode)
472 ("/\\(s\\|sh\\)/" . arm-assembler-mode)
473 ("\\.\\(cmd\\|exec\\|rexx\\)$" . rexx-mode)
474 ("\\.st$" . smalltalk-mode)
1e52f579
MW
475 ("\\.msgs$" . messages-mode)
476 ("/all-cmds\\.in$" . cpp-messages-mode)
f617db13
MW
477 ("\\.\\(tex\\|dtx\\)$" . latex-mode)
478 ("\\.gc$" . haskell.-mode)
479 (,(concat "^" (getenv "HOME") "/News/") . mdwmail-mode)
870778ff 480 (,(concat "^" tmpdir "/\\(SLRN\\|snd\\|pico\\|mutt\\)")
f617db13
MW
481 . mdwmail-mode))
482 auto-mode-alist))
483
27cb4215
MW
484(setq interpreter-mode-alist
485 (append `(("runlisp" . lisp-mode))
486 interpreter-mode-alist))
487
f617db13
MW
488(setq completion-ignored-extensions
489 (append `(".hc" ".hi") completion-ignored-extensions))
490
6132bc01 491;; Some common local definitions.
f617db13
MW
492
493(make-variable-buffer-local 'mdw-auto-indent)
494
495(mapcar (lambda (hook) (add-hook hook 'mdw-misc-mode-config))
496 '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
2ded9493 497 csharp-mode-hook perl-mode-hook cperl-mode-hook
99fe6ef5 498 python-mode-hook pyrec-mode-hook icon-mode-hook awk-mode-hook
07965a39 499 tcl-mode-hook go-mode-hook
2ded9493
MW
500 asm-mode-hook TeX-mode-hook LaTeX-mode-hook
501 TeXinfo-mode-hook tex-mode-hook latex-mode-hook
502 texinfo-mode-hook emacs-lisp-mode-hook scheme-mode-hook
503 lisp-mode-hook lisp-interaction-mode-hook
504 inferior-lisp-mode-hook slime-repl-mode-hook
505 sml-mode-hook haskell-mode-hook erlang-mode-hook
f617db13
MW
506 smalltalk-mode-hook rexx-mode-hook
507 arm-assembler-mode-hook))
508
509(global-font-lock-mode t)
510(defalias 'perl-mode 'cperl-mode)
511
6132bc01
MW
512;;;--------------------------------------------------------------------------
513;;; Rootly editingness.
f617db13
MW
514
515(eval-after-load "tramp"
ae7460d4
MW
516 '(let ((fix-args (if (mdw-version-< tramp-version "2.1")
517 #'append #'identity)))
f617db13
MW
518 (setq tramp-methods
519 (mdw-uniquify-alist
520 `(("become"
521 (tramp-connection-function tramp-open-connection-su)
522 (tramp-remote-sh "/bin/sh")
523 (tramp-login-program "become")
524 (tramp-copy-program nil)
525 (tramp-copy-args nil)
526 (tramp-copy-keep-date-arg nil)
ae7460d4 527 (tramp-login-args ,(funcall fix-args `("TERM=dumb" "%u"))))
f617db13
MW
528 ("really"
529 (tramp-connection-function tramp-open-connection-su)
530 (tramp-login-program "really")
ae7460d4
MW
531 (tramp-login-args ,(funcall fix-args
532 `("-u" "%u")
533 `("--")
534 `("env" "TERM=dumb" "/bin/sh")))
f617db13
MW
535 (tramp-copy-program nil)
536 (tramp-copy-args nil)
537 (tramp-copy-keep-date-arg nil)
538 (tramp-remote-sh "/bin/sh"))
539 ,@tramp-methods)))
f617db13
MW
540 (setq tramp-default-method "ssh")
541 (setq tramp-default-method-alist
ae7460d4 542 `(("\\`\\(localhost\\|\\)\\'" ""
f617db13
MW
543 ,(cond ((executable-find "become") "become")
544 ((executable-find "really") "really")
545 (t "su")))))))
546
6132bc01
MW
547;;;--------------------------------------------------------------------------
548;;; General fontification.
f617db13 549
6132bc01 550;; Configure lazy fontification.
f617db13 551
f29cc9b2
MW
552(and (fboundp 'lazy-lock-mode)
553 (setq font-lock-support-mode 'lazy-lock-mode))
f617db13 554; (setq lazy-lock-defer-contextually t)
f9d83bff
MW
555(setq lazy-lock-defer-time nil
556 font-lock-maximum-decoration 3
557 lazy-lock-minimum-size 0
558 lazy-lock-stealth-time 5
559 lazy-lock-stealth-lines 100
560 lazy-lock-stealth-verbose t)
f617db13 561
f9d83bff
MW
562(progn
563 (add-hook 'c-mode-hook 'mdw-fontify-c-and-c++ t)
564 (add-hook 'objc-mode-hook 'mdw-fontify-c-and-c++ t)
565 (add-hook 'c++-mode-hook 'mdw-fontify-c-and-c++ t)
566 (add-hook 'linux-c-mode-hook #'(lambda () (setq c-basic-offset 8)))
567 (add-hook 'asm-mode-hook 'mdw-fontify-asm t)
07965a39 568 (add-hook 'go-mode-hook 'mdw-fontify-go t)
f617db13 569
f9d83bff 570 (add-hook 'icon-mode-hook 'mdw-fontify-icon t)
f617db13 571
f9d83bff
MW
572 (add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t)
573 (add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
cc1980e1 574
f9d83bff
MW
575 (add-hook 'java-mode-hook 'mdw-fontify-java t)
576 (add-hook 'csharp-mode-hook 'mdw-fontify-csharp t)
f617db13 577
f9d83bff 578 (add-hook 'awk-mode-hook 'mdw-fontify-awk t)
f617db13 579
f9d83bff
MW
580 (add-hook 'perl-mode-hook 'mdw-fontify-perl t)
581 (add-hook 'cperl-mode-hook 'mdw-fontify-perl t))
f617db13 582
f9d83bff
MW
583(progn
584 (setq-default py-indent-offset 2
585 py-python-command-args
586 `("-i" "-colors" ,(if mdw-black-background
587 "Linux" "LightBG")))
588 (add-hook 'python-mode-hook 'mdw-fontify-python t)
589 (add-hook 'pyrex-mode-hook 'mdw-fontify-pyrex t))
f617db13
MW
590
591(setq-default tcl-indent-level 2)
592(add-hook 'tcl-mode-hook 'mdw-fontify-tcl t)
593
594(add-hook 'rexx-mode-hook 'mdw-fontify-rexx t)
595
f9d83bff
MW
596(setq sml-nested-if-indent t
597 sml-case-indent nil
598 sml-indent-level 4
599 sml-type-of-indent nil)
f617db13
MW
600(add-hook 'sml-mode-hook 'mdw-fontify-sml t)
601
602(add-hook 'haskell-mode-hook 'mdw-fontify-haskell t)
603(setq-default haskell-indent-offset 2)
604
2ded9493
MW
605(add-hook 'erlang-mode-hook 'mdw-fontify-erlang t)
606
f617db13
MW
607(add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t)
608(add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t)
609
610(setq LaTeX-table-label "tbl:")
f617db13
MW
611(setq TeX-auto-untabify nil)
612(add-hook 'TeX-mode-hook 'mdw-fontify-tex t)
613(add-hook 'tex-mode-hook 'mdw-fontify-tex t)
614(add-hook 'LaTeX-mode-hook 'mdw-fontify-tex t)
615(add-hook 'latex-mode-hook 'mdw-fontify-tex t)
616
617(add-hook 'sh-mode-hook #'mdw-setup-sh-script-mode)
ec007bea
MW
618(add-hook 'autoconf-mode-hook #'mdw-setup-m4)
619(add-hook 'm4-mode-hook #'mdw-setup-m4)
f617db13
MW
620
621(add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t)
622(add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t)
623
f9d83bff
MW
624(progn
625 (add-hook 'emacs-lisp-mode-hook 'mdw-fontify-lispy t)
626 (add-hook 'scheme-mode-hook 'mdw-fontify-lispy t)
627 (add-hook 'lisp-mode-hook 'mdw-fontify-lispy t)
628 (add-hook 'inferior-lisp-mode-hook 'mdw-fontify-lispy t)
629 (add-hook 'lisp-interaction-mode-hook 'mdw-fontify-lispy t)
630 (add-hook 'slime-repl-mode-hook 'mdw-fontify-lispy t)
631 (add-hook 'lisp-mode-hook 'mdw-common-lisp-indent t)
632 (add-hook 'inferior-lisp-mode-hook
f617db13 633 #'(lambda ()
f9d83bff 634 (local-set-key "\C-m" 'comint-send-and-indent)) t))
f617db13
MW
635
636(add-hook 'text-mode-hook 'mdw-text-mode t)
637
6132bc01
MW
638;;;--------------------------------------------------------------------------
639;;; TeX stuff.
e9955c63
MW
640
641(setq TeX-output-view-style
642 '(("^dvi$"
643 ("^landscape$" "^pstricks$\\|^pst-\\|^psfrag$")
644 "%(o?)dvips -t landscape %d -o && evince %f")
645 ("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$"
646 "%(o?)dvips %d -o && evince %f")
647 ("^dvi$"
648 ("^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "^landscape$")
649 "%(o?)xdvi %dS -paper a4r -s 0 %d")
650 ("^dvi$" "^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$"
651 "%(o?)xdvi %dS -paper a4 %d")
652 ("^dvi$"
653 ("^a5\\(?:comb\\|paper\\)$" "^landscape$")
654 "%(o?)xdvi %dS -paper a5r -s 0 %d")
655 ("^dvi$" "^a5\\(?:comb\\|paper\\)$" "%(o?)xdvi %dS -paper a5 %d")
656 ("^dvi$" "^b5paper$" "%(o?)xdvi %dS -paper b5 %d")
657 ("^dvi$" "^letterpaper$" "%(o?)xdvi %dS -paper us %d")
658 ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d")
659 ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d")
660 ("^dvi$" "." "%(o?)xdvi %dS %d")
661 ("^pdf$" "." "evince %o")
662 ("^html?$" "." "netscape %o")))
663
b615028c
MW
664(setq TeX-open-quote "\""
665 TeX-close-quote "\"")
666
ad21c20c
MW
667(setq reftex-use-external-file-finders t
668 reftex-auto-recenter-toc t)
669
670(setq reftex-label-alist
671 '(("theorem" ?T "th:" "~\\ref{%s}" t ("theorems?" "th\\.") -2)
672 ("axiom" ?A "ax:" "~\\ref{%s}" t ("axioms?" "ax\\.") -2)
673 ("definition" ?D "def:" "~\\ref{%s}" t ("definitions?" "def\\.") -2)
674 ("proposition" ?P "prop:" "~\\ref{%s}" t
675 ("propositions?" "prop\\.") -2)
676 ("lemma" ?P "lem:" "~\\ref{%s}" t ("lemmas?" "lem\\.") -2)
677 ("example" ?X "eg:" "~\\ref{%s}" t ("examples?") -2)
678 ("exercise" ?E "ex:" "~\\ref{%s}" t ("exercises?" "ex\\.") -2)
679 ("enumerate" ?i "i:" "~\\ref{%s}" item ("items?"))))
680(setq reftex-section-prefixes
681 '((0 . "part:")
682 (1 . "ch:")
683 (t . "sec:")))
55f80fae 684
cfabf52c
MW
685(setq bibtex-field-delimiters 'double-quotes
686 bibtex-entry-format '(realign opts-or-alts required-fields
687 numerical-fields last-comma delimiters
688 unify-case)
689 bibtex-include-OPTkey nil)
690
6132bc01
MW
691;;;--------------------------------------------------------------------------
692;;; SLIME setup.
c70671f3 693
ea8a749b
MW
694(trap
695 (if (not mdw-fast-startup)
696 (progn
697 (require 'slime-autoloads)
698 (slime-setup '(slime-autodoc slime-c-p-c)))))
699
c70671f3
MW
700(let ((stuff '((cmucl ("cmucl"))
701 (sbcl ("sbcl") :coding-system utf-8-unix)
702 (clisp ("clisp") :coding-system utf-8-unix))))
703 (or (boundp 'slime-lisp-implementations)
704 (setq slime-lisp-implementations nil))
705 (while stuff
706 (let* ((head (car stuff))
707 (found (assq (car head) slime-lisp-implementations)))
708 (setq stuff (cdr stuff))
709 (if found
710 (rplacd found (cdr head))
711 (setq slime-lisp-implementations
712 (cons head slime-lisp-implementations))))))
713(setq slime-default-lisp 'sbcl)
714
6132bc01
MW
715;;;--------------------------------------------------------------------------
716;;; Blogging.
362f6ac4
MW
717
718(setq weblogger-config-alist
719 '(("vox"
720 ("user" . "mdw")
721 ("server-url" . "http://vox.distorted.org.uk/admin/mt-xmlrpc.cgi")
722 ("weblog" . "1"))))
723
6132bc01
MW
724;;;--------------------------------------------------------------------------
725;;; Shell mode.
f617db13 726
6132bc01 727;; Make the shell mode aware of my prompt.
f617db13 728
ac4ae7cd 729(setq shell-prompt-pattern "^[^]#$%>»}\n]*\\([]#$%»}]\\|>>?\\) *")
f617db13 730(setq comint-password-prompt-regexp
ab9e097f
MW
731 (concat "\\(\\([Ee]nter \\|[Oo]ld \\|[Nn]ew \\|[a-zA-Z0-9_]*'s \\|^\\)"
732 "[Pp]assword\\|pass phrase\\):"))
f617db13 733
6132bc01 734;; Notice passwords, and make C-a work right.
f617db13
MW
735
736(add-hook 'shell-mode-hook #'mdw-sh-mode-setup)
21409787 737(add-hook 'shell-mode-hook #'ansi-color-for-comint-mode-on)
0805d57c 738(setq shell-font-lock-keywords nil)
f617db13
MW
739
740(add-hook 'term-mode-hook #'mdw-term-mode-setup)
741
6132bc01
MW
742;;;--------------------------------------------------------------------------
743;;; Finishing touches.
f617db13
MW
744
745(trap (select-window mdw-init-window))
746(provide 'emacs-init)
747
f617db13 748;;;----- That's all, folks --------------------------------------------------