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)))
54 (defun terminal-keybindings ()
55 "This function should be called by the term-setup-hook mechanism"
57 ; Set my own keybindings
59 ; Set keybindings generally (including I-search on C-\)
60 ; (global-set-key " " 'self-insert-command)
61 (global-set-key "
\1c" 'isearch-forward)
62 (global-set-key "
\r" 'newline-and-indent)
63 (global-set-key "
\ f" 'set-mark-command)
64 (global-set-key "
\1d" 'quoted-insert)
66 ; Set keybindings on esc-map
67 (global-set-key "
\e#" 'query-replace-regexp)
68 (global-set-key "
\e+" 'toggle-truncate-lines)
69 (global-set-key "
\eg" 'goto-line)
70 (global-set-key "
\es" 'isearch-forward-regexp)
71 (global-set-key "
\e\e" 'eval-expression)
73 ; Set keybindings on ^X-map.
74 (global-set-key "
\18m" 'vm-mail)
75 (global-set-key "
\18\1c" 'save-buffer)
76 (global-set-key "
\18\1d" 'toggle-read-only)
77 (global-set-key "
\18#" 'recover-file)
78 (global-set-key "
\18\12" 'bury-buffer)
79 (global-set-key "
\18\v" 'quicker-compile)
80 (global-set-key "
\18\18" 'exchange-point-and-mark)
81 (global-set-key "
\18\1a" 'load-ange-ftp)
82 (global-set-key "
\184
\16" 'scroll-other-window)
83 (global-set-key "
\184m" 'vm-mail-other-window)
84 (global-set-key "
\189" 'vm-visit-folder)
85 (global-set-key "
\188" 'rmail-input)
86 (global-set-key "
\18p" 'cite-region)
87 (global-set-key "
\18F" 'mail-formletter)
89 ; Set keybindings for Sun numeric pad.
90 (setq esc-bracket-map (make-keymap))
91 (define-key esc-bracket-map "D" 'backward-char)
92 (define-key esc-bracket-map "C" 'forward-char)
93 (define-key esc-bracket-map "A" 'previous-line)
94 (define-key esc-bracket-map "B" 'next-line)
95 (define-key esc-map "[" esc-bracket-map)
96 (global-set-key "\e[214z" 'beginning-of-buffer)
97 (global-set-key "\e[220z" 'end-of-buffer)
98 (global-set-key "\e[216z" 'scroll-down)
99 (global-set-key "\e[222z" 'scroll-up)
100 (global-set-key "\e[192z" 'save-buffer)
101 (global-set-key "\e[194z" 'save-some-buffers)
102 (global-set-key "\e[195z" 'undo)
103 (global-set-key "\e[193z" 'call-last-kbd-macro)
104 (global-set-key "\e[196z" 'switch-to-buffer-other-window)
105 (global-set-key "\e[197z" 'copy-region-as-kill)
106 (global-set-key "\e[198z" 'find-file)
107 (global-set-key "\e[199z" 'yank)
108 (global-set-key "\e[198z" 'find-alternate-file)
109 (global-set-key "\e[200z" 'find-file)
110 (global-set-key "\e[201z" 'kill-region)
111 (global-set-key "\e[-1z" 'info)
113 ; Set keybindings for Chiarks' x11emacs
114 (global-set-key "
\e[5~" 'scroll-down)
115 (global-set-key "
\e[6~" 'scroll-up)
117 ; Set keybindings for knackered vt100-like terminal emulators.
118 (global-set-key "\eOt" 'scroll-down)
119 (global-set-key "\eOu" 'scroll-up)
120 (global-set-key "\eOD" 'backward-char)
121 (global-set-key "\eOC" 'forward-char)
122 (global-set-key "\eOA" 'previous-line)
123 (global-set-key "\eOB" 'next-line))
124 (setq term-setup-hook 'terminal-keybindings) ; remap keys in due course
126 ; Autoload definitions
127 (autoload 'tar-mode "tar-mode")
128 (autoload 'uncompress-while-visiting "uncompress")
129 ; (autoload 'c++-mode "c++-mode" "Mode for editing C and C++ programs" t)
130 (autoload 'hide-ifdef-mode "hideif" "For editing code with #ifdefs" t)
131 ;(setq-default indent-tabs-mode nil)
132 (autoload 'dired-find-alternate-file "dired-alternate" "Find alternately" t)
133 (autoload 'dired-run-file "dired-alternate" "Run this file" t)
134 (autoload 'perl-mode "perl-mode" "Mode for Perl code" t)
135 ; (autoload 'rmail "rmail-fixed" "Patched mail reader" t)
136 (autoload 'quicker-compile "quicker-compile" "Patched Compile mode" t)
138 (autoload 'vm "vm" "Start VM on your primary inbox." t)
139 (autoload 'vm-visit-folder "vm" "Start VM on an arbitrary folder." t)
140 (autoload 'vm-visit-virtual-folder "vm" "Visit a VM virtual folder." t)
141 (autoload 'vm-mode "vm" "Run VM major mode on a buffer" t)
142 (autoload 'vm-mail "vm" "Send a mail message using VM." t)
143 (autoload 'vm-submit-bug-report "vm" "Send a bug report about VM." t)
145 ; (autoload 'info "info-fixed" "Patched info browser" t)
146 (setq shell-mode-hook
148 (make-variable-buffer-local 'scroll-step)
149 (setq scroll-step 1)))
150 ; (setq inferior-lisp-program "kcl")
151 (setq dired-mode-hook
153 (define-key dired-mode-map "F" 'dired-find-alternate-file)
154 (define-key dired-mode-map "X" 'dired-run-file)))
156 ; Prevent loading of default init file and do some of the things it did
157 ; (setq inhibit-default-init t)
159 ; Additional alist handling function
160 ;(defun alist-remove-elem (s s-list)
161 ; "Delete the element of the alist S-LIST whose car is S"
162 ; (if s-list (if (equal s (car (car s-list)))
164 ; (cons (car s-list) (alist-remove-elem s (cdr s-list))))
167 ; Load C++ mode and edit Perl in perl mode
168 (setq auto-mode-alist
169 (append '(("\\.[ch]$" . c-mode)
170 ("\\.[CH]$" . c++-mode)
171 ("\\.cc$" . c++-mode)
172 ("\\.hh$" . c++-mode)
173 ; ("\\.tar$" . tar-mode)
174 ("\\.pl$" . perl-mode)
175 ("\\.ci$" . tex-mode)
176 ("\\.Z$" . uncompress-while-visiting))
178 (setq interpreter-mode-alist
179 (append '(("sh" . fundamental-mode)
180 ("bash" . fundamental-mode))
181 interpreter-mode-alist))
183 ; Use auto-fill when editing text
184 (add-hook 'text-mode-hook '(lambda () (auto-fill-mode 1)))
185 (add-hook 'text-mode-hook '(lambda () (local-set-key " " 'self-insert-command)))
187 ; Set up newline to auto-indent & other stuff for perl, c++ and c modes.
188 (setq perl-mode-hook '(lambda ()
189 (local-set-key ";" 'self-insert-command)))
190 (setq c++-mode-hook '(lambda ()
192 (local-set-key ":" 'electric-c++-terminator)))
194 (setq c-mode-hook '(lambda ()
196 (c-set-offset 'substatement-open 0 nil)
197 (local-set-key "
\r" 'newline-and-indent)))
198 (setq c-hanging-comment-ender-p nil)
200 (defun vm-mail-other-window ()
201 "Like `vm-mail' command, but display buffer in another window."
203 (switch-to-buffer-other-window (current-buffer))
207 (setq mail-precedence-key-alist
208 '((?0 . "special-delivery")
211 (?3 . "second-class")
217 (defun mail-precedence-as-key ()
218 "Set precedence by looking up last command char in mail-precedence-key-alist"
220 (message "%s" (concat "Precedence ["
221 (mapconcat '(lambda (c) (char-to-string (car c)))
222 mail-precedence-key-alist "")
224 (let* ((key (read-char))
225 (prec (assoc key mail-precedence-key-alist)))
226 (if prec (mail-precedence (cdr prec))
227 (error "mail-precedence-as-key `%s' not found" key))))
229 (defun mail-precedence-as-key-send-and-exit (arg)
230 "Set precedence by looking up last command char in mail-precedence-key-alist,
231 then call send-and-exit."
233 (mail-precedence-as-key)
234 (execute-kbd-macro "
\ 3\ 3"))
236 (defun mail-precedence (prec)
238 (mail-position-on-field "Precedence")
241 (delete-region (point) p)
243 (insert "Precedence: " prec)
246 (defun mail-mode-setup-keys ()
247 (local-set-key "
\ 3\10" 'mail-precedence-as-key)
248 (local-set-key "
\ 3p" 'mail-precedence-as-key-send-and-exit))
249 (add-hook 'mail-mode-hook 'mail-mode-setup-keys)
250 (add-hook 'vm-mail-mode-hook 'mail-mode-setup-keys)
252 (defun vm-mail-other-window ()
253 "Like `vm-mail' command, but display buffer in another window."
255 (switch-to-buffer-other-window (current-buffer))
258 (defun mail-formletter ()
259 "Run VM-mail with ,Formletter"
262 (rename-buffer (generate-new-buffer-name "form letter") t)
263 (delete-region (point-min) (point-max))
264 (insert-file (concat vm-folder-directory ",Formletter")))
266 ; This function bound to C-x C-z
267 (defun load-ange-ftp ()
268 "Load ange-ftp using require, if it isn't loaded already"
270 (message "Loading ange-ftp...")
271 (require 'ange-ftp) ; -extended
272 (message "Loading ange-ftp...done"))
274 ; This function bound to M-+
275 (defun toggle-truncate-lines ()
276 "Toggle truncation or folding of long lines"
278 (set-variable 'truncate-lines (not truncate-lines))
282 ;(setq rmail-file-name "~/mail/RMAIL"
283 ; mail-archive-file-name "~/mail/Outbound"
284 ; rmail-primary-inbox-list '("~/mbox" "~/mail/Outbound" "~/mail/Record"
285 ; "~/mail/Import" "/var/spool/mail/ian")
286 ; rmail-delete-after-output t
287 ; rmail-last-rmail-file ""
288 ; rmail-ignored-headers (concat
289 ; "^Content-Identifier:\\|^X400-[^O][A-Za-z-]+:\\|"
290 ; rmail-ignored-headers))
292 (defun make-regexps-ignore-non-address (list)
293 (apply 'append (mapcar
295 (let ((item (mapconcat
297 (let ((s (char-to-string ch)))
298 (if (string-match "[][.*+?^$\\]" s)
303 (concat "<" item ">")
304 (concat "^" item " *\\((.*)\\)?$"))))
308 (setq bbdb-north-american-phone-numbers-p nil
309 bbdb/mail-auto-create-p t
311 bbdb-notice-auto-save-file-p t
312 bbdb-message-caching-enabled t)
315 (load-file "~/private/private.el")
316 (if (file-exists-p "~/private/private2.el")
317 (load-file "~/private/private2.el"))
318 (setq vm-included-text-attribution-format "%F writes (\"%s\"):\n"
319 vm-reply-subject-prefix "Re: "
320 vm-folder-directory "~/mail/"
321 vm-delete-after-saving t
322 vm-delete-empty-folders t
323 vm-mutable-windows nil
324 vm-auto-get-new-mail nil
325 vm-auto-next-message nil
326 vm-jump-to-new-messages nil
327 vm-jump-to-unread-messages nil
329 vm-included-text-prefix "> "
331 vm-auto-center-summary t
332 vm-confirm-new-folders t
333 vm-circular-folders nil
334 vm-visit-when-saving 0
335 vm-move-after-deleting t
336 vm-keep-sent-messages t
337 vm-follow-summary-cursor t
338 vm-frame-per-composition nil
339 vm-frame-per-edit nil
340 vm-frame-per-summary nil
341 vm-frame-per-folder nil
342 vm-tale-is-an-idiot t
343 vm-primary-inbox (concat vm-folder-directory "INBOX")
344 vm-sysadmin-inbox (concat vm-folder-directory "SINBOX")
345 vm-uninteresting-senders "ian"
346 vm-reply-ignored-addresses
347 (make-regexps-ignore-non-address
348 '("ian@chiark.chu.cam.ac.uk" "ian" "iwj10@cus.cam.ac.uk"
349 "ian@chiark.greenend.org.uk"
350 "ijackson@nyx.cs.du.edu" "ijackson@gnu.ai.mit.edu"))
351 vm-primary-inbox (concat vm-folder-directory "INBOX")
353 vm-uninteresting-senders "ian"
354 vm-reply-ignored-addresses
355 (make-regexps-ignore-non-address
356 '("ijackson@chiark.chu.cam.ac.uk" "ijackson"
357 "iwj10@thor.cam.ac.uk" "iwj10@hermes.cam.ac.uk" "iwj10@cl.cam.ac.uk"
358 "iwj10@cam.ac.uk" "Ian.Jackson@cl.cam.ac.uk"))
359 mail-archive-file-name "~/mail/Outbound"
368 ; "/var/spool/mail/ijackson"
369 (concat "mail:110:pass:iwj:" ijackson-pop-password)
370 "/u/ijackson/mail/INBOX.CRASH"
372 mail-host-address "ncipher.com"
373 user-mail-address "iwj@ncipher.com"
378 ; (list vm-primary-inbox "~/mbox" "~/mail/INBOX.CRASH")
379 ; (list vm-primary-inbox "~/mail/Outbound" "~/mail/INBOX.CRASH")
380 ; (list vm-primary-inbox "~/mail/Record" "~/mail/INBOX.CRASH")
381 ; (list vm-primary-inbox "~/mail/Import" "~/mail/INBOX.CRASH")
382 ; (list vm-primary-inbox "/var/spool/mail/ian" "~/mail/INBOX.CRASH")
383 ; (list vm-primary-inbox "~/News/r" "~/mail/INBOX.CRASH")
384 ; (list vm-sysadmin-inbox "~/mbox" "~/mail/SINBOX.CRASH")
385 ; (list vm-sysadmin-inbox "~/mail/SOutbound" "~/mail/SINBOX.CRASH")
386 ; (list vm-sysadmin-inbox "~/mail/Import" "~/mail/SINBOX.CRASH")
387 ; (list vm-sysadmin-inbox "/var/spool/mail/sysadmin" "~/mail/SINBOX.CRASH")
388 ; (list "/u/ijackson/mail/INBOX" "/u/ijackson/mbox" "/u/ijackson/mail/INBOX.CRASH")
389 ; (list "/u/ijackson/mail/INBOX" "/u/ijackson/mail/Outbound"
390 ; "/u/ijackson/mail/INBOX.CRASH")
391 ; (list "/u/ijackson/mail/INBOX" "/u/ijackson/mail/Record" "/u/ijackson/mail/INBOX.CRASH")
392 ; (list "/u/ijackson/mail/INBOX" "/u/ijackson/mail/Import" "/u/ijackson/mail/INBOX.CRASH")
393 ; (list "/u/ijackson/mail/INBOX"
394 ; (concat "localhost:110:pass:ijackson:" ijackson-pop-password)
395 ; "/u/ijackson/mail/INBOX.CRASH"))
396 vm-startup-with-summary nil
397 vm-summary-format "%3n %a %2d %3m %-19.19F %s\n"
398 mail-archive-file-name "~/mail/Outbound"
399 vm-mime-8bit-text-transfer-encoding '8bit)
401 (add-hook 'vm-mode-hook
403 (local-set-key "Q" 'vm-quit)
404 (local-set-key "q" "###Q")))
405 (add-hook 'mail-mode-hook
407 (if (and (boundp 'folder-buffer)
409 (string= (buffer-file-name folder-buffer)
410 (file-truename vm-sysadmin-inbox)))
412 (make-local-variable 'vm-mail-header-from)
413 (setq vm-mail-header-from
414 "sysadmin@chiark.greenend.org.uk (Ian Jackson)")
415 (make-local-variable 'mail-archive-file-name)
416 (setq mail-archive-file-name
417 "~/mail/SOutbound")))))
421 (vm vm-sysadmin-inbox))
423 (defun make-session ()
424 "Makes this emacs hard to kill by requiring ^X^Cy to kill it
425 instead of just ^X^C."
427 (global-unset-key "
\18\ 3")
428 (global-set-key "
\18\ 3y" 'save-buffers-kill-emacs))
430 ; Fix problems with M-| setting window title of emacs' parent xterm
431 (defun envdelete-term-termcap-windowid (list)
436 (if (or (string-match "^TERM=" x)
437 (string-match "^TERMCAP=" x)
438 (string-match "^WINDOWID=" x))
443 (setq process-environment
444 (envdelete-term-termcap-windowid process-environment))
446 (defun add-insertion-keys (table)
447 "Adds keybindings according to TABLE. Each element of
448 TABLE should be a four-element list.
450 BINDING should be the key to bind; FUNCTION will be the name of the
451 function defined to do the insertion; DESCRIPTION will be inserted
452 into \"Inserts ... .\", and used as the descriptive string for the
453 generated function; STRING is the string which will actually be
454 inserted into the buffer when the keystroke is pressed."
456 (let* ((head (car table))
460 (string (nth 3 head)))
464 (concat "Inserts " desc ".")
466 (list 'insert string)))
467 (funcall 'local-set-key key func))
468 (setq table (cdr table))))
470 (defun ian-sgml-setup ()
473 '(("
\ 3\r" sgml-insert-new-para "new paragraph markup" "\n<p>\n")
474 ("
\ 3\14" sgml-insert-tt-emph "tt emph markup" "<tt/")
475 ("
\ 3\10" sgml-insert-prgn-emph "prgn emph markup" "<prgn/")
476 ("
\ 3\ 5" sgml-insert-em-emph "em emfh markup" "<em/")
477 ("
\ 3\16" sgml-insert-var-empfh "var emph markup" "<var/"))))
478 (setq sgml-local-catalogs '("/jura:/usr/lib/debiandoc-sgml/sgml/catalog"))
480 (add-hook 'sgml-mode-hook 'ian-sgml-setup)
482 (defvar cite-string "> " "String to insert when citing")
484 (defun cite-region (start end)
485 "Quote each line in the region with an angle-bracket and space.
487 The citation string is taken from cite-string."
491 (narrow-to-region start end)
492 (goto-char (point-min))
497 (> (point-max) (point)))
498 (insert cite-string)))))