1 ; This is my real emacs start-up file (for chiark).
3 (make-variable-buffer-local 'indent-line-function)
4 ; Un-disable narrow and eval-expression
5 (put 'narrow-to-region 'disabled nil)
6 (put 'eval-expression 'disabled nil)
8 ; Make sure we don't disturb links or change ownership, use numbers
9 (setq backup-by-copying-when-mismatch t)
10 (setq backup-by-copying-when-linked t)
11 ;(setq version-control t
14 ; trim-versions-without-asking t)
17 (setq require-final-newline "ask")
18 (if (string= window-system 'x) (load-library "ian-x"))
19 (load-library "ian-aliases")
20 ; (load-library "auto-pgp")
21 ; (load-library "debian-changelog-mode")
22 ; (if (string= (getenv "TERM") "bbcb32") (setq term-file-prefix nil))
23 ; (setq explicit-shell-file-name "/usr/local/bin/tcsh")
24 (setq inhibit-local-variables t)
25 (setq enable-local-variables 'ask-me)
26 (setq enable-recursive-minibuffers t)
27 (setq compile-command "make")
28 (setq diff-switches "-u")
31 (set-variable 'search-repeat-char 28)
32 (if (string-match "^19\." emacs-version)
34 (setq file-name-handler-alist ; Disable nasty auto-loading of ange-ftp
35 (delq (rassq 'ange-ftp-completion-hook-function file-name-handler-alist)
36 file-name-handler-alist))
37 (require 'find-alternate-18style)
38 (defun unset-down-mouse-23 ()
39 (local-set-key [mouse-2] 'mouse-yank-at-click)
40 (local-unset-key [down-mouse-2])
41 (local-unset-key [down-mouse-3])
42 (local-unset-key [C-down-mouse-3]))
43 (add-hook 'vm-mode-hook 'unset-down-mouse-23)
44 (add-hook 'vm-mail-mode-hook 'unset-down-mouse-23)
45 (add-hook 'text-mode-hook 'unset-down-mouse-23)
46 (add-hook 'Info-mode-hook
48 (local-set-key " " 'scroll-up)
49 (local-set-key "
\7f" 'scroll-down))))
50 (define-key isearch-mode-map "
\1c" 'isearch-repeat-forward)
51 (define-key isearch-mode-map "
\1d" 'isearch-quote-char)))
52 (setq Info-directory-list '("/jura:/usr/info" "/dover:/usr/info"))
55 (defun terminal-keybindings ()
56 "This function should be called by the term-setup-hook mechanism"
58 ; Set my own keybindings
60 ; Set keybindings generally (including I-search on C-\)
61 ; (global-set-key " " 'self-insert-command)
62 (global-set-key "
\1c" 'isearch-forward)
63 (global-set-key "
\r" 'newline-and-indent)
64 (global-set-key "
\ f" 'set-mark-command)
65 (global-set-key "
\1d" 'quoted-insert)
67 ; Set keybindings on esc-map
68 (global-set-key "
\e#" 'query-replace-regexp)
69 (global-set-key "
\e+" 'toggle-truncate-lines)
70 (global-set-key "
\eg" 'goto-line)
71 (global-set-key "
\es" 'isearch-forward-regexp)
72 (global-set-key "
\e\e" 'eval-expression)
74 ; Set keybindings on ^X-map.
75 (global-set-key "
\18m" 'vm-mail)
76 (global-set-key "
\18\1c" 'save-buffer)
77 (global-set-key "
\18\1d" 'toggle-read-only)
78 (global-set-key "
\18#" 'recover-file)
79 (global-set-key "
\18\12" 'bury-buffer)
80 (global-set-key "
\18\v" 'quicker-compile)
81 (global-set-key "
\18\18" 'exchange-point-and-mark)
82 (global-set-key "
\18\1a" 'load-ange-ftp)
83 (global-set-key "
\184
\16" 'scroll-other-window)
84 (global-set-key "
\184m" 'vm-mail-other-window)
85 (global-set-key "
\189" 'vm-visit-folder)
86 (global-set-key "
\188" 'rmail-input)
87 (global-set-key "
\18p" 'cite-region)
88 (global-set-key "
\18F" 'mail-formletter)
90 ; Set keybindings for Sun numeric pad.
91 (setq esc-bracket-map (make-keymap))
92 (define-key esc-bracket-map "D" 'backward-char)
93 (define-key esc-bracket-map "C" 'forward-char)
94 (define-key esc-bracket-map "A" 'previous-line)
95 (define-key esc-bracket-map "B" 'next-line)
96 (define-key esc-map "[" esc-bracket-map)
97 (global-set-key "\e[214z" 'beginning-of-buffer)
98 (global-set-key "\e[220z" 'end-of-buffer)
99 (global-set-key "\e[216z" 'scroll-down)
100 (global-set-key "\e[222z" 'scroll-up)
101 (global-set-key "\e[192z" 'save-buffer)
102 (global-set-key "\e[194z" 'save-some-buffers)
103 (global-set-key "\e[195z" 'undo)
104 (global-set-key "\e[193z" 'call-last-kbd-macro)
105 (global-set-key "\e[196z" 'switch-to-buffer-other-window)
106 (global-set-key "\e[197z" 'copy-region-as-kill)
107 (global-set-key "\e[198z" 'find-file)
108 (global-set-key "\e[199z" 'yank)
109 (global-set-key "\e[198z" 'find-alternate-file)
110 (global-set-key "\e[200z" 'find-file)
111 (global-set-key "\e[201z" 'kill-region)
112 (global-set-key "\e[-1z" 'info)
114 ; Set keybindings for Chiarks' x11emacs
115 (global-set-key "
\e[5~" 'scroll-down)
116 (global-set-key "
\e[6~" 'scroll-up)
118 ; Set keybindings for knackered vt100-like terminal emulators.
119 (global-set-key "\eOt" 'scroll-down)
120 (global-set-key "\eOu" 'scroll-up)
121 (global-set-key "\eOD" 'backward-char)
122 (global-set-key "\eOC" 'forward-char)
123 (global-set-key "\eOA" 'previous-line)
124 (global-set-key "\eOB" 'next-line))
125 (setq term-setup-hook 'terminal-keybindings) ; remap keys in due course
127 ; Autoload definitions
128 (autoload 'tar-mode "tar-mode")
129 (autoload 'uncompress-while-visiting "uncompress")
130 ; (autoload 'c++-mode "c++-mode" "Mode for editing C and C++ programs" t)
131 (autoload 'hide-ifdef-mode "hideif" "For editing code with #ifdefs" t)
132 ;(setq-default indent-tabs-mode nil)
133 (autoload 'dired-find-alternate-file "dired-alternate" "Find alternately" t)
134 (autoload 'dired-run-file "dired-alternate" "Run this file" t)
135 (autoload 'perl-mode "perl-mode" "Mode for Perl code" t)
136 ; (autoload 'rmail "rmail-fixed" "Patched mail reader" t)
137 (autoload 'quicker-compile "quicker-compile" "Patched Compile mode" t)
139 (autoload 'vm "vm" "Start VM on your primary inbox." t)
140 (autoload 'vm-visit-folder "vm" "Start VM on an arbitrary folder." t)
141 (autoload 'vm-visit-virtual-folder "vm" "Visit a VM virtual folder." t)
142 (autoload 'vm-mode "vm" "Run VM major mode on a buffer" t)
143 (autoload 'vm-mail "vm" "Send a mail message using VM." t)
144 (autoload 'vm-submit-bug-report "vm" "Send a bug report about VM." t)
146 ; (autoload 'info "info-fixed" "Patched info browser" t)
147 (setq shell-mode-hook
149 (make-variable-buffer-local 'scroll-step)
150 (setq scroll-step 1)))
151 ; (setq inferior-lisp-program "kcl")
152 (setq dired-mode-hook
154 (define-key dired-mode-map "F" 'dired-find-alternate-file)
155 (define-key dired-mode-map "X" 'dired-run-file)))
157 ; Prevent loading of default init file and do some of the things it did
158 ; (setq inhibit-default-init t)
160 ; Additional alist handling function
161 ;(defun alist-remove-elem (s s-list)
162 ; "Delete the element of the alist S-LIST whose car is S"
163 ; (if s-list (if (equal s (car (car s-list)))
165 ; (cons (car s-list) (alist-remove-elem s (cdr s-list))))
168 ; Load C++ mode and edit Perl in perl mode
169 (setq auto-mode-alist
170 (append '(("\\.[ch]$" . c-mode)
171 ("\\.[CH]$" . c++-mode)
172 ("\\.cc$" . c++-mode)
173 ("\\.hh$" . c++-mode)
174 ; ("\\.tar$" . tar-mode)
175 ("\\.pl$" . perl-mode)
176 ("\\.ci$" . tex-mode)
177 ("\\.Z$" . uncompress-while-visiting))
179 (setq interpreter-mode-alist
180 (append '(("sh" . fundamental-mode)
181 ("bash" . fundamental-mode))
182 interpreter-mode-alist))
184 ; Use auto-fill when editing text
185 (add-hook 'text-mode-hook '(lambda () (auto-fill-mode 1)))
186 (add-hook 'text-mode-hook '(lambda () (local-set-key " " 'self-insert-command)))
188 ; Set up newline to auto-indent & other stuff for perl, c++ and c modes.
189 (setq perl-mode-hook '(lambda ()
190 (local-set-key ";" 'self-insert-command)))
191 (setq c++-mode-hook '(lambda ()
193 (local-set-key ":" 'electric-c++-terminator)))
195 (setq c-mode-hook '(lambda ()
197 (c-set-offset 'substatement-open 0 nil)
198 (local-set-key "
\r" 'newline-and-indent)))
199 (setq c-hanging-comment-ender-p nil)
201 (defun vm-mail-other-window ()
202 "Like `vm-mail' command, but display buffer in another window."
204 (switch-to-buffer-other-window (current-buffer))
208 (setq mail-precedence-key-alist
209 '((?0 . "special-delivery")
212 (?3 . "second-class")
218 (defun mail-precedence-as-key ()
219 "Set precedence by looking up last command char in mail-precedence-key-alist"
221 (message "%s" (concat "Precedence ["
222 (mapconcat '(lambda (c) (char-to-string (car c)))
223 mail-precedence-key-alist "")
225 (let* ((key (read-char))
226 (prec (assoc key mail-precedence-key-alist)))
227 (if prec (mail-precedence (cdr prec))
228 (error "mail-precedence-as-key `%s' not found" key))))
230 (defun mail-precedence-as-key-send-and-exit (arg)
231 "Set precedence by looking up last command char in mail-precedence-key-alist,
232 then call send-and-exit."
234 (mail-precedence-as-key)
235 (execute-kbd-macro "
\ 3\ 3"))
237 (defun mail-precedence (prec)
239 (mail-position-on-field "Precedence")
242 (delete-region (point) p)
244 (insert "Precedence: " prec)
247 (defun mail-mode-setup-keys ()
248 (local-set-key "
\ 3\10" 'mail-precedence-as-key)
249 (local-set-key "
\ 3p" 'mail-precedence-as-key-send-and-exit))
250 (add-hook 'mail-mode-hook 'mail-mode-setup-keys)
251 (add-hook 'vm-mail-mode-hook 'mail-mode-setup-keys)
253 (defun vm-mail-other-window ()
254 "Like `vm-mail' command, but display buffer in another window."
256 (switch-to-buffer-other-window (current-buffer))
259 (defun mail-formletter ()
260 "Run VM-mail with ,Formletter"
263 (rename-buffer (generate-new-buffer-name "form letter") t)
264 (delete-region (point-min) (point-max))
265 (insert-file (concat vm-folder-directory ",Formletter")))
267 ; This function bound to C-x C-z
268 (defun load-ange-ftp ()
269 "Load ange-ftp using require, if it isn't loaded already"
271 (message "Loading ange-ftp...")
272 (require 'ange-ftp) ; -extended
273 (message "Loading ange-ftp...done"))
275 ; This function bound to M-+
276 (defun toggle-truncate-lines ()
277 "Toggle truncation or folding of long lines"
279 (set-variable 'truncate-lines (not truncate-lines))
283 ;(setq rmail-file-name "~/mail/RMAIL"
284 ; mail-archive-file-name "~/mail/Outbound"
285 ; rmail-primary-inbox-list '("~/mbox" "~/mail/Outbound" "~/mail/Record"
286 ; "~/mail/Import" "/var/spool/mail/ian")
287 ; rmail-delete-after-output t
288 ; rmail-last-rmail-file ""
289 ; rmail-ignored-headers (concat
290 ; "^Content-Identifier:\\|^X400-[^O][A-Za-z-]+:\\|"
291 ; rmail-ignored-headers))
293 (defun make-regexps-ignore-non-address (list)
294 (apply 'append (mapcar
296 (let ((item (mapconcat
298 (let ((s (char-to-string ch)))
299 (if (string-match "[][.*+?^$\\]" s)
304 (concat "<" item ">")
305 (concat "^" item " *\\((.*)\\)?$"))))
309 (setq bbdb-north-american-phone-numbers-p nil
310 bbdb/mail-auto-create-p t
312 bbdb-notice-auto-save-file-p t
313 bbdb-message-caching-enabled t)
316 (load-file "~/private/private.el")
317 (setq vm-included-text-attribution-format "%F writes (\"%s\"):\n"
318 vm-reply-subject-prefix "Re: "
319 vm-folder-directory "~/mail/"
320 vm-delete-after-saving t
321 vm-delete-empty-folders t
322 vm-mutable-windows nil
323 vm-auto-get-new-mail nil
324 vm-auto-next-message nil
325 vm-jump-to-new-messages nil
326 vm-jump-to-unread-messages nil
328 vm-included-text-prefix "> "
330 vm-auto-center-summary t
331 vm-confirm-new-folders t
332 vm-circular-folders nil
333 vm-visit-when-saving 0
334 vm-move-after-deleting t
335 vm-keep-sent-messages t
336 vm-follow-summary-cursor t
337 vm-frame-per-composition nil
338 vm-frame-per-edit nil
339 vm-frame-per-summary nil
340 vm-frame-per-folder nil
341 vm-tale-is-an-idiot t
342 vm-primary-inbox (concat vm-folder-directory "INBOX")
343 vm-sysadmin-inbox (concat vm-folder-directory "SINBOX")
344 vm-uninteresting-senders "ian"
345 vm-reply-ignored-addresses
346 (make-regexps-ignore-non-address
347 '("ian@chiark.chu.cam.ac.uk" "ian" "iwj10@cus.cam.ac.uk"
348 "ian@chiark.greenend.org.uk"
349 "ijackson@nyx.cs.du.edu" "ijackson@gnu.ai.mit.edu"))
352 ; (list vm-primary-inbox "~/mbox" "~/mail/INBOX.CRASH")
353 ; (list vm-primary-inbox "~/mail/Outbound" "~/mail/INBOX.CRASH")
354 ; (list vm-primary-inbox "~/mail/Record" "~/mail/INBOX.CRASH")
355 ; (list vm-primary-inbox "~/mail/Import" "~/mail/INBOX.CRASH")
356 ; (list vm-primary-inbox "/var/spool/mail/ian" "~/mail/INBOX.CRASH")
357 ; (list vm-primary-inbox "~/News/r" "~/mail/INBOX.CRASH")
358 ; (list vm-sysadmin-inbox "~/mbox" "~/mail/SINBOX.CRASH")
359 ; (list vm-sysadmin-inbox "~/mail/SOutbound" "~/mail/SINBOX.CRASH")
360 ; (list vm-sysadmin-inbox "~/mail/Import" "~/mail/SINBOX.CRASH")
361 ; (list vm-sysadmin-inbox "/var/spool/mail/sysadmin" "~/mail/SINBOX.CRASH")
362 ; (list "/u/ijackson/mail/INBOX" "/u/ijackson/mbox" "/u/ijackson/mail/INBOX.CRASH")
363 ; (list "/u/ijackson/mail/INBOX" "/u/ijackson/mail/Outbound"
364 ; "/u/ijackson/mail/INBOX.CRASH")
365 ; (list "/u/ijackson/mail/INBOX" "/u/ijackson/mail/Record" "/u/ijackson/mail/INBOX.CRASH")
366 ; (list "/u/ijackson/mail/INBOX" "/u/ijackson/mail/Import" "/u/ijackson/mail/INBOX.CRASH")
367 ; (list "/u/ijackson/mail/INBOX"
368 ; (concat "localhost:110:pass:ijackson:" ijackson-pop-password)
369 ; "/u/ijackson/mail/INBOX.CRASH"))
370 vm-startup-with-summary nil
371 vm-summary-format "%3n %a %2d %3m %-19.19F %s\n"
372 mail-archive-file-name "~/mail/Outbound"
373 vm-mime-8bit-text-transfer-encoding '8bit)
375 (add-hook 'vm-mode-hook
377 (local-set-key "Q" 'vm-quit)
378 (local-set-key "q" "#Q")))
379 (add-hook 'mail-mode-hook
381 (if (and (boundp 'folder-buffer)
383 (string= (buffer-file-name folder-buffer)
384 (file-truename vm-sysadmin-inbox)))
386 (make-local-variable 'vm-mail-header-from)
387 (setq vm-mail-header-from
388 "sysadmin@chiark.greenend.org.uk (Ian Jackson)")
389 (make-local-variable 'mail-archive-file-name)
390 (setq mail-archive-file-name
391 "~/mail/SOutbound")))))
395 (vm "/u/ijackson/mail/INBOX"))
399 (vm vm-sysadmin-inbox))
401 (defun make-session ()
402 "Makes this emacs hard to kill by requiring ^X^Cy to kill it
403 instead of just ^X^C."
405 (global-unset-key "
\18\ 3")
406 (global-set-key "
\18\ 3y" 'save-buffers-kill-emacs))
408 ; Fix problems with M-| setting window title of emacs' parent xterm
409 (defun envdelete-term-termcap-windowid (list)
414 (if (or (string-match "^TERM=" x)
415 (string-match "^TERMCAP=" x)
416 (string-match "^WINDOWID=" x))
421 (setq process-environment
422 (envdelete-term-termcap-windowid process-environment))
424 (defun add-insertion-keys (table)
425 "Adds keybindings according to TABLE. Each element of
426 TABLE should be a four-element list.
428 BINDING should be the key to bind; FUNCTION will be the name of the
429 function defined to do the insertion; DESCRIPTION will be inserted
430 into \"Inserts ... .\", and used as the descriptive string for the
431 generated function; STRING is the string which will actually be
432 inserted into the buffer when the keystroke is pressed."
434 (let* ((head (car table))
438 (string (nth 3 head)))
442 (concat "Inserts " desc ".")
444 (list 'insert string)))
445 (funcall 'local-set-key key func))
446 (setq table (cdr table))))
448 (defun ian-sgml-setup ()
451 '(("
\ 3\r" sgml-insert-new-para "new paragraph markup" "\n<p>\n")
452 ("
\ 3\14" sgml-insert-tt-emph "tt emph markup" "<tt/")
453 ("
\ 3\10" sgml-insert-prgn-emph "prgn emph markup" "<prgn/")
454 ("
\ 3\ 5" sgml-insert-em-emph "em emfh markup" "<em/")
455 ("
\ 3\16" sgml-insert-var-empfh "var emph markup" "<var/"))))
456 (setq sgml-local-catalogs '("/jura:/usr/lib/debiandoc-sgml/sgml/catalog"))
458 (add-hook 'sgml-mode-hook 'ian-sgml-setup)
460 (defvar cite-string "> " "String to insert when citing")
462 (defun cite-region (start end)
463 "Quote each line in the region with an angle-bracket and space.
465 The citation string is taken from cite-string."
469 (narrow-to-region start end)
470 (goto-char (point-min))
475 (> (point-max) (point)))
476 (insert cite-string)))))