mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
Add region contents to new snippet
* yasnippet.el (yas-new-snippet-default): Add yas-selected-text. (yas-new-snippet): Let-bind yas-selected-text to region content. Copyright-paperwork-exempt: yes
This commit is contained in:
parent
bc80f67782
commit
1735a283d2
@ -207,7 +207,7 @@ created with `yas-new-snippet'. "
|
|||||||
# name: $1
|
# name: $1
|
||||||
# key: ${2:${1:$(yas--key-from-desc yas-text)}}
|
# key: ${2:${1:$(yas--key-from-desc yas-text)}}
|
||||||
# --
|
# --
|
||||||
$0"
|
$0`yas-selected-text`"
|
||||||
"Default snippet to use when creating a new snippet.
|
"Default snippet to use when creating a new snippet.
|
||||||
If nil, don't use any snippet."
|
If nil, don't use any snippet."
|
||||||
:type 'string
|
:type 'string
|
||||||
@ -2476,7 +2476,11 @@ where snippets of table might exist."
|
|||||||
Expands a snippet-writing snippet, unless the optional prefix arg
|
Expands a snippet-writing snippet, unless the optional prefix arg
|
||||||
NO-TEMPLATE is non-nil."
|
NO-TEMPLATE is non-nil."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(let ((guessed-directories (yas--guess-snippet-directories)))
|
(let ((guessed-directories (yas--guess-snippet-directories))
|
||||||
|
(yas-selected-text (or yas-selected-text
|
||||||
|
(and (region-active-p)
|
||||||
|
(buffer-substring-no-properties
|
||||||
|
(region-beginning) (region-end))))))
|
||||||
|
|
||||||
(switch-to-buffer "*new snippet*")
|
(switch-to-buffer "*new snippet*")
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user