[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/undo-tree c9f78c3 137/195: Use new user-error instead o
From: |
Stefan Monnier |
Subject: |
[elpa] externals/undo-tree c9f78c3 137/195: Use new user-error instead of error for expected undo errors. |
Date: |
Sat, 28 Nov 2020 13:41:38 -0500 (EST) |
branch: externals/undo-tree
commit c9f78c30f75bb798faadfb8351b4572b5a44e570
Author: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Commit: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Use new user-error instead of error for expected undo errors.
---
undo-tree.el | 51 ++++++++++++++++++++++++++++++++-------------------
1 file changed, 32 insertions(+), 19 deletions(-)
diff --git a/undo-tree.el b/undo-tree.el
index a597be9..9897250 100644
--- a/undo-tree.el
+++ b/undo-tree.el
@@ -828,6 +828,16 @@
(file-local-copy file-or-buf))))
+;; `user-error' isn't defined in Emacs < 24.3
+(unless (fboundp 'user-error)
+ (defalias 'user-error 'error)
+ ;; prevent debugger being called on user errors
+ (add-to-list 'debug-ignored-errors "^No further undo information")
+ (add-to-list 'debug-ignored-errors "^No further redo information")
+ (add-to-list 'debug-ignored-errors "^No further redo information for
region"))
+
+
+
;;; =====================================================================
@@ -1047,10 +1057,6 @@ in visualizer."
(defconst undo-tree-visualizer-buffer-name " *undo-tree*")
(defconst undo-tree-diff-buffer-name "*undo-tree Diff*")
-;; prevent debugger being called on "No further redo information"
-(add-to-list 'debug-ignored-errors "^No further redo information")
-(add-to-list 'debug-ignored-errors "^No further redo information for region")
-
;; install history-auto-save hooks
(add-hook 'write-file-functions 'undo-tree-save-history-hook)
(add-hook 'find-file-hook 'undo-tree-load-history-hook)
@@ -2653,7 +2659,8 @@ mode, just \\[universal-argument] as an argument limits
undo to
changes within the current region."
(interactive "*P")
;; throw error if undo is disabled in buffer
- (when (eq buffer-undo-list t) (error "No undo information in this buffer"))
+ (when (eq buffer-undo-list t)
+ (user-error "No undo information in this buffer"))
(undo-tree-undo-1 arg)
;; inform user if at branch point
(when (> (undo-tree-num-branches) 1) (message "Undo branch point!")))
@@ -2680,14 +2687,14 @@ changes within the current region."
(dotimes (i (or (and (numberp arg) (prefix-numeric-value arg)) 1))
;; check if at top of undo tree
(unless (undo-tree-node-previous (undo-tree-current buffer-undo-tree))
- (error "No further undo information"))
+ (user-error "No further undo information"))
;; if region is active, or a non-numeric prefix argument was supplied,
;; try to pull out a new branch of changes affecting the region
(when (and undo-in-region
(not (undo-tree-pull-undo-in-region-branch
(region-beginning) (region-end))))
- (error "No further undo information for region"))
+ (user-error "No further undo information for region"))
;; remove any GC'd elements from node's undo list
(setq current (undo-tree-current buffer-undo-tree))
@@ -2759,7 +2766,8 @@ mode, just \\[universal-argument] as an argument limits
redo to
changes within the current region."
(interactive "*P")
;; throw error if undo is disabled in buffer
- (when (eq buffer-undo-list t) (error "No undo information in this buffer"))
+ (when (eq buffer-undo-list t)
+ (user-error "No undo information in this buffer"))
(undo-tree-redo-1 arg)
;; inform user if at branch point
(when (> (undo-tree-num-branches) 1) (message "Undo branch point!")))
@@ -2786,14 +2794,14 @@ changes within the current region."
(dotimes (i (or (and (numberp arg) (prefix-numeric-value arg)) 1))
;; check if at bottom of undo tree
(when (null (undo-tree-node-next (undo-tree-current buffer-undo-tree)))
- (error "No further redo information"))
+ (user-error "No further redo information"))
;; if region is active, or a non-numeric prefix argument was supplied,
;; try to pull out a new branch of changes affecting the region
(when (and redo-in-region
(not (undo-tree-pull-redo-in-region-branch
(region-beginning) (region-end))))
- (error "No further redo information for region"))
+ (user-error "No further redo information for region"))
;; get next node (but DON'T advance current node in tree yet, in case
;; redoing fails)
@@ -2877,11 +2885,13 @@ using `undo-tree-redo'."
(1- (undo-tree-num-branches)) b)))
))))))
;; throw error if undo is disabled in buffer
- (when (eq buffer-undo-list t) (error "No undo information in this buffer"))
+ (when (eq buffer-undo-list t)
+ (user-error "No undo information in this buffer"))
;; sanity check branch number
- (when (<= (undo-tree-num-branches) 1) (error "Not at undo branch point"))
+ (when (<= (undo-tree-num-branches) 1)
+ (user-error "Not at undo branch point"))
(when (or (< branch 0) (> branch (1- (undo-tree-num-branches))))
- (error "Invalid branch number"))
+ (user-error "Invalid branch number"))
;; transfer entries accumulated in `buffer-undo-list' to `buffer-undo-tree'
(undo-list-transfer-to-tree)
;; switch branch
@@ -2931,7 +2941,8 @@ The saved state can be restored using
Argument is a character, naming the register."
(interactive "cUndo-tree state to register: ")
;; throw error if undo is disabled in buffer
- (when (eq buffer-undo-list t) (error "No undo information in this buffer"))
+ (when (eq buffer-undo-list t)
+ (user-error "No undo information in this buffer"))
;; transfer entries accumulated in `buffer-undo-list' to `buffer-undo-tree'
(undo-list-transfer-to-tree)
;; save current node to REGISTER
@@ -2956,11 +2967,11 @@ Argument is a character, naming the register."
(let ((data (registerv-data (get-register register))))
(cond
((eq buffer-undo-list t)
- (error "No undo information in this buffer"))
+ (user-error "No undo information in this buffer"))
((not (undo-tree-register-data-p data))
- (error "Register doesn't contain undo-tree state"))
+ (user-error "Register doesn't contain undo-tree state"))
((not (eq (current-buffer) (undo-tree-register-data-buffer data)))
- (error "Register contains undo-tree state for a different buffer")))
+ (user-error "Register contains undo-tree state for a different buffer")))
;; transfer entries accumulated in `buffer-undo-list' to `buffer-undo-tree'
(undo-list-transfer-to-tree)
;; restore buffer state corresponding to saved node
@@ -2996,7 +3007,8 @@ Otherwise, prompt for one.
If OVERWRITE is non-nil, any existing file will be overwritten
without asking for confirmation."
(interactive)
- (when (eq buffer-undo-list t) (error "No undo information in this buffer"))
+ (when (eq buffer-undo-list t)
+ (user-error "No undo information in this buffer"))
(undo-list-transfer-to-tree)
(when (and buffer-undo-tree (not (eq buffer-undo-tree t)))
(condition-case nil
@@ -3120,7 +3132,8 @@ signaling an error if file is not found."
(interactive "*")
(deactivate-mark)
;; throw error if undo is disabled in buffer
- (when (eq buffer-undo-list t) (error "No undo information in this buffer"))
+ (when (eq buffer-undo-list t)
+ (user-error "No undo information in this buffer"))
;; transfer entries accumulated in `buffer-undo-list' to `buffer-undo-tree'
(undo-list-transfer-to-tree)
;; add hook to kill visualizer buffer if original buffer is changed
- [elpa] externals/undo-tree ffd18cd 175/195: Refactor undo-list-transfer-to-tree again in attempt to mitigate GC races., (continued)
- [elpa] externals/undo-tree ffd18cd 175/195: Refactor undo-list-transfer-to-tree again in attempt to mitigate GC races., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 941bfe5 190/195: Don't attempt to save undo history if history file is unwritable., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 5a1ba84 017/195: Added standard Elisp package headers, including an extensive Commentary., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 62e6097 044/195: Added undo-tree-save/restore-state-to/from-register commands and keybindings, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree c638cbd 051/195: General code tidying and reorganisation., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree caa3bd0 082/195: Added new customization option to allow undo-in-region to be disabled., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 8972e4d 069/195: Use get-buffer-create when creating the visualizer buffer in undo-tree-visualize., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree d7c1b2c 118/195: "De-circle" undo-tree when saving to file, restore when loading., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 121cab9 136/195: Trivial typo fixes in comments., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 18754c1 114/195: Use with-temp-buffer instead of with-temp-file when saving undo history., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree c9f78c3 137/195: Use new user-error instead of error for expected undo errors.,
Stefan Monnier <=
- [elpa] externals/undo-tree 1114679 135/195: Fix bugs in binding of undo-tree-insert-face., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 5d19d4e 155/195: Bump version number and copyright year., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree ffb346a 157/195: Install undo-tree undo/redo Edit menu bar items., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 19baf49 158/195: Fix undo/redo-in-region tree diagrams in Commentary., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 22d6c01 153/195: Fix bug that cleared tree when enabling undo-tree-mode., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 46639dd 154/195: Tweak undo history file names to match Emacs backup file names., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree fba51e6 146/195: Add undo-tree-visualizer[-mouse]-select functions to select node at pos or click., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 43663f6 159/195: Fix bug in menu entries that triggered error on null buffer-undo-tree., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 133b439 148/195: Set protected-local property on various visualizer variables., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree bc9d095 156/195: Clear undo-tree-visualizer-needs-extending-[up|down] before drawing tree., Stefan Monnier, 2020/11/28