summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/eww.el6
-rw-r--r--lisp/progmodes/bug-reference.el6
-rw-r--r--lisp/thingatpt.el50
3 files changed, 35 insertions, 27 deletions
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index be43ac2f9db..32e24f9e2e5 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1380,15 +1380,15 @@ within text input fields."
(defun eww--url-at-point ()
"`thing-at-point' provider function."
- (thing-at-point-for-text-property 'shr-url))
+ (thing-at-point-for-char-property 'shr-url))
(defun eww--forward-url (backward)
"`forward-thing' provider function."
- (forward-thing-for-text-property 'shr-url backward))
+ (forward-thing-for-char-property 'shr-url backward))
(defun eww--bounds-of-url-at-point ()
"`bounds-of-thing-at-point' provider function."
- (bounds-of-thing-at-point-for-text-property 'shr-url))
+ (bounds-of-thing-at-point-for-char-property 'shr-url))
;;;###autoload
(defun eww-browse-url (url &optional new-window)
diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el
index 9b8e5c0b106..46163774e47 100644
--- a/lisp/progmodes/bug-reference.el
+++ b/lisp/progmodes/bug-reference.el
@@ -658,15 +658,15 @@ have been run, the auto-setup is inhibited.")
(defun bug-reference--url-at-point ()
"`thing-at-point' provider function."
- (thing-at-point-for-text-property 'bug-reference-url))
+ (thing-at-point-for-char-property 'bug-reference-url))
(defun bug-reference--forward-url (backward)
"`forward-thing' provider function."
- (forward-thing-for-text-property 'bug-reference-url backward))
+ (forward-thing-for-char-property 'bug-reference-url backward))
(defun bug-reference--bounds-of-url-at-point ()
"`bounds-of-thing-at-point' provider function."
- (bounds-of-thing-at-point-for-text-property 'bug-reference-url))
+ (bounds-of-thing-at-point-for-char-property 'bug-reference-url))
(defun bug-reference--init (enable)
(if enable
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index ff0ed66d62d..fe9f5003f0b 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -828,40 +828,48 @@ treated as white space."
;; Provider helper functions
-(defun thing-at-point-for-text-property (property)
+(defun thing-at-point-for-char-property (property)
"Return the \"thing\" at point.
-Each \"thing\" is a region of text with the specified text PROPERTY set."
- (or (get-text-property (point) property)
+Each \"thing\" is a region of text with the specified text PROPERTY (or
+overlay) set."
+ (or (get-char-property (point) property)
(and (> (point) (point-min))
- (get-text-property (1- (point)) property))))
+ (get-char-property (1- (point)) property))))
(autoload 'text-property-search-forward "text-property-search")
(autoload 'text-property-search-backward "text-property-search")
(autoload 'prop-match-beginning "text-property-search")
(autoload 'prop-match-end "text-property-search")
-(defun forward-thing-for-text-property (property &optional backward)
+(defun forward-thing-for-char-property (property &optional backward)
"Move forward to the end of the next \"thing\".
If BACKWARD is non-nil, move backward to the beginning of the previous
\"thing\" instead. Each \"thing\" is a region of text with the
-specified text PROPERTY set."
- (let ((search-func (if backward #'text-property-search-backward
- #'text-property-search-forward))
- (pos-func (if backward #'prop-match-beginning #'prop-match-end)))
- (when-let ((match (funcall search-func property)))
- (goto-char (funcall pos-func match)))))
-
-(defun bounds-of-thing-at-point-for-text-property (property)
+specified text PROPERTY (or overlay) set."
+ (let ((bounds (bounds-of-thing-at-point-for-char-property property)))
+ (if backward
+ (if (and bounds (> (point) (car bounds)))
+ (goto-char (car bounds))
+ (goto-char (previous-single-char-property-change (point) property))
+ (unless (get-char-property (point) property)
+ (goto-char (previous-single-char-property-change
+ (point) property))))
+ (if (and bounds (< (point) (cdr bounds)))
+ (goto-char (cdr bounds))
+ (unless (get-char-property (point) property)
+ (goto-char (next-single-char-property-change (point) property)))
+ (goto-char (next-single-char-property-change (point) property))))))
+
+(defun bounds-of-thing-at-point-for-char-property (property)
"Determine the start and end buffer locations for the \"thing\" at point.
-The \"thing\" is a region of text with the specified text PROPERTY set."
+The \"thing\" is a region of text with the specified text PROPERTY (or
+overlay) set."
(let ((pos (point)))
- (when (or (get-text-property pos property)
+ (when (or (get-char-property pos property)
(and (> pos (point-min))
- (get-text-property (setq pos (1- pos)) property)))
- (cons (or (previous-single-property-change
- (min (1+ pos) (point-max)) property)
- (point-min))
- (or (next-single-property-change pos property)
- (point-max))))))
+ (get-char-property (setq pos (1- pos)) property)))
+ (cons (previous-single-char-property-change
+ (min (1+ pos) (point-max)) property)
+ (next-single-char-property-change pos property)))))
;;; thingatpt.el ends here