summaryrefslogtreecommitdiff
path: root/lisp/thingatpt.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2011-05-13 14:02:56 -0300
committerStefan Monnier <monnier@iro.umontreal.ca>2011-05-13 14:02:56 -0300
commitf278f87fe6b2556d2152c72b0f9460b44bb4ff24 (patch)
tree2e690df8b81381224f5fe55132aebf42cb310cf8 /lisp/thingatpt.el
parentceb90e51986a8aa3e6e141137013fe454db48a78 (diff)
downloademacs-f278f87fe6b2556d2152c72b0f9460b44bb4ff24.tar.gz
* lisp/thingatpt.el (bounds-of-thing-at-point): Return nil rather than
bounds for the empty string. Fixes: debbugs:8667
Diffstat (limited to 'lisp/thingatpt.el')
-rw-r--r--lisp/thingatpt.el9
1 files changed, 5 insertions, 4 deletions
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index a56c3e4d501..a2aeb2e6d67 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -89,18 +89,19 @@ of the textual entity that was found."
(or (get thing 'beginning-op)
(lambda () (forward-thing thing -1))))
(let ((beg (point)))
- (if (not (and beg (> beg orig)))
+ (if (<= beg orig)
;; If that brings us all the way back to ORIG,
;; it worked. But END may not be the real end.
;; So find the real end that corresponds to BEG.
+ ;; FIXME: in which cases can `real-end' differ from `end'?
(let ((real-end
(progn
(funcall
(or (get thing 'end-op)
(lambda () (forward-thing thing 1))))
(point))))
- (if (and beg real-end (<= beg orig) (<= orig real-end))
- (cons beg real-end)))
+ (when (and (<= orig real-end) (< beg real-end))
+ (cons beg real-end)))
(goto-char orig)
;; Try a second time, moving backward first and then forward,
;; so that we can find a thing that ends at ORIG.
@@ -117,7 +118,7 @@ of the textual entity that was found."
(or (get thing 'beginning-op)
(lambda () (forward-thing thing -1))))
(point))))
- (if (and real-beg end (<= real-beg orig) (<= orig end))
+ (if (and (<= real-beg orig) (<= orig end) (< real-beg end))
(cons real-beg end))))))
(error nil)))))