Re: noweb and shell heredocs

2021-11-25 Thread Immanuel Litzroth
You can set the delimiters used for noweb code.
org-babel-noweb-wrap-end and org-babel-noweb-wrap-end.

I think I set them to @@ in shell code.
Immanuel

On Thu, Nov 25, 2021 at 7:41 PM Łukasz Stelmach  wrote:
>
> Hi,
>
> Is there anything I may try to stop shell syntax hihgliting in code
> blocks being fooled by noweb refs?
>
> --
> Kind regards,
> Łukasz Stelmach



-- 
-- A man must either resolve to point out nothing new or to become a
slave to defend it. -- Sir Isaac Newton



Re: noweb syntax clashing with shell here document syntax

2021-03-22 Thread Immanuel Litzroth
You can choose which delimiters signal noweb.
see the documentation of org-babel-noweb-wrap-start and
org-babel-noweb-wrap-end.
Immanuel

On Mon, Mar 22, 2021 at 5:35 PM Sebastian Miele
 wrote:
>
> Hello!
>
> The noweb syntax seems to clash with the syntax of here documents in
> shell scripts.  In the block like
>
> #+BEGIN_SRC shell :noweb yes
>   echo a
>   <>
>   echo b
> #+END_SRC
>
> everything following the line with the the noweb reference does not
> get fontified properly.  I suspect that the problem already is known
> for a long time.  Is that true?  If yes, what is the status of this
> issue?  Is there a known workaround?
>
> At least in ZSH it may very well be the case that a line ending with
> '>>' never is valid, except in cases where something like an '< before it is not an opening of a here document.  So it possibly is
> something that could be fixed in sh-script.el.  But I do not know
> exactly.
>
> Anybody who already knows more about this?
>
> Best wishes
> Sebastian
>


-- 
-- Researching the dual problem of finding the function that has a
given point as fixpoint.



Re: ist here a :post header arg for tangling?

2021-01-04 Thread Immanuel Litzroth
I also seem to remember that the buffer you are dropped into after tangling
doesn't even have the correct major mode set.
Immanuel

On Mon, Jan 4, 2021 at 4:11 PM Diego Zamboni  wrote:
>
> Agree. It should be possible to make the hook file-local, but still it's not 
> trivial to have good control over where and how the changes are made.
>
> --Diego
>
>
> On Mon, Jan 4, 2021 at 3:51 PM Immanuel Litzroth 
>  wrote:
>>
>> There's that, but you're not gonna do much with that since it is
>> global to emacs. If you're brimming
>> with vigour you might achieve what you want by rebinding that each
>> time you tangle to do the correct
>> thing. Not much information is available in that hook, you get dropped
>> into a temp buffer containing the
>> result of tangling.
>> Immanuel
>>
>> On Mon, Jan 4, 2021 at 3:07 PM Diego Zamboni  wrote:
>> >
>> > There's =org-babel-post-tangle-hook=, which AFAICT specifies hooks that 
>> > will be run with the tangled code in a temporary buffer. I couldn't find 
>> > much documentation nor examples, but it is mentioned at 
>> > https://orgmode.org/manual/Extracting-Source-Code.html#Hooks-3
>> >
>> > --Diego
>> >
>> >
>> >
>> >
>> >
>> > On Fri, Jan 1, 2021 at 1:31 PM Immanuel Litzroth 
>> >  wrote:
>> >>
>> >> I don't think there is an arg for that. I have written a tangler that
>> >> reuses a lot
>> >> of the org-babel machinery and has a more flexible mechanism to decide 
>> >> what
>> >> to do with the tangled code -- I use it for example to not write a
>> >> tangled file if it
>> >> hasn't changed, meaning that it will not trigger recompile.
>> >> The project is private now but if you're interested I can give you access 
>> >> to it.
>> >> What exactly are you trying to do?
>> >> Immanuel
>> >>
>> >> On Fri, Jan 1, 2021 at 2:09 AM George Mauer  wrote:
>> >> >
>> >> > I'd like to run some code to post-process files after they are tangled. 
>> >> > Is there a header-arg for that?
>> >>
>> >>
>> >>
>> >> --
>> >> -- Researching the dual problem of finding the function that has a
>> >> given point as fixpoint.
>> >>
>>
>>
>> --
>> -- Researching the dual problem of finding the function that has a
>> given point as fixpoint.



-- 
-- Researching the dual problem of finding the function that has a
given point as fixpoint.



Re: ist here a :post header arg for tangling?

2021-01-04 Thread Immanuel Litzroth
Oh and I also made the tangling itself more flexible in that you can now
also choose to only tangle stuff going to a certain file. This is mainly to be
able to define an interactive command that tangles/reloads everything going
to the file under point.
Immanuel

On Mon, Jan 4, 2021 at 4:31 PM Immanuel Litzroth
 wrote:
>
> Well I solved the problem by writing a tangler which can be configured
> with tangle-config
> you define a tangler by making a hash "language" -> tangle-hooks. The
> tangle-hooks are
> called at beginning of tangling, on each source block, on each
> noweb-ref and at the end of
> tangling. They receive the full source-block-info to do their work,
> and in the case of noweb-references
> they receive the full stack of sbi's that lead up to this noweb reference.
> >>>
> (tangled-buffer "Buffer that is being tangled")
>  (name "Name of the code block")
>  (tangle-file "Filename to tangle to")
>  (properties "Properties of this block")
>  (full-block "Text of the full block")
>  (beg-block "Buffer pos of beginning of the block in the tangled buffer")
>  (end-block "end of the block in the tangled buffer")
>  (lang "language of the tangled buffer")
>  (beg-lang "beginning of the language in the tangled buffer")
>  (end-lang "end of the language in the tangled buffer")
>  (switches "switches of this block")
>  (beg-switches "begin of the switches in this block")
>  (end-switches "end of the switches in this block")
>  (header-args "header args of this block")
>  (beg-header-args "buffer pos of header args beginning")
>  (end-header-args "buffer pos of header args end")
>  (body "body of the tangled block")
>  (beg-body "buffer pos of the beginning of the body")
>  (end-body "buffer pos of the end of the body"))
> >>>
> That way I can tangle a multi language org file and do the correct thing for
> each of the language by defining functions of interest. It's quite
> flexible, I'm
> going to use it to do some aspect-oriented programming/tangling when I
> find the time.
> Immanuel
>
> On Mon, Jan 4, 2021 at 4:11 PM Diego Zamboni  wrote:
> >
> > Agree. It should be possible to make the hook file-local, but still it's 
> > not trivial to have good control over where and how the changes are made.
> >
> > --Diego
> >
> >
> > On Mon, Jan 4, 2021 at 3:51 PM Immanuel Litzroth 
> >  wrote:
> >>
> >> There's that, but you're not gonna do much with that since it is
> >> global to emacs. If you're brimming
> >> with vigour you might achieve what you want by rebinding that each
> >> time you tangle to do the correct
> >> thing. Not much information is available in that hook, you get dropped
> >> into a temp buffer containing the
> >> result of tangling.
> >> Immanuel
> >>
> >> On Mon, Jan 4, 2021 at 3:07 PM Diego Zamboni  wrote:
> >> >
> >> > There's =org-babel-post-tangle-hook=, which AFAICT specifies hooks that 
> >> > will be run with the tangled code in a temporary buffer. I couldn't find 
> >> > much documentation nor examples, but it is mentioned at 
> >> > https://orgmode.org/manual/Extracting-Source-Code.html#Hooks-3
> >> >
> >> > --Diego
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > On Fri, Jan 1, 2021 at 1:31 PM Immanuel Litzroth 
> >> >  wrote:
> >> >>
> >> >> I don't think there is an arg for that. I have written a tangler that
> >> >> reuses a lot
> >> >> of the org-babel machinery and has a more flexible mechanism to decide 
> >> >> what
> >> >> to do with the tangled code -- I use it for example to not write a
> >> >> tangled file if it
> >> >> hasn't changed, meaning that it will not trigger recompile.
> >> >> The project is private now but if you're interested I can give you 
> >> >> access to it.
> >> >> What exactly are you trying to do?
> >> >> Immanuel
> >> >>
> >> >> On Fri, Jan 1, 2021 at 2:09 AM George Mauer  wrote:
> >> >> >
> >> >> > I'd like to run some code to post-process files after they are 
> >> >> > tangled. Is there a header-arg for that?
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> -- Researching the dual problem of finding the function that has a
> >> >> given point as fixpoint.
> >> >>
> >>
> >>
> >> --
> >> -- Researching the dual problem of finding the function that has a
> >> given point as fixpoint.
>
>
>
> --
> -- Researching the dual problem of finding the function that has a
> given point as fixpoint.



