emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master bd3572a 36/42: Handle multiple uses of yas-auto-next


From: Noam Postavsky
Subject: [elpa] master bd3572a 36/42: Handle multiple uses of yas-auto-next
Date: Sun, 22 Dec 2019 17:38:03 -0500 (EST)

branch: master
commit bd3572a9b392ce01ca60fb1e5f115a452827c37f
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    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.
---
 yasnippet-tests.el | 8 ++++++--
 yasnippet.el       | 9 +++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index cdd42bf..6a306ee 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -694,7 +694,11 @@ mapconcat #'(lambda (arg)
                                          (prin1-to-string '(yas-auto-next
                                                             (yas-choose-value
                                                              "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)
       (ruby-mode)
       (yas-minor-mode 1)
@@ -702,7 +706,7 @@ mapconcat #'(lambda (arg)
       (yas-mock-insert "snip")
       (ert-simulate-command '(yas-expand))
       (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
diff --git a/yasnippet.el b/yasnippet.el
index 67cecb8..25bf4cc 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -3039,8 +3039,13 @@ snippet field.  The arguments are the same as 
`completing-read'.
 
 (defun yas--auto-next ()
   "Helper for `yas-auto-next'."
-  (remove-hook 'post-command-hook #'yas--auto-next t)
-  (yas-next-field))
+  (cl-loop
+   do (progn (remove-hook 'post-command-hook #'yas--auto-next t)
+             (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)
   "Automatically advance to next field after eval'ing BODY."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]