annotate lisp/utils/skeleton.el @ 94:1040fe1366ac xemacs-20-0f2

Import from CVS: tag xemacs-20-0f2
author cvs
date Mon, 13 Aug 2007 09:12:09 +0200
parents 131b0175ea99
children 34a5b81f86ba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; skeleton.el --- Lisp language extension for writing statement skeletons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Copyright (C) 1993, 1994, 1995 by Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Daniel.Pfeiffer@Informatik.START.dbp.de, fax (+49 69) 7588-2389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Maintainer: FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: extensions, abbrev, languages, tools
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
8 ;; This file is part of XEmacs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
11 ;; under the terms of the GNU General Public License as published by
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
18 ;; General Public License for more details.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
23 ;; 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
25 ;;; Synched up with: FSF 19.34.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; A very concise language extension for writing structured statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; skeleton insertion commands for programming language modes. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; originated in shell-script mode and was applied to ada-mode's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; commands which shrunk to one third. And these commands are now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; user configurable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; page 1: statement skeleton language definition & interpreter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; page 2: paired insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; page 3: mirror-mode, an example for setting up paired insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (defvar skeleton-transformation nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 "*If non-nil, function applied to literal strings before they are inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 It should take strings and characters and return them transformed, or nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 which means no transformation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 Typical examples might be `upcase' or `capitalize'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ; this should be a fourth argument to defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (put 'skeleton-transformation 'variable-interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 "aTransformation function: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
53 (defvar skeleton-autowrap t
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
54 "Controls wrapping behaviour of functions created with `define-skeleton'.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
55 When the region is visible (due to `transient-mark-mode' or marking a region
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
56 with the mouse) and this is non-`nil' and the function was called without an
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
57 explicit ARG, then the ARG defaults to -1, i.e. wrapping around the visible
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
58 region.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
59
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
60 We will probably delete this variable in a future Emacs version
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
61 unless we get a substantial number of complaints about the auto-wrap
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
62 feature.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (defvar skeleton-end-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (or (eolp) (newline-and-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 "Hook called at end of skeleton but before going to point of interest.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 By default this moves out anything following to next line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 The variables `v1' and `v2' are still set when calling this.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (defvar skeleton-filter 'identity
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
74 "Function for transforming a skeleton proxy's aliases' variable value.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (defvar skeleton-untabify t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 "When non-`nil' untabifies when deleting backwards with element -ARG.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defvar skeleton-newline-indent-rigidly nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 "When non-`nil', indent rigidly under current line for element `\\n'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 Else use mode's `indent-line-function'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (defvar skeleton-further-elements ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 "A buffer-local varlist (see `let') of mode specific skeleton elements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 These variables are bound while interpreting a skeleton. Their value may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 in turn be any valid skeleton element if they are themselves to be used as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 skeleton elements.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (make-variable-buffer-local 'skeleton-further-elements)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (defvar skeleton-subprompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (substitute-command-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 "RET, \\<minibuffer-local-map>\\[abort-recursive-edit] or \\[help-command]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 "*Replacement for %s in prompts of recursive subskeletons.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
97 (defvar skeleton-abbrev-cleanup nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
98 "Variable used to delete the character that led to abbrev expansion.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
100 ;; XEmacs -- won't byte compile without the wrapper
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (defvar skeleton-debug nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 "*If non-nil `define-skeleton' will override previous definition."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; reduce the number of compiler warnings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (defvar skeleton)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defvar skeleton-modified)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (defvar skeleton-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (defvar skeleton-regions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (defmacro define-skeleton (command documentation &rest skeleton)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 "Define a user-configurable COMMAND that enters a statement skeleton.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 DOCUMENTATION is that of the command, while the variable of the same name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 which contains the skeleton, has a documentation to that effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 INTERACTOR and ELEMENT ... are as defined under `skeleton-insert'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (if skeleton-debug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (set command skeleton))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 `(progn
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
120 (defun ,command (&optional str arg)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
121 ,(concat documentation
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
122 (if (string-match "\n\\>" documentation)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
123 "" "\n")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
124 "\n"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
125 "This is a skeleton command (see `skeleton-insert').
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
126 Normally the skeleton text is inserted at point, with nothing \"inside\".
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
127 If there is a highlighted region, the skeleton text is wrapped
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
128 around the region text.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
129
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
130 A prefix argument ARG says to wrap the skeleton around the next ARG words.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
131 A prefix argument of zero says to wrap around zero words---that is, nothing.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
132 This is a way of overiding the use of a highlighted region.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
133 (interactive "*P\nP")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
134 (skeleton-proxy-new ',skeleton str arg))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
136 ;;;###autoload
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
137 (defun skeleton-proxy-new (skeleton &optional str arg)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
138 "Insert skeleton defined by variable of same name (see `skeleton-insert').
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
139 Prefix ARG allows wrapping around words or regions (see `skeleton-insert').
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
140 If no ARG was given, but the region is visible, ARG defaults to -1 depending
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
141 on `skeleton-autowrap'. An ARG of M-0 will prevent this just for once.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
142 This command can also be an abbrev expansion (3rd and 4th columns in
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
143 \\[edit-abbrevs] buffer: \"\" command-name).
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
144
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
145 When called as a function, optional first argument STR may also be a string
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
146 which will be the value of `str' whereas the skeleton's interactor is then
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
147 ignored."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
148 (interactive "*P\nP")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
149 (setq skeleton (funcall skeleton-filter skeleton))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
150 (if (not skeleton)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
151 (if (memq this-command '(self-insert-command
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
152 skeleton-pair-insert-maybe
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
153 expand-abbrev))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
154 (setq buffer-undo-list (primitive-undo 1 buffer-undo-list)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
155 (skeleton-insert skeleton
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
156 (if (setq skeleton-abbrev-cleanup
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
157 (or (eq this-command 'self-insert-command)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
158 (eq this-command
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
159 'skeleton-pair-insert-maybe)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
160 ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
161 ;; Pretend C-x a e passed its prefix arg to us
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
162 (if (or arg current-prefix-arg)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
163 (prefix-numeric-value (or arg
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
164 current-prefix-arg))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
165 (and skeleton-autowrap
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
166 (or (eq last-command 'mouse-drag-region)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
167 (and (boundp 'transient-mark-mode)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
168 transient-mark-mode mark-active))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
169 -1)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
170 (if (stringp str)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
171 str))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
172 (and skeleton-abbrev-cleanup
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
173 (setq skeleton-abbrev-cleanup (point))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
174 (add-hook 'post-command-hook 'skeleton-abbrev-cleanup nil t))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;; This command isn't meant to be called, only it's aliases with meaningful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;; names are.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (defun skeleton-proxy (&optional str arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 "Insert skeleton defined by variable of same name (see `skeleton-insert').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 Prefix ARG allows wrapping around words or regions (see `skeleton-insert').
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
182 If no ARG was given, but the region is visible, ARG defaults to -1 depending
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
183 on `skeleton-autowrap'. An ARG of M-0 will prevent this just for once.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 This command can also be an abbrev expansion (3rd and 4th columns in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 \\[edit-abbrevs] buffer: \"\" command-name).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 When called as a function, optional first argument STR may also be a string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 which will be the value of `str' whereas the skeleton's interactor is then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ignored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (interactive "*P\nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (let ((function (nth 1 (backtrace-frame 1))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
192 (if (eq function 'nth) ; uncompiled Lisp function
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (setq function (nth 1 (backtrace-frame 5)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (if (eq function 'byte-code) ; tracing byte-compiled function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (setq function (nth 1 (backtrace-frame 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (if (not (setq function (funcall skeleton-filter (symbol-value function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (if (memq this-command '(self-insert-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 skeleton-pair-insert-maybe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 expand-abbrev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (setq buffer-undo-list (primitive-undo 1 buffer-undo-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (skeleton-insert function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (if (setq skeleton-abbrev-cleanup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (or (eq this-command 'self-insert-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (eq this-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 'skeleton-pair-insert-maybe)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;; Pretend C-x a e passed its prefix arg to us
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (if (or arg current-prefix-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (prefix-numeric-value (or arg
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
210 current-prefix-arg))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
211 (and skeleton-autowrap
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
212 (or (eq last-command 'mouse-drag-region)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
213 (and (boundp 'transient-mark-mode)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
214 transient-mark-mode mark-active))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
215 -1)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (if (stringp str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 str))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
218 (and skeleton-abbrev-cleanup
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
219 (setq skeleton-abbrev-cleanup (point))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
220 (add-hook 'post-command-hook 'skeleton-abbrev-cleanup nil t)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (defun skeleton-abbrev-cleanup (&rest list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 "Value for `post-command-hook' to remove char that expanded abbrev."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (if (integerp skeleton-abbrev-cleanup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (delete-region skeleton-abbrev-cleanup (point))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
228 (setq skeleton-abbrev-cleanup nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
229 (remove-hook 'post-command-hook 'skeleton-abbrev-cleanup t))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (defun skeleton-insert (skeleton &optional skeleton-regions str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 "Insert the complex statement skeleton SKELETON describes very concisely.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 With optional third REGIONS wrap first interesting point (`_') in skeleton
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 around next REGIONS words, if REGIONS is positive. If REGIONS is negative,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 wrap REGIONS preceding interregions into first REGIONS interesting positions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 \(successive `_'s) in skeleton. An interregion is the stretch of text between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 two contiguous marked points. If you marked A B C [] (where [] is the cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 in alphabetical order, the 3 interregions are simply the last 3 regions. But
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 if you marked B A [] C, the interregions are B-A, A-[], []-C.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 Optional fourth STR is the value for the variable `str' within the skeleton.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 When this is non-`nil' the interactor gets ignored, and this should be a valid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 skeleton element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 SKELETON is made up as (INTERACTOR ELEMENT ...). INTERACTOR may be nil if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 not needed, a prompt-string or an expression for complex read functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 If ELEMENT is a string or a character it gets inserted (see also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 `skeleton-transformation'). Other possibilities are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 \\n go to next line and indent according to mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 _ interesting point, interregion here, point after termination
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 > indent line (or interregion if > _) according to major mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 & do next ELEMENT if previous moved point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 | do next ELEMENT if previous didn't move point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 -num delete num preceding characters (see `skeleton-untabify')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 resume: skipped, continue here if quit is signaled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 nil skipped
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 Further elements can be defined via `skeleton-further-elements'. ELEMENT may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 itself be a SKELETON with an INTERACTOR. The user is prompted repeatedly for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 different inputs. The SKELETON is processed as often as the user enters a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 non-empty string. \\[keyboard-quit] terminates skeleton insertion, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 continues after `resume:' and positions at `_' if any. If INTERACTOR in such
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 a subskeleton is a prompt-string which contains a \".. %s ..\" it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 formatted with `skeleton-subprompt'. Such an INTERACTOR may also a list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 strings with the subskeleton being repeated once for each string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
271 Quoted Lisp expressions are evaluated evaluated for their side-effect.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
272 Other Lisp expressions are evaluated and the value treated as above.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
273 Note that expressions may not return `t' since this implies an
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 endless loop. Modes can define other symbols by locally setting them
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 to any valid skeleton element. The following local variables are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 available:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 str first time: read a string according to INTERACTOR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 then: insert previously read string once more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 help help-form during interaction with the user or `nil'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 input initial input (string or cons with index) while reading str
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
282 v1, v2 local variables for memorizing anything you want
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 When done with skeleton, but before going back to `_'-point call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 `skeleton-end-hook' if that is non-`nil'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (and skeleton-regions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (setq skeleton-regions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (if (> skeleton-regions 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (list (point-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (save-excursion (forward-word skeleton-regions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (point-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (setq skeleton-regions (- skeleton-regions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;; copy skeleton-regions - 1 elements from `mark-ring'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (let ((l1 (cons (mark-marker) mark-ring))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (l2 (list (point-marker))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (while (and l1 (> skeleton-regions 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (setq l2 (cons (car l1) l2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 skeleton-regions (1- skeleton-regions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 l1 (cdr l1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (sort l2 '<))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (goto-char (car skeleton-regions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (setq skeleton-regions (cdr skeleton-regions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (let ((beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 skeleton-modified skeleton-point resume: help input v1 v2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (eval `(let ,skeleton-further-elements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (skeleton-internal-list skeleton str)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (run-hooks 'skeleton-end-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (or (pos-visible-in-window-p beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (recenter 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (if skeleton-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (goto-char skeleton-point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (defun skeleton-read (str &optional initial-input recursive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 "Function for reading a string from the minibuffer within skeletons.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 PROMPT may contain a `%s' which will be replaced by `skeleton-subprompt'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 If non-`nil' second arg INITIAL-INPUT or variable `input' is a string or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 cons with index to insert before reading. If third arg RECURSIVE is non-`nil'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 i.e. we are handling the iterator of a subskeleton, returns empty string if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 user didn't modify input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 While reading, the value of `minibuffer-help-form' is variable `help' if that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 is non-`nil' or a default string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (let ((minibuffer-help-form (or (if (boundp 'help) (symbol-value 'help))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (if recursive "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 As long as you provide input you will insert another subskeleton.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 If you enter the empty string, the loop inserting subskeletons is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 left, and the current one is removed as far as it has been entered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 If you quit, the current subskeleton is removed as far as it has been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 entered. No more of the skeleton will be inserted, except maybe for a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 syntactically necessary termination."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 You are inserting a skeleton. Standard text gets inserted into the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 automatically, and you are prompted to fill in the variable parts.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (eolp (eolp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;; since Emacs doesn't show main window's cursor, do something noticeable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (or eolp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (open-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (setq str (if (stringp str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (read-string (format str skeleton-subprompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (setq initial-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (or initial-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (symbol-value 'input))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (eval str)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (or eolp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (delete-char 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (if (and recursive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (or (null str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (string= str "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (equal str initial-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (equal str (car-safe initial-input))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (signal 'quit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (defun skeleton-internal-list (skeleton &optional str recursive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (let* ((start (save-excursion (beginning-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (column (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (line (buffer-substring start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (save-excursion (end-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (or str
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (setq str `(setq str (skeleton-read ',(car skeleton) nil ,recursive))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (while (setq skeleton-modified (eq opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 opoint (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 skeleton (cdr skeleton))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (condition-case quit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (skeleton-internal-1 (car skeleton))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (quit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (if (eq (cdr quit) 'recursive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (setq recursive 'quit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 skeleton (memq 'resume: skeleton))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 ;; remove the subskeleton as far as it has been shown
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 ;; the subskeleton shouldn't have deleted outside current line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (delete-region start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (insert line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (move-to-column column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (if (cdr quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (setq skeleton ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 recursive nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (signal 'quit 'recursive)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 ;; maybe continue loop or go on to next outer resume: section
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (if (eq recursive 'quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (signal 'quit 'recursive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 recursive))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (defun skeleton-internal-1 (element &optional literal)
94
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
394 (cond ((or (integerp element)
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
395 (char-or-string-p element))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (if (and (integerp element) ; -num
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (< element 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (if skeleton-untabify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (backward-delete-char-untabify (- element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (delete-backward-char (- element)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (insert-before-markers (if (and skeleton-transformation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (not literal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (funcall skeleton-transformation element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 element))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ((eq element '\n) ; actually (eq '\n 'n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (if (and skeleton-regions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (eq (nth 1 skeleton) '_))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (or (eolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (indent-region (point) (car skeleton-regions) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (if skeleton-newline-indent-rigidly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (indent-to (prog1 (current-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (newline)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (indent-according-to-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 ((eq element '>)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (if (and skeleton-regions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (eq (nth 1 skeleton) '_))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (indent-region (point) (car skeleton-regions) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (indent-according-to-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 ((eq element '_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (if skeleton-regions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (goto-char (car skeleton-regions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (setq skeleton-regions (cdr skeleton-regions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (and (<= (current-column) (current-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (eq (nth 1 skeleton) '\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (end-of-line 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (or skeleton-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (setq skeleton-point (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 ((eq element '&)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (if skeleton-modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (setq skeleton (cdr skeleton))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ((eq element '|)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (or skeleton-modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (setq skeleton (cdr skeleton))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 ((eq 'quote (car-safe element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (eval (nth 1 element)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 ((or (stringp (car-safe element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (consp (car-safe element)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (if (symbolp (car-safe (car element)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (while (skeleton-internal-list element nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (setq literal (car element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (while literal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (skeleton-internal-list element (car literal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (setq literal (cdr literal)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 ((null element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 ((skeleton-internal-1 (eval element) t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ;; Maybe belongs into simple.el or elsewhere
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
453 ;###autoload
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (define-skeleton local-variables-section
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 "Insert a local variables section. Use current comment syntax if any."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (completing-read "Mode: " obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (lambda (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (if (commandp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (string-match "-mode$" (symbol-name symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 t)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
461 '(save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
462 (if (re-search-forward page-delimiter nil t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
463 (error "Not on last page.")))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
464 comment-start "Local Variables:" comment-end \n
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
465 comment-start "mode: " str
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 & -5 | '(kill-line 0) & -1 | comment-end \n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ( (completing-read (format "Variable, %s: " skeleton-subprompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (lambda (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (or (eq symbol 'eval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (user-variable-p symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 comment-start str ": "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (read-from-minibuffer "Expression: " nil read-expression-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 'read-expression-history) | _
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
476 comment-end \n)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 resume:
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
478 comment-start "End:" comment-end \n)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;; Variables and command for automatically inserting pairs like () or "".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (defvar skeleton-pair nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 "*If this is nil pairing is turned off, no matter what else is set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 Otherwise modes with `skeleton-pair-insert-maybe' on some keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 will attempt to insert pairs of matching characters.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (defvar skeleton-pair-on-word nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 "*If this is nil, paired insertion is inhibited before or inside a word.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (defvar skeleton-pair-filter (lambda ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 "Attempt paired insertion if this function returns nil, before inserting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 This allows for context-sensitive checking whether pairing is appropriate.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (defvar skeleton-pair-alist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 "An override alist of pairing partners matched against `last-command-char'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 Each alist element, which looks like (ELEMENT ...), is passed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 `skeleton-insert' with no interactor. Variable `str' does nothing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 Elements might be (?` ?` _ \"''\"), (?\\( ? _ \" )\") or (?{ \\n > _ \\n ?} >).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (defun skeleton-pair-insert-maybe (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 "Insert the character you type ARG times.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
509 With no ARG, if `skeleton-pair' is non-nil, pairing can occur. If the region
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
510 is visible the pair is wrapped around it depending on `skeleton-autowrap'.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
511 Else, if `skeleton-pair-on-word' is non-nil or we are not before or inside a
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 word, and if `skeleton-pair-filter' returns nil, pairing is performed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 If a match is found in `skeleton-pair-alist', that is inserted, else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 the defaults are used. These are (), [], {}, <> and `' for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 symmetrical ones, and the same character twice for the others."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (interactive "*P")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
518 (let ((mark (and skeleton-autowrap
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
519 (or (eq last-command 'mouse-drag-region)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
520 (and (boundp 'transient-mark-mode)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
521 transient-mark-mode mark-active))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
522 (skeleton-end-hook))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
523 (if (or arg
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
524 (not skeleton-pair)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
525 (and (not mark)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
526 (or overwrite-mode
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
527 (if (not skeleton-pair-on-word) (looking-at "\\w"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
528 (funcall skeleton-pair-filter))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
529 (self-insert-command (prefix-numeric-value arg))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
530 (setq last-command-char (logand last-command-char 255))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
531 (or skeleton-abbrev-cleanup
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
532 (skeleton-insert
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
533 (cons nil (or (assq last-command-char skeleton-pair-alist)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
534 (assq last-command-char '((?( _ ?))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
535 (?[ _ ?])
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
536 (?{ _ ?})
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
537 (?< _ ?>)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
538 (?` _ ?')))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
539 `(,last-command-char _ ,last-command-char)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
540 (if mark -1))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
543 ;; A more serious example can be found in sh-script.el
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
544 ;;; (defun mirror-mode ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
545 ;; "This major mode is an amusing little example of paired insertion.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
546 ;;All printable characters do a paired self insert, while the other commands
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
547 ;;work normally."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
548 ;; (interactive)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
549 ;; (kill-all-local-variables)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
550 ;; (make-local-variable 'skeleton-pair)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
551 ;; (make-local-variable 'skeleton-pair-on-word)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
552 ;; (make-local-variable 'skeleton-pair-filter)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
553 ;; (make-local-variable 'skeleton-pair-alist)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
554 ;; (setq major-mode 'mirror-mode
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
555 ;; mode-name "Mirror"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
556 ;; skeleton-pair-on-word t
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
557 ;; ;; in the middle column insert one or none if odd window-width
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
558 ;; skeleton-pair-filter (lambda ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
559 ;; (if (>= (current-column)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
560 ;; (/ (window-width) 2))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
561 ;; ;; insert both on next line
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
562 ;; (next-line 1)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
563 ;; ;; insert one or both?
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
564 ;; (= (* 2 (1+ (current-column)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
565 ;; (window-width))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
566 ;; ;; mirror these the other way round as well
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
567 ;; skeleton-pair-alist '((?) _ ?()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
568 ;; (?] _ ?[)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
569 ;; (?} _ ?{)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
570 ;; (?> _ ?<)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
571 ;; (?/ _ ?\\)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
572 ;; (?\\ _ ?/)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
573 ;; (?` ?` _ "''")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
574 ;; (?' ?' _ "``"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
575 ;; ;; in this mode we exceptionally ignore the user, else it's no fun
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
576 ;; skeleton-pair t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
577 ;; (let ((map (make-vector 256 'skeleton-pair-insert-maybe))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
578 ;; (i 0))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
579 ;; (use-local-map `(keymap ,map))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
580 ;; (while (< i ? )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
581 ;; (aset map i nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
582 ;; (aset map (+ i 128) nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
583 ;; (setq i (1+ i))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
584 ;; (run-hooks 'mirror-mode-hook))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
585
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
586 (provide 'skeleton)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ;; skeleton.el ends here