-- 
-- Researching the dual problem of finding the function that has a
given point as fixpoint.



Re: ist here a :post header arg for tangling?

2021-01-04 Thread Immanuel Litzroth
Well I solved the problem by writing a tangler which can be configured
with tangle-config
you define a tangler by making a hash "language" -> tangle-hooks. The
tangle-hooks are
called at beginning of tangling, on each source block, on each
noweb-ref and at the end of
tangling. They receive the full source-block-info to do their work,
and in the case of noweb-references
they receive the full stack of sbi's that lead up to this noweb reference.
>>>
(tangled-buffer "Buffer that is being tangled")
 (name "Name of the code block")
 (tangle-file "Filename to tangle to")
 (properties "Properties of this block")
 (full-block "Text of the full block")
 (beg-block "Buffer pos of beginning of the block in the tangled buffer")
 (end-block "end of the block in the tangled buffer")
 (lang "language of the tangled buffer")
 (beg-lang "beginning of the language in the tangled buffer")
 (end-lang "end of the language in the tangled buffer")
 (switches "switches of this block")
 (beg-switches "begin of the switches in this block")
 (end-switches "end of the switches in this block")
 (header-args "header args of this block")
 (beg-header-args "buffer pos of header args beginning")
 (end-header-args "buffer pos of header args end")
 (body "body of the tangled block")
 (beg-body "buffer pos of the beginning of the body")
 (end-body "buffer pos of the end of the body"))
>>>
That way I can tangle a multi language org file and do the correct thing for
each of the language by defining functions of interest. It's quite
flexible, I'm
going to use it to do some aspect-oriented programming/tangling when I
find the time.
Immanuel

On Mon, Jan 4, 2021 at 4:11 PM Diego Zamboni  wrote:
>
> Agree. It should be possible to make the hook file-local, but still it's not 
> trivial to have good control over where and how the changes are made.
>
> --Diego
>
>
> On Mon, Jan 4, 2021 at 3:51 PM Immanuel Litzroth 
>  wrote:
>>
>> There's that, but you're not gonna do much with that since it is
>> global to emacs. If you're brimming
>> with vigour you might achieve what you want by rebinding that each
>> time you tangle to do the correct
>> thing. Not much information is available in that hook, you get dropped
>> into a temp buffer containing the
>> result of tangling.
>> Immanuel
>>
>> On Mon, Jan 4, 2021 at 3:07 PM Diego Zamboni  wrote:
>> >
>> > There's =org-babel-post-tangle-hook=, which AFAICT specifies hooks that 
>> > will be run with the tangled code in a temporary buffer. I couldn't find 
>> > much documentation nor examples, but it is mentioned at 
>> > https://orgmode.org/manual/Extracting-Source-Code.html#Hooks-3
>> >
>> > --Diego
>> >
>> >
>> >
>> >
>> >
>> > On Fri, Jan 1, 2021 at 1:31 PM Immanuel Litzroth 
>> >  wrote:
>> >>
>> >> I don't think there is an arg for that. I have written a tangler that
>> >> reuses a lot
>> >> of the org-babel machinery and has a more flexible mechanism to decide 
>> >> what
>> >> to do with the tangled code -- I use it for example to not write a
>> >> tangled file if it
>> >> hasn't changed, meaning that it will not trigger recompile.
>> >> The project is private now but if you're interested I can give you access 
>> >> to it.
>> >> What exactly are you trying to do?
>> >> Immanuel
>> >>
>> >> On Fri, Jan 1, 2021 at 2:09 AM George Mauer  wrote:
>> >> >
>> >> > I'd like to run some code to post-process files after they are tangled. 
>> >> > Is there a header-arg for that?
>> >>
>> >>
>> >>
>> >> --
>> >> -- Researching the dual problem of finding the function that has a
>> >> given point as fixpoint.
>> >>
>>
>>
>> --
>> -- Researching the dual problem of finding the function that has a
>> given point as fixpoint.



-- 
-- Researching the dual problem of finding the function that has a
given point as fixpoint.



Re: ist here a :post header arg for tangling?

2021-01-04 Thread Immanuel Litzroth
There's that, but you're not gonna do much with that since it is
global to emacs. If you're brimming
with vigour you might achieve what you want by rebinding that each
time you tangle to do the correct
thing. Not much information is available in that hook, you get dropped
into a temp buffer containing the
result of tangling.
Immanuel

On Mon, Jan 4, 2021 at 3:07 PM Diego Zamboni  wrote:
>
> There's =org-babel-post-tangle-hook=, which AFAICT specifies hooks that will 
> be run with the tangled code in a temporary buffer. I couldn't find much 
> documentation nor examples, but it is mentioned at 
> https://orgmode.org/manual/Extracting-Source-Code.html#Hooks-3
>
> --Diego
>
>
>
>
>
> On Fri, Jan 1, 2021 at 1:31 PM Immanuel Litzroth 
>  wrote:
>>
>> I don't think there is an arg for that. I have written a tangler that
>> reuses a lot
>> of the org-babel machinery and has a more flexible mechanism to decide what
>> to do with the tangled code -- I use it for example to not write a
>> tangled file if it
>> hasn't changed, meaning that it will not trigger recompile.
>> The project is private now but if you're interested I can give you access to 
>> it.
>> What exactly are you trying to do?
>> Immanuel
>>
>> On Fri, Jan 1, 2021 at 2:09 AM George Mauer  wrote:
>> >
>> > I'd like to run some code to post-process files after they are tangled. Is 
>> > there a header-arg for that?
>>
>>
>>
>> --
>> -- Researching the dual problem of finding the function that has a
>> given point as fixpoint.
>>


-- 
-- Researching the dual problem of finding the function that has a
given point as fixpoint.



Re: ist here a :post header arg for tangling?

2021-01-01 Thread Immanuel Litzroth
I don't think there is an arg for that. I have written a tangler that
reuses a lot
of the org-babel machinery and has a more flexible mechanism to decide what
to do with the tangled code -- I use it for example to not write a
tangled file if it
hasn't changed, meaning that it will not trigger recompile.
The project is private now but if you're interested I can give you access to it.
What exactly are you trying to do?
Immanuel

On Fri, Jan 1, 2021 at 2:09 AM George Mauer  wrote:
>
> I'd like to run some code to post-process files after they are tangled. Is 
> there a header-arg for that?



-- 
-- Researching the dual problem of finding the function that has a
given point as fixpoint.



Re: Unhealthy Haskell babel

