comparison lisp/autoinsert.el @ 21287:f61d91aef100

(auto-insert, auto-insert-query): :tag choices. (define-auto-insert): Rename arg key to match doc.
author Dave Love <fx@gnu.org>
date Wed, 25 Mar 1998 19:06:46 +0000
parents c582e15d8cfc
children a77d473867b8
comparison
equal deleted inserted replaced
21286:febfd4282be6 21287:f61d91aef100
1 ;;; autoinsert.el --- automatic mode-dependent insertion of text into new files 1 ;;; autoinsert.el --- automatic mode-dependent insertion of text into new files
2 2
3 ;; Copyright (C) 1985, 1986, 1987, 1994, 1995 Free Software Foundation, Inc. 3 ;; Copyright (C) 1985, 86, 87, 94, 95, 98 Free Software Foundation, Inc.
4 4
5 ;; Author: Charlie Martin <crm@cs.duke.edu> 5 ;; Author: Charlie Martin <crm@cs.duke.edu>
6 ;; Adapted-By: Daniel.Pfeiffer@Informatik.START.dbp.de, fax (+49 69) 7588-2389 6 ;; Adapted-By: Daniel.Pfeiffer@Informatik.START.dbp.de, fax (+49 69) 7588-2389
7 ;; Maintainer: FSF 7 ;; Maintainer: FSF
8 8
74 `auto-insert-alist'. When the insertion is marked as unmodified, you can 74 `auto-insert-alist'. When the insertion is marked as unmodified, you can
75 save it with \\[write-file] RET. 75 save it with \\[write-file] RET.
76 This variable is used when `auto-insert' is called as a function, e.g. 76 This variable is used when `auto-insert' is called as a function, e.g.
77 when you do (add-hook 'find-file-hooks 'auto-insert). 77 when you do (add-hook 'find-file-hooks 'auto-insert).
78 With \\[auto-insert], this is always treated as if it were `t'." 78 With \\[auto-insert], this is always treated as if it were `t'."
79 :type '(choice (const t) (const nil) (const not-modified)) 79 :type '(choice (const :tag "Insert if possible" t)
80 (const :tag "Do nothing" nil)
81 (const :tag "insert if possible, mark as unmodified."
82 not-modified))
80 :group 'auto-insert) 83 :group 'auto-insert)
81 84
82 (defcustom auto-insert-query 'function 85 (defcustom auto-insert-query 'function
83 "*If non-`nil', ask user before auto-inserting. 86 "*If non-`nil', ask user before auto-inserting.
84 When this is `function', only ask when called non-interactively." 87 When this is `function', only ask when called non-interactively."
85 :type '(choice (const t) (const nil) (const function)) 88 :type '(choice (const :tag "Ask" t)
89 (const :tag "Don't ask" nil)
90 (const :tag "Ask if called non-interactively" function))
86 :group 'auto-insert) 91 :group 'auto-insert)
87 92
88 (defcustom auto-insert-prompt "Perform %s auto-insertion? " 93 (defcustom auto-insert-prompt "Perform %s auto-insertion? "
89 "*Prompt to use when querying whether to auto-insert. 94 "*Prompt to use when querying whether to auto-insert.
90 If this contains a %s, that will be replaced by the matching rule." 95 If this contains a %s, that will be replaced by the matching rule."
260 (not (eq this-command 'auto-insert)) 265 (not (eq this-command 'auto-insert))
261 (set-buffer-modified-p (eq auto-insert t)))))) 266 (set-buffer-modified-p (eq auto-insert t))))))
262 267
263 268
264 ;;;###autoload 269 ;;;###autoload
265 (defun define-auto-insert (key action &optional after) 270 (defun define-auto-insert (condition action &optional after)
266 "Associate CONDITION with (additional) ACTION in `auto-insert-alist'. 271 "Associate CONDITION with (additional) ACTION in `auto-insert-alist'.
267 Optional AFTER means to insert action after all existing actions for CONDITION, 272 Optional AFTER means to insert action after all existing actions for CONDITION,
268 or if CONDITION had no actions, after all other CONDITIONs." 273 or if CONDITION had no actions, after all other CONDITIONs."
269 (let ((elt (assoc key auto-insert-alist))) 274 (let ((elt (assoc condition auto-insert-alist)))
270 (if elt 275 (if elt
271 (setcdr elt 276 (setcdr elt
272 (if (vectorp (cdr elt)) 277 (if (vectorp (cdr elt))
273 (vconcat (if after (cdr elt)) 278 (vconcat (if after (cdr elt))
274 (if (vectorp action) action (vector action)) 279 (if (vectorp action) action (vector action))
275 (if after () (cdr elt))) 280 (if after () (cdr elt)))
276 (if after 281 (if after
277 (vector (cdr elt) action) 282 (vector (cdr elt) action)
278 (vector action (cdr elt))))) 283 (vector action (cdr elt)))))
279 (if after 284 (if after
280 (nconc auto-insert-alist (list (cons key action))) 285 (nconc auto-insert-alist (list (cons condition action)))
281 (setq auto-insert-alist (cons (cons key action) 286 (setq auto-insert-alist (cons (cons condition action)
282 auto-insert-alist)))))) 287 auto-insert-alist))))))
283 288
284 ;;;###autoload 289 ;;;###autoload
285 (defun auto-insert-mode (&optional arg) 290 (defun auto-insert-mode (&optional arg)
286 "Toggle auto-insert mode. 291 "Toggle auto-insert mode.