unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "Philip Kaludercic" <philipk@posteo.net>,
	"Titus Müller" <mail@titusmueller.de>,
	68762@debbugs.gnu.org
Subject: bug#68762: 30.0.50; thing-at-point for an e-mail adress stops at "."
Date: Sun, 28 Jan 2024 06:58:19 +0100	[thread overview]
Message-ID: <m1zfwq0zk4.fsf@dazzs-mbp.home> (raw)
In-Reply-To: <86le8a7h9n.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 27 Jan 2024 20:39:16 +0200")

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Titus Müller <mail@titusmueller.de>
>> Date: Sat, 27 Jan 2024 14:25:08 +0100
>>
>>
>> When I use (thing-at-point 'email) and point is on an e-mail adress
>> like my.name@website.com, thing-at-point only gets name@website.com
>> and loses the first part before the "." character. This happens
>> after I upgraded from 29.1 to emacs 30.0.50.
>
> Philip, is this because of the changes in commit ff20898dad?
>
> Could you please look into this?

FWIW, AFAICT this is introduced by 03cfede8f0 (which fixed Bug#61519).

I think the real issue resides in `thing-at-point-looking-at`, though:
It stops extending the match backwards when it first encounters a
non-match.  The following change solves this for me, and keeps all the
tests happy:

diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index 323d3d1cf6c..6f7532f9b0f 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -621,34 +621,22 @@ thing-at-point-looking-at
 back from point."
   (save-excursion
     (let ((old-point (point))
-	  (forward-bound (and distance (+ (point) distance)))
-	  (backward-bound (and distance (- (point) distance)))
-	  match prev-pos new-pos)
-      (and (looking-at regexp)
-	   (>= (match-end 0) old-point)
-	   (setq match (point)))
-      ;; Search back repeatedly from end of next match.
-      ;; This may fail if next match ends before this match does.
-      (re-search-forward regexp forward-bound 'limit)
-      (setq prev-pos (point))
-      (while (and (setq new-pos (re-search-backward regexp backward-bound t))
-                  ;; Avoid inflooping with some regexps, such as "^",
-                  ;; matching which never moves point.
-                  (< new-pos prev-pos)
-		  (or (> (match-beginning 0) old-point)
-		      (and (looking-at regexp)	; Extend match-end past search start
-			   (>= (match-end 0) old-point)
-			   (setq match (point))))))
-      (if (not match) nil
-	(goto-char match)
-	;; Back up a char at a time in case search skipped
-	;; intermediate match straddling search start pos.
-	(while (and (not (bobp))
-		    (progn (backward-char 1) (looking-at regexp))
-		    (>= (match-end 0) old-point)
-		    (setq match (point))))
-	(goto-char match)
-	(looking-at regexp)))))
+          prev-point match)
+      (goto-char (if distance
+                     (max (point-min) (- old-point distance))
+                   (point-min)))
+      (while (and (setq prev-point (point))
+                  (setq match
+                        (re-search-forward regexp
+                                           (and distance
+                                                (min (point-max)
+                                                     (+ old-point distance)))
+                                           t))
+                  (< (match-end 0) old-point))
+        (unless (< prev-point (point))
+          (forward-char)))
+      (and match (<= (match-beginning 0) old-point (match-end 0))))))
+

 ;;   Email addresses
 (defvar thing-at-point-email-regexp





  parent reply	other threads:[~2024-01-28  5:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-27 13:25 bug#68762: 30.0.50; thing-at-point for an e-mail adress stops at "." Titus Müller
2024-01-27 18:39 ` Eli Zaretskii
2024-01-27 20:42   ` Titus Müller
2024-01-28  5:58   ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-01-28  7:11     ` Eli Zaretskii
2024-01-28  7:47       ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-29  9:05         ` Robert Pluim
2024-01-29 12:41           ` Eli Zaretskii
2024-02-01 10:26             ` Eli Zaretskii
2024-02-01 11:10               ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-08 11:47                 ` Eli Zaretskii
2024-02-10 16:48                   ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1zfwq0zk4.fsf@dazzs-mbp.home \
    --to=bug-gnu-emacs@gnu.org \
    --cc=68762@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=mail@titusmueller.de \
    --cc=me@eshelyaron.com \
    --cc=philipk@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).