2020-12-10 Thread Immanuel Litzroth
Well another possible solution is to wrap the code blocks in
:{
xxx
:}
in
(defun org-babel-execute:haskell (body params) -- ob-haskell.el
Immanuel

On Thu, Dec 10, 2020 at 6:21 PM Lawrence Bottorff  wrote:
>
> I see your point, i.e., compiled, multi-file projects are not really meant 
> for the REPL-dominant world of org-mode babel. Babel's sweet-spot would be 
> the interpreted world, the very best probably a Lisp language. Still, the 
> ability to add code to a running REPL should be possible. As I mentioned, SML 
> is a sibling of Haskell and its babel implementation worked fine for me as I 
> worked through an SML course. So yes, this appears to be a Haskell REPL 
> issue. I'm just a beginner with Haskell, and all my intro texts start you out 
> using the ghci REPL interactively. But then they switch you over to a text 
> file compiled in the REPL with :l myfile.hs . . . no explanation as to why 
> you can't just continue with the REPL putting the program in line-by-line. 
> The fact that I can use the :set +m to include multiple lines of code, but 
> cannot do a type definition is rather bizarre, though. This is a decision 
> Haskell made with their REPL and babel really can't do much about it, I 
> suppose. The Haskell .lhs literate option is interesting. Yes, I'd like to 
> see your tangle option, please.
>
> On Thu, Dec 10, 2020 at 4:28 AM Immanuel Litzroth 
>  wrote:
>>
>> I don't think org-babel is a good fit for compiled languages. If the
>> idea is to just take 1 snippet,
>> and "execute" that it means that to have a consistent whole you'd need
>> to put all the modules of
>> your program into that snippet (already impossible in Haskell, you can
>> have only 1 module per file),
>> compile that, run the resulting binary. Or org mode would have to have
>> some idea of what needs to
>> be retangled & rebuilt.
>> I think that using org-babel for compiled, multifile languages will
>> only work in very simple cases -- and
>> even then.. -- but will lead to problems very soon.
>> Immanuel
>>
>> On Thu, Dec 10, 2020 at 4:21 AM Lawrence Bottorff  wrote:
>> >
>> > I'm looking into Haskell (latest ghci) again on org-mode. This
>> >
>> > #+begin_src haskell :results verbatim :exports both
>> > :set +m
>> > doubleSmallNumber x = if x > 100
>> >   then x
>> >   else x*2
>> > #+end_src
>> >
>> > works, but still the :set +m is necessary for it to see the whole. But this
>> >
>> > #+begin_src haskell :results verbatim :exports both
>> > :set +m
>> > factorial :: Int -> Int
>> > factorial 0 = 1
>> > factorial n = n * factorial (n - 1)
>> > #+end_src
>> >
>> > results in this on the REPL side:
>> >
>> > Prelude> :set +m
>> > factorial :: Int -> Int
>> > factorial 0 = 1
>> > factorial n = n * factorial (n - 1)
>> > "org-babel-haskell-eoe"
>> > Prelude>
>> > :26:1-23: error:
>> > • No instance for (Show (Int -> Int)) arising from a use of ‘print’
>> > (maybe you haven't applied a function to enough arguments?)
>> > • In a stmt of an interactive GHCi command: print it
>> > Prelude> Prelude> Prelude> "org-babel-haskell-eoe"
>> >
>> > which is the same behavior if I try to feed the program into the REPL one 
>> > line at a time, i.e.,
>> >
>> > Prelude> factorial :: Int -> Int
>> >
>> > :40:1-23: error:
>> > • No instance for (Show (Int -> Int)) arising from a use of ‘print’
>> > (maybe you haven't applied a function to enough arguments?)
>> > • In a stmt of an interactive GHCi command: print it
>> >
>> > So the :set +m trick (take multiple lines) doesn't help here. Obviously, 
>> > Haskell is not ready to be used with Babel. Can it be fixed? BTW, this 
>> > does work with the regular ghci REPL and haskell-mode. If it helps, 
>> > Standard ML, which has very similar syntax (it was Haskell's parent), 
>> > works fine.
>> >
>> > LB
>>
>>
>>
>> --
>> -- Researching the dual problem of finding the function that has a
>> given point as fixpoint.



-- 
-- Researching the dual problem of finding the function that has a
given point as fixpoint.



Re: Unhealthy Haskell babel

2020-12-10 Thread Immanuel Litzroth
I don't think org-babel is a good fit for compiled languages. If the
idea is to just take 1 snippet,
and "execute" that it means that to have a consistent whole you'd need
to put all the modules of
your program into that snippet (already impossible in Haskell, you can
have only 1 module per file),
compile that, run the resulting binary. Or org mode would have to have
some idea of what needs to
be retangled & rebuilt.
I think that using org-babel for compiled, multifile languages will
only work in very simple cases -- and
even then.. -- but will lead to problems very soon.
Immanuel

On Thu, Dec 10, 2020 at 4:21 AM Lawrence Bottorff  wrote:
>
> I'm looking into Haskell (latest ghci) again on org-mode. This
>
> #+begin_src haskell :results verbatim :exports both
> :set +m
> doubleSmallNumber x = if x > 100
>   then x
>   else x*2
> #+end_src
>
> works, but still the :set +m is necessary for it to see the whole. But this
>
> #+begin_src haskell :results verbatim :exports both
> :set +m
> factorial :: Int -> Int
> factorial 0 = 1
> factorial n = n * factorial (n - 1)
> #+end_src
>
> results in this on the REPL side:
>
> Prelude> :set +m
> factorial :: Int -> Int
> factorial 0 = 1
> factorial n = n * factorial (n - 1)
> "org-babel-haskell-eoe"
> Prelude>
> :26:1-23: error:
> • No instance for (Show (Int -> Int)) arising from a use of ‘print’
> (maybe you haven't applied a function to enough arguments?)
> • In a stmt of an interactive GHCi command: print it
> Prelude> Prelude> Prelude> "org-babel-haskell-eoe"
>
> which is the same behavior if I try to feed the program into the REPL one 
> line at a time, i.e.,
>
> Prelude> factorial :: Int -> Int
>
> :40:1-23: error:
> • No instance for (Show (Int -> Int)) arising from a use of ‘print’
> (maybe you haven't applied a function to enough arguments?)
> • In a stmt of an interactive GHCi command: print it
>
> So the :set +m trick (take multiple lines) doesn't help here. Obviously, 
> Haskell is not ready to be used with Babel. Can it be fixed? BTW, this does 
> work with the regular ghci REPL and haskell-mode. If it helps, Standard ML, 
> which has very similar syntax (it was Haskell's parent), works fine.
>
> LB



-- 
-- Researching the dual problem of finding the function that has a
given point as fixpoint.



Re: buggy plantuml function

2020-11-23 Thread Immanuel Litzroth
There is a solution in all source blocks that would have a problem because there
is a * at the beginning of a line. Just prepend it with ,.
So this works over here:
#+BEGIN_SRC plantuml :file test.png
@startmindmap
,* Debian
,** Ubuntu
,*** Linux Mint
,*** Kubuntu
,*** Lubuntu
,*** KDE Neon
,** LMDE
,** SolydXK
,** SteamOS
,** Raspbian with a very long name
,*** Raspmbc => OSMC
,*** Raspyfi => Volumio
@endmind
#+END_SRC

Of course I also had to change  org-babel-plantuml-make-body
 (defun org-babel-plantuml-make-body (body _)
   body)
to make that work with "C-c C-c".
Weren't there supposed to be maintainers for this stuff? Has no plantuml
maintainer been found?
Immanuel



On Mon, Nov 23, 2020 at 11:28 AM Heinz Tuechler  wrote:
>
> Immanuel Litzroth wrote/hat geschrieben on/am 15.11.2020 13:27:
> > (defun org-babel-plantuml-make-body (body params)
> >   "Return PlantUML input string.
> >
> > BODY is the content of the source block and PARAMS is a property list
> > of source block parameters.  This function relies on the
> > `org-babel-expand-body:generic' function to extract `:var' entries
> > from PARAMS and on the `org-babel-variable-assignments:plantuml'
> > function to convert variables to PlantUML assignments.
> >
> > If BODY does not contain @startXXX ... @endXXX clauses, @startuml
> > ... @enduml will be added."
> >   (let ((assignments (org-babel-variable-assignments:plantuml params)))
> > (if (string-prefix-p "@start" body t) assignments
> >   (format "@startuml\n%s\n@enduml"
> >   (org-babel-expand-body:generic body params assignments)
> >
> > expands to assignments if the body starts with @startmindmap?
> > Immanuel
> >
>
> Dear Immanuel,
>
> did you ever receive an answer to your post? I ask, because I am
> curious, if you were able to use mindmap in a #+BEGIN_SRC plantuml /
> #+END_SRC block? For me it was not possible with *, because they get
> interpreted as org headlines and break the SRC block.
>
> best regards,
>
> Heinz
>


-- 
-- Researching the dual problem of finding the function that has a
given point as fixpoint.



buggy plantuml function

2020-11-15 Thread Immanuel Litzroth
(defun org-babel-plantuml-make-body (body params)
  "Return PlantUML input string.

BODY is the content of the source block and PARAMS is a property list
of source block parameters.  This function relies on the
`org-babel-expand-body:generic' function to extract `:var' entries
from PARAMS and on the `org-babel-variable-assignments:plantuml'
function to convert variables to PlantUML assignments.

If BODY does not contain @startXXX ... @endXXX clauses, @startuml
... @enduml will be added."
  (let ((assignments (org-babel-variable-assignments:plantuml params)))
(if (string-prefix-p "@start" body t) assignments
  (format "@startuml\n%s\n@enduml"
  (org-babel-expand-body:generic body params assignments)

expands to assignments if the body starts with @startmindmap?
Immanuel
-- 
-- Researching the dual problem of finding the function that has a
given point as fixpoint.



Re: best practices query: non-emacs packages based on tangled source

2020-10-28 Thread Immanuel Litzroth
I think the org way of tangling just doesn't work well for compiled languages.
Here are some reasons:
- Not possible to tangle all code going to a specified file
- Not possible to add line directives without major surgery
- Not all language modes do the correct thing
- No way to prevent overwriting an unchanged file
- Special casing e.g. Don’t tangle to a file called ‘no’.
Specific gripe:
- :prologue and :epilogue are not honoured by all modes
>>>
#+ BEGIN_SRC emacs-lisp :prologue "hello" :epilogue "goodbye" :tangle ex1.el
(+ 1 2)
#+ END_SRC


#+ BEGIN_SRC haskell :tangle ex1.hs :prologue "hello" :epilogue "goodbye"
hey
#+ END_SRC

hey

#+HEADER: :tangle ex1.cpp
#+ BEGIN_SRC cpp :prologue "hello" :epilogue "goodbye"
main()
{}
#+ END_SRC

#+ BEGIN_SRC bash :tangle ex1.bash :prologue "hello" :epilogue "goodbye"
aha
#+ END_SRC
>>>

Based on the org machinery I've written a simple tangler which addresses some
of these shortcomings. It can add line directives to recursively expanded noweb
references -- and get that right. It can also take any action at the
end of tangling
like comparing your tangled file to the one on disk and not overwrite
if it's the same,
or just sending your tangled buffer to an interpreter not writing it
to file (remember that
error references point back to the .org file). Also it can tangle all
blocks going to the
same file. This has been tested for Haskell, C++ and elisp.
It's in a private repo on github because it's not ready for release
yet, but if someone
is interested I can give them access.
Immanuel

On Tue, Oct 27, 2020 at 11:30 PM Dr. Arne Babenhauserheide
 wrote:
>
>
> TRS-80  writes:
>
> > Therefore, any stuff I plan on releasing publicly, I do not do in
> > literate style (JMHO).  However if you are dead set on doing literate
> > paradigm, then maybe my experience is invalid for your use-case.
>
> My experience is that literate style works very well for tutorials, but
> whenever I developed a larger program within org-mode, I tangled it once
> I had to start debugging and then kept it as separate source.
>
> Once the code becomes complex, I want to stay in one programming
> language without outside features that also add extra complexity.
>
> That said, for simple code the additional freedom of multi-language
> programming in org-mode is awesome. I’m using that to create random
> roleplaying characters directly from random tables in org-mode, with
> those tables being the primary source (because the book is the most
> important product, not the code).
>
> Best wishes,
> Arne
> --
> Unpolitisch sein
> heißt politisch sein
> ohne es zu merken



-- 
-- Researching the dual problem of finding the function that has a
given point as fixpoint.



Re: [O] Bug: org-edit-src keeps splitting the window [9.2.5 (release_9.2.5-504-g3c24be @ /home/immanuel/.emacs.d/straight/build/org/)]

2019-09-02 Thread Immanuel Litzroth
You want me to do that and send a new patch or are you going
to do it after you apply the patch?
Regards,
Immanuel

On Mon, Sep 2, 2019 at 9:41 PM Nicolas Goaziou  wrote:
>
> Hello,
>
> immanuel  writes:
>
> > When org-edit-src-code is called with org-window-setup equal to
> > 'split-window-below or 'split-window-right it will keep splitting the
> > window if the mouse is clicked on the src block in the org buffer.
> > This patch tries to address that
>
> [...]
>
> > +(defun org-src-select-window-for-buffer (buffer split-fun)
>
> You should make it an internal function: `org-src--select-window-for-buffer'.
>
> > +  "Tries to select an existing window for buffer or splits the
> > window."
>
> You need to expound the docstring a bit, e.g.:
>
>   "Re-use an existing window or split the current window.
>   If BUFFER is current in a window, use it.  Otherwise, split the current
>   window, according to SPLIT-FUN, in order to display it.
>
> Also, I think this should be notified in ORG-NEWS file.
>
> Thank you!
>
> Regards,
>
> --
> Nicolas Goaziou



Re: [O] Bug: tangling with elisp as lang in a noweb reference doesn't work [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/local/share/emacs/26.2/lisp/org/)]

2019-08-31 Thread Immanuel Litzroth
No problem! I have some more coming up :-)
I've been looking at getting org-babel to add line directives for
languages that support it.
(c, c++, haskell...). It would make literate programming for these
kinds of languages much
better, and other people have been complaining e.g.
https://paulbatchelor.github.io/blog/posts/2018-09-21-org-babel-impressions.html

Unfortunately there is no easy way to hook this into org-babel now
without doing some rather
intrusive work.
1) The language specific expansions don't know the file or the line a
block comes from, and
noweb references have already been expanded.
2) The tangle-body-hook is useless since it runs in a temp buffer that
doesn't even have the major
mode set for the language you're tangling to.
3) The :comments mechanism is not strong enough to allow language
specific comments and it 's
different for noweb vs. normal block expansion.

Would there be interest in such a feature, if it doesn't change
current behaviour?
Immanuel

On Fri, Aug 30, 2019 at 11:37 PM Nicolas Goaziou  wrote:
>
> Hello,
>
> immanuel  writes:
>
> > #+NAME: this is a test
> > #+BEGIN_SRC elisp :tangle no
> >
> > (message \"aha\") #+END_SRC
> >
> > #+BEGIN_SRC elisp :noweb yes :comments noweb :tangle out.el
> > first
> > <>
> > second
> > #+END_SRC
> >
> > #+BEGIN_SRC elisp :tangle no
> > (progn
> > (org-babel-tangle)
> > (with-temp-buffer
> > (insert-file-contents "out.el")
> > (buffer-string)
> > #+END_SRC
> >
> >
> > Doesn't work. The reason is that the function
> > org-babel-expand-noweb-references uses
> >
> > #+BEGIN_SRC emacs-lisp
> > (c-wrap (lambda (text)
> > (with-temp-buffer
> > (funcall (intern (concat lang "-mode")))
> > ...
> > #+END_SRC
>
> Fixed! Thank you for the report and the analysis.
>
> Regards,
>
> --
> Nicolas Goaziou



[O] Bug: org-babel-tangle-clean seems buggy [9.2.5 (release_9.2.5-504-g3c24be @ /home/immanuel/.emacs.d/straight/build/org/)]

2019-08-31 Thread immanuel


Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

 https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.


When running 'org-babel-tangle-clean on this buffer:

>>

[[file:foo][something]]

<>
[[file:bar][something else]]

<>

>>

I get

>>
<>
>>


Given the code of that function -- especially the (while (or -- it's highly
unlikely that that code does what the docstring says it does. I'm also not
clear on why you'd want to remove noweb references.

#+BEGIN_SRC emacs-lisp
(defun org-babel-tangle-clean ()
  "Remove comments inserted by `org-babel-tangle'.
Call this function inside of a source-code file generated by
`org-babel-tangle' to remove all comments inserted automatically
by `org-babel-tangle'.  Warning, this comment removes any lines
containing constructs which resemble Org file links or noweb
references."
  (interactive)
  (goto-char (point-min))
  (while (or (re-search-forward "\\[\\[file:.*\\]\\[.*\\]\\]" nil t)
 (re-search-forward (org-babel-noweb-wrap) nil t))
(delete-region (save-excursion (beginning-of-line 1) (point))
   (save-excursion (end-of-line 1) (forward-char 1) (point)
#END_SRC

Immanuel

Emacs  : GNU Emacs 26.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2019-07-17
Package: Org mode version 9.2.5 (release_9.2.5-504-g3c24be @ 
/home/immanuel/.emacs.d/straight/build/org/)

current state:
==
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer 
org-src-mode-configure-edit-buffer)
 org-link-shell-confirm-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-html-format-inlinetask-function 
'org-html-format-inlinetask-default-function
 org-odt-format-headline-function 'org-odt-format-headline-default-function
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-mode-hook '((closure
  (org-agenda-skip-regexp org-table1-hline-regexp 
org-table-tab-recognizes-table\.el org-table-dataline-regexp 
org-table-any-border-regexp
   org-agenda-restriction-lock-overlay 
org-agenda-overriding-restriction org-agenda-diary-file 
org-complex-heading-regexp calendar-mode-map t)
  nil (setq imenu-create-index-function (quote 
org-imenu-get-tree)))
 (closure
  (org--rds reftex-docstruct-symbol 
org-element-greater-elements org-clock-history org-agenda-current-date 
org-with-time org-defdecode org-def org-read-date-inactive
   org-ans2 org-ans1 org-columns-current-fmt-compiled 
org-clock-current-task org-clock-effort org-agenda-skip-function 
org-agenda-skip-comment-trees
   org-agenda-archives-mode org-end-time-was-given 
org-time-was-given org-log-note-extra org-log-note-purpose org-log-post-message 
org-last-inserted-timestamp
   org-last-changed-timestamp org-entry-property-inherited-from 
org-blocked-by-checkboxes org-state org-agenda-headline-snapshot-before-repeat
   org-capture-last-stored-marker org-agenda-start-on-weekday 
org-agenda-buffer-tmp-name org-priority-regexp org-mode-abbrev-table 
org-mode-syntax-table
   buffer-face-mode-face org-tbl-menu org-org-menu 
org-struct-menu org-entities org-last-state org-id-track-globally 
org-clock-start-time texmathp-why remember-data-file
   org-agenda-tags-todo-honor-ignore-options 
iswitchb-temp-buflist align-mode-rules-list org-emphasis-alist 
org-emphasis-regexp-components org-export-registered-backends
   org-modules org-babel-load-languages 
org-indent-indentation-per-level org-element-paragraph-separate ffap-url-regexp 
org-inlinetask-min-level t)
  nil (add-hook (quote change-major-mode-hook) (quote 
org-show-all) (quote append) (quote local)))
 (closure
  (org-src-window-setup *this* 
org-babel-confirm-evaluate-answer-no org-src-preserve-indentation 
org-src-lang-modes org-link-file-path-type org-edit-src-content-indentation
   org-babel-library-of-babel t)
  nil (add-hook (quote change-major-mode-hook) (quote 
org-babel-show-result-all) (quote append) (quote local)))
 org-babel-result-hide-spec org-babel-hide-all-hashes 
auto-fill-mode)
 org-odt-format-drawer-function '(closure
  (hfy-user-sheet-assoc hfy-html-quote-regex 
hfy-html-quote-map hfy-face-to-css hfy-begin-span-handler hfy-end-span-handler 
archive-zip-extract
   nxml-auto-insert-xml-declaration-flag t)
  (_name contents) contents)
 org-arch

[O] Bug: org-edit-src keeps splitting the window [9.2.5 (release_9.2.5-504-g3c24be @ /home/immanuel/.emacs.d/straight/build/org/)]

2019-08-30 Thread immanuel

Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

 https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.

When org-edit-src-code is called with org-window-setup equal to
'split-window-below or 'split-window-right it will keep splitting the
window if the mouse is clicked on the src block in the org buffer.
This patch tries to address that

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 9134d5b5d..c7e201687 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -786,6 +786,13 @@ Raise an error when current buffer is not a source editing buffer."
   (unless (org-src-edit-buffer-p) (error "Not in a source buffer"))
   org-src--source-type)
 
+(defun org-src-select-window-for-buffer (buffer split-fun)
+  "Tries to select an existing window for buffer or splits the window."
+  (select-window
+   (or
+(display-buffer-reuse-window buffer '())
+(funcall split-fun
+
 (defun org-src-switch-to-buffer (buffer context)
   (pcase org-src-window-setup
 (`current-window (pop-to-buffer-same-window buffer))
@@ -794,12 +801,12 @@ Raise an error when current buffer is not a source editing buffer."
 (`split-window-below
  (if (eq context 'exit)
 	 (delete-window)
-   (select-window (split-window-vertically)))
+   (org-src-select-window-for-buffer buffer #'split-window-vertically))
  (pop-to-buffer-same-window buffer))
 (`split-window-right
  (if (eq context 'exit)
 	 (delete-window)
-   (select-window (split-window-horizontally)))
+   (org-src-select-window-for-buffer buffer #'split-window-horizontally))
  (pop-to-buffer-same-window buffer))
 (`other-frame
  (pcase context


Emacs  : GNU Emacs 26.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2019-07-17
Package: Org mode version 9.2.5 (release_9.2.5-504-g3c24be @ 
/home/immanuel/.emacs.d/straight/build/org/)

current state:
==
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer 
org-src-mode-configure-edit-buffer)
 org-link-shell-confirm-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-reveal-start-hook '(org-decrypt-entry)
 org-mode-hook '(#[0 "\301\211\207" [imenu-create-index-function 
org-imenu-get-tree] 2] #[0 "\300\301\302\303\304$\207" [add-hook 
change-major-mode-hook org-show-all append local] 5]
 #[0 "\300\301\302\303\304$\207" [add-hook 
change-major-mode-hook org-babel-show-result-all append local] 5] 
org-babel-result-hide-spec org-babel-hide-all-hashes
 auto-fill-mode)
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn 
ENTRY)"]
 org-babel-pre-tangle-hook '(save-buffer)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
org-babel-header-arg-expand)
 org-babel-load-languages '((emacs-lisp . t) (C) (python . t) (shell . t) 
(plantuml . t))
 org-src-preserve-indentation t
 org-occur-hook '(org-first-headline-recenter)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-show-empty-lines 
org-optimize-window-after-visibility-change)
 org-speed-command-hook '(org-speed-command-activate 
org-babel-speed-command-activate)
 org-babel-tangle-lang-exts '(("D" . "d") ("C++" . "cpp") ("abc" . "abc") 
("asymptote" . "asy") ("awk" . "awk") ("clojure" . "clj") ("fortran" . "F90") 
("groovy" . "groovy")
  ("haskell" . "hs") ("io" . "io") ("java" . 
"java") ("latex" . "tex") ("LilyPond" . "ly") ("lisp" . "lisp") ("lua" . "lua") 
("maxima" . "max") ("ocaml" . "ml")
  ("perl" . "pl") ("picolisp" . "l") ("processing" 
. "pde") ("ruby" . "rb") ("sed" . "sed") ("vala" . "vala") ("python" . "py") 
("emacs-lisp" . "el")
  ("elisp" . "el"))
 org-confirm-shell-link-function 'yes-or-no-p
 org-link-parameters '(("attachment" :follow org-attach-open-link :export 
org-attach-export-link :complete org-attach-complete-link)

[O] Bug: tangling with elisp as lang in a noweb reference doesn't work [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/local/share/emacs/26.2/lisp/org/)]

2019-08-25 Thread immanuel


Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

 https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.


#+NAME: this is a test
#+BEGIN_SRC elisp :tangle no
(message \"aha\")
#+END_SRC

#+BEGIN_SRC elisp :noweb yes :comments noweb :tangle out.el
first
<>
second
#+END_SRC

#+BEGIN_SRC elisp :tangle no 
(progn
(org-babel-tangle)
(with-temp-buffer
(insert-file-contents "out.el")
(buffer-string)
#+END_SRC

Doesn't work. The reason is that the function
org-babel-expand-noweb-references uses 
#+BEGIN_SRC emacs-lisp
(c-wrap (lambda (text)
(with-temp-buffer
(funcall (intern (concat lang "-mode")))
...
#+END_SRC

Instead of the possibly more correct turning on of the major mode that
is found in org-babel-tangle:
#+BEGIN_SRC emacs-lisp
(lang-f (intern
 (concat
  (or (and (cdr (assoc lang org-src-lang-modes))
   (symbol-name
(cdr (assoc lang org-src-lang-modes
  lang)
  "-mode")))
#+END_SRC


Immanuel

Emacs  : GNU Emacs 26.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2019-07-17
Package: Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ 
/usr/local/share/emacs/26.2/lisp/org/)

current state:
==
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer 
org-src-mode-configure-edit-buffer)
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-latex-listings t
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-html-format-inlinetask-function 
'org-html-format-inlinetask-default-function
 org-odt-format-headline-function 'org-odt-format-headline-default-function
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-reveal-start-hook '(org-decrypt-entry)
 org-plantuml-jar-path "/home/immanuel/bin/plantuml.jar"
 org-mode-hook '(#[0 "\300\301\302\303\304$\207" [add-hook 
change-major-mode-hook org-show-block-all append local] 5]
 #[0 "\300\301\302\303\304$\207" [add-hook 
change-major-mode-hook org-babel-show-result-all append local] 5]
 org-babel-result-hide-spec org-babel-hide-all-hashes 
auto-fill-mode)
 org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn 
ENTRY)"]
 org-from-is-user-regexp "|\\"
 org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
 org-babel-pre-tangle-hook '(save-buffer)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
org-babel-header-arg-expand)
 org-babel-load-languages '((emacs-lisp . t) (C . t) (python . t) (lilypond . 
t) (shell . t) (plantuml . t))
 org-log-done 'time
 org-ascii-format-drawer-function #[771 "\207" [] 4 "\n\n(fn NAME CONTENTS 
WIDTH)"]
 org-babel-python-command "ipython --simple-prompt -i --pylab"
 org-src-preserve-indentation t
 org-occur-hook '(org-first-headline-recenter)
 org-structure-template-alist '(("r" "#+BEGIN_SRC rust\n?\n#+END_SRC") ("p" 
"#+BEGIN_SRC plantuml\n?\n#+END_SRC")
("ha" "#+BEGIN_SRC haskell\n?\n#+END_SRC")
("ly"
 "#+LaTeX: \\linebreak\n#+ATTR_LaTeX: 
width=17cm\n#+BEGIN_SRC lilypond :file ?.png :noweb yes\n#+END_SRC")
("bnf" "#+BEGIN_SRC abnf\n?\n#+END_SRC")
("cpp"
 "#+NAME:\n#+HEADER: :tangle\n#+HEADER: :main 
no\n#+HEADER: :noeval\n#+HEADER: :noweb yes\n#+BEGIN_SRC cpp\n?\n#+END_SRC")
("yp" "#+END_SRC\n?\n#+BEGIN_SRC python :noweb 
yes")
("py" "#+BEGIN_SRC python :noweb 
yes\n?\n#+END_SRC") ("ab" "#+END_SRC\n#+BEGIN_SRC bash")
("ba" "#+BEGIN_SRC bash?\n#+END_SRC") ("le" 
"#+END_SRC\n#+BEGIN_SRC emacs-lisp?")
("el" "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC") 
("s" "#+BEGIN_SRC ?\n\n#+END_SRC")
("e" "#+BEGIN_EXAMPLE\n?\n#+END_EXAMPLE") 

[O] Bug: org-babel-tangle-comment-links does not honor org-babel-tangle-uncomment-comments in noweb comments [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/local/share/emacs/26.2/lisp/org/)]

2019-08-24 Thread immanuel


Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

 https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.


Try the following code;
#+NAME: start
#+BEGIN_SRC emacs-lisp :tangle no
(message "start")
#+END_SRC

#+NAME: end
#+BEGIN_SRC emacs-lisp :tangle no
(message "end")
#+END_SRC

#+BEGIN_SRC emacs-lisp :tangle output.el :comments noweb :noweb yes
start
<>
end
<>
#+END_SRC

#+BEGIN_SRC emacs-lisp :tangle no
(let ((org-babel-tangle-comment-format-beg "start %start-line\n")
  (org-babel-tangle-comment-format-end "end %start-line\n")
  (org-babel-tangle-uncomment-comments t))
  (org-babel-tangle-file (buffer-file-name))
  (with-temp-buffer 
  (insert-file-contents "output.el")
  (buffer-string)))
#+END_SRC

#+RESULTS:
#+begin_example
start 71
start
;; start 285
(message "start")
;; end 285
;; start 1256
(message "start")
;; end 1256
end
;; start 360
(message "end")
;; end 360
;; start 1331
(message "end")
;; end 1331
end 71
#+end_example

You see the noweb comments are commented out. The reason is this cl-wrap
definition in org-babel-expand-noweb-references.

#+BEGIN_SRC emacs-lisp
(let ..
   (c-wrap (lambda (text)
   (with-temp-buffer
 (funcall (intern (concat lang "-mode")))
 (comment-region (point) (progn (insert text) (point)))
 (org-trim (buffer-string))
#+END_SRC



Emacs  : GNU Emacs 26.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2019-07-17
Package: Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ 
/usr/local/share/emacs/26.2/lisp/org/)

current state:
==
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer 
org-src-mode-configure-edit-buffer)
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-latex-listings t
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-html-format-inlinetask-function 
'org-html-format-inlinetask-default-function
 org-odt-format-headline-function 'org-odt-format-headline-default-function
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-plantuml-jar-path "/home/immanuel/bin/plantuml.jar"
 org-mode-hook '(#[0 "\300\301\302\303\304$\207" [add-hook 
change-major-mode-hook org-show-block-all append local] 5]
 #[0 "\300\301\302\303\304$\207" [add-hook 
change-major-mode-hook org-babel-show-result-all append local] 5]
 org-babel-result-hide-spec org-babel-hide-all-hashes 
auto-fill-mode)
 org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn 
ENTRY)"]
 org-from-is-user-regexp "|\\"
 org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
 org-babel-pre-tangle-hook '(save-buffer)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
org-babel-header-arg-expand)
 org-babel-load-languages '((emacs-lisp . t) (C . t) (python . t) (lilypond . 
t) (shell . t) (plantuml . t))
 org-log-done 'time
 org-ascii-format-drawer-function #[771 "\207" [] 4 "\n\n(fn NAME CONTENTS 
