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