[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 6c4fbb2 24/63: Fix snippet local exit hook
From: |
Noam Postavsky |
Subject: |
[elpa] master 6c4fbb2 24/63: Fix snippet local exit hook |
Date: |
Mon, 17 Jul 2017 22:54:14 -0400 (EDT) |
branch: master
commit 6c4fbb25b3cd50407b1b458e807922979995a684
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Fix snippet local exit hook
* yasnippet.el (yas--check-commit-snippet): Use
`yas-after-exit-snippet-hook' value of last exited snippet.
* yasnippet.el (yas--safely-run-hook): Also accept a list of functions.
* yasnippet.el (yas--safely-call-fun): New function, extracted from
yas--safely-run-hook.
---
yasnippet.el | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/yasnippet.el b/yasnippet.el
index f6036da..715dce6 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -3328,16 +3328,19 @@ This renders the snippet as ordinary text."
(yas--maybe-move-to-active-field snippet))
(setq yas--snippets-to-move nil))
+(defun yas--safely-call-fun (fun)
+ (condition-case error
+ (funcall fun)
+ ((debug error)
+ (yas--message 2 "Error running %s: %s"
+ (if (symbolp fun) fun "a hook")
+ (error-message-string error)))))
+
(defun yas--safely-run-hook (hook)
(let ((debug-on-error (and (not (memq yas-good-grace '(t hooks)))
debug-on-error)))
- (condition-case error
- (funcall hook)
- ((debug error)
- (yas--message 2 "Error running %s: %s"
- (if (symbolp hook) hook "a hook")
- (error-message-string error))))))
-
+ (if (functionp hook) (yas--safely-call-fun hook)
+ (mapc #'yas--safely-call-fun hook))))
(defun yas--check-commit-snippet ()
"Check if point exited the currently active field of the snippet.
@@ -3345,15 +3348,19 @@ This renders the snippet as ordinary text."
If so cleans up the whole snippet up."
(let* ((snippets (yas-active-snippets 'all))
(snippets-left snippets)
- (snippet-exit-transform))
+ (snippet-exit-transform nil)
+ (snippet-exit-hook yas-after-exit-snippet-hook))
(dolist (snippet snippets)
(let ((active-field (yas--snippet-active-field snippet)))
(yas--letenv (yas--snippet-expand-env snippet)
+ ;; Note: the `force-exit' field could be a transform in case of
+ ;; ${0: ...}, see `yas--move-to-field'.
(setq snippet-exit-transform (yas--snippet-force-exit snippet))
(cond ((or snippet-exit-transform
(not (and active-field (yas--field-contains-point-p
active-field))))
(setq snippets-left (delete snippet snippets-left))
(setf (yas--snippet-force-exit snippet) nil)
+ (setq snippet-exit-hook yas-after-exit-snippet-hook)
(yas--commit-snippet snippet))
((and active-field
(or (not yas--active-field-overlay)
@@ -3371,7 +3378,7 @@ If so cleans up the whole snippet up."
(unless (or (null snippets) snippets-left)
(if snippet-exit-transform
(yas--eval-for-effect snippet-exit-transform))
- (mapcar #'yas--safely-run-hook yas-after-exit-snippet-hook))))
+ (yas--safely-run-hook snippet-exit-hook))))
;; Apropos markers-to-points:
;;
- [elpa] master 9abf842 19/63: Enable snippet-mode automatically, (continued)
- [elpa] master 9abf842 19/63: Enable snippet-mode automatically, Noam Postavsky, 2017/07/17
- [elpa] master 48cd716 14/63: Use more compact format for snippet menus, Noam Postavsky, 2017/07/17
- [elpa] master b62cf52 23/63: Remove lambda list building hack, Noam Postavsky, 2017/07/17
- [elpa] master 7b3c29d 13/63: * doc/faq.org: Typos and grammar., Noam Postavsky, 2017/07/17
- [elpa] master 14819c9 28/63: Make yas-buffer-local-condition into a defcustom, Noam Postavsky, 2017/07/17
- [elpa] master f3d0e03 25/63: * yasnippet-tests.el (snippet-exit-hooks): New test., Noam Postavsky, 2017/07/17
- [elpa] master 4ee3835 08/63: Use expand-env for all snippet evaluations, Noam Postavsky, 2017/07/17
- [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 <=
- [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, 2017/07/17
- [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