WIDTH)"]
 org-babel-python-command "ipython --simple-prompt -i --pylab"
 org-src-preserve-indentation t
 org-occur-hook '(org-first-headline-recenter)
 org-structure-template-alist '(("r" "#+BEGIN_SRC rust\n?\n#+END_SRC") ("p" 
"#+BEGIN_SRC plantuml\n?\n#+END_SRC")
("ha" "#+BEGIN_SRC haskell\n?\n#+END_SRC")
("ly"
 "#+LaTeX: \\linebreak\n#+ATTR_LaTeX: 
width=17cm\n#+BEGIN_SRC lilypond :file ?.png :noweb yes\n#+END_SRC")
("bnf" "#+BEGIN_SRC abnf\n?\n#+END_SRC")
("cpp"
 "#+NAME:\n#+HEADER: :tangle\n#+HEADER: :main 
no\n#+HEADER: :noeval\n#+HEADER: :noweb yes\n#+BEGIN_SRC cpp\n?\n#+END_SRC")
("yp" "#+END_SRC\n?\n#+BEGIN_SRC python :noweb 
yes")
("py" "#+BEGIN_SRC python :noweb 
yes\n?\n#+END_SRC") ("ab" "#+END_SRC\n#+BEGIN_SRC bash")
   

[O] Bug: org-babel-tangle-comment-links does not start-line but start-point. [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/local/share/emacs/26.2/lisp/org/)]

2019-08-24 Thread immanuel


Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

 https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.

Try this in a buffer (results are also here for quick reference):

#+NAME: start
#+BEGIN_SRC emacs-lisp :tangle no
(message "start")
#+END_SRC

#+NAME: end
#+BEGIN_SRC emacs-lisp :tangle no
(message "end")
#+END_SRC

#+BEGIN_SRC emacs-lisp :tangle output.el :comments noweb :noweb yes
(progn
<>
<>
)
#+END_SRC

#+BEGIN_SRC emacs-lisp :tangle no
(let ((org-babel-tangle-comment-format-beg "start %start-line")
  (org-babel-tangle-comment-format-end "end %start-line"))
  (org-babel-tangle-file (buffer-file-name))
  (with-temp-buffer 
  (insert-file-contents "output.el")
  (buffer-string)))
#+END_SRC

#+RESULTS:
#+begin_example
;; start 12
(progn
;; start 15
(message "start")
;; end 15
;; start 90
(message "end")
;; end 90
)
;; end 12
#+end_example


The reason is that the function org-babel-tangle-comment-links uses
#+BEGIN_SRC emacs-lisp :tangle no
("start-line" . ,(number-to-string
 (org-babel-where-is-src-block-head)
#+END_SRC

Emacs  : GNU Emacs 26.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2019-07-17
Package: Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ 
/usr/local/share/emacs/26.2/lisp/org/)

current state:
==
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer 
org-src-mode-configure-edit-buffer)
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-latex-listings t
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-html-format-inlinetask-function 
'org-html-format-inlinetask-default-function
 org-odt-format-headline-function 'org-odt-format-headline-default-function
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-plantuml-jar-path "/home/immanuel/bin/plantuml.jar"
 org-mode-hook '(#[0 "\300\301\302\303\304$\207" [add-hook 
change-major-mode-hook org-show-block-all append local] 5]
 #[0 "\300\301\302\303\304$\207" [add-hook 
change-major-mode-hook org-babel-show-result-all append local] 5]
 org-babel-result-hide-spec org-babel-hide-all-hashes 
