7149f6f5928cbf88c6dbc5fdfb7b6aa2e780ad36
[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
157 "http://metalzone.distorted.org.uk/doc/cltl/")
158 (setq common-lisp-hyperspec-root
159 "http://metalzone.distorted.org.uk/doc/hyperspec/")
160
161 ;;;----- Calendar configuration ---------------------------------------------
162
163 ;; --- Trivial stuff for the sunrise/sunset calculations ---
164
165 (setq calendar-latitude 52.2)
166 (setq calendar-longitude 0.1)
167 (setq calendar-location-name "Cambridge, UK")
168
169 ;; --- Date format fiddling ---
170
171 (setq european-calendar-style t)
172
173 (setq diary-date-forms '((day "[-/]" month "[^-/0-9]")
174 (day " *" monthname "[ \t]*\\(\^M\\|\n\\)")
175 (backup day " *" monthname "\\W+\\<[^*0-9]")
176 (day "[-/]" month "[-/]" year "[^0-9]")
177 (day " *" monthname " *" year "[^0-9]")
178 (year "[-/]" month "[-/]" day "[^0-9]")
179 (dayname "\\W")))
180
181 ;; --- Fancy diary handling ---
182
183 (add-hook 'diary-display-hook 'fancy-diary-display)
184 (setq diary-list-include-blanks t)
185 (add-hook 'list-diary-entries-hook 'sort-diary-entries t)
186 (add-hook 'list-diary-entries-hook 'include-other-diary-files)
187 (add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
188
189 ;; --- Appointment management ---
190
191 (add-hook 'diary-hook 'appt-make-list)
192 (setq appt-issue-message t)
193 (setq appt-display-interval 3)
194 (setq appt-message-warning-time 10)
195
196 ;; --- Cosmetic stuff ---
197
198 (setq display-time-24hr-format t)
199 (display-time)
200 (trap
201 (if window-system
202 (let ((view-diary-entries-initially t))
203 (calendar))))
204
205 (defvar mdw-black-background t)
206
207 ;; --- Define more mode hooks for MailCrypt ---
208
209 (setq mdw-mc-modes
210 '((mdwmail-mode (encrypt . mdwmail-mc-encrypt)
211 (sign . mdwmail-mc-sign))))
212
213 ;; --- Load the MailCrypt support ---
214
215 (trap
216 (and (string-match "linux" (symbol-name system-type))
217 (progn (require 'mailcrypt-init)
218 (require 'mailcrypt)
219 (setq mc-default-scheme 'mc-scheme-gpg)
220 (setq mc-pgp-user-id "mdw-nsict-pgp")
221 (setq mc-gpg-user-id "mdw-nsict-gpg")
222 (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
223 (setq mc-pgp-always-sign t)
224 (setq mc-gpg-always-sign t)
225 (setq mc-always-replace 'never)
226 (setq mc-passwd-timeout 3600)
227 (setq mc-temp-directory tmpdir)
228 (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
229 (define-key mc-write-mode-map "\C-c/S" 'mc-sign-region)
230 (define-key mc-write-mode-map "\C-c/E" 'mc-encrypt-region)
231 (add-hook 'text-mode-hook 'mc-install-write-mode))))
232
233 ;;;----- Other common declarations ------------------------------------------
234
235 ;; --- Default frame size ---
236
237 (setq default-frame-alist
238 (mdw-uniquify-alist
239 '((width . 78)
240 (height . 33)
241 (vertical-scroll-bars . right))
242 (and window-system
243 '((cursor-type . bar)
244 (cursor-blink . t)))
245 '((cursor-color . "red"))
246 (if mdw-black-background
247 '((background-color . "black")
248 (foreground-color . "white")
249 (background-mode . dark))
250 '((background-mode . light)))
251 (and (eq window-system 'pm)
252 '((font . "-os2-System VIO-medium-r-normal--*-40-*-*-m-*-cp850")
253 (menu-font . "8.Helv")
254 (background-color . "lightgrey")))
255 '((transparency . t))
256 default-frame-alist))
257
258 ;; --- Other frame fiddling ---
259
260 (setq frame-title-format '("" invocation-name "@" system-name ": %b"))
261
262 ;; --- Global keymap changes ---
263
264 (trap
265 (windmove-default-keybindings)
266 (setq windmove-wrap-around t))
267 (trap (iswitchb-mode))
268 (global-set-key [f4] 'query-replace-regexp)
269 (global-set-key [f5] 'goto-line)
270 (global-set-key [f6] 'auto-fill-mode)
271 (global-set-key [f7] 'occur)
272 (global-set-key [f8] 'undo)
273 (global-set-key [f9] 'mdw-divvy-window)
274 (global-set-key [insertchar] 'overwrite-mode)
275 (global-set-key "\C-xm" 'vm-mail)
276 (global-set-key "\C-x\C-n" 'skel-create-file)
277 (global-set-key "\C-x4n" 'skel-create-file-other-window)
278 (global-set-key "\C-x5n" 'skel-create-file-other-frame)
279 (global-set-key [delete] 'delete-char)
280 (global-set-key "\C-[\C-m" 'call-last-kbd-macro)
281 (global-set-key "\M-q" 'mdw-fill-paragraph)
282 (global-set-key "\C-h\C-m" 'manual-entry)
283 (global-set-key [mode-line C-mouse-1] 'mouse-tear-off-window)
284 (global-set-key [vertical-scroll-bar C-down-mouse-1]
285 'mouse-drag-vertical-line)
286 (global-set-key [vertical-scroll-bar C-mouse-1]
287 #'(lambda () (interactive)))
288 (global-set-key [mouse-4] 'mdw-wheel-up)
289 (global-set-key [mouse-5] 'mdw-wheel-down)
290
291 ;; --- Recognising types of files ---
292
293 (setq auto-mode-alist
294 (append `(("\\.p[lm]$" . perl-mode)
295 ("\\.m$" . objc-mode)
296 ("\\.mxd$" . c-mode)
297 ;; ("/[ch]/" . c-mode)
298 (,(concat "/\\("
299 "\\.stgit\\.msg" "\\|"
300 "\\.git/COMMIT_EDITMSG" "\\|"
301 "svn-commit\\.tmp" "\\|"
302 "svk-commit[^/.]*\\.tmp"
303 "\\)$")
304 . text-mode)
305 (,(concat "^" tmpdir "/\\("
306 "svk-commit[^/.]*\\.tmp" "\\|"
307 "gitci\\.[^/.]*" "\\|"
308 "cvs[^/.]\\{6\\}" "\\|"
309 "\\)$")
310 . text-mode)
311 ("\\.calc?$" . apcalc-mode)
312 ("/src/linux/.*\\.\\(c\\|h\\|cc\\)$" . linux-c-mode)
313 ("/\\(s\\|sh\\)/" . arm-assembler-mode)
314 ("\\.\\(cmd\\|exec\\|rexx\\)$" . rexx-mode)
315 ("\\.st$" . smalltalk-mode)
316 ("\\.msgs$" . messages-mode)
317 ("/all-cmds\\.in$" . cpp-messages-mode)
318 ("\\.\\(tex\\|dtx\\)$" . latex-mode)
319 ("\\.gc$" . haskell.-mode)
320 (,(concat "^" (getenv "HOME") "/News/") . mdwmail-mode)
321 (,(concat "^" tmpdir "/\\(SLRN\\|snd\\|pico\\)")
322 . mdwmail-mode))
323 auto-mode-alist))
324
325 (setq completion-ignored-extensions
326 (append `(".hc" ".hi") completion-ignored-extensions))
327
328 ;; --- Some common local definitions ---
329
330 (make-variable-buffer-local 'mdw-auto-indent)
331
332 (mapcar (lambda (hook) (add-hook hook 'mdw-misc-mode-config))
333 '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
334 perl-mode-hook cperl-mode-hook python-mode-hook awk-mode-hook
335 tcl-mode-hook
336 TeX-mode-hook LaTeX-mode-hook TeXinfo-mode-hook
337 tex-mode-hook latex-mode-hook texinfo-mode-hook
338 emacs-lisp-mode-hook scheme-mode-hook
339 lisp-mode-hook lisp-interaction-mode-hook inferior-lisp-mode-hook
340 slime-repl-mode-hook
341 sml-mode-hook haskell-mode-hook
342 smalltalk-mode-hook rexx-mode-hook
343 arm-assembler-mode-hook))
344
345 (global-font-lock-mode t)
346 (defalias 'perl-mode 'cperl-mode)
347
348 ;;;----- Rootly editingness -------------------------------------------------
349
350 (eval-after-load "tramp"
351 '(progn
352 (setq tramp-methods
353 (mdw-uniquify-alist
354 `(("become"
355 (tramp-connection-function tramp-open-connection-su)
356 (tramp-remote-sh "/bin/sh")
357 (tramp-login-program "become")
358 (tramp-copy-program nil)
359 (tramp-copy-args nil)
360 (tramp-copy-keep-date-arg nil)
361 (tramp-login-args ("TERM=dumb" "%u")))
362 ("really"
363 (tramp-connection-function tramp-open-connection-su)
364 (tramp-login-program "really")
365 (tramp-login-args ("-u" "%u" "--"
366 "env" "TERM=dumb" "/bin/sh"))
367 (tramp-copy-program nil)
368 (tramp-copy-args nil)
369 (tramp-copy-keep-date-arg nil)
370 (tramp-remote-sh "/bin/sh"))
371 ,@tramp-methods)))
372 (setq tramp-multi-connection-function-alist
373 (mdw-uniquify-alist
374 '(("bc" tramp-multi-connect-su "become TERM=dumb %u%n"))
375 '(("r" tramp-multi-connect-su "really -u %u%n"))
376 tramp-multi-connection-function-alist))
377 (setq tramp-default-method "ssh")
378 (setq tramp-default-method-alist
379 `(("\\`localhost\\'" ""
380 ,(cond ((executable-find "become") "become")
381 ((executable-find "really") "really")
382 (t "su")))))))
383
384 ;;;----- General fontification ----------------------------------------------
385
386 ;; --- Configure lazy fontification ---
387
388 (setq font-lock-support-mode 'lazy-lock-mode)
389 ; (setq lazy-lock-defer-contextually t)
390 (setq lazy-lock-defer-time nil)
391 (setq font-lock-maximum-decoration 3)
392 (setq lazy-lock-minimum-size 0)
393 (setq lazy-lock-stealth-time 5)
394 (setq lazy-lock-stealth-lines 100)
395 (setq lazy-lock-stealth-verbose t)
396
397 (add-hook 'after-make-frame-functions 'mdw-do-set-font)
398 (add-hook 'term-setup-hook (lambda () (mdw-do-set-font (selected-frame))))
399 (add-hook 'window-setup-hook (lambda () (mdw-do-set-font (selected-frame))))
400
401 (add-hook 'c-mode-hook 'mdw-fontify-c-and-c++ t)
402 (add-hook 'objc-mode-hook 'mdw-fontify-c-and-c++ t)
403 (add-hook 'c++-mode-hook 'mdw-fontify-c-and-c++ t)
404 (add-hook 'linux-c-mode-hook #'(lambda () (setq c-basic-offset 8)))
405
406 (add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t)
407 (add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
408
409 (add-hook 'java-mode-hook 'mdw-fontify-java t)
410
411 (add-hook 'awk-mode-hook 'mdw-fontify-awk t)
412
413 (add-hook 'perl-mode-hook 'mdw-fontify-perl t)
414 (add-hook 'cperl-mode-hook 'mdw-fontify-perl t)
415
416 (setq-default py-indent-offset 2)
417 (add-hook 'python-mode-hook 'mdw-fontify-python t)
418
419 (setq-default tcl-indent-level 2)
420 (add-hook 'tcl-mode-hook 'mdw-fontify-tcl t)
421
422 (add-hook 'rexx-mode-hook 'mdw-fontify-rexx t)
423
424 (setq sml-nested-if-indent t)
425 (setq sml-case-indent nil)
426 (setq sml-indent-level 4)
427 (setq sml-type-of-indent nil)
428 (add-hook 'sml-mode-hook 'mdw-fontify-sml t)
429
430 (add-hook 'haskell-mode-hook 'mdw-fontify-haskell t)
431 (setq-default haskell-indent-offset 2)
432
433 (add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t)
434 (add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t)
435
436 (setq LaTeX-table-label "tbl:")
437 (setq-default TeX-master nil)
438 ;; (setq TeX-parse-self t)
439 ;; (setq TeX-auto-save t)
440 (setq TeX-auto-untabify nil)
441 (add-hook 'TeX-mode-hook 'mdw-fontify-tex t)
442 (add-hook 'tex-mode-hook 'mdw-fontify-tex t)
443 (add-hook 'LaTeX-mode-hook 'mdw-fontify-tex t)
444 (add-hook 'latex-mode-hook 'mdw-fontify-tex t)
445
446 (add-hook 'sh-mode-hook #'mdw-setup-sh-script-mode)
447
448 (add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t)
449 (add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t)
450
451 (add-hook 'emacs-lisp-mode-hook 'mdw-fontify-lispy t)
452 (add-hook 'scheme-mode-hook 'mdw-fontify-lispy t)
453 (add-hook 'lisp-mode-hook 'mdw-fontify-lispy t)
454 (add-hook 'inferior-lisp-mode-hook 'mdw-fontify-lispy t)
455 (add-hook 'lisp-interaction-mode-hook 'mdw-fontify-lispy t)
456 (add-hook 'slime-repl-mode-hook 'mdw-fontify-lispy t)
457 (add-hook 'lisp-mode-hook 'mdw-common-lisp-indent t)
458 (trap
459 (require 'slime)
460 (slime-setup :autodoc t))
461 (trap (require 'xscheme))
462 (setq-default xscheme-process-command-line "scheme -large -emacs")
463 (add-hook 'inferior-lisp-mode-hook
464 #'(lambda ()
465 (local-set-key "\C-m" 'comint-send-and-indent)) t)
466
467 (add-hook 'text-mode-hook 'mdw-text-mode t)
468
469 ;;;----- Shell mode ---------------------------------------------------------
470
471 ;; --- Make the shell mode aware of my prompt ---
472
473 (setq shell-prompt-pattern "^[^]#$%>»\n]*[]#$%>»] *")
474 (setq comint-password-prompt-regexp
475 (concat "\\(\\([Oo]ld \\|[Nn]ew \\|[a-zA-Z0-9_]*'s \\|^\\)"
476 "[Pp]assword\\|pass phrase\\):\\s *\\'"))
477
478 ;; --- Notice passwords, and make C-a work right ---
479
480 (add-hook 'shell-mode-hook #'mdw-sh-mode-setup)
481
482 (add-hook 'term-mode-hook #'mdw-term-mode-setup)
483
484 ;;;----- Finishing touches --------------------------------------------------
485
486 (trap (select-window mdw-init-window))
487 (provide 'emacs-init)
488
489 ;;;----- Emacs customization crud -------------------------------------------
490
491 (custom-set-variables
492 ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
493 ;; Your init file should contain only one such instance.
494 '(url-cookie-untrusted-urls (quote (".")))
495 '(url-proxy-services (quote (("http" . "metalzone.distorted.org.uk:3128") ("ftp" . "metalzone.distorted.org.uk:3128") ("gopher" . "metalzone.distorted.org.uk:3128"))))
496 '(w3-do-incremental-display t)
497 '(w3-honor-stylesheets nil)
498 '(w3-use-menus (quote (file edit view go bookmark options buffers style search emacs nil help)))
499 '(w3m-display-inline-image t)
500 '(w3m-key-binding (quote info)))
501 (custom-set-faces
502 ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
503 ;; Your init file should contain only one such instance.
504 )
505
506 ;;;----- That's all, folks --------------------------------------------------