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