Re: Can you automatically noweb include?

2020-08-07 Thread Tom Gillespie
After a bit of investigation, it seems that wallyqs implementation of
ob-racket does not treat/manage :prologue arguments correctly, which
is worrying because I would assume that the semantics for how prologue
works should not be something that could be accidentally broken by
ob-* implementations (but that is a separate issue). More relevant to
this thread is that python the prologue works as others have reported,
but if you include a noweb reference in the prologue it does not get
expanded. It is quite possible that this should be considered a bug
since it means that prologues are added only after the main block is
expanded. This seems incorrect, and I suspect that it is another bug
related to the one fixed in df5a83637518ad9aa586d49884a6271f11afc592
(discussion here
https://orgmode.org/list/ca+g3_pni3umvbiwgbdkuc3c6vjt1t1j-rkh43lrqybr+4ns...@mail.gmail.com/).
The fact that prologue is not expanded means that you can modify what
code is run by putting it in a prologue and org mode will be none-the
wiser. The sha1 changes if you set :cache yes, which means that
something in the execution code is doing something different than in
the block hashing code. Further investigation required.

* Use the code
:PROPERTIES:
:header-args:python: :prologue "<>"
:END:

#+name: python-helper
#+begin_src python
asdf = lambda : 'result'
#+end_src

#+begin_src python :noweb yes
return asdf()
#+end_src

On Fri, Aug 7, 2020 at 9:20 PM Tom Gillespie  wrote:
>
> Hah, this is what I get for not reading carefully enough. I wonder if
> it is possible to stick <> in the prologue and have it
> expand.
>
> On Fri, Aug 7, 2020 at 9:18 PM Tom Gillespie  wrote:
> >
> > I don't see a direct answer to the original question in the thread, so
> > here is an example of how I do it taken from
> > https://raw.githubusercontent.com/SciCrunch/sparc-curation/master/docs/developer-guide.org.
> > You can ctrl-f for racket-graph-helper to see the relevant blocks. A
> > reduced version is below. Recall that I use
> > https://github.com/wallyqs/ob-racket. I use this pattern all over the
> > place in my org blocks. Best,
> > Tom
> >
> > * Use the code
> > :cache yes"
> > #+begin_src racket :lang racket/base :noweb yes
> > <>
> > (helper-function "this should work")
> > #+end_src
> >
> > #+RESULTS:
> > : this should work hello world
> >
> >
> > * Define the helpers
> > #+name: racket-helper
> > #+header: :prologue "#lang racket/base"
> > #+begin_src racket :lang racket/base
> > (define (helper-function arg)
> >   (string-append arg " hello world"))
> > #+end_src



Re: Can you automatically noweb include?

2020-08-07 Thread Tom Gillespie
Hah, this is what I get for not reading carefully enough. I wonder if
it is possible to stick <> in the prologue and have it
expand.

On Fri, Aug 7, 2020 at 9:18 PM Tom Gillespie  wrote:
>
> I don't see a direct answer to the original question in the thread, so
> here is an example of how I do it taken from
> https://raw.githubusercontent.com/SciCrunch/sparc-curation/master/docs/developer-guide.org.
> You can ctrl-f for racket-graph-helper to see the relevant blocks. A
> reduced version is below. Recall that I use
> https://github.com/wallyqs/ob-racket. I use this pattern all over the
> place in my org blocks. Best,
> Tom
>
> * Use the code
> :cache yes"
> #+begin_src racket :lang racket/base :noweb yes
> <>
> (helper-function "this should work")
> #+end_src
>
> #+RESULTS:
> : this should work hello world
>
>
> * Define the helpers
> #+name: racket-helper
> #+header: :prologue "#lang racket/base"
> #+begin_src racket :lang racket/base
> (define (helper-function arg)
>   (string-append arg " hello world"))
> #+end_src



Re: Can you automatically noweb include?

2020-08-07 Thread Tom Gillespie
I don't see a direct answer to the original question in the thread, so
here is an example of how I do it taken from
https://raw.githubusercontent.com/SciCrunch/sparc-curation/master/docs/developer-guide.org.
You can ctrl-f for racket-graph-helper to see the relevant blocks. A
reduced version is below. Recall that I use
https://github.com/wallyqs/ob-racket. I use this pattern all over the
place in my org blocks. Best,
Tom

* Use the code
:cache yes"
#+begin_src racket :lang racket/base :noweb yes
<>
(helper-function "this should work")
#+end_src

#+RESULTS:
: this should work hello world


* Define the helpers
#+name: racket-helper
#+header: :prologue "#lang racket/base"
#+begin_src racket :lang racket/base
(define (helper-function arg)
  (string-append arg " hello world"))
#+end_src



Re: Can you automatically noweb include?

2020-08-07 Thread George Mauer
Is there a straightforward way to have a multiline prologue? Or maybe use
the body of named block as prologue?

On Fri, Aug 7, 2020 at 5:02 PM William McCoy  wrote:

> Yes, of course, that was it!  I ran into that issue a few months ago and
> then I forgot about again!
>
> Thanks both for your help!
>
> Bill
>
> On 8/7/20 5:25 PM, Berry, Charles wrote:
> > Good catch. Also it works if you put the property block at the very
> beginning of the file.
> >
> > This sometimes helps:
> >
> > M-x org-lint RET
> >
> > which in this case reports "Incorrect contents for PROPERTIES drawer"
> >
> > which is a bit cryptic IMO, but does point to any issue with the
> property.
> >
> > HTH,
> >
> > Chuck
> >
> >> On Aug 7, 2020, at 2:18 PM, Thomas S. Dye  wrote:
> >>
> >> It works here if you remove the blank line between the headline and the
> PROPERTIES block.
> >>
> >> William McCoy writes:
> >>
> >>> Chuck,
> >>>
> >>> Thanks very much for your response.  I didn't know about those
> options.  When I
> >>> use C-c C-v C-i, I get the following:
> >>>
> >>> Lang: python
> >>> Properties:
> >>> :header-argsnil
> >>> :header-args:python nil
> >>> Header Arguments:
> >>> :cache  no
> >>> :exportscode
> >>> :hlines no
> >>> :noweb  no
> >>> :resultsoutput replace
> >>> :sessionnone
> >>> :tangle no
> >>>
> >>> And C-c C-v C-v, shows that the import statements in the header do not
> get
> >>> expanded into the code block.
> >>>
> >>> So I am obviously doing something wrong.  There appear to be no typos
> or
> >>> misspellings and the org file containing the coded is exactly this:
> >>>
> >>> * Test of prologue header
> >>>
> >>> :PROPERTIES:
> >>> :header-args:python+: :prologue "import numpy as np; import os"
> >>> :END:
> >>>
> >>> #+BEGIN_SRC python :results output
> >>> print(np.__version__)
> >>> #+END_SRC
> >>>
> >>> #+RESULTS:
> >>>
> >>>
> >>> My init file has no org babel header arguments defined.
> >>>
> >>> I am using C-c C-v C-b or C-c C-v C-s to evaluate and I get
> >>>
> >>> "Code block produced no output." in the mini-buffer.
> >>>
> >>>
> >>> If I use C-c C-c directly on the code block itself I get:
> >>>
> >>> Traceback (most recent call last):
> >>>   File "", line 1, in 
> >>> NameError: name 'np' is not defined
> >>>
> >>> Is there something else I need to do to get babel to recognize the
> header-args?
> >>>
> >>> Thanks
> >>>
> >>>
> >>> On 8/7/20 12:51 PM, Berry, Charles wrote:
> > On Aug 7, 2020, at 8:39 AM, William McCoy  wrote:
> >
> > This use of :prologue appeared to me to be very useful.  But for
> some reason when I try it out it does not work for me.  I just get a
> message that the code block produced no output and that 'np' is not
> defined.  Just to check, when I put the import statements directly within
> my code block it works fine.
> >
> > I am running:  Org mode version 9.3.7 (9.3.7-16-g521d7f-elpa
> >
> > Any idea what I'm doing wrong?
> >
> >
>  It is sometimes useful to use C-c C-v C-i to see what header args org
> has detected for a source block. Misspelled words sometimes wreak havoc and
> invisible characters can cause real pain.
> 
> 
>  Also, it helps to use C-c C-v C-v to to see the expanded code block.
> When I do this with Kens' ECM, I get
> 
>  import numpy as np; import os
>  print(np.__version__)
> 
>  in the preview buffer.
> 
>  HTH,
> 
>  Chuck
> 
> 
> > On 8/6/20 2:12 PM, Ken Mankoff wrote:
> >> Actual example:
> >>
> >>
> >> * Prologue test
> >> :PROPERTIES:
> >> :header-args:python+: :prologue "import numpy as np; import os"
> >> :END:
> >>
> >> #+BEGIN_SRC python :results output
> >> print(np.__version__)
> >> #+END_SRC
> >>
> >> #+RESULTS:
> >> : 1.18.4
> >>
> >>
> >>
> >>
> >> On Wed, Aug 5, 2020 at 3:03 PM Ken Mankoff 
> wrote:
> >> What about using :pre or :prologue and setting it at the header or
> document level?
> >>
> >> Please excuse brevity. Sent from tiny pocket computer with
> non-haptic-feedback keyboard.
> >>
> >> On Wed, Aug 5, 2020, 14:22 George Mauer  wrote:
> >> Use case:
> >>
> >> I'm using ob-racket but this would apply just as well to a few
> other workflows I have with python or js.
> >>
> >> I would like to write a helper function in a src block and then
> automatically have access to it in other src blocks further down the
> document. I don't really want a stateful session (nor does ob-racket
> support sessions) so I essentially want the equivalent of automatically
> including it everywhere so I don't have to type it out all the time (and
> have it screw up syntax coloring/indentation).
> >>
> >> Is this currently possible? Does anyone have any ideas for how to
> extend things so it is?
> >>
> >> --
> >> Thomas S. Dye
> >> 

