34a8983b29fed1394b0b12792acfde593d59ccdc
[bpt/emacs.git] / etc / srecode / el.srt
1 ;;; el.srt --- SRecode templates for Emacs Lisp mode
2
3 ;; Copyright (C) 2007-2012 Free Software Foundation, Inc.
4
5 ;; Author: Eric Ludlam <zappo@gnu.org>
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22 set escape_start "$"
23 set escape_end "$"
24
25 set mode "emacs-lisp-mode"
26
27 set comment_start ";;;"
28 set comment_prefix ";;"
29 set comment_end ""
30
31 set DOLLAR "$"
32
33 context file
34
35 template section-comment :blank
36 "Insert a comment that separates sections of an Emacs Lisp file."
37 ----
38 \f
39 ;;; $^$
40 ;;
41
42 ----
43 bind "s"
44
45
46 template empty :user :time :file
47 "Insert a skeleton for an Emacs Lisp file."
48 ----
49 $>:filecomment$
50
51 ;;; Commentary:
52 ;;
53 ;; $^$
54
55 ;;; Code:
56
57
58 (provide '$FILE$)
59
60 ;;; $FILENAME$ ends here
61
62 ----
63
64 prompt MODESYM "Major Mode Symbol (sans -mode): "
65 prompt MODENAME "Nice Name of mode: " defaultmacro "MODESYM"
66 prompt MODEEXTENSION "File name extension for mode: "
67
68 template major-mode :file :blank :indent
69 "Insert the framework needed for a major mode."
70 sectiondictionary "FONTLOCK"
71 set NAME macro "MODESYM" "-mode-font-lock-keywords"
72 set DOC "Keywords for use with srecode macros and font-lock."
73 sectiondictionary "MODEHOOK"
74 set NAME macro "MODESYM" "-mode-hook"
75 set DOC "Hook run when " macro "MODESYM" " starts."
76 set GROUP macro "MODESYM" "-mode"
77 set CUSTOMTYPE "'hook"
78 sectiondictionary "MODEFCN"
79 set NAME macro "MODESYM" "-mode"
80 set DOC "Major-mode for " macro "MODESYM" "-mode buffers."
81 set INTERACTIVE ""
82 ----
83 $>:declaration:defgroup$
84
85 $>:syntax-table$
86
87 $<FONTLOCK:declaration:variable$
88 '(
89 )
90 $/FONTLOCK$
91
92 $>:declaration:keymap$
93
94 $<MODEHOOK:declaration:variable-option$nil$/MODEHOOK$
95
96 ;;;###autoload
97 $<MODEFCN:declaration:function$
98 (interactive)
99 (kill-all-local-variables)
100 (setq major-mode '$MODESYM$-mode
101 mode-name "$?MODENAME$"
102 comment-start ";;"
103 comment-end "")
104 (set (make-local-variable 'comment-start-skip)
105 "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
106 (set-syntax-table $MODESYM$-mode-syntax-table)
107 (use-local-map $MODESYM$-mode-map)
108 (set (make-local-variable 'font-lock-defaults)
109 '($MODESYM$-mode-font-lock-keywords
110 nil ;; perform string/comment fontification
111 nil ;; keywords are case sensitive.
112 ;; This puts _ & - as a word constituent,
113 ;; simplifying our keywords significantly
114 ((?_ . "w") (?- . "w"))))
115 (run-hooks '$MODESYM$-mode-hook)
116 $/MODEFCN$
117
118 ;;;###autoload
119 (add-to-list 'auto-mode-alist '("\\.$?MODEEXTENSION$$DOLLAR$" . $MODESYM$-mode))
120
121 $<A:section-comment$Commands for $MODESYM$$/A$
122
123 $<B:section-comment$Utils for $MODESYM$$/B$
124 ----
125
126 template syntax-table
127 "Create a syntax table."
128 sectiondictionary "A"
129 set NAME macro "?MODESYM" "-mode-syntax-table"
130 set DOC "Syntax table used in " macro "?MODESYM" " buffers."
131 ----
132 $<A:declaration:variable$
133 (let ((table (make-syntax-table (standard-syntax-table))))
134 (modify-syntax-entry ?\; ". 12" table) ;; SEMI, Comment start ;;
135 (modify-syntax-entry ?\n ">" table) ;; Comment end
136 (modify-syntax-entry ?\" "\"" table) ;; String
137 (modify-syntax-entry ?\- "_" table) ;; Symbol
138 (modify-syntax-entry ?\\ "\\" table) ;; Quote
139 (modify-syntax-entry ?\` "'" table) ;; Prefix ` (backquote)
140 (modify-syntax-entry ?\' "'" table) ;; Prefix ' (quote)
141 (modify-syntax-entry ?\, "'" table) ;; Prefix , (comma)
142
143 table)
144 $/A$
145 ----
146
147
148 context declaration
149
150 template include :blank
151 "Insert a require statement."
152 ----
153 (require '$?NAME$)
154 ----
155 bind "i"
156
157 template include-protected :blank
158 "Insert a require statement."
159 ----
160 (condition-case nil
161 (require '$?NAME$)
162 (error nil))
163 ----
164
165 prompt INTERACTIVE "Is this an interactive function? " default " (interactive)\n " read y-or-n-p
166 prompt NAME "Name: " defaultmacro "PRENAME"
167
168 template function :el :indent :blank
169 "Insert a defun outline."
170 ----
171 (defun $?NAME$ ($#ARGS$$NAME$$#NOTLAST$ $/NOTLAST$$/ARGS$)
172 "$DOC$"
173 $?INTERACTIVE$$^$
174 )
175 ----
176 bind "f"
177
178
179 template variable :el :indent :blank
180 "Inert a variable.
181 DOC is optional."
182 ----
183 (defvar $?NAME$ $^$
184 "$DOC$")
185 ----
186 bind "v"
187
188 template variable-const :el :indent :blank
189 "Inert a variable."
190 ----
191 (defconst $?NAME$ $^$
192 "$DOC$")
193 ----
194
195 template variable-option :el :el-custom :indent :blank
196 "Inert a variable created using defcustom."
197 ----
198 (defcustom $?NAME$ $^$
199 "*$DOC$"
200 :group '$GROUP$
201 :type $?CUSTOMTYPE$)
202 ----
203 bind "o"
204
205 template class :el :indent :blank
206 "Insert a new class."
207 ----
208 (defclass $?NAME$ ()
209 (($?ARG1$ :initarg :$ARG1$
210 :documentation
211 "$^$")
212 )
213 "Class $NAME$ ")
214 ----
215 bind "c"
216
217 template class-tag :el :indent :blank
218 "Insert a new class."
219 ----
220 (defclass $?NAME$ ($#PARENTS$$NAME$ $/PARENTS$)
221 ($^$
222 )
223 "Class $NAME$ ")
224 ----
225
226 template method :el :ctxt :indent :blank
227 "Insert a new method."
228 ----
229 (defmethod $?NAME$ ((this $?PARENT$))
230 "$DOC$"
231 $^$
232 )
233 ----
234 bind "m"
235
236 template method-tag :el :ctxt :indent :blank
237 "Insert a new method for tag inserter."
238 ----
239 (defmethod $NAME$ ($#ARGS$$#FIRST$($NAME$ $PARENT$)$/FIRST$$#NOTFIRST$ $NAME$$/NOTFIRST$$/ARGS$)
240 "$DOC$"
241 $^$
242 )
243 ----
244
245 prompt NAME "Method to Override: " defaultmacro "PRENAME" read mode-local-read-function
246 prompt PARENT "Major Mode for binding: " defaultmacro "MODESYM"
247
248 ;; Note: PARENT is used for override methods and for classes. Handy!
249 template modelocal :el :ctxt :indent :blank
250 "Insert a new mode-local function."
251 ----
252 (define-mode-local-override $?NAME$ $?PARENT$ ()
253 "$DOC$"
254 $^$)
255 ----
256 bind "l"
257
258
259 template defgroup :indent :blank
260 "Create a custom group."
261 ----
262 (defgroup $?MODESYM$-mode nil
263 "$MODESYM$ group."
264 :group 'languages)
265 ----
266 bind "g"
267
268
269 template keymap :indent :blank
270 "Insert a keymap of some sort"
271 ----
272 (defvar $?MODESYM$-mode-map
273 (let ((km (make-sparse-keymap)))
274 (define-key km "\C-c\C-c" '$MODESYM$-mode$^$)
275 km)
276 "Keymap used in `$MODESYM$-mode'.")
277 ----
278 bind "k"
279
280
281 context classdecl
282
283 prompt NAME "Slot Name: "
284
285 template variable-tag :indent :indent :blank
286 "A field in a class."
287 ----
288 ($?NAME$ :initarg :$NAME$
289 $#DEFAULTVALUE$:initform $VALUE$$/DEFAULTVALUE$
290 :documentation
291 "$DOC$")
292
293 ----
294
295 template variable :indent :indent :blank
296 "A field in a class."
297 ----
298 ($?NAME$ :initarg :$NAME$
299 :initform nil
300 :type list
301 :documentation
302 "$DOC$")
303
304 ----
305 bind "s"
306
307
308
309 ;; end
310
311