From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Visuwesh Newsgroups: gmane.emacs.bugs Subject: bug#69239: 30.0.50; number-at-point and bounds-of-thing-at-point disagree Date: Sat, 09 Mar 2024 15:18:03 +0530 Message-ID: <8734szg2i4.fsf@gmail.com> References: <871q9c4mtv.fsf@gmail.com> <86o7c6z0f3.fsf@gnu.org> <87sf1hi28t.fsf@gmail.com> <86cyslxd3p.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="901"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 69239@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 09 10:49:59 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ritL5-00005u-CV for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 09 Mar 2024 10:49:59 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ritKd-0005Rp-8U; Sat, 09 Mar 2024 04:49:31 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ritKb-0005R0-UK for bug-gnu-emacs@gnu.org; Sat, 09 Mar 2024 04:49:29 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ritKb-0007vt-Lk for bug-gnu-emacs@gnu.org; Sat, 09 Mar 2024 04:49:29 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ritL7-0002Qd-Qc for bug-gnu-emacs@gnu.org; Sat, 09 Mar 2024 04:50:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Mar 2024 09:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69239 X-GNU-PR-Package: emacs Original-Received: via spool by 69239-submit@debbugs.gnu.org id=B69239.17099777899309 (code B ref 69239); Sat, 09 Mar 2024 09:50:01 +0000 Original-Received: (at 69239) by debbugs.gnu.org; 9 Mar 2024 09:49:49 +0000 Original-Received: from localhost ([127.0.0.1]:60712 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ritKu-0002Q3-JS for submit@debbugs.gnu.org; Sat, 09 Mar 2024 04:49:48 -0500 Original-Received: from mail-pl1-f193.google.com ([209.85.214.193]:48548) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ritKr-0002Po-Ov for 69239@debbugs.gnu.org; Sat, 09 Mar 2024 04:49:46 -0500 Original-Received: by mail-pl1-f193.google.com with SMTP id d9443c01a7336-1dd7df835a8so2241765ad.1 for <69239@debbugs.gnu.org>; Sat, 09 Mar 2024 01:49:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709977687; x=1710582487; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=L+gK/f5sJWi/PDpfTH55rihgTSKMO9odvgNoo6jT1Rg=; b=FOflNrMOsvKkiE9D7GWqbSmKDttrqodIxj2y1hMINoyJaZkeaqtKj1SbIU2UVz5fG7 yJoVKaBOE/LearwRWP2ikjpx0ipKxhA+XhkB0AHLANLbBt97SJRIL77Err3TPt/0IDzn chuudYEkhXoQ/aMBeTcvpwkt2pLelNZIZ+XjHY0tU9tohV5WVmO1nxjZXh1p7s77a/56 dm4mqjtfmYlYm+5iWiIfj3SiNQ6QW7yNEqm7G1DNJfl/kCz7gV09Wu1DZmHfdtWL3HW/ JAsSQ0Dz1TsJ3CrWZ6ZUmcTr8q+EjUvubqM4Rtv0f5ipi26KOcvSyxuRRD0kQ9Ko0zLS nMcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709977687; x=1710582487; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=L+gK/f5sJWi/PDpfTH55rihgTSKMO9odvgNoo6jT1Rg=; b=Vrw3IogWJgH8LPxc1TJOsOSbAWG0sUtonhg0VCjx+FQhWNLXqcLLkNkjfNRXjdr5h9 AkAm656nRVz7EqP5BT2z0wYHLBwyiNrcXY0OhmXEVI00rYiRTassHxDZIjlluRqKh6ju BDGVzsQpNrk91zxv8CWB4gnfazTFpOlfDp4TN2tqqENPArOmM3dhDHIh2OcqsVNyBFhC A3q8HdXqSOt3V1+JHozvv/fRuGlKGtRMIyjEjo6kdEeLoh9oynR8y+I3jFNZNYhBnP1o Tx0eLS55IFg4n5arArTQinhj80/gnrttiCSryNk9AaoihALFFDJ17QSxJEpaijNx68Pk Kr5w== X-Gm-Message-State: AOJu0YwjNg8ioK45+a+vEsf5fiSUSaFdEwmj1cc57YqpsE254+gedXeW IEEP632s13ZBvF9w6j+at3ZUYWwe37fv6FXR+syVZm+TlJSeLPockR+omtog5Ms= X-Google-Smtp-Source: AGHT+IGZFZ8b6ihfQx3WTMspF764fsSySRk6eNP5PZjets7ARYpQAU+R9LTl+RF9LfVpCKz8SiRyrw== X-Received: by 2002:a17:902:e88f:b0:1dd:7d71:66ea with SMTP id w15-20020a170902e88f00b001dd7d7166eamr1005716plg.53.1709977687180; Sat, 09 Mar 2024 01:48:07 -0800 (PST) Original-Received: from localhost ([115.240.90.130]) by smtp.gmail.com with ESMTPSA id g10-20020a1709026b4a00b001dd6a0580e3sm966329plt.280.2024.03.09.01.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 01:48:06 -0800 (PST) In-Reply-To: <86cyslxd3p.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 25 Feb 2024 08:38:34 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:281319 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable [=E0=AE=9E=E0=AE=BE=E0=AE=AF=E0=AE=BF=E0=AE=B1=E0=AF=81 =E0=AE=AA=E0=AE=BF= =E0=AE=AA=E0=AF=8D=E0=AE=B0=E0=AE=B5=E0=AE=B0=E0=AE=BF 25, 2024] Eli Zarets= kii wrote: >> But if you want to be on the safer side, then I can write a patch that >> doesn't use number-at-point. > > Yes, please. > > Thanks. Sorry for the delay, life had me busy. Please find attached patch. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-bounds-of-thing-at-point-property-for-number.patch >From f402a765365ec76f741d8eaffb75f4177abb1261 Mon Sep 17 00:00:00 2001 From: Visuwesh Date: Sat, 9 Mar 2024 15:17:26 +0530 Subject: [PATCH] Add bounds-of-thing-at-point property for 'number' * lisp/thingatpt.el (thing-at-point-decimal-regexp) (thing-at-point-hexadecimal-regexp): Extract regexps from... (number-at-point): here. Use above. (number): Add 'bounds-of-thing-at-point' property as `forward-word' does not always return the right boundary e.g., in latex-mode buffers. (bug#69239) --- lisp/thingatpt.el | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index 83ddc640d35..7896ad984df 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -735,20 +735,33 @@ symbol-at-point (let ((thing (thing-at-point 'symbol))) (if thing (intern thing)))) +(defvar thing-at-point-decimal-regexp + "-?[0-9]+\\.?[0-9]*" + "A regexp matching a decimal number.") + +(defvar thing-at-point-hexadecimal-regexp + "\\(0x\\|#x\\)\\([a-fA-F0-9]+\\)" + "A regexp matchin a hexadecimal number.") + ;;;###autoload (defun number-at-point () "Return the number at point, or nil if none is found. Decimal numbers like \"14\" or \"-14.5\", as well as hex numbers like \"0xBEEF09\" or \"#xBEEF09\", are recognized." (cond - ((thing-at-point-looking-at "\\(0x\\|#x\\)\\([a-fA-F0-9]+\\)" 500) + ((thing-at-point-looking-at thing-at-point-hexadecimal-regexp 500) (string-to-number (buffer-substring (match-beginning 2) (match-end 2)) 16)) - ((thing-at-point-looking-at "-?[0-9]+\\.?[0-9]*" 500) + ((thing-at-point-looking-at thing-at-point-decimal-regexp 500) (string-to-number (buffer-substring (match-beginning 0) (match-end 0)))))) +(put 'number 'bounds-of-thing-at-point + (lambda () + (and (or (thing-at-point-looking-at thing-at-point-hexadecimal-regexp 500) + (thing-at-point-looking-at thing-at-point-decimal-regexp 500)) + (cons (match-beginning 0) (match-end 0))))) (put 'number 'forward-op 'forward-word) (put 'number 'thing-at-point 'number-at-point) -- 2.43.0 --=-=-=--