Re: Can you automatically noweb include?

2020-08-07 Thread William McCoy
Yes, of course, that was it!  I ran into that issue a few months ago and 
then I forgot about again!


Thanks both for your help!

Bill

On 8/7/20 5:25 PM, Berry, Charles wrote:

Good catch. Also it works if you put the property block at the very beginning 
of the file.

This sometimes helps:

M-x org-lint RET

which in this case reports "Incorrect contents for PROPERTIES drawer"

which is a bit cryptic IMO, but does point to any issue with the property.

HTH,

Chuck


On Aug 7, 2020, at 2:18 PM, Thomas S. Dye  wrote:

It works here if you remove the blank line between the headline and the 
PROPERTIES block.

William McCoy writes:


Chuck,

Thanks very much for your response.  I didn't know about those options.  When I
use C-c C-v C-i, I get the following:

Lang: python
Properties:
:header-argsnil
:header-args:python nil
Header Arguments:
:cache  no
:exportscode
:hlines no
:noweb  no
:resultsoutput replace
:sessionnone
:tangle no

And C-c C-v C-v, shows that the import statements in the header do not get
expanded into the code block.

So I am obviously doing something wrong.  There appear to be no typos or
misspellings and the org file containing the coded is exactly this:

* Test of prologue header

:PROPERTIES:
:header-args:python+: :prologue "import numpy as np; import os"
:END:

