[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 203df22 22/63: Use debug-on-error to simplify error handli
From: |
Noam Postavsky |
Subject: |
[elpa] master 203df22 22/63: Use debug-on-error to simplify error handling |
Date: |
Mon, 17 Jul 2017 22:54:13 -0400 (EDT) |
branch: master
commit 203df22e26ac6fd5b1ad8aee3c2b4e5c0b57071d
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Use debug-on-error to simplify error handling
* yasnippet.el (yas--eval-for-string, yas--safely-run-hook: Let-bind
`debug-on-error' according to `yas-good-grace' and add `debug' to
condition handler to deduplicate evaluation.
---
yasnippet.el | 42 +++++++++++++++++++-----------------------
1 file changed, 19 insertions(+), 23 deletions(-)
diff --git a/yasnippet.el b/yasnippet.el
index 4258d14..7645c19 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -1332,20 +1332,17 @@ Returns (TEMPLATES START END). This function respects
(defun yas--eval-for-string (form)
"Evaluate FORM and convert the result to string."
- (let ((eval-saving-stuff
- (lambda (form)
- (save-excursion
- (save-restriction
- (save-match-data
- (widen)
- (let ((result (eval form)))
- (when result
- (format "%s" result)))))))))
- (if (memq yas-good-grace '(t inline))
- (condition-case oops
- (funcall eval-saving-stuff form)
- (error (cdr oops)))
- (funcall eval-saving-stuff form))))
+ (let ((debug-on-error (and (not (memq yas-good-grace '(t inline)))
+ debug-on-error)))
+ (condition-case oops
+ (save-excursion
+ (save-restriction
+ (save-match-data
+ (widen)
+ (let ((result (eval form)))
+ (when result
+ (format "%s" result))))))
+ ((debug error) (cdr oops)))))
(defun yas--eval-for-effect (form)
;; FIXME: simulating lexical-binding.
@@ -3334,15 +3331,14 @@ This renders the snippet as ordinary text."
(setq yas--snippets-to-move nil))
(defun yas--safely-run-hook (hook)
- (let ((run-the-hook (lambda (hook) (funcall hook))))
- (if (memq yas-good-grace '(t hooks))
- (funcall run-the-hook hook)
- (condition-case error
- (funcall run-the-hook hook)
- (error
- (yas--message 2 "Error running %s: %s"
- (if (symbolp hook) hook "a hook")
- (error-message-string error)))))))
+ (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))))))
(defun yas--check-commit-snippet ()
- [elpa] master 28d5496 11/63: Use git describe for doc HTML output, (continued)
- [elpa] master 28d5496 11/63: Use git describe for doc HTML output, Noam Postavsky, 2017/07/17
- [elpa] master cce2e0d 09/63: Make the documentation build reproducible, Noam Postavsky, 2017/07/17
- [elpa] master 2ca6321 05/63: Promote yas--snippets-at-point to a public API, Noam Postavsky, 2017/07/17
- [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 <=
- [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, 2017/07/17