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 (defun defuse-electrocuting-indent ()
45 "Disable electric-indent-mode if indent-line-function is daft"
47 (eq indent-line-function 'insert-tab)
48 (electric-indent-local-mode 0)))
49 (add-hook 'after-change-major-mode-hook 'defuse-electrocuting-indent)
51 (set-variable 'search-repeat-char 28)
52 (set-fringe-mode (cons 0 nil))
53 (if (string-match "^19\." emacs-version)
55 ; (setq file-name-handler-alist ; Disable nasty auto-loading of ange-ftp
56 ; (delq (rassq 'ange-ftp-completion-hook-function file-name-handler-alist)
57 ; file-name-handler-alist))
58 (require 'find-alternate-18style)
59 (defun unset-down-mouse-23 ()
60 (local-set-key [mouse-2] 'mouse-yank-at-click)
61 (local-unset-key [down-mouse-2])
62 (local-unset-key [down-mouse-3])
63 (local-unset-key [C-down-mouse-3]))
64 (add-hook 'vm-mode-hook 'unset-down-mouse-23)
65 (add-hook 'vm-mail-mode-hook 'unset-down-mouse-23)
66 (add-hook 'text-mode-hook 'unset-down-mouse-23)
67 (add-hook 'Info-mode-hook
69 (local-set-key " " 'scroll-up)
70 (local-set-key "
\7f" 'scroll-down))))
71 (add-hook 'sh-mode-hook
73 (local-set-key "<" 'self-insert-command))))
74 (define-key isearch-mode-map "
\1c" 'isearch-repeat-forward)
75 (define-key isearch-mode-map "
\1d" 'isearch-quote-char)))
78 (defun terminal-keybindings ()
79 "This function should be called by the term-setup-hook mechanism"
81 ; Set my own keybindings
83 ; Set keybindings generally (including I-search on C-\)
84 ; (global-set-key " " 'self-insert-command)
85 (global-set-key "
\1c" 'isearch-forward)
86 ; (global-set-key "
\r" 'newline)
87 (global-set-key "
\ f" 'set-mark-command)
88 (global-set-key "
\1d" 'quoted-insert)
90 ; Set keybindings on esc-map
91 (global-set-key "
\e#" 'query-replace-regexp)
92 (global-set-key "
\e+" 'toggle-truncate-lines)
93 (global-set-key "
\eg" 'goto-line)
94 (global-set-key "
\es" 'isearch-forward-regexp)
95 (global-set-key "
\e\e" 'eval-expression)
97 ; Set keybindings on ^X-map.
98 (global-set-key "
\18m" 'vm-mail)
99 (global-set-key "
\18\1c" 'save-buffer)
100 (global-set-key "
\18\1d" 'toggle-read-only)
101 (global-set-key "
\18#" 'recover-file)
102 (global-set-key "
\18\12" 'bury-buffer)
103 (global-set-key "
\18\v" 'quicker-compile)
104 (global-set-key "
\18\18" 'exchange-point-and-mark)
105 (global-set-key "
\18\1a" 'load-tramp)
106 (global-set-key "
\184
\16" 'scroll-other-window)
107 (global-set-key "
\184m" 'vm-mail-other-window)
108 (global-set-key "
\189" 'vm-visit-folder)
109 (global-set-key "
\188" 'rmail-input)
110 (global-set-key "
\18p" 'cite-region)
111 (global-set-key "
\18F" 'mail-formletter)
113 ; Set keybindings for Sun numeric pad.
114 (setq esc-bracket-map (make-keymap))
115 (define-key esc-bracket-map "D" 'backward-char)
116 (define-key esc-bracket-map "C" 'forward-char)
117 (define-key esc-bracket-map "A" 'previous-line)
118 (define-key esc-bracket-map "B" 'next-line)
119 (define-key esc-map "[" esc-bracket-map)
120 (global-set-key "\e[214z" 'beginning-of-buffer)
121 (global-set-key "\e[220z" 'end-of-buffer)
122 (global-set-key "\e[216z" 'scroll-down)
123 (global-set-key "\e[222z" 'scroll-up)
124 (global-set-key "\e[192z" 'save-buffer)
125 (global-set-key "\e[194z" 'save-some-buffers)
126 (global-set-key "\e[195z" 'undo)
127 (global-set-key "\e[193z" 'call-last-kbd-macro)
128 (global-set-key "\e[196z" 'switch-to-buffer-other-window)
129 (global-set-key "\e[197z" 'copy-region-as-kill)
130 (global-set-key "\e[198z" 'find-file)
131 (global-set-key "\e[199z" 'yank)
132 (global-set-key "\e[198z" 'find-alternate-file)
133 (global-set-key "\e[200z" 'find-file)
134 (global-set-key "\e[201z" 'kill-region)
135 (global-set-key "\e[-1z" 'info)
137 ; Set keybindings for Chiarks' x11emacs
138 (global-set-key "
\e[5~" 'scroll-down)
139 (global-set-key "
\e[6~" 'scroll-up)
141 ; Set keybindings for knackered vt100-like terminal emulators.
142 (global-set-key "\eOt" 'scroll-down)
143 (global-set-key "\eOu" 'scroll-up)
144 (global-set-key "\eOD" 'backward-char)
145 (global-set-key "\eOC" 'forward-char)
146 (global-set-key "\eOA" 'previous-line)
147 (global-set-key "\eOB" 'next-line))
148 (setq term-setup-hook 'terminal-keybindings) ; remap keys in due course
150 (setq frame-title-format
154 ((buf (current-buffer))
155 (leaf (buffer-name buf))
156 (dir default-directory))
159 ((dir (abbreviate-file-name dir))
160 (node (replace-regexp-in-string "\\..*" "" system-name)))
161 (concat leaf " " node ":" dir))
163 ("" invocation-name "@" system-name)))
164 ;(setq frame-title-format
168 ; ((buf (current-buffer))
169 ; (fn (buffer-file-name buf)))
172 ; ((fn (abbreviate-file-name fn))
173 ; (dir (file-name-directory fn))
174 ; (leaf (file-name-nondirectory fn))
175 ; (node (replace-regexp-in-string "\\..*" "" system-name)))
176 ; (concat leaf " " node ":" dir))
177 ; (buffer-name buf))))
178 ; ("" invocation-name "@" system-name)))
180 ; Autoload definitions
181 (autoload 'tar-mode "tar-mode")
182 (autoload 'uncompress-while-visiting "uncompress")
183 ; (autoload 'c++-mode "c++-mode" "Mode for editing C and C++ programs" t)
184 (autoload 'hide-ifdef-mode "hideif" "For editing code with #ifdefs" t)
185 ;(setq-default indent-tabs-mode nil)
186 (autoload 'dired-find-alternate-file "dired-alternate" "Find alternately" t)
187 (autoload 'dired-run-file "dired-alternate" "Run this file" t)
188 (autoload 'perl-mode "perl-mode" "Mode for Perl code" t)
189 ; (autoload 'rmail "rmail-fixed" "Patched mail reader" t)
190 (autoload 'quicker-compile "quicker-compile" "Patched Compile mode" t)
192 ;(autoload 'vm "vm" "Start VM on your primary inbox." t)
193 ;(autoload 'vm-visit-folder "vm" "Start VM on an arbitrary folder." t)
194 ;(autoload 'vm-visit-virtual-folder "vm" "Visit a VM virtual folder." t)
195 ;(autoload 'vm-mode "vm" "Run VM major mode on a buffer" t)
196 ;(autoload 'vm-mail "vm" "Send a mail message using VM." t)
197 ;(autoload 'vm-submit-bug-report "vm" "Send a bug report about VM." t)
199 ;(require 'vm-autoload)
201 (vm-legacy-key-bindings)
203 ; (autoload 'info "info-fixed" "Patched info browser" t)
204 (setq shell-mode-hook
206 (make-variable-buffer-local 'scroll-step)
207 (setq scroll-step 1)))
208 (setq inferior-lisp-program "sbcl")
209 ;(setq jit-lock-chunk-size 100
210 ; jit-lock-stealth-time 1.00)
211 (setq dired-mode-hook
213 (define-key dired-mode-map "F" 'dired-find-alternate-file)
214 (define-key dired-mode-map "X" 'dired-run-file)))
216 ; Prevent loading of default init file and do some of the things it did
217 ; (setq inhibit-default-init t)
219 ; Additional alist handling function
220 ;(defun alist-remove-elem (s s-list)
221 ; "Delete the element of the alist S-LIST whose car is S"
222 ; (if s-list (if (equal s (car (car s-list)))
224 ; (cons (car s-list) (alist-remove-elem s (cdr s-list))))
227 ; Load C++ mode and edit Perl in perl mode
228 (setq auto-mode-alist
229 (append '(("\\.[ch]$" . c-mode)
230 ("\\.[CH]$" . c++-mode)
231 ("\\.cc$" . c++-mode)
232 ("\\.hh$" . c++-mode)
233 ; ("\\.tar$" . tar-mode)
234 ("\\.pl$" . perl-mode)
235 ("\\.ci$" . tex-mode)
236 ("\\.asm$" . fundamental-mode)
237 ("\\.Z$" . uncompress-while-visiting))
239 (setq interpreter-mode-alist
240 (append '(("sh" . fundamental-mode)
241 ("bash" . fundamental-mode))
242 interpreter-mode-alist))
244 ; Use auto-fill when editing text
245 (add-hook 'text-mode-hook '(lambda () (auto-fill-mode 1)))
246 ; (add-hook 'text-mode-hook '(lambda () (local-set-key " " 'self-insert-command)))
248 ; Set up newline to auto-indent & other stuff for perl, c++ and c modes.
249 (setq perl-mode-hook '(lambda ()
250 (local-set-key ";" 'self-insert-command)))
251 (setq c++-mode-hook '(lambda ()
253 (local-set-key "," 'self-insert-command)
254 (local-set-key ":" 'electric-c++-terminator)))
256 (setq c-mode-hook '(lambda ()
258 (c-set-offset 'substatement-open 0 nil)
259 (local-set-key "," 'self-insert-command)
260 (local-set-key ";" 'self-insert-command)
261 (local-set-key "/" 'self-insert-command)
262 (local-set-key "*" 'self-insert-command)
263 (local-set-key "#" 'self-insert-command)
264 (local-set-key "(" 'self-insert-command)
265 (local-set-key ")" 'self-insert-command)
266 (local-set-key "{" 'self-insert-command)
267 (local-set-key "
\r" 'newline-and-indent)))
268 (setq c-hanging-comment-ender-p nil)
270 (defun vm-mail-other-window ()
271 "Like `vm-mail' command, but display buffer in another window."
273 (switch-to-buffer-other-window (current-buffer))
277 (setq mail-precedence-key-alist
278 '((?0 . "special-delivery")
281 (?3 . "second-class")
287 (defun mail-precedence-as-key ()
288 "Set precedence by looking up last command char in mail-precedence-key-alist"
290 (message "%s" (concat "Precedence ["
291 (mapconcat '(lambda (c) (char-to-string (car c)))
292 mail-precedence-key-alist "")
294 (let* ((key (read-char))
295 (prec (assoc key mail-precedence-key-alist)))
296 (if prec (mail-precedence (cdr prec))
297 (error "mail-precedence-as-key `%s' not found" key))))
299 (defun mail-precedence-as-key-send-and-exit (arg)
300 "Set precedence by looking up last command char in mail-precedence-key-alist,
301 then call send-and-exit."
303 (mail-precedence-as-key)
304 (execute-kbd-macro "
\ 3\ 3"))
306 (defun mail-precedence (prec)
308 (mail-position-on-field "Precedence")
311 (delete-region (point) p)
313 (insert "Precedence: " prec)
316 (defun mail-mode-setup-keys ()
317 (local-set-key "
\ 3\10" 'mail-precedence-as-key)
318 (local-set-key "
\ 3p" 'mail-precedence-as-key-send-and-exit))
319 (add-hook 'mail-mode-hook 'mail-mode-setup-keys)
320 (add-hook 'vm-mail-mode-hook 'mail-mode-setup-keys)
322 (defun vm-mail-other-window ()
323 "Like `vm-mail' command, but display buffer in another window."
325 (switch-to-buffer-other-window (current-buffer))
328 (defun mail-formletter ()
329 "Run VM-mail with ,Formletter"
332 (rename-buffer (generate-new-buffer-name "form letter") t)
333 (delete-region (point-min) (point-max))
334 (insert-file (concat vm-folder-directory ",Formletter")))
336 ; This function bound to C-x C-z
338 "Load tramp using require, if it isn't loaded already"
340 (message "Loading tramp...")
341 (require 'tramp) ; -extended
342 (message "Loading tramp...done"))
344 ; This function bound to M-+
345 (defun toggle-truncate-lines ()
346 "Toggle truncation or folding of long lines"
348 (set-variable 'truncate-lines (not truncate-lines))
352 ;(setq rmail-file-name "~/mail/RMAIL"
353 ; mail-archive-file-name "~/mail/Outbound"
354 ; rmail-primary-inbox-list '("~/mbox" "~/mail/Outbound" "~/mail/Record"
355 ; "~/mail/Import" "/var/spool/mail/ian")
356 ; rmail-delete-after-output t
357 ; rmail-last-rmail-file ""
358 ; rmail-ignored-headers (concat
359 ; "^Content-Identifier:\\|^X400-[^O][A-Za-z-]+:\\|"
360 ; rmail-ignored-headers))
362 (defun make-regexps-ignore-non-address (list)
363 (apply 'append (mapcar
365 (let ((item (mapconcat
367 (let ((s (char-to-string ch)))
368 (if (string-match "[][.*+?^$\\]" s)
373 (concat "<" item ">")
374 (concat "^" item " *\\((.*)\\)?$"))))
378 (setq bbdb-north-american-phone-numbers-p nil
379 bbdb/mail-auto-create-p t
381 bbdb-notice-auto-save-file-p t
382 bbdb-message-caching-enabled t)
385 (if (file-exists-p "~/private/private.el")
386 (load-file "~/private/private.el"))
387 (if (file-exists-p "~/private/private2.el")
388 (load-file "~/private/private2.el"))
389 (setq vm-included-text-attribution-format "%F writes (\"%s\"):\n"
390 vm-reply-subject-prefix "Re: "
391 vm-folder-directory "~/mail/"
392 vm-delete-after-saving t
393 vm-delete-empty-folders t
395 vm-auto-get-new-mail nil
396 vm-auto-next-message nil
397 vm-jump-to-new-messages nil
398 vm-jump-to-unread-messages nil
399 vm-auto-displayed-mime-content-types '("text" "multipart")
400 vm-mime-digest-discard-header-regexp "only-drop-this-header"
402 vm-included-text-prefix "> "
404 vm-auto-center-summary t
405 vm-confirm-new-folders t
406 vm-circular-folders nil
407 vm-visit-when-saving 0
408 vm-move-after-deleting t
409 vm-keep-sent-messages t
410 vm-follow-summary-cursor t
411 vm-frame-per-composition nil
412 vm-frame-per-edit nil
413 vm-frame-per-summary nil
414 vm-frame-per-folder nil
415 vm-tale-is-an-idiot t
416 vm-primary-inbox (concat vm-folder-directory "INBOX")
417 vm-sinbin-inbox (concat vm-folder-directory "SINBOX")
418 vm-uninteresting-senders "ian"
419 vm-reply-ignored-addresses
420 (make-regexps-ignore-non-address
421 '("ian@chiark.chu.cam.ac.uk" "ian" "iwj10@cus.cam.ac.uk"
422 "ian@chiark.greenend.org.uk"
423 "ijackson@nyx.cs.du.edu" "ijackson@gnu.ai.mit.edu"))
424 vm-primary-inbox (concat vm-folder-directory "INBOX")
426 vm-uninteresting-senders "ian"
427 vm-reply-ignored-addresses
428 (make-regexps-ignore-non-address
429 '("ijackson@chiark.chu.cam.ac.uk" "ijackson"
430 "iwj10@thor.cam.ac.uk" "iwj10@hermes.cam.ac.uk" "iwj10@cl.cam.ac.uk"
431 "iwj10@cam.ac.uk" "Ian.Jackson@cl.cam.ac.uk"))
432 mail-archive-file-name "~/mail/Outbound"
435 vm-startup-with-summary t
437 user-mail-address "ijackson@chiark.greenend.org.uk"
440 vm-startup-with-summary nil
441 vm-summary-format "%3n %a %2d %3m %-19.19F %s\n"
442 mail-archive-file-name "~/mail/Outbound"
443 vm-mime-8bit-text-transfer-encoding '8bit)
445 (add-hook 'vm-mode-hook
447 (local-set-key "Q" 'vm-quit)
448 (local-set-key "q" "###Q")))
449 ;(add-hook 'mail-mode-hook
451 ; (if (and (boundp 'folder-buffer)
453 ; (string= (buffer-file-name folder-buffer)
454 ; (file-truename vm-sysadmin-inbox)))
456 ; (make-local-variable 'vm-mail-header-from)
457 ; (setq vm-mail-header-from
458 ; "sysadmin@chiark.greenend.org.uk (Ian Jackson)")
459 ; (make-local-variable 'mail-archive-file-name)
460 ; (setq mail-archive-file-name
461 ; "~/mail/SOutbound")))))
465 ; (vm "/u/ijackson/mail/INBOX"))
469 ; (vm vm-sinbin-inbox))
471 (defun make-session ()
472 "Makes this emacs hard to kill by requiring ^X^Cy to kill it
473 instead of just ^X^C."
475 (global-unset-key "
\18\ 3")
476 (global-set-key "
\18\ 3y" 'save-buffers-kill-emacs))
478 ; Fix problems with M-| setting window title of emacs' parent xterm
479 ;(defun envdelete-term-termcap-windowid (list)
481 ; (mapcar '(lambda (x)
483 ; (mapcar '(lambda (x)
484 ; (if (or (string-match "^TERM=" x)
485 ; (string-match "^TERMCAP=" x)
486 ; (string-match "^WINDOWID=" x))
491 ;(setq process-environment
492 ; (envdelete-term-termcap-windowid process-environment))
494 (defun add-insertion-keys (table)
495 "Adds keybindings according to TABLE. Each element of
496 TABLE should be a four-element list.
498 BINDING should be the key to bind; FUNCTION will be the name of the
499 function defined to do the insertion; DESCRIPTION will be inserted
500 into \"Inserts ... .\", and used as the descriptive string for the
501 generated function; STRING is the string which will actually be
502 inserted into the buffer when the keystroke is pressed."
504 (let* ((head (car table))
508 (string (nth 3 head)))
512 (concat "Inserts " desc ".")
514 (list 'insert string)))
515 (funcall 'local-set-key key func))
516 (setq table (cdr table))))
518 (defun ian-sgml-setup ()
521 '(("
\ 3\r" sgml-insert-new-para "new paragraph markup" "\n<p>\n")
522 ("
\ 3\14" sgml-insert-tt-emph "tt emph markup" "<tt/")
523 ("
\ 3\10" sgml-insert-prgn-emph "prgn emph markup" "<prgn/")
524 ("
\ 3\ 5" sgml-insert-em-emph "em emfh markup" "<em/")
525 ("
\ 3\16" sgml-insert-var-empfh "var emph markup" "<var/"))))
526 (setq sgml-local-catalogs '("/jura:/usr/lib/debiandoc-sgml/sgml/catalog"))
528 (add-hook 'sgml-mode-hook 'ian-sgml-setup)
530 (defvar cite-string "> " "String to insert when citing")
532 (defun cite-region (start end)
533 "Quote each line in the region with an angle-bracket and space.
535 The citation string is taken from cite-string."
539 (narrow-to-region start end)
540 (goto-char (point-min))
545 (> (point-max) (point)))
546 (insert cite-string)))))
553 ;; (defun hack-dir-local-variables ()
554 ;; "Read per-directory local variables for the current buffer.
555 ;; Store the directory-local variables in `dir-local-variables-alist'
556 ;; and `file-local-variables-alist', without applying them."
557 ;; (when (and enable-local-variables
558 ;; (buffer-file-name))
559 ;; ;; Find the variables file.
560 ;; (let ((variables-file (dir-locals-find-file (buffer-file-name)))
564 ;; ((stringp variables-file)
565 ;; (setq dir-name (file-name-directory (buffer-file-name)))
566 ;; (setq class (dir-locals-read-from-file variables-file)))
567 ;; ((consp variables-file)
568 ;; (setq dir-name (nth 0 variables-file))
569 ;; (setq class (nth 1 variables-file))))
572 ;; (dir-locals-collect-variables
573 ;; (dir-locals-get-class-variables class) dir-name nil)))
575 ;; (dolist (elt variables)
576 ;; (unless (memq (car elt) '(eval mode))
577 ;; (setq dir-local-variables-alist
578 ;; (assq-delete-all (car elt) dir-local-variables-alist)))
579 ;; (push elt dir-local-variables-alist))
580 ;; (hack-local-variables-filter variables dir-name)))))))
582 (delete ".git/" completion-ignored-extensions)