#+BEGIN_SRC python :results output
print(np.__version__)
#+END_SRC

#+RESULTS:


My init file has no org babel header arguments defined.

I am using C-c C-v C-b or C-c C-v C-s to evaluate and I get

"Code block produced no output." in the mini-buffer.


If I use C-c C-c directly on the code block itself I get:

Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'np' is not defined

Is there something else I need to do to get babel to recognize the header-args?

Thanks


On 8/7/20 12:51 PM, Berry, Charles wrote:

On Aug 7, 2020, at 8:39 AM, William McCoy  wrote:

This use of :prologue appeared to me to be very useful.  But for some reason 
when I try it out it does not work for me.  I just get a message that the code 
block produced no output and that 'np' is not defined.  Just to check, when I 
put the import statements directly within my code block it works fine.

I am running:  Org mode version 9.3.7 (9.3.7-16-g521d7f-elpa

Any idea what I'm doing wrong?



It is sometimes useful to use C-c C-v C-i to see what header args org has 
detected for a source block. Misspelled words sometimes wreak havoc and 
invisible characters can cause real pain.


Also, it helps to use C-c C-v C-v to to see the expanded code block. When I do 
this with Kens' ECM, I get

import numpy as np; import os
print(np.__version__)

in the preview buffer.

HTH,

Chuck



On 8/6/20 2:12 PM, Ken Mankoff wrote:

Actual example:


* Prologue test
:PROPERTIES:
:header-args:python+: :prologue "import numpy as np; import os"
:END:

#+BEGIN_SRC python :results output
print(np.__version__)
#+END_SRC

#+RESULTS:
: 1.18.4




On Wed, Aug 5, 2020 at 3:03 PM Ken Mankoff  wrote:
What about using :pre or :prologue and setting it at the header or document 
level?

Please excuse brevity. Sent from tiny pocket computer with non-haptic-feedback 
keyboard.

On Wed, Aug 5, 2020, 14:22 George Mauer  wrote:
Use case:

I'm using ob-racket but this would apply just as well to a few other workflows 
I have with python or js.

I would like to write a helper function in a src block and then automatically 
have access to it in other src blocks further down the document. I don't really 
want a stateful session (nor does ob-racket support sessions) so I essentially 
want the equivalent of automatically including it everywhere so I don't have to 
type it out all the time (and have it screw up syntax coloring/indentation).

Is this currently possible? Does anyone have any ideas for how to extend things 
so it is?


--
Thomas S. Dye
https://tsdye.online/tsdye







Re: Can you automatically noweb include?

2020-08-07 Thread Berry, Charles
Good catch. Also it works if you put the property block at the very beginning 
of the file.

This sometimes helps:

M-x org-lint RET

which in this case reports "Incorrect contents for PROPERTIES drawer"

which is a bit cryptic IMO, but does point to any issue with the property.

HTH,

Chuck

> On Aug 7, 2020, at 2:18 PM, Thomas S. Dye  wrote:
> 
> It works here if you remove the blank line between the headline and the 
> PROPERTIES block.
> 
> William McCoy writes:
> 
>> Chuck,
>> 
>> Thanks very much for your response.  I didn't know about those options.  
>> When I
>> use C-c C-v C-i, I get the following:
>> 
>> Lang: python
>> Properties:
>>:header-argsnil
>>:header-args:python nil
>> Header Arguments:
>>:cache  no
>>:exportscode
>>:hlines no
>>:noweb  no
>>:resultsoutput replace
>>:sessionnone
>>:tangle no
>> 
>> And C-c C-v C-v, shows that the import statements in the header do not get
>> expanded into the code block.
>> 
>> So I am obviously doing something wrong.  There appear to be no typos or
>> misspellings and the org file containing the coded is exactly this:
>> 
>> * Test of prologue header
>> 
>> :PROPERTIES:
>> :header-args:python+: :prologue "import numpy as np; import os"
>> :END:
>> 
>> #+BEGIN_SRC python :results output
>> print(np.__version__)
>> #+END_SRC
>> 
>> #+RESULTS:
>> 
>> 
>> My init file has no org babel header arguments defined.
>> 
>> I am using C-c C-v C-b or C-c C-v C-s to evaluate and I get
>> 
>> "Code block produced no output." in the mini-buffer.
>> 
>> 
>> If I use C-c C-c directly on the code block itself I get:
>> 
>> Traceback (most recent call last):
>>  File "", line 1, in 
>> NameError: name 'np' is not defined
>> 
>> Is there something else I need to do to get babel to recognize the 
>> header-args?
>> 
>> Thanks
>> 
>> 
>> On 8/7/20 12:51 PM, Berry, Charles wrote:
>>> 
 On Aug 7, 2020, at 8:39 AM, William McCoy  wrote:
 
 This use of :prologue appeared to me to be very useful.  But for some 
 reason when I try it out it does not work for me.  I just get a message 
 that the code block produced no output and that 'np' is not defined.  Just 
 to check, when I put the import statements directly within my code block 
 it works fine.
 
 I am running:  Org mode version 9.3.7 (9.3.7-16-g521d7f-elpa
 
 Any idea what I'm doing wrong?
 
 
>>> It is sometimes useful to use C-c C-v C-i to see what header args org has 
>>> detected for a source block. Misspelled words sometimes wreak havoc and 
>>> invisible characters can cause real pain.
>>> 
>>> 
>>> Also, it helps to use C-c C-v C-v to to see the expanded code block. When I 
>>> do this with Kens' ECM, I get
>>> 
>>> import numpy as np; import os
>>> print(np.__version__)
>>> 
>>> in the preview buffer.
>>> 
>>> HTH,
>>> 
>>> Chuck
>>> 
>>> 
 On 8/6/20 2:12 PM, Ken Mankoff wrote:
> Actual example:
> 
> 
> * Prologue test
> :PROPERTIES:
> :header-args:python+: :prologue "import numpy as np; import os"
> :END:
> 
> #+BEGIN_SRC python :results output
> print(np.__version__)
> #+END_SRC
> 
> #+RESULTS:
> : 1.18.4
> 
> 
> 
> 
> On Wed, Aug 5, 2020 at 3:03 PM Ken Mankoff  wrote:
> What about using :pre or :prologue and setting it at the header or 
> document level?
> 
> Please excuse brevity. Sent from tiny pocket computer with 
> non-haptic-feedback keyboard.
> 
> On Wed, Aug 5, 2020, 14:22 George Mauer  wrote:
> Use case:
> 
> I'm using ob-racket but this would apply just as well to a few other 
> workflows I have with python or js.
> 
> I would like to write a helper function in a src block and then 
> automatically have access to it in other src blocks further down the 
> document. I don't really want a stateful session (nor does ob-racket 
> support sessions) so I essentially want the equivalent of automatically 
> including it everywhere so I don't have to type it out all the time (and 
> have it screw up syntax coloring/indentation).
> 
> Is this currently possible? Does anyone have any ideas for how to extend 
> things so it is?
>>> 
> 
> 
> --
> Thomas S. Dye
> https://tsdye.online/tsdye