auto-fill-mode)
 org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn 
ENTRY)"]
 org-from-is-user-regexp "|\\"
 org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
 org-babel-pre-tangle-hook '(save-buffer)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
org-babel-header-arg-expand)
 org-babel-load-languages '((emacs-lisp . t) (C . t) (python . t) (lilypond . 
t) (shell . t) (plantuml . t))
 org-log-done 'time
 org-ascii-format-drawer-function #[771 "\207" [] 4 "\n\n(fn NAME CONTENTS 
WIDTH)"]
 org-babel-python-command "ipython --simple-prompt -i --pylab"
 org-src-preserve-indentation t
 org-occur-hook '(org-first-headline-recenter)
 org-structure-template-alist '(("r" "#+BEGIN_SRC rust\n?\n#+END_SRC") ("p" 
"#+BEGIN_SRC plantuml\n?\n#+END_SRC")
("ha" "#+BEGIN_SRC haskell\n?\n#+END_SRC")
("ly"
 "#+LaTeX: \\linebreak\n#+ATTR_LaTeX: 
width=17cm\n#+BEGIN_SRC lilypond :file ?.png :noweb yes\n#+END_SRC")
("bnf" "#+BEGIN_SRC abnf\n?\n#+END_SRC")
("cpp"
 "#+NAME:\n#+HEADER: :tangle\n#+HEADER: :main 
no\n#+HEADER: :noeval\n#+HEADER: :noweb yes\n#+BEGIN_SRC cpp\n?\n#+END_SRC")
("yp" "#+END_SRC\n?\n#+BEGIN_SRC python :noweb 
yes")
("py" "#+BEGIN_SRC python :noweb 
yes\n?\n#+END_SRC") ("ab" "#+END_SRC\n#+BEGIN_SRC bash")
("ba" "#+BEGIN_SRC bash?\n#+END_SRC") ("le" 
"#+END_SRC\n#+BEGIN_SRC emacs-lisp?")
("el" "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC") 
("s" "#+BEGIN_SRC ?\n\n#+END_SRC")

[O] Editing elisp code block inserts spurious , before *

2019-08-21 Thread Immanuel Litzroth
Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

 https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.


When editing this block with C- '

+BEGIN_SRC emacs-lisp :lexical t :tangle elisp.el
  (defvar *a-var* "blah")
  (defun v()
(interactive)
*a-var*)
#+END_SRC

On return it adds a , before the *a-var*

#+BEGIN_SRC emacs-lisp :lexical t :tangle elisp.el
(defvar *a-var* "blah")
(defun v()
  (interactive)
  ,*a-var*)
#+END_SRC

This happens in a clean emacs started the -q flag, so it should not have
anything to do with my configuration.
Immanuel

Emacs  : GNU Emacs 26.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2019-07-17
Package: Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @
/usr/local/share/emacs/26.2/lisp/org/)

current state:
==
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
org-src-mode-configure-edit-buffer)
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-latex-listings t
 org-pomodoro-long-break-length 30
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-html-format-inlinetask-function
'org-html-format-inlinetask-default-function
 org-odt-format-headline-function 'org-odt-format-headline-default-function
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-plantuml-jar-path "/home/immanuel/bin/plantuml.jar"
 org-mode-hook '(#[0 "\300\301\302\303\304$\207" [add-hook
change-major-mode-hook org-show-block-all append local] 5]
 #[0 "\300\301\302\303\304$\207" [add-hook
