[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 41c2d0a 02/57: Handle error when no overlay at point
From: |
Justin Burkett |
Subject: |
[elpa] master 41c2d0a 02/57: Handle error when no overlay at point |
Date: |
Tue, 3 Nov 2020 14:32:17 -0500 (EST) |
branch: master
commit 41c2d0a157e739725c478aeb77de51f4d83bf569
Author: Justin Burkett <justin@burkett.cc>
Commit: Justin Burkett <justin@burkett.cc>
Handle error when no overlay at point
* vdiff.el (vdiff--overlay-at-pos): Throw user-error when no overlay is
found.
---
vdiff.el | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/vdiff.el b/vdiff.el
index 6d990f9..178d860 100644
--- a/vdiff.el
+++ b/vdiff.el
@@ -371,20 +371,28 @@ one buffer to another. Only applies in 3-way diffs."
(goto-char (point-min))
(forward-line (1- n)))
-(defun vdiff--overlay-at-pos (&optional pos)
+(defun vdiff--overlay-at-pos (&optional pos noerror)
"Return first vdiff overlay found at POS which defaults to
-point."
- (let ((pos (or pos (point))))
- (catch 'yes
- (dolist (ovr (overlays-at pos))
- (when (overlay-get ovr 'vdiff-type)
- (throw 'yes ovr))))))
+point.
+
+If NOERROR is non-nil, don't signal an error when no overlay is
+found."
+ (let ((pos (or pos (point)))
+ ovr)
+ (setq ovr
+ (catch 'yes
+ (dolist (ovr (overlays-at pos))
+ (when (overlay-get ovr 'vdiff-type)
+ (throw 'yes ovr)))))
+ (if (or ovr noerror)
+ ovr
+ (user-error "No vdiff overlay found here."))))
(defun vdiff--hunk-at-point-p ()
"Non-nil if point is in hunk overlay.
Returns overlay."
- (let ((ovr (vdiff--overlay-at-pos)))
+ (let ((ovr (vdiff--overlay-at-pos nil t)))
(and (overlayp ovr)
(overlay-get ovr 'vdiff-type)
(not (eq (overlay-get ovr 'vdiff-type) 'fold))
@@ -394,7 +402,7 @@ Returns overlay."
"Non-nil if point is in fold overlay.
Returns overlay."
- (let ((ovr (vdiff--overlay-at-pos)))
+ (let ((ovr (vdiff--overlay-at-pos nil t)))
(and (overlayp ovr)
(overlay-get ovr 'vdiff-type)
(eq (overlay-get ovr 'vdiff-type) 'fold)
@@ -411,7 +419,7 @@ Returns overlay."
(defun vdiff--maybe-exit-overlay (&optional up no-fold)
"Move point out of any vdiff overlays. Move down unless UP is
non-nil. Ignore folds if NO-FOLD is non-nil."
- (let* ((ovr (vdiff--overlay-at-pos))
+ (let* ((ovr (vdiff--overlay-at-pos nil t))
(type (when ovr (overlay-get ovr 'vdiff-type))))
(when (and type
(or (not no-fold)
@@ -1162,7 +1170,7 @@ well. This only returns bounds for `interactive'."
(deactivate-mark))
(list (if (or (= (line-number-at-pos) 1)
(vdiff--overlay-at-pos
- (line-beginning-position)))
+ (line-beginning-position) t))
(line-beginning-position)
(save-excursion
(forward-line -1)
- [elpa] master updated (3bfaa7a -> 185e803), Justin Burkett, 2020/11/03
- [elpa] master 66ae1ac 03/57: README: Note new option, Justin Burkett, 2020/11/03
- [elpa] master 52b7e04 04/57: Switch to using unified diff output (diff -u), Justin Burkett, 2020/11/03
- [elpa] master fb21cc6 08/57: Fix parsing of subtractions in diff -u, Justin Burkett, 2020/11/03
- [elpa] master f0de403 21/57: Add emacs-26.1 for Travis, Justin Burkett, 2020/11/03
- [elpa] master af74300 01/57: Add vdiff-disable-folding user option, Justin Burkett, 2020/11/03
- [elpa] master 41c2d0a 02/57: Handle error when no overlay at point,
Justin Burkett <=
- [elpa] master c1525a8 05/57: Fix problems with diff -u parser at beg and end of file, Justin Burkett, 2020/11/03
- [elpa] master 0312ac8 06/57: Update copyright years, Justin Burkett, 2020/11/03
- [elpa] master bc5e1a7 07/57: Remove debugging message, Justin Burkett, 2020/11/03
- [elpa] master b15b020 10/57: Add diff --minimal as algorithm and fix case args for git, Justin Burkett, 2020/11/03
- [elpa] master 992d07b 14/57: Add travis support, Justin Burkett, 2020/11/03
- [elpa] master 0bfb259 11/57: Add vdiff-debug flag, Justin Burkett, 2020/11/03
- [elpa] master 106a69f 20/57: Fix previous tests for Travis, Justin Burkett, 2020/11/03
- [elpa] master c803bd6 17/57: Add warnings for obsolete variables, Justin Burkett, 2020/11/03
- [elpa] master 5f7d3fd 22/57: Add Travis badge, Justin Burkett, 2020/11/03
- [elpa] master 348d1a7 27/57: Add after-quit arg to vdiff-test-with-buffers, Justin Burkett, 2020/11/03