[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/edit-indirect 45c4c72864 09/28: Use our own error signals
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/edit-indirect 45c4c72864 09/28: Use our own error signals inheriting from user-error. |
Date: |
Thu, 7 Jul 2022 11:59:13 -0400 (EDT) |
branch: elpa/edit-indirect
commit 45c4c728646855d4b24069472d8cc0b3cfdefdfc
Author: Fanael Linithien <fanael4@gmail.com>
Commit: Fanael Linithien <fanael4@gmail.com>
Use our own error signals inheriting from user-error.
---
edit-indirect.el | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/edit-indirect.el b/edit-indirect.el
index 4f0a96e748..14fae8e431 100644
--- a/edit-indirect.el
+++ b/edit-indirect.el
@@ -92,6 +92,19 @@ end of the changed region."
"Face used to highlight an indirectly edited region."
:group 'edit-indirect-faces)
+;; Emacs <= 24.3 has no `define-error'.
+(let* ((user-error-conditions (get 'user-error 'error-conditions))
+ (define-user-error (lambda (name message)
+ (put name 'error-conditions
+ (cons name user-error-conditions))
+ (put name 'error-message message))))
+ (funcall define-user-error 'edit-indirect-overlapping
+ "Indirectly edited regions cannot overlap")
+ (funcall define-user-error 'edit-indirect-read-only
+ "Text is read-only, modify the edit-indirect buffer instead")
+ (funcall define-user-error 'edit-indirect-not-indirect
+ "This is not an edit-indirect buffer"))
+
(defvar edit-indirect--overlay)
;;;###autoload
@@ -116,7 +129,8 @@ Edit-indirect buffers use the `edit-indirect-mode-map'
keymap.
If there's already an edit-indirect buffer for BEG..END, use that.
If there's already an edit-indirect buffer active overlapping any
-portion of BEG..END, an `user-error' is signaled.
+portion of BEG..END, an `edit-indirect-overlapping' error is
+signaled.
When DISPLAY-BUFFER is non-nil or when called interactively,
display the edit-indirect buffer in some window and select it.
@@ -200,7 +214,8 @@ OVERLAY is the value to set `edit-indirect--overlay' to."
(defun edit-indirect--get-edit-indirect-buffer (beg end)
"Return an edit-indirect buffer for the region BEG..END.
If there's already an edit-indirect buffer active overlapping any
-portion of BEG..END, an `user-error' is signaled."
+portion of BEG..END, an `edit-indirect-overlapping' error is
+signaled."
(let ((old-overlay (edit-indirect--search-for-edit-indirect beg end)))
(cond
((null old-overlay)
@@ -210,7 +225,7 @@ portion of BEG..END, an `user-error' is signaled."
(= end (overlay-end old-overlay)))
(overlay-get old-overlay 'edit-indirect-buffer))
(t
- (user-error "Indirectly edited regions cannot overlap")))))
+ (signal 'edit-indirect-overlapping '())))))
(defun edit-indirect--search-for-edit-indirect (beg end)
"Return an existing edit-indirect overlay for some region inside BEG..END.
@@ -270,11 +285,11 @@ BEG and END specify the region the overlay should
encompass."
"Non-nil means disregard read-only status of indirectly-edited region.")
(defun edit-indirect--barf-read-only (_ov _after _beg _end &optional _len)
- "Signal an `user-error' because the text is read-only.
-The text edited in an edit-indirect buffer shouldn't be changed in
-the parent buffer."
+ "Signal an error because the text is read-only.
+No error is signaled if `inhibit-read-only' or
+`edit-indirect--inhibit-read-only' is non-nil."
(unless (or inhibit-read-only edit-indirect--inhibit-read-only)
- (user-error "Text is read-only, modify the edit-indirect buffer instead")))
+ (signal 'edit-indirect-read-only '())))
(defun edit-indirect--commit ()
"Commit the modifications done in an edit-indirect buffer."
@@ -309,9 +324,10 @@ Should be called only from `kill-buffer-hook'."
(edit-indirect--abort)))
(defun edit-indirect--barf-if-not-indirect ()
- "Signal an `user-error' if the current buffer is not an edit-indirect
buffer."
+ "Signal an error if the current buffer is not an edit-indirect buffer.
+The error signaled is `edit-indirect-not-indirect'."
(unless edit-indirect--overlay
- (user-error "This is not an edit-indirect buffer")))
+ (signal 'edit-indirect-not-indirect '())))
(provide 'edit-indirect)
;;; edit-indirect.el ends here
- [nongnu] elpa/edit-indirect b461e559e1 05/28: Don't retrieve the buffer-local hook values before actual uses., (continued)
- [nongnu] elpa/edit-indirect b461e559e1 05/28: Don't retrieve the buffer-local hook values before actual uses., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 7d9bcfced3 06/28: Extract buffer-local value handling into a macro., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 6fa78ff6f1 07/28: Prohibit modification at the beginning of the overlay., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect f43936b3a4 12/28: Use `quit-window' instead of `kill-buffer-and-window`., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect d1ab87fdfb 14/28: Release version 0.1.2., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 032ac0ec69 20/28: Try to preserve markers when committing, ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect e3d86416bc 26/28: Offer to commit edit-indirect buffers on save-buffers-kill-emacs, ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect ce6e60c705 08/28: Require Emacs 24.3, for user-error., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect a28aba75f8 13/28: Don't separate sentences with double spaces., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 523f84cb7e 10/28: Release version 0.1.1., ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 45c4c72864 09/28: Use our own error signals inheriting from user-error.,
ELPA Syncer <=
- [nongnu] elpa/edit-indirect c6b08f5cd7 15/28: Call quit-window only when a window is created, ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 99a88e9590 17/28: Make edit-indirect-quit-window a buffer-local variable, ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 1d1dae8425 18/28: Release version 0.1.4, ELPA Syncer, 2022/07/07
- [nongnu] elpa/edit-indirect 935ded353b 22/28: Add SPDX license identifier for easy license identification, ELPA Syncer, 2022/07/07