From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.devel,gmane.emacs.orgmode Subject: Re: Adding custom providers for thingatpt.el (was: [PATCH] Add support for 'thing-at-point' to get URL at point) Date: Mon, 6 Nov 2023 12:53:02 -0800 Message-ID: <88435424-afa3-d7a3-56ff-df9f0a2ca6ba@gmail.com> References: <87leba3ame.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22848"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-orgmode@gnu.org To: Ihor Radchenko , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Nov 06 21:54:00 2023 Return-path: Envelope-to: ged-emacs-devel@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 1r06bf-0005fa-HJ for ged-emacs-devel@m.gmane-mx.org; Mon, 06 Nov 2023 21:53:59 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r06ar-0004aH-IJ; Mon, 06 Nov 2023 15:53:09 -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 1r06ap-0004Zs-TR; Mon, 06 Nov 2023 15:53:07 -0500 Original-Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r06ao-00022k-79; Mon, 06 Nov 2023 15:53:07 -0500 Original-Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6b709048f32so4603512b3a.0; Mon, 06 Nov 2023 12:53:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699303984; x=1699908784; darn=gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=d98Z+eIEI27hF9SSHxjuETENIYN/AlDTWOYnFNW5df0=; b=I3efItMb9VJvRA1ANISPvxcwezOpa+4uMcDyj4O3g8nH2JXQJrOZ9+hbWkoiGY8PzK 6lvuV+1bic2M21sAQFATTUY5S6iphOVvHH97RlVlnJs7KrSUw2EKptXhuzAEvpZ+1zM+ MRp49FRidDTCH68yuzq9xqUhXTC1ZxPOvL0+oYZJVsUy/vjS6Cam2Zv0j+GCo3LhoWiT wVrS1qtKHTt2yKtpiyFsS3QIqpvI3cSzGFUGwx3lprUdL5ZaQd1x7WQG+nDS/vJBsFAr kxMSe7M/QPBhkHQbp0+uEaN2+iFyJWvKLpYbOgC5e04adtJE1sJ27DZsHks25+7D9O8I wyng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699303984; x=1699908784; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=d98Z+eIEI27hF9SSHxjuETENIYN/AlDTWOYnFNW5df0=; b=EsYHfNGttmbKzyRj5+HFc7aVDwPawYlm9kJrcT5iltYujNmEH9Kjk3D7EIeRq298g6 bbwFlO+dCKrvJvx8Efheqb0IHptcgzFo4c8E9I6OXug4IXT3SQuxOfmiGuULnE217B+9 wmRDn8C+A3x3kY6NUJoZE/jVq12hBvin7P8BQzZ3icv3MYe9NSWKjubmN14iXFCQXbQA 1zSQpWwn7iPRVKvpbvm4g+z7h+yy4Gn0aj1Yyj2Zb84dhYvF5IoMU84HftA1GKhk657i vFnKxVHXYFGgbO4V+cxgdWNGvInE1F4PCJxsL40JUblHGttKBhbRzKO22i7UTDoMpXu+ JSzw== X-Gm-Message-State: AOJu0Yx8/KTvo7UzVIOcPWNrwhp6uNf2d87RnKpcHYTtfMdmEbRcwt1m W2m2tyGrRZ/mIad96N30MBs= X-Google-Smtp-Source: AGHT+IEdaOpp8YcHX+qLfLLFx4iWPcrxddUdNNBxM4WN/hBxqVMLxtg6NajmmiL9vPnNloQavt4WHg== X-Received: by 2002:a05:6a00:1345:b0:6bd:f760:6ab1 with SMTP id k5-20020a056a00134500b006bdf7606ab1mr28830736pfu.14.1699303984061; Mon, 06 Nov 2023 12:53:04 -0800 (PST) Original-Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id q9-20020a056a0002a900b006c33c82da66sm6000484pfs.75.2023.11.06.12.53.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Nov 2023 12:53:03 -0800 (PST) Content-Language: en-US In-Reply-To: <87leba3ame.fsf@localhost> Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=jporterbugs@gmail.com; helo=mail-pf1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:312278 gmane.emacs.orgmode:158115 Archived-At: On 11/6/2023 12:11 PM, Ihor Radchenko wrote: > [ Branching to emacs-devel for further input from Emacs devs ] > > Jim Porter writes: > >> This is similar to Emacs bug#66752[1]. It would be nice if >> "(thing-at-point 'url)" would return the URL when point is over an Org >> link. With this, it's easier to write a function that copies (or browses >> to) the URL at point without coding so many special cases. >> ... >> +(defun org--url-at-point () >> + "`thing-at-point' provider function." >> + (org-element-property :raw-link (org-element-context))) > > Supporting thingatpt.el is certainly welcome. However, I have some > doubts about how mature thingatpt.el is. > > In particular, I am concerned whether `thing-at-point-provider-alist' is > reliable enough in non-trivial scenarios like when given URL string is > not matching some generic URL regexp. The nice thing about 'thing-at-point-provider-alist' is that your provider has absolute control over what to return, so Org's URL provider could do whatever it wants. As far as I can tell, this code path completely avoids calling 'bounds-of-thing-at-point' ('botap'). However, it *would* call 'botap' if point wasn't on an Org link, since it would fall back to the last condition in 'thing-at-point'. Still, this is what happens today with no provider, so it's not really any worse than before... Maybe it would make sense for 'thing-at-point' to have a "(catch 'not-found ...)" form around the loop over 'thing-at-point-provider-alist'. Then Org could definitively say, "There's no URL at point, no matter what anyone else says". > Looking into the source code of `bounds-of-thing-at-point', I see that > for standard "things" (like url), > `thing-at-point-bounds-of-url-at-point' is used unconditionally. In the > case of Org links, we may have something like [[https://orgmode.org]] > that will not match default URL regexp as is. AFAIU, there is no > documented way to customize the behaviour of `bounds-of-thing-at-point' > and `forward-thing'. I think it would make sense to add some sort of 'bounds-of-thing-at-point-provider-alist' (that's a mouthful!) that would let modes override the behavior of 'botap', but I don't think that's necessary for the narrower purpose of asking, "I want the value of THING at point, if any." > I also have concerns about Org-specific part of the patch, but the above > is far more important, and we need to discuss it before starting to > consider anything for Org mode. For better or worse, I mostly modeled this patch on how EWW integrates with thing-at-point, since that's the only place I saw in the Emacs tree that did this already.