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