Re: Can you automatically noweb include?

2020-08-07 Thread Thomas S. Dye
It works here if you remove the blank line between the headline 
and the PROPERTIES block.


William McCoy writes:


Chuck,

Thanks very much for your response.  I didn't know about those 
options.  When I

use C-c C-v C-i, I get the following:

Lang: python
Properties:
:header-argsnil
:header-args:python nil
Header Arguments:
:cache  no
:exportscode
:hlines no
:noweb  no
:resultsoutput replace
:sessionnone
:tangle no

And C-c C-v C-v, shows that the import statements in the header 
do not get

expanded into the code block.

So I am obviously doing something wrong.  There appear to be no 
typos or
misspellings and the org file containing the coded is exactly 
this:


* Test of prologue header

:PROPERTIES:
:header-args:python+: :prologue "import numpy as np; import os"
:END:

#+BEGIN_SRC python :results output
print(np.__version__)
#+END_SRC

#+RESULTS:


My init file has no org babel header arguments defined.

I am using C-c C-v C-b or C-c C-v C-s to evaluate and I get

"Code block produced no output." in the mini-buffer.


If I use C-c C-c directly on the code block itself I get:

Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'np' is not defined

Is there something else I need to do to get babel to recognize 
the header-args?


Thanks


On 8/7/20 12:51 PM, Berry, Charles wrote:


