Mercurial > emacs
comparison lisp/autoinsert.el @ 31878:6731a720a7a1
(auto-insert): Doc fix.
(auto-insert-alist): Following GNU notices, don't say `copyright
_by_'. Use line-beginning-position.
(auto-insert): Check buffer-file-name is non-nil before use.
author | Dave Love <fx@gnu.org> |
---|---|
date | Mon, 25 Sep 2000 14:43:07 +0000 |
parents | a3246f443a38 |
children | e67c88d8e5c4 |
comparison
equal
deleted
inserted
replaced
31877:517180d8eccd | 31878:6731a720a7a1 |
---|---|
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, 86, 87, 94, 95, 98 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1985, 86, 87, 94, 95, 98, 2000 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 <occitan@esperanto.org> | 6 ;; Adapted-By: Daniel Pfeiffer <occitan@esperanto.org> |
7 ;; Keywords: convenience | 7 ;; Keywords: convenience |
8 ;; Maintainer: FSF | 8 ;; Maintainer: FSF |
75 t insert if possible | 75 t insert if possible |
76 other insert if possible, but mark as unmodified. | 76 other insert if possible, but mark as unmodified. |
77 Insertion is possible when something appropriate is found in | 77 Insertion is possible when something appropriate is found in |
78 `auto-insert-alist'. When the insertion is marked as unmodified, you can | 78 `auto-insert-alist'. When the insertion is marked as unmodified, you can |
79 save it with \\[write-file] RET. | 79 save it with \\[write-file] RET. |
80 This variable is used when `auto-insert' is called as a function, e.g. | 80 This variable is used when the function `auto-insert' is called, e.g. |
81 when you do (add-hook 'find-file-hooks 'auto-insert). | 81 when you do (add-hook 'find-file-hooks 'auto-insert). |
82 With \\[auto-insert], this is always treated as if it were t." | 82 With \\[auto-insert], this is always treated as if it were t." |
83 :type '(choice (const :tag "Insert if possible" t) | 83 :type '(choice (const :tag "Insert if possible" t) |
84 (const :tag "Do nothing" nil) | 84 (const :tag "Do nothing" nil) |
85 (other :tag "insert if possible, mark as unmodified." | 85 (other :tag "insert if possible, mark as unmodified." |
145 | 145 |
146 (("\\.el\\'" . "Emacs Lisp header") | 146 (("\\.el\\'" . "Emacs Lisp header") |
147 "Short description: " | 147 "Short description: " |
148 ";;; " (file-name-nondirectory (buffer-file-name)) " --- " str " | 148 ";;; " (file-name-nondirectory (buffer-file-name)) " --- " str " |
149 | 149 |
150 ;; Copyright (C) " (substring (current-time-string) -4) " by " | 150 ;; Copyright (C) " (substring (current-time-string) -4) " " |
151 (getenv "ORGANIZATION") | "Free Software Foundation, Inc." " | 151 (getenv "ORGANIZATION") | "Free Software Foundation, Inc." " |
152 | 152 |
153 ;; Author: " (user-full-name) | 153 ;; Author: " (user-full-name) |
154 '(if (search-backward "&" (save-excursion (beginning-of-line 1) (point)) t) | 154 '(if (search-backward "&" (line-beginning-position) t) |
155 (replace-match (capitalize (user-login-name)) t t)) | 155 (replace-match (capitalize (user-login-name)) t t)) |
156 '(end-of-line 1) " <" (progn user-mail-address) "> | 156 '(end-of-line 1) " <" (progn user-mail-address) "> |
157 ;; Keywords: " | 157 ;; Keywords: " |
158 '(require 'finder) | 158 '(require 'finder) |
159 ;;'(setq v1 (apply 'vector (mapcar 'car finder-known-keywords))) | 159 ;;'(setq v1 (apply 'vector (mapcar 'car finder-known-keywords))) |
211 :group 'auto-insert) | 211 :group 'auto-insert) |
212 | 212 |
213 | 213 |
214 ;;;###autoload | 214 ;;;###autoload |
215 (defun auto-insert () | 215 (defun auto-insert () |
216 "Insert default contents into a new file if `auto-insert' is non-nil. | 216 "Insert default contents into new files if variable `auto-insert' is non-nil. |
217 Matches the visited file name against the elements of `auto-insert-alist'." | 217 Matches the visited file name against the elements of `auto-insert-alist'." |
218 (interactive) | 218 (interactive) |
219 (and (not buffer-read-only) | 219 (and (not buffer-read-only) |
220 (or (eq this-command 'auto-insert) | 220 (or (eq this-command 'auto-insert) |
221 (and auto-insert | 221 (and auto-insert |
229 (setq desc cond) | 229 (setq desc cond) |
230 (setq desc (cdr cond) | 230 (setq desc (cdr cond) |
231 cond (car cond))) | 231 cond (car cond))) |
232 (if (if (symbolp cond) | 232 (if (if (symbolp cond) |
233 (eq cond major-mode) | 233 (eq cond major-mode) |
234 (string-match cond buffer-file-name)) | 234 (and buffer-file-name |
235 (string-match cond buffer-file-name))) | |
235 (setq action (cdr (car alist)) | 236 (setq action (cdr (car alist)) |
236 alist nil) | 237 alist nil) |
237 (setq alist (cdr alist)))) | 238 (setq alist (cdr alist)))) |
238 | 239 |
239 ;; Now, if we found something, do it | 240 ;; Now, if we found something, do it |