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 (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)
43 (or (fboundp 'make-regexp)
44 (load "make-regexp")))
46 (trap (require 'tex-site))
48 ;; --- Skeleton stuff ---
50 (trap (require 'skel-init))
52 ;; --- Window system-dependent things ---
55 (trap (show-paren-mode t))
56 (or window-system (menu-bar-mode -1))
58 ;; --- Temporary directory handling ---
60 (defun mdw-check-dir-exists (dir)
62 (file-directory-p dir)
64 (setq tmpdir (or (mdw-check-dir-exists (getenv "TMPDIR"))
65 (mdw-check-dir-exists (format "/tmp/%s" (user-login-name)))
68 ;; --- Emacs server behaviour ---
72 (setq server-temp-file-regexp (concat "^" tmpdir "\\|/draft$"))))
74 ;; --- Control backup behaviour ---
76 (setq backup-by-copying nil)
77 (setq backup-by-copying-when-linked t)
78 (setq backup-by-copying-when-mismatch t)
80 ;; --- Calculator fiddling ---
82 (setq calc-settings-file "~/.emacs-calc")
83 (load calc-settings-file)
85 ;; ---- Some mail and news configuration ---
87 (setq mail-from-style 'parens)
88 (setq mail-signature t)
89 (setq mail-yank-prefix "> ")
90 (setq mail-archive-file-name "~/Mail/sent")
92 (setq rmail-display-summary t)
93 (setq rmail-file-name "~/Mail/rmail")
95 ;; --- GNUS configuration ---
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)
102 ;; --- Internationalization twiddling ---
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"))
111 ;; --- Don't disable any commands ---
113 (mapatoms #'(lambda (sym) (put sym 'disabled nil)))
115 ;; --- Split a wide window ---
119 ;; --- Other goodies ---
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")
147 (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
148 (setq uniquify-after-kill-buffer-p t))
149 (transient-mark-mode t)
153 (trap (global-auto-revert-mode t))
154 (setq psgml-html-build-new-buffer nil)
157 "http://metalzone.distorted.org.uk/doc/cltl/")
158 (setq common-lisp-hyperspec-root
159 "http://metalzone.distorted.org.uk/doc/hyperspec/")
161 ;;;----- Calendar configuration ---------------------------------------------
163 ;; --- Trivial stuff for the sunrise/sunset calculations ---
165 (setq calendar-latitude 52.2)
166 (setq calendar-longitude 0.1)
167 (setq calendar-location-name "Cambridge, UK")
169 ;; --- Date format fiddling ---
171 (setq european-calendar-style t)
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]")
181 ;; --- Fancy diary handling ---
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)
189 ;; --- Appointment management ---
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)
196 ;; --- Cosmetic stuff ---
198 (setq display-time-24hr-format t)
202 (let ((view-diary-entries-initially t))
205 (defvar mdw-black-background t)
207 ;; --- Define more mode hooks for MailCrypt ---
210 '((mdwmail-mode (encrypt . mdwmail-mc-encrypt)
211 (sign . mdwmail-mc-sign))))
213 ;; --- Load the MailCrypt support ---
216 (and (string-match "linux" (symbol-name system-type))
217 (progn (require 'mailcrypt-init)
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))))
233 ;;;----- Other common declarations ------------------------------------------
235 ;; --- Default frame size ---
237 (setq default-frame-alist
241 (vertical-scroll-bars . right))
243 '((cursor-type . bar)
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))
258 ;; --- Other frame fiddling ---
260 (setq frame-title-format '("" invocation-name "@" system-name ": %b"))
262 ;; --- Global keymap changes ---
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)
291 ;; --- Recognising types of files ---
293 (setq auto-mode-alist
294 (append `(("\\.p[lm]$" . perl-mode)
295 ("\\.m$" . objc-mode)
297 ;; ("/[ch]/" . c-mode)
299 "\\.stgit\\.msg" "\\|"
300 "\\.git/COMMIT_EDITMSG" "\\|"
301 "svn-commit\\.tmp" "\\|"
302 "svk-commit[^/.]*\\.tmp"
305 (,(concat "^" tmpdir "/\\("
306 "svk-commit[^/.]*\\.tmp" "\\|"
307 "gitci\\.[^/.]*" "\\|"
308 "cvs[^/.]\\{6\\}" "\\|"
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\\)")
323 (setq completion-ignored-extensions
324 (append `(".hc" ".hi") completion-ignored-extensions))
326 ;; --- Some common local definitions ---
328 (make-variable-buffer-local 'mdw-auto-indent)
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
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
339 sml-mode-hook haskell-mode-hook
340 smalltalk-mode-hook rexx-mode-hook
341 arm-assembler-mode-hook))
343 (global-font-lock-mode t)
344 (defalias 'perl-mode 'cperl-mode)
346 ;;;----- Rootly editingness -------------------------------------------------
348 (eval-after-load "tramp"
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")))
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"))
370 (setq tramp-multi-connection-function-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")
382 ;;;----- General fontification ----------------------------------------------
384 ;; --- Configure lazy fontification ---
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)
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))))
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)))
404 (add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t)
405 (add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
407 (add-hook 'java-mode-hook 'mdw-fontify-java t)
409 (add-hook 'awk-mode-hook 'mdw-fontify-awk t)
411 (add-hook 'perl-mode-hook 'mdw-fontify-perl t)
412 (add-hook 'cperl-mode-hook 'mdw-fontify-perl t)
414 (setq-default py-indent-offset 2)
415 (add-hook 'python-mode-hook 'mdw-fontify-python t)
417 (setq-default tcl-indent-level 2)
418 (add-hook 'tcl-mode-hook 'mdw-fontify-tcl t)
420 (add-hook 'rexx-mode-hook 'mdw-fontify-rexx t)
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)
428 (add-hook 'haskell-mode-hook 'mdw-fontify-haskell t)
429 (setq-default haskell-indent-offset 2)
431 (add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t)
432 (add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t)
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)
444 (add-hook 'sh-mode-hook #'mdw-setup-sh-script-mode)
446 (add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t)
447 (add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t)
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)
458 (slime-setup :autodoc t))
459 (trap (require 'xscheme))
460 (setq-default xscheme-process-command-line "scheme -large -emacs")
461 (add-hook 'inferior-lisp-mode-hook
463 (local-set-key "\C-m" 'comint-send-and-indent)) t)
465 (add-hook 'text-mode-hook 'mdw-text-mode t)
467 ;;;----- Shell mode ---------------------------------------------------------
469 ;; --- Make the shell mode aware of my prompt ---
471 (setq shell-prompt-pattern "^[^]#$%>»\n]*[]#$%>»] *")
472 (setq comint-password-prompt-regexp
473 (concat "\\(\\([Oo]ld \\|[Nn]ew \\|[a-zA-Z0-9_]*'s \\|^\\)"
474 "[Pp]assword\\|pass phrase\\):\\s *\\'"))
476 ;; --- Notice passwords, and make C-a work right ---
478 (add-hook 'shell-mode-hook #'mdw-sh-mode-setup)
480 (add-hook 'term-mode-hook #'mdw-term-mode-setup)
482 ;;;----- Finishing touches --------------------------------------------------
484 (trap (select-window mdw-init-window))
485 (provide 'emacs-init)
487 ;;;----- Emacs customization crud -------------------------------------------
489 (custom-set-variables
490 ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
491 ;; Your init file should contain only one such instance.
492 '(url-cookie-untrusted-urls (quote (".")))
493 '(url-proxy-services (quote (("http" . "metalzone.distorted.org.uk:3128") ("ftp" . "metalzone.distorted.org.uk:3128") ("gopher" . "metalzone.distorted.org.uk:3128"))))
494 '(w3-do-incremental-display t)
495 '(w3-honor-stylesheets nil)
496 '(w3-use-menus (quote (file edit view go bookmark options buffers style search emacs nil help)))
497 '(w3m-display-inline-image t)
498 '(w3m-key-binding (quote info)))
500 ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
501 ;; Your init file should contain only one such instance.
504 ;;;----- That's all, folks --------------------------------------------------