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