change-major-mode-hook org-babel-show-result-all append local] 5]
org-babel-result-hide-spec org-babel-hide-all-hashes
 auto-fill-mode)
 org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3
"\n\n(fn ENTRY)"]
 org-from-is-user-regexp "|\\"
 org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
 org-babel-pre-tangle-hook '(save-buffer)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe
org-babel-header-arg-expand)
 org-babel-load-languages '((emacs-lisp . t) (C . t) (python . t) (lilypond
. t) (shell . t) (plantuml . t))
 org-log-done 'time
 org-ascii-format-drawer-function #[771 "\207" [] 4 "\n\n(fn NAME CONTENTS
WIDTH)"]
 org-babel-python-command "ipython --simple-prompt -i --pylab"
 org-src-preserve-indentation t
 org-occur-hook '(org-first-headline-recenter)
 org-pomodoro-ticking-sound
"/home/immanuel/.emacs.d/straight/build/org-pomodoro/resources/tick.wav"
 org-structure-template-alist '(("r" "#+BEGIN_SRC rust\n?\n#+END_SRC") ("p"
"#+BEGIN_SRC plantuml\n?\n#+END_SRC") ("ha" "#+BEGIN_SRC
haskell\n?\n#+END_SRC")
("ly" "#+LaTeX: \\linebreak\n#+ATTR_LaTeX:
width=17cm\n#+BEGIN_SRC lilypond :file ?.png :noweb yes\n#+END_SRC") ("bnf"
"#+BEGIN_SRC abnf\n?\n#+END_SRC")
("cpp" "#+NAME:\n#+HEADER:
:tangle\n#+HEADER: :main no\n#+HEADER: :noeval\n#+HEADER: :noweb
yes\n#+BEGIN_SRC cpp\n?\n#+END_SRC")
("yp" "#+END_SRC\n?\n#+BEGIN_SRC python
:noweb yes") ("py" "#+BEGIN_SRC python :noweb yes\n?\n#+END_SRC") ("ab"
"#+END_SRC\n#+BEGIN_SRC bash")
("ba" "#+BEGIN_SRC bash?\n#+END_SRC") ("le"
"#+END_SRC\n#+BEGIN_SRC emacs-lisp?") ("el" "#+BEGIN_SRC
emacs-lisp\n?\n#+END_SRC")
("s" "#+BEGIN_SRC ?\n\n#+END_SRC") ("e"
"#+BEGIN_EXAMPLE\n?\n#+END_EXAMPLE") ("q" "#+BEGIN_QUOTE\n?\n#+END_QUOTE")
("v" "#+BEGIN_VERSE\n?\n#+END_VERSE")
("V" "#+BEGIN_VERBATIM\n?\n#+END_VERBATIM")
("c" "#+BEGIN_CENTER\n?\n#+END_CENTER") ("C"
"#+BEGIN_COMMENT\n?\n#+END_COMMENT")
("l" "#+BEGIN_EXPORT
latex\n?\n#+END_EXPORT") ("L" "#+LaTeX: ") ("h" "#+BEGIN_EXPORT
html\n?\n#+END_EXPORT") ("H" "#+HTML: ")
   

[O] Bug: :lexical header argument not handled when tangling [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/local/share/emacs/26.2/lisp/org/)]

2019-08-21 Thread immanuel


Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

 https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.



#+BEGIN_SRC emacs-lisp :lexical t :tangle elisp.el
(defun lex-p ()
  "Return t if lexical binding is in effect."
  (interactive)
  (let (lex
_lex-p)
(let ((lex t))
  (setq _lex-p
(lambda ()
  lex)))
(if (funcall _lex-p)
(message "lexical binding")
  (message "no lexical binding"

(lex-p)
#+END_SRC

When evaluating this code block with C-c C-c I get lexical binding.
When tangling it or with org-babel-load-file I get no lexical binding.
Immanuel

Emacs  : GNU Emacs 26.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2019-07-17
Package: Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ 
/usr/local/share/emacs/26.2/lisp/org/)

current state:
==
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer 
org-src-mode-configure-edit-buffer)
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-latex-listings t
 org-pomodoro-long-break-length 30
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-html-format-inlinetask-function 
'org-html-format-inlinetask-default-function
 org-odt-format-headline-function 'org-odt-format-headline-default-function
 org-babel-tangle-body-hook '(il-org-babel-tangle-body-hook)
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-plantuml-jar-path "/home/immanuel/bin/plantuml.jar"
 org-mode-hook '(#[0 "\300\301\302\303\304$\207" [add-hook 
change-major-mode-hook org-show-block-all append local] 5]
 #[0 "\300\301\302\303\304$\207" [add-hook 
change-major-mode-hook org-babel-show-result-all append local] 5] 
org-babel-result-hide-spec org-babel-hide-all-hashes
 auto-fill-mode)
 org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn 
