mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-14 05:23:04 +00:00
move snippet saving from loading to closing
yas-load-snippet-buffer now just loads the snippet, yas-load-snippet-buffer-and-close also saves it.
This commit is contained in:
parent
ffd497d541
commit
205b0e6970
37
yasnippet.el
37
yasnippet.el
@ -2527,10 +2527,7 @@ neither do the elements of PARENTS."
|
|||||||
|
|
||||||
TABLE is a symbol naming a passed to `yas--table-get-create'.
|
TABLE is a symbol naming a passed to `yas--table-get-create'.
|
||||||
|
|
||||||
When called interactively, prompt for the table name and
|
When called interactively, prompt for the table name."
|
||||||
whether (and where) to save the snippet.
|
|
||||||
|
|
||||||
Returns the name of the file saved (if any)."
|
|
||||||
(interactive (list (yas--read-table) t))
|
(interactive (list (yas--read-table) t))
|
||||||
(cond
|
(cond
|
||||||
;; We have `yas--editing-template', this buffer's content comes from a
|
;; We have `yas--editing-template', this buffer's content comes from a
|
||||||
@ -2549,10 +2546,22 @@ Returns the name of the file saved (if any)."
|
|||||||
(set (make-local-variable 'yas--editing-template)
|
(set (make-local-variable 'yas--editing-template)
|
||||||
(yas--define-snippets-1 (yas--parse-template buffer-file-name)
|
(yas--define-snippets-1 (yas--parse-template buffer-file-name)
|
||||||
table)))))
|
table)))))
|
||||||
|
(when interactive
|
||||||
|
(yas--message 3 "Snippet \"%s\" loaded for %s."
|
||||||
|
(yas--template-name yas--editing-template)
|
||||||
|
(yas--table-name (yas--template-table yas--editing-template)))))
|
||||||
|
|
||||||
(prog1
|
(defun yas-load-snippet-buffer-and-close (table &optional kill)
|
||||||
(when (and interactive
|
"Load the snippet with `yas-load-snippet-buffer', offer to
|
||||||
(or
|
save, then `quit-window' if saved.
|
||||||
|
|
||||||
|
The prefix argument KILL is passed to `quit-window'.
|
||||||
|
|
||||||
|
Don't use this from a Lisp program, call `yas-load-snippet-buffer'
|
||||||
|
and `kill-buffer' instead."
|
||||||
|
(interactive (list (yas--read-table) current-prefix-arg))
|
||||||
|
(yas-load-snippet-buffer table t)
|
||||||
|
(when (and (or
|
||||||
;; Only offer to save this if it looks like a library or new
|
;; Only offer to save this if it looks like a library or new
|
||||||
;; snippet (loaded from elisp, from a dir in `yas-snippet-dirs'
|
;; snippet (loaded from elisp, from a dir in `yas-snippet-dirs'
|
||||||
;; which is not the first, or from an unwritable file)
|
;; which is not the first, or from an unwritable file)
|
||||||
@ -2574,18 +2583,8 @@ Returns the name of the file saved (if any)."
|
|||||||
(write-file (concat chosen "/"
|
(write-file (concat chosen "/"
|
||||||
(read-from-minibuffer (format "File name to create in %s? " chosen)
|
(read-from-minibuffer (format "File name to create in %s? " chosen)
|
||||||
default-file-name)))
|
default-file-name)))
|
||||||
(setf (yas--template-file yas--editing-template) buffer-file-name)))))
|
(setf (yas--template-file yas--editing-template) buffer-file-name)
|
||||||
(when interactive
|
(quit-window kill))))))
|
||||||
(yas--message 3 "Snippet \"%s\" loaded for %s."
|
|
||||||
(yas--template-name yas--editing-template)
|
|
||||||
(yas--table-name (yas--template-table yas--editing-template))))))
|
|
||||||
|
|
||||||
(defun yas-load-snippet-buffer-and-close (table &optional kill interactive)
|
|
||||||
"Call `yas-load-snippet-buffer' and then `quit-window', prefix
|
|
||||||
argument KILL passed to `quit-window'."
|
|
||||||
(interactive (list (yas--read-table) current-prefix-arg t))
|
|
||||||
(and (yas-load-snippet-buffer table interactive)
|
|
||||||
(quit-window kill)))
|
|
||||||
|
|
||||||
(defun yas-tryout-snippet (&optional debug)
|
(defun yas-tryout-snippet (&optional debug)
|
||||||
"Test current buffer's snippet template in other buffer."
|
"Test current buffer's snippet template in other buffer."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user