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