1 ; This is my real emacs start-up file (for chiark).
4 (defalias 'perl-mode 'cperl-mode)
5 (setq cperl-invalid-face nil
8 (make-variable-buffer-local 'indent-line-function)
9 ; Un-disable narrow and eval-expression
10 (put 'narrow-to-region 'disabled nil)
11 (put 'eval-expression 'disabled nil)
12 (standard-display-european t)
14 (setq browse-url-netscape-program "mozilla")
15 (setq common-lisp-hyperspec-root "/usr/share/doc/hyperspec/")
17 ; Make sure we don't disturb links or change ownership, use numbers
18 (setq backup-by-copying-when-mismatch t)
19 (setq backup-by-copying-when-linked t)
20 ;(setq version-control t
23 ; trim-versions-without-asking t)
26 (setq require-final-newline "ask")
27 (if (string= window-system 'x) (load-library "ian-x"))
28 (load-library "ian-aliases")
29 ; (load-library "auto-pgp")
30 ; (load-library "debian-changelog-mode")
31 ; (if (string= (getenv "TERM") "bbcb32") (setq term-file-prefix nil))
32 ; (setq explicit-shell-file-name "/usr/local/bin/tcsh")
33 (setq inhibit-local-variables t)
34 (setq enable-local-variables 'ask-me)
35 (setq enable-recursive-minibuffers t)
36 (setq compile-command "make")
37 (setq next-line-add-newlines t)
38 (setq diff-switches "-u")
39 (setq line-move-visual nil)
42 (set-variable 'search-repeat-char 28)
43 (set-fringe-mode (cons 0 nil))
44 (if (string-match "^19\." emacs-version)
46 ; (setq file-name-handler-alist ; Disable nasty auto-loading of ange-ftp
47 ; (delq (rassq 'ange-ftp-completion-hook-function file-name-handler-alist)
48 ; file-name-handler-alist))
49 (require 'find-alternate-18style)
50 (defun unset-down-mouse-23 ()
51 (local-set-key [mouse-2] 'mouse-yank-at-click)
52 (local-unset-key [down-mouse-2])
53 (local-unset-key [down-mouse-3])
54 (local-unset-key [C-down-mouse-3]))
55 (add-hook 'vm-mode-hook 'unset-down-mouse-23)
56 (add-hook 'vm-mail-mode-hook 'unset-down-mouse-23)
57 (add-hook 'text-mode-hook 'unset-down-mouse-23)
58 (add-hook 'Info-mode-hook
60 (local-set-key " " 'scroll-up)
61 (local-set-key "
\7f" 'scroll-down))))
62 (define-key isearch-mode-map "
\1c" 'isearch-repeat-forward)
63 (define-key isearch-mode-map "
\1d" 'isearch-quote-char)))
66 (defun terminal-keybindings ()
67 "This function should be called by the term-setup-hook mechanism"
69 ; Set my own keybindings
71 ; Set keybindings generally (including I-search on C-\)
72 ; (global-set-key " " 'self-insert-command)
73 (global-set-key "
\1c" 'isearch-forward)
74 ; (global-set-key "
\r" 'newline)
75 (global-set-key "
\ f" 'set-mark-command)
76 (global-set-key "
\1d" 'quoted-insert)
78 ; Set keybindings on esc-map
79 (global-set-key "
\e#" 'query-replace-regexp)
80 (global-set-key "
\e+" 'toggle-truncate-lines)
81 (global-set-key "
\eg" 'goto-line)
82 (global-set-key "
\es" 'isearch-forward-regexp)
83 (global-set-key "
\e\e" 'eval-expression)
85 ; Set keybindings on ^X-map.
86 (global-set-key "
\18m" 'vm-mail)
87 (global-set-key "
\18\1c" 'save-buffer)
88 (global-set-key "
\18\1d" 'toggle-read-only)
89 (global-set-key "
\18#" 'recover-file)
90 (global-set-key "
\18\12" 'bury-buffer)
91 (global-set-key "
\18\v" 'quicker-compile)
92 (global-set-key "
\18\18" 'exchange-point-and-mark)
93 (global-set-key "
\18\1a" 'load-tramp)
94 (global-set-key "
\184
\16" 'scroll-other-window)
95 (global-set-key "
\184m" 'vm-mail-other-window)
96 (global-set-key "
\189" 'vm-visit-folder)
97 (global-set-key "
\188" 'rmail-input)
98 (global-set-key "
\18p" 'cite-region)
99 (global-set-key "
\18F" 'mail-formletter)
101 ; Set keybindings for Sun numeric pad.
102 (setq esc-bracket-map (make-keymap))
103 (define-key esc-bracket-map "D" 'backward-char)
104 (define-key esc-bracket-map "C" 'forward-char)
105 (define-key esc-bracket-map "A" 'previous-line)
106 (define-key esc-bracket-map "B" 'next-line)
107 (define-key esc-map "[" esc-bracket-map)
108 (global-set-key "\e[214z" 'beginning-of-buffer)
109 (global-set-key "\e[220z" 'end-of-buffer)
110 (global-set-key "\e[216z" 'scroll-down)
111 (global-set-key "\e[222z" 'scroll-up)
112 (global-set-key "\e[192z" 'save-buffer)
113 (global-set-key "\e[194z" 'save-some-buffers)
114 (global-set-key "\e[195z" 'undo)
115 (global-set-key "\e[193z" 'call-last-kbd-macro)
116 (global-set-key "\e[196z" 'switch-to-buffer-other-window)
117 (global-set-key "\e[197z" 'copy-region-as-kill)
118 (global-set-key "\e[198z" 'find-file)
119 (global-set-key "\e[199z" 'yank)
120 (global-set-key "\e[198z" 'find-alternate-file)
121 (global-set-key "\e[200z" 'find-file)
122 (global-set-key "\e[201z" 'kill-region)
123 (global-set-key "\e[-1z" 'info)
125 ; Set keybindings for Chiarks' x11emacs
126 (global-set-key "
\e[5~" 'scroll-down)
127 (global-set-key "
\e[6~" 'scroll-up)
129 ; Set keybindings for knackered vt100-like terminal emulators.
130 (global-set-key "\eOt" 'scroll-down)
131 (global-set-key "\eOu" 'scroll-up)
132 (global-set-key "\eOD" 'backward-char)
133 (global-set-key "\eOC" 'forward-char)
134 (global-set-key "\eOA" 'previous-line)
135 (global-set-key "\eOB" 'next-line))
136 (setq term-setup-hook 'terminal-keybindings) ; remap keys in due course
138 ; Autoload definitions
139 (autoload 'tar-mode "tar-mode")
140 (autoload 'uncompress-while-visiting "uncompress")
141 ; (autoload 'c++-mode "c++-mode" "Mode for editing C and C++ programs" t)
142 (autoload 'hide-ifdef-mode "hideif" "For editing code with #ifdefs" t)
143 ;(setq-default indent-tabs-mode nil)
144 (autoload 'dired-find-alternate-file "dired-alternate" "Find alternately" t)
145 (autoload 'dired-run-file "dired-alternate" "Run this file" t)
146 (autoload 'perl-mode "perl-mode" "Mode for Perl code" t)
147 ; (autoload 'rmail "rmail-fixed" "Patched mail reader" t)
148 (autoload 'quicker-compile "quicker-compile" "Patched Compile mode" t)
150 (autoload 'vm "vm" "Start VM on your primary inbox." t)
151 (autoload 'vm-visit-folder "vm" "Start VM on an arbitrary folder." t)
152 (autoload 'vm-visit-virtual-folder "vm" "Visit a VM virtual folder." t)
153 (autoload 'vm-mode "vm" "Run VM major mode on a buffer" t)
154 (autoload 'vm-mail "vm" "Send a mail message using VM." t)
155 (autoload 'vm-submit-bug-report "vm" "Send a bug report about VM." t)
157 ; (autoload 'info "info-fixed" "Patched info browser" t)
158 (setq shell-mode-hook
160 (make-variable-buffer-local 'scroll-step)
161 (setq scroll-step 1)))
162 (setq inferior-lisp-program "sbcl")
163 ;(setq jit-lock-chunk-size 100
164 ; jit-lock-stealth-time 1.00)
165 (setq dired-mode-hook
167 (define-key dired-mode-map "F" 'dired-find-alternate-file)
168 (define-key dired-mode-map "X" 'dired-run-file)))
170 ; Prevent loading of default init file and do some of the things it did
171 ; (setq inhibit-default-init t)
173 ; Additional alist handling function
174 ;(defun alist-remove-elem (s s-list)
175 ; "Delete the element of the alist S-LIST whose car is S"
176 ; (if s-list (if (equal s (car (car s-list)))
178 ; (cons (car s-list) (alist-remove-elem s (cdr s-list))))
181 ; Load C++ mode and edit Perl in perl mode
182 (setq auto-mode-alist
183 (append '(("\\.[ch]$" . c-mode)
184 ("\\.[CH]$" . c++-mode)
185 ("\\.cc$" . c++-mode)
186 ("\\.hh$" . c++-mode)
187 ; ("\\.tar$" . tar-mode)
188 ("\\.pl$" . perl-mode)
189 ("\\.ci$" . tex-mode)
190 ("\\.asm$" . fundamental-mode)
191 ("\\.Z$" . uncompress-while-visiting))
193 (setq interpreter-mode-alist
194 (append '(("sh" . fundamental-mode)
195 ("bash" . fundamental-mode))
196 interpreter-mode-alist))
198 ; Use auto-fill when editing text
199 (add-hook 'text-mode-hook '(lambda () (auto-fill-mode 1)))
200 ; (add-hook 'text-mode-hook '(lambda () (local-set-key " " 'self-insert-command)))
202 ; Set up newline to auto-indent & other stuff for perl, c++ and c modes.
203 (setq perl-mode-hook '(lambda ()
204 (local-set-key ";" 'self-insert-command)))
205 (setq c++-mode-hook '(lambda ()
207 (local-set-key "," 'self-insert-command)
208 (local-set-key ":" 'electric-c++-terminator)))
210 (setq c-mode-hook '(lambda ()
212 (c-set-offset 'substatement-open 0 nil)
213 (local-set-key "," 'self-insert-command)
214 (local-set-key ";" 'self-insert-command)
215 (local-set-key "/" 'self-insert-command)
216 (local-set-key "*" 'self-insert-command)
217 (local-set-key "#" 'self-insert-command)
218 (local-set-key "(" 'self-insert-command)
219 (local-set-key ")" 'self-insert-command)
220 (local-set-key "{" 'self-insert-command)
221 (local-set-key "
\r" 'newline-and-indent)))
222 (setq c-hanging-comment-ender-p nil)
224 (defun vm-mail-other-window ()
225 "Like `vm-mail' command, but display buffer in another window."
227 (switch-to-buffer-other-window (current-buffer))
231 (setq mail-precedence-key-alist
232 '((?0 . "special-delivery")
235 (?3 . "second-class")
241 (defun mail-precedence-as-key ()
242 "Set precedence by looking up last command char in mail-precedence-key-alist"
244 (message "%s" (concat "Precedence ["
245 (mapconcat '(lambda (c) (char-to-string (car c)))
246 mail-precedence-key-alist "")
248 (let* ((key (read-char))
249 (prec (assoc key mail-precedence-key-alist)))
250 (if prec (mail-precedence (cdr prec))
251 (error "mail-precedence-as-key `%s' not found" key))))
253 (defun mail-precedence-as-key-send-and-exit (arg)
254 "Set precedence by looking up last command char in mail-precedence-key-alist,
255 then call send-and-exit."
257 (mail-precedence-as-key)
258 (execute-kbd-macro "
\ 3\ 3"))
260 (defun mail-precedence (prec)
262 (mail-position-on-field "Precedence")
265 (delete-region (point) p)
267 (insert "Precedence: " prec)
270 (defun mail-mode-setup-keys ()
271 (local-set-key "
\ 3\10" 'mail-precedence-as-key)
272 (local-set-key "
\ 3p" 'mail-precedence-as-key-send-and-exit))
273 (add-hook 'mail-mode-hook 'mail-mode-setup-keys)
274 (add-hook 'vm-mail-mode-hook 'mail-mode-setup-keys)
276 (defun vm-mail-other-window ()
277 "Like `vm-mail' command, but display buffer in another window."
279 (switch-to-buffer-other-window (current-buffer))
282 (defun mail-formletter ()
283 "Run VM-mail with ,Formletter"
286 (rename-buffer (generate-new-buffer-name "form letter") t)
287 (delete-region (point-min) (point-max))
288 (insert-file (concat vm-folder-directory ",Formletter")))
290 ; This function bound to C-x C-z
292 "Load tramp using require, if it isn't loaded already"
294 (message "Loading tramp...")
295 (require 'tramp) ; -extended
296 (message "Loading tramp...done"))
298 ; This function bound to M-+
299 (defun toggle-truncate-lines ()
300 "Toggle truncation or folding of long lines"
302 (set-variable 'truncate-lines (not truncate-lines))
306 ;(setq rmail-file-name "~/mail/RMAIL"
307 ; mail-archive-file-name "~/mail/Outbound"
308 ; rmail-primary-inbox-list '("~/mbox" "~/mail/Outbound" "~/mail/Record"
309 ; "~/mail/Import" "/var/spool/mail/ian")
310 ; rmail-delete-after-output t
311 ; rmail-last-rmail-file ""
312 ; rmail-ignored-headers (concat
313 ; "^Content-Identifier:\\|^X400-[^O][A-Za-z-]+:\\|"
314 ; rmail-ignored-headers))
316 (defun make-regexps-ignore-non-address (list)
317 (apply 'append (mapcar
319 (let ((item (mapconcat
321 (let ((s (char-to-string ch)))
322 (if (string-match "[][.*+?^$\\]" s)
327 (concat "<" item ">")
328 (concat "^" item " *\\((.*)\\)?$"))))
332 (setq bbdb-north-american-phone-numbers-p nil
333 bbdb/mail-auto-create-p t
335 bbdb-notice-auto-save-file-p t
336 bbdb-message-caching-enabled t)
339 ;(load-file "~/private/private.el")
340 (if (file-exists-p "~/private/private2.el")
341 (load-file "~/private/private2.el"))
342 (setq vm-included-text-attribution-format "%F writes (\"%s\"):\n"
343 vm-reply-subject-prefix "Re: "
344 vm-folder-directory "~/mail/"
345 vm-delete-after-saving t
346 vm-delete-empty-folders t
348 vm-auto-get-new-mail nil
349 vm-auto-next-message nil
350 vm-jump-to-new-messages nil
351 vm-jump-to-unread-messages nil
352 vm-mime-digest-discard-header-regexp "only-drop-this-header"
354 vm-included-text-prefix "> "
356 vm-auto-center-summary t
357 vm-confirm-new-folders t
358 vm-circular-folders nil
359 vm-visit-when-saving 0
360 vm-move-after-deleting t
361 vm-keep-sent-messages t
362 vm-follow-summary-cursor t
363 vm-frame-per-composition nil
364 vm-frame-per-edit nil
365 vm-frame-per-summary nil
366 vm-frame-per-folder nil
367 vm-tale-is-an-idiot t
368 vm-primary-inbox (concat vm-folder-directory "INBOX")
369 vm-sinbin-inbox (concat vm-folder-directory "SINBOX")
370 vm-uninteresting-senders "ian"
371 vm-reply-ignored-addresses
372 (make-regexps-ignore-non-address
373 '("ian@chiark.chu.cam.ac.uk" "ian" "iwj10@cus.cam.ac.uk"
374 "ian@chiark.greenend.org.uk"
375 "ijackson@nyx.cs.du.edu" "ijackson@gnu.ai.mit.edu"))
376 vm-primary-inbox (concat vm-folder-directory "INBOX")
378 vm-uninteresting-senders "ian"
379 vm-reply-ignored-addresses
380 (make-regexps-ignore-non-address
381 '("ijackson@chiark.chu.cam.ac.uk" "ijackson"
382 "iwj10@thor.cam.ac.uk" "iwj10@hermes.cam.ac.uk" "iwj10@cl.cam.ac.uk"
383 "iwj10@cam.ac.uk" "Ian.Jackson@cl.cam.ac.uk"))
384 mail-archive-file-name "~/mail/Outbound"
388 '((vm-primary-inbox "/var/spool/mail/ian"
389 "~/mail/INBOX.CRASH")
390 (vm-primary-inbox "~/News/r" "~/mail/INBOX.CRASH")
391 (vm-primary-inbox "~/mbox" "~/mail/INBOX.CRASH")
392 (vm-primary-inbox "~/mail/Outbound" "~/mail/INBOX.CRASH")
393 (vm-primary-inbox "~/mail/Import" "~/mail/INBOX.CRASH")
394 (vm-primary-inbox "~/mail/Record" "~/mail/INBOX.CRASH")
395 (vm-sinbin-inbox "/var/spool/mail/ian" "~/mail/SINBOX.CRASH"))
396 vm-startup-with-summary t
398 user-mail-address "ijackson@chiark.greenend.org.uk"
403 ; (list vm-primary-inbox "~/mbox" "~/mail/INBOX.CRASH")
404 ; (list vm-primary-inbox "~/mail/Outbound" "~/mail/INBOX.CRASH")
405 ; (list vm-primary-inbox "~/mail/Record" "~/mail/INBOX.CRASH")
406 ; (list vm-primary-inbox "~/mail/Import" "~/mail/INBOX.CRASH")
407 ; (list vm-primary-inbox "/var/spool/mail/ian" "~/mail/INBOX.CRASH")
408 ; (list vm-primary-inbox "~/News/r" "~/mail/INBOX.CRASH")
409 ; (list vm-sysadmin-inbox "~/mbox" "~/mail/SINBOX.CRASH")
410 ; (list vm-sysadmin-inbox "~/mail/SOutbound" "~/mail/SINBOX.CRASH")
411 ; (list vm-sysadmin-inbox "~/mail/Import" "~/mail/SINBOX.CRASH")
412 ; (list vm-sysadmin-inbox "/var/spool/mail/sysadmin" "~/mail/SINBOX.CRASH")
413 ; (list "/u/ijackson/mail/INBOX" "/u/ijackson/mbox" "/u/ijackson/mail/INBOX.CRASH")
414 ; (list "/u/ijackson/mail/INBOX" "/u/ijackson/mail/Outbound"
415 ; "/u/ijackson/mail/INBOX.CRASH")
416 ; (list "/u/ijackson/mail/INBOX" "/u/ijackson/mail/Record" "/u/ijackson/mail/INBOX.CRASH")
417 ; (list "/u/ijackson/mail/INBOX" "/u/ijackson/mail/Import" "/u/ijackson/mail/INBOX.CRASH")
418 ; (list "/u/ijackson/mail/INBOX"
419 ; (concat "localhost:110:pass:ijackson:" ijackson-pop-password)
420 ; "/u/ijackson/mail/INBOX.CRASH"))
421 vm-startup-with-summary nil
422 vm-summary-format "%3n %a %2d %3m %-19.19F %s\n"
423 mail-archive-file-name "~/mail/Outbound"
424 vm-mime-8bit-text-transfer-encoding '8bit)
426 (add-hook 'vm-mode-hook
428 (local-set-key "Q" 'vm-quit)
429 (local-set-key "q" "###Q")))
430 (add-hook 'mail-mode-hook
432 (if (and (boundp 'folder-buffer)
434 (string= (buffer-file-name folder-buffer)
435 (file-truename vm-sysadmin-inbox)))
437 (make-local-variable 'vm-mail-header-from)
438 (setq vm-mail-header-from
439 "sysadmin@chiark.greenend.org.uk (Ian Jackson)")
440 (make-local-variable 'mail-archive-file-name)
441 (setq mail-archive-file-name
442 "~/mail/SOutbound")))))
446 ; (vm "/u/ijackson/mail/INBOX"))
450 (vm vm-sinbin-inbox))
452 (defun make-session ()
453 "Makes this emacs hard to kill by requiring ^X^Cy to kill it
454 instead of just ^X^C."
456 (global-unset-key "
\18\ 3")
457 (global-set-key "
\18\ 3y" 'save-buffers-kill-emacs))
459 ; Fix problems with M-| setting window title of emacs' parent xterm
460 (defun envdelete-term-termcap-windowid (list)
465 (if (or (string-match "^TERM=" x)
466 (string-match "^TERMCAP=" x)
467 (string-match "^WINDOWID=" x))
472 (setq process-environment
473 (envdelete-term-termcap-windowid process-environment))
475 (defun add-insertion-keys (table)
476 "Adds keybindings according to TABLE. Each element of
477 TABLE should be a four-element list.
479 BINDING should be the key to bind; FUNCTION will be the name of the
480 function defined to do the insertion; DESCRIPTION will be inserted
481 into \"Inserts ... .\", and used as the descriptive string for the
482 generated function; STRING is the string which will actually be
483 inserted into the buffer when the keystroke is pressed."
485 (let* ((head (car table))
489 (string (nth 3 head)))
493 (concat "Inserts " desc ".")
495 (list 'insert string)))
496 (funcall 'local-set-key key func))
497 (setq table (cdr table))))
499 (defun ian-sgml-setup ()
502 '(("
\ 3\r" sgml-insert-new-para "new paragraph markup" "\n<p>\n")
503 ("
\ 3\14" sgml-insert-tt-emph "tt emph markup" "<tt/")
504 ("
\ 3\10" sgml-insert-prgn-emph "prgn emph markup" "<prgn/")
505 ("
\ 3\ 5" sgml-insert-em-emph "em emfh markup" "<em/")
506 ("
\ 3\16" sgml-insert-var-empfh "var emph markup" "<var/"))))
507 (setq sgml-local-catalogs '("/jura:/usr/lib/debiandoc-sgml/sgml/catalog"))
509 (add-hook 'sgml-mode-hook 'ian-sgml-setup)
511 (defvar cite-string "> " "String to insert when citing")
513 (defun cite-region (start end)
514 "Quote each line in the region with an angle-bracket and space.
516 The citation string is taken from cite-string."
520 (narrow-to-region start end)
521 (goto-char (point-min))
526 (> (point-max) (point)))
527 (insert cite-string)))))