[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 0967dbf2de 4/4: Add test for thing-at-mouse
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 0967dbf2de 4/4: Add test for thing-at-mouse |
Date: |
Mon, 16 Jan 2023 05:57:28 -0500 (EST) |
branch: externals/compat
commit 0967dbf2decbeabe3421430b4a37f94e9da25505
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add test for thing-at-mouse
---
compat-28.el | 8 ++++----
compat-tests.el | 9 +++++++++
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/compat-28.el b/compat-28.el
index 29a7942155..b04b75c3ed 100644
--- a/compat-28.el
+++ b/compat-28.el
@@ -678,20 +678,20 @@ just the selected frame."
;;;; Defined in thingatpt.el
-(compat-defun thing-at-mouse (event thing &optional no-properties) ;;
<UNTESTED>
+(compat-defun thing-at-mouse (event thing &optional no-properties) ;;
<compat-tests:thing-at-mouse>
"Return the THING at mouse click.
Like `thing-at-point', but tries to use the event
where the mouse button is clicked to find a thing nearby."
- :feature thingatpt
+ ;; No :feature specified, since the function is autoloaded.
(save-excursion
(mouse-set-point event)
(thing-at-point thing no-properties)))
-(compat-defun bounds-of-thing-at-mouse (event thing) ;; <UNTESTED>
+(compat-defun bounds-of-thing-at-mouse (event thing) ;;
<compat-tests:thing-at-mouse>
"Determine start and end locations for THING at mouse click given by EVENT.
Like `bounds-of-thing-at-point', but tries to use the position in EVENT
where the mouse button is clicked to find the thing nearby."
- :feature thingatpt
+ ;; No :feature specified, since the function is autoloaded.
(save-excursion
(mouse-set-point event)
(bounds-of-thing-at-point thing)))
diff --git a/compat-tests.el b/compat-tests.el
index a83f48f216..08ea45ed23 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -80,6 +80,15 @@
(setq list (funcall sym list "first" 1 #'string=))
(should (eq (compat-call plist-get list "first" #'string=) 1))))
+(ert-deftest thing-at-mouse ()
+ (save-window-excursion
+ (with-temp-buffer
+ (let ((event `(mouse-1 (,(selected-window) 1 (0 . 0) 0))))
+ (set-window-buffer nil (current-buffer))
+ (insert "http://emacs.org/")
+ (should-equal "http://emacs.org/" (thing-at-mouse event 'url))
+ (should-equal '(1 . 18) (bounds-of-thing-at-mouse event 'url))))))
+
(ert-deftest dolist-with-progress-reporter ()
(let (y)
(should-equal