From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id ELYgD8Tu7GKdzAAAbAwnHQ (envelope-from ) for ; Fri, 05 Aug 2022 12:19:48 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id cNjuDsTu7GJhVAEA9RJhRA (envelope-from ) for ; Fri, 05 Aug 2022 12:19:48 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C5FEF8DA2 for ; Fri, 5 Aug 2022 12:19:47 +0200 (CEST) Received: from localhost ([::1]:35582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJuQh-0000gO-Ge for larch@yhetil.org; Fri, 05 Aug 2022 06:19:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJuLo-0005cc-UF for emacs-orgmode@gnu.org; Fri, 05 Aug 2022 06:14:40 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:38685) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJuLm-0006tx-Sb for emacs-orgmode@gnu.org; Fri, 05 Aug 2022 06:14:40 -0400 Received: by mail-pf1-x431.google.com with SMTP id d20so1851818pfq.5 for ; Fri, 05 Aug 2022 03:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=w/d6Dv4fB0jNHndBlv6hofE9J17JFCNWueIk21ZS6QI=; b=OD6qls2pHy6II+L+Xo+vVUhOlhLDw2iLUJQHaYlpMsWjwaujatUyacSoGvJ146Ll1/ 4BNKVAvi8H+WXU8g7L8UFaRKa78+Is1IyWlNTr8hwoPSasi8uOP8Fbnkwcm12bIVhpHi Ak7PE+N2FIt7YKOJeG606gsvexY3jDsuSfCUB/M2NgKYY6BJIZVtg/XQNmbLey+osjxb 5IQg9WEsP8j9US8jYlyHoHBKnljyTsW1lrZ0XL9+VYMI1sjFXz2qpqsk51fv2p2iW86q UWfIUWyyIu8R9glvgTNffdN5hzovCL03DDucjiIt9qaLkcD2Q3f8lXgAuZWM0bStFU+Q F46Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=w/d6Dv4fB0jNHndBlv6hofE9J17JFCNWueIk21ZS6QI=; b=MRDQvngM2zj9/+28XfSffg0TNhQNv8ZntsGx85X353yPz53lZPOR43SH0LRzAtEK9X PYDjlEF88LgygfwmOv0iv1gKBrfTPK+sLt0I6xR7fYVee3wz30kEhtbzeOtVhj1PQy9T v9uX+gFJ1MSAdLZ+0/NL3QE+qBNjJVbxnInhuZzYCixv08rj4f9XCpYyHxmZ/AIfnBiR /xFOJ7JQ8ukS71skvWDo95AEqzXHdzCRGTNtfGN72ZaR7NT1WKTiyoO09dW64ewoIxng WJWsHpk1BRv5pgco2ejJg+rp5XuWG+w6TTe6UShfzal7V03yV9oO0dTJjvgkg4kJB5/O kANA== X-Gm-Message-State: ACgBeo25egD0HxH/AdGeNbQ704MDAdvOt+3yKdVtvKqQVYevRvAz+JG4 dV8kVGPkkmLKFNoKw6kTOGpGoWmALWM= X-Google-Smtp-Source: AA6agR7hMsINHy4kZIq789t2tm8gPVyUj1SOZOoZZMjsWGn3v6pxpW9SGcq8qZoGGGOrJ8ou3oXcqA== X-Received: by 2002:a05:6a02:207:b0:41c:9e7d:775e with SMTP id bh7-20020a056a02020700b0041c9e7d775emr5215191pgb.227.1659694477325; Fri, 05 Aug 2022 03:14:37 -0700 (PDT) Received: from localhost ([115.154.175.57]) by smtp.gmail.com with ESMTPSA id p16-20020a63c150000000b0040ca587fe0fsm1133781pgi.63.2022.08.05.03.14.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 03:14:36 -0700 (PDT) From: Ihor Radchenko To: reza Cc: "emacs-orgmode@gnu.org" Subject: [PATCH] org-export: Make results of named code blocks a valid link In-Reply-To: <010201826cb68597-bf75d596-7890-4dd0-b9ff-0c7b617b4dd4-000000@eu-west-1.amazonses.com> References: <56e1e299-b04d-0b01-7dec-564207d4484a@housseini.me> <01020182658e20e8-67e349b2-0f8b-457a-89ac-8242af01ff94-000000@eu-west-1.amazonses.com> <87mtckhgxq.fsf@localhost> <032306dd-7465-fdfd-b6c1-0bd82b662370@housseini.me> <0102018269e0c5a8-804eb3c2-47b4-45e5-9efc-87a2aa56cc0e-000000@eu-west-1.amazonses.com> <87bkszpiiy.fsf@localhost> <010201826cb68597-bf75d596-7890-4dd0-b9ff-0c7b617b4dd4-000000@eu-west-1.amazonses.com> Date: Fri, 05 Aug 2022 18:15:43 +0800 Message-ID: <87mtcjnghc.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=yantar92@gmail.com; helo=mail-pf1-x431.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, 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-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1659694787; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=w/d6Dv4fB0jNHndBlv6hofE9J17JFCNWueIk21ZS6QI=; b=HoT+dOHLVvOYIMLAn+Qpuj4vv7+kWyNps51VAHg2ykObx3Bs/GsUJV9jACYnGpgTPJzRpf P/RWqL8XIs6DXTazvORccbzQhsCtTaDZe0duFunP/w2FL2/m5WwFweSfv04uq4Z0V7phBJ i1XfEYW/SCqTdCZOg90bAtOOrurzKOj2Z92UFIst3Yayjf8q5sgYz49ppTgWRkZYJRulu5 13ZXDjWYyd4TPNwQktfKIbkpzHsT59Lv7KiS0zueqy20E+3jmpQIfCY2+vl9WRPzx1qMQ6 pf9X229ckFqBx+hJlPtJyqBF0XNKs/6WSxKJjGgOgHp/N9jqOFGt/1uBIndHxA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1659694787; a=rsa-sha256; cv=none; b=BNxuYzqOdShLnzqi6KgO/xhr+wcT24SAWa772240KATwVyIh8kuVBrYIh7TnnZm5IddGB/ Bv4VKJqDHF/Yh05rAloa71FiFcQuhkKTkLBZ0WD/wvkNHhPbVbkwGbdrnq5+lIO7igA7ae AqC9GoL7iGPUqv5CLWageDFztm3Jyle2MnLRX6iI2tMUMfxwfbpqQIQSmlSW18oTma1n/+ nMck2i3UV9RheD+ugqW2SttmsaBHI467A2rXobLJ+RFnF7CLHnfGq7NAo3AHrRniLIbCfq IyBI8DM/L5srNFaKHKEBagOfX5WujTCr2ccluEGHtw8LbUawuPHgpJ5LJ7AA2w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OD6qls2p; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -5.40 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OD6qls2p; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: C5FEF8DA2 X-Spam-Score: -5.40 X-Migadu-Scanner: scn0.migadu.com X-TUID: g3/Wrz6NszG8 --=-=-= Content-Type: text/plain reza writes: > On 8/5/22 03:48, Ihor Radchenko wrote: >> >> This email is already a bug report :) > Haha nice :) >> >> However, we cannot just blindly carry over the name tag to the result. >> >> Consider a case when you have ":results both" in your src block. Where >> should the [[html transformation]] link refer to? The src block? The >> resulting image? >> > Perhaps it is sufficient to add a hint to the error message: > > unable to resolve link, name tag is on source but you specified :exports > results This would be tricky. The export code is only presented with buffer version to be exported. All the :exports none/:exports results code blocks are removed when we resolve links. > Or just carry it over for :exports results only? I like this idea better. See the attached patch. After the patch, links to :exports both blocks will be ambiguous, unless the results are explicitly named. So, I documented this detail in the manual. Let me know if there are any objections. Best, Ihor --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-export-Make-results-of-named-code-blocks-a-valid.patch >From 0a0dda33cee7355602feb954e0645ed8652e0983 Mon Sep 17 00:00:00 2001 Message-Id: <0a0dda33cee7355602feb954e0645ed8652e0983.1659694297.git.yantar92@gmail.com> From: Ihor Radchenko Date: Fri, 5 Aug 2022 18:09:02 +0800 Subject: [PATCH] org-export: Make results of named code blocks a valid link target * lisp/ox.el (org-export-search-cells): Use #+RESULTS keyword as search cell when #+NAME is not provided. Update the docstring accordingly. (org-export-resolve-fuzzy-link): Update the docstring. * doc/org-manual.org (Exporting Code Blocks): Document the new behavior and explain the details of exporting links to named code blocks/results. Fixes https://orgmode.org/list/010201826cb68597-bf75d596-7890-4dd0-b9ff-0c7b617b4dd4-000000@eu-west-1.amazonses.com --- doc/org-manual.org | 30 ++++++++++++++++++++++++++++++ lisp/ox.el | 10 ++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 466718e6e..e03fd059a 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -18283,6 +18283,36 @@ ** Exporting Code Blocks exported file. Whether the code is evaluated at all depends on other options. Example: =:exports none=. +If a source block is named using =NAME= keyword, the same name will be +assigned to the results of evaluation. This way, fuzzy links pointing +to the named source blocks exported using =:exports results= will +remain valid and point to the results of evaluation. + +Results of evaluation of a named block can also be explicitly named +using a separate =NAME= keyword. The name value set via =NAME= +keyword will be preferred over the parent source block. + +: #+NAME: code name +: #+BEGIN_SRC emacs-lisp :exports both value +: (+ 1 2) +: #+END_SRC +: +: #+NAME: results name +: #+RESULTS: code name +: 3 +: +: This [[code name][link]] will point to the code block. +: Another [[results name][link]] will point to the results. + +Explicit setting of the result name may be necessary when a named code +block is exported using =:exports both=. Links to such block may +arbitrarily point either to the code block or to its results when +results do not have a distinct name. + +Note that all the links pointing to a source block exported using +=:exports none= will be broken. This will make export process fail, +unless broken links are allowed during export (see [[*Export Settings]]). + #+vindex: org-export-use-babel To stop Org from evaluating code blocks to speed exports, use the header argument =:eval never-export= (see [[*Evaluating Code Blocks]]). diff --git a/lisp/ox.el b/lisp/ox.el index 57d375b35..433272915 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -4312,7 +4312,7 @@ (defun org-export-search-cells (datum) - target's or radio-target's name as a list of strings if TYPE is `target'. - - NAME affiliated keyword if TYPE is `other'. + - NAME or RESULTS affiliated keyword if TYPE is `other'. A search cell is the internal representation of a fuzzy link. It ignores white spaces and statistics cookies, if applicable." @@ -4330,7 +4330,8 @@ (defun org-export-search-cells (datum) (and custom-id (cons 'custom-id custom-id))))))) (`target (list (cons 'target (split-string (org-element-property :value datum))))) - ((and (let name (org-element-property :name datum)) + ((and (let name (or (org-element-property :name datum) + (car (org-element-property :results datum)))) (guard name)) (list (cons 'other (split-string name)))) (_ nil))) @@ -4362,8 +4363,9 @@ (defun org-export-resolve-fuzzy-link (link info &rest pseudo-types) - If LINK path matches a target object (i.e. <>) return it. -- If LINK path exactly matches the name affiliated keyword - (i.e. #+NAME: path) of an element, return that element. +- If LINK path exactly matches the name or results affiliated keyword + (i.e. #+NAME: path or #+RESULTS: name) of an element, return that + element. - If LINK path exactly matches any headline name, return that element. -- 2.35.1 --=-=-=--