mdw.conf: Central configuration file for common differences.
[profile] / emacs
1 ;;; -*-emacs-lisp-*-
2 ;;;
3 ;;; $Id: .emacs,v 1.11 1997/01/01 18:47:09 mdw Exp $
4 ;;;
5 ;;; Emacs configuration file
6 ;;;
7 ;;; (c) 1996-1999 Mark Wooding
8 ;;;
9
10 ;;;----- Licensing notice ---------------------------------------------------
11 ;;;
12 ;;; This program is free software; you can redistribute it and/or modify
13 ;;; it under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 2 of the License, or
15 ;;; (at your option) any later version.
16 ;;;
17 ;;; This program is distributed in the hope that it will be useful,
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
21 ;;;
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with this program; if not, write to the Free Software
24 ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
25
26 (setq load-path (nconc load-path (list "~/lib/emacs")))
27 (require 'dot-emacs)
28
29 ;;;----- Some random initialisation -----------------------------------------
30
31 (setq mdw-init-window (selected-window))
32
33 ;; --- Load some other bits of code ---
34
35 (setq load-path (cons "~/lib/emacs" load-path))
36
37 (autoload 'cc-mode "cc-mode" nil t)
38 (autoload 'rexx-mode "rexx-mode" nil t)
39 (autoload 'cvs-update "pcl-cvs" nil t)
40 (autoload 'debian-changelog-mode "debian-changelog-mode" nil t)
41
42 (trap
43 (or (fboundp 'make-regexp)
44 (load "make-regexp")))
45
46 (trap (require 'tex-site))
47
48 ;; --- Skeleton stuff ---
49
50 (trap (require 'skel-init))
51
52 ;; --- Window system-dependent things ---
53
54 (require 'paren)
55 (trap (show-paren-mode t))
56 (or window-system (menu-bar-mode -1))
57
58 ;; --- Temporary directory handling ---
59
60 (defun mdw-check-dir-exists (dir)
61 (and dir
62 (file-directory-p dir)
63 dir))
64 (setq tmpdir (or (mdw-check-dir-exists (getenv "TMPDIR"))
65 (mdw-check-dir-exists (format "/tmp/%s" (user-login-name)))
66 "/tmp"))
67
68 ;; --- Emacs server behaviour ---
69
70 (and window-system
71 (trap (gnuserv-start)
72 (setq server-temp-file-regexp (concat "^" tmpdir "\\|/draft$"))))
73
74 ;; --- Control backup behaviour ---
75
76 (setq backup-by-copying nil)
77 (setq backup-by-copying-when-linked t)
78 (setq backup-by-copying-when-mismatch t)
79
80 ;; --- Calculator fiddling ---
81
82 (setq calc-settings-file "~/.emacs-calc")
83 (load calc-settings-file)
84
85 ;; ---- Some mail and news configuration ---
86
87 (setq mail-from-style 'parens)
88 (setq mail-signature t)
89 (setq mail-yank-prefix "> ")
90 (setq mail-archive-file-name "~/Mail/sent")
91
92 (setq rmail-display-summary t)
93 (setq rmail-file-name "~/Mail/rmail")
94
95 ;; --- GNUS configuration ---
96
97 (setq gnus-select-method '(nntp "tux.nsict.org"))
98 (setq gnus-read-active-file 'some)
99 (setq gnus-inhibit-startup-message t)
100 (setq gnus-large-newsgroup 500)
101
102 ;; --- Internationalization twiddling ---
103
104 (trap
105 (standard-display-european 1)
106 (let ((im (current-input-mode)))
107 (apply #'set-input-mode
108 (nconc (list (nth 0 im) (nth 1 im) 0) (nthcdr 3 im))))
109 (set-language-environment "Latin-1"))
110
111 ;; --- Don't disable any commands ---
112
113 (mapatoms #'(lambda (sym) (put sym 'disabled nil)))
114
115 ;; --- Split a wide window ---
116
117 (mdw-divvy-window)
118
119 ;; --- Other goodies ---
120
121 (resize-minibuffer-mode 1) ;Make minibuffer grow dynamically
122 (auto-compression-mode 1) ;Enable automatic compression
123 (setq dabbrev-case-replace nil) ;Retain case when completing
124 (setq next-line-add-newlines nil) ;Don't add weird newlines
125 (setq split-height-threshold 45) ;Reuse windows where sensible
126 (setq dired-deletion-confirmer ;Make deletion easier in dired
127 (symbol-function 'y-or-n-p))
128 (setq dired-listing-switches "-alF") ;Do `ls -F' things in dired windows
129 (setq case-fold-file-names nil) ;Don't translate file names (grr...)
130 (setq scroll-step 5) ;Don't scroll too much at a time
131 (setq-default fill-column 77) ;I use rather narrow windows
132 (setq-default comment-column 40) ;Set a standard comment column
133 (setq-default truncate-partial-width-windows nil)
134 (setq diff-switches "-u" ;I like reading unified diffs
135 cvs-diff-flags (list diff-switches))
136 (setq echo-keystrokes 10) ;Long delay before keystrokes echo
137 (setq ange-ftp-ftp-program-name "pftp") ;Use passive FTP
138 (setq find-ls-option ;Build file lists efficiently
139 '("-print0 | xargs -0r ls -ld" . "ld"))
140 (setq Info-fontify-maximum-menu-size 60000)
141 (setq ispell-dictionary "british"
142 flyspell-default-dictionary "british")
143 (setq browse-url-browser-function 'browse-url-mozilla
144 browse-url-mozilla-program "firefox")
145 (trap
146 (require 'uniquify)
147 (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
148 (setq uniquify-after-kill-buffer-p t))
149 (transient-mark-mode t)
150 (trap
151 (tooltip-mode 0)
152 (tool-bar-mode 0))
153 (trap (global-auto-revert-mode t))
154 (setq psgml-html-build-new-buffer nil)
155
156 (setq cltl2-root-url (mdw-config 'cltl-url))
157 (setq common-lisp-hyperspec-root (mdw-config 'hyperspec-url))
158
159 ;;;----- W3 and URL fetching stuff ------------------------------------------
160
161 (let ((proxy (mdw-config 'proxy)))
162 (setq url-proxy-services
163 `(("http" . ,proxy)
164 ("ftp" . ,proxy)
165 ("gopher" . ,proxy))))
166 (setq url-cookie-untrusted-urls '("."))
167
168 (setq w3-do-incremental-display t
169 w3-use-menus '(file edit view go bookmark options
170 buffers style search emacs nil help)
171 w3-display-inline-image t
172 w3-keybinding 'info)
173
174 ;;;----- Calendar configuration ---------------------------------------------
175
176 ;; --- Trivial stuff for the sunrise/sunset calculations ---
177
178 (setq calendar-latitude 52.2)
179 (setq calendar-longitude 0.1)
180 (setq calendar-location-name "Cambridge, UK")
181
182 ;; --- Date format fiddling ---
183
184 (setq european-calendar-style t)
185
186 (setq diary-date-forms '((day "[-/]" month "[^-/0-9]")
187 (day " *" monthname "[ \t]*\\(\^M\\|\n\\)")
188 (backup day " *" monthname "\\W+\\<[^*0-9]")
189 (day "[-/]" month "[-/]" year "[^0-9]")
190 (day " *" monthname " *" year "[^0-9]")
191 (year "[-/]" month "[-/]" day "[^0-9]")
192 (dayname "\\W")))
193
194 ;; --- Fancy diary handling ---
195
196 (add-hook 'diary-display-hook 'fancy-diary-display)
197 (setq diary-list-include-blanks t)
198 (add-hook 'list-diary-entries-hook 'sort-diary-entries t)
199 (add-hook 'list-diary-entries-hook 'include-other-diary-files)
200 (add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
201
202 ;; --- Appointment management ---
203
204 (add-hook 'diary-hook 'appt-make-list)
205 (setq appt-issue-message t)
206 (setq appt-display-interval 3)
207 (setq appt-message-warning-time 10)
208
209 ;; --- Cosmetic stuff ---
210
211 (setq display-time-24hr-format t)
212 (display-time)
213 (trap
214 (if window-system
215 (let ((view-diary-entries-initially t))
216 (calendar))))
217
218 (defvar mdw-black-background t)
219
220 ;; --- Define more mode hooks for MailCrypt ---
221
222 (setq mdw-mc-modes
223 '((mdwmail-mode (encrypt . mdwmail-mc-encrypt)
224 (sign . mdwmail-mc-sign))))
225
226 ;; --- Load the MailCrypt support ---
227
228 (trap
229 (and (string-match "linux" (symbol-name system-type))
230 (progn (require 'mailcrypt-init)
231 (require 'mailcrypt)
232 (setq mc-default-scheme 'mc-scheme-gpg)
233 (setq mc-pgp-user-id "mdw-nsict-pgp")
234 (setq mc-gpg-user-id "mdw-nsict-gpg")
235 (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
236 (setq mc-pgp-always-sign t)
237 (setq mc-gpg-always-sign t)
238 (setq mc-always-replace 'never)
239 (setq mc-passwd-timeout 3600)
240 (setq mc-temp-directory tmpdir)
241 (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
242 (define-key mc-write-mode-map "\C-c/S" 'mc-sign-region)
243 (define-key mc-write-mode-map "\C-c/E" 'mc-encrypt-region)
244 (add-hook 'text-mode-hook 'mc-install-write-mode))))
245
246 ;;;----- Other common declarations ------------------------------------------
247
248 ;; --- Default frame size ---
249
250 (setq default-frame-alist
251 (mdw-uniquify-alist
252 '((width . 78)
253 (height . 33)
254 (vertical-scroll-bars . right))
255 (and window-system
256 '((cursor-type . bar)
257 (cursor-blink . t)))
258 '((cursor-color . "red"))
259 (if mdw-black-background
260 '((background-color . "black")
261 (foreground-color . "white")
262 (background-mode . dark))
263 '((background-mode . light)))
264 (and (eq window-system 'pm)
265 '((font . "-os2-System VIO-medium-r-normal--*-40-*-*-m-*-cp850")
266 (menu-font . "8.Helv")
267 (background-color . "lightgrey")))
268 '((transparency . t))
269 default-frame-alist))
270
271 ;; --- Other frame fiddling ---
272
273 (setq frame-title-format '("" invocation-name "@" system-name ": %b"))
274
275 ;; --- Global keymap changes ---
276
277 (trap
278 (windmove-default-keybindings)
279 (setq windmove-wrap-around t))
280 (trap (iswitchb-mode))
281 (global-set-key [f4] 'query-replace-regexp)
282 (global-set-key [f5] 'goto-line)
283 (global-set-key [f6] 'auto-fill-mode)
284 (global-set-key [f7] 'occur)
285 (global-set-key [f8] 'undo)
286 (global-set-key [f9] 'mdw-divvy-window)
287 (global-set-key [insertchar] 'overwrite-mode)
288 (global-set-key "\C-xm" 'vm-mail)
289 (global-set-key "\C-x\C-n" 'skel-create-file)
290 (global-set-key "\C-x4n" 'skel-create-file-other-window)
291 (global-set-key "\C-x5n" 'skel-create-file-other-frame)
292 (global-set-key [delete] 'delete-char)
293 (global-set-key "\C-[\C-m" 'call-last-kbd-macro)
294 (global-set-key "\M-q" 'mdw-fill-paragraph)
295 (global-set-key "\C-h\C-m" 'manual-entry)
296 (global-set-key [mode-line C-mouse-1] 'mouse-tear-off-window)
297 (global-set-key [vertical-scroll-bar C-down-mouse-1]
298 'mouse-drag-vertical-line)
299 (global-set-key [vertical-scroll-bar C-mouse-1]
300 #'(lambda () (interactive)))
301 (global-set-key [mouse-4] 'mdw-wheel-up)
302 (global-set-key [mouse-5] 'mdw-wheel-down)
303
304 ;; --- Recognising types of files ---
305
306 (setq auto-mode-alist
307 (append `(("\\.p[lm]$" . perl-mode)
308 ("\\.m$" . objc-mode)
309 ("\\.mxd$" . c-mode)
310 ;; ("/[ch]/" . c-mode)
311 (,(concat "/\\("
312 "\\.stgit\\.msg" "\\|"
313 "\\.git/COMMIT_EDITMSG" "\\|"
314 "svn-commit\\.tmp" "\\|"
315 "svk-commit[^/.]*\\.tmp"
316 "\\)$")
317 . text-mode)
318 (,(concat "^" tmpdir "/\\("
319 "svk-commit[^/.]*\\.tmp" "\\|"
320 "gitci\\.[^/.]*" "\\|"
321 "cvs[^/.]\\{6\\}" "\\|"
322 "\\)$")
323 . text-mode)
324 ("\\.calc?$" . apcalc-mode)
325 ("/src/linux/.*\\.\\(c\\|h\\|cc\\)$" . linux-c-mode)
326 ("/\\(s\\|sh\\)/" . arm-assembler-mode)
327 ("\\.\\(cmd\\|exec\\|rexx\\)$" . rexx-mode)
328 ("\\.st$" . smalltalk-mode)
329 ("\\.msgs$" . messages-mode)
330 ("/all-cmds\\.in$" . cpp-messages-mode)
331 ("\\.\\(tex\\|dtx\\)$" . latex-mode)
332 ("\\.gc$" . haskell.-mode)
333 (,(concat "^" (getenv "HOME") "/News/") . mdwmail-mode)
334 (,(concat "^" tmpdir "/\\(SLRN\\|snd\\|pico\\)")
335 . mdwmail-mode))
336 auto-mode-alist))
337
338 (setq completion-ignored-extensions
339 (append `(".hc" ".hi") completion-ignored-extensions))
340
341 ;; --- Some common local definitions ---
342
343 (make-variable-buffer-local 'mdw-auto-indent)
344
345 (mapcar (lambda (hook) (add-hook hook 'mdw-misc-mode-config))
346 '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
347 perl-mode-hook cperl-mode-hook python-mode-hook awk-mode-hook
348 tcl-mode-hook
349 TeX-mode-hook LaTeX-mode-hook TeXinfo-mode-hook
350 tex-mode-hook latex-mode-hook texinfo-mode-hook
351 emacs-lisp-mode-hook scheme-mode-hook
352 lisp-mode-hook lisp-interaction-mode-hook inferior-lisp-mode-hook
353 slime-repl-mode-hook
354 sml-mode-hook haskell-mode-hook
355 smalltalk-mode-hook rexx-mode-hook
356 arm-assembler-mode-hook))
357
358 (global-font-lock-mode t)
359 (defalias 'perl-mode 'cperl-mode)
360
361 ;;;----- Rootly editingness -------------------------------------------------
362
363 (eval-after-load "tramp"
364 '(progn
365 (setq tramp-methods
366 (mdw-uniquify-alist
367 `(("become"
368 (tramp-connection-function tramp-open-connection-su)
369 (tramp-remote-sh "/bin/sh")
370 (tramp-login-program "become")
371 (tramp-copy-program nil)
372 (tramp-copy-args nil)
373 (tramp-copy-keep-date-arg nil)
374 (tramp-login-args ("TERM=dumb" "%u")))
375 ("really"
376 (tramp-connection-function tramp-open-connection-su)
377 (tramp-login-program "really")
378 (tramp-login-args ("-u" "%u" "--"
379 "env" "TERM=dumb" "/bin/sh"))
380 (tramp-copy-program nil)
381 (tramp-copy-args nil)
382 (tramp-copy-keep-date-arg nil)
383 (tramp-remote-sh "/bin/sh"))
384 ,@tramp-methods)))
385 (setq tramp-multi-connection-function-alist
386 (mdw-uniquify-alist
387 '(("bc" tramp-multi-connect-su "become TERM=dumb %u%n"))
388 '(("r" tramp-multi-connect-su "really -u %u%n"))
389 tramp-multi-connection-function-alist))
390 (setq tramp-default-method "ssh")
391 (setq tramp-default-method-alist
392 `(("\\`localhost\\'" ""
393 ,(cond ((executable-find "become") "become")
394 ((executable-find "really") "really")
395 (t "su")))))))
396
397 ;;;----- General fontification ----------------------------------------------
398
399 ;; --- Configure lazy fontification ---
400
401 (setq font-lock-support-mode 'lazy-lock-mode)
402 ; (setq lazy-lock-defer-contextually t)
403 (setq lazy-lock-defer-time nil)
404 (setq font-lock-maximum-decoration 3)
405 (setq lazy-lock-minimum-size 0)
406 (setq lazy-lock-stealth-time 5)
407 (setq lazy-lock-stealth-lines 100)
408 (setq lazy-lock-stealth-verbose t)
409
410 (add-hook 'after-make-frame-functions 'mdw-do-set-font)
411 (add-hook 'term-setup-hook (lambda () (mdw-do-set-font (selected-frame))))
412 (add-hook 'window-setup-hook (lambda () (mdw-do-set-font (selected-frame))))
413
414 (add-hook 'c-mode-hook 'mdw-fontify-c-and-c++ t)
415 (add-hook 'objc-mode-hook 'mdw-fontify-c-and-c++ t)
416 (add-hook 'c++-mode-hook 'mdw-fontify-c-and-c++ t)
417 (add-hook 'linux-c-mode-hook #'(lambda () (setq c-basic-offset 8)))
418
419 (add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t)
420 (add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
421
422 (add-hook 'java-mode-hook 'mdw-fontify-java t)
423
424 (add-hook 'awk-mode-hook 'mdw-fontify-awk t)
425
426 (add-hook 'perl-mode-hook 'mdw-fontify-perl t)
427 (add-hook 'cperl-mode-hook 'mdw-fontify-perl t)
428
429 (setq-default py-indent-offset 2)
430 (add-hook 'python-mode-hook 'mdw-fontify-python t)
431
432 (setq-default tcl-indent-level 2)
433 (add-hook 'tcl-mode-hook 'mdw-fontify-tcl t)
434
435 (add-hook 'rexx-mode-hook 'mdw-fontify-rexx t)
436
437 (setq sml-nested-if-indent t)
438 (setq sml-case-indent nil)
439 (setq sml-indent-level 4)
440 (setq sml-type-of-indent nil)
441 (add-hook 'sml-mode-hook 'mdw-fontify-sml t)
442
443 (add-hook 'haskell-mode-hook 'mdw-fontify-haskell t)
444 (setq-default haskell-indent-offset 2)
445
446 (add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t)
447 (add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t)
448
449 (setq LaTeX-table-label "tbl:")
450 (setq-default TeX-master nil)
451 ;; (setq TeX-parse-self t)
452 ;; (setq TeX-auto-save t)
453 (setq TeX-auto-untabify nil)
454 (add-hook 'TeX-mode-hook 'mdw-fontify-tex t)
455 (add-hook 'tex-mode-hook 'mdw-fontify-tex t)
456 (add-hook 'LaTeX-mode-hook 'mdw-fontify-tex t)
457 (add-hook 'latex-mode-hook 'mdw-fontify-tex t)
458
459 (add-hook 'sh-mode-hook #'mdw-setup-sh-script-mode)
460
461 (add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t)
462 (add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t)
463
464 (add-hook 'emacs-lisp-mode-hook 'mdw-fontify-lispy t)
465 (add-hook 'scheme-mode-hook 'mdw-fontify-lispy t)
466 (add-hook 'lisp-mode-hook 'mdw-fontify-lispy t)
467 (add-hook 'inferior-lisp-mode-hook 'mdw-fontify-lispy t)
468 (add-hook 'lisp-interaction-mode-hook 'mdw-fontify-lispy t)
469 (add-hook 'slime-repl-mode-hook 'mdw-fontify-lispy t)
470 (add-hook 'lisp-mode-hook 'mdw-common-lisp-indent t)
471 (trap
472 (require 'slime)
473 (slime-setup :autodoc t))
474 (trap (require 'xscheme))
475 (setq-default xscheme-process-command-line "scheme -large -emacs")
476 (add-hook 'inferior-lisp-mode-hook
477 #'(lambda ()
478 (local-set-key "\C-m" 'comint-send-and-indent)) t)
479
480 (add-hook 'text-mode-hook 'mdw-text-mode t)
481
482 ;;;----- Shell mode ---------------------------------------------------------
483
484 ;; --- Make the shell mode aware of my prompt ---
485
486 (setq shell-prompt-pattern "^[^]#$%>»\n]*[]#$%>»] *")
487 (setq comint-password-prompt-regexp
488 (concat "\\(\\([Oo]ld \\|[Nn]ew \\|[a-zA-Z0-9_]*'s \\|^\\)"
489 "[Pp]assword\\|pass phrase\\):\\s *\\'"))
490
491 ;; --- Notice passwords, and make C-a work right ---
492
493 (add-hook 'shell-mode-hook #'mdw-sh-mode-setup)
494
495 (add-hook 'term-mode-hook #'mdw-term-mode-setup)
496
497 ;;;----- Finishing touches --------------------------------------------------
498
499 (trap (select-window mdw-init-window))
500 (provide 'emacs-init)
501
502 ;;;----- That's all, folks --------------------------------------------------