On Aug 7, 2020, at 8:39 AM, William McCoy  
wrote:


This use of :prologue appeared to me to be very useful.  But 
for some reason when I try it out it does not work for me.  I 
just get a message that the code block produced no output and 
that 'np' is not defined.  Just to check, when I put the 
import statements directly within my code block it works fine.


I am running:  Org mode version 9.3.7 (9.3.7-16-g521d7f-elpa

Any idea what I'm doing wrong?


It is sometimes useful to use C-c C-v C-i to see what header 
args org has detected for a source block. Misspelled words 
sometimes wreak havoc and invisible characters can cause real 
pain.



Also, it helps to use C-c C-v C-v to to see the expanded code 
block. When I do this with Kens' ECM, I get


import numpy as np; import os
print(np.__version__)

in the preview buffer.

HTH,

Chuck



On 8/6/20 2:12 PM, Ken Mankoff wrote:

Actual example:


* Prologue test
:PROPERTIES:
:header-args:python+: :prologue "import numpy as np; import 
os"

:END:

#+BEGIN_SRC python :results output
print(np.__version__)
#+END_SRC

#+RESULTS:
: 1.18.4




On Wed, Aug 5, 2020 at 3:03 PM Ken Mankoff 
 wrote:
What about using :pre or :prologue and setting it at the 
header or document level?


Please excuse brevity. Sent from tiny pocket computer with 
non-haptic-feedback keyboard.


On Wed, Aug 5, 2020, 14:22 George Mauer  
wrote:

Use case:

I'm using ob-racket but this would apply just as well to a 
few other workflows I have with python or js.


I would like to write a helper function in a src block and 
then automatically have access to it in other src blocks 
further down the document. I don't really want a stateful 
session (nor does ob-racket support sessions) so I 
essentially want the equivalent of automatically including it 
everywhere so I don't have to type it out all the time (and 
have it screw up syntax coloring/indentation).


Is this currently possible? Does anyone have any ideas for 
how to extend things so it is?





--
Thomas S. Dye
https://tsdye.online/tsdye



Re: How create a hook before export ONLY to text

2020-08-07 Thread pineiden
Hi.

I have some example

Here the in org, the source code:

#+NAME: secuencia_1
#+ATTR_LATEX: :width 0.6
#+BEGIN_SRC plantuml :file ./img/secuencia_1.png
actor Usuario
Usuario -> Computador : iniciar programa
Computador -> Usuario : pedir nombre
Usuario -> Computador : entregar nombre
Computador -> Usuario : saludar
#+END_SRC

Now, with minted, the latex:

\begin{minted}[frame=lines,fontsize=\scriptsize,xleftmargin=\parindent,linenos,frame=single]{plantuml}
actor Usuario
Usuario -> Computador : iniciar programa
Computador -> Usuario : pedir nombre
Usuario -> Computador : entregar nombre
Computador -> Usuario : saludar
\end{minted}

So, minted doesn't know plantuml and throws the error.

I need some like that:

\begin{code}[frame=lines,fontsize=\scriptsize,xleftmargin=\parindent,linenos,frame=single]{plantuml}
actor Usuario
Usuario -> Computador : iniciar programa
Computador -> Usuario : pedir nombre
Usuario -> Computador : entregar nombre
Computador -> Usuario : saludar
\end{code}

br!

