chiark / gitweb /
6b4e611a386c2acd8dcaf549bf81433bb7de6d62
[ian-dotfiles.git] / home / emacs / ian.el
1 ; This is my real emacs start-up file (for chiark).
2
3
4 (defalias 'perl-mode 'cperl-mode)
5 (setq cperl-invalid-face nil
6       cperl-indent-level 4
7       cperl-continued-statement-offset 4)
8
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)
14 ;
15 (setq browse-url-netscape-program "mozilla")
16 (setq common-lisp-hyperspec-root "/usr/share/doc/hyperspec/")
17 ;
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
22 ;      kept-new-versions 4
23 ;      kept-old-versions 4
24 ;      trim-versions-without-asking t)
25 ;
26 ; Various one-liners
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)
41 (display-time)
42 ;
43 (set-variable 'search-repeat-char 28)
44 (set-fringe-mode (cons 0 nil))
45 (if (string-match "^19\." emacs-version)
46     (progn
47 ;      (setq file-name-handler-alist     ; Disable nasty auto-loading of ange-ftp
48 ;            (delq (rassq 'ange-ftp-completion-hook-function file-name-handler-alist)
49 ;                  file-name-handler-alist))
50       (require 'find-alternate-18style)
51       (defun unset-down-mouse-23 ()
52         (local-set-key [mouse-2] 'mouse-yank-at-click)
53         (local-unset-key [down-mouse-2])
54         (local-unset-key [down-mouse-3])
55         (local-unset-key [C-down-mouse-3]))
56       (add-hook 'vm-mode-hook 'unset-down-mouse-23)
57       (add-hook 'vm-mail-mode-hook 'unset-down-mouse-23)
58       (add-hook 'text-mode-hook 'unset-down-mouse-23)
59       (add-hook 'Info-mode-hook
60                 (function (lambda ()
61                             (local-set-key " " 'scroll-up)
62                             (local-set-key "\7f" 'scroll-down))))
63       (add-hook 'sh-mode-hook
64                 (function (lambda ()
65                             (local-set-key "<" 'self-insert-command))))
66       (define-key isearch-mode-map "\1c" 'isearch-repeat-forward)
67       (define-key isearch-mode-map "\1d" 'isearch-quote-char)))
68 ;
69 (menu-bar-mode -1)
70 (defun terminal-keybindings ()
71   "This function should be called by the term-setup-hook mechanism"
72   (interactive)
73   ; Set my own keybindings
74   ;
75   ; Set keybindings generally (including I-search on C-\)
76 ;  (global-set-key "    " 'self-insert-command)
77   (global-set-key "\1c" 'isearch-forward)
78 ;  (global-set-key "\r" 'newline)
79   (global-set-key "\ f" 'set-mark-command)
80   (global-set-key "\1d" 'quoted-insert)
81   ;
82   ; Set keybindings on esc-map
83   (global-set-key "\e#" 'query-replace-regexp)
84   (global-set-key "\e+" 'toggle-truncate-lines)
85   (global-set-key "\eg" 'goto-line)
86   (global-set-key "\es" 'isearch-forward-regexp)
87   (global-set-key "\e\e" 'eval-expression)
88   ;
89   ; Set keybindings on ^X-map.
90   (global-set-key "\18m" 'vm-mail)
91   (global-set-key "\18\1c" 'save-buffer)
92   (global-set-key "\18\1d" 'toggle-read-only)
93   (global-set-key "\18#" 'recover-file)
94   (global-set-key "\18\12" 'bury-buffer)
95   (global-set-key "\18\v" 'quicker-compile)
96   (global-set-key "\18\18" 'exchange-point-and-mark)
97   (global-set-key "\18\1a" 'load-tramp)
98   (global-set-key "\184\16" 'scroll-other-window)
99   (global-set-key "\184m" 'vm-mail-other-window)
100   (global-set-key "\189" 'vm-visit-folder)
101   (global-set-key "\188" 'rmail-input)
102   (global-set-key "\18p" 'cite-region)
103   (global-set-key "\18F" 'mail-formletter)
104   ;
105   ; Set keybindings for Sun numeric pad.
106   (setq esc-bracket-map (make-keymap))
107   (define-key esc-bracket-map "D" 'backward-char)
108   (define-key esc-bracket-map "C" 'forward-char)
109   (define-key esc-bracket-map "A" 'previous-line)
110   (define-key esc-bracket-map "B" 'next-line)
111   (define-key esc-map "[" esc-bracket-map)
112   (global-set-key "\e[214z" 'beginning-of-buffer)
113   (global-set-key "\e[220z" 'end-of-buffer)
114   (global-set-key "\e[216z" 'scroll-down)
115   (global-set-key "\e[222z" 'scroll-up)
116   (global-set-key "\e[192z" 'save-buffer)
117   (global-set-key "\e[194z" 'save-some-buffers)
118   (global-set-key "\e[195z" 'undo)
119   (global-set-key "\e[193z" 'call-last-kbd-macro)
120   (global-set-key "\e[196z" 'switch-to-buffer-other-window)
121   (global-set-key "\e[197z" 'copy-region-as-kill)
122   (global-set-key "\e[198z" 'find-file)
123   (global-set-key "\e[199z" 'yank)
124   (global-set-key "\e[198z" 'find-alternate-file)
125   (global-set-key "\e[200z" 'find-file)
126   (global-set-key "\e[201z" 'kill-region)
127   (global-set-key "\e[-1z" 'info)
128   ;
129   ; Set keybindings for Chiarks' x11emacs
130   (global-set-key "\e[5~" 'scroll-down)
131   (global-set-key "\e[6~" 'scroll-up)
132   ;
133   ; Set keybindings for knackered vt100-like terminal emulators.
134   (global-set-key "\eOt" 'scroll-down)
135   (global-set-key "\eOu" 'scroll-up)
136   (global-set-key "\eOD" 'backward-char)
137   (global-set-key "\eOC" 'forward-char)
138   (global-set-key "\eOA" 'previous-line)
139   (global-set-key "\eOB" 'next-line))
140 (setq term-setup-hook 'terminal-keybindings)     ; remap keys in due course
141 ;
142 (setq frame-title-format
143       '(multiple-frames
144         (:eval 
145          (let*
146              ((buf (current-buffer))
147               (leaf (buffer-name buf))
148               (dir default-directory))
149            (if dir
150                (let*
151                    ((dir (abbreviate-file-name dir))
152                     (node (replace-regexp-in-string "\\..*" "" system-name)))
153                  (concat leaf "  " node ":" dir))
154              leaf)))
155         ("" invocation-name "@" system-name)))
156 ;(setq frame-title-format
157 ;      '(multiple-frames
158 ;       (:eval 
159 ;        (let*
160 ;            ((buf (current-buffer))
161 ;             (fn (buffer-file-name buf)))
162 ;          (if fn
163 ;              (let*
164 ;                  ((fn (abbreviate-file-name fn))
165 ;                   (dir (file-name-directory fn))
166 ;                   (leaf (file-name-nondirectory fn))
167 ;                   (node (replace-regexp-in-string "\\..*" "" system-name)))
168 ;                (concat leaf "  " node ":" dir))
169 ;            (buffer-name buf))))
170 ;       ("" invocation-name "@" system-name)))
171 ;
172 ; Autoload definitions
173 (autoload 'tar-mode "tar-mode")
174 (autoload 'uncompress-while-visiting "uncompress")
175 ; (autoload 'c++-mode "c++-mode" "Mode for editing C and C++ programs" t)
176 (autoload 'hide-ifdef-mode "hideif" "For editing code with #ifdefs" t)
177 ;(setq-default indent-tabs-mode nil)
178 (autoload 'dired-find-alternate-file "dired-alternate" "Find alternately" t)
179 (autoload 'dired-run-file "dired-alternate" "Run this file" t)
180 (autoload 'perl-mode "perl-mode" "Mode for Perl code" t)
181 ; (autoload 'rmail "rmail-fixed" "Patched mail reader" t)
182 (autoload 'quicker-compile "quicker-compile" "Patched Compile mode" t)
183
184 (autoload 'vm "vm" "Start VM on your primary inbox." t)
185 (autoload 'vm-visit-folder "vm" "Start VM on an arbitrary folder." t)
186 (autoload 'vm-visit-virtual-folder "vm" "Visit a VM virtual folder." t)
187 (autoload 'vm-mode "vm" "Run VM major mode on a buffer" t)
188 (autoload 'vm-mail "vm" "Send a mail message using VM." t)
189 (autoload 'vm-submit-bug-report "vm" "Send a bug report about VM." t)
190 ;
191 ; (autoload 'info "info-fixed" "Patched info browser" t)
192 (setq shell-mode-hook
193       '(lambda ()
194          (make-variable-buffer-local 'scroll-step)
195          (setq scroll-step 1)))
196 (setq inferior-lisp-program "sbcl")
197 ;(setq jit-lock-chunk-size 100
198 ;      jit-lock-stealth-time 1.00)
199 (setq dired-mode-hook
200       '(lambda ()
201          (define-key dired-mode-map "F" 'dired-find-alternate-file)
202          (define-key dired-mode-map "X" 'dired-run-file)))
203 ;
204 ; Prevent loading of default init file and do some of the things it did
205 ; (setq inhibit-default-init t)
206 ;
207 ; Additional alist handling function
208 ;(defun alist-remove-elem (s s-list)
209 ;  "Delete the element of the alist S-LIST whose car is S"
210 ;  (if s-list (if (equal s (car (car s-list)))
211 ;                (cdr s-list)
212 ;              (cons (car s-list) (alist-remove-elem s (cdr s-list))))
213 ;    (nil)))
214 ;
215 ; Load C++ mode and edit Perl in perl mode
216 (setq auto-mode-alist
217       (append '(("\\.[ch]$" . c-mode)
218                 ("\\.[CH]$" . c++-mode)
219                 ("\\.cc$" . c++-mode)
220                 ("\\.hh$" . c++-mode)
221 ;                ("\\.tar$" . tar-mode)
222                 ("\\.pl$" . perl-mode)
223                 ("\\.ci$" . tex-mode)
224                 ("\\.asm$" . fundamental-mode)
225                 ("\\.Z$" . uncompress-while-visiting))
226               auto-mode-alist))
227 (setq interpreter-mode-alist
228       (append '(("sh" . fundamental-mode)
229                 ("bash" . fundamental-mode))
230               interpreter-mode-alist))
231 ;
232 ; Use auto-fill when editing text
233 (add-hook 'text-mode-hook '(lambda () (auto-fill-mode 1)))
234 ; (add-hook 'text-mode-hook '(lambda () (local-set-key "        " 'self-insert-command)))
235 ;
236 ; Set up newline to auto-indent & other stuff for perl, c++ and c modes.
237 (setq perl-mode-hook '(lambda () 
238                         (local-set-key ";" 'self-insert-command)))
239 (setq c++-mode-hook '(lambda ()
240                        (hide-ifdef-mode 1)
241                        (local-set-key "," 'self-insert-command)
242                        (local-set-key ":" 'electric-c++-terminator)))
243 ; c++-electric-colon
244 (setq c-mode-hook '(lambda ()
245                      (hide-ifdef-mode 1)
246                      (c-set-offset 'substatement-open 0 nil)
247                      (local-set-key "," 'self-insert-command)
248                      (local-set-key ";" 'self-insert-command)
249                      (local-set-key "/" 'self-insert-command)
250                      (local-set-key "*" 'self-insert-command)
251                      (local-set-key "#" 'self-insert-command)
252                      (local-set-key "(" 'self-insert-command)
253                      (local-set-key ")" 'self-insert-command)
254                      (local-set-key "{" 'self-insert-command)
255                      (local-set-key "\r" 'newline-and-indent)))
256 (setq c-hanging-comment-ender-p nil)
257 ;
258 (defun vm-mail-other-window ()
259   "Like `vm-mail' command, but display buffer in another window."
260   (interactive)
261   (switch-to-buffer-other-window (current-buffer))
262   (vm-mail))
263 ;
264 ; mail precedences
265 (setq mail-precedence-key-alist
266       '((?0  . "special-delivery")
267         (?1  . "air-mail")
268         (?2  . "first-class")
269         (?3  . "second-class")
270         (?5  . "third-class")
271         (?\  . nil)
272         (?6  . "bulk")
273         (?9  . "junk")))
274 ;
275 (defun mail-precedence-as-key ()
276   "Set precedence by looking up last command char in mail-precedence-key-alist"
277   (interactive)
278   (message "%s" (concat "Precedence ["
279                         (mapconcat '(lambda (c) (char-to-string (car c)))
280                                    mail-precedence-key-alist "")
281                         "] ?"))
282   (let* ((key (read-char))
283          (prec (assoc key mail-precedence-key-alist)))
284     (if prec (mail-precedence (cdr prec))
285       (error "mail-precedence-as-key `%s' not found" key))))
286 ;
287 (defun mail-precedence-as-key-send-and-exit (arg)
288   "Set precedence by looking up last command char in mail-precedence-key-alist,
289 then call send-and-exit."
290   (interactive "P")
291   (mail-precedence-as-key)
292   (execute-kbd-macro "\ 3\ 3"))
293 ;
294 (defun mail-precedence (prec)
295   (save-excursion
296     (mail-position-on-field "Precedence")
297     (let ((p (point)))
298       (beginning-of-line)
299       (delete-region (point) p)
300       (if prec
301           (insert "Precedence: " prec)
302         (delete-char 1)))))
303 ;
304 (defun mail-mode-setup-keys ()
305   (local-set-key "\ 3\10" 'mail-precedence-as-key)
306   (local-set-key "\ 3p" 'mail-precedence-as-key-send-and-exit))
307 (add-hook 'mail-mode-hook 'mail-mode-setup-keys)
308 (add-hook 'vm-mail-mode-hook 'mail-mode-setup-keys)
309 ;
310 (defun vm-mail-other-window ()
311   "Like `vm-mail' command, but display buffer in another window."
312   (interactive)
313   (switch-to-buffer-other-window (current-buffer))
314   (vm-mail))
315 ;
316 (defun mail-formletter ()
317   "Run VM-mail with ,Formletter"
318   (interactive)
319   (vm-mail)
320   (rename-buffer (generate-new-buffer-name "form letter") t)
321   (delete-region (point-min) (point-max))
322   (insert-file (concat vm-folder-directory ",Formletter")))
323 ;
324 ; This function bound to C-x C-z
325 (defun load-tramp ()
326   "Load tramp using require, if it isn't loaded already"
327   (interactive)
328   (message "Loading tramp...")
329   (require 'tramp) ; -extended
330   (message "Loading tramp...done"))
331 ;
332 ; This function bound to M-+
333 (defun toggle-truncate-lines ()
334   "Toggle truncation or folding of long lines"
335   (interactive)
336   (set-variable 'truncate-lines (not truncate-lines))
337   (redraw-display))
338 ;
339 ; RMAIL stuff
340 ;(setq rmail-file-name "~/mail/RMAIL"
341 ;      mail-archive-file-name "~/mail/Outbound"
342 ;      rmail-primary-inbox-list '("~/mbox" "~/mail/Outbound" "~/mail/Record"
343 ;                                 "~/mail/Import" "/var/spool/mail/ian")
344 ;      rmail-delete-after-output t
345 ;      rmail-last-rmail-file ""
346 ;      rmail-ignored-headers (concat
347 ;                             "^Content-Identifier:\\|^X400-[^O][A-Za-z-]+:\\|"
348 ;                             rmail-ignored-headers))
349 ;
350 (defun make-regexps-ignore-non-address (list)
351   (apply 'append (mapcar
352                   '(lambda (item)
353                      (let ((item (mapconcat
354                                   '(lambda (ch)
355                                      (let ((s (char-to-string ch)))
356                                        (if (string-match "[][.*+?^$\\]" s)
357                                            (concat "\\" s)
358                                          s)))
359                                   item "")))
360                        (list
361                         (concat "<" item ">")
362                         (concat "^" item " *\\((.*)\\)?$"))))
363                   list)))
364 ;
365 ; BBDB
366 (setq bbdb-north-american-phone-numbers-p nil
367       bbdb/mail-auto-create-p t
368       bbdb-auto-revert-p t
369       bbdb-notice-auto-save-file-p t
370       bbdb-message-caching-enabled t)      
371 ;
372 ; VM stuff
373 ;(load-file "~/private/private.el")
374 (if (file-exists-p "~/private/private2.el")
375   (load-file "~/private/private2.el"))
376 (setq vm-included-text-attribution-format "%F writes (\"%s\"):\n"
377       vm-reply-subject-prefix "Re: "
378       vm-folder-directory "~/mail/"
379       vm-delete-after-saving t
380       vm-delete-empty-folders t
381       vm-mutable-windows t
382       vm-auto-get-new-mail nil
383       vm-auto-next-message nil
384       vm-jump-to-new-messages nil
385       vm-jump-to-unread-messages nil
386       vm-mime-digest-discard-header-regexp "only-drop-this-header"
387       vm-preview-lines nil
388       vm-included-text-prefix "> "
389       vm-confirm-quit 1
390       vm-auto-center-summary t
391       vm-confirm-new-folders t
392       vm-circular-folders nil
393       vm-visit-when-saving 0
394       vm-move-after-deleting t
395       vm-keep-sent-messages t
396       vm-follow-summary-cursor t
397       vm-frame-per-composition nil
398       vm-frame-per-edit nil
399       vm-frame-per-summary nil
400       vm-frame-per-folder nil
401       vm-tale-is-an-idiot t
402       vm-primary-inbox (concat vm-folder-directory "INBOX")
403       vm-sinbin-inbox (concat vm-folder-directory "SINBOX")
404       vm-uninteresting-senders "ian"
405       vm-reply-ignored-addresses
406       (make-regexps-ignore-non-address
407        '("ian@chiark.chu.cam.ac.uk" "ian" "iwj10@cus.cam.ac.uk"
408          "ian@chiark.greenend.org.uk"
409          "ijackson@nyx.cs.du.edu" "ijackson@gnu.ai.mit.edu"))
410       vm-primary-inbox (concat vm-folder-directory "INBOX")
411
412       vm-uninteresting-senders "ian"
413       vm-reply-ignored-addresses
414       (make-regexps-ignore-non-address
415        '("ijackson@chiark.chu.cam.ac.uk" "ijackson"
416          "iwj10@thor.cam.ac.uk" "iwj10@hermes.cam.ac.uk" "iwj10@cl.cam.ac.uk"
417          "iwj10@cam.ac.uk" "Ian.Jackson@cl.cam.ac.uk"))
418       mail-archive-file-name "~/mail/Outbound"
419
420
421       vm-spool-files
422       '((vm-primary-inbox "/var/spool/mail/ian"
423                           "~/mail/INBOX.CRASH")
424         (vm-primary-inbox "~/News/r" "~/mail/INBOX.CRASH")
425         (vm-primary-inbox "~/mbox" "~/mail/INBOX.CRASH")
426         (vm-primary-inbox "~/mail/Outbound" "~/mail/INBOX.CRASH")
427         (vm-primary-inbox "~/mail/Import" "~/mail/INBOX.CRASH")
428         (vm-primary-inbox "~/mail/Record" "~/mail/INBOX.CRASH")
429         (vm-sinbin-inbox "/var/spool/mail/ian" "~/mail/SINBOX.CRASH"))
430       vm-startup-with-summary t
431
432       user-mail-address "ijackson@chiark.greenend.org.uk"
433
434
435 ;      vm-spool-files
436 ;      (list
437 ;       (list vm-primary-inbox "~/mbox" "~/mail/INBOX.CRASH")
438 ;       (list vm-primary-inbox "~/mail/Outbound" "~/mail/INBOX.CRASH")
439 ;       (list vm-primary-inbox "~/mail/Record" "~/mail/INBOX.CRASH")
440 ;       (list vm-primary-inbox "~/mail/Import" "~/mail/INBOX.CRASH")
441 ;       (list vm-primary-inbox "/var/spool/mail/ian" "~/mail/INBOX.CRASH")
442 ;       (list vm-primary-inbox "~/News/r" "~/mail/INBOX.CRASH")
443 ;       (list vm-sysadmin-inbox "~/mbox" "~/mail/SINBOX.CRASH")
444 ;       (list vm-sysadmin-inbox "~/mail/SOutbound" "~/mail/SINBOX.CRASH")
445 ;       (list vm-sysadmin-inbox "~/mail/Import" "~/mail/SINBOX.CRASH")
446 ;       (list vm-sysadmin-inbox "/var/spool/mail/sysadmin" "~/mail/SINBOX.CRASH")
447 ; (list "/u/ijackson/mail/INBOX" "/u/ijackson/mbox" "/u/ijackson/mail/INBOX.CRASH")
448 ; (list "/u/ijackson/mail/INBOX" "/u/ijackson/mail/Outbound"
449 ;       "/u/ijackson/mail/INBOX.CRASH")
450 ; (list "/u/ijackson/mail/INBOX" "/u/ijackson/mail/Record" "/u/ijackson/mail/INBOX.CRASH")
451 ; (list "/u/ijackson/mail/INBOX" "/u/ijackson/mail/Import" "/u/ijackson/mail/INBOX.CRASH")
452 ;        (list "/u/ijackson/mail/INBOX"
453 ;         (concat "localhost:110:pass:ijackson:" ijackson-pop-password)
454 ;         "/u/ijackson/mail/INBOX.CRASH"))
455       vm-startup-with-summary nil
456       vm-summary-format "%3n %a %2d %3m  %-19.19F  %s\n"
457       mail-archive-file-name "~/mail/Outbound"
458       vm-mime-8bit-text-transfer-encoding '8bit)
459 ;
460 (add-hook 'vm-mode-hook
461           '(lambda ()
462              (local-set-key "Q" 'vm-quit)
463              (local-set-key "q" "###Q")))
464 (add-hook 'mail-mode-hook
465           '(lambda ()
466              (if (and (boundp 'folder-buffer)
467                       folder-buffer
468                       (string= (buffer-file-name folder-buffer)
469                                (file-truename vm-sysadmin-inbox)))
470                  (progn
471                    (make-local-variable 'vm-mail-header-from)
472                    (setq vm-mail-header-from
473                          "sysadmin@chiark.greenend.org.uk (Ian Jackson)")
474                    (make-local-variable 'mail-archive-file-name)
475                    (setq mail-archive-file-name
476                          "~/mail/SOutbound")))))
477 ;
478 ;(defun vmi ()
479 ;  (interactive)
480 ;  (vm "/u/ijackson/mail/INBOX"))
481 ;;
482 (defun vms ()
483   (interactive)
484   (vm vm-sinbin-inbox))
485 ;
486 (defun make-session ()
487   "Makes this emacs hard to kill by requiring ^X^Cy to kill it
488 instead of just ^X^C."
489   (interactive)
490   (global-unset-key "\18\ 3")
491   (global-set-key "\18\ 3y" 'save-buffers-kill-emacs))
492 ;
493 ; Fix problems with M-| setting window title of emacs' parent xterm
494 (defun envdelete-term-termcap-windowid (list)
495   (let ((l list))
496     (mapcar '(lambda (x)
497                (if x (delq x l)))
498             (mapcar '(lambda (x)
499                        (if (or (string-match "^TERM=" x)
500                                (string-match "^TERMCAP=" x)
501                                (string-match "^WINDOWID=" x))
502                            x
503                          nil))
504                     l))
505     l))
506 (setq process-environment
507       (envdelete-term-termcap-windowid process-environment))
508 ;
509 (defun add-insertion-keys (table)
510   "Adds keybindings according to TABLE.  Each element of
511 TABLE should be a four-element list.
512
513 BINDING should be the key to bind; FUNCTION will be the name of the
514 function defined to do the insertion; DESCRIPTION will be inserted
515 into \"Inserts ... .\", and used as the descriptive string for the
516 generated function; STRING is the string which will actually be
517 inserted into the buffer when the keystroke is pressed."
518   (while table
519     (let* ((head (car table))
520            (key (car head))
521            (func (nth 1 head))
522            (desc (nth 2 head))
523            (string (nth 3 head)))
524       (defalias func
525         (list
526          'lambda () 
527          (concat "Inserts " desc ".")
528          '(interactive)
529          (list 'insert string)))
530       (funcall 'local-set-key key func))
531     (setq table (cdr table))))
532
533 (defun ian-sgml-setup ()
534   (interactive)
535   (add-insertion-keys
536    '(("\ 3\r" sgml-insert-new-para "new paragraph markup" "\n<p>\n")
537      ("\ 3\14" sgml-insert-tt-emph "tt emph markup" "<tt/")
538      ("\ 3\10" sgml-insert-prgn-emph "prgn emph markup" "<prgn/")
539      ("\ 3\ 5" sgml-insert-em-emph "em emfh markup" "<em/")
540      ("\ 3\16" sgml-insert-var-empfh "var emph markup" "<var/"))))
541 (setq sgml-local-catalogs '("/jura:/usr/lib/debiandoc-sgml/sgml/catalog"))
542   
543 (add-hook 'sgml-mode-hook 'ian-sgml-setup)
544 ;
545 (defvar cite-string "> " "String to insert when citing")
546 ;
547 (defun cite-region (start end)
548   "Quote each line in the region with an angle-bracket and space.
549
550 The citation string is taken from cite-string."
551   (interactive "r")
552   (save-excursion
553     (save-restriction
554       (narrow-to-region start end)
555       (goto-char (point-min))
556       (insert cite-string)
557       (while
558           (and
559            (= (forward-line) 0)
560            (> (point-max) (point)))
561         (insert cite-string)))))
562 ;
563 ; End of this file.