aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJim Porter2024-05-20 12:45:13 -0700
committerJim Porter2024-05-20 13:24:11 -0700
commit77ece5709a1d38df8cec33432e77044c308b1d6b (patch)
treebf4ddbdf2a1c3a50e62b5b4f2d3f1271a6a370b4 /test
parentf6c60f16a231802104f53f3953b7fdc363944316 (diff)
downloademacs-77ece5709a1d38df8cec33432e77044c308b1d6b.tar.gz
emacs-77ece5709a1d38df8cec33432e77044c308b1d6b.zip
Support text overlays for thingatpt provider helpers
* lisp/thingatpt.el (thing-at-point-for-text-property) (forward-thing-for-text-property) (bounds-of-thing-at-point-for-text-property): Rename to... (thing-at-point-for-char-property) (forward-thing-for-char-property) (bounds-of-thing-at-point-for-char-property): ... and add overlay support. Update callers. * test/lisp/thingatpt-tests.el (thing-at-point-providers) (forward-thing-providers, bounds-of-thing-at-point-providers): Test overlays too. * test/lisp/progmodes/bug-reference-tests.el (test-thing-at-point): Test 'bounds-of-thing-at-point' and 'forward-point'. * etc/NEWS: Update function names in announcement.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/progmodes/bug-reference-tests.el5
-rw-r--r--test/lisp/thingatpt-tests.el30
2 files changed, 19 insertions, 16 deletions
diff --git a/test/lisp/progmodes/bug-reference-tests.el b/test/lisp/progmodes/bug-reference-tests.el
index 8cca354705b..21b9d3c8ff3 100644
--- a/test/lisp/progmodes/bug-reference-tests.el
+++ b/test/lisp/progmodes/bug-reference-tests.el
@@ -136,8 +136,11 @@
136 (goto-char (point-min)) 136 (goto-char (point-min))
137 ;; Make sure we get the URL when `bug-reference-mode' is active... 137 ;; Make sure we get the URL when `bug-reference-mode' is active...
138 (should (equal (thing-at-point 'url) "https://debbugs.gnu.org/1234")) 138 (should (equal (thing-at-point 'url) "https://debbugs.gnu.org/1234"))
139 (should (equal (bounds-of-thing-at-point 'url) '(1 . 9)))
140 (should (= (save-excursion (forward-thing 'url) (point)) 9))
139 (bug-reference-mode -1) 141 (bug-reference-mode -1)
140 ;; ... and get nil when `bug-reference-mode' is inactive. 142 ;; ... and get nil when `bug-reference-mode' is inactive.
141 (should-not (thing-at-point 'url)))) 143 (should-not (thing-at-point 'url))
144 (should-not (bounds-of-thing-at-point 'url))))
142 145
143;;; bug-reference-tests.el ends here 146;;; bug-reference-tests.el ends here
diff --git a/test/lisp/thingatpt-tests.el b/test/lisp/thingatpt-tests.el
index c3b04f29ce5..cc51e3f5296 100644
--- a/test/lisp/thingatpt-tests.el
+++ b/test/lisp/thingatpt-tests.el
@@ -262,10 +262,10 @@ position to retrieve THING.")
262 (with-temp-buffer 262 (with-temp-buffer
263 (setq-local 263 (setq-local
264 thing-at-point-provider-alist 264 thing-at-point-provider-alist
265 `((url . ,(lambda () (thing-at-point-for-text-property 'foo-url))) 265 `((url . ,(lambda () (thing-at-point-for-char-property 'foo-url)))
266 (url . ,(lambda () (thing-at-point-for-text-property 'bar-url))))) 266 (url . ,(lambda () (thing-at-point-for-char-property 'bar-url)))))
267 (insert (propertize "hello" 'foo-url "foo.com") "\n" 267 (insert (propertize "hello" 'foo-url "foo.com") "\ngoodbye")
268 (propertize "goodbye" 'bar-url "bar.com")) 268 (overlay-put (make-overlay 7 14) 'bar-url "bar.com")
269 (goto-char (point-min)) 269 (goto-char (point-min))
270 ;; Get the URL using the first provider. 270 ;; Get the URL using the first provider.
271 (should (equal (thing-at-point 'url) "foo.com")) 271 (should (equal (thing-at-point 'url) "foo.com"))
@@ -280,10 +280,10 @@ position to retrieve THING.")
280 (with-temp-buffer 280 (with-temp-buffer
281 (setq-local 281 (setq-local
282 forward-thing-provider-alist 282 forward-thing-provider-alist
283 `((url . ,(lambda (n) (forward-thing-for-text-property 'foo-url n))) 283 `((url . ,(lambda (n) (forward-thing-for-char-property 'foo-url n)))
284 (url . ,(lambda (n) (forward-thing-for-text-property 'bar-url n))))) 284 (url . ,(lambda (n) (forward-thing-for-char-property 'bar-url n)))))
285 (insert (propertize "hello" 'foo-url "foo.com") "there\n" 285 (insert (propertize "hello" 'foo-url "foo.com") "there\ngoodbye")
286 (propertize "goodbye" 'bar-url "bar.com")) 286 (overlay-put (make-overlay 12 19) 'bar-url "bar.com")
287 (goto-char (point-min)) 287 (goto-char (point-min))
288 (forward-thing 'url) ; Move past the first URL. 288 (forward-thing 'url) ; Move past the first URL.
289 (should (= (point) 6)) 289 (should (= (point) 6))
@@ -301,11 +301,11 @@ position to retrieve THING.")
301 (setq-local 301 (setq-local
302 bounds-of-thing-at-point-provider-alist 302 bounds-of-thing-at-point-provider-alist
303 `((url . ,(lambda () 303 `((url . ,(lambda ()
304 (bounds-of-thing-at-point-for-text-property 'foo-url))) 304 (bounds-of-thing-at-point-for-char-property 'foo-url)))
305 (url . ,(lambda () 305 (url . ,(lambda ()
306 (bounds-of-thing-at-point-for-text-property 'bar-url))))) 306 (bounds-of-thing-at-point-for-char-property 'bar-url)))))
307 (insert (propertize "hello" 'foo-url "foo.com") "there\n" 307 (insert (propertize "hello" 'foo-url "foo.com") "there\ngoodbye")
308 (propertize "goodbye" 'bar-url "bar.com")) 308 (overlay-put (make-overlay 12 19) 'bar-url "bar.com")
309 (goto-char (point-min)) 309 (goto-char (point-min))
310 ;; Look for a URL, using the first provider above. 310 ;; Look for a URL, using the first provider above.
311 (should (equal (bounds-of-thing-at-point 'url) '(1 . 6))) 311 (should (equal (bounds-of-thing-at-point 'url) '(1 . 6)))
@@ -325,11 +325,11 @@ position to retrieve THING.")
325 (with-temp-buffer 325 (with-temp-buffer
326 (setq-local 326 (setq-local
327 thing-at-point-provider-alist 327 thing-at-point-provider-alist
328 `((url . ,(lambda () (thing-at-point-for-text-property 'url)))) 328 `((url . ,(lambda () (thing-at-point-for-char-property 'url))))
329 forward-thing-provider-alist 329 forward-thing-provider-alist
330 `((url . ,(lambda (n) (forward-thing-for-text-property 'url n)))) 330 `((url . ,(lambda (n) (forward-thing-for-char-property 'url n))))
331 bounds-of-thing-at-point-provider-alist 331 bounds-of-thing-at-point-provider-alist
332 `((url . ,(lambda () (bounds-of-thing-at-point-for-text-property 'url))))) 332 `((url . ,(lambda () (bounds-of-thing-at-point-for-char-property 'url)))))
333 (insert (propertize "one" 'url "foo.com") 333 (insert (propertize "one" 'url "foo.com")
334 (propertize "two" 'url "bar.com") 334 (propertize "two" 'url "bar.com")
335 (propertize "three" 'url "baz.com")) 335 (propertize "three" 'url "baz.com"))