emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-babel-detangle issue on 9.1.14
       [not found] <833272723.4259898.1538636915102.ref@mail.yahoo.com>
@ 2018-10-04  7:08 ` Brad Knotwell
  2018-10-04 15:19   ` Grant Rettke
  0 siblings, 1 reply; 4+ messages in thread
From: Brad Knotwell @ 2018-10-04  7:08 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 793 bytes --]

Good day all--
I've been playing with org-babel-detangle and I've noticed something that's either a bug or a limitation.  It's confusing enough that it's worth writing down if it's expected.  Basically, it doesn't work if there are variables defined in the begin_src header.  I've attached an example below.  The first one won't detangle and the last two will.
* no work#+begin_src sh sh :tangle hw.sh :var x="hello world" :shebang #!/bin/sh :comments linkecho $x#+end_src
* works#+begin_src sh sh :tangle hw2.sh :comments linkecho "helloworld2"#+end_src
* stillworks#+begin_src sh sh :tangle hw3.sh :comments link :shebang #!/bin/shecho "helloworld3"

#+end_src
I've tested with 9.1.7 and 9.1.14 so if this is supposed to be supported it's not something newly broken.
Thx.
--Brad

[-- Attachment #2: Type: text/html, Size: 1451 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: org-babel-detangle issue on 9.1.14
  2018-10-04  7:08 ` org-babel-detangle issue on 9.1.14 Brad Knotwell
@ 2018-10-04 15:19   ` Grant Rettke
  2018-10-04 15:51     ` Brad Knotwell
  0 siblings, 1 reply; 4+ messages in thread
From: Grant Rettke @ 2018-10-04 15:19 UTC (permalink / raw)
  To: bknotwell; +Cc: Org-mode

On Thu, Oct 4, 2018 at 2:09 AM Brad Knotwell <bknotwell@yahoo.com> wrote:
> I've been playing with org-babel-detangle and I've noticed something that's either a bug or a limitation.  It's confusing enough that
> it's worth writing down if it's expected.  Basically, it doesn't work if there are variables defined in the begin_src header.  I've
> attached an example below.  The first one won't detangle and the last two will.

That is expected behavior. Org can only detangle the content of source
blocks. It can't deduce how that
source code got in there.

Maybe this example says it better:

#+begin_src sh sh :tangle hw.sh :var x=(random) :shebang #!/bin/sh
:comments link
echo $x
#+end_src

Tangles to

#!/bin/sh
# [[file:~/tmp/test.org::org_gcr_2018-10-04T08-35-43-05-00_cosmicality_CCEACAA2-A6B3-4FDD-9259-7F633316F0CE][org_gcr_2018-10-04T08-35-43-05-00_cosmicality_CCEACAA2-A6B3-4FDD-9259-7F633316F0CE]]
x='422131055910453451'
echo $x
# org_gcr_2018-10-04T08-35-43-05-00_cosmicality_CCEACAA2-A6B3-4FDD-9259-7F633316F0CE
ends here

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: org-babel-detangle issue on 9.1.14
  2018-10-04 15:19   ` Grant Rettke
@ 2018-10-04 15:51     ` Brad Knotwell
  2018-10-05 20:06       ` Grant Rettke
  0 siblings, 1 reply; 4+ messages in thread
From: Brad Knotwell @ 2018-10-04 15:51 UTC (permalink / raw)
  To: Grant Rettke; +Cc: Org-mode

[-- Attachment #1: Type: text/plain, Size: 2426 bytes --]

 Thanks for the response.  At a minimum, I'd recommend changing the error message from "Not in a source block" to something more descriptive as most people's initial response will be, "uhhh, but it looks like I am."  
Ideally, an additional comment marker would delineate the source block from the meta-programmed variables to allow the edited source code's verbatim replacement.  Or it might make sense to have a setting that separates the tangled source file from the meta programmed variables.  Using your example above, it could tangle to something like the following:
#!/bin/sh
# [[file:~/tmp/test.org::org_gcr_2018-10-04T08-35-43-05-00_cosmicality_CCEACAA2-A6B3-4FDD-9259-7F633316F0CE][org_gcr_2018-10-04T08-35-43-05-00_cosmicality_CCEACAA2-A6B3-4FDD-9259-7F633316F0CE]]. ./noideahowtonamethesegenerically.sh    # the naming seems tricky to me
echo $x# org_gcr_2018-10-04T08-35-43-05-00_cosmicality_CCEACAA2-A6B3-4FDD-9259-7F633316F0CE
ends here
If babel was starting anew, I'd prefer that as it seems cleaner than adding another comment (assumption: majority of languages have an include-like facility of some sort).  Given the number of languages currently supported, the additional comment delimiters seem less disruptive.

--Brad
    On Thursday, October 4, 2018, 8:19:30 AM PDT, Grant Rettke <gcr@wisdomandwonder.com> wrote:  
 
 On Thu, Oct 4, 2018 at 2:09 AM Brad Knotwell <bknotwell@yahoo.com> wrote:
> I've been playing with org-babel-detangle and I've noticed something that's either a bug or a limitation.  It's confusing enough that
> it's worth writing down if it's expected.  Basically, it doesn't work if there are variables defined in the begin_src header.  I've
> attached an example below.  The first one won't detangle and the last two will.

That is expected behavior. Org can only detangle the content of source
blocks. It can't deduce how that
source code got in there.

Maybe this example says it better:

#+begin_src sh sh :tangle hw.sh :var x=(random) :shebang #!/bin/sh
:comments link
echo $x
#+end_src

Tangles to

#!/bin/sh
# [[file:~/tmp/test.org::org_gcr_2018-10-04T08-35-43-05-00_cosmicality_CCEACAA2-A6B3-4FDD-9259-7F633316F0CE][org_gcr_2018-10-04T08-35-43-05-00_cosmicality_CCEACAA2-A6B3-4FDD-9259-7F633316F0CE]]
x='422131055910453451'
echo $x
# org_gcr_2018-10-04T08-35-43-05-00_cosmicality_CCEACAA2-A6B3-4FDD-9259-7F633316F0CE
ends here
  

[-- Attachment #2: Type: text/html, Size: 4085 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: org-babel-detangle issue on 9.1.14
  2018-10-04 15:51     ` Brad Knotwell
@ 2018-10-05 20:06       ` Grant Rettke
  0 siblings, 0 replies; 4+ messages in thread
From: Grant Rettke @ 2018-10-05 20:06 UTC (permalink / raw)
  To: bknotwell; +Cc: Org-mode

On Thu, Oct 4, 2018 at 10:53 AM Brad Knotwell <bknotwell@yahoo.com> wrote:
> Thanks for the response.  At a minimum, I'd recommend changing the error message from "Not in a source block" to something more descriptive
> as most people's initial response will be, "uhhh, but it looks like I am."

Consider submitting your suggestion as a patch so it is super easy to
know what change you are suggesting.

If you never submitted one before I am glad to help.

> Ideally, an additional comment marker would delineate the source block from the meta-programmed variables to allow the edited source code's
> verbatim replacement.  Or it might make sense to have a setting that separates the tangled source file from the meta programmed variables.
> Using your example above, it could tangle to something like the following:
>
> #!/bin/sh
> # [[file:~/tmp/test.org::org_gcr_2018-10-04T08-35-43-05-00_cosmicality_CCEACAA2-A6B3-4FDD-9259-7F633316F0CE][org_gcr_2018-10-04T08-35-43-05-00_cosmicality_CCEACAA2-A6B3-4FDD-9259-7F633316F0CE]]
> . ./noideahowtonamethesegenerically.sh    # the naming seems tricky to me
> echo $x
> # org_gcr_2018-10-04T08-35-43-05-00_cosmicality_CCEACAA2-A6B3-4FDD-9259-7F633316F0CE
> ends here

One way is that you can keep the values in an external file and load
it before each source block in the preamble code?

I'm thinking pretty simply but depending on what you wan to do here
there might be an easy solution.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-10-05 20:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <833272723.4259898.1538636915102.ref@mail.yahoo.com>
2018-10-04  7:08 ` org-babel-detangle issue on 9.1.14 Brad Knotwell
2018-10-04 15:19   ` Grant Rettke
2018-10-04 15:51     ` Brad Knotwell
2018-10-05 20:06       ` Grant Rettke

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).