[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 0d9afb2 31/63: Fix mirror transformation error with expand
From: |
Noam Postavsky |
Subject: |
[elpa] master 0d9afb2 31/63: Fix mirror transformation error with expand-env |
Date: |
Mon, 17 Jul 2017 22:54:15 -0400 (EDT) |
branch: master
commit 0d9afb2c69214db3f1fc64d18f3dd336a6096233
Author: Etienne <address@hidden>
Commit: Noam Postavsky <address@hidden>
Fix mirror transformation error with expand-env
* yasnippet.el (yas-expand-snippet): Use the snippet's bindings when
moving to the first field. This prevents getting an error when using
a variable defined in expand-env.
* yasnippet-tests.el (snippet-mirror-bindings): New test, check if
mirror transformations have access to variables defined in the snippet
environment.
---
yasnippet-tests.el | 20 ++++++++++++++++++++
yasnippet.el | 3 ++-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index 1c7c94f..432d77d 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -614,6 +614,26 @@ foobaz\n"))))
(should (eq 'global (nth 0 yas--ran-exit-hook)))
(should (eq 'local (nth 1 yas--ran-exit-hook))))))))
+(ert-deftest snippet-mirror-bindings ()
+ "Check that variables defined with the expand-env field are
+accessible from mirror transformations."
+ (with-temp-buffer
+ (yas-saving-variables
+ (let ((yas-triggers-in-field t)
+ (yas-good-grace nil))
+ (yas-with-snippet-dirs
+ '((".emacs.d/snippets"
+ ("emacs-lisp-mode"
+ ("baz" . "\
+# expand-env: ((func #'upcase))
+# --
+hello ${1:$(when (stringp yas-text) (funcall func yas-text))} foo${1:$$(concat
\"baz\")}$0"))))
+ (yas-reload-all)
+ (emacs-lisp-mode)
+ (yas-minor-mode +1)
+ (insert "baz")
+ (ert-simulate-command '(yas-expand))
+ (should (string= (yas--buffer-contents) "hello BAZ foobaz\n")))))))
(defvar yas--barbaz)
(defvar yas--foobarbaz)
diff --git a/yasnippet.el b/yasnippet.el
index 76e1d25..2645121 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -3731,7 +3731,8 @@ considered when expanding the snippet."
(let ((first-field (car (yas--snippet-fields snippet))))
(when first-field
(sit-for 0) ;; fix issue 125
- (yas--move-to-field snippet first-field)))
+ (yas--letenv (yas--snippet-expand-env snippet)
+ (yas--move-to-field snippet first-field))))
(yas--message 4 "snippet expanded.")
t))))
- [elpa] master 203df22 22/63: Use debug-on-error to simplify error handling, (continued)
- [elpa] master 203df22 22/63: Use debug-on-error to simplify error handling, Noam Postavsky, 2017/07/17
- [elpa] master 9c9547a 21/63: Don't catch and rethrow yas-{-}exception, Noam Postavsky, 2017/07/17
- [elpa] master e878afb 12/63: Update handling of markers during indentation, Noam Postavsky, 2017/07/17
- [elpa] master 6c4fbb2 24/63: Fix snippet local exit hook, Noam Postavsky, 2017/07/17
- [elpa] master d0c6fec 16/63: Refactor snippet marker manipulating functions, Noam Postavsky, 2017/07/17
- [elpa] master e74f00e 18/63: Fix whitespace lossage between mirrors, Noam Postavsky, 2017/07/17
- [elpa] master 4f37afd 27/63: Let snippets expand in strings/comments by default, Noam Postavsky, 2017/07/17
- [elpa] master cddb826 29/63: Merge: let snippets expand in strings/comments by default, Noam Postavsky, 2017/07/17
- [elpa] master 462f566 44/63: Don't leave unreadable objects in the undo list, Noam Postavsky, 2017/07/17
- [elpa] master 3949421 41/63: Fix problems with auto-fill-mode interaction, Noam Postavsky, 2017/07/17
- [elpa] master 0d9afb2 31/63: Fix mirror transformation error with expand-env,
Noam Postavsky <=
- [elpa] master b4d2f9c 37/63: Update snippets submodule, Noam Postavsky, 2017/07/17
- [elpa] master c5fddf8 34/63: Restore syntax-propertize-function before indenting snippet, Noam Postavsky, 2017/07/17
- [elpa] master 5043a96 38/63: Correctly wrap auto-fill-function when it's toggled on later, Noam Postavsky, 2017/07/17
- [elpa] master 30913fd 35/63: Only update live snippets, Noam Postavsky, 2017/07/17
- [elpa] master 0f6d82f 46/63: * .travis.yml: Use Emacs 25.2, Noam Postavsky, 2017/07/17
- [elpa] master 6102ff5 50/63: Handle undo of snippet 1st line indent properly, Noam Postavsky, 2017/07/17
- [elpa] master ac26024 20/63: Rework error handling, Noam Postavsky, 2017/07/17
- [elpa] master c3a9447 43/63: Fix condition timestamps in key filter functions, Noam Postavsky, 2017/07/17
- [elpa] master 82818e5 48/63: Don't delete snippets more than once., Noam Postavsky, 2017/07/17
- [elpa] master 63f44b4 33/63: Ensure inhibit-modification-hooks is nil while modifying buffer, Noam Postavsky, 2017/07/17