From f278f87fe6b2556d2152c72b0f9460b44bb4ff24 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 13 May 2011 14:02:56 -0300 Subject: [PATCH] * lisp/thingatpt.el (bounds-of-thing-at-point): Return nil rather than bounds for the empty string. Fixes: debbugs:8667 --- lisp/ChangeLog | 7 ++++++- lisp/thingatpt.el | 9 +++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3fa18d2480b..b4807f7d279 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,9 +1,14 @@ +2011-05-13 Stefan Monnier + + * thingatpt.el (bounds-of-thing-at-point): Return nil rather than + bounds for the empty string (bug#8667). + 2011-05-13 Glenn Morris * mail/feedmail.el (feedmail-buffer-to-sendmail): Require sendmail. * mail/sendmail.el (sendmail-program): Try executable-find first. - (sendmail-send-it): sendmail-program cannot be unbound. + (sendmail-send-it): `sendmail-program' cannot be unbound. * calendar/appt.el (appt-make-list): Simplify. (appt-time-msg-list): Doc fix. 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))))) -- 2.39.2