Mercurial > emacs
comparison lisp/skeleton.el @ 15544:ef2b47c6c225
(skeleton-proxy-new): New function.
(define-skeleton): Define the skeleton as a defun
using skeleton-proxy-new.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 28 Jun 1996 08:11:18 +0000 |
parents | 1a66dbb1a470 |
children | 3b9f64eb097b |
comparison
equal
deleted
inserted
replaced
15543:1047c2816dd4 | 15544:ef2b47c6c225 |
---|---|
113 which contains the skeleton, has a documentation to that effect. | 113 which contains the skeleton, has a documentation to that effect. |
114 INTERACTOR and ELEMENT ... are as defined under `skeleton-insert'." | 114 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 | 120 (if (string-match "\n\\>" documentation) |
121 | 121 "" "\n") |
122 "\n" | |
123 "This is a skeleton command (see `skeleton-insert'). | |
124 Normally the skeleton text is inserted at point, with nothing \"inside\". | |
125 If there is a highlighted region, the skeleton text is wrapped | |
126 around the region text. | |
127 | |
128 A prefix argument ARG says to wrap the skeleton around the next ARG words. | |
129 A prefix argument of zero says to wrap around zero words---that is, nothing. | |
130 This is a way of overiding the use of a highlighted region.") | |
131 (interactive "*P\nP") | |
132 (skeleton-proxy-new ',skeleton str arg)))) | |
133 | |
134 ;;;###autoload | |
135 (defun skeleton-proxy-new (skeleton &optional str arg) | |
136 "Insert skeleton defined by variable of same name (see `skeleton-insert'). | |
137 Prefix ARG allows wrapping around words or regions (see `skeleton-insert'). | |
138 If no ARG was given, but the region is visible, ARG defaults to -1 depending | |
139 on `skeleton-autowrap'. An ARG of M-0 will prevent this just for once. | |
140 This command can also be an abbrev expansion (3rd and 4th columns in | |
141 \\[edit-abbrevs] buffer: \"\" command-name). | |
142 | |
143 When called as a function, optional first argument STR may also be a string | |
144 which will be the value of `str' whereas the skeleton's interactor is then | |
145 ignored." | |
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. |
125 ;;;###autoload | 175 ;;;###autoload |
126 (defun skeleton-proxy (&optional str arg) | 176 (defun skeleton-proxy (&optional str arg) |
419 ;; comment-start str ": " | 469 ;; comment-start str ": " |
420 ;; (read-from-minibuffer "Expression: " nil read-expression-map nil | 470 ;; (read-from-minibuffer "Expression: " nil read-expression-map nil |
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 |
428 (defvar skeleton-pair nil | 478 (defvar skeleton-pair nil |
429 "*If this is nil pairing is turned off, no matter what else is set. | 479 "*If this is nil pairing is turned off, no matter what else is set. |