Handle errors during evaluation properly

* yasnippet.el (yas--eval-for-string): Convert error to a string,
rather than returning the error data (which can only lead to confusing
type errors later when code expecting a string gets a list).
* yasnippet-tests.el (yas-no-memory-of-bad-snippet): Adjust test, now
that snippet expansion swallows errors properly.
This commit is contained in:
Noam Postavsky 2020-06-03 22:46:18 -04:00
parent d3d6d70b1c
commit 5cbdbf0d20
2 changed files with 2 additions and 2 deletions

View File

@ -847,7 +847,7 @@ mapconcat #'(lambda (arg)
;; See https://github.com/joaotavora/yasnippet/issues/800.
(with-temp-buffer
(yas-minor-mode 1)
(should-error (yas-expand-snippet "```foo\n\n```"))
(yas-expand-snippet "```foo\n\n```")
(erase-buffer) ; Bad snippet may leave wrong text.
;; But expanding the corrected snippet should work fine.
(yas-expand-snippet "\\`\\`\\`foo\n\n\\`\\`\\`")

View File

@ -1505,7 +1505,7 @@ Also tries to work around Emacs Bug#30931."
(let ((result (eval form)))
(when result
(format "%s" result))))))
((debug error) (cdr oops)))))
((debug error) (error-message-string oops)))))
(defun yas--eval-for-effect (form)
(yas--safely-call-fun (apply-partially #'eval form)))