aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/skeleton.el
diff options
context:
space:
mode:
authorRichard M. Stallman1996-06-28 08:11:18 +0000
committerRichard M. Stallman1996-06-28 08:11:18 +0000
commit28895aea1005f30bbdd87f66bd3a42ce0eaeeee8 (patch)
tree3d21ebdacdd9174775416c42c18b69eb87b22fe7 /lisp/skeleton.el
parent538f13d4d76bccdd18184098c90491b7019f66c9 (diff)
downloademacs-28895aea1005f30bbdd87f66bd3a42ce0eaeeee8.tar.gz
emacs-28895aea1005f30bbdd87f66bd3a42ce0eaeeee8.zip
(skeleton-proxy-new): New function.
(define-skeleton): Define the skeleton as a defun using skeleton-proxy-new.
Diffstat (limited to 'lisp/skeleton.el')
-rw-r--r--lisp/skeleton.el56
1 files changed, 53 insertions, 3 deletions
diff --git a/lisp/skeleton.el b/lisp/skeleton.el
index edea9c4c3e9..a488dbdf540 100644
--- a/lisp/skeleton.el
+++ b/lisp/skeleton.el
@@ -115,10 +115,60 @@ INTERACTOR and ELEMENT ... are as defined under `skeleton-insert'."
115 (if skeleton-debug 115 (if skeleton-debug
116 (set command skeleton)) 116 (set command skeleton))
117 `(progn 117 `(progn
118 (defvar ,command ',skeleton ,documentation) 118 (defun ,command (&optional str arg)
119 (defalias ',command 'skeleton-proxy))) 119 ,(concat documentation
120 (if (string-match "\n\\>" documentation)
121 "" "\n")
122 "\n"
123 "This is a skeleton command (see `skeleton-insert').
124Normally the skeleton text is inserted at point, with nothing \"inside\".
125If there is a highlighted region, the skeleton text is wrapped
126around the region text.
127
128A prefix argument ARG says to wrap the skeleton around the next ARG words.
129A prefix argument of zero says to wrap around zero words---that is, nothing.
130This is a way of overiding the use of a highlighted region.")
131 (interactive "*P\nP")
132 (skeleton-proxy-new ',skeleton str arg))))
120 133
134;;;###autoload
135(defun skeleton-proxy-new (skeleton &optional str arg)
136 "Insert skeleton defined by variable of same name (see `skeleton-insert').
137Prefix ARG allows wrapping around words or regions (see `skeleton-insert').
138If no ARG was given, but the region is visible, ARG defaults to -1 depending
139on `skeleton-autowrap'. An ARG of M-0 will prevent this just for once.
140This command can also be an abbrev expansion (3rd and 4th columns in
141\\[edit-abbrevs] buffer: \"\" command-name).
121 142
143When called as a function, optional first argument STR may also be a string
144which will be the value of `str' whereas the skeleton's interactor is then
145ignored."
146 (interactive "*P\nP")
147 (setq skeleton (funcall skeleton-filter skeleton))
148 (if (not skeleton)
149 (if (memq this-command '(self-insert-command
150 skeleton-pair-insert-maybe
151 expand-abbrev))
152 (setq buffer-undo-list (primitive-undo 1 buffer-undo-list)))
153 (skeleton-insert skeleton
154 (if (setq skeleton-abbrev-cleanup
155 (or (eq this-command 'self-insert-command)
156 (eq this-command
157 'skeleton-pair-insert-maybe)))
158 ()
159 ;; Pretend C-x a e passed its prefix arg to us
160 (if (or arg current-prefix-arg)
161 (prefix-numeric-value (or arg
162 current-prefix-arg))
163 (and skeleton-autowrap
164 (or (eq last-command 'mouse-drag-region)
165 (and transient-mark-mode mark-active))
166 -1)))
167 (if (stringp str)
168 str))
169 (and skeleton-abbrev-cleanup
170 (setq skeleton-abbrev-cleanup (point))
171 (add-hook 'post-command-hook 'skeleton-abbrev-cleanup nil t))))
122 172
123;; This command isn't meant to be called, only it's aliases with meaningful 173;; This command isn't meant to be called, only it's aliases with meaningful
124;; names are. 174;; names are.
@@ -421,7 +471,7 @@ automatically, and you are prompted to fill in the variable parts.")))
421;; 'read-expression-history) | _ 471;; 'read-expression-history) | _
422;; comment-end \n) 472;; comment-end \n)
423;; resume: 473;; resume:
424;; comment-start "End:" comment-end) 474;; comment-start "End:" comment-end \n)
425 475
426;; Variables and command for automatically inserting pairs like () or "". 476;; Variables and command for automatically inserting pairs like () or "".
427 477