mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
Handle multiple uses of yas-auto-next
* yasnippet.el (yas--auto-next): Loop again after moving to the next field. * yasnippet-tests.el (auto-next-field): Test for multiple yas-auto-next uses.
This commit is contained in:
parent
476bc77c34
commit
bd3572a9b3
@ -694,7 +694,11 @@ mapconcat #'(lambda (arg)
|
|||||||
(prin1-to-string '(yas-auto-next
|
(prin1-to-string '(yas-auto-next
|
||||||
(yas-choose-value
|
(yas-choose-value
|
||||||
"bar" "foo")))
|
"bar" "foo")))
|
||||||
"} baz ${2:quinn} quinn")))))
|
"} ${2:$$"
|
||||||
|
(prin1-to-string '(yas-auto-next
|
||||||
|
(yas-choose-value
|
||||||
|
"too" "foo")))
|
||||||
|
"} baz ${3:quinn} quinn")))))
|
||||||
(yas-reload-all)
|
(yas-reload-all)
|
||||||
(ruby-mode)
|
(ruby-mode)
|
||||||
(yas-minor-mode 1)
|
(yas-minor-mode 1)
|
||||||
@ -702,7 +706,7 @@ mapconcat #'(lambda (arg)
|
|||||||
(yas-mock-insert "snip")
|
(yas-mock-insert "snip")
|
||||||
(ert-simulate-command '(yas-expand))
|
(ert-simulate-command '(yas-expand))
|
||||||
(yas-mock-insert "quux")
|
(yas-mock-insert "quux")
|
||||||
(should (equal "foo bar baz quux quinn" (buffer-string)))))))
|
(should (equal "foo bar too baz quux quinn" (buffer-string)))))))
|
||||||
|
|
||||||
|
|
||||||
;;; Snippet expansion and character escaping
|
;;; Snippet expansion and character escaping
|
||||||
|
@ -3039,8 +3039,13 @@ snippet field. The arguments are the same as `completing-read'.
|
|||||||
|
|
||||||
(defun yas--auto-next ()
|
(defun yas--auto-next ()
|
||||||
"Helper for `yas-auto-next'."
|
"Helper for `yas-auto-next'."
|
||||||
(remove-hook 'post-command-hook #'yas--auto-next t)
|
(cl-loop
|
||||||
|
do (progn (remove-hook 'post-command-hook #'yas--auto-next t)
|
||||||
(yas-next-field))
|
(yas-next-field))
|
||||||
|
;; The transform in the next field may have requested auto-next as
|
||||||
|
;; well. Call it ourselves, since the command loop itself won't
|
||||||
|
;; recheck the value of post-command-hook while running it.
|
||||||
|
while (memq #'yas--auto-next post-command-hook)))
|
||||||
|
|
||||||
(defmacro yas-auto-next (&rest body)
|
(defmacro yas-auto-next (&rest body)
|
||||||
"Automatically advance to next field after eval'ing BODY."
|
"Automatically advance to next field after eval'ing BODY."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user