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 (setq load-path (cons "~/lib/emacs" load-path))
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")
49 (or (fboundp 'make-regexp)
50 (load "make-regexp")))
52 (trap (require 'tex-site))
54 ;; --- Skeleton stuff ---
56 (trap (require 'skel-init))
58 ;; --- Window system-dependent things ---
61 (trap (show-paren-mode t))
62 (or window-system (menu-bar-mode -1))
64 ;; --- Temporary directory handling ---
66 (defun mdw-check-dir-exists (dir)
68 (file-directory-p dir)
70 (setq tmpdir (or (mdw-check-dir-exists (getenv "TMPDIR"))
71 (mdw-check-dir-exists (format "/tmp/%s" (user-login-name)))
74 ;; --- Emacs server behaviour ---
78 (setq server-temp-file-regexp (concat "^" tmpdir "\\|/draft$"))))
80 ;; --- Control backup behaviour ---
82 (setq backup-by-copying nil)
83 (setq backup-by-copying-when-linked t)
84 (setq backup-by-copying-when-mismatch t)
86 ;; --- Calculator fiddling ---
88 (setq calc-settings-file "~/.emacs-calc")
89 (load calc-settings-file)
91 ;; ---- Some mail and news configuration ---
93 (setq mail-from-style 'parens)
94 (setq mail-signature t)
95 (setq mail-yank-prefix "> ")
96 (setq mail-archive-file-name "~/Mail/sent")
98 (setq rmail-display-summary t)
99 (setq rmail-file-name "~/Mail/rmail")
101 ;; --- GNUS configuration ---
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)
108 ;; --- Internationalization twiddling ---
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"))
117 ;; --- Don't disable any commands ---
119 (mapatoms #'(lambda (sym) (put sym 'disabled nil)))
121 ;; --- Split a wide window ---
125 ;; --- Other goodies ---
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")
151 (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
152 (setq uniquify-after-kill-buffer-p t))
153 (transient-mark-mode t)
157 (trap (global-auto-revert-mode t))
158 (setq psgml-html-build-new-buffer nil)
160 (setq cltl2-root-url (mdw-config 'cltl-url))
161 (setq common-lisp-hyperspec-root (mdw-config 'hyperspec-url))
163 ;;;----- W3 and URL fetching stuff ------------------------------------------
165 (let ((proxy (mdw-config 'proxy)))
166 (setq url-proxy-services
169 ("gopher" . ,proxy))))
170 (setq url-cookie-untrusted-urls '("."))
172 (let ((browsers '(w3m browse-url-w3 browse-url-mozilla)) browser)
174 (setq browser (car browsers)
175 browsers (cdr browsers))
176 (if (fboundp browser)
177 (setq browse-url-browser-function browser
180 (setq browse-url-mozilla-program "firefox")
182 (setq w3m-default-display-inline-images t)
184 (setq w3-do-incremental-display t
185 w3-use-menus '(file edit view go bookmark options
186 buffers style search emacs nil help)
187 w3-display-inline-image t
190 ;;;----- Calendar configuration ---------------------------------------------
192 ;; --- Trivial stuff for the sunrise/sunset calculations ---
194 (setq calendar-latitude 52.2)
195 (setq calendar-longitude 0.1)
196 (setq calendar-location-name "Cambridge, UK")
198 ;; --- Date format fiddling ---
200 (setq european-calendar-style t)
202 (setq diary-date-forms '((day "[-/]" month "[^-/0-9]")
203 (day " *" monthname "[ \t]*\\(\^M\\|\n\\)")
204 (backup day " *" monthname "\\W+\\<[^*0-9]")
205 (day "[-/]" month "[-/]" year "[^0-9]")
206 (day " *" monthname " *" year "[^0-9]")
207 (year "[-/]" month "[-/]" day "[^0-9]")
210 ;; --- Fancy diary handling ---
212 (add-hook 'diary-display-hook 'fancy-diary-display)
213 (setq diary-list-include-blanks t)
214 (add-hook 'list-diary-entries-hook 'sort-diary-entries t)
215 (add-hook 'list-diary-entries-hook 'include-other-diary-files)
216 (add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
218 ;; --- Appointment management ---
220 (add-hook 'diary-hook 'appt-make-list)
221 (setq appt-issue-message t)
222 (setq appt-display-interval 3)
223 (setq appt-message-warning-time 10)
225 ;; --- Cosmetic stuff ---
227 (setq display-time-24hr-format t)
231 (let ((view-diary-entries-initially t))
234 (defvar mdw-black-background t)
236 ;; --- Define more mode hooks for MailCrypt ---
239 '((mdwmail-mode (encrypt . mdwmail-mc-encrypt)
240 (sign . mdwmail-mc-sign))))
242 ;; --- Load the MailCrypt support ---
245 (and (string-match "linux" (symbol-name system-type))
246 (progn (require 'mailcrypt-init)
248 (setq mc-default-scheme 'mc-scheme-gpg)
249 (setq mc-pgp-user-id "mdw-nsict-pgp")
250 (setq mc-gpg-user-id "mdw-nsict-gpg")
251 (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
252 (setq mc-pgp-always-sign t)
253 (setq mc-gpg-always-sign t)
254 (setq mc-always-replace 'never)
255 (setq mc-passwd-timeout 3600)
256 (setq mc-temp-directory tmpdir)
257 (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
258 (define-key mc-write-mode-map "\C-c/S" 'mc-sign-region)
259 (define-key mc-write-mode-map "\C-c/E" 'mc-encrypt-region)
260 (add-hook 'text-mode-hook 'mc-install-write-mode))))
262 ;;;----- Other common declarations ------------------------------------------
264 ;; --- Default frame size ---
266 (setq default-frame-alist
270 (vertical-scroll-bars . right))
272 '((cursor-type . bar)
274 '((cursor-color . "red"))
275 (if mdw-black-background
276 '((background-color . "black")
277 (foreground-color . "white")
278 (background-mode . dark))
279 '((background-mode . light)))
280 (and (eq window-system 'pm)
281 '((font . "-os2-System VIO-medium-r-normal--*-40-*-*-m-*-cp850")
282 (menu-font . "8.Helv")
283 (background-color . "lightgrey")))
284 '((transparency . t))
285 default-frame-alist))
287 ;; --- Other frame fiddling ---
289 (setq frame-title-format '("" invocation-name "@" system-name ": %b"))
291 ;; --- Global keymap changes ---
294 (windmove-default-keybindings)
295 (setq windmove-wrap-around t))
296 (trap (iswitchb-mode))
297 (global-set-key [f4] 'query-replace-regexp)
298 (global-set-key [f5] 'goto-line)
299 (global-set-key [f6] 'auto-fill-mode)
300 (global-set-key [f7] 'occur)
301 (global-set-key [f8] 'undo)
302 (global-set-key [f9] 'mdw-divvy-window)
303 (global-set-key [insertchar] 'overwrite-mode)
304 (global-set-key "\C-xm" 'vm-mail)
305 (global-set-key "\C-x\C-n" 'skel-create-file)
306 (global-set-key "\C-x4n" 'skel-create-file-other-window)
307 (global-set-key "\C-x5n" 'skel-create-file-other-frame)
308 (global-set-key [delete] 'delete-char)
309 (global-set-key "\C-[\C-m" 'call-last-kbd-macro)
310 (global-set-key "\M-q" 'mdw-fill-paragraph)
311 (global-set-key "\C-h\C-m" 'manual-entry)
312 (global-set-key [mode-line C-mouse-1] 'mouse-tear-off-window)
313 (global-set-key [vertical-scroll-bar C-down-mouse-1]
314 'mouse-drag-vertical-line)
315 (global-set-key [vertical-scroll-bar C-mouse-1]
316 #'(lambda () (interactive)))
317 (global-set-key [mouse-4] 'mdw-wheel-up)
318 (global-set-key [mouse-5] 'mdw-wheel-down)
320 ;; --- Recognising types of files ---
322 (setq auto-mode-alist
323 (append `(("\\.p[lm]$" . perl-mode)
324 ("\\.m$" . objc-mode)
326 ;; ("/[ch]/" . c-mode)
328 "\\.stgit\\.msg" "\\|"
329 "\\.git/COMMIT_EDITMSG" "\\|"
330 "svn-commit\\.tmp" "\\|"
331 "svk-commit[^/.]*\\.tmp"
334 (,(concat "^" tmpdir "/\\("
335 "svk-commit[^/.]*\\.tmp" "\\|"
336 "gitci\\.[^/.]*" "\\|"
337 "cvs[^/.]\\{6\\}" "\\|"
338 "quilt_header\.[^/.]\\{6\\}"
341 ("\\.calc?$" . apcalc-mode)
342 ("/src/linux/.*\\.\\(c\\|h\\|cc\\)$" . linux-c-mode)
343 ("/\\(s\\|sh\\)/" . arm-assembler-mode)
344 ("\\.\\(cmd\\|exec\\|rexx\\)$" . rexx-mode)
345 ("\\.st$" . smalltalk-mode)
346 ("\\.msgs$" . messages-mode)
347 ("/all-cmds\\.in$" . cpp-messages-mode)
348 ("\\.\\(tex\\|dtx\\)$" . latex-mode)
349 ("\\.gc$" . haskell.-mode)
350 (,(concat "^" (getenv "HOME") "/News/") . mdwmail-mode)
351 (,(concat "^" tmpdir "/\\(SLRN\\|snd\\|pico\\)")
355 (setq completion-ignored-extensions
356 (append `(".hc" ".hi") completion-ignored-extensions))
358 ;; --- Some common local definitions ---
360 (make-variable-buffer-local 'mdw-auto-indent)
362 (mapcar (lambda (hook) (add-hook hook 'mdw-misc-mode-config))
363 '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
364 perl-mode-hook cperl-mode-hook python-mode-hook awk-mode-hook
366 TeX-mode-hook LaTeX-mode-hook TeXinfo-mode-hook
367 tex-mode-hook latex-mode-hook texinfo-mode-hook
368 emacs-lisp-mode-hook scheme-mode-hook
369 lisp-mode-hook lisp-interaction-mode-hook inferior-lisp-mode-hook
371 sml-mode-hook haskell-mode-hook
372 smalltalk-mode-hook rexx-mode-hook
373 arm-assembler-mode-hook))
375 (global-font-lock-mode t)
376 (defalias 'perl-mode 'cperl-mode)
378 ;;;----- Rootly editingness -------------------------------------------------
380 (eval-after-load "tramp"
385 (tramp-connection-function tramp-open-connection-su)
386 (tramp-remote-sh "/bin/sh")
387 (tramp-login-program "become")
388 (tramp-copy-program nil)
389 (tramp-copy-args nil)
390 (tramp-copy-keep-date-arg nil)
391 (tramp-login-args ("TERM=dumb" "%u")))
393 (tramp-connection-function tramp-open-connection-su)
394 (tramp-login-program "really")
395 (tramp-login-args ("-u" "%u" "--"
396 "env" "TERM=dumb" "/bin/sh"))
397 (tramp-copy-program nil)
398 (tramp-copy-args nil)
399 (tramp-copy-keep-date-arg nil)
400 (tramp-remote-sh "/bin/sh"))
402 (setq tramp-multi-connection-function-alist
404 '(("bc" tramp-multi-connect-su "become TERM=dumb %u%n"))
405 '(("r" tramp-multi-connect-su "really -u %u%n"))
406 tramp-multi-connection-function-alist))
407 (setq tramp-default-method "ssh")
408 (setq tramp-default-method-alist
409 `(("\\`localhost\\'" ""
410 ,(cond ((executable-find "become") "become")
411 ((executable-find "really") "really")
414 ;;;----- General fontification ----------------------------------------------
416 ;; --- Configure lazy fontification ---
418 (setq font-lock-support-mode 'lazy-lock-mode)
419 ; (setq lazy-lock-defer-contextually t)
420 (setq lazy-lock-defer-time nil)
421 (setq font-lock-maximum-decoration 3)
422 (setq lazy-lock-minimum-size 0)
423 (setq lazy-lock-stealth-time 5)
424 (setq lazy-lock-stealth-lines 100)
425 (setq lazy-lock-stealth-verbose t)
427 (add-hook 'after-make-frame-functions 'mdw-do-set-font)
428 (add-hook 'term-setup-hook (lambda () (mdw-do-set-font (selected-frame))))
429 (add-hook 'window-setup-hook (lambda () (mdw-do-set-font (selected-frame))))
431 (add-hook 'c-mode-hook 'mdw-fontify-c-and-c++ t)
432 (add-hook 'objc-mode-hook 'mdw-fontify-c-and-c++ t)
433 (add-hook 'c++-mode-hook 'mdw-fontify-c-and-c++ t)
434 (add-hook 'linux-c-mode-hook #'(lambda () (setq c-basic-offset 8)))
436 (add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t)
437 (add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
439 (add-hook 'java-mode-hook 'mdw-fontify-java t)
441 (add-hook 'awk-mode-hook 'mdw-fontify-awk t)
443 (add-hook 'perl-mode-hook 'mdw-fontify-perl t)
444 (add-hook 'cperl-mode-hook 'mdw-fontify-perl t)
446 (setq-default py-indent-offset 2)
447 (add-hook 'python-mode-hook 'mdw-fontify-python t)
449 (setq-default tcl-indent-level 2)
450 (add-hook 'tcl-mode-hook 'mdw-fontify-tcl t)
452 (add-hook 'rexx-mode-hook 'mdw-fontify-rexx t)
454 (setq sml-nested-if-indent t)
455 (setq sml-case-indent nil)
456 (setq sml-indent-level 4)
457 (setq sml-type-of-indent nil)
458 (add-hook 'sml-mode-hook 'mdw-fontify-sml t)
460 (add-hook 'haskell-mode-hook 'mdw-fontify-haskell t)
461 (setq-default haskell-indent-offset 2)
463 (add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t)
464 (add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t)
466 (setq LaTeX-table-label "tbl:")
467 (setq-default TeX-master nil)
468 ;; (setq TeX-parse-self t)
469 ;; (setq TeX-auto-save t)
470 (setq TeX-auto-untabify nil)
471 (add-hook 'TeX-mode-hook 'mdw-fontify-tex t)
472 (add-hook 'tex-mode-hook 'mdw-fontify-tex t)
473 (add-hook 'LaTeX-mode-hook 'mdw-fontify-tex t)
474 (add-hook 'latex-mode-hook 'mdw-fontify-tex t)
476 (add-hook 'sh-mode-hook #'mdw-setup-sh-script-mode)
478 (add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t)
479 (add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t)
481 (add-hook 'emacs-lisp-mode-hook 'mdw-fontify-lispy t)
482 (add-hook 'scheme-mode-hook 'mdw-fontify-lispy t)
483 (add-hook 'lisp-mode-hook 'mdw-fontify-lispy t)
484 (add-hook 'inferior-lisp-mode-hook 'mdw-fontify-lispy t)
485 (add-hook 'lisp-interaction-mode-hook 'mdw-fontify-lispy t)
486 (add-hook 'slime-repl-mode-hook 'mdw-fontify-lispy t)
487 (add-hook 'lisp-mode-hook 'mdw-common-lisp-indent t)
490 (slime-setup :autodoc t))
491 (trap (require 'xscheme))
492 (setq-default xscheme-process-command-line "scheme -large -emacs")
493 (add-hook 'inferior-lisp-mode-hook
495 (local-set-key "\C-m" 'comint-send-and-indent)) t)
497 (add-hook 'text-mode-hook 'mdw-text-mode t)
499 ;;;----- Shell mode ---------------------------------------------------------
501 ;; --- Make the shell mode aware of my prompt ---
503 (setq shell-prompt-pattern "^[^]#$%>»}\n]*[]#$%>»}] *")
504 (setq comint-password-prompt-regexp
505 (concat "\\(\\([Oo]ld \\|[Nn]ew \\|[a-zA-Z0-9_]*'s \\|^\\)"
506 "[Pp]assword\\|pass phrase\\):\\s *\\'"))
508 ;; --- Notice passwords, and make C-a work right ---
510 (add-hook 'shell-mode-hook #'mdw-sh-mode-setup)
512 (add-hook 'term-mode-hook #'mdw-term-mode-setup)
514 ;;;----- Finishing touches --------------------------------------------------
516 (trap (select-window mdw-init-window))
517 (provide 'emacs-init)
519 ;;;----- That's all, folks --------------------------------------------------