[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/lentic 4332b289fb 250/333: Graceful error handling is n
From: |
ELPA Syncer |
Subject: |
[elpa] externals/lentic 4332b289fb 250/333: Graceful error handling is now optional. |
Date: |
Tue, 27 Feb 2024 13:00:41 -0500 (EST) |
branch: externals/lentic
commit 4332b289fbd6f49886bc9ee87b5f7af8e57311db
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>
Graceful error handling is now optional.
While it's generally good, graceful error handling swallows backtraces
when running in batch or during testing. So, we now have the option of
turning it off by introducing a new macro to wrap condition-case.
---
lentic.el | 41 +++++++++++++++++++++++++++++++++++------
1 file changed, 35 insertions(+), 6 deletions(-)
diff --git a/lentic.el b/lentic.el
index 82a9531ffa..f24b2ce30b 100644
--- a/lentic.el
+++ b/lentic.el
@@ -632,6 +632,24 @@ see `lentic-init' for details."
buffer
(when lentic-config
,@body)))
+
+
+(defvar lentic-condition-case-disabled
+ noninteractive
+ "If non-nil throw exceptions from errors.
+
+By default this is set to the value of noninteractive, so that
+Emacs crashes with backtraces in batch." )
+
+(defmacro lentic-condition-case-unless-disabled (var bodyform &rest handlers)
+ "Like `condition-case' but can be disabled like
`condition-case-unless-debug'."
+ (declare (debug condition-case) (indent 2))
+ `(if lentic-condition-case-disabled
+ ,bodyform
+ (condition-case-unless-debug ,var
+ ,bodyform
+ ,@handlers)))
+
;; #+end_src
;; Recurse down the lentic tree to all lentic views.
@@ -832,7 +850,7 @@ ERR is the error. HOOK is the hook type."
(defun lentic-after-save-hook ()
"Error protected call to real after save hook."
(unless lentic-emergency
- (condition-case err
+ (lentic-condition-case-unless-disabled err
(lentic-after-save-hook-1)
(error
(lentic-hook-fail err "after-save-hook")))))
@@ -854,7 +872,7 @@ This also saves every lentic which is file-associated."
(defun lentic-kill-buffer-hook ()
"Error protected call to real `kill-buffer-hook'."
(unless lentic-emergency
- (condition-case err
+ (lentic-condition-case-unless-disabled err
(lentic-kill-buffer-hook-1)
(error
(lentic-hook-fail err "kill-buffer-hook")))))
@@ -897,7 +915,7 @@ then remove any associated file."
(defun lentic-kill-emacs-hook ()
"Error protected call to real `kill-emacs-hook'."
(unless lentic-emergency
- (condition-case err
+ (lentic-condition-case-unless-disabled err
(lentic-kill-emacs-hook-1)
(error
(lentic-hook-fail err "kill-emacs-hook")))))
@@ -934,7 +952,7 @@ marked as :delete-on-exit."
(defun lentic-post-command-hook ()
"Update point according to config, with error handling."
(unless lentic-emergency
- (condition-case err
+ (lentic-condition-case-unless-disabled err
(progn
;; we test for this later anyway, but this makes it easier to debug.
(when lentic-config
@@ -988,6 +1006,12 @@ SEEN-BUFFER is a list of lentics that have already been
updated."
(defvar lentic-emergency-last-change nil)
(make-variable-buffer-local 'lentic-emergency-last-change)
+(defun lentic-after-change-transform (buffer start stop length-before)
+ "Function called after every change percolated by lentic.
+This function does nothing and is meant for advising. See
+lentic-dev."
+)
+
(defun lentic-after-change-function (start stop length-before)
"Run change update according to `lentic-config'.
Errors are handled.
@@ -998,7 +1022,7 @@ LENGTH-BEFORE is the length of the area before the change."
(when lentic-emergency-debug
(setq lentic-emergency-last-change (list start stop length-before)))
(unless lentic-emergency
- (condition-case err
+ (lentic-condition-case-unless-disabled err
(lentic-after-change-function-1
(current-buffer) start stop length-before)
(error
@@ -1026,6 +1050,9 @@ the change."
(lentic-update-contents config
start stop length-before)
'(nil nil nil))))
+ (apply 'lentic-after-change-transform
+ (lentic-that config)
+ updates)
(lentic-after-change-function-1
(lentic-that config)
(nth 0 updates)
@@ -1034,6 +1061,8 @@ the change."
seen-buffer))))
lentic-config)))
+
+
;; #+end_src
;; We also need to store the location of the area to be changed before the
change
@@ -1054,7 +1083,7 @@ STOP is at least the end of the change."
(unless (and
lentic-emergency
(not lentic-emergency-debug))
- (condition-case err
+ (lentic-condition-case-unless-disabled err
(lentic-before-change-function-1 (current-buffer) start stop)
(error
(lentic-hook-fail err "before change")))))
- [elpa] externals/lentic 8a007a60c5 218/333: Default for init is now a list., (continued)
- [elpa] externals/lentic 8a007a60c5 218/333: Default for init is now a list., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 35db8a038a 219/333: Major-mode functions reworked totally., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 243d2710d1 224/333: Advance m-buffer version to fix point bug., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic bc6e3db510 237/333: Merge branch 'Prathyvsh-patch-1', ELPA Syncer, 2024/02/27
- [elpa] externals/lentic d4d494bb20 232/333: Full documentation for lentic.el., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic e97bc286d7 241/333: Lentic-self doc moved to lentic-mode., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 65f94e69d7 242/333: Shorten names of entry points to lentic-doc., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 54290fcc0c 248/333: Documentation Updates., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 3f20d2a5ec 261/333: Prepare for next iteration, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 884882d10d 245/333: Fixes error with path handling., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 4332b289fb 250/333: Graceful error handling is now optional.,
ELPA Syncer <=
- [elpa] externals/lentic b8f399ea51 244/333: lentic-doc now uses correct directory., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 9d542c732b 255/333: README update for 0.8 release., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic c740b170ea 262/333: Enable use of tags in org-mode src blocks., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic ba0be3b36f 265/333: Merge branch 'feature/tags-on-org-sections', ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 678db93272 322/333: Merge pull request #50 from DamienCassou/patch-1, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 7b75e8079c 276/333: Regularisation of start/stop handling., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic c744f3d3be 321/333: Shorten maximum line length in orgel, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic e27c3f3b2a 281/333: Merge pull request #41 from syohex/load-library, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 32a17b1829 323/333: Fix use of undefined variable, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic bbbfa78a0d 302/333: Add missing files, including tests., ELPA Syncer, 2024/02/27