Initial import of my profile.
[profile] / emacs
CommitLineData
f617db13
MW
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 ("\\.\\(tex\\|dtx\\)$" . latex-mode)
317 ("\\.gc$" . haskell.-mode)
318 (,(concat "^" (getenv "HOME") "/News/") . mdwmail-mode)
319 (,(concat "^" tmpdir "/\\(SLRN\\|snd\\|pico\\)")
320 . mdwmail-mode))
321 auto-mode-alist))
322
323(setq completion-ignored-extensions
324 (append `(".hc" ".hi") completion-ignored-extensions))
325
326;; --- Some common local definitions ---
327
328(make-variable-buffer-local 'mdw-auto-indent)
329
330(mapcar (lambda (hook) (add-hook hook 'mdw-misc-mode-config))
331 '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
332 perl-mode-hook cperl-mode-hook python-mode-hook awk-mode-hook
333 tcl-mode-hook
334 TeX-mode-hook LaTeX-mode-hook TeXinfo-mode-hook
335 tex-mode-hook latex-mode-hook texinfo-mode-hook
336 emacs-lisp-mode-hook scheme-mode-hook
337 lisp-mode-hook lisp-interaction-mode-hook inferior-lisp-mode-hook
338 slime-repl-mode-hook
339 sml-mode-hook haskell-mode-hook
340 smalltalk-mode-hook rexx-mode-hook
341 arm-assembler-mode-hook))
342
343(global-font-lock-mode t)
344(defalias 'perl-mode 'cperl-mode)
345
346;;;----- Rootly editingness -------------------------------------------------
347
348(eval-after-load "tramp"
349 '(progn
350 (setq tramp-methods
351 (mdw-uniquify-alist
352 `(("become"
353 (tramp-connection-function tramp-open-connection-su)
354 (tramp-remote-sh "/bin/sh")
355 (tramp-login-program "become")
356 (tramp-copy-program nil)
357 (tramp-copy-args nil)
358 (tramp-copy-keep-date-arg nil)
359 (tramp-login-args ("TERM=dumb" "%u")))
360 ("really"
361 (tramp-connection-function tramp-open-connection-su)
362 (tramp-login-program "really")
363 (tramp-login-args ("-u" "%u" "--"
364 "env" "TERM=dumb" "/bin/sh"))
365 (tramp-copy-program nil)
366 (tramp-copy-args nil)
367 (tramp-copy-keep-date-arg nil)
368 (tramp-remote-sh "/bin/sh"))
369 ,@tramp-methods)))
370 (setq tramp-multi-connection-function-alist
371 (mdw-uniquify-alist
372 '(("bc" tramp-multi-connect-su "become TERM=dumb %u%n"))
373 '(("r" tramp-multi-connect-su "really -u %u%n"))
374 tramp-multi-connection-function-alist))
375 (setq tramp-default-method "ssh")
376 (setq tramp-default-method-alist
377 `(("\\`localhost\\'" ""
378 ,(cond ((executable-find "become") "become")
379 ((executable-find "really") "really")
380 (t "su")))))))
381
382;;;----- General fontification ----------------------------------------------
383
384;; --- Configure lazy fontification ---
385
386(setq font-lock-support-mode 'lazy-lock-mode)
387; (setq lazy-lock-defer-contextually t)
388(setq lazy-lock-defer-time nil)
389(setq font-lock-maximum-decoration 3)
390(setq lazy-lock-minimum-size 0)
391(setq lazy-lock-stealth-time 5)
392(setq lazy-lock-stealth-lines 100)
393(setq lazy-lock-stealth-verbose t)
394
395(add-hook 'after-make-frame-functions 'mdw-do-set-font)
396(add-hook 'term-setup-hook (lambda () (mdw-do-set-font (selected-frame))))
397(add-hook 'window-setup-hook (lambda () (mdw-do-set-font (selected-frame))))
398
399(add-hook 'c-mode-hook 'mdw-fontify-c-and-c++ t)
400(add-hook 'objc-mode-hook 'mdw-fontify-c-and-c++ t)
401(add-hook 'c++-mode-hook 'mdw-fontify-c-and-c++ t)
402(add-hook 'linux-c-mode-hook #'(lambda () (setq c-basic-offset 8)))
403
404(add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t)
405(add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
406
407(add-hook 'java-mode-hook 'mdw-fontify-java t)
408
409(add-hook 'awk-mode-hook 'mdw-fontify-awk t)
410
411(add-hook 'perl-mode-hook 'mdw-fontify-perl t)
412(add-hook 'cperl-mode-hook 'mdw-fontify-perl t)
413
414(setq-default py-indent-offset 2)
415(add-hook 'python-mode-hook 'mdw-fontify-python t)
416
417(setq-default tcl-indent-level 2)
418(add-hook 'tcl-mode-hook 'mdw-fontify-tcl t)
419
420(add-hook 'rexx-mode-hook 'mdw-fontify-rexx t)
421
422(setq sml-nested-if-indent t)
423(setq sml-case-indent nil)
424(setq sml-indent-level 4)
425(setq sml-type-of-indent nil)
426(add-hook 'sml-mode-hook 'mdw-fontify-sml t)
427
428(add-hook 'haskell-mode-hook 'mdw-fontify-haskell t)
429(setq-default haskell-indent-offset 2)
430
431(add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t)
432(add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t)
433
434(setq LaTeX-table-label "tbl:")
435(setq-default TeX-master nil)
436;; (setq TeX-parse-self t)
437;; (setq TeX-auto-save t)
438(setq TeX-auto-untabify nil)
439(add-hook 'TeX-mode-hook 'mdw-fontify-tex t)
440(add-hook 'tex-mode-hook 'mdw-fontify-tex t)
441(add-hook 'LaTeX-mode-hook 'mdw-fontify-tex t)
442(add-hook 'latex-mode-hook 'mdw-fontify-tex t)
443
444(add-hook 'sh-mode-hook #'mdw-setup-sh-script-mode)
445
446(add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t)
447(add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t)
448
449(add-hook 'emacs-lisp-mode-hook 'mdw-fontify-lispy t)
450(add-hook 'scheme-mode-hook 'mdw-fontify-lispy t)
451(add-hook 'lisp-mode-hook 'mdw-fontify-lispy t)
452(add-hook 'inferior-lisp-mode-hook 'mdw-fontify-lispy t)
453(add-hook 'lisp-interaction-mode-hook 'mdw-fontify-lispy t)
454(add-hook 'slime-repl-mode-hook 'mdw-fontify-lispy t)
455(add-hook 'lisp-mode-hook 'mdw-common-lisp-indent t)
456(require 'slime)
457(slime-setup :autodoc t)
458(trap (require 'xscheme))
459(setq-default xscheme-process-command-line "scheme -large -emacs")
460(add-hook 'inferior-lisp-mode-hook
461 #'(lambda ()
462 (local-set-key "\C-m" 'comint-send-and-indent)) t)
463
464(add-hook 'text-mode-hook 'mdw-text-mode t)
465
466;;;----- Shell mode ---------------------------------------------------------
467
468;; --- Make the shell mode aware of my prompt ---
469
470