emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Kevin M. Stout" <kevin.m.stout@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: 2 Surprises and 2 Questions Regarding Org Tangle
Date: Fri, 12 Feb 2021 21:41:43 -0500	[thread overview]
Message-ID: <20210213024143.GA14639@cibola.cibola> (raw)
In-Reply-To: <CAGY83Ef23PZoY5ve05+8p4UwuV8BoCT1o7gjd574ddvourSxQQ@mail.gmail.com>

On 2021-02-11 18:44, Diego Zamboni wrote:

> #2 is known (maybe documented? Not sure) behavior: using :noweb-ref
> accumulates multiple blocks with the same name, whereas #+NAME uses only
> the first one.

Deep in org-babel-tangle,                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
  (org-babel-map-src-blocks nil                                                                                                                                                                                                                   (let ((i (let ((org-babel-current-src-block-location (point)))                                                                                                                                                                                           (org-babel-get-src-block-info 'light))))                                                                                                                                                                                             (when (equal (or (cdr (assq :noweb-ref (nth 2 i)))                                                                                                                                                                                                             (nth 4 i))                                                                                                                                                                                                                                source-name)                                                                                                                                                                                                                       ...)))

So, while :noweb-ref gets priority over #+NAME, we can still accumulate blocks
having the same #+NAME (provided there's no overriding :noweb-ref).

> I think #+NAME's are supposed to be unique within a document.

Even though I'm a huge fan of this behavior, which lines up well with the
traditional WEB and Noweb behavior, the Org manual's discussion of code blocks
does say, "For duplicate names, Org mode's behavior is undefined." [Section
14.1] So,

Dear Org Maintainers,

Please do not change org-babel-tangle's accumulation behavior for duplicate
#+NAME's. It's handy, and users of other literate programming tools will find it
familiar. Also, #+NAME is a nicer per-block syntax than :noweb-ref.

Sincerely,
Kevin M. Stout


  reply	other threads:[~2021-02-13  2:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-09 12:29 2 Surprises and 2 Questions Regarding Org Tangle Lee Jia Hong
2021-02-11 17:44 ` Diego Zamboni
2021-02-13  2:41   ` Kevin M. Stout [this message]
2021-02-13  4:13   ` Kevin M. Stout
2021-02-11 17:46 ` Greg Minshall
2021-02-11 17:52 ` Greg Minshall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210213024143.GA14639@cibola.cibola \
    --to=kevin.m.stout@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).