ENTRY)"]
 org-from-is-user-regexp "|\\"
 org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
 org-babel-pre-tangle-hook '(save-buffer)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
org-babel-header-arg-expand)
 org-babel-load-languages '((emacs-lisp . t) (C . t) (python . t) (lilypond . 
t) (shell . t) (plantuml . t))
 org-log-done 'time
 org-ascii-format-drawer-function #[771 "\207" [] 4 "\n\n(fn NAME CONTENTS 
WIDTH)"]
 org-babel-python-command "ipython --simple-prompt -i --pylab"
 org-src-preserve-indentation t
 org-occur-hook '(org-first-headline-recenter)
 org-pomodoro-ticking-sound 
"/home/immanuel/.emacs.d/straight/build/org-pomodoro/resources/tick.wav"
 org-structure-template-alist '(("r" "#+BEGIN_SRC rust\n?\n#+END_SRC") ("p" 
"#+BEGIN_SRC plantuml\n?\n#+END_SRC") ("ha" "#+BEGIN_SRC haskell\n?\n#+END_SRC")
("ly" "#+LaTeX: \\linebreak\n#+ATTR_LaTeX: 
width=17cm\n#+BEGIN_SRC lilypond :file ?.png :noweb yes\n#+END_SRC") ("bnf" 
"#+BEGIN_SRC abnf\n?\n#+END_SRC")
("cpp" "#+header: :tangle\n#+header: :main 
no\n#+header: :noeval\n#+header: :noweb yes\n#+BEGIN_SRC cpp\n?\n#+END_SRC")
("yp" "#+END_SRC\n?\n#+BEGIN_SRC python :noweb 
yes") ("py" "#+BEGIN_SRC python :noweb yes\n?\n#+END_SRC") ("ab" 
"#+END_SRC\n#+BEGIN_SRC bash")
("ba" "#+BEGIN_SRC bash?\n#+END_SRC") ("le" 
"#+END_SRC\n#+BEGIN_SRC emacs-lisp?") ("el" "#+BEGIN_SRC 
emacs-lisp\n?\n#+END_SRC")
("s" "#+BEGIN_SRC ?\n\n#+END_SRC") ("e" 
"#+BEGIN_EXAMPLE\n?\n#+END_EXAMPLE") ("q" "#+BEGIN_QUOTE\n?\n#+END_QUOTE") ("v" 
"#+BEGIN_VERSE\n?\n#+END_VERSE")
("V" "#+BEGIN_VERBATIM\n?\n#+END_VERBATIM") 
("c" "#+BEGIN_CENTER\n?\n#+END_CENTER") ("C" 
"#+BEGIN_COMMENT\n?\n#+END_COMMENT")
("l" "#+BEGIN_EXPORT latex\n?\n#+END_EXPORT") 
("L&