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