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