From mboxrd@z Thu Jan 1 00:00:00 1970 From: Win Treese Subject: Re: open link in source code block Date: Wed, 16 Jan 2019 18:43:02 -0500 Message-ID: <2C9824E1-C291-475C-820A-B0F83A5E6619@acm.org> References: <8585C713-3A24-4FE3-A187-A4587F3ADC97@acm.org> <87y37zo0za.fsf@gmail.com> <00803EED-3898-4FA2-803E-245F45F897FE@ucsd.edu> Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([209.51.188.92]:33972) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjuq0-0000Ju-AH for Emacs-orgmode@gnu.org; Wed, 16 Jan 2019 18:43:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjupy-0002XG-LE for Emacs-orgmode@gnu.org; Wed, 16 Jan 2019 18:43:12 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:47641) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gjupy-0002QE-7E for Emacs-orgmode@gnu.org; Wed, 16 Jan 2019 18:43:10 -0500 In-Reply-To: <00803EED-3898-4FA2-803E-245F45F897FE@ucsd.edu> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: "Berry, Charles" Cc: "Emacs-orgmode@gnu.org" [Quoting trimmed for the most relevant context.] > On Jan 11, 2019, at 7:12 PM, Berry, Charles wrote: >=20 >> On Jan 5, 2019, at 7:41 AM, Win Treese wrote: >>=20 >>> On Jan 5, 2019, at 5:25 AM, Eric S Fraga wrote: >>>=20 >>> On Friday, 4 Jan 2019 at 19:38, Win Treese wrote: >>>> Suppose I have the following Org file contents: >>>>=20 >>>> * test >>>>=20 >>>> #+BEGIN_SRC emacs-lisp >>>> (setq yyy 3) >>>> ;; See https://www.gnu.org >>>> #+END_SRC >>>>=20 >>>> The URL for gnu.org is highlighted as a clickable link. But if I = click >>>> it, the source block is evaluated. This seems rather unexpected, >>>> especially since my intention was to open the link. >>>=20 >>> Probably expected albeit maybe not your preferred behaviour; all = about >>> precedence. In any case, I would suggest that the easy solution = would >>> be to move such links out of the src block.=20 >> This seems like a slightly bigger problem, though: clicking on a = highlighted >> link doesn=E2=80=99t just fail to open the link, it executes the = source block, which can >> have very unintended side effects. >>=20 >> I wonder if the issue is an artifact of implementation rather than = intentional >> design: org-open-at-mouse sets point to the location of the click and = then >> calls org-open-at-point. The documentation at points says that C-c = C-o in=20 >> a source block opens the results of evaluation (fair enough, although = the >> docstring does not). >>=20 >> So the problem seems to be about the mouse click behavior, not the = basic >> function of org-open-at-point. >=20 > AFAICS, the issue is with org-open-at-point. >=20 > If you really want to `fix' this, there is a hook that allows = customization of the behavior of org-open-at-point. >=20 > This snippet will add a function to that hook that will attempt to = follow a link, when you click on a link in a src-block: [Example code with function added to org-open-at-point-functions = elided.] Chuck, Thanks for the code. You=E2=80=99re right=E2=80=94the proximate problem = is in org-open-at-point. Unfortunately, org-open-at-point calls org-babel-open-src-block-result = first thing, wrapped by unless, before it gets to running the hook. Plausible changes would be to treat this as a mouse click issue and = change org-open-at-mouse, or to change the precedence in org-open-at-point, which Eric suggested = is a way to look at the problem. For the moment, I=E2=80=99m going to use a personal version of = org-open-at-mouse, but I still think that running the code in a block when a URL is clicked is an = unusual but=20 potentially big problem for someone. Thanks, Win