summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1996-06-28 08:11:18 +0000
committerRichard M. Stallman <rms@gnu.org>1996-06-28 08:11:18 +0000
commit1bfc618d6de47a4f84f266e4d1f8c8d1049bdde2 (patch)
treef44476c129f54d65cea283518177e637b2d03e47
parent3897fd42a70f665726a33335ed0290a55a3b73c0 (diff)
downloademacs-1bfc618d6de47a4f84f266e4d1f8c8d1049bdde2.tar.gz
(skeleton-proxy-new): New function.
(define-skeleton): Define the skeleton as a defun using skeleton-proxy-new.
-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'."
(if skeleton-debug
(set command skeleton))
`(progn
- (defvar ,command ',skeleton ,documentation)
- (defalias ',command 'skeleton-proxy)))
+ (defun ,command (&optional str arg)
+ ,(concat documentation
+ (if (string-match "\n\\>" documentation)
+ "" "\n")
+ "\n"
+ "This is a skeleton command (see `skeleton-insert').
+Normally the skeleton text is inserted at point, with nothing \"inside\".
+If there is a highlighted region, the skeleton text is wrapped
+around the region text.
+
+A prefix argument ARG says to wrap the skeleton around the next ARG words.
+A prefix argument of zero says to wrap around zero words---that is, nothing.
+This is a way of overiding the use of a highlighted region.")
+ (interactive "*P\nP")
+ (skeleton-proxy-new ',skeleton str arg))))
+;;;###autoload
+(defun skeleton-proxy-new (skeleton &optional str arg)
+ "Insert skeleton defined by variable of same name (see `skeleton-insert').
+Prefix ARG allows wrapping around words or regions (see `skeleton-insert').
+If no ARG was given, but the region is visible, ARG defaults to -1 depending
+on `skeleton-autowrap'. An ARG of M-0 will prevent this just for once.
+This command can also be an abbrev expansion (3rd and 4th columns in
+\\[edit-abbrevs] buffer: \"\" command-name).
+When called as a function, optional first argument STR may also be a string
+which will be the value of `str' whereas the skeleton's interactor is then
+ignored."
+ (interactive "*P\nP")
+ (setq skeleton (funcall skeleton-filter skeleton))
+ (if (not skeleton)
+ (if (memq this-command '(self-insert-command
+ skeleton-pair-insert-maybe
+ expand-abbrev))
+ (setq buffer-undo-list (primitive-undo 1 buffer-undo-list)))
+ (skeleton-insert skeleton
+ (if (setq skeleton-abbrev-cleanup
+ (or (eq this-command 'self-insert-command)
+ (eq this-command
+ 'skeleton-pair-insert-maybe)))
+ ()
+ ;; Pretend C-x a e passed its prefix arg to us
+ (if (or arg current-prefix-arg)
+ (prefix-numeric-value (or arg
+ current-prefix-arg))
+ (and skeleton-autowrap
+ (or (eq last-command 'mouse-drag-region)
+ (and transient-mark-mode mark-active))
+ -1)))
+ (if (stringp str)
+ str))
+ (and skeleton-abbrev-cleanup
+ (setq skeleton-abbrev-cleanup (point))
+ (add-hook 'post-command-hook 'skeleton-abbrev-cleanup nil t))))
;; This command isn't meant to be called, only it's aliases with meaningful
;; names are.
@@ -421,7 +471,7 @@ automatically, and you are prompted to fill in the variable parts.")))
;; 'read-expression-history) | _
;; comment-end \n)
;; resume:
-;; comment-start "End:" comment-end)
+;; comment-start "End:" comment-end \n)
;; Variables and command for automatically inserting pairs like () or "".