1 ;;; -*- mode: emacs-lisp; coding: utf-8 -*-
3 ;;; $Id: .emacs,v 1.11 1997/01/01 18:47:09 mdw Exp $
5 ;;; Emacs configuration file
7 ;;; (c) 1996-1999 Mark Wooding
10 ;;;----- Licensing notice ---------------------------------------------------
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.
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.
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
26 (setq load-path (nconc load-path (list "~/lib/emacs")))
29 ;;;----- Some random initialisation -----------------------------------------
31 (setq mdw-init-window (selected-window))
33 ;; --- Load some other bits of code ---
35 (maybe-autoload 'cc-mode "cc-mode" nil t)
36 (maybe-autoload 'rexx-mode "rexx-mode" nil t)
37 (maybe-autoload 'cvs-update "pcl-cvs" nil t)
38 (maybe-autoload 'debian-changelog-mode "debian-changelog-mode" nil t)
39 (maybe-autoload 'git-status "git" nil t)
40 (maybe-autoload 'git-blame-mode "git-blame" nil t)
41 (maybe-autoload 'stgit "stgit" nil t)
42 (and (library-exists-p "vc-git")
43 (not (memq 'GIT vc-handled-backends))
44 (setq vc-handled-backends (cons 'GIT vc-handled-backends)))
45 (and (library-exists-p "quilt")
46 (not mdw-fast-startup)
49 (trap (or mdw-fast-startup (require 'tex-site)))
51 ;; --- Skeleton stuff ---
53 (trap (or mdw-fast-startup (require 'skel-init)))
55 ;; --- Window system-dependent things ---
58 (trap (show-paren-mode t))
59 (or window-system (menu-bar-mode -1))
61 ;; --- Temporary directory handling ---
63 (defun mdw-check-dir-exists (dir)
65 (file-directory-p dir)
67 (setq tmpdir (or (mdw-check-dir-exists (getenv "TMPDIR"))
68 (mdw-check-dir-exists (format "/tmp/%s" (user-login-name)))
71 ;; --- Emacs server behaviour ---
75 (setq server-temp-file-regexp (concat "^" tmpdir "\\|/draft$"))))
77 ;; --- Control backup behaviour ---
79 (setq backup-by-copying nil)
80 (setq backup-by-copying-when-linked t)
81 (setq backup-by-copying-when-mismatch t)
83 ;; --- Calculator fiddling ---
85 (setq calc-settings-file "~/.emacs-calc")
86 (load calc-settings-file)
88 ;; ---- Some mail and news configuration ---
90 (setq mail-from-style 'parens)
91 (setq mail-signature t)
92 (setq mail-yank-prefix "> ")
93 (setq mail-archive-file-name "~/Mail/sent")
95 (setq rmail-display-summary t)
96 (setq rmail-file-name "~/Mail/rmail")
98 ;; --- GNUS configuration ---
100 (setq gnus-select-method '(nntp "tux.nsict.org"))
101 (setq gnus-read-active-file 'some)
102 (setq gnus-inhibit-startup-message t)
103 (setq gnus-large-newsgroup 500)
105 ;; --- Internationalization twiddling ---
108 ;; Have top-bit-set characters work properly in terminals.
109 (let ((im (current-input-mode)))
110 (apply #'set-input-mode
111 (nconc (list (nth 0 im) (nth 1 im) 0) (nthcdr 3 im)))))
113 ;; --- Don't disable any commands ---
115 (mapatoms #'(lambda (sym) (put sym 'disabled nil)))
117 ;; --- Split a wide window ---
121 ;; --- Postscript printing ---
123 (setq ps-paper-type 'a4
126 ps-number-of-columns 3
127 ps-font-family 'Courier
130 ;; --- Splash screen stuff ---
133 (setq inhibit-splash-screen t
134 inhibit-startup-message t))
136 ;; --- Other goodies ---
138 (trap (resize-minibuffer-mode 1)) ;Make minibuffer grow dynamically
139 (auto-compression-mode 1) ;Enable automatic compression
140 (setq dabbrev-case-replace nil) ;Retain case when completing
141 (setq next-line-add-newlines nil) ;Don't add weird newlines
142 (setq split-height-threshold 45) ;Reuse windows where sensible
143 (setq dired-deletion-confirmer ;Make deletion easier in dired
144 (symbol-function 'y-or-n-p))
145 (setq dired-listing-switches "-alF") ;Do `ls -F' things in dired windows
146 (setq wdired-allow-to-change-permissions t)
147 (setq case-fold-file-names nil) ;Don't translate file names (grr...)
148 (setq scroll-step 5) ;Don't scroll too much at a time
149 (setq-default fill-column 77) ;I use rather narrow windows
150 (setq-default comment-column 40) ;Set a standard comment column
151 (setq-default truncate-partial-width-windows nil)
152 (setq woman-use-own-frame nil) ;Keep man pages somewhere sensible
153 (setq diff-switches "-u" ;I like reading unified diffs
154 cvs-diff-flags (list diff-switches))
155 (setq echo-keystrokes 10) ;Long delay before keystrokes echo
156 (setq ange-ftp-ftp-program-name "pftp") ;Use passive FTP
157 (setq find-ls-option ;Build file lists efficiently
158 '("-print0 | xargs -0r ls -ld" . "ld"))
159 (setq bookmark-save-flag 0) ;Save bookmarks automatically
160 (setq Info-fontify-maximum-menu-size 60000)
161 (setq ispell-program-name "aspell"
162 ispell-local-dictionary "en_GB-ize-w_accents"
163 flyspell-default-dictionary "en_GB-ize-w_accents"
164 ispell-silently-savep t)
167 (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
168 (setq uniquify-after-kill-buffer-p t))
169 (transient-mark-mode t)
173 ;;(trap (global-auto-revert-mode t))
174 (setq psgml-html-build-new-buffer nil)
176 (setq cltl2-root-url (mdw-config 'cltl-url))
177 (setq common-lisp-hyperspec-root (mdw-config 'hyperspec-url))
179 ;;;----- W3 and URL fetching stuff ------------------------------------------
181 (let ((proxy (mdw-config 'http-proxy)))
182 (setq url-proxy-services
185 ("gopher" . ,proxy))))
186 (setq url-cookie-untrusted-urls '("."))
188 (setq browse-url-browser-function (mdw-good-url-browser)
189 browse-url-mozilla-program "firefox")
191 (setq w3m-default-display-inline-images t)
193 (setq w3-do-incremental-display t
194 w3-use-menus '(file edit view go bookmark options
195 buffers style search emacs nil help)
196 w3-display-inline-image t
199 ;;;----- Calendar configuration ---------------------------------------------
201 ;; --- Trivial stuff for the sunrise/sunset calculations ---
203 (setq calendar-latitude 52.2)
204 (setq calendar-longitude 0.1)
205 (setq calendar-location-name "Cambridge, UK")
207 ;; --- Date format fiddling ---
209 (setq european-calendar-style t)
211 (setq diary-date-forms '((day "[-/]" month "[^-/0-9]")
212 (day " *" monthname "[ \t]*\\(\^M\\|\n\\)")
213 (backup day " *" monthname "\\W+\\<[^*0-9]")
214 (day "[-/]" month "[-/]" year "[^0-9]")
215 (day " *" monthname " *" year "[^0-9]")
216 (year "[-/]" month "[-/]" day "[^0-9]")
219 ;; --- Fancy diary handling ---
221 (add-hook 'diary-display-hook 'fancy-diary-display)
222 (setq diary-list-include-blanks t)
223 (add-hook 'list-diary-entries-hook 'sort-diary-entries t)
224 (add-hook 'list-diary-entries-hook 'include-other-diary-files)
225 (add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
227 ;; --- Appointment management ---
229 (add-hook 'diary-hook 'appt-make-list)
230 (setq appt-issue-message t)
231 (setq appt-display-interval 3)
232 (setq appt-message-warning-time 10)
234 ;; --- Cosmetic stuff ---
236 (setq display-time-24hr-format t)
240 (let ((view-diary-entries-initially t))
243 (defvar mdw-black-background t)
245 ;; --- Define more mode hooks for MailCrypt ---
248 '((mdwmail-mode (encrypt . mdwmail-mc-encrypt)
249 (sign . mdwmail-mc-sign))))
251 ;; --- Load the MailCrypt support ---
254 (and (string-match "linux" (symbol-name system-type))
255 (not mdw-fast-startup)
256 (progn (require 'mailcrypt-init)
258 (setq mc-default-scheme 'mc-scheme-gpg)
259 (setq mc-pgp-user-id "mdw-nsict-pgp")
260 (setq mc-gpg-user-id "mdw-nsict-gpg")
261 (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
262 (setq mc-pgp-always-sign t)
263 (setq mc-gpg-always-sign t)
264 (setq mc-always-replace 'never)
265 (setq mc-passwd-timeout 3600)
266 (setq mc-temp-directory tmpdir)
267 (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
268 (define-key mc-write-mode-map "\C-c/S" 'mc-sign-region)
269 (define-key mc-write-mode-map "\C-c/E" 'mc-encrypt-region)
270 (add-hook 'text-mode-hook 'mc-install-write-mode))))
272 ;;;----- Other common declarations ------------------------------------------
274 ;; --- Default frame size ---
276 (setq default-frame-alist
280 (vertical-scroll-bars . right))
282 '((cursor-type . bar)
286 (scroll-bar-width . 15)))
287 '((cursor-color . "red"))
288 (if mdw-black-background
289 '((background-color . "black")
290 (foreground-color . "white")
291 (background-mode . dark))
292 '((background-mode . light)))
293 (and (eq window-system 'pm)
294 '((font . "-os2-System VIO-medium-r-normal--*-40-*-*-m-*-cp850")
295 (menu-font . "8.Helv")
296 (background-color . "lightgrey")))
297 '((transparency . t))
298 default-frame-alist))
300 ;; --- Other frame fiddling ---
302 (setq frame-title-format '("" invocation-name "@" system-name ": %b"))
304 ;; --- Global keymap changes ---
307 (windmove-default-keybindings)
308 (setq windmove-wrap-around t))
309 (trap (iswitchb-mode))
310 (global-set-key "\M-#" 'calc-dispatch)
311 (global-set-key [f4] 'query-replace-regexp)
312 (global-set-key [f5] 'goto-line)
313 (global-set-key [f6] 'auto-fill-mode)
314 (global-set-key [f7] 'occur)
315 (global-set-key [f8] 'undo)
316 (global-set-key [f9] 'mdw-divvy-window)
317 (global-set-key [insertchar] 'overwrite-mode)
318 (global-set-key "\C-xm" 'vm-mail)
319 (global-set-key "\C-x\C-n" 'skel-create-file)
320 (global-set-key "\C-x4n" 'skel-create-file-other-window)
321 (global-set-key "\C-x5n" 'skel-create-file-other-frame)
322 (global-set-key [delete] 'delete-char)
323 (global-set-key "\C-[\C-m" 'call-last-kbd-macro)
324 (global-set-key "\M-q" 'mdw-fill-paragraph)
325 (global-set-key "\C-h\C-m" 'manual-entry)
326 (global-set-key [mode-line C-mouse-1] 'mouse-tear-off-window)
327 (global-set-key [vertical-scroll-bar C-down-mouse-1]
328 'mouse-drag-vertical-line)
329 (global-set-key [vertical-scroll-bar C-mouse-1]
330 #'(lambda () (interactive)))
331 (global-set-key [mouse-4] 'mdw-wheel-up)
332 (global-set-key [mouse-5] 'mdw-wheel-down)
334 ;; --- Recognising types of files ---
336 (setq auto-mode-alist
337 (append `(("\\.p[lm]$" . perl-mode)
338 ("\\.m$" . objc-mode)
340 ("\\.cs" . csharp-mode)
341 ;; ("/[ch]/" . c-mode)
343 "\\.stgit\\.msg" "\\|"
344 "\\.git/COMMIT_EDITMSG" "\\|"
345 "svn-commit\\.tmp" "\\|"
346 "svk-commit[^/.]*\\.tmp"
349 (,(concat "^" tmpdir "/\\("
350 "svk-commit[^/.]*\\.tmp" "\\|"
351 "gitci\\.[^/.]*" "\\|"
352 "cvs[^/.]\\{6\\}" "\\|"
353 "quilt_header\.[^/.]\\{6\\}"
356 ("\\.calc?$" . apcalc-mode)
357 ("/src/linux/.*\\.\\(c\\|h\\|cc\\)$" . linux-c-mode)
358 ("/\\(s\\|sh\\)/" . arm-assembler-mode)
359 ("\\.\\(cmd\\|exec\\|rexx\\)$" . rexx-mode)
360 ("\\.st$" . smalltalk-mode)
361 ("\\.msgs$" . messages-mode)
362 ("/all-cmds\\.in$" . cpp-messages-mode)
363 ("\\.\\(tex\\|dtx\\)$" . latex-mode)
364 ("\\.gc$" . haskell.-mode)
365 (,(concat "^" (getenv "HOME") "/News/") . mdwmail-mode)
366 (,(concat "^" tmpdir "/\\(SLRN\\|snd\\|pico\\)")
370 (setq interpreter-mode-alist
371 (append `(("runlisp" . lisp-mode))
372 interpreter-mode-alist))
374 (setq completion-ignored-extensions
375 (append `(".hc" ".hi") completion-ignored-extensions))
377 ;; --- Some common local definitions ---
379 (make-variable-buffer-local 'mdw-auto-indent)
381 (mapcar (lambda (hook) (add-hook hook 'mdw-misc-mode-config))
382 '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
383 perl-mode-hook cperl-mode-hook python-mode-hook awk-mode-hook
384 tcl-mode-hook asm-mode-hook
385 TeX-mode-hook LaTeX-mode-hook TeXinfo-mode-hook
386 tex-mode-hook latex-mode-hook texinfo-mode-hook
387 emacs-lisp-mode-hook scheme-mode-hook
388 lisp-mode-hook lisp-interaction-mode-hook inferior-lisp-mode-hook
390 sml-mode-hook haskell-mode-hook
391 smalltalk-mode-hook rexx-mode-hook
392 arm-assembler-mode-hook))
394 (global-font-lock-mode t)
395 (defalias 'perl-mode 'cperl-mode)
397 ;;;----- Rootly editingness -------------------------------------------------
399 (eval-after-load "tramp"
404 (tramp-connection-function tramp-open-connection-su)
405 (tramp-remote-sh "/bin/sh")
406 (tramp-login-program "become")
407 (tramp-copy-program nil)
408 (tramp-copy-args nil)
409 (tramp-copy-keep-date-arg nil)
410 (tramp-login-args ("TERM=dumb" "%u")))
412 (tramp-connection-function tramp-open-connection-su)
413 (tramp-login-program "really")
414 (tramp-login-args ("-u" "%u" "--"
415 "env" "TERM=dumb" "/bin/sh"))
416 (tramp-copy-program nil)
417 (tramp-copy-args nil)
418 (tramp-copy-keep-date-arg nil)
419 (tramp-remote-sh "/bin/sh"))
421 (setq tramp-multi-connection-function-alist
423 '(("bc" tramp-multi-connect-su "become TERM=dumb %u%n"))
424 '(("r" tramp-multi-connect-su "really -u %u%n"))
425 tramp-multi-connection-function-alist))
426 (setq tramp-default-method "ssh")
427 (setq tramp-default-method-alist
428 `(("\\`localhost\\'" ""
429 ,(cond ((executable-find "become") "become")
430 ((executable-find "really") "really")
433 ;;;----- General fontification ----------------------------------------------
435 ;; --- Configure lazy fontification ---
437 (and (fboundp 'lazy-lock-mode)
438 (setq font-lock-support-mode 'lazy-lock-mode))
439 ; (setq lazy-lock-defer-contextually t)
440 (setq lazy-lock-defer-time nil)
441 (setq font-lock-maximum-decoration 3)
442 (setq lazy-lock-minimum-size 0)
443 (setq lazy-lock-stealth-time 5)
444 (setq lazy-lock-stealth-lines 100)
445 (setq lazy-lock-stealth-verbose t)
447 (add-hook 'after-make-frame-functions 'mdw-do-set-font)
448 (add-hook 'term-setup-hook (lambda () (mdw-do-set-font (selected-frame))))
449 (add-hook 'window-setup-hook (lambda () (mdw-do-set-font (selected-frame))))
451 (add-hook 'c-mode-hook 'mdw-fontify-c-and-c++ t)
452 (add-hook 'objc-mode-hook 'mdw-fontify-c-and-c++ t)
453 (add-hook 'c++-mode-hook 'mdw-fontify-c-and-c++ t)
454 (add-hook 'linux-c-mode-hook #'(lambda () (setq c-basic-offset 8)))
455 (add-hook 'asm-mode-hook 'mdw-fontify-asm t)
457 (add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t)
458 (add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
460 (add-hook 'java-mode-hook 'mdw-fontify-java t)
462 (add-hook 'awk-mode-hook 'mdw-fontify-awk t)
464 (add-hook 'perl-mode-hook 'mdw-fontify-perl t)
465 (add-hook 'cperl-mode-hook 'mdw-fontify-perl t)
467 (setq-default py-indent-offset 2)
468 (add-hook 'python-mode-hook 'mdw-fontify-python t)
470 (setq-default tcl-indent-level 2)
471 (add-hook 'tcl-mode-hook 'mdw-fontify-tcl t)
473 (add-hook 'rexx-mode-hook 'mdw-fontify-rexx t)
475 (setq sml-nested-if-indent t)
476 (setq sml-case-indent nil)
477 (setq sml-indent-level 4)
478 (setq sml-type-of-indent nil)
479 (add-hook 'sml-mode-hook 'mdw-fontify-sml t)
481 (add-hook 'haskell-mode-hook 'mdw-fontify-haskell t)
482 (setq-default haskell-indent-offset 2)
484 (add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t)
485 (add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t)
487 (setq LaTeX-table-label "tbl:")
488 (setq-default TeX-master nil)
489 ;; (setq TeX-parse-self t)
490 ;; (setq TeX-auto-save t)
491 (setq TeX-auto-untabify nil)
492 (add-hook 'TeX-mode-hook 'mdw-fontify-tex t)
493 (add-hook 'tex-mode-hook 'mdw-fontify-tex t)
494 (add-hook 'LaTeX-mode-hook 'mdw-fontify-tex t)
495 (add-hook 'latex-mode-hook 'mdw-fontify-tex t)
497 (add-hook 'sh-mode-hook #'mdw-setup-sh-script-mode)
498 (add-hook 'autoconf-mode-hook #'mdw-setup-m4)
499 (add-hook 'm4-mode-hook #'mdw-setup-m4)
501 (add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t)
502 (add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t)
504 (add-hook 'emacs-lisp-mode-hook 'mdw-fontify-lispy t)
505 (add-hook 'scheme-mode-hook 'mdw-fontify-lispy t)
506 (add-hook 'lisp-mode-hook 'mdw-fontify-lispy t)
507 (add-hook 'inferior-lisp-mode-hook 'mdw-fontify-lispy t)
508 (add-hook 'lisp-interaction-mode-hook 'mdw-fontify-lispy t)
509 (add-hook 'slime-repl-mode-hook 'mdw-fontify-lispy t)
510 (add-hook 'lisp-mode-hook 'mdw-common-lisp-indent t)
512 (if (not mdw-fast-startup)
514 (require 'slime-autoloads)
515 (slime-setup '(slime-autodoc)))))
516 (add-hook 'inferior-lisp-mode-hook
518 (local-set-key "\C-m" 'comint-send-and-indent)) t)
520 (add-hook 'text-mode-hook 'mdw-text-mode t)
522 ;;;----- TeX stuff ----------------------------------------------------------
524 (setq TeX-output-view-style
526 ("^landscape$" "^pstricks$\\|^pst-\\|^psfrag$")
527 "%(o?)dvips -t landscape %d -o && evince %f")
528 ("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$"
529 "%(o?)dvips %d -o && evince %f")
531 ("^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "^landscape$")
532 "%(o?)xdvi %dS -paper a4r -s 0 %d")
533 ("^dvi$" "^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$"
534 "%(o?)xdvi %dS -paper a4 %d")
536 ("^a5\\(?:comb\\|paper\\)$" "^landscape$")
537 "%(o?)xdvi %dS -paper a5r -s 0 %d")
538 ("^dvi$" "^a5\\(?:comb\\|paper\\)$" "%(o?)xdvi %dS -paper a5 %d")
539 ("^dvi$" "^b5paper$" "%(o?)xdvi %dS -paper b5 %d")
540 ("^dvi$" "^letterpaper$" "%(o?)xdvi %dS -paper us %d")
541 ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d")
542 ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d")
543 ("^dvi$" "." "%(o?)xdvi %dS %d")
544 ("^pdf$" "." "evince %o")
545 ("^html?$" "." "netscape %o")))
547 ;;;----- SLIME setup --------------------------------------------------------
549 (let ((stuff '((cmucl ("cmucl"))
550 (sbcl ("sbcl") :coding-system utf-8-unix)
551 (clisp ("clisp") :coding-system utf-8-unix))))
552 (or (boundp 'slime-lisp-implementations)
553 (setq slime-lisp-implementations nil))
555 (let* ((head (car stuff))
556 (found (assq (car head) slime-lisp-implementations)))
557 (setq stuff (cdr stuff))
559 (rplacd found (cdr head))
560 (setq slime-lisp-implementations
561 (cons head slime-lisp-implementations))))))
562 (setq slime-default-lisp 'sbcl)
564 ;;;----- Shell mode ---------------------------------------------------------
566 ;; --- Make the shell mode aware of my prompt ---
568 (setq shell-prompt-pattern "^[^]#$%>»}\n]*[]#$%>»}] *")
569 (setq comint-password-prompt-regexp
570 (concat "\\(\\([Oo]ld \\|[Nn]ew \\|[a-zA-Z0-9_]*'s \\|^\\)"
571 "[Pp]assword\\|pass phrase\\):\\s *\\'"))
573 ;; --- Notice passwords, and make C-a work right ---
575 (add-hook 'shell-mode-hook #'mdw-sh-mode-setup)
577 (add-hook 'term-mode-hook #'mdw-term-mode-setup)
579 ;;;----- Finishing touches --------------------------------------------------
581 (trap (select-window mdw-init-window))
582 (provide 'emacs-init)
584 ;;;----- That's all, folks --------------------------------------------------