* org-babel prepends <<noweb>> expansions with the prefix of the <<tag>>? Can this be turned off? @ 2020-02-25 2:09 Vladimir Nikishkin 2020-02-25 7:00 ` Johannes Dahl 2020-09-07 4:33 ` Bastien 0 siblings, 2 replies; 5+ messages in thread From: Vladimir Nikishkin @ 2020-02-25 2:09 UTC (permalink / raw) To: emacs-orgmode Hello, everyone I have the following case: #+name: test1 #+begin_src shell LINE to comment LINE to not comment #+end_src #+begin_src shell #<<test1>> #+end_src When I expand it, I get: #LINE to comment #LINE to not comment That's not entirely what I want. Can this behaviour be switched off somehow? -- Yours sincerely, Vladimir Nikishkin ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: org-babel prepends <<noweb>> expansions with the prefix of the <<tag>>? Can this be turned off? 2020-02-25 2:09 org-babel prepends <<noweb>> expansions with the prefix of the <<tag>>? Can this be turned off? Vladimir Nikishkin @ 2020-02-25 7:00 ` Johannes Dahl 2020-02-25 7:11 ` Johannes Dahl 2020-09-07 4:33 ` Bastien 1 sibling, 1 reply; 5+ messages in thread From: Johannes Dahl @ 2020-02-25 7:00 UTC (permalink / raw) Cc: emacs-orgmode Hi, That's a fun coincidence, I ran into this behaviour a couple of days ago as well. For anyone wondering why one would want to comment out their noweb tags but still expect them to result in uncommented code expansion: if one is to edit a source block containing Noweb tags, the emacs mode for that programming language might interpret those tags in an unexpected way and give a messy result, e.g. in my case with LilyPond, mess up the indentation of the rest of the code block. Luckily, Noweb tag syntax is configurable using org-babel-noweb-wrap-start and org-babel-noweb-wrap-end. Thus, the way I worked around this was to define, for the file containing LilyPond code blocks, org-babel-noweb-wrap-start as "%<<", % being LilyPond's comment symbol. But I still wonder if there is a better way. Cheers, Johannes On Tue, 25 Feb 2020 at 04:10, Vladimir Nikishkin <lockywolf@gmail.com> wrote: > > Hello, everyone > > I have the following case: > > #+name: test1 > #+begin_src shell > LINE to comment > LINE to not comment > #+end_src > > #+begin_src shell > #<<test1>> > #+end_src > > When I expand it, I get: > #LINE to comment > #LINE to not comment > > That's not entirely what I want. Can this behaviour be switched off somehow? > > -- > Yours sincerely, Vladimir Nikishkin > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: org-babel prepends <<noweb>> expansions with the prefix of the <<tag>>? Can this be turned off? 2020-02-25 7:00 ` Johannes Dahl @ 2020-02-25 7:11 ` Johannes Dahl 0 siblings, 0 replies; 5+ messages in thread From: Johannes Dahl @ 2020-02-25 7:11 UTC (permalink / raw) Cc: emacs-orgmode Having re-read Vladimir's original question, it looks like I may have misunderstood it at first. Now I'm wondering: What's the use case for referencing a code block but commenting out the first line? On Tue, 25 Feb 2020 at 09:00, Johannes Dahl <muusik@gmail.com> wrote: > > Hi, > > That's a fun coincidence, I ran into this behaviour a couple of days > ago as well. For anyone wondering why one would want to comment out > their noweb tags but still expect them to result in uncommented code > expansion: if one is to edit a source block containing Noweb tags, the > emacs mode for that programming language might interpret those tags in > an unexpected way and give a messy result, e.g. in my case with > LilyPond, mess up the indentation of the rest of the code block. > > Luckily, Noweb tag syntax is configurable using > org-babel-noweb-wrap-start and org-babel-noweb-wrap-end. Thus, the way > I worked around this was to define, for the file containing LilyPond > code blocks, org-babel-noweb-wrap-start as "%<<", % being LilyPond's > comment symbol. But I still wonder if there is a better way. > > Cheers, > Johannes > > On Tue, 25 Feb 2020 at 04:10, Vladimir Nikishkin <lockywolf@gmail.com> wrote: > > > > Hello, everyone > > > > I have the following case: > > > > #+name: test1 > > #+begin_src shell > > LINE to comment > > LINE to not comment > > #+end_src > > > > #+begin_src shell > > #<<test1>> > > #+end_src > > > > When I expand it, I get: > > #LINE to comment > > #LINE to not comment > > > > That's not entirely what I want. Can this behaviour be switched off somehow? > > > > -- > > Yours sincerely, Vladimir Nikishkin > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: org-babel prepends <<noweb>> expansions with the prefix of the <<tag>>? Can this be turned off? 2020-02-25 2:09 org-babel prepends <<noweb>> expansions with the prefix of the <<tag>>? Can this be turned off? Vladimir Nikishkin 2020-02-25 7:00 ` Johannes Dahl @ 2020-09-07 4:33 ` Bastien 2020-09-10 9:21 ` Vladimir Nikishkin 1 sibling, 1 reply; 5+ messages in thread From: Bastien @ 2020-09-07 4:33 UTC (permalink / raw) To: Vladimir Nikishkin; +Cc: emacs-orgmode Hi Vladimir, Vladimir Nikishkin <lockywolf@gmail.com> writes: > That's not entirely what I want. What do you want instead? It's not clear to me from your example. Thanks, -- Bastien ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: org-babel prepends <<noweb>> expansions with the prefix of the <<tag>>? Can this be turned off? 2020-09-07 4:33 ` Bastien @ 2020-09-10 9:21 ` Vladimir Nikishkin 0 siblings, 0 replies; 5+ messages in thread From: Vladimir Nikishkin @ 2020-09-10 9:21 UTC (permalink / raw) To: Bastien; +Cc: emacs-orgmode Hello, Bastien, Thanks for getting back to me. In ob-core.el, function org-babel-expand-noweb-references, line 2747, there is a 'mapconcat, that is commented as ";; Interpose PREFIX between every line." It prepends the "prefix", that is the content of the block to be expanded from the beginning of the line where a <<noweb>> reference is encountered to the beginning of the reference itself, that is to the first "<". My point is that this is not the most obvious way to do the expansion. It does work if the "prefix" is a line comment character, similar to C++ "//" However, consider the following example: ``` # -*- mode: org; -*- * test :PROPERTIES: :header-args: :noweb yes :END: #+name: block1 #+begin_src shell printf "test1 \n" printf "test2 \n" printf "test3 \n" #+end_src #+begin_src shell :shebang "#!/bin/chibi-scheme" #<<block1>> <<block1>> #+end_src ``` Expanding this example gives: ``` #printf "test1 \n" #printf "test2 \n" #printf "test3 \n" # printf "test1 \n" #<<block1>> printf "test2 \n" #<<block1>> printf "test3 \n" #<<block1>> ``` Not a very obvious interpretation! At least I would expect the following instead: ``` #printf "test1 \n" printf "test2 \n" printf "test3 \n" printf "test1 \n" printf "test2 \n" printf "test3 \n" ``` Because at least it wouldn't leave anything resembling a "<<noweb>>" block in the expansion result. Thanks for looking at this issue. Vlad On Mon, 7 Sep 2020 at 12:33, Bastien <bzg@gnu.org> wrote: > > Hi Vladimir, > > Vladimir Nikishkin <lockywolf@gmail.com> writes: > > > That's not entirely what I want. > > What do you want instead? It's not clear to me from your example. > > Thanks, > > -- > Bastien -- Yours sincerely, Vladimir Nikishkin ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-09-10 9:27 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-02-25 2:09 org-babel prepends <<noweb>> expansions with the prefix of the <<tag>>? Can this be turned off? Vladimir Nikishkin 2020-02-25 7:00 ` Johannes Dahl 2020-02-25 7:11 ` Johannes Dahl 2020-09-07 4:33 ` Bastien 2020-09-10 9:21 ` Vladimir Nikishkin
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.