Sent with [ProtonMail](https://protonmail.com) Secure Email.

How to refer to remote table, in another file, as a source block variable?

2020-08-07 Thread William Denton

I can't figure this one out.  Let's say I have a table in an Org file, like so:

# -

* Primes

#+NAME: test_table
| number | prime |
|+---|
| two| yes   |
| three  | yes   |
| four   | no|

# -

In another file, I want to bring this table into a source block as a variable. 
If it was the same file, I'd say ":var t=test_table" and that's that.  But 
what's the syntax for a different file?  I can't figure it out from the docs [1] 
and none of my attempts with quotes, file:, etc. work.  It's something like 
this, isn't it?  But what?


#+begin_src R :var t=(remote(table.org::*Primes))
t
#+end_src

Thanks,

Bill

[1] https://orgmode.org/manual/References.html#References
--
William Denton :: Toronto, Canada   ---   Listening to Art: 
https://listeningtoart.org/
https://www.miskatonic.org/ ---   GHG.EARTH: https://ghg.earth/
Caveat lector.  ---   STAPLR: https://staplr.org/



Re: Can you automatically noweb include?

2020-08-07 Thread William McCoy

Chuck,

Thanks very much for your response.  I didn't know about those options.  
When I use C-c C-v C-i, I get the following:


Lang: python
Properties:
    :header-args    nil
    :header-args:python nil
Header Arguments:
    :cache  no
    :exports    code
    :hlines no
    :noweb  no
    :results    output replace
    :session    none
    :tangle no

And C-c C-v C-v, shows that the import statements in the header do not 
get expanded into the code block.


So I am obviously doing something wrong.  There appear to be no typos or 
misspellings and the org file containing the coded is exactly this:


* Test of prologue header

:PROPERTIES:
:header-args:python+: :prologue "import numpy as np; import os"
:END:

#+BEGIN_SRC python :results output
print(np.__version__)
#+END_SRC

#+RESULTS:


My init file has no org babel header arguments defined.

I am using C-c C-v C-b or C-c C-v C-s to evaluate and I get

"Code block produced no output." in the mini-buffer.


If I use C-c C-c directly on the code block itself I get:

Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'np' is not defined

Is there something else I need to do to get babel to recognize the 
header-args?


Thanks


On 8/7/20 12:51 PM, Berry, Charles wrote:



On Aug 7, 2020, at 8:39 AM, William McCoy  wrote:

This use of :prologue appeared to me to be very useful.  But for some reason 
when I try it out it does not work for me.  I just get a message that the code 
block produced no output and that 'np' is not defined.  Just to check, when I 
put the import statements directly within my code block it works fine.

I am running:  Org mode version 9.3.7 (9.3.7-16-g521d7f-elpa

Any idea what I'm doing wrong?



It is sometimes useful to use C-c C-v C-i to see what header args org has 
detected for a source block. Misspelled words sometimes wreak havoc and 
invisible characters can cause real pain.


Also, it helps to use C-c C-v C-v to to see the expanded code block. When I do 
this with Kens' ECM, I get

import numpy as np; import os
print(np.__version__)

in the preview buffer.

HTH,

Chuck



On 8/6/20 2:12 PM, Ken Mankoff wrote:

Actual example:


* Prologue test
:PROPERTIES:
:header-args:python+: :prologue "import numpy as np; import os"
:END:

#+BEGIN_SRC python :results output
print(np.__version__)
#+END_SRC

#+RESULTS:
: 1.18.4




On Wed, Aug 5, 2020 at 3:03 PM Ken Mankoff  wrote:
What about using :pre or :prologue and setting it at the header or document 
level?

Please excuse brevity. Sent from tiny pocket computer with non-haptic-feedback 
keyboard.

On Wed, Aug 5, 2020, 14:22 George Mauer  wrote:
Use case:

I'm using ob-racket but this would apply just as well to a few other workflows 
I have with python or js.

I would like to write a helper function in a src block and then automatically 
have access to it in other src blocks further down the document. I don't really 
want a stateful session (nor does ob-racket support sessions) so I essentially 
want the equivalent of automatically including it everywhere so I don't have to 
type it out all the time (and have it screw up syntax coloring/indentation).

Is this currently possible? Does anyone have any ideas for how to extend things 
so it is?







Re: Can you automatically noweb include?

2020-08-07 Thread Berry, Charles



> On Aug 7, 2020, at 8:39 AM, William McCoy  wrote:
> 
> This use of :prologue appeared to me to be very useful.  But for some reason 
> when I try it out it does not work for me.  I just get a message that the 
> code block produced no output and that 'np' is not defined.  Just to check, 
> when I put the import statements directly within my code block it works fine.
> 
> I am running:  Org mode version 9.3.7 (9.3.7-16-g521d7f-elpa
> 
> Any idea what I'm doing wrong?
> 
> 

It is sometimes useful to use C-c C-v C-i to see what header args org has 
detected for a source block. Misspelled words sometimes wreak havoc and 
invisible characters can cause real pain.


Also, it helps to use C-c C-v C-v to to see the expanded code block. When I do 
this with Kens' ECM, I get

import numpy as np; import os
print(np.__version__)

in the preview buffer.

HTH,

Chuck


> On 8/6/20 2:12 PM, Ken Mankoff wrote:
>> Actual example:
>> 
>> 
>> * Prologue test
>> :PROPERTIES:
>> :header-args:python+: :prologue "import numpy as np; import os"
>> :END:
>> 
>> #+BEGIN_SRC python :results output
>> print(np.__version__)
>> #+END_SRC
>> 
>> #+RESULTS:
>> : 1.18.4
>> 
>> 
>> 
>> 
>> On Wed, Aug 5, 2020 at 3:03 PM Ken Mankoff  wrote:
>> What about using :pre or :prologue and setting it at the header or document 
>> level?
>> 
>> Please excuse brevity. Sent from tiny pocket computer with 
>> non-haptic-feedback keyboard.
>> 
>> On Wed, Aug 5, 2020, 14:22 George Mauer  wrote:
>> Use case:
>> 
>> I'm using ob-racket but this would apply just as well to a few other 
>> workflows I have with python or js.
>> 
>> I would like to write a helper function in a src block and then 
>> automatically have access to it in other src blocks further down the 
>> document. I don't really want a stateful session (nor does ob-racket support 
>> sessions) so I essentially want the equivalent of automatically including it 
>> everywhere so I don't have to type it out all the time (and have it screw up 
>> syntax coloring/indentation).
>> 
>> Is this currently possible? Does anyone have any ideas for how to extend 
>> things so it is?
> 





Re: Can you automatically noweb include?

2020-08-07 Thread William McCoy
This use of :prologue appeared to me to be very useful.  But for some 
reason when I try it out it does not work for me.  I just get a message 
that the code block produced no output and that 'np' is not defined.  
Just to check, when I put the import statements directly within my code 
block it works fine.


I am running:  Org mode version 9.3.7 (9.3.7-16-g521d7f-elpa

Any idea what I'm doing wrong?


On 8/6/20 2:12 PM, Ken Mankoff wrote:

Actual example:


* Prologue test
:PROPERTIES:
:header-args:python+: :prologue "import numpy as np; import os"
:END:

#+BEGIN_SRC python :results output
print(np.__version__)
#+END_SRC

#+RESULTS:
: 1.18.4




On Wed, Aug 5, 2020 at 3:03 PM Ken Mankoff > wrote:


What about using :pre or :prologue and setting it at the header or
document level?

Please excuse brevity. Sent from tiny pocket computer with
non-haptic-feedback keyboard.

On Wed, Aug 5, 2020, 14:22 George Mauer mailto:gma...@gmail.com>> wrote:

Use case:

I'm using ob-racket
 but this would
apply just as well to a few other workflows I have with python
or js.

I would like to write a helper function in a src block and
then automatically have access to it in other src blocks
further down the document. I don't really want a stateful
session (nor does ob-racket support sessions) so I essentially
want the equivalent of automatically including it everywhere
so I don't have to type it out all the time (and have it screw
up syntax coloring/indentation).

Is this currently possible? Does anyone have any ideas for how
to extend things so it is?





Re: Bug#42184: org-fontify-whole-*-line in emacs 27

2020-08-07 Thread Kévin Le Gouguec
Kyle Meyer  writes:

> Kévin Le Gouguec writes:
>
>> Since 27.1-rc1 is out, I'd like to bump this; it'd be a shame if 27.1
>> shipped with this bug, which seems to be getting some attention (I just
>> spotted a Reddit thread[1] about it, in addition to the original report
>> on Debbugs).
>
> In the associated emacs-bug thread, Eli said that ship has sailed.  With
> the possibility of making it into 27.1 out of the picture, I think this
> patch should be made against the Org repo, as usual.
>
> As I said in the emacs-bug thread, the patch (which you also included
> upstream in this thread) looks fine to me.  If you'd prefer to bundle
> your org-block change in the same patch, could you send an updated patch
> here against the Org repo?

I've just noticed that my patch for org-block (bug#42184#44) was missing
a compatibility shim for Emacs<27; here are updated patches against
maint and master:

>From 6ca21259589e212452411acd4ac2de3258ede508 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= 
Date: Fri, 7 Aug 2020 11:04:53 +0200
Subject: [PATCH] Fix org-fontify-whole-*-line by setting face extension
 (bug#42184)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/org-faces.el (org-block): Set background extension beyond
end-of-line.
* lisp/org-compat.el (org--extended-face): New function to add :extend
attribute to face definition for Emacs≥27.
(org--set-faces-extend): New function to temporarily (re)set :extend
for Emacs≥27.
* lisp/org.el (org-mode): Call it to set the extend attribute of
relevant faces to the correct value.
---
 lisp/org-compat.el | 15 +++
 lisp/org-faces.el  |  2 +-
 lisp/org.el|  6 +-
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index c757355ba..c0f4833a3 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -101,6 +101,21 @@ is nil)."
   (defun org-time-convert-to-list (time)
 (seconds-to-time (float-time time
 
+(defmacro org--extended-face (attributes)
+  "Make face that extends beyond end of line.
+
+Up to Emacs 26, all faces extended beyond end of line; getting
+the same behaviour starting with Emacs 27 requires :extend t."
+  `(nconc ,attributes (when (>= emacs-major-version 27) '(:extend t
+
+(defun org--set-faces-extend (faces extend-p)
+  "Set the :extend attribute of FACES to EXTEND-P.
+
+This is a no-op for Emacs versions lower than 27, since face
+extension beyond end of line was not controllable."
+  (when (fboundp 'set-face-extend)
+(mapc (lambda (f) (set-face-extend f extend-p)) faces)))
+

 ;;; Emacs < 26.1 compatibility
 
diff --git a/lisp/org-faces.el b/lisp/org-faces.el
index 30eab9bc6..4c5a51624 100644
--- a/lisp/org-faces.el
+++ b/lisp/org-faces.el
@@ -393,7 +393,7 @@ follows a #+DATE:, #+AUTHOR: or #+EMAIL: keyword."
   "Face for #+TITLE:, #+AUTHOR:, #+EMAIL: and #+DATE: keywords."
   :group 'org-faces)
 
-(defface org-block '((t :inherit shadow))
+(defface org-block `((t ,(org--extended-face '(:inherit shadow
   "Face text in #+begin ... #+end blocks.
 For source-blocks `org-src-block-faces' takes precedence."
   :group 'org-faces
diff --git a/lisp/org.el b/lisp/org.el
index 007dd6e2a..34c0235c1 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4940,7 +4940,11 @@ The following commands are available:
   ;; Try to set `org-hide' face correctly.
   (let ((foreground (org-find-invisible-foreground)))
 (when foreground
-  (set-face-foreground 'org-hide foreground
+  (set-face-foreground 'org-hide foreground)))
+  ;; Set face extension as requested.
+  (org--set-faces-extend '(org-block-begin-line org-block-end-line)
+ org-fontify-whole-block-delimiter-line)
+  (org--set-faces-extend org-level-faces org-fontify-whole-heading-line))
 
 ;; Update `customize-package-emacs-version-alist'
 (add-to-list 'customize-package-emacs-version-alist
-- 
2.28.0

>From 715927aa2f1baae32040e52d2cfca4aef2edc14b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= 
Date: Fri, 7 Aug 2020 11:04:53 +0200
Subject: [PATCH] Fix org-fontify-whole-*-line by setting face extension
 (bug#42184)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/org-faces.el (org-block): Set background extension beyond
end-of-line.
* lisp/org-compat.el (org--extended-face): New function to add :extend
attribute to face definition for Emacs≥27.
(org--set-faces-extend): New function to temporarily (re)set :extend
for Emacs≥27.
* lisp/org.el (org-mode): Call it to set the extend attribute of
relevant faces to the correct value.
---
 lisp/org-compat.el | 15 +++
 lisp/org-faces.el  |  2 +-
 lisp/org.el|  6 +-
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 5953f89d2..a9cf400a7 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -109,6 +109,21 @@ is nil)."

Bug: clocking and rounding [9.3.7 (9.3.7-16-g521d7f-elpa @ c:/Users/maiers/AppData/Roaming/.emacs.d/elpa/org-20200803/)]

2020-08-07 Thread Siegmar Maier
Hi,
I'm using clocking within org mode.
I feel the rounding of the clock-in/out is not working correctly.

E.g. if I'm clocked-in in one task and the time is 9:29
Then I clock in to another task
The clock-in time of the new taks will jump to 9:25 (rounding-down)
The clock-out time of the old task will jump to 9:30 (rounding-up)
So I get an overlap

I use the rounding of 5 minutes

Regards
Siegmar

Emacs  : GNU Emacs 26.3 (build 1, x86_64-w64-mingw32)
 of 2019-08-29
Package: Org mode version 9.3.7 (9.3.7-16-g521d7f-elpa @ 
c:/Users/maiers/AppData/Roaming/.emacs.d/elpa/org-20200803/)




Re: Document containing different text colours?

2020-08-07 Thread Eric S Fraga
On Thursday,  6 Aug 2020 at 14:35, Bo Grimes wrote:
> It feels to me like this should be possible because syntax
> highlighting mixes colors.

hi-lock-mode may do what the OP wanted with some careful insertion of
tags in the document, maybe in the form of comment lines.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-705-gea9463