chiark / gitweb /
dot/e16-bindings: Keyboard shortcut for `zoom'.
[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
MW
270(setq browse-url-browser-function (mdw-good-url-browser)
271 browse-url-mozilla-program "firefox")
9b72460c
MW
272
273(setq w3m-default-display-inline-images t)
274
b0ef6a66
MW
275(eval-after-load "w3m"
276 '(let ((entries '(("application/pdf" "\\.pdf\\'" ("evince" file) nil)
277 ("application/x-pdf" "\\.pdf\\'" ("evince" file) nil))))
278 (dolist (e entries)
279 (setq w3m-content-type-alist
280 (cons e (remove* (car e) w3m-content-type-alist
281 :key #'car :test #'string=))))))
282
f141fe0f
MW
283(setq w3-do-incremental-display t
284 w3-use-menus '(file edit view go bookmark options
285 buffers style search emacs nil help)
286 w3-display-inline-image t
287 w3-keybinding 'info)
f617db13 288
6132bc01
MW
289;;;--------------------------------------------------------------------------
290;;; Calendar configuration.
f617db13 291
ea09c6cb
MW
292(setq diary-file "~/etc/diary")
293
6132bc01 294;; Trivial stuff for the sunrise/sunset calculations.
f617db13
MW
295
296(setq calendar-latitude 52.2)
297(setq calendar-longitude 0.1)
298(setq calendar-location-name "Cambridge, UK")
299
6132bc01 300;; Holidays.
a1293ade
MW
301
302(and (not mdw-fast-startup)
303 (trap
304 (require 'ew-hols)
305 (setq other-holidays (append english-and-welsh-bank-holidays
306 other-holidays))))
307
6132bc01 308;; Date format fiddling.
f617db13
MW
309
310(setq european-calendar-style t)
311
312(setq diary-date-forms '((day "[-/]" month "[^-/0-9]")
313 (day " *" monthname "[ \t]*\\(\^M\\|\n\\)")
314 (backup day " *" monthname "\\W+\\<[^*0-9]")
315 (day "[-/]" month "[-/]" year "[^0-9]")
316 (day " *" monthname " *" year "[^0-9]")
317 (year "[-/]" month "[-/]" day "[^0-9]")
318 (dayname "\\W")))
319
6132bc01 320;; Fancy diary handling.
f617db13
MW
321
322(add-hook 'diary-display-hook 'fancy-diary-display)
323(setq diary-list-include-blanks t)
324(add-hook 'list-diary-entries-hook 'sort-diary-entries t)
325(add-hook 'list-diary-entries-hook 'include-other-diary-files)
326(add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
327
6132bc01 328;; Appointment management.
f617db13
MW
329
330(add-hook 'diary-hook 'appt-make-list)
331(setq appt-issue-message t)
332(setq appt-display-interval 3)
333(setq appt-message-warning-time 10)
334
6132bc01 335;; Org-mode agenda.
2d6b9d95 336
e3f433a2
MW
337(setq org-agenda-include-diary t
338 org-tags-column -77)
2d6b9d95 339
6132bc01 340;; Cosmetic stuff.
f617db13
MW
341
342(setq display-time-24hr-format t)
343(display-time)
dca9e3ae 344(column-number-mode 1)
f617db13
MW
345(trap
346 (if window-system
347 (let ((view-diary-entries-initially t))
348 (calendar))))
349
6132bc01
MW
350;;;--------------------------------------------------------------------------
351;;; MailCrypt.
f617db13 352
6132bc01 353;; Define more mode hooks for MailCrypt.
f617db13
MW
354
355(setq mdw-mc-modes
356 '((mdwmail-mode (encrypt . mdwmail-mc-encrypt)
357 (sign . mdwmail-mc-sign))))
358
6132bc01 359;; Load the MailCrypt support.
f617db13
MW
360
361(trap
362 (and (string-match "linux" (symbol-name system-type))
c7a8da49 363 (not mdw-fast-startup)
f617db13
MW
364 (progn (require 'mailcrypt-init)
365 (require 'mailcrypt)
366 (setq mc-default-scheme 'mc-scheme-gpg)
367 (setq mc-pgp-user-id "mdw-nsict-pgp")
368 (setq mc-gpg-user-id "mdw-nsict-gpg")
369 (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
370 (setq mc-pgp-always-sign t)
371 (setq mc-gpg-always-sign t)
372 (setq mc-always-replace 'never)
373 (setq mc-passwd-timeout 3600)
374 (setq mc-temp-directory tmpdir)
375 (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
376 (define-key mc-write-mode-map "\C-c/S" 'mc-sign-region)
377 (define-key mc-write-mode-map "\C-c/E" 'mc-encrypt-region)
378 (add-hook 'text-mode-hook 'mc-install-write-mode))))
379
6132bc01
MW
380;;;--------------------------------------------------------------------------
381;;; Other common declarations.
f617db13 382
6132bc01 383;; Default frame size.
f617db13
MW
384
385(setq default-frame-alist
386 (mdw-uniquify-alist
387 '((width . 78)
388 (height . 33)
c14ce5af
MW
389 (vertical-scroll-bars . right)
390 (cursor-type . bar)
391 (cursor-blink . t)
392 (left-fringe . 5)
393 (right-fringe . 5)
394 (scroll-bar-width . 15)
395 (cursor-color . "red"))
f617db13 396 (if mdw-black-background
6dc0fd06 397 '((background-mode . dark))
2dd9081f
MW
398 '((background-mode . light)))))
399(setq window-system-default-frame-alist
400 '((pm (font . "-os2-System VIO-medium-r-normal--*-40-*-*-m-*-cp850")
401 (menu-font . "8.Helv")
402 (background-color . "lightgrey"))
403 (nil (menu-bar-lines . 0))))
f617db13 404
6132bc01 405;; Other frame fiddling.
f617db13
MW
406
407(setq frame-title-format '("" invocation-name "@" system-name ": %b"))
408
6132bc01 409;; Global keymap changes.
f617db13
MW
410
411(trap
f110f932
MW
412 (windmove-default-keybindings))
413(setq windmove-wrap-around t)
f617db13 414(trap (iswitchb-mode))
f9d83bff
MW
415(progn
416 (global-set-key [?\C-x ?w left] 'windmove-left)
417 (global-set-key [?\C-x ?w ?h] 'windmove-left)
418 (global-set-key [?\C-x ?w up] 'windmove-up)
419 (global-set-key [?\C-x ?w ?k] 'windmove-up)
420 (global-set-key [?\C-x ?w down] 'windmove-down)
421 (global-set-key [?\C-x ?w ?j] 'windmove-down)
422 (global-set-key [?\C-x ?w right] 'windmove-right)
423 (global-set-key [?\C-x ?w ?l] 'windmove-right)
424 (global-set-key [?\C-x ?g ?l] 'org-store-link)
425 (global-set-key [?\C-x ?g ?a] 'org-agenda)
426 (global-set-key [?\C-x ?g ?b] 'org-iswitchb)
427 (global-set-key [?\C-x ?t ?i] 'timeclock-in)
428 (global-set-key [?\C-x ?t ?c] 'timeclock-change)
429 (global-set-key [?\C-x ?t ?o] 'timeclock-out)
430 (global-set-key [?\C-x ?t ?r] 'timeclock-reread-log)
431 (global-set-key [?\C-x ?t ?w] 'timeclock-workday-remaining-string)
432 (global-set-key [?\C-x ?t ?s] 'timeclock-status-string)
433 (global-set-key [?\C-x ?t ?p] 'nc-timesheet-prepare)
434 (global-set-key [?\C-x ?t ?\C-m] 'nc-timesheet-submit)
435 (global-set-key [?\M-#] 'calc-dispatch)
436 (global-set-key [?\C-x ?/] 'auto-fill-mode)
437 (global-set-key [?\C-x ?w ?d] 'mdw-divvy-window)
438 (global-set-key [insertchar] 'overwrite-mode)
439 (global-set-key [?\C-x ?\C-n] 'skel-create-file)
440 (global-set-key [?\C-x ?4 ?n] 'skel-create-file-other-window)
441 (global-set-key [?\C-x ?5 ?n] 'skel-create-file-other-frame)
442 (global-set-key [delete] 'delete-char)
443 (global-set-key [?\M-q] 'mdw-fill-paragraph)
444 (global-set-key [?\C-h ?\C-m] 'manual-entry)
445 (global-set-key [C-M-backspace] 'backward-kill-sexp)
446 (global-set-key [mode-line C-mouse-1] 'mouse-tear-off-window)
447 (global-set-key [vertical-scroll-bar C-down-mouse-1]
448 'mouse-drag-vertical-line)
449 (global-set-key [vertical-scroll-bar C-mouse-1]
450 #'(lambda () (interactive)))
451 (global-set-key [XF86WakeUp] "")
452 (and (not mdw-fast-startup) (fboundp 'hippie-expand)
453 (global-set-key [?\M-/] 'hippie-expand)))
f617db13 454
cadc9736
MW
455(eval-after-load "dired"
456 '(progn
8cb828d5
MW
457 (or (lookup-key dired-mode-map [?\C-x ?\C-q])
458 (define-key dired-mode-map [?\C-x ?\C-q]
459 'wdired-change-to-wdired-mode))
460 (and (fboundp 'dired-do-relsymlink)
461 (define-key dired-mode-map [?\C-c ?\C-s] 'dired-do-relsymlink))))
cadc9736 462
16fe7c41
MW
463(add-hook 'org-mode-hook
464 #'(lambda () (mdw-clobber-evil-keymap org-mode-map)))
465(add-hook 'org-agenda-mode-hook
466 #'(lambda () (mdw-clobber-evil-keymap org-agenda-mode-map)))
f351e828
MW
467(or mdw-fast-startup
468 (progn
469 (org-remember-insinuate)
470 (global-set-key [?\C-c ?r] 'org-remember)))
4849ea18 471
6132bc01 472;; Recognising types of files.
f617db13
MW
473
474(setq auto-mode-alist
475 (append `(("\\.p[lm]$" . perl-mode)
476 ("\\.m$" . objc-mode)
477 ("\\.mxd$" . c-mode)
e6cb5770 478 ("\\.cs$" . csharp-mode)
07965a39 479 ("\\.go$" . go-mode)
133cf81d 480 ("\\.org$" . org-mode)
f617db13
MW
481 ;; ("/[ch]/" . c-mode)
482 (,(concat "/\\("
483 "\\.stgit\\.msg" "\\|"
484 "\\.git/COMMIT_EDITMSG" "\\|"
485 "svn-commit\\.tmp" "\\|"
486 "svk-commit[^/.]*\\.tmp"
487 "\\)$")
488 . text-mode)
489 (,(concat "^" tmpdir "/\\("
490 "svk-commit[^/.]*\\.tmp" "\\|"
491 "gitci\\.[^/.]*" "\\|"
492 "cvs[^/.]\\{6\\}" "\\|"
400223a1 493 "quilt_header\.[^/.]\\{6\\}"
f617db13
MW
494 "\\)$")
495 . text-mode)
496 ("\\.calc?$" . apcalc-mode)
497 ("/src/linux/.*\\.\\(c\\|h\\|cc\\)$" . linux-c-mode)
498 ("/\\(s\\|sh\\)/" . arm-assembler-mode)
499 ("\\.\\(cmd\\|exec\\|rexx\\)$" . rexx-mode)
500 ("\\.st$" . smalltalk-mode)
1e52f579
MW
501 ("\\.msgs$" . messages-mode)
502 ("/all-cmds\\.in$" . cpp-messages-mode)
f617db13
MW
503 ("\\.\\(tex\\|dtx\\)$" . latex-mode)
504 ("\\.gc$" . haskell.-mode)
505 (,(concat "^" (getenv "HOME") "/News/") . mdwmail-mode)
870778ff 506 (,(concat "^" tmpdir "/\\(SLRN\\|snd\\|pico\\|mutt\\)")
f617db13
MW
507 . mdwmail-mode))
508 auto-mode-alist))
509
27cb4215
MW
510(setq interpreter-mode-alist
511 (append `(("runlisp" . lisp-mode))
512 interpreter-mode-alist))
513
f617db13
MW
514(setq completion-ignored-extensions
515 (append `(".hc" ".hi") completion-ignored-extensions))
298fab5b
MW
516(dolist (dir (remove-if-not (lambda (ext)
517 (= (aref ext (- (length ext) 1)) ?/))
518 completion-ignored-extensions))
519 (if (/= (aref dir 0) ?/)
520 (setq completion-ignored-extensions
521 (cons (concat "/" dir)
522 (remove dir completion-ignored-extensions)))))
f617db13 523
6132bc01 524;; Some common local definitions.
f617db13
MW
525
526(make-variable-buffer-local 'mdw-auto-indent)
527
528(mapcar (lambda (hook) (add-hook hook 'mdw-misc-mode-config))
529 '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
2ded9493 530 csharp-mode-hook perl-mode-hook cperl-mode-hook
99fe6ef5 531 python-mode-hook pyrec-mode-hook icon-mode-hook awk-mode-hook
07965a39 532 tcl-mode-hook go-mode-hook
2ded9493
MW
533 asm-mode-hook TeX-mode-hook LaTeX-mode-hook
534 TeXinfo-mode-hook tex-mode-hook latex-mode-hook
535 texinfo-mode-hook emacs-lisp-mode-hook scheme-mode-hook
536 lisp-mode-hook lisp-interaction-mode-hook
537 inferior-lisp-mode-hook slime-repl-mode-hook
538 sml-mode-hook haskell-mode-hook erlang-mode-hook
f617db13
MW
539 smalltalk-mode-hook rexx-mode-hook
540 arm-assembler-mode-hook))
541
542(global-font-lock-mode t)
543(defalias 'perl-mode 'cperl-mode)
544
6132bc01
MW
545;;;--------------------------------------------------------------------------
546;;; Rootly editingness.
f617db13
MW
547
548(eval-after-load "tramp"
ae7460d4 549 '(let ((fix-args (if (mdw-version-< tramp-version "2.1")
507ebf80 550 #'append #'list)))
f617db13
MW
551 (setq tramp-methods
552 (mdw-uniquify-alist
553 `(("become"
554 (tramp-connection-function tramp-open-connection-su)
555 (tramp-remote-sh "/bin/sh")
556 (tramp-login-program "become")
557 (tramp-copy-program nil)
558 (tramp-copy-args nil)
559 (tramp-copy-keep-date-arg nil)
ae7460d4 560 (tramp-login-args ,(funcall fix-args `("TERM=dumb" "%u"))))
f617db13
MW
561 ("really"
562 (tramp-connection-function tramp-open-connection-su)
563 (tramp-login-program "really")
ae7460d4
MW
564 (tramp-login-args ,(funcall fix-args
565 `("-u" "%u")
566 `("--")
567 `("env" "TERM=dumb" "/bin/sh")))
f617db13
MW
568 (tramp-copy-program nil)
569 (tramp-copy-args nil)
570 (tramp-copy-keep-date-arg nil)
571 (tramp-remote-sh "/bin/sh"))
572 ,@tramp-methods)))
f617db13
MW
573 (setq tramp-default-method "ssh")
574 (setq tramp-default-method-alist
ae7460d4 575 `(("\\`\\(localhost\\|\\)\\'" ""
f617db13
MW
576 ,(cond ((executable-find "become") "become")
577 ((executable-find "really") "really")
578 (t "su")))))))
579
6132bc01
MW
580;;;--------------------------------------------------------------------------
581;;; General fontification.
f617db13 582
6132bc01 583;; Configure lazy fontification.
f617db13 584
f29cc9b2
MW
585(and (fboundp 'lazy-lock-mode)
586 (setq font-lock-support-mode 'lazy-lock-mode))
f617db13 587; (setq lazy-lock-defer-contextually t)
f9d83bff
MW
588(setq lazy-lock-defer-time nil
589 font-lock-maximum-decoration 3
590 lazy-lock-minimum-size 0
591 lazy-lock-stealth-time 5
592 lazy-lock-stealth-lines 100
593 lazy-lock-stealth-verbose t)
f617db13 594
f9d83bff
MW
595(progn
596 (add-hook 'c-mode-hook 'mdw-fontify-c-and-c++ t)
597 (add-hook 'objc-mode-hook 'mdw-fontify-c-and-c++ t)
598 (add-hook 'c++-mode-hook 'mdw-fontify-c-and-c++ t)
599 (add-hook 'linux-c-mode-hook #'(lambda () (setq c-basic-offset 8)))
600 (add-hook 'asm-mode-hook 'mdw-fontify-asm t)
07965a39 601 (add-hook 'go-mode-hook 'mdw-fontify-go t)
f617db13 602
f9d83bff 603 (add-hook 'icon-mode-hook 'mdw-fontify-icon t)
f617db13 604
f9d83bff
MW
605 (add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t)
606 (add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
cc1980e1 607
f9d83bff
MW
608 (add-hook 'java-mode-hook 'mdw-fontify-java t)
609 (add-hook 'csharp-mode-hook 'mdw-fontify-csharp t)
f617db13 610
f9d83bff 611 (add-hook 'awk-mode-hook 'mdw-fontify-awk t)
f617db13 612
f9d83bff
MW
613 (add-hook 'perl-mode-hook 'mdw-fontify-perl t)
614 (add-hook 'cperl-mode-hook 'mdw-fontify-perl t))
f617db13 615
f9d83bff
MW
616(progn
617 (setq-default py-indent-offset 2
618 py-python-command-args
619 `("-i" "-colors" ,(if mdw-black-background
620 "Linux" "LightBG")))
621 (add-hook 'python-mode-hook 'mdw-fontify-python t)
622 (add-hook 'pyrex-mode-hook 'mdw-fontify-pyrex t))
f617db13
MW
623
624(setq-default tcl-indent-level 2)
625(add-hook 'tcl-mode-hook 'mdw-fontify-tcl t)
626
627(add-hook 'rexx-mode-hook 'mdw-fontify-rexx t)
628
f9d83bff
MW
629(setq sml-nested-if-indent t
630 sml-case-indent nil
631 sml-indent-level 4
632 sml-type-of-indent nil)
f617db13
MW
633(add-hook 'sml-mode-hook 'mdw-fontify-sml t)
634
635(add-hook 'haskell-mode-hook 'mdw-fontify-haskell t)
636(setq-default haskell-indent-offset 2)
637
2ded9493
MW
638(add-hook 'erlang-mode-hook 'mdw-fontify-erlang t)
639
f617db13
MW
640(add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t)
641(add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t)
642
643(setq LaTeX-table-label "tbl:")
f617db13
MW
644(setq TeX-auto-untabify nil)
645(add-hook 'TeX-mode-hook 'mdw-fontify-tex t)
646(add-hook 'tex-mode-hook 'mdw-fontify-tex t)
647(add-hook 'LaTeX-mode-hook 'mdw-fontify-tex t)
648(add-hook 'latex-mode-hook 'mdw-fontify-tex t)
649
650(add-hook 'sh-mode-hook #'mdw-setup-sh-script-mode)
ec007bea
MW
651(add-hook 'autoconf-mode-hook #'mdw-setup-m4)
652(add-hook 'm4-mode-hook #'mdw-setup-m4)
f617db13
MW
653
654(add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t)
655(add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t)
656
f9d83bff
MW
657(progn
658 (add-hook 'emacs-lisp-mode-hook 'mdw-fontify-lispy t)
659 (add-hook 'scheme-mode-hook 'mdw-fontify-lispy t)
660 (add-hook 'lisp-mode-hook 'mdw-fontify-lispy t)
661 (add-hook 'inferior-lisp-mode-hook 'mdw-fontify-lispy t)
662 (add-hook 'lisp-interaction-mode-hook 'mdw-fontify-lispy t)
663 (add-hook 'slime-repl-mode-hook 'mdw-fontify-lispy t)
664 (add-hook 'lisp-mode-hook 'mdw-common-lisp-indent t)
665 (add-hook 'inferior-lisp-mode-hook
f617db13 666 #'(lambda ()
f9d83bff 667 (local-set-key "\C-m" 'comint-send-and-indent)) t))
f617db13
MW
668
669(add-hook 'text-mode-hook 'mdw-text-mode t)
670
6132bc01
MW
671;;;--------------------------------------------------------------------------
672;;; TeX stuff.
e9955c63
MW
673
674(setq TeX-output-view-style
675 '(("^dvi$"
676 ("^landscape$" "^pstricks$\\|^pst-\\|^psfrag$")
677 "%(o?)dvips -t landscape %d -o && evince %f")
678 ("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$"
679 "%(o?)dvips %d -o && evince %f")
680 ("^dvi$"
681 ("^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "^landscape$")
682 "%(o?)xdvi %dS -paper a4r -s 0 %d")
683 ("^dvi$" "^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$"
684 "%(o?)xdvi %dS -paper a4 %d")
685 ("^dvi$"
686 ("^a5\\(?:comb\\|paper\\)$" "^landscape$")
687 "%(o?)xdvi %dS -paper a5r -s 0 %d")
688 ("^dvi$" "^a5\\(?:comb\\|paper\\)$" "%(o?)xdvi %dS -paper a5 %d")
689 ("^dvi$" "^b5paper$" "%(o?)xdvi %dS -paper b5 %d")
690 ("^dvi$" "^letterpaper$" "%(o?)xdvi %dS -paper us %d")
691 ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d")
692 ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d")
693 ("^dvi$" "." "%(o?)xdvi %dS %d")
694 ("^pdf$" "." "evince %o")
695 ("^html?$" "." "netscape %o")))
696
b615028c
MW
697(setq TeX-open-quote "\""
698 TeX-close-quote "\"")
699
ad21c20c
MW
700(setq reftex-use-external-file-finders t
701 reftex-auto-recenter-toc t)
702
703(setq reftex-label-alist
704 '(("theorem" ?T "th:" "~\\ref{%s}" t ("theorems?" "th\\.") -2)
705 ("axiom" ?A "ax:" "~\\ref{%s}" t ("axioms?" "ax\\.") -2)
706 ("definition" ?D "def:" "~\\ref{%s}" t ("definitions?" "def\\.") -2)
707 ("proposition" ?P "prop:" "~\\ref{%s}" t
708 ("propositions?" "prop\\.") -2)
709 ("lemma" ?P "lem:" "~\\ref{%s}" t ("lemmas?" "lem\\.") -2)
710 ("example" ?X "eg:" "~\\ref{%s}" t ("examples?") -2)
711 ("exercise" ?E "ex:" "~\\ref{%s}" t ("exercises?" "ex\\.") -2)
712 ("enumerate" ?i "i:" "~\\ref{%s}" item ("items?"))))
713(setq reftex-section-prefixes
714 '((0 . "part:")
715 (1 . "ch:")
716 (t . "sec:")))
55f80fae 717
cfabf52c
MW
718(setq bibtex-field-delimiters 'double-quotes
719 bibtex-entry-format '(realign opts-or-alts required-fields
720 numerical-fields last-comma delimiters
721 unify-case)
722 bibtex-include-OPTkey nil)
723
6132bc01
MW
724;;;--------------------------------------------------------------------------
725;;; SLIME setup.
c70671f3 726
ea8a749b
MW
727(trap
728 (if (not mdw-fast-startup)
729 (progn
730 (require 'slime-autoloads)
731 (slime-setup '(slime-autodoc slime-c-p-c)))))
732
c70671f3
MW
733(let ((stuff '((cmucl ("cmucl"))
734 (sbcl ("sbcl") :coding-system utf-8-unix)
735 (clisp ("clisp") :coding-system utf-8-unix))))
736 (or (boundp 'slime-lisp-implementations)
737 (setq slime-lisp-implementations nil))
738 (while stuff
739 (let* ((head (car stuff))
740 (found (assq (car head) slime-lisp-implementations)))
741 (setq stuff (cdr stuff))
742 (if found
743 (rplacd found (cdr head))
744 (setq slime-lisp-implementations
745 (cons head slime-lisp-implementations))))))
746(setq slime-default-lisp 'sbcl)
747
6132bc01
MW
748;;;--------------------------------------------------------------------------
749;;; Blogging.
362f6ac4
MW
750
751(setq weblogger-config-alist
752 '(("vox"
753 ("user" . "mdw")
754 ("server-url" . "http://vox.distorted.org.uk/admin/mt-xmlrpc.cgi")
755 ("weblog" . "1"))))
756
6132bc01
MW
757;;;--------------------------------------------------------------------------
758;;; Shell mode.
f617db13 759
6132bc01 760;; Make the shell mode aware of my prompt.
f617db13 761
ac4ae7cd 762(setq shell-prompt-pattern "^[^]#$%>»}\n]*\\([]#$%»}]\\|>>?\\) *")
f617db13 763(setq comint-password-prompt-regexp
ab9e097f
MW
764 (concat "\\(\\([Ee]nter \\|[Oo]ld \\|[Nn]ew \\|[a-zA-Z0-9_]*'s \\|^\\)"
765 "[Pp]assword\\|pass phrase\\):"))
f617db13 766
6132bc01 767;; Notice passwords, and make C-a work right.
f617db13
MW
768
769(add-hook 'shell-mode-hook #'mdw-sh-mode-setup)
21409787 770(add-hook 'shell-mode-hook #'ansi-color-for-comint-mode-on)
0805d57c 771(setq shell-font-lock-keywords nil)
f617db13
MW
772
773(add-hook 'term-mode-hook #'mdw-term-mode-setup)
774
6132bc01
MW
775;;;--------------------------------------------------------------------------
776;;; Finishing touches.
f617db13
MW
777
778(trap (select-window mdw-init-window))
779(provide 'emacs-init)
780
f617db13 781;;;----- That's all, folks --------------------------------------------------