branch: master commit f3d0e03a05d3422bbeec1ed57514cc1628181251 Author: Noam Postavsky <npost...@users.sourceforge.net> Commit: Noam Postavsky <npost...@users.sourceforge.net>
* yasnippet-tests.el (snippet-exit-hooks): New test. --- yasnippet-tests.el | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/yasnippet-tests.el b/yasnippet-tests.el index a6abcb7..dc0c43c 100644 --- a/yasnippet-tests.el +++ b/yasnippet-tests.el @@ -553,6 +553,36 @@ TODO: correct this bug!" "brother from another mother") ;; no newline should be here! ))) +(ert-deftest snippet-exit-hooks () + (defvar yas--ran-exit-hook) + (with-temp-buffer + (yas-saving-variables + (let ((yas--ran-exit-hook nil) + (yas-triggers-in-field t)) + (yas-with-snippet-dirs + '((".emacs.d/snippets" + ("emacs-lisp-mode" + ("foo" . "\ +# expand-env: ((yas-after-exit-snippet-hook (lambda () (setq yas--ran-exit-hook t)))) +# -- +FOO ${1:f1} ${2:f2}") + ("sub" . "\ +# expand-env: ((yas-after-exit-snippet-hook (lambda () (setq yas--ran-exit-hook 'sub)))) +# -- +SUB")))) + (yas-reload-all) + (emacs-lisp-mode) + (yas-minor-mode +1) + (insert "foo") + (ert-simulate-command '(yas-expand)) + (should-not yas--ran-exit-hook) + (yas-mock-insert "sub") + (ert-simulate-command '(yas-expand)) + (ert-simulate-command '(yas-next-field)) + (should-not yas--ran-exit-hook) + (ert-simulate-command '(yas-next-field)) + (should (eq yas--ran-exit-hook t))))))) + (defvar yas--barbaz) (defvar yas--foobarbaz)