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 (load-library "vm-reply")
11 (make-variable-buffer-local 'indent-line-function)
12 ; Un-disable narrow and eval-expression
13 (put 'narrow-to-region 'disabled nil)
14 (put 'eval-expression 'disabled nil)
15 ;(standard-display-european t)
17 (setq browse-url-netscape-program "mozilla")
18 (setq common-lisp-hyperspec-root "/usr/share/doc/hyperspec/")
20 ; Make sure we don't disturb links or change ownership, use numbers
21 (setq backup-by-copying-when-mismatch t)
22 (setq backup-by-copying-when-linked t)
23 ;(setq version-control t
26 ; trim-versions-without-asking t)
29 (setq require-final-newline "ask")
30 (if (string= window-system 'x) (load-library "ian-x"))
31 (load-library "ian-aliases")
32 ; (load-library "auto-pgp")
33 ; (load-library "debian-changelog-mode")
34 ; (if (string= (getenv "TERM") "bbcb32") (setq term-file-prefix nil))
35 ; (setq explicit-shell-file-name "/usr/local/bin/tcsh")
36 (setq inhibit-local-variables t)
37 (setq enable-local-variables 'ask-me)
38 (setq enable-recursive-minibuffers t)
39 (setq compile-command "make")
40 (setq next-line-add-newlines t)
41 (setq diff-switches "-u")
42 (setq line-move-visual nil)
45 (set-default 'indent-line-function 'insert-tab)
46 (defun defuse-electrocuting-indent ()
47 "Disable electric-indent-mode if indent-line-function is daft"
49 (eq indent-line-function 'insert-tab)
50 (electric-indent-local-mode 0)))
51 (add-hook 'after-change-major-mode-hook 'defuse-electrocuting-indent)
53 (set-variable 'search-repeat-char 28)
54 (set-fringe-mode (cons 0 nil))
55 (if (string-match "^19\." emacs-version)
57 ; (setq file-name-handler-alist ; Disable nasty auto-loading of ange-ftp
58 ; (delq (rassq 'ange-ftp-completion-hook-function file-name-handler-alist)
59 ; file-name-handler-alist))
60 (require 'find-alternate-18style)
61 (defun unset-down-mouse-23 ()
62 (local-set-key [mouse-2] 'mouse-yank-at-click)
63 (local-unset-key [down-mouse-2])
64 (local-unset-key [down-mouse-3])
65 (local-unset-key [C-down-mouse-3]))
66 (add-hook 'vm-mode-hook 'unset-down-mouse-23)
67 (add-hook 'vm-mail-mode-hook 'unset-down-mouse-23)
68 (add-hook 'text-mode-hook 'unset-down-mouse-23)
69 (add-hook 'Info-mode-hook
71 (local-set-key " " 'scroll-up)
72 (local-set-key "
\7f" 'scroll-down))))
73 (add-hook 'sh-mode-hook
75 (local-set-key "<" 'self-insert-command))))
76 (define-key isearch-mode-map "
\1c" 'isearch-repeat-forward)
77 (define-key isearch-mode-map "
\1d" 'isearch-quote-char)))
80 (defun terminal-keybindings ()
81 "This function should be called by the term-setup-hook mechanism"
83 ; Set my own keybindings
85 ; Set keybindings generally (including I-search on C-\)
86 ; (global-set-key " " 'self-insert-command)
87 (global-set-key "
\1c" 'isearch-forward)
88 ; (global-set-key "
\r" 'newline)
89 (global-set-key "
\ f" 'set-mark-command)
90 (global-set-key "
\1d" 'quoted-insert)
92 ; Set keybindings on esc-map
93 (global-set-key "
\e#" 'query-replace-regexp)
94 (global-set-key "
\e+" 'toggle-truncate-lines)
95 (global-set-key "
\eg" 'goto-line)
96 (global-set-key "
\es" 'isearch-forward-regexp)
97 (global-set-key "
\e\e" 'eval-expression)
99 ; Set keybindings on ^X-map.
100 (global-set-key "
\18m" 'vm-mail)
101 (global-set-key "
\18\1c" 'save-buffer)
102 (global-set-key "
\18\1d" 'toggle-read-only)
103 (global-set-key "
\18#" 'recover-file)
104 (global-set-key "
\18\12" 'bury-buffer)
105 (global-set-key "
\18\v" 'quicker-compile)
106 (global-set-key "
\18\18" 'exchange-point-and-mark)
107 (global-set-key "
\18\1a" 'load-tramp)
108 (global-set-key "
\18g" 'magit-status)
109 (global-set-key "
\18\eg" 'magit-dispatch-popup)
110 (global-set-key "
\184
\16" 'scroll-other-window)
111 (global-set-key "
\184m" 'vm-mail-other-window)
112 (global-set-key "
\189" 'vm-visit-folder)
113 (global-set-key "
\188" 'rmail-input)
114 (global-set-key "
\18p" 'cite-region)
115 (global-set-key "
\18F" 'mail-formletter)
117 ; Set keybindings for Sun numeric pad.
118 (setq esc-bracket-map (make-keymap))
119 (define-key esc-bracket-map "D" 'backward-char)
120 (define-key esc-bracket-map "C" 'forward-char)
121 (define-key esc-bracket-map "A" 'previous-line)
122 (define-key esc-bracket-map "B" 'next-line)
123 (define-key esc-map "[" esc-bracket-map)
124 (global-set-key "\e[214z" 'beginning-of-buffer)
125 (global-set-key "\e[220z" 'end-of-buffer)
126 (global-set-key "\e[216z" 'scroll-down)
127 (global-set-key "\e[222z" 'scroll-up)
128 (global-set-key "\e[192z" 'save-buffer)
129 (global-set-key "\e[194z" 'save-some-buffers)
130 (global-set-key "\e[195z" 'undo)
131 (global-set-key "\e[193z" 'call-last-kbd-macro)
132 (global-set-key "\e[196z" 'switch-to-buffer-other-window)
133 (global-set-key "\e[197z" 'copy-region-as-kill)
134 (global-set-key "\e[198z" 'find-file)
135 (global-set-key "\e[199z" 'yank)
136 (global-set-key "\e[198z" 'find-alternate-file)
137 (global-set-key "\e[200z" 'find-file)
138 (global-set-key "\e[201z" 'kill-region)
139 (global-set-key "\e[-1z" 'info)
141 ; Set keybindings for Chiarks' x11emacs
142 (global-set-key "
\e[5~" 'scroll-down)
143 (global-set-key "
\e[6~" 'scroll-up)
145 ; Set keybindings for knackered vt100-like terminal emulators.
146 (global-set-key "\eOt" 'scroll-down)
147 (global-set-key "\eOu" 'scroll-up)
148 (global-set-key "\eOD" 'backward-char)
149 (global-set-key "\eOC" 'forward-char)
150 (global-set-key "\eOA" 'previous-line)
151 (global-set-key "\eOB" 'next-line))
152 (setq term-setup-hook 'terminal-keybindings) ; remap keys in due course
154 (setq frame-title-format
158 ((buf (current-buffer))
159 (leaf (buffer-name buf))
160 (dir default-directory))
163 ((dir (abbreviate-file-name dir))
164 (node (replace-regexp-in-string "\\..*" "" system-name)))
165 (concat leaf " " node ":" dir))
167 ("" invocation-name "@" system-name)))
168 ;(setq frame-title-format
172 ; ((buf (current-buffer))
173 ; (fn (buffer-file-name buf)))
176 ; ((fn (abbreviate-file-name fn))
177 ; (dir (file-name-directory fn))
178 ; (leaf (file-name-nondirectory fn))
179 ; (node (replace-regexp-in-string "\\..*" "" system-name)))
180 ; (concat leaf " " node ":" dir))
181 ; (buffer-name buf))))
182 ; ("" invocation-name "@" system-name)))
184 ; Autoload definitions
185 (autoload 'tar-mode "tar-mode")
186 (autoload 'uncompress-while-visiting "uncompress")
187 ; (autoload 'c++-mode "c++-mode" "Mode for editing C and C++ programs" t)
188 (autoload 'hide-ifdef-mode "hideif" "For editing code with #ifdefs" t)
189 ;(setq-default indent-tabs-mode nil)
190 (autoload 'dired-find-alternate-file "dired-alternate" "Find alternately" t)
191 (autoload 'dired-run-file "dired-alternate" "Run this file" t)
192 (autoload 'perl-mode "perl-mode" "Mode for Perl code" t)
193 ; (autoload 'rmail "rmail-fixed" "Patched mail reader" t)
194 (autoload 'quicker-compile "quicker-compile" "Patched Compile mode" t)
196 ;(autoload 'vm "vm" "Start VM on your primary inbox." t)
197 ;(autoload 'vm-visit-folder "vm" "Start VM on an arbitrary folder." t)
198 ;(autoload 'vm-visit-virtual-folder "vm" "Visit a VM virtual folder." t)
199 ;(autoload 'vm-mode "vm" "Run VM major mode on a buffer" t)
200 ;(autoload 'vm-mail "vm" "Send a mail message using VM." t)
201 ;(autoload 'vm-submit-bug-report "vm" "Send a bug report about VM." t)
203 ;(require 'vm-autoload)
205 (vm-legacy-key-bindings)
207 ; (autoload 'info "info-fixed" "Patched info browser" t)
208 (setq shell-mode-hook
210 (make-variable-buffer-local 'scroll-step)
211 (setq scroll-step 1)))
212 (setq inferior-lisp-program "sbcl")
213 ;(setq jit-lock-chunk-size 100
214 ; jit-lock-stealth-time 1.00)
215 (setq dired-mode-hook
217 (define-key dired-mode-map "F" 'dired-find-alternate-file)
218 (define-key dired-mode-map "X" 'dired-run-file)))
220 ; Prevent loading of default init file and do some of the things it did
221 ; (setq inhibit-default-init t)
223 ; Additional alist handling function
224 ;(defun alist-remove-elem (s s-list)
225 ; "Delete the element of the alist S-LIST whose car is S"
226 ; (if s-list (if (equal s (car (car s-list)))
228 ; (cons (car s-list) (alist-remove-elem s (cdr s-list))))
231 ; Load C++ mode and edit Perl in perl mode
232 (setq auto-mode-alist
233 (append '(("\\.[ch]$" . c-mode)
234 ("\\.[CH]$" . c++-mode)
235 ("\\.cc$" . c++-mode)
236 ("\\.hh$" . c++-mode)
237 ; ("\\.tar$" . tar-mode)
238 ("\\.pl$" . perl-mode)
239 ("\\.ci$" . tex-mode)
240 ("\\.asm$" . fundamental-mode)
241 ("\\.Z$" . uncompress-while-visiting))
243 (setq interpreter-mode-alist
244 (append '(("sh" . fundamental-mode)
245 ("bash" . fundamental-mode))
246 interpreter-mode-alist))
248 ; Use auto-fill when editing text
249 (add-hook 'text-mode-hook '(lambda () (auto-fill-mode 1)))
250 ; (add-hook 'text-mode-hook '(lambda () (local-set-key " " 'self-insert-command)))
252 ; Set up newline to auto-indent & other stuff for perl, c++ and c modes.
253 (setq perl-mode-hook '(lambda ()
254 (local-set-key ";" 'self-insert-command)))
255 (setq c++-mode-hook '(lambda ()
257 (local-set-key "," 'self-insert-command)
258 (local-set-key ":" 'electric-c++-terminator)))
260 (setq c-mode-hook '(lambda ()
262 (c-set-offset 'substatement-open 0 nil)
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 "#" 'self-insert-command)
268 (local-set-key "(" 'self-insert-command)
269 (local-set-key ")" 'self-insert-command)
270 (local-set-key "{" 'self-insert-command)
271 (local-set-key "
\r" 'newline-and-indent)))
272 (setq c-hanging-comment-ender-p nil)
274 (defun vm-mail-other-window ()
275 "Like `vm-mail' command, but display buffer in another window."
277 (switch-to-buffer-other-window (current-buffer))
281 (setq mail-precedence-key-alist
282 '((?0 . "special-delivery")
285 (?3 . "second-class")
291 (defun mail-precedence-as-key ()
292 "Set precedence by looking up last command char in mail-precedence-key-alist"
294 (message "%s" (concat "Precedence ["
295 (mapconcat '(lambda (c) (char-to-string (car c)))
296 mail-precedence-key-alist "")
298 (let* ((key (read-char))
299 (prec (assoc key mail-precedence-key-alist)))
300 (if prec (mail-precedence (cdr prec))
301 (error "mail-precedence-as-key `%s' not found" key))))
303 (defun mail-precedence-as-key-send-and-exit (arg)
304 "Set precedence by looking up last command char in mail-precedence-key-alist,
305 then call send-and-exit."
307 (mail-precedence-as-key)
308 (execute-kbd-macro "
\ 3\ 3"))
310 (defun mail-precedence (prec)
312 (mail-position-on-field "Precedence")
315 (delete-region (point) p)
317 (insert "Precedence: " prec)
320 (defun mail-mode-setup-keys ()
321 (local-set-key "
\ 3\10" 'mail-precedence-as-key)
322 (local-set-key "
\ 3p" 'mail-precedence-as-key-send-and-exit))
323 (add-hook 'mail-mode-hook 'mail-mode-setup-keys)
324 (add-hook 'vm-mail-mode-hook 'mail-mode-setup-keys)
326 (defun vm-mail-other-window ()
327 "Like `vm-mail' command, but display buffer in another window."
329 (switch-to-buffer-other-window (current-buffer))
332 (defun mail-formletter ()
333 "Run VM-mail with ,Formletter"
336 (rename-buffer (generate-new-buffer-name "form letter") t)
337 (delete-region (point-min) (point-max))
338 (insert-file (concat vm-folder-directory ",Formletter")))
340 ; This function bound to C-x C-z
342 "Load tramp using require, if it isn't loaded already"
344 (message "Loading tramp...")
345 (require 'tramp) ; -extended
346 (message "Loading tramp...done"))
348 ; This function bound to M-+
349 (defun toggle-truncate-lines ()
350 "Toggle truncation or folding of long lines"
352 (set-variable 'truncate-lines (not truncate-lines))
356 ;(setq rmail-file-name "~/mail/RMAIL"
357 ; mail-archive-file-name "~/mail/Outbound"
358 ; rmail-primary-inbox-list '("~/mbox" "~/mail/Outbound" "~/mail/Record"
359 ; "~/mail/Import" "/var/spool/mail/ian")
360 ; rmail-delete-after-output t
361 ; rmail-last-rmail-file ""
362 ; rmail-ignored-headers (concat
363 ; "^Content-Identifier:\\|^X400-[^O][A-Za-z-]+:\\|"
364 ; rmail-ignored-headers))
366 (defun make-regexps-ignore-non-address (list)
367 (apply 'append (mapcar
369 (let ((item (mapconcat
371 (let ((s (char-to-string ch)))
372 (if (string-match "[][.*+?^$\\]" s)
377 (concat "<" item ">")
378 (concat "^" item " *\\((.*)\\)?$"))))
382 (setq bbdb-north-american-phone-numbers-p nil
383 bbdb/mail-auto-create-p t
385 bbdb-notice-auto-save-file-p t
386 bbdb-message-caching-enabled t)
389 (if (file-exists-p "~/private/private.el")
390 (load-file "~/private/private.el"))
391 (if (file-exists-p "~/private/private2.el")
392 (load-file "~/private/private2.el"))
393 (setq vm-included-text-attribution-format "%F writes (\"%s\"):\n"
394 vm-reply-subject-prefix "Re: "
395 vm-folder-directory "~/mail/"
396 vm-delete-after-saving t
397 vm-delete-empty-folders t
399 vm-auto-get-new-mail nil
400 vm-auto-next-message nil
401 vm-jump-to-new-messages nil
402 vm-jump-to-unread-messages nil
403 vm-auto-displayed-mime-content-types '("text" "multipart")
404 vm-mime-digest-discard-header-regexp "only-drop-this-header"
406 vm-included-text-prefix "> "
408 vm-auto-center-summary t
409 vm-confirm-new-folders t
410 vm-circular-folders nil
411 vm-visit-when-saving 0
412 vm-move-after-deleting t
413 vm-keep-sent-messages t
414 vm-follow-summary-cursor t
415 vm-frame-per-composition nil
416 vm-frame-per-edit nil
417 vm-frame-per-summary nil
418 vm-frame-per-folder nil
419 vm-tale-is-an-idiot t
420 vm-primary-inbox (concat vm-folder-directory "INBOX")
421 vm-sinbin-inbox (concat vm-folder-directory "SINBOX")
422 vm-uninteresting-senders "ian"
423 vm-reply-ignored-addresses
424 (make-regexps-ignore-non-address
425 '("ian@chiark.chu.cam.ac.uk" "ian" "iwj10@cus.cam.ac.uk"
426 "ian@chiark.greenend.org.uk"
427 "ijackson@nyx.cs.du.edu" "ijackson@gnu.ai.mit.edu"))
428 vm-primary-inbox (concat vm-folder-directory "INBOX")
430 vm-uninteresting-senders "ian"
431 vm-reply-ignored-addresses
432 (make-regexps-ignore-non-address
433 '("ijackson@chiark.chu.cam.ac.uk" "ijackson"
434 "iwj10@thor.cam.ac.uk" "iwj10@hermes.cam.ac.uk" "iwj10@cl.cam.ac.uk"
435 "iwj10@cam.ac.uk" "Ian.Jackson@cl.cam.ac.uk"))
436 mail-archive-file-name "~/mail/Outbound"
439 vm-startup-with-summary t
441 user-mail-address "ijackson@chiark.greenend.org.uk"
444 vm-startup-with-summary nil
445 vm-summary-format "%3n %a %2d %3m %-19.19F %s\n"
446 mail-archive-file-name "~/mail/Outbound"
447 vm-mime-8bit-text-transfer-encoding '8bit)
449 (add-hook 'vm-mode-hook
451 (local-set-key "Q" 'vm-quit)
452 (local-set-key "q" "###Q")))
453 ;(add-hook 'mail-mode-hook
455 ; (if (and (boundp 'folder-buffer)
457 ; (string= (buffer-file-name folder-buffer)
458 ; (file-truename vm-sysadmin-inbox)))
460 ; (make-local-variable 'vm-mail-header-from)
461 ; (setq vm-mail-header-from
462 ; "sysadmin@chiark.greenend.org.uk (Ian Jackson)")
463 ; (make-local-variable 'mail-archive-file-name)
464 ; (setq mail-archive-file-name
465 ; "~/mail/SOutbound")))))
469 ; (vm "/u/ijackson/mail/INBOX"))
473 ; (vm vm-sinbin-inbox))
475 (defun make-session ()
476 "Makes this emacs hard to kill by requiring ^X^Cy to kill it
477 instead of just ^X^C."
479 (global-unset-key "
\18\ 3")
480 (global-set-key "
\18\ 3y" 'save-buffers-kill-emacs))
482 ; Fix problems with M-| setting window title of emacs' parent xterm
483 ;(defun envdelete-term-termcap-windowid (list)
485 ; (mapcar '(lambda (x)
487 ; (mapcar '(lambda (x)
488 ; (if (or (string-match "^TERM=" x)
489 ; (string-match "^TERMCAP=" x)
490 ; (string-match "^WINDOWID=" x))
495 ;(setq process-environment
496 ; (envdelete-term-termcap-windowid process-environment))
498 (defun add-insertion-keys (table)
499 "Adds keybindings according to TABLE. Each element of
500 TABLE should be a four-element list.
502 BINDING should be the key to bind; FUNCTION will be the name of the
503 function defined to do the insertion; DESCRIPTION will be inserted
504 into \"Inserts ... .\", and used as the descriptive string for the
505 generated function; STRING is the string which will actually be
506 inserted into the buffer when the keystroke is pressed."
508 (let* ((head (car table))
512 (string (nth 3 head)))
516 (concat "Inserts " desc ".")
518 (list 'insert string)))
519 (funcall 'local-set-key key func))
520 (setq table (cdr table))))
522 (defun ian-sgml-setup ()
525 '(("
\ 3\r" sgml-insert-new-para "new paragraph markup" "\n<p>\n")
526 ("
\ 3\14" sgml-insert-tt-emph "tt emph markup" "<tt/")
527 ("
\ 3\10" sgml-insert-prgn-emph "prgn emph markup" "<prgn/")
528 ("
\ 3\ 5" sgml-insert-em-emph "em emfh markup" "<em/")
529 ("
\ 3\16" sgml-insert-var-empfh "var emph markup" "<var/"))))
530 (setq sgml-local-catalogs '("/jura:/usr/lib/debiandoc-sgml/sgml/catalog"))
532 (add-hook 'sgml-mode-hook 'ian-sgml-setup)
534 (defvar cite-string "> " "String to insert when citing")
536 (defun cite-region (start end)
537 "Quote each line in the region with an angle-bracket and space.
539 The citation string is taken from cite-string."
543 (narrow-to-region start end)
544 (goto-char (point-min))
549 (> (point-max) (point)))
550 (insert cite-string)))))
556 (global-magit-file-mode)
558 (magit-wip-after-save-mode)
559 (magit-wip-after-apply-mode)
560 (magit-wip-before-change-mode)
561 (setq magit-no-confirm
562 (append magit-no-confirm '(safe-with-wip)))
564 (setq vc-handled-backends (delq 'Git vc-handled-backends))
566 ;; (defun hack-dir-local-variables ()
567 ;; "Read per-directory local variables for the current buffer.
568 ;; Store the directory-local variables in `dir-local-variables-alist'
569 ;; and `file-local-variables-alist', without applying them."
570 ;; (when (and enable-local-variables
571 ;; (buffer-file-name))
572 ;; ;; Find the variables file.
573 ;; (let ((variables-file (dir-locals-find-file (buffer-file-name)))
577 ;; ((stringp variables-file)
578 ;; (setq dir-name (file-name-directory (buffer-file-name)))
579 ;; (setq class (dir-locals-read-from-file variables-file)))
580 ;; ((consp variables-file)
581 ;; (setq dir-name (nth 0 variables-file))
582 ;; (setq class (nth 1 variables-file))))
585 ;; (dir-locals-collect-variables
586 ;; (dir-locals-get-class-variables class) dir-name nil)))
588 ;; (dolist (elt variables)
589 ;; (unless (memq (car elt) '(eval mode))
590 ;; (setq dir-local-variables-alist
591 ;; (assq-delete-all (car elt) dir-local-variables-alist)))
592 ;; (push elt dir-local-variables-alist))
593 ;; (hack-local-variables-filter variables dir-name)))))))
595 (delete ".git/" completion-ignored-extensions)