From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Madhu Newsgroups: gmane.emacs.bugs Subject: bug#74132: 31.0.50; thing-at-pt, ffap and Github markdown Date: Thu, 31 Oct 2024 16:06:49 +0530 (IST) Message-ID: <20241031.160649.1619221016115134543.enometh@meer.net> Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Thu_Oct_31_16_06_49_2024_217)--" Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16630"; mail-complaints-to="usenet@ciao.gmane.io" To: 74132@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 31 11:43:14 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 1t6Se2-0004Ah-5H for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 31 Oct 2024 11:43:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6Sdt-0005Bc-U2; Thu, 31 Oct 2024 06:43:05 -0400 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 1t6Sdr-0005AY-OL for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 06:43:03 -0400 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 1t6Sdq-0008EG-FA for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 06:43:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=Mime-Version:From:Date:To:Subject; bh=2MkwQDFPOb2kmD1IJBQNd5wHWIGhSUt80UD5uMyzAkE=; b=R+Fa3pW9DIfVNin2DTIilZ8w8FSXpUGi0kASgRbeHYROq/7/0q+Hp7reCnTpqMhYSXM16bQLU7mF36cRfHjbWeXV//RueIYFdLQHX+OduKcBTxeQ3eo6RecXOMWX9H8YiZgy9mWW43M5BT4zBp7fJXd5MK9VX22rsK4QBWdKXqCKo5JNC9TplfKKunlQV2zScJ30+zuOMdTLAkqys+HKxlKm2Jr/WPVkPyOF6z42Yy4kVutHVFygSwWfg//GybpPQnGsIcPfPpnauHu3AwB4S11iZB8/PrZYcGvg2RgHk7cBz4COa2f0YVTIBicqgddc2n9EtwK/9cZjYs5zDwiyDg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t6Sdq-0003J9-9b for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 06:43:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Madhu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 31 Oct 2024 10:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74132 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.173037135112690 (code B ref -1); Thu, 31 Oct 2024 10:43:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 31 Oct 2024 10:42:31 +0000 Original-Received: from localhost ([127.0.0.1]:41595 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6SdK-0003Ib-UB for submit@debbugs.gnu.org; Thu, 31 Oct 2024 06:42:31 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:57514) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6SdH-0003IS-Gv for submit@debbugs.gnu.org; Thu, 31 Oct 2024 06:42:29 -0400 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 1t6SdF-0004mr-57 for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 06:42:26 -0400 Original-Received: from smtp0.ctinetworks.com ([205.166.61.207]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6SdC-00088d-Dp for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 06:42:24 -0400 X-ctinetworks-Watermark: 1731235341.49993@R/A0v5/5scwRcHdNk/ZayQ X-ctinetworks-Envelope-From: enometh@meer.net X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-Message-ID: 920F399E8.A2FF0 Original-Received: from localhost (unknown [117.254.37.96]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp0.ctinetworks.com (Postfix) with ESMTPSA id 920F399E8 for ; Thu, 31 Oct 2024 06:42:19 -0400 (EDT) X-Mailer: Mew version 6.9 on Emacs 31.0.50 Received-SPF: pass client-ip=205.166.61.207; envelope-from=enometh@meer.net; helo=smtp0.ctinetworks.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:294613 Archived-At: ----Next_Part(Thu_Oct_31_16_06_49_2024_217)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Consider the following text as is typically found on README.md ``` [![GitHub Releases Downloads](https://img.shields.io/github/downloads/raysan5/raylib/total)](https://github.com/raysan5/raylib/releases) ``` If the point is say at "r" at "raylib/releases", invoking (ffap-url-at-point) fails. this eventually calls thing-at-point-bounds-of-url-at-point, which has hardcoded behaviour to, skip over "allowed characters" backwards to find the beginning of the bound. here it it finds the space character (in "Release Downloads") and the whole thing fails. This particular failure can be addressed by supplying the lim paramater to the skip-chars-backward, as shown in the attached patch. does this look like a problem which ought to be solved? and is this appropriate? (I was going to post on emacs-devel but decided to post to the bug list instead) -- Best Regards, Madhu ----Next_Part(Thu_Oct_31_16_06_49_2024_217)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0001-lisp-thingatpt.el-recognize-urls-better-in-markdown-.patch" >From 5971b7c10d7c38d540fdf278a0cd559c96b10ed2 Mon Sep 17 00:00:00 2001 From: Madhu Date: Thu, 31 Oct 2024 15:40:42 +0530 Subject: [PATCH] lisp/thingatpt.el: recognize urls better in markdown text * lisp/thingatpt.el: (thing-at-point-bounds-of-url-at-point): supply a LIM when calling (skip-chars-backward allowed-chars), which is the position where `thing-at-point-beginning-of-url-regexp' matches backwards problematic url e.g. ``` [![GitHub Releases Downloads](https://img.shields.io/github/downloads/raysan5/raylib/total)](https://github.com/raysan5/raylib/releases) ``` If the point is in the the second url, skip-chars-backwards goes to the space (between s and D) and `ffap-url-at-point' eventually fails. but if we supply a limit with a left anchor, we work around it. --- lisp/thingatpt.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index 3cfd3905701..0b8e28af5b9 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -502,9 +502,14 @@ thing-at-point-bounds-of-url-at-point (let* ((allowed-chars "--:=&?$+@-Z_[:alpha:]~#,%;*()!'[]") (skip-before "^[0-9a-zA-Z]") (skip-after ":;.,!?'") + (hard-beg (and thing-at-point-beginning-of-url-regexp + (save-excursion + (re-search-backward + thing-at-point-beginning-of-url-regexp nil t) + (point)))) (pt (point)) (beg (save-excursion - (skip-chars-backward allowed-chars) + (skip-chars-backward allowed-chars hard-beg) (skip-chars-forward skip-before pt) (point))) (end (save-excursion -- 2.46.0.27.gfa3b914457 ----Next_Part(Thu_Oct_31_16_06_49_2024_217)----