1 ; This is my real emacs start-up file (for chiark).
4 (defalias 'perl-mode 'cperl-mode)
5 (setq cperl-invalid-face nil
7 cperl-continued-statement-offset 4)
9 (make-variable-buffer-local 'indent-line-function)
10 ; Un-disable narrow and eval-expression
11 (put 'narrow-to-region 'disabled nil)
12 (put 'eval-expression 'disabled nil)
13 ;(standard-display-european t)
15 (setq browse-url-netscape-program "mozilla")
16 (setq common-lisp-hyperspec-root "/usr/share/doc/hyperspec/")
18 ; Make sure we don't disturb links or change ownership, use numbers
19 (setq backup-by-copying-when-mismatch t)
20 (setq backup-by-copying-when-linked t)
21 ;(setq version-control t
24 ; trim-versions-without-asking t)
27 (setq require-final-newline "ask")
28 (if (string= window-system 'x) (load-library "ian-x"))
29 (load-library "ian-aliases")
30 ; (load-library "auto-pgp")
31 ; (load-library "debian-changelog-mode")
32 ; (if (string= (getenv "TERM") "bbcb32") (setq term-file-prefix nil))
33 ; (setq explicit-shell-file-name "/usr/local/bin/tcsh")
34 (setq inhibit-local-variables t)
35 (setq enable-local-variables 'ask-me)
36 (setq enable-recursive-minibuffers t)
37 (setq compile-command "make")
38 (setq next-line-add-newlines t)
39 (setq diff-switches "-u")
40 (setq line-move-visual nil)
43 (set-default 'indent-line-function 'insert-tab)
44 (set-default 'electric-indent-mode nil)
45 (set-variable 'search-repeat-char 28)
46 (set-fringe-mode (cons 0 nil))
47 (if (string-match "^19\." emacs-version)
49 ; (setq file-name-handler-alist ; Disable nasty auto-loading of ange-ftp
50 ; (delq (rassq 'ange-ftp-completion-hook-function file-name-handler-alist)
51 ; file-name-handler-alist))
52 (require 'find-alternate-18style)
53 (defun unset-down-mouse-23 ()
54 (local-set-key [mouse-2] 'mouse-yank-at-click)
55 (local-unset-key [down-mouse-2])
56 (local-unset-key [down-mouse-3])
57 (local-unset-key [C-down-mouse-3]))
58 (add-hook 'vm-mode-hook 'unset-down-mouse-23)
59 (add-hook 'vm-mail-mode-hook 'unset-down-mouse-23)
60 (add-hook 'text-mode-hook 'unset-down-mouse-23)
61 (add-hook 'Info-mode-hook
63 (local-set-key " " 'scroll-up)
64 (local-set-key "
\7f" 'scroll-down))))
65 (add-hook 'sh-mode-hook
67 (local-set-key "<" 'self-insert-command))))
68 (define-key isearch-mode-map "
\1c" 'isearch-repeat-forward)
69 (define-key isearch-mode-map "
\1d" 'isearch-quote-char)))
72 (defun terminal-keybindings ()
73 "This function should be called by the term-setup-hook mechanism"
75 ; Set my own keybindings
77 ; Set keybindings generally (including I-search on C-\)
78 ; (global-set-key " " 'self-insert-command)
79 (global-set-key "
\1c" 'isearch-forward)
80 ; (global-set-key "
\r" 'newline)
81 (global-set-key "
\ f" 'set-mark-command)
82 (global-set-key "
\1d" 'quoted-insert)
84 ; Set keybindings on esc-map
85 (global-set-key "
\e#" 'query-replace-regexp)
86 (global-set-key "
\e+" 'toggle-truncate-lines)
87 (global-set-key "
\eg" 'goto-line)
88 (global-set-key "
\es" 'isearch-forward-regexp)
89 (global-set-key "
\e\e" 'eval-expression)
91 ; Set keybindings on ^X-map.
92 (global-set-key "
\18m" 'vm-mail)
93 (global-set-key "
\18\1c" 'save-buffer)
94 (global-set-key "
\18\1d" 'toggle-read-only)
95 (global-set-key "
\18#" 'recover-file)
96 (global-set-key "
\18\12" 'bury-buffer)
97 (global-set-key "
\18\v" 'quicker-compile)
98 (global-set-key "
\18\18" 'exchange-point-and-mark)
99 (global-set-key "
\18\1a" 'load-tramp)
100 (global-set-key "
\184
\16" 'scroll-other-window)
101 (global-set-key "
\184m" 'vm-mail-other-window)
102 (global-set-key "
\189" 'vm-visit-folder)
103 (global-set-key "
\188" 'rmail-input)
104 (global-set-key "
\18p" 'cite-region)
105 (global-set-key "
\18F" 'mail-formletter)
107 ; Set keybindings for Sun numeric pad.
108 (setq esc-bracket-map (make-keymap))
109 (define-key esc-bracket-map "D" 'backward-char)
110 (define-key esc-bracket-map "C" 'forward-char)
111 (define-key esc-bracket-map "A" 'previous-line)
112 (define-key esc-bracket-map "B" 'next-line)
113 (define-key esc-map "[" esc-bracket-map)
114 (global-set-key "\e[214z" 'beginning-of-buffer)
115 (global-set-key "\e[220z" 'end-of-buffer)
116 (global-set-key "\e[216z" 'scroll-down)
117 (global-set-key "\e[222z" 'scroll-up)
118 (global-set-key "\e[192z" 'save-buffer)
119 (global-set-key "\e[194z" 'save-some-buffers)
120 (global-set-key "\e[195z" 'undo)
121 (global-set-key "\e[193z" 'call-last-kbd-macro)
122 (global-set-key "\e[196z" 'switch-to-buffer-other-window)
123 (global-set-key "\e[197z" 'copy-region-as-kill)
124 (global-set-key "\e[198z" 'find-file)
125 (global-set-key "\e[199z" 'yank)
126 (global-set-key "\e[198z" 'find-alternate-file)
127 (global-set-key "\e[200z" 'find-file)
128 (global-set-key "\e[201z" 'kill-region)
129 (global-set-key "\e[-1z" 'info)
131 ; Set keybindings for Chiarks' x11emacs
132 (global-set-key "
\e[5~" 'scroll-down)
133 (global-set-key "
\e[6~" 'scroll-up)
135 ; Set keybindings for knackered vt100-like terminal emulators.
136 (global-set-key "\eOt" 'scroll-down)
137 (global-set-key "\eOu" 'scroll-up)
138 (global-set-key "\eOD" 'backward-char)
139 (global-set-key "\eOC" 'forward-char)
140 (global-set-key "\eOA" 'previous-line)
141 (global-set-key "\eOB" 'next-line))
142 (setq term-setup-hook 'terminal-keybindings) ; remap keys in due course
144 (setq frame-title-format
148 ((buf (current-buffer))
149 (leaf (buffer-name buf))
150 (dir default-directory))
153 ((dir (abbreviate-file-name dir))
154 (node (replace-regexp-in-string "\\..*" "" system-name)))
155 (concat leaf " " node ":" dir))
157 ("" invocation-name "@" system-name)))
158 ;(setq frame-title-format
162 ; ((buf (current-buffer))
163 ; (fn (buffer-file-name buf)))
166 ; ((fn (abbreviate-file-name fn))
167 ; (dir (file-name-directory fn))
168 ; (leaf (file-name-nondirectory fn))
169 ; (node (replace-regexp-in-string "\\..*" "" system-name)))
170 ; (concat leaf " " node ":" dir))
171 ; (buffer-name buf))))
172 ; ("" invocation-name "@" system-name)))
174 ; Autoload definitions
175 (autoload 'tar-mode "tar-mode")
176 (autoload 'uncompress-while-visiting "uncompress")
177 ; (autoload 'c++-mode "c++-mode" "Mode for editing C and C++ programs" t)
178 (autoload 'hide-ifdef-mode "hideif" "For editing code with #ifdefs" t)
179 ;(setq-default indent-tabs-mode nil)
180 (autoload 'dired-find-alternate-file "dired-alternate" "Find alternately" t)
181 (autoload 'dired-run-file "dired-alternate" "Run this file" t)
182 (autoload 'perl-mode "perl-mode" "Mode for Perl code" t)
183 ; (autoload 'rmail "rmail-fixed" "Patched mail reader" t)
184 (autoload 'quicker-compile "quicker-compile" "Patched Compile mode" t)
186 ;(autoload 'vm "vm" "Start VM on your primary inbox." t)
187 ;(autoload 'vm-visit-folder "vm" "Start VM on an arbitrary folder." t)
188 ;(autoload 'vm-visit-virtual-folder "vm" "Visit a VM virtual folder." t)
189 ;(autoload 'vm-mode "vm" "Run VM major mode on a buffer" t)
190 ;(autoload 'vm-mail "vm" "Send a mail message using VM." t)
191 ;(autoload 'vm-submit-bug-report "vm" "Send a bug report about VM." t)
193 ;(require 'vm-autoload)
195 (vm-legacy-key-bindings)
197 ; (autoload 'info "info-fixed" "Patched info browser" t)
198 (setq shell-mode-hook
200 (make-variable-buffer-local 'scroll-step)
201 (setq scroll-step 1)))
202 (setq inferior-lisp-program "sbcl")
203 ;(setq jit-lock-chunk-size 100
204 ; jit-lock-stealth-time 1.00)
205 (setq dired-mode-hook
207 (define-key dired-mode-map "F" 'dired-find-alternate-file)
208 (define-key dired-mode-map "X" 'dired-run-file)))
210 ; Prevent loading of default init file and do some of the things it did
211 ; (setq inhibit-default-init t)
213 ; Additional alist handling function
214 ;(defun alist-remove-elem (s s-list)
215 ; "Delete the element of the alist S-LIST whose car is S"
216 ; (if s-list (if (equal s (car (car s-list)))
218 ; (cons (car s-list) (alist-remove-elem s (cdr s-list))))
221 ; Load C++ mode and edit Perl in perl mode
222 (setq auto-mode-alist
223 (append '(("\\.[ch]$" . c-mode)
224 ("\\.[CH]$" . c++-mode)
225 ("\\.cc$" . c++-mode)
226 ("\\.hh$" . c++-mode)
227 ; ("\\.tar$" . tar-mode)
228 ("\\.pl$" . perl-mode)
229 ("\\.ci$" . tex-mode)
230 ("\\.asm$" . fundamental-mode)
231 ("\\.Z$" . uncompress-while-visiting))
233 (setq interpreter-mode-alist
234 (append '(("sh" . fundamental-mode)
235 ("bash" . fundamental-mode))
236 interpreter-mode-alist))
238 ; Use auto-fill when editing text
239 (add-hook 'text-mode-hook '(lambda () (auto-fill-mode 1)))
240 ; (add-hook 'text-mode-hook '(lambda () (local-set-key " " 'self-insert-command)))
242 ; Set up newline to auto-indent & other stuff for perl, c++ and c modes.
243 (setq perl-mode-hook '(lambda ()
244 (local-set-key ";" 'self-insert-command)))
245 (setq c++-mode-hook '(lambda ()
247 (local-set-key "," 'self-insert-command)
248 (local-set-key ":" 'electric-c++-terminator)))
250 (setq c-mode-hook '(lambda ()
252 (c-set-offset 'substatement-open 0 nil)
253 (local-set-key "," 'self-insert-command)
254 (local-set-key ";" 'self-insert-command)
255 (local-set-key "/" 'self-insert-command)
256 (local-set-key "*" 'self-insert-command)
257 (local-set-key "#" 'self-insert-command)
258 (local-set-key "(" 'self-insert-command)
259 (local-set-key ")" 'self-insert-command)
260 (local-set-key "{" 'self-insert-command)
261 (local-set-key "
\r" 'newline-and-indent)))
262 (setq c-hanging-comment-ender-p nil)
264 (defun vm-mail-other-window ()
265 "Like `vm-mail' command, but display buffer in another window."
267 (switch-to-buffer-other-window (current-buffer))
271 (setq mail-precedence-key-alist
272 '((?0 . "special-delivery")
275 (?3 . "second-class")
281 (defun mail-precedence-as-key ()
282 "Set precedence by looking up last command char in mail-precedence-key-alist"
284 (message "%s" (concat "Precedence ["
285 (mapconcat '(lambda (c) (char-to-string (car c)))
286 mail-precedence-key-alist "")
288 (let* ((key (read-char))
289 (prec (assoc key mail-precedence-key-alist)))
290 (if prec (mail-precedence (cdr prec))
291 (error "mail-precedence-as-key `%s' not found" key))))
293 (defun mail-precedence-as-key-send-and-exit (arg)
294 "Set precedence by looking up last command char in mail-precedence-key-alist,
295 then call send-and-exit."
297 (mail-precedence-as-key)
298 (execute-kbd-macro "
\ 3\ 3"))
300 (defun mail-precedence (prec)
302 (mail-position-on-field "Precedence")
305 (delete-region (point) p)
307 (insert "Precedence: " prec)
310 (defun mail-mode-setup-keys ()
311 (local-set-key "
\ 3\10" 'mail-precedence-as-key)
312 (local-set-key "
\ 3p" 'mail-precedence-as-key-send-and-exit))
313 (add-hook 'mail-mode-hook 'mail-mode-setup-keys)
314 (add-hook 'vm-mail-mode-hook 'mail-mode-setup-keys)
316 (defun vm-mail-other-window ()
317 "Like `vm-mail' command, but display buffer in another window."
319 (switch-to-buffer-other-window (current-buffer))
322 (defun mail-formletter ()
323 "Run VM-mail with ,Formletter"
326 (rename-buffer (generate-new-buffer-name "form letter") t)
327 (delete-region (point-min) (point-max))
328 (insert-file (concat vm-folder-directory ",Formletter")))
330 ; This function bound to C-x C-z
332 "Load tramp using require, if it isn't loaded already"
334 (message "Loading tramp...")
335 (require 'tramp) ; -extended
336 (message "Loading tramp...done"))
338 ; This function bound to M-+
339 (defun toggle-truncate-lines ()
340 "Toggle truncation or folding of long lines"
342 (set-variable 'truncate-lines (not truncate-lines))
346 ;(setq rmail-file-name "~/mail/RMAIL"
347 ; mail-archive-file-name "~/mail/Outbound"
348 ; rmail-primary-inbox-list '("~/mbox" "~/mail/Outbound" "~/mail/Record"
349 ; "~/mail/Import" "/var/spool/mail/ian")
350 ; rmail-delete-after-output t
351 ; rmail-last-rmail-file ""
352 ; rmail-ignored-headers (concat
353 ; "^Content-Identifier:\\|^X400-[^O][A-Za-z-]+:\\|"
354 ; rmail-ignored-headers))
356 (defun make-regexps-ignore-non-address (list)
357 (apply 'append (mapcar
359 (let ((item (mapconcat
361 (let ((s (char-to-string ch)))
362 (if (string-match "[][.*+?^$\\]" s)
367 (concat "<" item ">")
368 (concat "^" item " *\\((.*)\\)?$"))))
372 (setq bbdb-north-american-phone-numbers-p nil
373 bbdb/mail-auto-create-p t
375 bbdb-notice-auto-save-file-p t
376 bbdb-message-caching-enabled t)
379 (if (file-exists-p "~/private/private.el")
380 (load-file "~/private/private.el"))
381 (if (file-exists-p "~/private/private2.el")
382 (load-file "~/private/private2.el"))
383 (setq vm-included-text-attribution-format "%F writes (\"%s\"):\n"
384 vm-reply-subject-prefix "Re: "
385 vm-folder-directory "~/mail/"
386 vm-delete-after-saving t
387 vm-delete-empty-folders t
389 vm-auto-get-new-mail nil
390 vm-auto-next-message nil
391 vm-jump-to-new-messages nil
392 vm-jump-to-unread-messages nil
393 vm-auto-displayed-mime-content-types '("text" "multipart")
394 vm-mime-digest-discard-header-regexp "only-drop-this-header"
396 vm-included-text-prefix "> "
398 vm-auto-center-summary t
399 vm-confirm-new-folders t
400 vm-circular-folders nil
401 vm-visit-when-saving 0
402 vm-move-after-deleting t
403 vm-keep-sent-messages t
404 vm-follow-summary-cursor t
405 vm-frame-per-composition nil
406 vm-frame-per-edit nil
407 vm-frame-per-summary nil
408 vm-frame-per-folder nil
409 vm-tale-is-an-idiot t
410 vm-primary-inbox (concat vm-folder-directory "INBOX")
411 vm-sinbin-inbox (concat vm-folder-directory "SINBOX")
412 vm-uninteresting-senders "ian"
413 vm-reply-ignored-addresses
414 (make-regexps-ignore-non-address
415 '("ian@chiark.chu.cam.ac.uk" "ian" "iwj10@cus.cam.ac.uk"
416 "ian@chiark.greenend.org.uk"
417 "ijackson@nyx.cs.du.edu" "ijackson@gnu.ai.mit.edu"))
418 vm-primary-inbox (concat vm-folder-directory "INBOX")
420 vm-uninteresting-senders "ian"
421 vm-reply-ignored-addresses
422 (make-regexps-ignore-non-address
423 '("ijackson@chiark.chu.cam.ac.uk" "ijackson"
424 "iwj10@thor.cam.ac.uk" "iwj10@hermes.cam.ac.uk" "iwj10@cl.cam.ac.uk"
425 "iwj10@cam.ac.uk" "Ian.Jackson@cl.cam.ac.uk"))
426 mail-archive-file-name "~/mail/Outbound"
429 vm-startup-with-summary t
431 user-mail-address "ijackson@chiark.greenend.org.uk"
434 vm-startup-with-summary nil
435 vm-summary-format "%3n %a %2d %3m %-19.19F %s\n"
436 mail-archive-file-name "~/mail/Outbound"
437 vm-mime-8bit-text-transfer-encoding '8bit)
439 (add-hook 'vm-mode-hook
441 (local-set-key "Q" 'vm-quit)
442 (local-set-key "q" "###Q")))
443 ;(add-hook 'mail-mode-hook
445 ; (if (and (boundp 'folder-buffer)
447 ; (string= (buffer-file-name folder-buffer)
448 ; (file-truename vm-sysadmin-inbox)))
450 ; (make-local-variable 'vm-mail-header-from)
451 ; (setq vm-mail-header-from
452 ; "sysadmin@chiark.greenend.org.uk (Ian Jackson)")
453 ; (make-local-variable 'mail-archive-file-name)
454 ; (setq mail-archive-file-name
455 ; "~/mail/SOutbound")))))
459 ; (vm "/u/ijackson/mail/INBOX"))
463 ; (vm vm-sinbin-inbox))
465 (defun make-session ()
466 "Makes this emacs hard to kill by requiring ^X^Cy to kill it
467 instead of just ^X^C."
469 (global-unset-key "
\18\ 3")
470 (global-set-key "
\18\ 3y" 'save-buffers-kill-emacs))
472 ; Fix problems with M-| setting window title of emacs' parent xterm
473 ;(defun envdelete-term-termcap-windowid (list)
475 ; (mapcar '(lambda (x)
477 ; (mapcar '(lambda (x)
478 ; (if (or (string-match "^TERM=" x)
479 ; (string-match "^TERMCAP=" x)
480 ; (string-match "^WINDOWID=" x))
485 ;(setq process-environment
486 ; (envdelete-term-termcap-windowid process-environment))
488 (defun add-insertion-keys (table)
489 "Adds keybindings according to TABLE. Each element of
490 TABLE should be a four-element list.
492 BINDING should be the key to bind; FUNCTION will be the name of the
493 function defined to do the insertion; DESCRIPTION will be inserted
494 into \"Inserts ... .\", and used as the descriptive string for the
495 generated function; STRING is the string which will actually be
496 inserted into the buffer when the keystroke is pressed."
498 (let* ((head (car table))
502 (string (nth 3 head)))
506 (concat "Inserts " desc ".")
508 (list 'insert string)))
509 (funcall 'local-set-key key func))
510 (setq table (cdr table))))
512 (defun ian-sgml-setup ()
515 '(("
\ 3\r" sgml-insert-new-para "new paragraph markup" "\n<p>\n")
516 ("
\ 3\14" sgml-insert-tt-emph "tt emph markup" "<tt/")
517 ("
\ 3\10" sgml-insert-prgn-emph "prgn emph markup" "<prgn/")
518 ("
\ 3\ 5" sgml-insert-em-emph "em emfh markup" "<em/")
519 ("
\ 3\16" sgml-insert-var-empfh "var emph markup" "<var/"))))
520 (setq sgml-local-catalogs '("/jura:/usr/lib/debiandoc-sgml/sgml/catalog"))
522 (add-hook 'sgml-mode-hook 'ian-sgml-setup)
524 (defvar cite-string "> " "String to insert when citing")
526 (defun cite-region (start end)
527 "Quote each line in the region with an angle-bracket and space.
529 The citation string is taken from cite-string."
533 (narrow-to-region start end)
534 (goto-char (point-min))
539 (> (point-max) (point)))
540 (insert cite-string)))))
545 ;; (defun hack-dir-local-variables ()
546 ;; "Read per-directory local variables for the current buffer.
547 ;; Store the directory-local variables in `dir-local-variables-alist'
548 ;; and `file-local-variables-alist', without applying them."
549 ;; (when (and enable-local-variables
550 ;; (buffer-file-name))
551 ;; ;; Find the variables file.
552 ;; (let ((variables-file (dir-locals-find-file (buffer-file-name)))
556 ;; ((stringp variables-file)
557 ;; (setq dir-name (file-name-directory (buffer-file-name)))
558 ;; (setq class (dir-locals-read-from-file variables-file)))
559 ;; ((consp variables-file)
560 ;; (setq dir-name (nth 0 variables-file))
561 ;; (setq class (nth 1 variables-file))))
564 ;; (dir-locals-collect-variables
565 ;; (dir-locals-get-class-variables class) dir-name nil)))
567 ;; (dolist (elt variables)
568 ;; (unless (memq (car elt) '(eval mode))
569 ;; (setq dir-local-variables-alist
570 ;; (assq-delete-all (car elt) dir-local-variables-alist)))
571 ;; (push elt dir-local-variables-alist))
572 ;; (hack-local-variables-filter variables dir-name)))))))
574 (delete ".git/" completion-ignored-extensions)