Mercurial > emacs
annotate lisp/autoinsert.el @ 95006:96a5a9eaf628
Switch to recommended form of GPLv3 permissions notice.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Thu, 15 May 2008 07:31:52 +0000 |
parents | ee5932bf781d |
children | df27f026bbe2 |
rev | line source |
---|---|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
180
diff
changeset
|
1 ;;; autoinsert.el --- automatic mode-dependent insertion of text into new files |
14169 | 2 |
74439 | 3 ;; Copyright (C) 1985, 1986, 1987, 1994, 1995, 1998, 2000, 2001, 2002, |
79721 | 4 ;; 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
845 | 5 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
6 ;; Author: Charlie Martin <crm@cs.duke.edu> |
23869 | 7 ;; Adapted-By: Daniel Pfeiffer <occitan@esperanto.org> |
22250
a77d473867b8
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21287
diff
changeset
|
8 ;; Keywords: convenience |
17976 | 9 ;; Maintainer: FSF |
180 | 10 |
11 ;; This file is part of GNU Emacs. | |
12 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92292
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
180 | 14 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92292
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92292
diff
changeset
|
16 ;; (at your option) any later version. |
180 | 17 |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92292
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
180 | 25 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
26 ;;; Commentary: |
180 | 27 |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
28 ;; The following defines an association list for text to be |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
29 ;; automatically inserted when a new file is created, and a function |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
30 ;; which automatically inserts these files; the idea is to insert |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
31 ;; default text much as the mode is automatically set using |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
32 ;; auto-mode-alist. |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
33 ;; |
26661 | 34 ;; To use: |
60876
e6350e6a85be
find-file-hooks -> find-file-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58242
diff
changeset
|
35 ;; (add-hook 'find-file-hook 'auto-insert) |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
36 ;; setq auto-insert-directory to an appropriate slash-terminated value |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
37 ;; |
20809
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
38 ;; You can also customize the variable `auto-insert-mode' to load the |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
39 ;; package. Alternatively, add the following to your .emacs file: |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
40 ;; (auto-insert-mode 1) |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
41 ;; |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
42 ;; Author: Charlie Martin |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
43 ;; Department of Computer Science and |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
44 ;; National Biomedical Simulation Resource |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
45 ;; Box 3709 |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
46 ;; Duke University Medical Center |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
47 ;; Durham, NC 27710 |
26661 | 48 ;; (crm@cs.duke.edu,mcnc!duke!crm) |
180 | 49 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
50 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
51 |
20809
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
52 (defgroup auto-insert nil |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
53 "Automatic mode-dependent insertion of text into new files." |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
54 :prefix "auto-insert-" |
22250
a77d473867b8
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21287
diff
changeset
|
55 :group 'files |
a77d473867b8
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21287
diff
changeset
|
56 :group 'convenience) |
20809
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
57 |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
58 |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
59 (defcustom auto-insert 'not-modified |
26661 | 60 "*Controls automatic insertion into newly found empty files. |
61 Possible values: | |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
62 nil do nothing |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
63 t insert if possible |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
64 other insert if possible, but mark as unmodified. |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
65 Insertion is possible when something appropriate is found in |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
66 `auto-insert-alist'. When the insertion is marked as unmodified, you can |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
67 save it with \\[write-file] RET. |
31878 | 68 This variable is used when the function `auto-insert' is called, e.g. |
60876
e6350e6a85be
find-file-hooks -> find-file-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58242
diff
changeset
|
69 when you do (add-hook 'find-file-hook 'auto-insert). |
26661 | 70 With \\[auto-insert], this is always treated as if it were t." |
21287
f61d91aef100
(auto-insert, auto-insert-query): :tag choices.
Dave Love <fx@gnu.org>
parents:
20809
diff
changeset
|
71 :type '(choice (const :tag "Insert if possible" t) |
f61d91aef100
(auto-insert, auto-insert-query): :tag choices.
Dave Love <fx@gnu.org>
parents:
20809
diff
changeset
|
72 (const :tag "Do nothing" nil) |
26661 | 73 (other :tag "insert if possible, mark as unmodified." |
21287
f61d91aef100
(auto-insert, auto-insert-query): :tag choices.
Dave Love <fx@gnu.org>
parents:
20809
diff
changeset
|
74 not-modified)) |
20809
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
75 :group 'auto-insert) |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
76 |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
77 (defcustom auto-insert-query 'function |
26661 | 78 "*Non-nil means ask user before auto-inserting. |
20809
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
79 When this is `function', only ask when called non-interactively." |
22567
b20af24c6cdd
(auto-insert, auto-insert-query): Use `other'
Andreas Schwab <schwab@suse.de>
parents:
22250
diff
changeset
|
80 :type '(choice (const :tag "Don't ask" nil) |
b20af24c6cdd
(auto-insert, auto-insert-query): Use `other'
Andreas Schwab <schwab@suse.de>
parents:
22250
diff
changeset
|
81 (const :tag "Ask if called non-interactively" function) |
b20af24c6cdd
(auto-insert, auto-insert-query): Use `other'
Andreas Schwab <schwab@suse.de>
parents:
22250
diff
changeset
|
82 (other :tag "Ask" t)) |
20809
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
83 :group 'auto-insert) |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
84 |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
85 (defcustom auto-insert-prompt "Perform %s auto-insertion? " |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
86 "*Prompt to use when querying whether to auto-insert. |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
87 If this contains a %s, that will be replaced by the matching rule." |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
88 :type 'string |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
89 :group 'auto-insert) |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
90 |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
91 |
20809
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
92 (defcustom auto-insert-alist |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
93 '((("\\.\\([Hh]\\|hh\\|hpp\\)\\'" . "C / C++ header") |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
94 (upcase (concat (file-name-nondirectory |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
95 (substring buffer-file-name 0 (match-beginning 0))) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
96 "_" |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
97 (substring buffer-file-name (1+ (match-beginning 0))))) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
98 "#ifndef " str \n |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
99 "#define " str "\n\n" |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
100 _ "\n\n#endif") |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
101 |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
102 (("\\.\\([Cc]\\|cc\\|cpp\\)\\'" . "C / C++ program") |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
103 nil |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
104 "#include \"" |
42161
18516f8e5cff
(auto-insert-alist): Redo finding C and C++ headers.
Richard M. Stallman <rms@gnu.org>
parents:
34380
diff
changeset
|
105 (let ((stem (file-name-sans-extension buffer-file-name))) |
18516f8e5cff
(auto-insert-alist): Redo finding C and C++ headers.
Richard M. Stallman <rms@gnu.org>
parents:
34380
diff
changeset
|
106 (cond ((file-exists-p (concat stem ".h")) |
18516f8e5cff
(auto-insert-alist): Redo finding C and C++ headers.
Richard M. Stallman <rms@gnu.org>
parents:
34380
diff
changeset
|
107 (file-name-nondirectory (concat stem ".h"))) |
18516f8e5cff
(auto-insert-alist): Redo finding C and C++ headers.
Richard M. Stallman <rms@gnu.org>
parents:
34380
diff
changeset
|
108 ((file-exists-p (concat stem ".hh")) |
18516f8e5cff
(auto-insert-alist): Redo finding C and C++ headers.
Richard M. Stallman <rms@gnu.org>
parents:
34380
diff
changeset
|
109 (file-name-nondirectory (concat stem ".hh"))))) |
18516f8e5cff
(auto-insert-alist): Redo finding C and C++ headers.
Richard M. Stallman <rms@gnu.org>
parents:
34380
diff
changeset
|
110 & ?\" | -10) |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
111 |
42161
18516f8e5cff
(auto-insert-alist): Redo finding C and C++ headers.
Richard M. Stallman <rms@gnu.org>
parents:
34380
diff
changeset
|
112 (("[Mm]akefile\\'" . "Makefile") . "makefile.inc") |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
113 |
14153
3e949d37e46f
(auto-insert-alist): For html-mode, use `sgml-tag'.
Richard M. Stallman <rms@gnu.org>
parents:
12502
diff
changeset
|
114 (html-mode . (lambda () (sgml-tag "html"))) |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49024
diff
changeset
|
115 |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
116 (plain-tex-mode . "tex-insert.tex") |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
117 (bibtex-mode . "tex-insert.tex") |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
118 (latex-mode |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
119 ;; should try to offer completing read for these |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
120 "options, RET: " |
33252
ffb346e61cf2
(auto-insert-alist) <latex-mode>: Use
Dave Love <fx@gnu.org>
parents:
33184
diff
changeset
|
121 "\\documentclass[" str & ?\] | -1 |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
122 ?{ (read-string "class: ") "}\n" |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
123 ("package, %s: " |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
124 "\\usepackage[" (read-string "options, RET: ") & ?\] | -1 ?{ str "}\n") |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
125 _ "\n\\begin{document}\n" _ |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
126 "\n\\end{document}") |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
127 |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
128 (("/bin/.*[^/]\\'" . "Shell-Script mode magic number") |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
129 lambda () |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
130 (if (eq major-mode default-major-mode) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
131 (sh-mode))) |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49024
diff
changeset
|
132 |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
133 (ada-mode . ada-header) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
134 |
49024
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
135 (("\\.[1-9]\\'" . "Man page skeleton") |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
136 "Short description: " |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
137 ".\\\" Copyright (C), " (substring (current-time-string) -4) " " |
55040
4728f7603f2a
(auto-insert-alist): Insert the user's name in
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
138 (getenv "ORGANIZATION") | (progn user-full-name) |
49024
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
139 " |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
140 .\\\" You may distribute this file under the terms of the GNU Free |
63623
39385d905a25
(auto-insert-alist): Fix spellings.
Juanma Barranquero <lekktu@gmail.com>
parents:
60876
diff
changeset
|
141 .\\\" Documentation License. |
49024
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
142 .TH " (file-name-sans-extension (file-name-nondirectory (buffer-file-name))) |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
143 " " (file-name-extension (buffer-file-name)) |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
144 " " (format-time-string "%Y-%m-%d ") |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
145 "\n.SH NAME\n" |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
146 (file-name-sans-extension (file-name-nondirectory (buffer-file-name))) |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
147 " \\- " str |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
148 "\n.SH SYNOPSIS |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
149 .B " (file-name-sans-extension (file-name-nondirectory (buffer-file-name))) |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
150 "\n" |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
151 _ |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
152 " |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
153 .SH DESCRIPTION |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
154 .SH OPTIONS |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
155 .SH FILES |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
156 .SH \"SEE ALSO\" |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
157 .SH BUGS |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
158 .SH AUTHOR |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
159 " (user-full-name) |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
160 '(if (search-backward "&" (line-beginning-position) t) |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
161 (replace-match (capitalize (user-login-name)) t t)) |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
162 '(end-of-line 1) " <" (progn user-mail-address) ">\n") |
417bead90660
(auto-insert-alist): Add man page skeleton.
Dave Love <fx@gnu.org>
parents:
45025
diff
changeset
|
163 |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
164 (("\\.el\\'" . "Emacs Lisp header") |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
165 "Short description: " |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
166 ";;; " (file-name-nondirectory (buffer-file-name)) " --- " str " |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
167 |
34380
45cb6948fefa
(auto-insert-alist): Add missing final \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33794
diff
changeset
|
168 ;; Copyright (C) " (substring (current-time-string) -4) " " |
58242
239eb406bf92
(auto-insert-alist): Insert the user's name in copyright notice,
John Paul Wallington <jpw@pobox.com>
parents:
55040
diff
changeset
|
169 (getenv "ORGANIZATION") | (progn user-full-name) " |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
170 |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
171 ;; Author: " (user-full-name) |
31878 | 172 '(if (search-backward "&" (line-beginning-position) t) |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
173 (replace-match (capitalize (user-login-name)) t t)) |
23782
ffae9b995e65
(auto-insert-alist): Use user-mail-address.
Richard M. Stallman <rms@gnu.org>
parents:
23708
diff
changeset
|
174 '(end-of-line 1) " <" (progn user-mail-address) "> |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
175 ;; Keywords: " |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
176 '(require 'finder) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
177 ;;'(setq v1 (apply 'vector (mapcar 'car finder-known-keywords))) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
178 '(setq v1 (mapcar (lambda (x) (list (symbol-name (car x)))) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
179 finder-known-keywords) |
79586
83cdf5665b35
(auto-insert-alist): Remove nonsensical precision
Martin Rudalics <rudalics@gmx.at>
parents:
78236
diff
changeset
|
180 v2 (mapconcat (lambda (x) (format "%12s: %s" (car x) (cdr x))) |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
181 finder-known-keywords |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
182 "\n")) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
183 ((let ((minibuffer-help-form v2)) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
184 (completing-read "Keyword, C-h: " v1 nil t)) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
185 str ", ") & -2 " |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
186 |
92253
fa0d39c9e1ee
(auto-insert-alist): Change permission text to match FSF's GPLv3 form.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
187 \;; This program is free software; you can redistribute it and/or modify |
81053
469db45b9f02
(auto-insert-alist): Quote elisp sample code so as not
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75347
diff
changeset
|
188 \;; it under the terms of the GNU General Public License as published by |
92253
fa0d39c9e1ee
(auto-insert-alist): Change permission text to match FSF's GPLv3 form.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
189 \;; the Free Software Foundation, either version 3 of the License, or |
fa0d39c9e1ee
(auto-insert-alist): Change permission text to match FSF's GPLv3 form.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
190 \;; (at your option) any later version. |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
191 |
92253
fa0d39c9e1ee
(auto-insert-alist): Change permission text to match FSF's GPLv3 form.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
192 \;; This program is distributed in the hope that it will be useful, |
81053
469db45b9f02
(auto-insert-alist): Quote elisp sample code so as not
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75347
diff
changeset
|
193 \;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
469db45b9f02
(auto-insert-alist): Quote elisp sample code so as not
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75347
diff
changeset
|
194 \;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
469db45b9f02
(auto-insert-alist): Quote elisp sample code so as not
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75347
diff
changeset
|
195 \;; GNU General Public License for more details. |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
196 |
81053
469db45b9f02
(auto-insert-alist): Quote elisp sample code so as not
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75347
diff
changeset
|
197 \;; You should have received a copy of the GNU General Public License |
92253
fa0d39c9e1ee
(auto-insert-alist): Change permission text to match FSF's GPLv3 form.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
198 \;; along with this program. If not, see <http://www.gnu.org/licenses/>. |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
199 |
81053
469db45b9f02
(auto-insert-alist): Quote elisp sample code so as not
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75347
diff
changeset
|
200 \;;; Commentary: |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
201 |
81053
469db45b9f02
(auto-insert-alist): Quote elisp sample code so as not
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75347
diff
changeset
|
202 \;; " _ " |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
203 |
81053
469db45b9f02
(auto-insert-alist): Quote elisp sample code so as not
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75347
diff
changeset
|
204 \;;; Code: |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
205 |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
206 |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
207 |
33794
f35b09043a64
(auto-insert-alist): Add `provide' to elisp skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33252
diff
changeset
|
208 \(provide '" |
f35b09043a64
(auto-insert-alist): Add `provide' to elisp skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33252
diff
changeset
|
209 (file-name-sans-extension (file-name-nondirectory (buffer-file-name))) |
f35b09043a64
(auto-insert-alist): Add `provide' to elisp skeleton.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33252
diff
changeset
|
210 ") |
85054
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
211 \;;; " (file-name-nondirectory (buffer-file-name)) " ends here\n") |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
212 (("\\.texi\\(nfo\\)?\\'" . "Texinfo file skeleton") |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
213 "Title: " |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
214 "\\input texinfo @c -*-texinfo-*- |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
215 @c %**start of header |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
216 @setfilename " |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
217 (file-name-sans-extension |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
218 (file-name-nondirectory (buffer-file-name))) ".info\n" |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
219 "@settitle " str " |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
220 @c %**end of header |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
221 @copying\n" |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
222 (setq short-description (read-string "Short description: ")) |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
223 ".\n\n" |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
224 "Copyright @copyright{} " (substring (current-time-string) -4) " " |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
225 (getenv "ORGANIZATION") | (progn user-full-name) " |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
226 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
227 @quotation |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
228 Permission is granted to copy, distribute and/or modify this document |
92292
c7a02490dc02
(auto-insert-alist): Update to FDL 1.2.
Glenn Morris <rgm@gnu.org>
parents:
92253
diff
changeset
|
229 under the terms of the GNU Free Documentation License, Version 1.2 |
c7a02490dc02
(auto-insert-alist): Update to FDL 1.2.
Glenn Morris <rgm@gnu.org>
parents:
92253
diff
changeset
|
230 or any later version published by the Free Software Foundation; |
c7a02490dc02
(auto-insert-alist): Update to FDL 1.2.
Glenn Morris <rgm@gnu.org>
parents:
92253
diff
changeset
|
231 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover |
c7a02490dc02
(auto-insert-alist): Update to FDL 1.2.
Glenn Morris <rgm@gnu.org>
parents:
92253
diff
changeset
|
232 Texts. A copy of the license is included in the section entitled ``GNU |
c7a02490dc02
(auto-insert-alist): Update to FDL 1.2.
Glenn Morris <rgm@gnu.org>
parents:
92253
diff
changeset
|
233 Free Documentation License''. |
85054
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
234 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
235 A copy of the license is also available from the Free Software |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
236 Foundation Web site at @url{http://www.gnu.org/licenses/fdl.html}. |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
237 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
238 @end quotation |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
239 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
240 The document was typeset with |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
241 @uref{http://www.texinfo.org/, GNU Texinfo}. |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
242 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
243 @end copying |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
244 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
245 @titlepage |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
246 @title " str " |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
247 @subtitle " short-description " |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
248 @author " (getenv "ORGANIZATION") | (progn user-full-name) |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
249 " <" (progn user-mail-address) "> |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
250 @page |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
251 @vskip 0pt plus 1filll |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
252 @insertcopying |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
253 @end titlepage |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
254 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
255 @c Output the table of the contents at the beginning. |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
256 @contents |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
257 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
258 @ifnottex |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
259 @node Top |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
260 @top " str " |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
261 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
262 @insertcopying |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
263 @end ifnottex |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
264 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
265 @c Generate the nodes for this menu with `C-c C-u C-m'. |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
266 @menu |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
267 @end menu |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
268 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
269 @c Update all node entries with `C-c C-u C-n'. |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
270 @c Insert new nodes with `C-c C-c n'. |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
271 @node Chapter One |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
272 @chapter Chapter One |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
273 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
274 " _ " |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
275 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
276 @node Copying This Manual |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
277 @appendix Copying This Manual |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
278 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
279 @menu |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
280 * GNU Free Documentation License:: License for copying this manual. |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
281 @end menu |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
282 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
283 @c Get fdl.texi from http://www.gnu.org/licenses/fdl.html |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
284 @include fdl.texi |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
285 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
286 @node Index |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
287 @unnumbered Index |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
288 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
289 @printindex cp |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
290 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
291 @bye |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
292 |
76282b9aa263
Aaron Hawley <aaronh at garden.org>
Glenn Morris <rgm@gnu.org>
parents:
84857
diff
changeset
|
293 @c " (file-name-nondirectory (buffer-file-name)) " ends here\n")) |
180 | 294 "A list specifying text to insert by default into a new file. |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
295 Elements look like (CONDITION . ACTION) or ((CONDITION . DESCRIPTION) . ACTION). |
73274
46e9c5d41caa
(auto-insert-alist): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
68651
diff
changeset
|
296 CONDITION may be a regexp that must match the new file's name, or it may be |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
297 a symbol that must match the major mode for this element to apply. |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
298 Only the first matching element is effective. |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
299 Optional DESCRIPTION is a string for filling `auto-insert-prompt'. |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
300 ACTION may be a skeleton to insert (see `skeleton-insert'), an absolute |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
301 file-name or one relative to `auto-insert-directory' or a function to call. |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
302 ACTION may also be a vector containing several successive single actions as |
20809
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
303 described above, e.g. [\"header.insert\" date-and-author-update]." |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
304 :type 'sexp |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
305 :group 'auto-insert) |
180 | 306 |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
307 |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
308 ;; Establish a default value for auto-insert-directory |
20809
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
309 (defcustom auto-insert-directory "~/insert/" |
44978
9b2201ff0db7
(auto-insert-directory): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
42161
diff
changeset
|
310 "*Directory from which auto-inserted files are taken. |
45025
b38fc6fb7a1a
(auto-insert-directory): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
44984
diff
changeset
|
311 The value must be an absolute directory name; |
b38fc6fb7a1a
(auto-insert-directory): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
44984
diff
changeset
|
312 thus, on a GNU or Unix system, it must end in a slash." |
20809
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
313 :type 'directory |
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
314 :group 'auto-insert) |
180 | 315 |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
316 |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
317 ;;;###autoload |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
318 (defun auto-insert () |
31878 | 319 "Insert default contents into new files if variable `auto-insert' is non-nil. |
180 | 320 Matches the visited file name against the elements of `auto-insert-alist'." |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
321 (interactive) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
322 (and (not buffer-read-only) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
323 (or (eq this-command 'auto-insert) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
324 (and auto-insert |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
325 (bobp) (eobp))) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
326 (let ((alist auto-insert-alist) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
327 case-fold-search cond desc action) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
328 (goto-char 1) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
329 ;; find first matching alist entry |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
330 (while alist |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
331 (if (atom (setq cond (car (car alist)))) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
332 (setq desc cond) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
333 (setq desc (cdr cond) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
334 cond (car cond))) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
335 (if (if (symbolp cond) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
336 (eq cond major-mode) |
31878 | 337 (and buffer-file-name |
338 (string-match cond buffer-file-name))) | |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
339 (setq action (cdr (car alist)) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
340 alist nil) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
341 (setq alist (cdr alist)))) |
180 | 342 |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
343 ;; Now, if we found something, do it |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
344 (and action |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
345 (if (stringp action) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
346 (file-readable-p (concat auto-insert-directory action)) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
347 t) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
348 (if auto-insert-query |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
349 (or (if (eq auto-insert-query 'function) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
350 (eq this-command 'auto-insert)) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
351 (y-or-n-p (format auto-insert-prompt desc))) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
352 t) |
84857
03c05458c97e
(auto-insert): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82140
diff
changeset
|
353 (mapc |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
354 (lambda (action) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
355 (if (stringp action) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
356 (if (file-readable-p |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
357 (setq action (concat auto-insert-directory action))) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
358 (insert-file-contents action)) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
359 (save-window-excursion |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
360 ;; make buffer visible before skeleton or function |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
361 ;; which might ask the user for something |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
362 (switch-to-buffer (current-buffer)) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
363 (if (and (consp action) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
364 (not (eq (car action) 'lambda))) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
365 (skeleton-insert action) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
366 (funcall action))))) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
367 (if (vectorp action) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
368 action |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
369 (vector action)))) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
370 (and (buffer-modified-p) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
371 (not (eq this-command 'auto-insert)) |
26661 | 372 (set-buffer-modified-p (eq auto-insert t))))) |
373 ;; Return nil so that it could be used in | |
374 ;; `find-file-not-found-hooks', though that's probably inadvisable. | |
375 nil) | |
180 | 376 |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
377 |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
378 ;;;###autoload |
21287
f61d91aef100
(auto-insert, auto-insert-query): :tag choices.
Dave Love <fx@gnu.org>
parents:
20809
diff
changeset
|
379 (defun define-auto-insert (condition action &optional after) |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
380 "Associate CONDITION with (additional) ACTION in `auto-insert-alist'. |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
381 Optional AFTER means to insert action after all existing actions for CONDITION, |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
382 or if CONDITION had no actions, after all other CONDITIONs." |
21287
f61d91aef100
(auto-insert, auto-insert-query): :tag choices.
Dave Love <fx@gnu.org>
parents:
20809
diff
changeset
|
383 (let ((elt (assoc condition auto-insert-alist))) |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
384 (if elt |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
385 (setcdr elt |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
386 (if (vectorp (cdr elt)) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
387 (vconcat (if after (cdr elt)) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
388 (if (vectorp action) action (vector action)) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
389 (if after () (cdr elt))) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
390 (if after |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
391 (vector (cdr elt) action) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
392 (vector action (cdr elt))))) |
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
393 (if after |
21287
f61d91aef100
(auto-insert, auto-insert-query): :tag choices.
Dave Love <fx@gnu.org>
parents:
20809
diff
changeset
|
394 (nconc auto-insert-alist (list (cons condition action))) |
f61d91aef100
(auto-insert, auto-insert-query): :tag choices.
Dave Love <fx@gnu.org>
parents:
20809
diff
changeset
|
395 (setq auto-insert-alist (cons (cons condition action) |
12502
8bb3424bf745
extended to use skeletons or call functions
Karl Heuer <kwzh@gnu.org>
parents:
8764
diff
changeset
|
396 auto-insert-alist)))))) |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
180
diff
changeset
|
397 |
20809
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
398 ;;;###autoload |
32025
e67c88d8e5c4
(auto-insert-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31878
diff
changeset
|
399 (define-minor-mode auto-insert-mode |
26661 | 400 "Toggle Auto-insert mode. |
401 With prefix ARG, turn Auto-insert mode on if and only if ARG is positive. | |
402 Returns the new status of Auto-insert mode (non-nil means on). | |
20809
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
403 |
26661 | 404 When Auto-insert mode is enabled, when new files are created you can |
20809
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
405 insert a template for the file depending on the mode of the buffer." |
33184
8e6b63f3317d
(auto-insert-mode): Drop unneeded positional args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32025
diff
changeset
|
406 :global t :group 'auto-insert |
32025
e67c88d8e5c4
(auto-insert-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31878
diff
changeset
|
407 (if auto-insert-mode |
60876
e6350e6a85be
find-file-hooks -> find-file-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58242
diff
changeset
|
408 (add-hook 'find-file-hook 'auto-insert) |
e6350e6a85be
find-file-hooks -> find-file-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58242
diff
changeset
|
409 (remove-hook 'find-file-hook 'auto-insert))) |
20809
c582e15d8cfc
(auto-insert-mode): New function.
Stephen Eglen <stephen@gnu.org>
parents:
18383
diff
changeset
|
410 |
18383 | 411 (provide 'autoinsert) |
412 | |
60876
e6350e6a85be
find-file-hooks -> find-file-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58242
diff
changeset
|
413 ;; arch-tag: 5b6630ac-c735-43cf-b097-b78c622af909 |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
180
diff
changeset
|
414 ;;; autoinsert.el ends here |