1 ;;; el.srt --- SRecode templates for Emacs Lisp mode
3 ;; Copyright (C) 2007-2016 Free Software Foundation, Inc.
5 ;; Author: Eric Ludlam <zappo@gnu.org>
7 ;; This file is part of GNU Emacs.
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.
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.
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/>.
25 set mode "emacs-lisp-mode"
27 set comment_start ";;;"
28 set comment_prefix ";;"
35 template section-comment :blank
36 "Insert a comment that separates sections of an Emacs Lisp file."
46 template empty :user :time :file
47 "Insert a skeleton for an Emacs Lisp file."
60 ;;; $FILENAME$ ends here
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: "
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."
83 $>:declaration:defgroup$
87 $<FONTLOCK:declaration:variable$
92 $>:declaration:keymap$
94 $<MODEHOOK:declaration:variable-option$nil$/MODEHOOK$
97 $<MODEFCN:declaration:function$
99 (kill-all-local-variables)
100 (setq major-mode '$MODESYM$-mode
101 mode-name "$?MODENAME$"
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)
119 (add-to-list 'auto-mode-alist '("\\.$?MODEEXTENSION$$DOLLAR$" . $MODESYM$-mode))
121 $<A:section-comment$Commands for $MODESYM$$/A$
123 $<B:section-comment$Utils for $MODESYM$$/B$
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."
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)
150 template include :blank
151 "Insert a require statement."
157 template include-protected :blank
158 "Insert a require statement."
165 prompt INTERACTIVE "Is this an interactive function? " default " (interactive)\n " read y-or-n-p
166 prompt NAME "Name: " defaultmacro "PRENAME"
168 template function :el :indent :blank
169 "Insert a defun outline."
171 (defun $?NAME$ ($#ARGS$$NAME$$#NOTLAST$ $/NOTLAST$$/ARGS$)
179 template variable :el :indent :blank
188 template variable-const :el :indent :blank
191 (defconst $?NAME$ $^$
195 template variable-option :el :el-custom :indent :blank
196 "Inert a variable created using defcustom."
198 (defcustom $?NAME$ $^$
205 template class :el :indent :blank
206 "Insert a new class."
209 (($?ARG1$ :initarg :$ARG1$
217 template class-tag :el :indent :blank
218 "Insert a new class."
220 (defclass $?NAME$ ($#PARENTS$$NAME$ $/PARENTS$)
226 template method :el :ctxt :indent :blank
227 "Insert a new method."
229 (defmethod $?NAME$ ((this $?PARENT$))
236 template method-tag :el :ctxt :indent :blank
237 "Insert a new method for tag inserter."
239 (defmethod $NAME$ ($#ARGS$$#FIRST$($NAME$ $PARENT$)$/FIRST$$#NOTFIRST$ $NAME$$/NOTFIRST$$/ARGS$)
245 prompt NAME "Method to Override: " defaultmacro "PRENAME" read mode-local-read-function
246 prompt PARENT "Major Mode for binding: " defaultmacro "MODESYM"
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."
252 (define-mode-local-override $?NAME$ $?PARENT$ ()
259 template defgroup :indent :blank
260 "Create a custom group."
262 (defgroup $?MODESYM$-mode nil
269 template keymap :indent :blank
270 "Insert a keymap of some sort"
272 (defvar $?MODESYM$-mode-map
273 (let ((km (make-sparse-keymap)))
274 (define-key km "\C-c\C-c" '$MODESYM$-mode$^$)
276 "Keymap used in `$MODESYM$-mode'.")
283 prompt NAME "Slot Name: "
285 template variable-tag :indent :indent :blank
286 "A field in a class."
288 ($?NAME$ :initarg :$NAME$
289 $#DEFAULTVALUE$:initform $VALUE$$/DEFAULTVALUE$
295 template variable :indent :indent :blank
296 "A field in a class."
298 ($?NAME$ :initarg :$NAME$