mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-14 05:23:04 +00:00
Minor tweaks
* snippet.el (with-static-snippet): Move checks for duplicate &exit to macroexpansion time. (define-static-snippet): Tweak docstring a bit.
This commit is contained in:
parent
2d111e82b1
commit
579ca936d2
23
snippet.el
23
snippet.el
@ -173,7 +173,9 @@ As `define-static-snippet' but doesn't define a function."
|
|||||||
(let ((unfolded (snippet--unfold-forms
|
(let ((unfolded (snippet--unfold-forms
|
||||||
(mapcar #'snippet--canonicalize-form forms)))
|
(mapcar #'snippet--canonicalize-form forms)))
|
||||||
mirrors-and-sources
|
mirrors-and-sources
|
||||||
all-objects exit-object)
|
all-objects)
|
||||||
|
(when (> (cl-count '&exit unfolded :key #'car) 1)
|
||||||
|
(error "Too many &exit forms given"))
|
||||||
`(let* ((region-string (and (region-active-p)
|
`(let* ((region-string (and (region-active-p)
|
||||||
(buffer-substring-no-properties
|
(buffer-substring-no-properties
|
||||||
(region-beginning)
|
(region-beginning)
|
||||||
@ -212,10 +214,7 @@ As `define-static-snippet' but doesn't define a function."
|
|||||||
:prev ,prev-sym
|
:prev ,prev-sym
|
||||||
:parent ,parent))))
|
:parent ,parent))))
|
||||||
(`(&exit (&eval ,form) (&parent ,parent))
|
(`(&exit (&eval ,form) (&parent ,parent))
|
||||||
(when exit-object
|
(setq sym (snippet--make-exit-sym))
|
||||||
(error "Too many &exit forms given"))
|
|
||||||
(setq sym (snippet--make-exit-sym)
|
|
||||||
exit-object sym)
|
|
||||||
`((,sym (snippet--make-object
|
`((,sym (snippet--make-object
|
||||||
'snippet--exit
|
'snippet--exit
|
||||||
,(and form
|
,(and form
|
||||||
@ -246,7 +245,7 @@ As `define-static-snippet' but doesn't define a function."
|
|||||||
|
|
||||||
(defmacro define-static-snippet (name _properties &optional docstring
|
(defmacro define-static-snippet (name _properties &optional docstring
|
||||||
&rest snippet-forms)
|
&rest snippet-forms)
|
||||||
"Make a snippet-inserting function from FORMS.
|
"Define NAME as a snippet-inserting function.
|
||||||
|
|
||||||
Each form in SNIPPET-FORMS, inserted at point in order, can be:
|
Each form in SNIPPET-FORMS, inserted at point in order, can be:
|
||||||
|
|
||||||
@ -274,7 +273,7 @@ Each form in SNIPPET-FORMS, inserted at point in order, can be:
|
|||||||
form, called after each command while the snippet is alive to
|
form, called after each command while the snippet is alive to
|
||||||
produce a string that becomes the mirror text.
|
produce a string that becomes the mirror text.
|
||||||
|
|
||||||
* A string literal or a lisp form CONSTANT evaluated at
|
* A string literal or a lisp form, call it CONSTANT, evaluated at
|
||||||
snippet-insertion time and producing a string that is a part of
|
snippet-insertion time and producing a string that is a part of
|
||||||
the snippet but constant while the snippet is alive.
|
the snippet but constant while the snippet is alive.
|
||||||
|
|
||||||
@ -289,17 +288,17 @@ The forms CONSTANT, FIELD-DEFAULT, MIRROR-TRANSFORM,
|
|||||||
FIELD-TRANSFORM and EXIT-DEFAULT are evaluated with the variable
|
FIELD-TRANSFORM and EXIT-DEFAULT are evaluated with the variable
|
||||||
`region-string' set to the text of the buffer selected at
|
`region-string' set to the text of the buffer selected at
|
||||||
snippet-insertion time. If no region was selected the value of
|
snippet-insertion time. If no region was selected the value of
|
||||||
this variable is the empty string..
|
this variable is the empty string.
|
||||||
|
|
||||||
The forms MIRROR-TRANSFORM and FIELD-TRANSFORM are evaluated with
|
The forms MIRROR-TRANSFORM and FIELD-TRANSFORM are evaluated with
|
||||||
the variable `field-string' set to the text contained in the
|
the variable `field-string' set to the text contained in the
|
||||||
corresponding field. If the field is empty, this variable is the
|
corresponding field. If the field is empty, this variable is the
|
||||||
empty string and the additional variable `field-empty-p' is t. If
|
empty string and the additional variable `field-empty-p' is t.
|
||||||
these forms return nil, they are considered to have returned the
|
|
||||||
empty string.
|
|
||||||
|
|
||||||
If the form CONSTANT returns nil or the empty string, it is
|
If the form CONSTANT returns nil or the empty string, it is
|
||||||
considered to have returned a single whitespace.
|
considered to have returned a single whitespace. If any other
|
||||||
|
form returns nil, it is considered to have returned the empty
|
||||||
|
string.
|
||||||
|
|
||||||
PROPERTIES is an even-numbered property list of (KEY VAL)
|
PROPERTIES is an even-numbered property list of (KEY VAL)
|
||||||
pairs. Its meaning is not decided yet"
|
pairs. Its meaning is not decided yet"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user