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