Re: [FR] ob-awk.el specifying a delimeter argument in for output

2023-03-05 Thread Jeremie Juste


Hello Ihor,

>> I guess we might add an option to tell Org which separator to use when
>> parsing output when :results table header argument is provided (see 16.6
>> Results of Evaluation section of Org manual). However, you can achieve
>> the same now, using :post header argument, replacing the separators with
>> something Org can understand.

Thanks again for the suggestion, after giving your solution more thoughts, I 
could
achieve the desired output. 

# file test.csv
# 123;0;123

#+NAME: specific-delim
#+BEGIN_SRC emacs-lisp :var tbl="" delim=";"
(format "|%s"  (replace-regexp-in-string delim  "|" tbl))
#+end_src

#+RESULTS: specific-delim
: |



#+begin_src awk :in-file test.csv :cmd-line -F ";" :post 
specific-delim(*this*,";") :results raw
 {print $0}
#+end_src

#+RESULTS:
| 123 | 0 | 123 |


Best regards,
Jeremie



Re: [FR] ob-awk.el specifying a delimeter argument in for output

2023-03-05 Thread Jeremie Juste


Hello Ihor,


> Org knows nothing about your output, by default.
> You could as well do something like {print $1+-+$2+-+$3}
> What should Org do in such case?
>
> Currently, Org tries to guess the type of arbitrary output. If the
> output looks like a table, with fields separated by tabs, commas, or
> spaces, it converts the output to table. Otherwise, it is treated as
> string.

Many thanks for the insights.  Ok, I guess this it likely to take some
time, but it would be a great feature in my option.

>
> I guess we might add an option to tell Org which separator to use when
> parsing output when :results table header argument is provided (see 16.6
> Results of Evaluation section of Org manual). However, you can achieve
> the same now, using :post header argument, replacing the separators with
> something Org can understand.

Thanks for the suggestion. I tried using post replacing semi columns by
commas but was surprised by the output.

# file test.csv
# 123;0;123

#+NAME: specific-delim
#+BEGIN_SRC emacs-lisp :var tbl=""
(replace-regexp-in-string ";" "," tbl)
#+end_src

#+RESULTS: specific-delim



#+begin_src awk :in-file test.csv :cmd-line -F ";" :post specific-delim(*this*)
 {print $0}
#+end_src

#+RESULTS:
: 123,0,123



After a short investigation, I notice that the function
org-babel-import-elisp-from-file, is the function making the call wheter
the result should be a table or not i.e before the :post argument. Have
I understood correctly?

If it is the case, then I would have to not just replace the delimeter
but convert the entire results to an org-table.

Best regards,
Jeremie



[FR] ob-awk.el specifying a delimeter argument in for output

2023-03-05 Thread Jeremie Juste
Hello,

ob-awk has proven very valuable to me lately so many
thanks for maintaining it. 

First of all let me specify that I'm a beginner user of awk and I don't
know if I'm using ob-awk as it is intended, so I'll be glad for any
suggestions. Let me explain further:


* Default behavior

If I have a csv file with comma separated values, I get the output as an
org table.

;; test.csv
123,0,123


#+begin_src awk :in-file test.csv :cmd-line -F ","
{print $0}
#+end_src

#+RESULTS:
| 123 | 0 | 123 |

* Request 

However If I have a csv file with say semi column delimited values (;)
I don't get the org table as output

#+begin_src awk :in-file test1.csv :cmd-line -F ";"
{print $0}
#+end_src

#+RESULTS:
: 123;0;123


In my opinion, this could be fixed if we could read the :cmd-line
parameter -F  and use the delimeter argument ; as a parameter to the
following function

modified   lisp/ob-awk.el
@@ -93,7 +93,7 @@ This function is called by `org-babel-execute-src-block'."
   results
   (let ((tmp (org-babel-temp-file "awk-results-")))
 (with-temp-file tmp (insert results))
-(org-babel-import-elisp-from-file tmp)
+(org-babel-import-elisp-from-file tmp ";")


Would this be the right way to do think about this issue? 

Best regards,
Jeremie

PS Note that we have a samilar issue in ob-shell
where the delimiter is by default a comma. 

#+begin_src shell
  echo '192;168;1;200' | awk -F ";"   '{print $0}' 
#+end_src

#+RESULTS:
: 192;168;1;200



#+begin_src shell
  echo '192,168,1,200' | awk -F ","   '{print $0}' 
#+end_src

#+RESULTS:
| 192 | 168 | 1 | 200 |



Re: [BUG] ob-R.el: extra empty data.frame columns generated from plain lists after recent change [9.6 (release_9.6-3-ga4d38e @ /usr/share/emacs/30.0.50/lisp/org/)]

2022-12-11 Thread Jeremie Juste
Hello Ihor

On Thursday,  8 Dec 2022 at 09:07, Ihor Radchenko wrote:

> I am not sure if I like the approach you used in the commit.
>
> -(unless (listp (car value)) (setq value (list value)))
> +(unless (listp (car value)) (setq value (mapcar 'list value)))
>
> In the above, you are transforming (val1 val2 val3 ...) list into
> ((val1) (val2) (val3) ...).
>
> Does it make sense from the point of view of R code?
> AFAIU, the current ob-R implementation converts lists into R tables,
> which is not accurate? Would it make sense to convert Elisp lists into R
> lists directly?

Many thanks for the feedback. At this point I don't know. On one hand you are
right on the other, this option is backward compatible, and the user can
always create an interface in R to suit his need.

If there are more complaints about that in the future, I'll reconsider. 

Best regards,
Jeremie



Re: [BUG] ob-R.el: extra empty data.frame columns generated from plain lists after recent change [9.6 (release_9.6-3-ga4d38e @ /usr/share/emacs/30.0.50/lisp/org/)]

2022-12-07 Thread Jeremie Juste
Hello,

Many thanks to you all for your feedback.
>From 1ad16ffb9, I have restored the expected output in R. that is.


#+NAME: example-list
- simple
  - not
  - nested
- list

#+BEGIN_SRC R :var x=example-list
x
#+END_SRC

#+RESULTS:
| simple |
| list   |


On Wednesday,  7 Dec 2022 at 12:16, Ihor Radchenko wrote:

> I also like the second option as **printing** more, but it is _not_ what
> we have in the manual.

Thanks for the precision. We propably need to update the doc. I guess it also
has to be language specific.

Best regards,
Jeremie



Re: [BUG] ob-R: session evaluation returns empty ouputs with Org 9.6 [9.6 ( @ /home/fsantos/.emacs.d/elpa/org-9.6/)]

2022-12-07 Thread Jeremie Juste


Hello Malcolm,

On Wednesday,  7 Dec 2022 at 17:50, Cook, Malcolm wrote:
>
> Byte-compiling and reloading ob-R.el worked.

Glad that you could solve it. From 08433d9b0, I added a test to make sure we 
are not
surprised again. 

Best regards,
Jeremie





Re: [BUG] ob-R.el: extra empty data.frame columns generated from plain lists after recent change [9.6 (release_9.6-3-ga4d38e @ /usr/share/emacs/30.0.50/lisp/org/)]

2022-12-06 Thread Jeremie Juste
Hello,

Many thanks for the insights. I confess that I have never transferred
list from org to R before. I've always use tables and as far as I
understand they works fine in 9.6.

So assuming this list

#+name: alist 
- first item
- second item
- third item
  - 3.1 item
- fourth item


before c72d5ee84 we could do something like 

#+begin_src R :var list=alist
  list
#+end_src

#+RESULTS:
| first item  ||
| second item ||
| third item  | (unordered (3.1 item)) |
| fourth item ||

and after we end up with 


#+begin_src R :var list=alist
  list
#+end_src

#+RESULTS:
| first item | second item | third item | fourth item |   |   |   |   |   |   |

Here I'm on uncharted territory. We could go with 
1.
| first item | second item | third item | fourth item |

or be closer to the version 9.5 with
2. 
| first item  | 
| second item | 
| third item  | 
| fourth item | 

However I'm still tempted to choose the second option to break as little
workflow as possible.

If we go in this direction the solution of Chuck works fine. Many thanks
for the suggestions.

> @@ -241,7 +241,7 @@ This function is called by `org-babel-execute-src-block'."
> (defun org-babel-R-assign-elisp (name value colnames-p rownames-p)
>   "Construct R code assigning the elisp VALUE to a variable named NAME."
>   (if (listp value)
> -  (let* ((lengths (mapcar 'length (cl-remove-if-not 'sequencep value)))
> +  (let* ((lengths (mapcar 'length (cl-remove-if-not 'listp value)))
>(max (if lengths (apply 'max lengths) 0))
>(min (if lengths (apply 'min lengths) 0)))
> ;; Ensure VALUE has an orgtbl structure (depth of at least 2).

- (unless (listp (car value)) (setq value (list value)))
+ (unless (listp (car value)) (setq value (mapcar 'list value)))



Do you have any case of using org-list to R? Do you think we could use
the list for a different purpose.  Suggestions are welcome.

Best regards,
Jeremie








On Sunday,  4 Dec 2022 at 18:49, Greg Minshall wrote:
> for the record, these are the tests i ran with my off-the-cuff "fix"
> (s/sequencep/listp/):
> 
>
> #+name: alist
> - first item
>
> - second item
> - third item
>
> #+begin_src R :var list=alist :session ss
>  list
> #+end_src
>
>
> #+RESULTS:
> | first item | second item | third item |
>
> #+begin_src R :var variable='(a test)
>   variable
> #+end_src
>
>
> #+RESULTS:
> | a | test |
>
> #+name: atable
> | this | is | a | header | line |
>
> |--++---++--|
> | 1| 2  | 3 | 4  | 5|
> | a| b  | c | d  | e|
>
> #+begin_src R :var list=atable :session ss
>  list
> #+end_src
>
>
> #+RESULTS:
> | 1 | 2 | 3 | 4 | 5 |
> | a | b | c | d | e |
>
> #+begin_src R :var list='((1 2 3) (1 2))
>   list
> #+end_src
>
>
> #+RESULTS:
> | 1 | 2 | 3 |
> | 1 | 2 |   |
>
> #+begin_src elisp :var list=alist
>  list
> #+end_src
>
> #+RESULTS:
> | first item | second item | third item |



Re: [BUG] ob-R: session evaluation returns empty ouputs with Org 9.6 [9.6 ( @ /home/fsantos/.emacs.d/elpa/org-9.6/)]

2022-12-03 Thread Jeremie Juste


Hello Ihor,

On Friday,  2 Dec 2022 at 06:02, Ihor Radchenko wrote:>
> Fixed on bugfix.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=456462741


Many thanks to you all for helping solve this issue.
I apologise for the delayed response. From ffb30cd7373, I added two
tests to make sure this issue does not happen again in ob-R.


Best regards,
Jeremie




Re: Seeing all the steps when I run an R code block

2022-11-27 Thread Jeremie Juste
Hello Ihor,

On Sunday, 27 Nov 2022 at 11:52, Ihor Radchenko wrote:>

> So, if R has some way to override the working directory, we should
> enforce what we promise in the above section of our manual anyway.
>
> Otherwise, the will lose on Org document reproducibility.

This is a fair point, many thanks the insights.

ESS indeed overrides the working directory when ess-startup-directory is
set to nil. It only happens when :sessions are used though. Here I
created created a git repository in /tmp/test, and when a process is
initiated with session (the last code chunk) the process is started in
at the root of the git repository. 

#+BEGIN_SRC elisp
  (setq ess-startup-directory nil)
#+END_SRC

#+BEGIN_SRC elisp
  default-directory
#+END_SRC

#+RESULTS:
: /tmp/test/books/reading/


#+BEGIN_SRC R
getwd()
#+END_SRC

#+RESULTS:
: /tmp/test/books/reading


#+begin_src R :session R:testing :results value
getwd()
#+end_src

#+RESULTS:
: /tmp/test

Thanks again, I'll improve this.

Best regards,
Jeremie



Re: Images generated by R code blocks do not display

2022-11-27 Thread Jeremie Juste
Hello Ihor,


On Sunday, 27 Nov 2022 at 13:21, Ihor Radchenko wrote:
> Jeremie Juste  writes:
>
>> I tried to reproduce your steps on Org mode version 9.6-pre
>> (release_9.5.5-1096-gf83e45.dirty @ /home/djj/src/org-mode/lisp/).
>>
>> and I get stuck at step 12, Inline display image cannot be switched on
>> again.
>
> Not switching on again has been fixed in
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=d4522dd4d
> (see the previous replies in this thread)
>
> You need a newer Org version.
Sorry, Yes I realised that I hadn't pulled.

I confirm the behaviour with the version

Org mode version 9.6-pre (release_9.5.5-1158-g927621 @
/home/djj/src/org-mode/lisp/)

Best regards,
Jeremie




Re: Images generated by R code blocks do not display

2022-11-27 Thread Jeremie Juste


Hello Ihor,


On Friday, 25 Nov 2022 at 02:03, Ihor Radchenko wrote:
>
> What I did is
>
> 1. cd /path/to/org/repo
> 2. git checkout main
> 3. make repro
> 4. M-: (require 'ob-shell)
> 5. Open the following org file
>
> #+begin_src sh :results graphics file :file /tmp/colour.png
> convert -size 300x300 xc:#002b36 /tmp/colour.png
> #+end_src
>
> 6. Move point to the source block and C-c C-c yes
> 7. C-c C-x C-v
> 8. Observe the 300x300 image appearing
> 9. Edit the source code to 500x300
> 10. C-c C-c yes
> 11. Image disappears
> 12. C-c C-x C-v
> 13. Observe what appears to be the old 300x300 image
> 14. Move the cursor to the image
> 15. Observe the correct 500x300 appearing while the cursor is on it!!
>
I tried to reproduce your steps on Org mode version 9.6-pre
(release_9.5.5-1096-gf83e45.dirty @ /home/djj/src/org-mode/lisp/).

and I get stuck at step 12, Inline display image cannot be switched on
again.

Hope this helps,

Jeremie



Re: Seeing all the steps when I run an R code block

2022-11-27 Thread Jeremie Juste
Hello William,

Many thanks for reporting.

>
> I think this specific issue might be solved on Org side.
> We can let-bind `ess-startup-directory' to 'default-directory while
> running R source blocks.
>
> CCing the maintainer.
Ihor, many thanks for the suggestion. However I'm not sure it will work
here. The issue is that sometimes ESS has many ways of doing the same
thing so finding a middle ground is more challenging.

A possible configuration related to the point above for ESS is to do the
following

(setq ess-startup-directory nil)

(describe-variable  'ess-startup-directory)


which regardless of the value in the 'default-directory, will start the
R process in the current project directory

With the configuration above org-mode does not have any issues finding
the current directory. For instance

If I move following file test.org in the directory
/home/djj/Documents/projects/R. And run the code chunk I get.

#+begin_src R
  getwd()
#+end_src

#+RESULTS:
: /home/djj/Documents/projects/R


Moving it to /tmp/test/, I get
#+begin_src R
  getwd()
#+end_src

#+RESULTS:
: /tmp/test


Note also that you can force the R process to start in a particular
directory with the dir parameter.

#+begin_src R :dir ~/
  getwd()
#+end_src

#+RESULTS:
: /home/djj


Now on the org-mode side. This is becomes tricky because I don't know
what users expects. For now this issue is delegated to the ESS configuration.
Is the present state a satisfactory one? Please voice out your opinion.

Hope this help, 
Jeremie



Re: User

2022-11-23 Thread Jeremie Juste
Hello Paul,

As far as I know emacs 28 ships with org-mode 9.5.
So if you have org-mode 9.4 you might have install an older version on
top of this.

When installing emacs 28 on window with a plain vanilla installation,
M-x org-version, should give you 9.5.

My best advice would be to try reinstalling emacs on Windows. Now I need
to specify that I'm not an expert here. I  also use emacs on Windows and
I'm not sure I've installed it the optimal way, but my org file works
out of the box.

Hope this helps.
Jeremie



On Wednesday, 23 Nov 2022 at 11:33, Paul Schlesinger wrote:
> Have been using org mode for more than 10 years and package manager since
> emacs 26.  When I moved to emacs 28, the included org package was 9.4x
> and a nag message to install org from the elpa repository
> appeared everytime an org file is processed.  I run emacs on windows and
> list-packages does not show and "org" package to install although there
> are many "org-xxx" packages.  Suggestions appreciated!
>
> Paul H. Schlesinger MD, PhD
> Washington University School of Medicine
> Don't let your models of reality become confused with reality itself.



Re: [BUG] Incorrect background color [9.5.4 (release_9.5.4-3-g6dc785 @ /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/)]

2022-11-12 Thread Jeremie Juste


 Hello Ihor,

 On Sunday, 16 Oct 2022 at 10:44, Ihor Radchenko wrote:

 >>
 >> Confirmed.
 >>
 >> WORG page is not accurate here. The truth is that ob-R.el does not provide
 >> any defaults for header args. Instead, R defaults are used. I suspect
 >> that defaults for background color changed in R since the WORG page has
 >> been written.
 >
 > Jeremie, could you please take a look?

 Yes. Thanks for confirming the issue. I confirm that the white backgroud is 
the default and is R default.
 I could not trace back any recent change in R. So I suspect white was always 
the default.
 But I could well be wrong here.

 Note also that R parameters always takes precedence on the org-mode ones. As 
in the example below.

 #+BEGIN_SRC R :results graphics file :file test.svg :outputs both bg red
  par(bg="blue")
  plot(1:10, type = "n")
 #+end_src

In opinion the actual org parameters are the right ones. But I'm open to 
suggestions.
Thanks also for updating the WORG page.

Best regards,
Jeremie




Re: [BUG] Incorrect background color [9.5.4 (release_9.5.4-3-g6dc785 @ /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/)]

2022-11-12 Thread Jeremie Juste


 On Sunday, 16 Oct 2022 at 10:44, Ihor Radchenko wrote:

 >>
 >> Confirmed.
 >>
 >> WORG page is not accurate here. The truth is that ob-R.el does not provide
 >> any defaults for header args. Instead, R defaults are used. I suspect
 >> that defaults for background color changed in R since the WORG page has
 >> been written.
 >
 > Jeremie, could you please take a look?

 Yes. Thanks for confirming the issue. I confirm that the white backgroud is 
the default and is R default.
 I could not trace back any recent change in R. So I suspect white was always 
the default.
 But I could well be wrong here.

 Note also that R parameters always takes precedence on the org-mode ones. As 
in the example below.

 #+BEGIN_SRC R :results graphics file :file test.svg :outputs both bg red
  par(bg="blue")
  plot(1:10, type = "n")
#+end_src

In opinion the actual org parameters are the right ones. But I'm open to 
suggestions.
Thanks also for updating the WORG page.

Best regards,
Jeremie




Re: You can now support Org-mode through https://liberapay.com/org-mode/

2022-09-17 Thread Jeremie Juste
Hello,

Many thanks for setting this up.  I'm happy and relieved that an
agreement has been reached to support contributors to org mode.
I'd like to imagine that this move is the first step to many further
improvements towards further and better financial support.

Best regards,
Jeremie





On Saturday, 17 Sep 2022 at 10:32, Bastien wrote:
> Dear all,
>
> We recently set up a Liberapay team for processing donations made to
> Org-mode contributors:
>
> https://liberapay.com/org-mode/
>
> For now, the team is comprised of Ihor, Timothy (TEC) and me.
>
> If you have a Liberapay account and are a maintainer of one of Org's
> core file, please don't hesitate to join this team.
>
> The team is also open to non-code contributors: e.g. people who spend
> time answering questions on this list or enhancing Worg documentation,
> all these efforts that make Org valuable to everyone.
>
> New members are added if current members all agree on adding them.
>
> Donations are equally shared among members -- for now this amount of
> donations is 10€ per week, so don't be shy.
>
> Thanks to Ihor for triggering this change. For more context about it,
> see this thread: https://list.orgmode.org/87iloyyd1y.fsf@localhost/



Re: org-latex preview on Windows

2022-08-09 Thread Jeremie Juste
Hello Ypo,

Many thanks for sharing.

On Sunday,  7 Aug 2022 at 20:05, Ypo wrote:
> Hi Jeremie
>
> In my emacs it works great. Even org-fragtog that allows you to edit in
> an interactive manner.
Org impatient is also pretty nice :-)
https://github.com/yangsheng6810/org-latex-impatient

>
> - Just in case it could be helpfult, these are the lines in my init file
> that I can find related to LaTeX:

I manage to solve the problem just by updating the temporary-file-directory
(setq temporary-file-directory
"c:/Users/JeremieJuste/AppData/Local/Temp/")



Best regards,
Jeremie



Re: org-verse-num: display verse numbers within a verse block

2022-08-07 Thread Jeremie Juste
Hello Juan,

On Sunday,  7 Aug 2022 at 14:22, Juan Manuel Macías wrote:

> I've added some minor improvements to my little package 'org-verse-num',
> which was born out of necessity in my translation to spanish
> (work-in-progress) of Homer's Odyssey (11600 verses spread over 24
> books):

> https://gitlab.com/maciaschain/org-verse-num

Many thanks for sharing.

>
> Sorry for the inconvenience. I plan to set up my own GitLab instance in
> the future, but I don't have time to do it anytime soon.
>
> BTW, is there any proprietary JavaScript free alternative to
> GitLab/GitHub? I would be very grateful for any recommendations.

https://sourcehut.org/ seems to gain popularity, but they charge a
fee. But it might still be less expensive than hosting your own gitlab
repository. (I have no affiliation with sourcehut and I am not an expert).

>
> (I noticed that my previous message was sent to the duplicate list.
> Apologies for that).

No problem for posting to two lists. I didn't know about emacs-humanities
.


Best regards,
Jeremie



Re: Bug: Folding problem with markdown source block

2022-08-07 Thread Jeremie Juste


Hello Jack,

Thanks for reporting. I can reproduce the bug.

Best regards,
Jeremie


On Saturday,  6 Aug 2022 at 14:10, Jack Kamm wrote:
> Hello,
>
> I found that Org entries containing markdown source blocks don't get
> properly folded on the main development branch, when markdown-mode is
> also loaded.
>
> To reproduce:
>
> 1. Download markdown-mode from MELPA or Github. [1]
> 2. Fix the paths in the attached init.el.
> 3. emacs -Q -l init.el test.org
> 4. Shift-tab to collapse the visibility
>
> Output should look like this:
>
> * Headline 1...
>
> But instead I observe this:
>
> * Headline 1... ```
> ... ```
> ...
>
> If markdown-mode isn't loaded, then the problem goes away. I think the
> problem might have to do with the fontification that markdown-mode
> applies to the back-quoted code block.
>
> Versions:
> GNU Emacs 28.1 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 
> 1.17.6, Xaw3d scroll bars) of 2022-07-10
> Org mode version 9.5.4 (release_9.5.4-717-g9cc60d @ 
> /home/jack/dev/org-mode/lisp/)
>
> [1] https://github.com/jrblevin/markdown-mode
>
>
> (add-to-list 'load-path "~/.emacs.d/elpa/markdown-mode-20220708.6")
> (require 'markdown-mode)
>
> (add-to-list 'load-path "~/dev/org-mode/lisp")
>
>
> * Headline 1
> ** Headline 1a
>
> #+begin_src markdown
>   Some source code:
>
>   ```
>   echo hello world
>   ```
>
>   A list:
>
>   ,* Item 1
>   ,* Item 2
> #+end_src
>
> ** Headline 1b
>
> Lorem ipsum.



org-latex preview on Windows

2022-08-06 Thread Jeremie Juste
Hello everyone,

I have had difficulties using  org-latex-preview to run properly on Windows.
The main issue seems to be that the user name on windows gets abbreviated
with ~. As far as I understand this generate problems as the temporary
folder cannot be found.

see for instance these posts
https://emacs.stackexchange.com/a/70119

and an old post from Vincente Vera
https://list.orgmode.org/CAMfbzvDPLS1eqXJ=7tzh1035z3vq4q4-yjmqsvbcgxzp8kd...@mail.gmail.com/

Vincente, suggests altering the temporary environment variable
(setenv "TEMP" "C:\Temp"). I have tried this option and place it in my
.init file but the Temporary file in org-mode uses does not change. 


As a work around I modified the function org-compile-file in lisp/org/
org-macs.el
by adding altering the source variable as such

 (let* ((source (replace-regexp-in-string "JEREMI~1" "JeremieJuste"
source))

This is obviously not an ideal solution but I cannot find any other
solution immediately. Have someone else come across the same issue on
Windows? Do you have any suggestions?

Best regards,
Jeremie
Org mode version 9.5.4
GNU Emacs 28.1 




Re: Efficiently reuse code in org babel with R

2022-07-07 Thread Jeremie Juste
Hello Naresh,

Many thanks for sharing.
If I'm looking for efficiency, I tend not to use noweb and use an R
session instead.

One reason is that caching does not work with noweb

#+name: test
#+begin_src R  :cache yes :session *R*
Sys.sleep(10)
  a <- 1
#+end_src

#+RESULTS[36c41617bf9aa447ecc28fca8207eab38340d418]: test
: 1


#+name: add1
#+begin_src R :noweb yes :cache no :session *R*
<>
 a + 1
#+end_src

#+RESULTS: add1
: 2


I would proceed in the following way

#+name: connection
#+begin_src R :exports results :results output :session *R* 
 ## my code here
#+end_src

#+begin_src R :exports results :results output graphics file
:session *R* :file figures/fig1.png
## my code here
#+end_src

#+begin_src R :exports results output graphics file :file figures/fig2.png 
:session *R*
## my code here
#+end_src

this will require running the first code chunk once only to run the rest

On Thursday,  7 Jul 2022 at 09:22, Greg Minshall wrote:
>  you'd have to be careful to not get bitten by the code
> *not* being evaluated, and by it being evaluated too often.  (probably
> too clever by half.)

The comment of Greg is very relevant here as you'll have to manage
updates yourself, and it can get complex very quickly. A potential
pitfall is when the tables in database you are referring to, change.
So in this case I would avoid using :cache yes in the first code chunk


I'm also tempted to adopt the following organization

* setup table
#+name: connection
#+begin_src R :exports results :results output :session *R* 
 ## my code here
#+end_src

* output graphs
 :PROPERTIES:
 :header-args:R: :exports results output graphics file  :session *R*
 :END:
 
#+begin_src R  :file figures/fig2.png
## my code here
#+end_src

#+begin_src R  :file figures/fig1.png 
## my code here
#+end_src

then I would use (org-babel-execute-subtree) which is bound to C-c C-v
s on the subheading output graphs to regenerate the graphs.


HTH,
Jeremie



Re: Links to javascript-based websites from orgmode.org: Paypal and Github

2022-07-02 Thread Jeremie Juste


Hello,


For some reason, I increased the score of an email, when the body of the
email contains "discouraged" :-). The argument raised by Timothy
particularly interesting. 

So I've taken the time to read this thread again to understand better
the issue.

As far as I understand, there is currently no
technology that can send electronic payment to someone and at the same time 
achieve
three goals.

- Promote user freedom (by running free javascript)
- Is a legal form of payment (crypto currency) [1]
- Is decentralized and anonymous

An exception is the FSF which has a special agreement to run free JS,
but it is something that might be costly to implement for individuals.

I think we can all agree that freesoftware developpers and
maintainers are in many cases underfunded for the value they create.  

[1]:https://www.theverge.com/2021/9/24/22691472/china-central-bank-cryptocurrency-illegal-bitcoin

On Friday,  1 Jul 2022 at 13:53, Tim Cross wrote:
> Richard Stallman  writes:
>
>> [[[ To any NSA and FBI agents reading my email: please consider]]]
>> [[[ whether defending the US Constitution against all enemies, ]]]
>> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>>
>>   > I do make a serious point: by linking to liberapay who are actively
>>   > searching for ways to get rid of proprietary software, those links are
>>   > most likely to become usable without proprietary software once a
>>   > practical method to donate without proprietary software exists.
>>
>> I agree that links to liberapay might someday work without the donor's
>> running nonfree software.  But that is not likely to occur this year,
>> and for it to occur in this decade is a long shot.
>>
>> So please don't put links to liberapay into GNU package web pages.
>
> Please explain how you can argue that position when the FSF has such a
> link on their web page? Why is it OK for the FSF to do this to raise
> funds, but not acceptable for projects to do the same? 

Here, I think that the FSF, even while having a free JS alternative,  is
still giving the freedom to potential donors to
restrict their own freedom to fund project that are important for them, by
using Paypal.

My question is the following:  Can we have the freedom to deliberately
restrict our freedom to fund projects that we care about, that give us
freedom in other dimensions?

I am not suggesting to encourage anyone to use non free method of
payments, but allowing them to do so if they want to.  I'd like to see
solutions towards free electronic payments emerge eventually, but I'm
not sure if restricting funding of free software will make that happen.


Best regards,
Jeremie Juste

In the long run we are all dead.



Re: Change both width and height of R plot in SRC block

2022-07-01 Thread Jeremie Juste


Hello Gerado,

Thanks for your email. I'm glad you reached out to the community.

>>> Gerardo Moro  writes:
>>>
>>> > I have been trying for over a year to change the output plot  >
>>> size when
>>> > using Orgmode SRC blocks with R. I have tried both using  >
>>> orgmode settings
>>> > and R settings.

I feel your pain and frustration here. In the future, please reach out to the
mailing list sooner. We think (together) therefore we R (org-mode users) ;-).

> Gerardo Moro  writes:
>
>> Oh my god, this works! I honestly tried everything but...
>> Apologies.

No need to apologise, but I hope reaching out to
the mailing list will be in your definition of everything :-).


Many thanks to Ihor and Thomas for your reactivity.

Best regards,
Jeremie



Re: problem with unwanted strikeout in src blocks

2022-05-23 Thread Jeremie Juste
Hello Uwe

> On Monday, 23 May 2022 at 19:24, Uwe Brauer wrote:

Sorry I don't have matlab and I have never used the solutionorbox
environment, but I believe you can generate latex directly. For example
with R I can to the following.

#+begin_src R :exports results  :eval yes  :results output latex
cat("\\begin{align*}")
cat("P(\\text{Covid19}|\\text{ + })&=\\frac{P(\\text{ + 
}|\\text{Covid19})P(\\text{Covid19})}{P(\\text{ + } | 
\\text{Covid19})P(\\text{Covid19}) + P(text{ + 
}|\\text{No-Covid19})P(\\text{No-Covid19})}")
cat("\\end{align*}")
#+end_src

With the :post keyword so that you can wrap pretty much anything. 

(info "(org) Results of Evaluation")

Consider

#+NAME: box
#+BEGIN_SRC emacs-lisp :var equation="" 
(format  "begin{solutionorbox}
 %s
 end{solutionorbox}" equation )
#+end_src


#+begin_src R :exports results  :eval yes  :results output latex :post 
box(*this*)
cat("\\frac{3}{4}")
#+end_src  

#+RESULTS:
#+begin_export latex
\\begin{solutionorbox}
 \frac{3}{4}
 \\end{solutionorbox}
#+end_export

HTH,
Jeremie



Re: calculating quartils, tercils (or percentiles) Using R?

2022-05-22 Thread Jeremie Juste


Hello Uwe,

> On Sunday, 22 May 2022 at 08:40, Uwe Brauer wrote:

> but I can't not find a way to calculate other percentiles, like terciles or 
> so.
> Does anybody know about this, or a org-function doing it?


I would recommend checking the R documentation. 
 #+begin_src R :colnames t :var t1=TC :results output
  ?quantile
 #+end_src

 #+tblname: TC
 | Data |
 |--|
 |5 |
 |   10 |
 |   12 |
 |   15 |
 |   20 |
 |   24 |
 |   27 |
 |   30 |
 |   35 |

Consider also the R mailing list r-h...@r-project.org. The community is
quite active. 

I believe that you might be looking for the following.

 #+begin_src R :colnames t :var t1=TC 
  quantile(t1$Data,c(1/3,2/3,1))
 #+end_src

 #+RESULTS:
 |  x |
 ||
 | 14 |
 | 25 |
 | 35 |


HTH,

Jeremie 



Re: Bug: ob-R.el breaks when :session is specified

2022-05-15 Thread Jeremie Juste


Hello Christian

On Sunday, 15 May 2022 at 20:06, Christian Heinrich wrote:
> I just tested with
>
>  Org mode version 9.5.3 (release_9.5.3-504-gcdbb1c @
> /home/heinrich/.emacs.d/straight/repos/org/lisp/)
>
> using
>
> GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo 
> version 1.16.0) of 2021-
> 11-27, modified by Debian


Many thanks for reporting back.  I updated to gcdbb1c and it is still working 
fine.

My minimum working example is the following. From the org-mode root directory,

$ emacs -Q -L ./lisp -l org  -l ~/ess-barebone.el

where ~/ess-barebone.el is the following:

#+begin_src  elisp
(add-to-list 'load-path "/home/djj/.emacs.d/elpa/ess-20220125.2207/")
(require 'ess-r-mode)

 (org-babel-do-load-languages
   'org-babel-load-languages
   '((R . t)))

(setq org-confirm-babel-evaluate nil)
#+end_src

Note that I'm still using a rather old ess version. Could you please try
with the above configuration? Note that I am using a rather old ess
version but the I haven't experienced issues with the newer one.

Best regards
Jeremie


> Hi Jeremie,
>
> I just tested with
>
>  Org mode version 9.5.3 (release_9.5.3-504-gcdbb1c @
> /home/heinrich/.emacs.d/straight/repos/org/lisp/)
>
> using
>
> GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo 
> version 1.16.0) of 2021-
> 11-27, modified by Debian
>
> I am on Debian Testing and that is the default emacs version.
>
> Using the unmodified org (git hash from above) I get the following messages 
> when executing a src
> block with R:
>
>executing R code block...
>Loading ‘ess-bugs-l’: unescaped character literals `?(', `?)' detected, 
> `?\(', `?\)' expected!
>Type C-h m for help on ESS version 15.09
>ess-tracebug mode enabled
>Quit
>Package cl is deprecated
>
> Note that the "Quit" is me pressing Ctrl-g after a few seconds.
>
> Removing the commit in question makes the block return instantaneously:
>
>executing R code block...
>Loading ‘ess-bugs-l’: unescaped character literals `?(', `?)' detected, 
> `?\(', `?\)' expected!
>Type C-h m for help on ESS version 15.09
>ess-tracebug mode enabled
>Code block evaluation complete.
>Package cl is deprecated
>
> I anticipated that this would not be obvious, since this feature is used too 
> much to go unnoticed for
> two years - but I am clueless as to how I should continue with debugging...
>
> Thanks for your help!
> Christian
>
> On Sun, 2022-05-15 at 16:16 +0200, Jeremie Juste wrote:
>> 
>> Hello Christian,
>> 
>> Thanks for reporting but I cannot reproduce the bug with the org and
>> emacs version below.
>> 
>> Org mode version 9.5.3 (release_9.5.3-467-g2bd34e @
>> /home/djj/src/org-mode/lisp/)
>> GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24) of
>> 2022-01-16
>> 
>> Can you please let me know which version of org-mode you are actually
>> using?
>> 
>> Ihor, many thanks for checking.
>> 
>> Best regards,
>> Jeremie
>> 
>> On Sunday, 15 May 2022 at 16:08, Ihor Radchenko wrote:
>> > Christian Heinrich  writes:
>> > 
>> > > I got back to an org file after upgrading to the latest release of 
>> > > org-mode and tried
>> > > executing the
>> > > contained R source blocks. Unfortunately, emacs got stuck in the 
>> > > execution and was blocked; I
>> > > had to
>> > > exit using C-g.
>> > > 
>> > > Here's a minimal example src block that causes emacs to get stuck:
>> > > 
>> > > #+begin_src R :results output :session *R* :exports both
>> > >   a <- 10
>> > >   a
>> > > #+end_src
>> > > 
>> > > R itself does start and the code is also executed correctly. However, 
>> > > the output from that
>> > > session
>> > > is apparently not returned to emacs or the buffer.
>> > 
>> > I tried you example using Emacs >=26 and it works just fine.
>> > 
>> > Best,
>> > Ihor



Re: Bug: ob-R.el breaks when :session is specified

2022-05-15 Thread Jeremie Juste


Hello Christian,

Thanks for reporting but I cannot reproduce the bug with the org and
emacs version below.

Org mode version 9.5.3 (release_9.5.3-467-g2bd34e @
/home/djj/src/org-mode/lisp/)
GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24) of
2022-01-16

Can you please let me know which version of org-mode you are actually
using?

Ihor, many thanks for checking.

Best regards,
Jeremie

On Sunday, 15 May 2022 at 16:08, Ihor Radchenko wrote:
> Christian Heinrich  writes:
>
>> I got back to an org file after upgrading to the latest release of org-mode 
>> and tried executing the
>> contained R source blocks. Unfortunately, emacs got stuck in the execution 
>> and was blocked; I had to
>> exit using C-g.
>>
>> Here's a minimal example src block that causes emacs to get stuck:
>>
>> #+begin_src R :results output :session *R* :exports both
>>   a <- 10
>>   a
>> #+end_src
>>
>> R itself does start and the code is also executed correctly. However, the 
>> output from that session
>> is apparently not returned to emacs or the buffer.
>
> I tried you example using Emacs >=26 and it works just fine.
>
> Best,
> Ihor



Re: source block evaluation in #+DATE line

2022-05-10 Thread Jeremie Juste
Hello Andreas,


On Tuesday, 10 May 2022 at 13:50, Andreas Leha wrote:
> Hi all,
>
> how can I have a source block result in a #+Date line?
>
> I am creating a beamer presentation.  While the code works and the
> results get exported nicely at any other position, in the #+Date line
> only the code is exported.



> #+DATE:  Only Code Exported: src_sh[:exports results :results
> output wrap replace]{date}

I'm not sure I undersand, why you would want to use the shell to specify
a date. Could you please explain? Are you looking for a particular date
format?

The example below, taken from the org documentation produces the current
date when exported to BEAMER.

#+TITLE: Example Presentation
#+AUTHOR: Carsten Dominik
#+OPTIONS: H:2 toc:t num:t
#+LATEX_CLASS: beamer
#+LATEX_CLASS_OPTIONS: [presentation]
#+BEAMER_THEME: Madrid
#+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col)

* This is the first structural section

** Frame 1
*** Thanks to Eric Fraga   :B_block:
:PROPERTIES:
:BEAMER_COL: 0.48
:BEAMER_ENV: block
:END:
for the first viable Beamer setup in Org
*** Thanks to everyone else:B_block:
:PROPERTIES:
:BEAMER_COL: 0.48
:BEAMER_ACT: <2->
:BEAMER_ENV: block
:END:
for contributing to the discussion
 This will be formatted as a beamer note   :B_note:
 :PROPERTIES:
 :BEAMER_env: note
 :END:
** Frame 2 (where we will not use columns)
*** Request
    Please test this stuff!


HTH,
Jeremie



Re: How to export to markdown programmatically without the table of contents?

2022-05-03 Thread Jeremie Juste
Hello Karl,

On Tuesday,  3 May 2022 at 11:15, Karl Voit wrote:
>
> I tried this neat code snippet today with Emacs 26.3 and Org-mode
> 9.1.9 and I got an error:
>
> | org-export-barf-if-invalid-backend: Unknown "nil" back-end: Aborting export
>
> When I execute the following code, I get the same error:
> | (setq region "/foo/ *bar* https://example.com baz")
> | (org-export-string-as region 'md t '(:with-toc nil))
>
> Could it be that I don't have "md" as backend somehow? Is there a
> hidden requirement?

with
$ emacs -Q -L ./lisp -l org /tmp/test.org

then C-c C-e, I don't have markdown in the default export options.

tested with, Org mode version 9.5.3 (release_9.5.3-467-g2bd34e @
/home/djj/src/org-mode/lisp/).

And I still work with (require 'ox-md).

Best regards,
Jeremie



Re: org-startup-folded does not work with directory local variables

2022-05-03 Thread Jeremie Juste
Hello Max,


On Tuesday,  3 May 2022 at 00:37, Max Fujimoto wrote:
> Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo
> version 1.17.6)


I must apologise for, I haven't made the jump to emacs 28 yet:  GNU Emacs 27.2 
(build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.24) of 2022-01-16.

I'm on the following version of Org mode version 9.5.3 
(release_9.5.3-467-g2bd34e @ /home/djj/src/org-mode/lisp/)

and I don't know where is .dir-locals.el.

but, with the following unfoled file /tmp/test.org

* Some Heading Title [0/2] 
** TODO Some Todo Item
** TODO heading 3


the following command

$ emacs -Q -L ./lisp -l org   --eval "(setq org-startup-folded t)"
/tmp/test.org

Produces your desired results

* Some Heading Title [0/2] ...


HTH,
Jeremie



Re: How to export to markdown programmatically without the table of contents?

2022-05-01 Thread Jeremie Juste
Hello Chuck,

> On Sunday,  1 May 2022 at 20:01, Berry, Charles wrote:
> It does seem odd that BODY-ONLY as `t' gives a toc. With latex it does not 
> regardless of `:with-toc'.
>
> : (org-export-string-as my-string 'md t '(:with-toc nil))
>
> seems to give what you want.

Many thanks for the insights.

I know where to look now:

(info "(org) Publishing options")

Best regards,
Jeremie



Re: How to export to markdown programmatically without the table of contents?

2022-05-01 Thread Jeremie Juste
Hello Marcin,

On Sunday,  1 May 2022 at 11:20, Marcin Borkowski wrote:

| Optional argument EXT-PLIST, when provided, is a property list
| with external parameters overriding Org default settings, but
| still inferior to file-local settings.

Sorry I don't fully understand what doc means by overriding the Org
default settings.

However I the toc can be removed in this way. 

(org-export-string-as "#+OPTIONS: toc:nil \n\n* test\n1"
'md)

HTH,
Jeremie Juste




Re: processing of babel blocks and select_tags

2022-02-18 Thread Jeremie Juste
Hello Eric,

On Friday, 18 Feb 2022 at 11:57, Eric S Fraga wrote:
> TL;DR: can I have org completely ignore src blocks in non-selected
> sections during export without using COMMENT?

If I change eval: no_export to :eval no, Only the =Description= section
is evaluated and exported. That said, I have often search in vain of a way of
using tags to prevent evaualtion of code chuck. I have resorted to use
either property at the heading or file level to control the execution
of code chunks.

 ** Subheading
   :PROPERTIES:
   :header-args:julia::eval no
   :END:



Another option would be to store what is needed in as a variable in a
session and use =:eval no= before exporting, but it might not be very
practical for a book.

I have a small helper function that toggle eval yes or no at the file
level, if it is of any help.

HTH,

Jeremie

* toggle eval yes.

(defun toggle-global-eval ()
  "toggle :eval yes :evalno  "
  (interactive)
  (save-excursion
  (beginning-of-buffer)
  (search-forward-regexp ":eval ")
  (kill-word 1)
  (setq wd (car kill-ring))
  (if (equal "yes" wd)  
 (insert "no")
  (insert  "yes"))
  (org-ctrl-c-ctrl-c))
  (save-buffer)
  (message "global :eval was %s" wd)
  )




* file tag.org
#+title: org babel and select tags
#+select_tags: current

* Introduction
This section has some code that should not be evaluated on export.

#+name: introblock
#+begin_src julia :eval no
  a = [1, 2, 3]
#+end_src

* Description  :current:
I am writing this section right now.

* Conclusions
This will be worked on later.
#+name: conclusionblock
#+begin_src julia :eval no
  a = [4, 5, 6]
#+end_src





Re: Bug with exporting list with link item containing "::" to markdown

2022-02-13 Thread Jeremie Juste
Hello Cash,

Many thanks for reporting but I cannot reproduce the error with my current
version of emacs and org-mode. Could you specify the version of org-mode
and emacs you are currently using?

* test
:PROPERTIES:
:ID:   cbce567a-861c-4d9b-8b2f-5933afadb864
:END:

[[id:cbce567a-861c-4d9b-8b2f-5933afadb864][ryans01 :: No Zero Days]]

is exported as

# Table of Contents

1.  [test](#org7d47e12)




# test

[ryans01 :: No Zero Days](#org7d47e12)


Hope this helps,
Jeremie

Org mode version 9.5 (release_9.5-142-g0ef88e)
GNU Emacs 27.2 



Re: R terminal output does not match src block output due to ">" character in results

2022-01-16 Thread Jeremie Juste
Hello John,

As promised, I'm coming back about the formatting of  NA_characters_.
In org-mode 9.5 NA_characters_ are not printed anymore with :results
value. See example 2 and 3 for more details. Please let me know if
this post solves your issues. Woudl updating to 9.5 be an option for
you?

Best regards,
Jeremie



#+BEGIN_SRC elisp
   (org-version)
  #+END_SRC

  #+RESULTS:
  : 9.5
  
#+BEGIN_SRC elisp
  (emacs-version)
#+end_src

#+RESULTS:
: GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24)
:  of 2021-11-26

* Example 1
#+BEGIN_SRC R :results output
data.frame(abc=NA_character_)
#+end_src

#+RESULTS:
:abc
: 1 

* Example 2
#+BEGIN_SRC R :results value 
a <- data.frame(column1=NA_character_,column2=1:10)
#+end_src

#+RESULTS:
|   |  1 |
|   |  2 |
|   |  3 |
|   |  4 |
|   |  5 |
|   |  6 |
|   |  7 |
|   |  8 |
|   |  9 |
|   | 10 |


* Example 3
#+BEGIN_SRC R :results value :colnames yes
library(RSQLite)
con <- dbConnect(RSQLite::SQLite(), ":memory:")

dbWriteTable(con, "df", data.frame(column1=NA_character_,column2=1:10))
dbGetQuery(con, "SELECT * FROM df")
#+end_src

#+RESULTS:
| column1 | column2 |
|-+-|
| |   1 |
| |   2 |
| |   3 |
| |   4 |
| |   5 |
| |   6 |
| |   7 |
| |   8 |
| |   9 |
| |  10 |





Re: Help debugging R source code block output problem with :session

2022-01-11 Thread Jeremie Juste
Hello John,

Many thanks for reporting.  I'm short of time right now, but I'll take a closer 
look at the problem over
the weekend and keep you posted. Could you let me know which version of
org-mode you are currently using?

Best regards,
Jeremie Juste


On Tuesday, 11 Jan 2022 at 17:36, John Hendy wrote:
> Greetings,
>
> Apologies for writing off-list, but I don't have the original thread
> anymore to reply to. I just pulled this group in directly from the
> email I found... I just got bitten by this as well and burned most of
> my afternoon trying to figure out what the issue was.
>
> Any further thoughts on a patch that could be finalized/applied?
>
> Is the one from the thread still the best from your continued experience?
> https://list.orgmode.org/87zgxc42qg@gmail.com/
>
> This r/orgmode post was what finally got me to the existence of this
> as a previous issue (I'd just sent my own email to list as my
> searching did not find the above):
> https://www.reddit.com/r/orgmode/comments/pt3em4/source_block_modifying_format_of_results_r/
>
> And it links to a patch as well:
> https://gist.github.com/gtuckerkellogg/e356d20497cfdc8e4fc683412e320e3e
>
> Many thanks,
> John



[forged] Re: from 0ef88e2d9 make generates error

2021-10-17 Thread Jeremie Juste
Hello,

False alert. I missed texinfo on my system. Many thanks Ihor,
for the lead.

Best regards
Jeremie



Re: "begin_src R :session" opens R session when file first visited

2021-10-17 Thread Jeremie Juste
Hello William,

Many thanks for reporting your issue and many thanks to Greg for testing.

Sorry, I cannot reproduce the issue either. I don't think it is related
to async. Could you try with 'emacs -Q'?


my minimal configuration is along with emacs -Q is the following:

#+begin_src elisp
(add-to-list 'load-path (expand-file-name "~/src/gnu/org-mode/lisp") t)
(require 'org)
(add-to-list 'load-path "/home/djj/.emacs.d/elpa/ess-20200825.829")
#+end_src

My ess-version is starting to date. I'm still on ess-version: 18.10.3snapshot 
[elpa: 20200825.829], but I'm not aware of
any breaking changes in ESS.


Best regards,
Jeremie



On Sunday, 17 Oct 2021 at 06:06, Greg Minshall wrote:
> Bill,
>
>> I run Org from the source tree, and recently (a couple of weeks ago or
>> so) something new started happening with my Org files with R source
>> blocks:  when I open one up, an R session automatically starts,
>> without me doing anything.
>
> i don't see that behavior.  does it do this for 'emacs -Q' (suitably
> tailored to load org mode, set `org-babel-load-languages`, etc.)?
>
> cheers, Greg



from 0ef88e2d9 make generates error

2021-10-17 Thread Jeremie Juste
Hello,

I just tried make on 0ef88e2d9 and got the following error.

org-version: 9.5 (release_9.5-142-g0ef88e)
makeinfo --no-split org.texi -o org.info
make[1]: makeinfo: No such file or directory
make[1]: *** [Makefile:72: org] Error 127
make[1]: Leaving directory '/home/djj/src/gnu/org-mode/doc'
make: *** [mk/targets.mk:127: info] Error 2


Best regards,
Jeremie



[PATCH] ob-R async evaluation

2021-10-05 Thread Jeremie Juste
Hello,

I'm attaching a patch that clean up a bit of non conventional coding
practices (mainly because of my ignorance), in ob-R. These were
initially generating warning during the compilation of org-mode.

The main feature is the use of the defvaralias ess-eval-visibly-p when
the :result output in async evaluation. 

With this change make does not generate any warning for ob-R.el and all
the test of ob-R.el passes, so no significant change for the user.

Best regards,
Jeremie



0001-ob-R.el-Patch-4-async-evaluation.patch
Description: Adobe PDF document


Re: [PATCH] async process in R

2021-09-28 Thread Jeremie Juste
Hello Chuck,

> OK. The patch works when applied on top of the previous 2 (but the second one 
> has the same name, so there is that to watch out for).
Thanks for the feedback, I'll make sure to provide unique names for
patches in the future.
>
> However, I think we are not quite home free. With `:async no', this works as 
> expected:
>
> #+begin_src R :session *R*  :results output :async no
>   Sys.sleep(2)
>   1:5
>   10:
> a
>   1:2
> #+end_src
>
> #+RESULTS:
> : 
> : [1] 1 2 3 4 5
> : 
> : Error: object 'a' not found
> : 
> : [1] 1 2
>
> But changing to `:async yes', the error aborts in a way that omits the output.

Interesting, I haven't thought about errors cases enough. Async process
will be on the 9.5 release and this issue will be next on the todo list.
Many thanks again for the feedback.


It does help,

Jeremie



Re: [PATCH] async process in R

2021-09-28 Thread Jeremie Juste
Hello Chuck,

On Monday, 27 Sep 2021 at 23:40, Berry, Charles wrote:
> Jeremie,
>
>> On Sep 27, 2021, at 3:56 PM, Berry, Charles  wrote:
>> 
>> There is something in my init that doesn't play nice with this.  
>
> (setq ess-inject-source nil)

Thanks for the feedback. With the following patch, I made sure that
ess-inject-source is set to default before evaluating the buffer.

So even if I set
(setq ess-inject-source 'function-and-buffer), I get the following
output. Note that I get the same output in the IESS console buffer when
I execute the command following command.

#+begin_src R :session *R*  :results output :async yes
  Sys.sleep(2)
  1:5

  10:20
  1:2
#+end_src

#+RESULTS:
: [1] 1 2 3 4 5
:  [1] 10 11 12 13 14 15 16 17 18 19 20
: [1] 1 2

It might be good to fix this on the ESS side. I'll see what can be
done, but I'd appreciate any input you might have on this. Thanks again.

Best regards,
Jeremie

>From db2ad631247a5c52d9d6f6779948f6d0cf34c698 Mon Sep 17 00:00:00 2001
From: Jeremie Juste 
Date: Tue, 28 Sep 2021 09:04:25 +0200
Subject: [PATCH] ob-R.el: Patch async evaluation when :results output

* lisp/ob-R.el (ob-session-async-org-babel-R-evaluate-session): Make
sure that `ess-inject-source' is set to the default
'function-and-buffer before running (ess-eval-buffer). Return
`ess-inject-source' to its user-specified state afterwards.
---
 lisp/ob-R.el | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index 188b9ac8f..7e050c094 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -528,9 +528,13 @@ by `org-babel-comint-async-filter'."
  (insert (format ob-session-async-R-indicator
 			 "end" uuid))
  (setq tmp ess-eval-visibly)
+ (setq user-inject-src-param ess-inject-source)
  (setq ess-eval-visibly nil)
+ (setq  ess-inject-source 'function-and-buffer)
  (ess-eval-buffer nil))
- (setq ess-eval-visibly tmp)
+   (setq ess-eval-visibly tmp)
+   (setq ess-inject-source user-inject-src-param)
+   
uuid
 
 (defun ob-session-async-R-value-callback (params tmp-file)
-- 
2.30.2



Re: [PATCH] async process in R

2021-09-27 Thread Jeremie Juste
Hello Chuck,

On Monday, 27 Sep 2021 at 18:28, Berry, Charles wrote:
>
> It looks like you have `(setq ess-eval-visibly t)' here. I think that is a 
> default setting.

Thanks again for your suggestion. The following patch to be applied on
top of the previous one, solves the issue.


#+begin_src R :session *R*  :results output :async yes
Sys.sleep(5)
1:5
#+end_src

#+RESULTS:
: [1] 1 2 3 4 5


The function (ess-eval-buffer), when the parameter VIS is nil,  misled me in 
the sense that it inverses
the value of ess-eval-visibly.

Note as well that all the tests in test-ob-R.el passed including the
tests for async evaluation from [1] ob-session-async.

[1]: https://github.com/jackkamm/ob-session-async/.

>From 795cc0ebe637aa4ff148c495cf5403ba2baec242 Mon Sep 17 00:00:00 2001
From: Jeremie Juste 
Date: Mon, 27 Sep 2021 22:02:17 +0200
Subject: [PATCH] ob-R.el: Patch async evaluation when :results output

* lisp/ob-R.el (ob-session-async-org-babel-R-evaluate-session): Make
sure that 'ess-eval-visibly' is nil before evaluating the temporary
buffer, but return ess-eval-visibly to it's original state afterwards.
---
 lisp/ob-R.el | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index 299ccdf1d..188b9ac8f 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -526,8 +526,11 @@ by `org-babel-comint-async-filter'."
  (insert body)
  (insert "\n")
  (insert (format ob-session-async-R-indicator
-	  "end" uuid))
+			 "end" uuid))
+ (setq tmp ess-eval-visibly)
+ (setq ess-eval-visibly nil)
  (ess-eval-buffer nil))
+ (setq ess-eval-visibly tmp)
uuid
 
 (defun ob-session-async-R-value-callback (params tmp-file)
-- 
2.30.2


Thanks again to Jack for this useful feature.

Best regards,
Jeremie


Re: [PATCH] async process in R

2021-09-27 Thread Jeremie Juste
Hello Chuck,

On Monday, 27 Sep 2021 at 18:28, Berry, Charles wrote:
>
> It looks like you have `(setq ess-eval-visibly t)' here. I think that is a 
> default setting.
>

Many thanks for the feedback.
>
> which is better, but the prompts still need cleaning along the lines of 
> `org-babel-R-evaluate-session'.
>
> It seems like this is an ob-R.el issue.

I'll look deeper into ob-R.el

Best regards,
Jeremie



Re: [PATCH] async process in R

2021-09-27 Thread Jeremie Juste
Hello,

On Monday, 27 Sep 2021 at 08:48, Bastien wrote:
> Hi Greg and Jeremie,
>
> Greg Minshall  writes:
>
>> if this is not already idiomatic for org mode, i'd vote to require the
>> "yes" or "no".  just my 2 cents.
>
> Agreed: even if a syntax is allowed, let's use the idiomatic form in
> examples.

Many thanks for the feedback, I'll keep that in mind and use the idomatic
form in examples.

For the parameter  :async without any values assigned to it. I'm
coordinating with ob-python.el and the orginal package
https://github.com/jackkamm/ob-session-async.

Jack do you see the need to change it and expect :async to have the
value yes or no?

Best regards,
Jeremie











Re: [PATCH] async process in R

2021-09-26 Thread Jeremie Juste
Hello Greg,
>
> i was surprised by =:async= standing alone, i.e., with no following
> "yes" or "no".  is that an org-mode "idiom"?  i.e., unadorned header
> arguments default to (some form of) "yes"?

Many thanks for the feedback, assigning yes or no to async will work as 
expected.

#+begin_src R :session *R* :results value :async yes :colnames yes
Sys.sleep(10)
as.list(1:5)
#+end_src

No async process in R

#+begin_src R :session *R* :results value :async no :colnames yes
Sys.sleep(10)
as.list(1:5)
#+end_src

:async without parameters will default to yes.

#+begin_src R :session *R* :results value :async :colnames yes
Sys.sleep(10)
as.list(1:5)
#+end_src

I am not sure if it is a desirable feature or not. 

Best regards,
Jeremie






[PATCH] async process in R

2021-09-26 Thread Jeremie Juste
Hello,

I have integrated some of the ob-session-async package in ob-R.el
(finally). Most of the heavy lifting has been made by Jack.


So with the patch async evaluation is  expected to work out of the box
for :result value

#+begin_src R :session *R*  :results value :async :colnames yes
Sys.sleep(10)
as.list(1:5)
#+end_src

#+RESULTS:
| x |
|---|
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |

But for the time being result output produces the following output.

#+begin_src R :session *R*  :results output :async
Sys.sleep(1)
print(1:5)
#+end_src

#+RESULTS:
: > Sys.sleep(1)
: > print(1:5)
: [1] 1 2 3 4 5
: > 'ob_comint_async_R_end_53c0a42fed17cf78f5508e5293029430'


>From my understanding the async command of python does not suffer from
this issue. I'm not sure if the issue needs to be solve at the ob-R.el
or at the ob-core.el. I welcome any comments on this patch or any idea
to move it forward.

Best regards,
Jeremie

>From 51e1efb75e15fab348fd5a2c8b5fb5c1dbbf4d1c Mon Sep 17 00:00:00 2001
From: Jeremie Juste 
Date: Sun, 26 Sep 2021 18:25:23 +0200
Subject: [PATCH] lisp/ob-R: Async evaluation in R

* lisp/ob-R.el `ob-session-async-R-indicator': Add constant
representing a prefix R to identity session.
(ob-session-async-org-babel-R-evaluate-session):New
function to evaluate R src block
asynchrously.  (ob-session-async-R-value-callback): New function that
callback the result of the asynchronous evaluation.
(org-babel-R-evaluate): Add `async' parameter and call
ob-session-async-org-babel-R-evaluate-session if `async' parameter is
present.  (org-babel-execute:R): Call (org-babel-comint-use-async) to
check if async is among `params' and add async parameter to (org-babel-R-evaluate).

* testing/lisp/test-ob-R.el: Add 7 more tests for async evaluations,
also taken from ob-session-async package.

This is almost a carbon copy of the package of ob-session-async
of Jack Kamm. The original source code can be found
https://github.com/jackkamm/ob-session-async

Please refer to the following thread to trace back the discussion on
async evaluation in R.
https://list.orgmode.org/87eed9g9p6@gmail.com/
---
 lisp/ob-R.el  | 90 +++--
 testing/lisp/test-ob-R.el | 94 +++
 2 files changed, 181 insertions(+), 3 deletions(-)

diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index 2d9073cee..299ccdf1d 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -158,6 +158,7 @@ This function is called by `org-babel-execute-src-block'."
   (save-excursion
 (let* ((result-params (cdr (assq :result-params params)))
 	   (result-type (cdr (assq :result-type params)))
+   (async (org-babel-comint-use-async params))
(session (org-babel-R-initiate-session
 		 (cdr (assq :session params)) params))
 	   (graphics-file (and (member "graphics" (assq :result-params params))
@@ -184,7 +185,8 @@ This function is called by `org-babel-execute-src-block'."
 		  (cdr (assq :colname-names params)) colnames-p))
 	 (or (equal "yes" rownames-p)
 		 (org-babel-pick-name
-		  (cdr (assq :rowname-names params)) rownames-p)
+		  (cdr (assq :rowname-names params)) rownames-p))
+ async)))
   (if graphics-file nil result
 
 (defun org-babel-prep-session:R (session params)
@@ -371,11 +373,14 @@ Has four %s escapes to be filled in:
 4. The name of the file to write to")
 
 (defun org-babel-R-evaluate
-  (session body result-type result-params column-names-p row-names-p)
+  (session body result-type result-params column-names-p row-names-p async)
   "Evaluate R code in BODY."
   (if session
+  (if async
+  (ob-session-async-org-babel-R-evaluate-session
+   session body result-type result-params column-names-p row-names-p)
   (org-babel-R-evaluate-session
-   session body result-type result-params column-names-p row-names-p)
+   session body result-type result-params column-names-p row-names-p))
 (org-babel-R-evaluate-external-process
  body result-type result-params column-names-p row-names-p)))
 
@@ -468,6 +473,85 @@ Insert hline if column names in output have been requested."
 	(error "Could not parse R result"))
 result))
 
+
+;;; async evaluation
+
+(defconst ob-session-async-R-indicator "'ob_comint_async_R_%s_%s'")
+
+(defun ob-session-async-org-babel-R-evaluate-session
+(session body result-type result-params column-names-p row-names-p)
+  "Asynchronously evaluate BODY in SESSION.
+Returns a placeholder string for insertion, to later be replaced
+by `org-babel-comint-async-filter'."
+  (org-babel-comint-async-register
+   session (current-buffer)
+   "^\\(?:[>.+] \\)*\\[1\\] \"ob_comint_async_R_\\(.+?\\)_\\(.+\\)\"$"
+   'org-babel-chomp
+   'ob-session-async-R-value-callback)
+  (cl-case result-type
+(value
+ (let ((tmp-file (org-babel-temp-file "R-")))
+   (with-temp-bu

Re: [PATCH] ob-R output file with graphics parameter

2021-09-26 Thread Jeremie Juste
Hello Bastien,

On Sunday, 26 Sep 2021 at 10:48, Bastien wrote:
> What is the status of this patch?  Should it be more tested?  If it is
> ready, feel free to apply it in the main branch.

The patch is redundant in its present state. In it's present state,
ob-R is better without it.

Thanks,
Jeremie




Re: Bug: unexpected behavior of nesting braces when exporting to LaTeX

2021-08-22 Thread Jeremie Juste
Hello Yue,

Posting your mail below back to the list where you have a better chance
of getting the right explanation. I totally understand that many times
copy directly latex chunk is a nice feature org-mode offers.

>From your example below, exporting the following script to latex would
work ok in org-mode.

#+BEGIN_SRC org
#+options: toc:nil
#+LATEX_HEADER: \usepackage{amsthm}
#+LATEX_HEADER:\theoremstyle{theorem}
#+LATEX_HEADER: \newtheorem{theorem}{Theorem}\usepackage{setspace}
#+end_src

* Theorem

 The longest word in this sentence is \emph{emphasized}.
 \begin{theorem}
   An emphasized a word looks \emph{distinguished}.
 \end{theorem}

Yes, for my part I usually wrap into a source block, if I need native
latex syntax

#+BEGIN_SRC latex
\emph{{n+1}-a}
\textit{a{b}c}
#+end_src

I don't know if it is the case by design or if it is a bug.

HTH,
Jeremie


On Sunday, 22 Aug 2021 at 09:03, Chlo De wrote:
> Hello Jeremie,
>
> Thank you for your reply. 
>
> As both \emph and \textit are commonly used LaTeX commands, I would
> expect everything inside the braces be interpreted in LaTeX way, i.e.,
> plain { }  are for semantic use only and are omitted in the output.
>
> I appreciate that you mentioned native org-syntax. There are two reasons
> that I prefer the LaTeX way. 
> - I sometimes need to copy large chunk of tex contents from my other
> notes or papers. It would be easier if I don’t need to convert them one
> by one, as it is hard to spot such a thing in a long document.
> - \emph is not exactly \textbf or \textit. With its default definition,
> in text, \emph behaves like \textit. However, in an environment where the
> text is italic by default, say, theorem, \emph will turn the text into
> normal font. Here is a minimal example.
> \documentclass{article}
> \usepackage{amsthm}
> \theoremstyle{theorem}
> \newtheorem{theorem}{Theorem}
>
> \begin{document}
>  The longest word in this sentence is \emph{emphasized}.
>  \begin{theorem}
>An emphasized a word looks \emph{distinguished}.
>  \end{theorem}
> \end{document}
>
> The output is
>
> [cid]
>
> Besides, this question seems related 
> https://emacs.stackexchange.com/questions/52510/not-scape-braces-in-latex-org-mode
>
> Best,
> Yue
>
> On Aug 22, 2021, at 03:27, Jeremie Juste 
> wrote:
>
> Hello Yue,
>
> On Friday, 20 Aug 2021 at 00:45, Chlo De wrote:
>
> \emph{{n+1}-a}
> \textit{a{b}c}
>
> will be translated as LaTeX expressions
>
> \emph\{\{n+1\}-a\}
> \textit\{a\{b\}c\}
>
> I'm not sure it is a bug. Could you specify what do you expect in
> these
> cases?
>
> Note that there are native org-syntax for \emph and \textbf
>
> *n+1 - a*
> /a{b}c/
>
> (info "(org) Emphasis and Monospace")
>
> HTH,
> --
> Jeremie Juste
>

-- 
Jeremie Juste



Re: Bug: unexpected behavior of nesting braces when exporting to LaTeX

2021-08-22 Thread Jeremie Juste


Hello Yue,


On Friday, 20 Aug 2021 at 00:45, Chlo De wrote:

> \emph{{n+1}-a}
> \textit{a{b}c}
>
> will be translated as LaTeX expressions
>
> \emph\{\{n+1\}-a\}
> \textit\{a\{b\}c\}

I'm not sure it is a bug. Could you specify what do you expect in these
cases?


Note that there are native org-syntax for \emph and \textbf

*n+1 - a* 
/a{b}c/

(info "(org) Emphasis and Monospace")

HTH,
-- 
Jeremie Juste



Re: Number format for table results outut from R data.frame/tibble

2021-08-21 Thread Jeremie Juste


Hello, John

For my workflow, I generally use the minimum from xtable and do the
formatting in org-mode using the :post parameter to call another lisp code
block.


That said, as Chuck said, you can go a long way with xtable. In my
attic, I found the following code where I take only the core data from
xtable and do formatting in org-mode. This code may be a little
extravagant on the latex side but, it shows the possibilities.

HTH,

Jeremie

#+LATEX_HEADER: \usepackage{booktabs}
#+LATEX_HEADER: \usepackage{array}
#+LATEX_HEADER: \usepackage{setspace}
#+LATEX_HEADER: \usepackage{dcolumn}
#+LATEX_HEADER: \usepackage{array}
#+LATEX_HEADER: \usepackage{setspace}
#+LATEX_HEADER:\usepackage{longtable,tabularx,ltablex}
#+LATEX_HEADER:\usepackage{siunitx}
#+LATEX_HEADER:\usepackage[flushleft]{threeparttablex}


#+Name: add-table-env
#+BEGIN_SRC emacs-lisp :var  table="TABLE" notes="NOTES" caption="CAPTION" 
:results silent :exports none
(replace-regexp-in-string 
"begin{tabular}.*\\S.*\\toprule\\|end{tabular}" "" 
(format "\\scriptsize{
\\begin{center}
\\begin{TableNotes}\\footnotesize
 \\item[\\hspace{-\\fontdimen2\\font}]   
%s
\\end{TableNotes}
\\begin{ThreePartTable}
 \\sisetup{table-format=-2.3, table-space-text-post=***, 
table-number-alignment=center}
\\keepXColumns
\\begin{tabularx}{\\textwidth}{l *{3}{D..{5.3}}}
\\caption{%s} 
\\toprule
\\toprule
\\multicolumn{1}{c}{colnum 1} &\\multicolumn{1}{c}{colnum 2}   
  \\cmidrule(lr){1-1}  \\cmidrule(lr){2-2}  

%s
\\insertTableNotes
\\end{tabularx}
\\end{ThreePartTable}
\\end{center}
}
\\pagebreak
" notes caption table))
 #+END_SRC




#+begin_src R :session foo :results output latex :post add-table-env(*this*, 
"Some note", "A caption" ) :exports results
  library(tibble)
  library(xtable)
  tmp <- tibble(x=1:5, y=x/pi)
  print.xtable(xtable(tmp),
   include.colnames=FALSE,include.rownames=FALSE,floating=FALSE,
   comment = FALSE,dcolumn=TRUE,booktabs=TRUE
  ,sanitize.text.function = function(x) {
x[x=="NA"] <-""
x})
#+end_src




Re: [PATCH] ob-R output file with graphics parameter

2021-07-10 Thread Jeremie Juste


Re: [PATCH] ob-R output file with graphics parameter

2021-07-03 Thread Jeremie Juste
Hello Jack,

Many thanks for the feed back

On Friday,  2 Jul 2021 at 21:21, Jack Kamm wrote:
> Hi Jeremie,
>
>>> The requirement for a second file parameter was added in Org 9.3 to
>>> support the use case in this thread:
>>>
>>> https://orgmode.org/list/3ac2f42a-8ff2-1464-fa36-451e2ef0e...@pressure.to/
>>>
>>> But this syntax is annoyingly verbose for ob-R users, and also broke
>>> lots of ob-R examples prior to Org 9.3.
>>>
>>> A simple fix might be to have the "graphics" flag implicitly add the
>>> "file" flag as well. But we would need to first check that this doesn't
>>> break other use cases.
>>
>> I do agree with this solution. If the current specification works, we
>> could make it easy for ob-R user by implicitly adding a file flag. But
>> as far as I understand, the change will have to be made in ob-core.el.
>
> Hmm, I think you're right -- this would have to be done in ob-core.el.
>From what I understand, the document has grown in complexity and
it is a bit complicated to generate graphics.

I unfortunately cannot measure fully the impact of the change other
client of the :graphics, :file parameters.

I see that the source of the difficulty is that ob-core is handling too
much. I remember a time where we had only  output, graphics, value, and
raw, for the output, and the we file-ext came, this was still fine, the
second file parameter might be telling that we are over heating
ob-core.el and it will become difficult for it to satisfy all its
clients at some point.

A way out of this might be for ob-core to delegate more to the
respective ob-*.el. It will be duplicated work in some cases but each
maintainer would find it easier to add and remove stuffs without having
to consider the effect of the change on other ob-*.el.

Regarding ob-R.el most of the job was done there already, in fact with
the second :file parameter, I believe that the file handling was removed from
ob-R.el.

So what can ob-core delegate more to it's clients?

Regarding the documentation, it might be good that we have a small case
for each ob-*.el. When a user is looking how to produce graph with
python or R, asymptote or shell might not be very telling for them and the
:graphics parameter has a src shell as an example. This might be a killer for
the new user.

#+begin_src shell :results file link :file "download.tar.gz"
wget -c "http://example.com/download.tar.gz;
#+end_src


Please don't see my comments as criticism. I'm short of time and I share
responsibility if anything. I'll try to improve this part. 

>
> I think it would still make sense though, and would be beneficial beyond
> ob-R. According to [1], the "graphics" and "link" arguments don't do
> anything unless used with "file", so it would make sense for them to
> automatically add the "file" argument.

I do agree with you again.

>
> [1] 
> https://orgmode.org/manual/Results-of-Evaluation.html#Results-of-Evaluation
>

Best regards,
-- 
Jeremie Juste



Re: [PATCH] ob-R output file with graphics parameter

2021-06-28 Thread Jeremie Juste
Hello,


Sorry for the delayed reply.

On Sunday, 27 Jun 2021 at 10:12, Jack Kamm wrote:

@Colin, thanks for your feedback. I have to confess that I didn't know about 
the second file
parameter at all until I provided the patch. I just discovered main branch 
works with the second :file
specification,  by chance just before your mail. I have been led into the wrong 
direction trying to get back the
old specification for graphics link.

#+BEGIN_SRC R :results output graphics :file test.pdf
plot(1)
#+end_src


The documentation about this part is poor and I must have missed these
dicussions on the mailing list. So all this time I lived without the graphics 
link. ;-|.

Now that I am back on track, I will check how well the current version works 
particularly for
remote connection. If it does the patch will be redundant.



> However, I tested Jeremie's example on latest org master and it also
> worked fine for me, also on remote sessions.

@Jack thanks for your feedback. I'll improve my style.
>
> The requirement for a second file parameter was added in Org 9.3 to
> support the use case in this thread:
>
> https://orgmode.org/list/3ac2f42a-8ff2-1464-fa36-451e2ef0e...@pressure.to/
>
> But this syntax is annoyingly verbose for ob-R users, and also broke
> lots of ob-R examples prior to Org 9.3.
>
> A simple fix might be to have the "graphics" flag implicitly add the
> "file" flag as well. But we would need to first check that this doesn't
> break other use cases.

I do agree with this solution. If the current specification works, we
could make it easy for ob-R user by implicitly adding a file flag. But
as far as I understand, the change will have to be made in ob-core.el.

>
>> Subject: [PATCH 1/4] ob-R.el: Remove redundant argument to function
>
> I think it would be better to squash these changes into a single commit.
>
Thanks again for the feedback.

Best regards,

-- 
Jeremie Juste



[PATCH] ob-R output file with graphics parameter

2021-06-23 Thread Jeremie Juste

Hello,

With the following patch the link to graphics output is finally back on
with R source code. Note that on top of the "graphics" parameter the
"file" parameter have to be used for the org-link to work out of the
box. I will try to remove the need for a second "file" parameter in the
future. 



#+begin_src R :results output graphics file  :file test2.pdf :session *local* 
:cache no :dir "~/Documents/images"
plot(rnorm(100))
#+end_src

#+RESULTS:
[[file:images/test2.pdf]]

The link also works for R remote sessions. Comments are welcome.  The
next steps

- Remove second the need for a second file parameter
- Add tests to avoid regression
- implement async in ob-R


>From e3d37da7b643990dc70ee42528051f1323fa5cae Mon Sep 17 00:00:00 2001
From: Jeremie Juste 
Date: Wed, 23 Jun 2021 23:58:26 +0200
Subject: [PATCH 1/4] ob-R.el: Remove redundant argument to function

* lisp/ob-R.el (org-babel-R-construct-graphics-device-call):  Modify
function to take only 'params' and not 'graphics-file'. The parameter
graphics-file can be extracted from params.
---
 lisp/ob-R.el | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index 2d9073cee..8266dc4ae 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -170,8 +170,7 @@ This function is called by `org-babel-execute-src-block'."
 	  (mapconcat 'identity
 			 (if graphics-file
 			 (append
-			  (list (org-babel-R-construct-graphics-device-call
- graphics-file params))
+			  (list (org-babel-R-construct-graphics-device-call params))
 			  inside
 			  (list "},error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); paste('ERROR', e$message, sep=' : ')}); dev.off()"))
 			   inside)
@@ -311,13 +310,16 @@ Each member of this list is a list with three members:
 3. the name of the argument to this function which specifies the
file to write to (typically \"file\" or \"filename\")")
 
-(defun org-babel-R-construct-graphics-device-call (out-file params)
+(defun org-babel-R-construct-graphics-device-call (params)
   "Construct the call to the graphics device."
   (let* ((allowed-args '(:width :height :bg :units :pointsize
 :antialias :quality :compression :res
 :type :family :title :fonts :version
 :paper :encoding :pagecentre :colormodel
 :useDingbats :horizontal))
+
+ (out-file (cdr (assq :file params)))
+
 	 (device (file-name-extension out-file))
 	 (device-info (or (assq (intern (concat ":" device))
 org-babel-R-graphics-devices)
-- 
2.20.1


>From 589eab5d98a4156b46943c7201404300f0ae6ca0 Mon Sep 17 00:00:00 2001
From: Jeremie Juste 
Date: Thu, 24 Jun 2021 00:04:59 +0200
Subject: [PATCH 2/4] ob-R.el: New function to construct org-link

* lisp/ob-R.el (org-babel-output-link-path:R):  New function to
contruct org-link from 'params'.
---
 lisp/ob-R.el | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index 8266dc4ae..c325c9cfa 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -185,6 +185,13 @@ This function is called by `org-babel-execute-src-block'."
 		 (org-babel-pick-name
 		  (cdr (assq :rowname-names params)) rownames-p)
   (if graphics-file nil result
+(defun org-babel-output-link-path:R (params)
+  "format org-link to file from PARAMS"
+  
+  (format "[[file:%s]]" (concat (cdr (assq :dir params))
+ "/"
+(cdr (assq :file params)
+  
 
 (defun org-babel-prep-session:R (session params)
   "Prepare SESSION according to the header arguments specified in PARAMS."
-- 
2.20.1


>From b55148df0da94312e1a3e5709263ed9b66355384 Mon Sep 17 00:00:00 2001
From: Jeremie Juste 
Date: Thu, 24 Jun 2021 00:07:39 +0200
Subject: [PATCH 3/4] ob-R.el: Return link if graphics parameter is used

* lisp/ob-R.el (org-babel-execute:R): Return org-link instead of nil if graphics
parameter is used.
---
 lisp/ob-R.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index c325c9cfa..9f32db97a 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -184,7 +184,9 @@ This function is called by `org-babel-execute-src-block'."
 	 (or (equal "yes" rownames-p)
 		 (org-babel-pick-name
 		  (cdr (assq :rowname-names params)) rownames-p)
-  (if graphics-file nil result
+  (if graphics-file (org-babel-output-link-path:R params)
+result
+
 (defun org-babel-output-link-path:R (params)
   "format org-link to file from PARAMS"
   
-- 
2.20.1


>From 12a06671415a55c726975d6e0297a20aefbbce62 Mon Sep 17 00:00:00 2001
From: Jeremie Juste 
Date: Thu, 24 Jun 2021 00:11:10 +0200
Subject: [PATCH 4/4] ob-R.el: Handle graphics file path for remote R session

* lisp/ob-R.el (org-babel-R-co

Re: example paper written in org completely

2021-06-19 Thread Jeremie Juste
Hello,

The thread is going far from the original post, and I'm pushing it
further. Eric, sorry for that.

But this is an interesting topic so just to have some more thoughts on this I'm 
jumping
in. Org-mode has enhanced my organizational skills and I have still a
lot to learn here. To continue this conversation, we need a philosopher
here one I'm far from being one, so please take my comments lightly.

On Saturday, 19 Jun 2021 at 09:26, Tim Cross wrote:
> A major pitfall with todo lists and priorities is that we fail to make
> the distinction between important and urgent tasks. What ends up
> happening is that all our time gets consumed by urgent tasks and we
> never get time to address important tasks. Unfortunately, it is the
> important tasks which, once completed, will reduce the number or time
> taken to deal with urgent tasks - we end up being more reactive and
> proactive.

First how do we make the distinction between urgent and important tasks?
Many tasks are important because they are urgent but who and what
defines their urgency?

>
> In our case, we all hated having to update/edit the course guides in MS
> Office because it was painful and time consuming, but urgent. However,
> nobody belt they had the time to fix matters, despite us all agreeing it
> was important.

This reminds me of the Aesop fable the [1] Mice in Council, which pushes the
importance part to the extreme.

[1]: https://aesopsfables.org/F184_The-Mice-in-Council.html.

A way to solve this might be identify some heroes and compensate them for
doing their job. Too many heroes never have their inner calling. 

>
> What would have been really great is if we had more Emacs users. We
You are in good company here.

> could then just have used org mode for the base format and even less
> work would have been required to convert from MS Office, but that will
> never happen. On the up side, I do see more and more ideas originally
> germinated in an Emacs environment finding there way into other tool
> chains, so perhaps the environments of the future won't suck quite as
> much as they might if MS Office had been the only source for
> inspiration! As the Beta v VHS war demonstrated, great technology is not
> enough, you also need to factor in marketing and advertising budgets of
> the competition!

[2] Monday.com raised $574 Million, in an IPO this month.  Many times
I'm forced to use pictures as replacement for
table and I am still struggling to add more DONE states there.

[2]: 
https://www.bloomberg.com/news/articles/2021-06-10/monday-com-prices-u-s-ipo-above-range-at-155-a-share

I suspect that it would be difficult to compete with a front-end with
org-mode at the back, but again, I'm telling more than I know.

Best regards,
-- 
Jeremie Juste



Re: TMIO Pre-release, request for feedback

2021-06-12 Thread Jeremie Juste
Hello Jack


On Thursday, 10 Jun 2021 at 05:56, Jack Kamm wrote:
> Hi Jeremie,
>
> Jeremie Juste  writes:
>
>> Just a precision async process is already available in R. Thanks again
>> to Jack Kamm for this input.
>
> I believe async evaluation in R still requires my external package:
Yes you are right. I used it so much that I wrongly thought is was part
of ob-R already.

@Timothy my apologies you were right all the way, Async is not part of
ob-R but will be soon.

>
> https://github.com/jackkamm/ob-session-async
>
> Are you sure you don't have that package enabled?
>
> I'm currently blocked on porting the R implementation here, while
> awaiting paperwork at my current job (I am making headway, but
> slowly).
Glad to hear that it is moving in the right direction. 

>
> In the meantime, feel free to go ahead and port it, if you like. It
> should be a very simple copy-paste, changing 1 or 2 variable names. All
> that code was written while at my previous job, which had signed the
> copyright disclaimer, so is safe to copy.
Thanks, I'll will keep you posted.

>
> You can also refer to my port of async sessions to ob-python, which I
> wrote before switching jobs:
>
> https://code.orgmode.org/bzg/org-mode/commit/53fd5b774e23406ed351bdb166ab35edd0c44892
Thanks this is a valuable info, I'll keep that in mind

>
> https://orgmode.org/list/87h7qi2l2m@gmail.com/

Best regards,
Jeremie Juste



Re: TMIO Pre-release, request for feedback

2021-06-10 Thread Jeremie Juste


Hello Timothy,

On Monday, 31 May 2021 at 01:33, Timothy wrote:

Many thanks for these highlights. I value them very much as even though
I check this list almost everyday, I missed the thread on 'Font lock for inline 
export snippets'.

Just a precision async process is already available in R. Thanks again
to Jack Kamm for this input.


#+BEGIN_SRC R :session *R* :async yes :eval yes
Sys.sleep(5)
print("I needed 5 sec to run but I didn't freeze emacs")
#+end_src

#+RESULTS:
: [1] "I needed 5 sec to run but I didn't freeze emacs"


Best regards,
Jeremie

> Hi Everyone,
>
> As we arrive at the end of May, I'm about to publish the 3rd issue of
> /This Month in Org/. I thought I'd share the current draft with the list
> the day before I publish to so that those of you who are interested have
> the chance to point out any errors, let me know if there's anything I
> haven't covered that you'd like to see, along with any other feedback
> you may have.
>
> For the next day, you can find the draft at:
> https://blog.tecosaur.com/tmio/DRAFT-2021-05-31.html
> and then once published it will live at:
> https://blog.tecosaur.com/tmio/2021-05-31.html
>
> All the best,
>
> Timothy.
>
> p.s. Based on the response to this, I may or may not keep on doing this.
> If you would (or wouldn't) like to see me repeat this, let me know :)
>

-- 
Jeremie Juste



Re: Bug: Failed to render org file during first load on buffer emacs 27.1 windows binaries [9.3 (release_9.3 @ c:/ProgramFilesh/emacs-27.1-x86_64/share/emacs/27.1/lisp/org/)]

2021-05-21 Thread Jeremie Juste
Hello Aaron,

The org-version that ships with emacs 27.2 is 9.4.4.
And, for me this version works well on windows 10 out of the box.

Can you confirm this?

Then if you want to upgrade orgmode, please let us know how you did it.
In general the instructions (Info-goto-node  "(org) Installation") works
for me.

Hope this helps,
Jeremie





Re: Table alignment problem

2021-05-08 Thread Jeremie Juste


Hello,

You can have some success using [1] valign-mode.

https://github.com/casouri/valign

HTH,
Jeremie



Re: Commit message instructions on the website

2021-05-03 Thread Jeremie Juste
Hello Bastien,

On Monday,  3 May 2021 at 10:27, Bastien wrote:
> Hi Jeremie,
>
> I pushed a fix for this (though a little bit before I read your public
> message here) - let me know if it needs to be enhanced.
It's good enough for me. Many thanks again

Best regards,
-- 
Jeremie Juste



Re: Help debugging R source code block output problem with :session

2021-05-03 Thread Jeremie Juste
Hello,

I must apologize again for the delay. I'll be more responsive from now
on.

@Jack, I have applied the patch at the bottom of the mail. It is not
your latest patch but it works as well and is able to handle R errors.

> https://orgmode.org/list/87ft7t9wqk@gmail.com/
I have also added the 2 test cases with to make sure we are aware if
this feature breaks in the future.

> https://orgmode.org/list/87h7slgbi5@gmail.com/
> I'd be interested to hear if the attached patch works for the common
> cases you encounter, such as with tibbles.


@ Ilja, sorry for the delayed reply.
Regarding tibbles we are still not out of the woods. But the current
patch would work if crayon option is removed.

#+BEGIN_SRC R :results output :session "local1" :pre
  options(crayon.enabled=FALSE)
  library(tidyr)
  library(dplyr)
  as_tibble(iris)
#+END_SRC

#+RESULTS:
#+begin_example
# A tibble: 150 x 5
   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
   
 1  5.1 3.5  1.4 0.2 setosa 
 2  4.9 31.4 0.2 setosa 
 3  4.7 3.2  1.3 0.2 setosa 
 4  4.6 3.1  1.5 0.2 setosa 
 5  5   3.6  1.4 0.2 setosa 
 6  5.4 3.9  1.7 0.4 setosa 
 7  4.6 3.4  1.4 0.3 setosa 
 8  5   3.4  1.5 0.2 setosa 
 9  4.4 2.9  1.4 0.2 setosa 
10  4.9 3.1  1.5 0.1 setosa 
# … with 140 more rows
#+end_example

> 

@Chuck

> https://orgmode.org/list/352c7149-743f-4944-aca5-7a1242b5a...@health.ucsd.edu/
>If you do decide to dig into solving this, please be sure that remote
>sessions and graphical outputs are not broken. test-ob-R.el does not
>cover those cases. In fact, it is pretty short, so there are probably
>other things that could break without `make test' complaining.


The current patch have been tested for remote connections as well and
AFAIK, nothing breaks.

But I'm afraid that the graphical output is broken and has long been
even before the path. The test for graphical output is compromised and
does not do the right test. I will suggest new ones. 


Please feel free to contact me or reply on the mailing list if you have
see any improvements to be made.

Best regards,
Jeremie



On Saturday, 29 Aug 2020 at 00:24, Jack Kamm wrote:

>>From 9eaf81d708f88d06f14f9b6b9cf4182dd0fbb997 Mon Sep 17 00:00:00 2001
> From: Jack Kamm 
> Date: Sat, 29 Aug 2020 00:07:58 -0700
> Subject: [PATCH] ob-R: Fix prompt mangling in session output
>
> * lisp/ob-R.el (org-babel-R-evaluate-session): Force comint prompt
> regexp to start at beginning of line, to prevent
> org-babel-comint-with-output from splitting mid-line.
>
> Fixes https://orgmode.org/list/875zgjh8wn@gmail.com/ and
> https://orgmode.org/list/87r1rqled0.fsf@havana/
> ---
>  lisp/ob-R.el | 12 +++-
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/lisp/ob-R.el b/lisp/ob-R.el
> index 5e9d35f58..10b3b6fe3 100644
> --- a/lisp/ob-R.el
> +++ b/lisp/ob-R.el
> @@ -450,11 +450,13 @@ (defun org-babel-R-evaluate-session
> (car (split-string line "\n")))
>(substring line (match-end 1))
>  line))
> -(org-babel-comint-with-output (session org-babel-R-eoe-output)
> -  (insert (mapconcat 'org-babel-chomp
> - (list body org-babel-R-eoe-indicator)
> - "\n"))
> -  (inferior-ess-send-input)) "\n"
> +(with-current-buffer session
> +  (let ((comint-prompt-regexp (concat "^" comint-prompt-regexp)))
> +(org-babel-comint-with-output (session 
> org-babel-R-eoe-output)
> +  (insert (mapconcat 'org-babel-chomp
> + (list body org-babel-R-eoe-indicator)
> + "\n"))
> +  (inferior-ess-send-input "\n"
>  
>  (defun org-babel-R-process-value-result (result column-names-p)
>"R-specific processing of return value.
> -- 
> 2.28.0



Commit message instructions on the website

2021-05-03 Thread Jeremie Juste
Hello,

The commit message instruction on the website
https://orgmode.org/contribute.html

The following instructions might help make commit message more precise
for newbies:

- Sentences should start with an uppercase letter (after the column) and end 
with a full stop
- The sentence on the first line should not end with a full stop.
- The first sentence should not start with a star.


On the website, the first line of the commit message does not start with an 
uppercase
after the column.

> main file/feature: overall change summary

> * file-changed.el (function-changed, another-function): Description of
> the change implemented, reference any relevant `other-functions' or
> `variables' here.
> (another-changed-function): Change something.  Use active voice,
> and avoid passive forms.  Please write in full sentences.

everything else is good.

Best regards,
Jeremie Juste



Re: Bug: Babel+R handles spaces wrongly in tables [9.3.6 (release_9.3.6 @ /home/cassou/.emacs.d/lib/org/lisp/)]

2021-05-02 Thread Jeremie Juste
Hello Bastien,

Many thanks, I was waiting for feedback but it seems that nobody
complained. 

On Sunday,  2 May 2021 at 05:52, Bastien wrote:
> Hi Damien and Jeremie,
>
> Jeremie Juste  writes:
>
>> The following patch will at least harmonize the results towards the
>> data.frame. 
>
> I see the patch has been applied - thanks!
>
> I'm marking this bug as resolved right now, feel free to reopen it if
> I'm wrong.
>
Thanks, feel free to reopen if you face any issue.


Best regards
-- 
Jeremie Juste



Re: org to beamer structure not working

2021-03-15 Thread Jeremie Juste
On Monday, 15 Mar 2021 at 10:37, Nick Dokos wrote:
> Luca Ferrari  writes:
>
>> On Mon, Mar 8, 2021 at 4:29 PM Eric S Fraga  wrote:
>>>
>>> How are you actually exporting?  Are you choosing a beamer export option
>>> as it looks like article LaTeX output.  Your settings look fine
>>> otherwise.
>>
>> Shame on me! I was exporting it as latex-pdf file (C-c C-e l p)
>> instead of beamer (C-c C-e l P).
>>
>
> You are not the first (nor are you going to be the last) to do that - I speak 
> from experience ;-)
>
A way to compensate my fluctuating cognitive abilities is

(define-key org-mode-map (kbd "") 'org-beamer-export-to-pdf)

Best regards,
-- 
Jeremie Juste



Re: ob-reticulate: R+Python interface from Babel

2021-02-27 Thread Jeremie Juste
Hello Jack,

Many thanks for this package. It seems like a better way all together
to manipulate python output.

I admit that my python foo is decreasing more and more but

#+BEGIN_SRC python :results output :session *Python*
  import pandas as pd
  df = pd.DataFrame({"X":[1,2,3], "Y":["a","b","c"]})
  df
#+end_src

#+RESULTS:

#+BEGIN_SRC python :results value  :session *Python*
  import pandas as pd
  df = pd.DataFrame({"X":[1,2,3], "Y":["a","b","c"]})
  df
#+end_src

#+RESULTS:
:X  Y
: 0  1  a
: 1  2  b
: 2  3  c

compared to your [1] example of reticulate is easier to work with.
https://github.com/jackkamm/ob-reticulate

Best regards,
Jeremie


On Saturday, 27 Feb 2021 at 06:15, Jack Kamm wrote:
> Hi all,
>
> ob-reticulate is now available on MELPA.
>
> You can find more information here:
> https://github.com/jackkamm/ob-reticulate
>
> Cheers,
> Jack
>

-- 
Jeremie Juste



Re: org-in-org

2021-02-23 Thread Jeremie Juste
Hello Greg,

Many thanks for the effort. 
A possible solution might be this one 

#+NAME: readdata-code
#+BEGIN_SRC org
  ,#+NAME: readdata-code
  ,#+BEGIN_SRC R :results value silent

  read.data("datafile1.csv",sep=",",header=T)->mydata1


  ,#+END_SRC
#+END_SRC

credit goes to 
https://raw.githubusercontent.com/vikasrawal/orgpaper/master/orgpapers.org

Best regards,
Jeremie


On Tuesday, 23 Feb 2021 at 17:24, Greg Minshall wrote:
> i have a question about org-in-org source blocks.  i volunteered to help
> in an effort to provide a tutorial of using the ESS (Emacs Speaks
> Statistics) package for R, in particular, from org mode.
>
> i'd like to write my contribution as a .org file.  i'd like to include
> fragments of org code, including source blocks (in R).  and, i'd like to
> show various result types.  so, i'd like to be able to have the
> #+RESULTS show up in the org-in-org source block as exported inside the
> containing .org file.
>
> and, i'd like to trigger all this from a makefile, using some emacs
> batch script to export the containing .org file into a .html or .pdf
> file.
>
> (i *think*) what i would like to end up with is what it would like if i
> had manually opened the org-in-org source blocks (C-c‌'), then went to
> each (or, possibly, selected, i guess) source blocks inside *that*
> (org-in-org) source block, and executed each, producing a #+RESULTS
> block for each, then closed the org-in-org source block (C-c‌', again),
> and then exported the containing .org file.
>
> is this possible?  any ideas?
>
> cheers, Greg
>

-- 
Jeremie Juste



Re: na=\"nil\" in ob-R.elo

2021-02-06 Thread Jeremie Juste

Hello,

Thanks again for reporting this. With the attached patch I'll remove
nil replacement for NA. 

>From 90881079d431a8af3cba5be14ecf882735ed7a6a Mon Sep 17 00:00:00 2001
From: Jeremie Juste 
Date: Sat, 6 Feb 2021 20:50:00 +0100
Subject: [PATCH] For :results value, return empty string instead of nil

---
 lisp/ob-R.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index f6fa9a417..981f21119 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -349,7 +349,7 @@ Each member of this list is a list with three members:
 {
 tfile<-tempfile()
 write.table(object, file=tfile, sep=\"\\t\",
-na=\"nil\",row.names=%s,col.names=%s,
+na=\"\",row.names=%s,col.names=%s,
 quote=FALSE)
 file.rename(tfile,transfer.file)
     },
-- 
2.20.1


Best regards,
Jeremie

On Saturday, 16 Jan 2021 at 00:19, Berry, Charles" via "General discussions 
about Org-mode. wrote:
>> On Jan 14, 2021, at 3:42 PM, Brett Presnell  wrote:
>> 
>> 
>> Probably a silly question, but in ob-R.el, what is the reason for
>> setting na=\"nil\" when defining org-babel-R-write-object-command?  Is
>> this an elisp compatibility thing?
>> 
>
> I don't get it either. The value corresponding to the NA becomes a string in 
> emacs-lisp whether \"nil\" or \"\" is used.
>
> So when passed to elisp via a :post header referencing an emacs-lisp src 
> block, its treated as a string.   
>
>> Regardless, I generally (always?) want na=\"\" for this, so I am finding
>> all those "nil"s very annoying, and the only way that I see to defeat
>> them is to redefine org-babel-R-write-object-command.
>> 
>> If there is no reason for the current behavior (doubtful I know) and if
>> I am not missing an obvious work-around, then I would like to suggest
>> changing this behavior.  Otherwise, would it be feasible to add an
>> option for R code blocks (:nastring?) where one could specify the NA
>> replacement string?
>> 
>> What do you think?  It's easy to suggest I know and certainly beyond my
>> elisp coding skills at present, but I am supposing that someone more
>> fluent in elisp could do this safely without too much trouble.
>> 
>
> You can use a :post header to customize outputs like this to make them more 
> pleasing. Or just use your own `org-babel-R-write-object-command'.
>
> Adding another header arg qualifies as feature creep and in this case would 
> require non-trivial work to implement.
>
> HTH,
>
> Chuck
>

-- 
Jeremie Juste


Re: na=\"nil\" in ob-R.elo

2021-01-16 Thread Jeremie Juste


Hello,

Thanks for the feedback

|| On Saturday, 16 Jan 2021 at 00:19, Berry, Charles" via "General discussions 
about Org-mode. wrote:
> You can use a :post header to customize outputs like this to make them
> more pleasing. Or just use your own
> `org-babel-R-write-object-command'.


As a quick work around you can use

#+name: remove-nil
#+begin_src emacs-lisp :var tbl=""
   (mapcar (lambda (row)
 (mapcar (lambda (cell)
   (if (equal "nil" cell)
   ""
cell))
 row))
   tbl)

#+end_src



#+BEGIN_SRC R  :results value :colnames yes :post remove-nil[:colnames 
yes](*this*)
data.frame(A=c(NA,1,1,1,1),B=c(1,2,NA,4,4))
#+end_src

#+RESULTS:
| A | B |
|---+---|
|   | 1 |
| 1 | 2 |
| 1 |   |
| 1 | 4 |
| 1 | 4 |



>> Probably a silly question, but in ob-R.el, what is the reason for
>> setting na=\"nil\" when defining org-babel-R-write-object-command?  Is
>> this an elisp compatibility thing?
>> 
>
> I don't get it either. The value corresponding to the NA becomes a string in 
> emacs-lisp whether \"nil\" or \"\" is used.
> So when passed to elisp via a :post header referencing an emacs-lisp
> src block, its treated as a string.

Thanks Chuck for pointing this out. R users are used to handle NA but in
this particular case where empty string and NA are treated
the same, I'm not sure the nil feature is very useful. If it does not break
anything else I will consider removing it.


Best regards,

-- 
Jeremie Juste



Re: Bug: Babel+R handles spaces wrongly in tables [9.3.6 (release_9.3.6 @ /home/cassou/.emacs.d/lib/org/lisp/)]

2020-12-19 Thread Jeremie Juste
Hello,

Apologies for the late reply and thanks for pointing out this bug.
|| On Sunday,  6 Sep 2020 at 13:32, Damien Cassou wrote:

#+name: table
| | 2014 |
|-+--|
| A C |1 |
| C   |2 |

#+name: linechart
#+begin_src R :results value :var accounts="" :exports none
length(accounts)
#+end_src

#+call: linechart(accounts=table[,0])

#+RESULTS:
: 3

Currently there are no support for vectors. So it is either a
data.frame or an object of length 1. 

|| On Sun, 06 Sep 2020 18:23:19  Berry, Charles" wrote
> Actually the length should be 1, i.e. a data.frame with a single column of 
> two elements.

Indeed with the current handling the length should be 1 but it is
not. Even with the previous case solved, it might still be an
unexpected behavior for a typical R user who would expect a vector. Do you
think it is reasonable?

The following patch will at least harmonize the results towards the
data.frame. 

diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index 420b8ccbc..81693d157 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -236,11 +236,11 @@ This function is called by `org-babel-execute-src-block'."
 (defun org-babel-R-assign-elisp (name value colnames-p rownames-p)
   "Construct R code assigning the elisp VALUE to a variable named NAME."
   (if (listp value)
-  (let* ((value (if (listp (car value)) value (list value)))
-(lengths (mapcar 'length (cl-remove-if-not 'sequencep value)))
+  (let* ((lengths (mapcar 'length (cl-remove-if-not 'sequencep value)))
 (max (if lengths (apply 'max lengths) 0))
 (min (if lengths (apply 'min lengths) 0)))
 ;; Ensure VALUE has an orgtbl structure (depth of at least 2).
+(unless (listp (car value)) (setq value (list value)))
(let ((file (orgtbl-to-tsv value '(:fmt org-babel-R-quote-tsv-field)))
  (header (if (or (eq (nth 1 value) 'hline) colnames-p)
  "TRUE" "FALSE"))


so the following will return a data.frame

#+begin_src R :results output :var accounts=(identity '("A B" "C")) 
print(accounts)
#+end_src

#+RESULTS:
:V1 V2
: 1 A B  C


I will add support for selection of 1 single column as a
vector soon.

Best regards,
Jeremie

PS: I am a newbie maintainer so feel free to comment if there you find
room for improvements ;-)



Re: LaTeX fragments not being generated due to extra * in tikz env

2020-12-19 Thread Jeremie Juste
Hello Thibault,

Many thanks. This looks like a reasonable trade off for me.

Best regards,
Jeremie
On Thursday, 17 Dec 2020 at 19:30, Thibault Marin wrote:
> Hi,
>
> I introduced the change that broke the behavior.  The attached patch
> seems to fix the issue for me, does it look reasonable?
>
> Thanks,
>
> thibault
>
> On 2020-12-09T13:16:19-0500, Jeremie Juste wrote:
>
>   Hello,
>
>   Thanks for reporting. Indeed this is an issue that hasn't been fixed
>   yet. This is the case for most latex environments
>
>   My solution is here
>   https://www.mail-archive.com/emacs-orgmode@gnu.org/msg129974.html
>
>   but consider also the idea behind the star
>   https://www.mail-archive.com/emacs-orgmode@gnu.org/msg129976.html
>
>   I will try to submit a patch soon.
>
>   Best regards,
>   Jeremie
>
>   On Tuesday,  8 Dec 2020 at 20:57, 10cadr wrote:
>   > I was trying out the new option tex:dvipng. The HTML result was a image
>   > with the tikz code.
>   >
>   > Turns out, debugging and telling the fragment processor not to delete the
>   > files, what org generates for the tikz fragment is:
>   >
>   > \begin{tikzpicture*}
>   >
>   > Removing the astherisk would make it work without any workarounds.
>   >
>   > How I got around this was
>   >
>   > #+LATEX_HEADER: \usepackage{environ,amsmath,multicol}
>   > #+LATEX_HEADER:
>   > 
> \NewEnviron{tikzpicture*}[1][]{\begin{tikzpicture}[#1]\BODY\end{tikzpicture}}
>   >
>   > Possibly fixing this issue, will make cross formats much easier.
>
>   --
>   Jeremie Juste
>
>
>

-- 
Jeremie Juste



Re: LaTeX fragments not being generated due to extra * in tikz env

2020-12-09 Thread Jeremie Juste
Hello,

Thanks for reporting. Indeed this is an issue that hasn't been fixed
yet. This is the case for most latex environments  

My solution is here
https://www.mail-archive.com/emacs-orgmode@gnu.org/msg129974.html

but consider also the idea behind the star
https://www.mail-archive.com/emacs-orgmode@gnu.org/msg129976.html

I will try to submit a patch soon.

Best regards,
Jeremie

On Tuesday,  8 Dec 2020 at 20:57, 10cadr wrote:
> I was trying out the new option tex:dvipng. The HTML result was a image
> with the tikz code.
>
> Turns out, debugging and telling the fragment processor not to delete the
> files, what org generates for the tikz fragment is:
>
> \begin{tikzpicture*}
>
> Removing the astherisk would make it work without any workarounds.
>
> How I got around this was
>
> #+LATEX_HEADER: \usepackage{environ,amsmath,multicol}
> #+LATEX_HEADER:
> \NewEnviron{tikzpicture*}[1][]{\begin{tikzpicture}[#1]\BODY\end{tikzpicture}}
>
> Possibly fixing this issue, will make cross formats much easier.

-- 
Jeremie Juste



Re: Adding Org Files to org-agenda-files

2020-11-29 Thread Jeremie Juste
Hello,

>> If you have *both* a settings in your emacs init file for
>> org-agenda-files using (setq org-agenda-files...) and you have a line in
>> your (custom ...) section, you should remove one of them to avoid
>> confusion. In general, what is in the custom section will take
>> preference as it is usually loaded last. If your going to remove the one
>> in the custom section, run M-x customize-variable  org-agenda-files
>>  and then select the options under the 'state' button to 'Erase
>> Customisation', don't just erase the values in the 'Value Menu' box.
>
> Emacs automatically introduced the custom, did not write it myself.
>
I fear I might have been the source of the confusion by suggesting
the command (org-agenda-file-to-front), which has triggered another
definition of org-agenda-file in the custom-set-variables section.  I
hadn't realized fully the consequences.

I apologize for this and I hope that it won't turn any user
against each other. I must confess that among the mailing-lists I have
subscribed to, this mailing list is the most cordial.

Yes using both the `custom-set-variables` section and setting variable
can introduce confusion. I am sure many of us have fallen prey to
(counting me many times).

At the same time it is convenient for some people to be able to
customize easily some variable and some users might use
custom-set-variables exclusively.

We just need to understand the consequences of it and I guess many
users of emacs eventually come to do with these two options and even use
the best of both world modifying directly variables in the init files
and using the custom-set-variables section.

It is a bug? I wouldn't say so. Can we explain to (new) users better
about it? Probably.

Best regards,
Jeremie



Re: Adding Org Files to org-agenda-files

2020-11-28 Thread Jeremie Juste
|| On Saturday, 28 Nov 2020 at 22:45, daniela-s...@gmx.it wrote:
>
> Many thanks for helping me.  I would not have got to this stage without
> your helpful commands and checks.
You are welcome ;-)
>
> Getting used to a problem to the extent of depending on it is not a good 
> system.
> Emacs should follow what the user demands by default, with perhaps the option
> for the user to change that behaviour.  But it is the user that should demand
> it.  In situations when Emacs gets to do something so drastic, it should 
> inform
> the user what is happening and put that information in a log file.
What you see as a problem some see as a solution. For instance, it depends how 
many
org-files you want to add to the agenda. Some users including me have 2
or three files in  org-agenda-files so I never interact with this
variable directly.

It seams that we cannot make everyone happy. :-), but we can hack our
way out of it together ;-). That is one of the purpose of this mailing
list I believe.


Best regards,
Jeremie



Re: Adding Org Files to org-agenda-files

2020-11-28 Thread Jeremie Juste
On Saturday, 28 Nov 2020 at 21:40, daniela-s...@gmx.it wrote:
> I have now identified the problem.  If incidentally, one of the user defined
> files in org-agenda-files does not exist, emacs demands that the file if
> removed.  Additionally Emacs takes over the user's settings by hardwiring
> org-agenda-files at the end of the file .emacs.
>
Glad you find the source the problem. Congratulations for your perseverance.

> This should be considered a bug.
It is not the behavior you expect but some people might rely on this
feature it is a matter of organization.  Emacs allows you to choose
which side you want to pick. Admittedly there are sometimes unexpected
default behaviors that don't please everyone but emacs offers choices.

Best regards,
Jeremie



>
>> Sent: Saturday, November 28, 2020 at 9:27 PM
>> From: "Jeremie Juste" 
>> To: daniela-s...@gmx.it
>> Cc: "Org-Mode mailing list" 
>> Subject: Re: Adding Org Files to org-agenda-files
>>
>> || On Saturday, 28 Nov 2020 at 21:11, daniela-s...@gmx.it wrote:
>> > I've made some progress, I am getting
>>
>> Very well. Then I guess that you have multiple variables named
>> org-agenda-files.
>>
>> > File: ~/02histr/gadmin/meeting.rcl.org
>> >
>> > This happens even though I removed the file name from org-agenda-files
>> > in my init file, and restarted another session.
>>
>> Can you look for the file  ~/02histr/gadmin/meeting.rcl.org in your init
>> file?
>>
>> Best regards,
>>
>

-- 
Jeremie Juste



Re: Adding Org Files to org-agenda-files

2020-11-28 Thread Jeremie Juste
|| On Saturday, 28 Nov 2020 at 21:11, daniela-s...@gmx.it wrote:
> I've made some progress, I am getting

Very well. Then I guess that you have multiple variables named
org-agenda-files.

> File: ~/02histr/gadmin/meeting.rcl.org
>
> This happens even though I removed the file name from org-agenda-files
> in my init file, and restarted another session.

Can you look for the file  ~/02histr/gadmin/meeting.rcl.org in your init
file?

Best regards,



Re: Adding Org Files to org-agenda-files

2020-11-28 Thread Jeremie Juste
||On Saturday, 28 Nov 2020 at 20:16, daniela-s...@gmx.it wrote:
> Something is wrong.  Now I have done as follows, but Org Agenda still shows
> meetings.

You have two checks to make,

1. what is the content of org-agenda-files?
2. refresh the org-agenda with the command (org-agenda-redo) usually
bounded to r in the org-agenda-mode

HTH,
Jeremie


||On Saturday, 28 Nov 2020 at 20:16, daniela-s...@gmx.it wrote:
> Something is wrong.  Now I have done as follows, but Org Agenda still shows
> meetings.
>
> (setq org-agenda-files
>'("~/02histr/gadmin/todo.rcl.org"
>  "~/02histr/gadmin/writing.rcl.org"
>  "~/02histr/gadmin/health.rcl.org"))
>
> ;; "~/02histr/gadmin/meeting.rcl.org"
> ;; "~/02histr/gadmin/household.rcl.org"
>
>> Sent: Saturday, November 28, 2020 at 8:01 PM
>> From: "Jeremie Juste" 
>> To: daniela-s...@gmx.it
>> Cc: "Org-Mode mailing list" 
>> Subject: Re: Adding Org Files to org-agenda-files
>>
>> || On Saturday, 28 Nov 2020 at 19:43, daniela-s...@gmx.it wrote:
>> > Why does Agenda not simply honour the init file.  Many fume something awful
>> > when you question them on how things are done.
>> It turns out that it does.
>>
>> This what I have in my input file
>>
>> (setq org-agenda-files
>>'("~/Documents/academic-project.org" "~/Documents/when-tired.org"
>>"~/Documents/work.org" "~/Documents/refile.org"
>>"~/Documents/todo.org"))
>>
>> just be careful about the custom-set-variables section. I you use
>> the command (org-agenda-file-to-front) to add files to org-agenda-files,
>> then if I'm not mistaken the org-agenda-files will get redefined in the
>> custom-set-variables section.
>>
>> HTH,
>> Best regards,
>> Jeremie
>>
>>
>>
>>
>>
>

-- 
Jeremie Juste



Re: Adding Org Files to org-agenda-files

2020-11-28 Thread Jeremie Juste
|| On Saturday, 28 Nov 2020 at 19:43, daniela-s...@gmx.it wrote:
> Why does Agenda not simply honour the init file.  Many fume something awful
> when you question them on how things are done.
It turns out that it does.

This what I have in my input file

(setq org-agenda-files
   '("~/Documents/academic-project.org" "~/Documents/when-tired.org"
   "~/Documents/work.org" "~/Documents/refile.org"
   "~/Documents/todo.org"))

just be careful about the custom-set-variables section. I you use
the command (org-agenda-file-to-front) to add files to org-agenda-files,
then if I'm not mistaken the org-agenda-files will get redefined in the
custom-set-variables section.

HTH,
Best regards,
Jeremie






Re: Adding Org Files to org-agenda-files

2020-11-28 Thread Jeremie Juste


Hello,

|| On Saturday, 28 Nov 2020 at 17:54, daniela-s...@gmx.it wrote:
> Yes, it shows.  That was a good test.
This is encouraging. So the problem might be in the wild card expansion
if you execute the following command do you get all the files you expect?

(file-expand-wildcards "~/02histr/gadmin/household*.org")


|| On Saturday, 28 Nov 2020 at 18:01, daniela-s...@gmx.it wrote:
> Have now removed /02histr/gadmin/household*.org and the entries are still 
> there.  Does
> it save things and got to reset something?  It has become very confusing.

The agenda files get stored in the variable org-agenda-files.
So if you do C-h v org-agenda-files then you will see all the file that
the agenda will show. If you want to remove a file you have two
options. 

1. modify the org-agenda-files directly
2. or go the file you want to remove and M-x org-remove-file .
   you can have more info by executing  this command - (info "(org) Agenda 
Files")

Of course, Don't forget to refresh the agenda. A trap I have often
fallen into  :-)

HTH,
Jeremie



Re: Adding Org Files to org-agenda-files

2020-11-28 Thread Jeremie Juste
Hello

Could you try to add the file another way just for testing?
For instance open a file that match the path
~/02histr/gadmin/household*.org, then

execute M-x org-agenda-file-to-front in this buffer.
It is also bound to C-c [ by default.

If the file is shown in the agenda, it might be a wildcard issue.

HTH,
Jeremie








On Saturday, 28 Nov 2020 at 16:39, daniela-s...@gmx.it wrote:
> Am trying to put files to display my schedules using the code below.
> I am seeing the schedule from meeting*.org, but those in household*.org
> are not being shown in Agenda.
>
> (setq org-agenda-files
>(append
> (file-expand-wildcards "~/02histr/gadmin/todo*.org")
> (file-expand-wildcards "~/02histr/gadmin/writing*.org")
> (file-expand-wildcards "~/02histr/gadmin/household*.org")
> (file-expand-wildcards "~/02histr/gadmin/health*.org")
>     (file-expand-wildcards "~/02histr/gadmin/meeting*.org") ))
>

-- 
Jeremie Juste



Re: Help debugging R source code block output problem with :session

2020-10-28 Thread Jeremie Juste
Hello Jack,

> Thanks for volunteering to maintain ob-R.el :)
Thanks for the encouragements and the suggestions. 

I need will take some time to dive into the existing code but
I will definitely look into it and keep you posted.

I've also noticed a [1] bug waiting to be fixed.
[1] 
https://orgmode.org/list/71761e05-7d0a-4fef-8baf-4c776a2fc...@health.ucsd.edu/

Best regards,
Jeremie 
On Wednesday, 28 Oct 2020 at 06:13, Jack Kamm wrote:
> Hi Jeremie,
>
> Thanks for volunteering to maintain ob-R.el :)
>
> I'm bumping this patch [0] to see if it could be merged into ob-R.el. It
> fixes some long-standing issues with prompt mangling for :session blocks
> with :results output.
>
> Elsewhere in the thread, Chuck had a suggestion [1] to allow :results
> value to be properly handled in remote sessions. It's not included in
> the patch, but worth adding separately IMO.
>
> It may be helpful reading the thread in full -- Chuck had several
> comments on ob-R that I found insightful, and may be useful for you to
> consider as maintainer. I'd highlight [2] in particular:
>
>> If you do decide to dig into solving this, please be sure that remote
>> sessions and graphical outputs are not broken.  test-ob-R.el does not
>> cover those cases.  In fact, it is pretty short, so there are probably
>> other things that could break without `make test' complaining.
>
> All the best,
> Jack
>
> [0] https://orgmode.org/list/87ft7t9wqk@gmail.com/
> [1] 
> https://orgmode.org/list/1e0046a6-1fab-45b5-9b08-68fe1be98...@health.ucsd.edu/
> [2] 
> https://orgmode.org/list/352c7149-743f-4944-aca5-7a1242b5a...@health.ucsd.edu/
>



Re: Please help by becoming a maintainer for an Org Babel file

2020-10-26 Thread Jeremie Juste
Hello Bastien,

On Monday, 26 Oct 2020 at 10:52, Bastien wrote:
> Hi Jeremie,
>
> Jeremie Juste  writes:
>
>> I'm willing to take care of ob-R.el.
>
> You're in as of 36f4df892.  Thank you very much!
Got it! It might take my elisp skills to a new level. :-)

Thanks to you,
-- 
Jeremie Juste



Re: Please help by becoming a maintainer for an Org Babel file

2020-10-26 Thread Jeremie Juste
Hello,

I'm willing to take care of ob-R.el.

Best regards,
Jeremie Juste



Re: org-table-sum

2020-10-24 Thread Jeremie Juste
Hello,

I have slightly improved the org-table-sum function.
It calls directly calc-eval and yield the same result as vsum.

It can not handle better floating points.
> | 171.00 |
> |   4.07 |
> |   4.44 |
> |   2.61 |
> |  12.21 |
> |   6.69 |
> |  19.72 |
> |  23.09 |
> |   6.23 |
> |  15.28 |
> | 250.00 |
> | 250.00 |
> | 250.00 |
> |  78.85 |
> ||
> ||
> #+TBLFM:@>$1=vsum(@1$1..@-1$1)


diff --git a/lisp/org-table.el b/lisp/org-table.el
index a3c49874c..ac237af2c 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -4728,6 +4728,18 @@ blank, and the content is appended to the field above."
  ((equal n 0) nil)
  (t n
 
+
+(defun org-table-cell-no-prop (x)
+  "remove property from org-table-cell. If cell is empty output nil. X is a 
string - a cell from org-table
+usage (org-table-cell-no-prop #(\"foo \" 0 2 (face default))) ==> foo
+"
+  (interactive)
+  (let ( (res (replace-regexp-in-string "\s+" "" 
+   (substring-no-properties x
+(when (not (equal res ""))
+  res)
+))
+
 ;;;###autoload
 (defun org-table-sum ( beg end nlast)
   "Sum numbers in region of current table column.
@@ -4769,9 +4781,9 @@ If NLAST is a number, only the NLAST fields will actually 
be summed."
   (t (setq items (reverse items))
  (setcdr (nthcdr (1- nlast) items) nil)
  (nreverse items
-(numbers (delq nil (mapcar #'org-table--number-for-summing
-   items1)))
-(res (apply '+ numbers))
+(numbers (delq nil (mapcar 'org-table-cell-no-prop  items1 )))
+(res (string-to-number (calc-eval
+(combine-and-quote-strings numbers  
"+" 


Best regards
Jeremie Juste



Re: org-table-sum

2020-10-22 Thread Jeremie Juste
Hello

I have figured out that calc-eval might do the job for the floating
point problem for org.

(info "(calc) Calling Calc from Your Programs")

(calc-eval "83.6+0.1")


So in the function org-table-sum I have made the following modification:
> (res (string-to-number (calc-eval (combine-and-quote-strings  (mapcar 
> 'number-to-string numbers )  "+"


modified   lisp/org-table.el
@@ -4771,7 +4771,7 @@ If NLAST is a number, only the NLAST fields will actually 
be summed."
  (nreverse items
 (numbers (delq nil (mapcar #'org-table--number-for-summing
items1)))
-(res (apply '+ numbers))
+(res (string-to-number (calc-eval (combine-and-quote-strings  
(mapcar 'number-to-string numbers )  "+"
 (sres (if (= org-timecnt 0)
   (number-to-string res)
 (setq diff (* 3600 res)


I believe that the org-table--number-for-summing function can be
bypassed but my elisp foo is weak. Feel free to improve.

Best regards
Jeremie



Re: [Share] collect some idea about auto eval code when TAB expand headline

2020-10-16 Thread Jeremie Juste


Hello,

I don't see very clearly how you want to use the code.
(It might well be because of my lack of skills)

Could you give a usage example?

Best regards,

Jeremie


On Friday, 16 Oct 2020 at 13:01, stardiviner wrote:
> I write an elisp config for Org Mode to auto evaluate inline source block in 
> property "EVAL".
>
> #+begin_src emacs-lisp
> (defcustom org-property-eval-keywords-list '("EVAL")
>   "A list of property keywords for evaluate code."
>   :type 'list
>   :safe #'listp
>   :group 'org)
>
> (defun org-property-eval-code ( state)
>   "Evaluate Org inline source block in property value."
>   (when (memq state '(children subtree))
> (if-let ((inline-src-block (org-entry-get nil "EVAL" nil)))
> (with-temp-buffer
>   (insert inline-src-block)
>   (goto-char (point-min))
>   (require 'ob-async nil t)
>   (setq-local org-babel-default-inline-header-args
>   '((:results . "silent") (:async . t)))
>   (let* ((context (org-element-context))
>  (src-block-info (org-babel-get-src-block-info nil context))
>  (type (org-element-type context)))
> (when (eq type 'inline-src-block)
>   ;; ob-async: `org-babel-execute-src-block:async'
>   (org-babel-execute-src-block nil src-block-info)))
>
> (add-hook 'org-cycle-hook #'org-property-eval-code)
> #+end_src
>
> A question:
>
> How to get all property keywords under headline? I want to use ~member~ to 
> detect
> whether property keywords has member in defined custom list
> ~org-property-eval-keywords-list~.
>
> Second question:
>
> Do you have any good idea or suggest about this?
>
> Thanks for sharing your idea.




Re: opening a 0.5 MB org file is slow

2020-09-30 Thread Jeremie Juste




Re: opening a 0.5 MB org file is slow

2020-09-30 Thread Jeremie Juste
Hello Uwe,

Very well, it seems that we are on the right track. So you might gain
some speed by preventing some minor modes to load at the beginning and
load only when you need them.

Like Ihor Radchenko mentioned in his previous a great way to diagnose
the issu would be the following:

1. M-x profiler-start cpu
2. open your file
3. M-x profiler-report 

It will let you see which functions are slowing you down.

HTH,
-- 
Jeremie Juste



Re: opening a 0.5 MB org file is slow

2020-09-29 Thread Jeremie Juste
Hello Uwe,

Can you test with emacs -Q ?

A 1.6M org file took a little under 7 sec on my computer.
It probably depends on the number of minor modes are being loaded, font-lock,
auto-completion, etc. 

I'm afraid I don't know how to profile the opening of a file. Does
anybody know a function that would do the profiling like
elp-instrument-function for functions?

-- 
HTH
Jeremie Juste



On Tuesday, 29 Sep 2020 at 21:11, Uwe Brauer wrote:
> Hi 
>
> maybe I am just to impatient but on my 8 GB Thinkpad X1 (4gen) to open a
> 0.5MB org file takes around 15 sec.
>
> Any change to speed this up?
>
> Thanks and regards
>
> Uwe Brauer 
>




Re: org-table-sum

2020-09-28 Thread Jeremie Juste
Hello Robert,

Thanks for sharing your thoughts.

> I suspect that the people using org-table sum would not want to split
> the function in two: itʼs a useful utility function (and why split off
> the integer summing? Thatʼs always going to be accurate).
I see your point here and I agree with you.

>
> You could make org-table-sum use calc, which would achieve the same. I
> donʼt think there'd be any complaints about floating-point additions
> suddenly being more accurate (famous last words)
I have investigated a little further about using calc. I haven't come up
with a solution yet. I don't know yet which function calc is using to
perform this operation. I have tried calcFunc-vsum but fell back on the
same issue.

#+BEGIN_SRC elisp
(calcFunc-vsum 85.6 .1)
#+end_src   

-- 
Best regards
Jeremie Juste



Re: org-table-sum

2020-09-26 Thread Jeremie Juste
Hello,

Thanks for the input.

>From what I understand, it seems that org-table-sum is not behaving as
expected. I don't know if it would be interesting to split the function
into 2. One for summing of time values and one for summing integers?

For the sum of integers (possibly real numbers) it might be interesting
to make a function use TBLFM directly? 

Best regards,
Jeremie






On Friday, 25 Sep 2020 at 10:59, Robert Pluim wrote:
>>>>>> On Thu, 24 Sep 2020 16:48:14 -0400, Kyle Meyer  said:
>
> >> I did not find a way to reproduce this with other numbers, but the
> >> order seems to matter.
>
> Kyle> See <https://floating-point-gui.de/basic/>.
>
> Exactly. Which is why you should use 'calc' with floating point
> numbers, it handles them correctly. i.e.
>
> | 171.00 |
> |   4.07 |
> |   4.44 |
> |   2.61 |
> |  12.21 |
> |   6.69 |
> |  19.72 |
> |  23.09 |
> |   6.23 |
> |  15.28 |
> | 250.00 |
> | 250.00 |
> | 250.00 |
> |  78.85 |
> ||
> ||
> #+TBLFM:@>$1=vsum(@1$1..@-1$1)
>
> Put point in that empty cell and do 'C-u C-c C-c'
>
> Robert
>

-- 
Best regards
Jeremie Juste



Re: org-tempo question

2020-09-24 Thread Jeremie Juste


Hello Nick,

Thanks for the feedback. I'm not sure I understand your setting
entirely. I have reproduced the behaviour of tempo
inside an org src block below. I don't have any comma before the
source block expansion unless I type it.

Any character except space or tab on the line of the expansion
destroys it. For example item 2 below. I have noted that the example block
on item 3 doesn not expand at all  (item 3). My normal usage is
generally the item 1 case and I get the expected behavior.


#+BEGIN_SRC org

* heading 1 (cursor position)
   writes:

> I can't say anything about indentation (I encounter problems that I
> have not reported because of lack of time to investigate combined with
> laziness - but I suspect they are, partly at least, of my own making).
>
> But when I do ` badly indented) example block, with commas before the #+begin and the
> #+end_example lines - OTOH, ` no-indent example block even if I have spaces before the ` have printable charactes before the `
> #+NAME: third
> #+begin_src org
>
> - an item
>   - subitem
>
>   ,#+begin_example
>
>   ,#+end_example
>
> #+end_src
>
> #+begin_example
>
> #+end_example
>
>
> The commas are important: are you not getting them?



Re: org-tempo question

2020-09-24 Thread Jeremie Juste
Hello Bruno,

Thanks for your mail. I have been missing this feature that was taken
out of core. I will have to keep up with the modulation of org-mode but
it is for the better.


Regarding your concern 
> In the same spirit if before trying that I type tabulation then = then tabulation again, nothing is inserted, aka org-tempo seems to work
> only when cursor is at the beginning of line.
I cannot reproduce it. That is

#+BEGIN_SRC
* headline 1
   - item
   https://orgmode.org/manual/Structure-Templates.html



Re: Bug: org-table-wrap-region incorrectly places the wrapped region [9.4 (9.4-elpaplus @ /home/marko/.emacs.d/elpa/org-plus-contrib-20200914/)]

2020-09-24 Thread Jeremie Juste
Hello Marko,

Thanks for reporting. Unexpected behavior of (org-table-wrap-region)
confirmed.

works fine with 
> | Includes all aspects of|
> | information about  |
> | proposed project.  |


Error: user-error: Not in table data field
with header line
> ||
> | Includes all aspects of|
> | information about  |
> | proposed project.  |

Best regards
Jeremie

Org mode version 9.4
GNU Emacs 28.0.50 



Marko Schuetz-Schmuck  writes:

> Emacs  : GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22, 
> cairo version 1.17.3)
>  of 2020-08-28
> Package: Org mode version 9.4 (9.4-elpaplus @ 
> /home/marko/.emacs.d/elpa/org-plus-contrib-20200914/)
>
> I'm using multi-line fields in org tables. When I wrap such a field
> there are unexpected results:
>
> Marking the region from the 'I' of "Includes" to the space just left of
> the right bottom column border and calling org-table-wrap-region
>
> | Includes all aspects of|
> | information about  |
> | proposed project.  |
>
> wraps correctly to
>
> | Includes all aspects |
> | of information about |
> | proposed project.|
>
> But when I mark the same region in this table
>
> ||
> | Includes all aspects of|
> | information about  |
> | proposed project.  |
>
> it results in an error message "Not in table data field".
>
> Initially I observed such unexpected behaviors with more complex
> situations where the field was in a column further to the right. But it
> seems it's the same problem.
>
> Best regards,
>
> Marko



Re: Help with moderating non-subscribers messages on the Org mailing list

2020-09-23 Thread Jeremie Juste
Hello Dominique,

Many thanks for this info. I'll give it a try.

Best regards,
Jeremie


Dominique Dumont  writes:

> Hi
>
> On mercredi 16 septembre 2020 11:04:42 CEST Bastien wrote:
>> The task is to check the mailman administration page and to discard
>> messages that should not be sent to the list, while allowing those
>> sent by non-subscribers who ask relevant questions.
>
> For what's it's worth, I use listadmin [1] to moderate a few Debian mailing 
> list. 
>
> I feel this is much faster than checking mailman pages: I run listadmin in a 
> terminal and then mostly hit return to discard spam.
>
> HTH
>
> [1] https://sourceforge.net/projects/listadmin/



Re: strange bug after a fresh install

2020-09-16 Thread Jeremie Juste


Hello Uwe,

if seems that the problem lies with ob-ipython.
I would suggest to remove ob-ipython to check and then perform a fresh
install of ob-ipython.

HTH,
Jeremie


Uwe Brauer  writes:

> Hi
>
> I freshly installed Ubuntu 20.04 and used the pre compiled Emacs 26, I
> copies also all my init files.
>
> When I open an org file I obtain an error message I don't understand and
> attach any help is appreciated
>
> Regards
>
> Uwe Brauer 
>
> Debugger entered--Lisp error: (json-readtable-error 47)
>   signal(json-readtable-error (47))
>   json-read()
>   json-read-from-string("/home/oub/.login: No such file or 
> directory.\njupyter: Command not found.\n")
>   ob-ipython--get-kernels()
>   ob-ipython-auto-configure-kernels()
>   run-hooks(change-major-mode-after-body-hook text-mode-hook 
> outline-mode-hook org-mode-hook)
>   apply(run-hooks (change-major-mode-after-body-hook text-mode-hook 
> outline-mode-hook org-mode-hook))
>   run-mode-hooks(org-mode-hook)
>   org-mode()
>   set-auto-mode-0(org-mode nil)
>   set-auto-mode()
>   normal-mode(t)
>   after-find-file(nil t)
>   find-file-noselect-1(# 
> "~/kde3-trinity/INSTALL-Trusty.org" nil nil 
> "~/kde3-trinity/INSTALL-Trusty.org" (17304181 66309))
>   find-file-noselect("/home/mjpons/kde3-trinity/INSTALL-Trusty.org" nil nil 
> nil)
>   #f(compiled-function (filename  wildcards) "Edit file
> FILENAME.\nSwitch to a buffer visiting file FILENAME,\ncreating one if
> none already exists.\nInteractively, the default if you just type RET
> is the current directory,\nbut the visited file name is available
> through the minibuffer history:\ntype \\[next-history-element] to pull
> it into the minibuffer.\n\nThe first time \\[next-history-element] is
> used after Emacs prompts for\nthe file name, the result is affected by
> `file-name-at-point-functions',\nwhich by default try to guess the
> file name by looking at point in the\ncurrent buffer.  Customize the
> value of `file-name-at-point-functions'\nor set it to nil, if you want
> only the visited file name and the\ncurrent directory to be available
> on first \\[next-history-element]\nrequest.\n\nYou can visit files on
> remote machines by specifying something\nlike
> /ssh:SOME_REMOTE_MACHINE:FILE for the file name.  You can\nalso visit
> local files as a different user by specifying\n/sudo::FILE for the
> file name.\nSee the Info node `(tramp)File name Syntax' in the Tramp
> Info\nmanual, for more about this.\n\nInteractively, or if WILDCARDS
> is non-nil in a call from Lisp,\nexpand wildcards (if any) and visit
> multiple files.  You can\nsuppress wildcard expansion by setting
> `find-file-wildcards' to nil.\n\nTo visit a file without any kind of
> conversion and without\nautomatically choosing a major mode, use
> \\[find-file-literally]." (interactive #f(compiled-function ()
> #)) # 0x1b4a57>)("/home/mjpons/kde3-trinity/INSTALL-Trusty.org" nil)
>   ad-Advice-find-file(#f(compiled-function (filename 
> wildcards) "Edit file FILENAME.\nSwitch to a buffer visiting file
> FILENAME,\ncreating one if none already exists.\nInteractively, the
> default if you just type RET is the current directory,\nbut the
> visited file name is available through the minibuffer history:\ntype
> \\[next-history-element] to pull it into the minibuffer.\n\nThe first
> time \\[next-history-element] is used after Emacs prompts for\nthe
> file name, the result is affected by
> `file-name-at-point-functions',\nwhich by default try to guess the
> file name by looking at point in the\ncurrent buffer.  Customize the
> value of `file-name-at-point-functions'\nor set it to nil, if you want
> only the visited file name and the\ncurrent directory to be available
> on first \\[next-history-element]\nrequest.\n\nYou can visit files on
> remote machines by specifying something\nlike
> /ssh:SOME_REMOTE_MACHINE:FILE for the file name.  You can\nalso visit
> local files as a different user by specifying\n/sudo::FILE for the
> file name.\nSee the Info node `(tramp)File name Syntax' in the Tramp
> Info\nmanual, for more about this.\n\nInteractively, or if WILDCARDS
> is non-nil in a call from Lisp,\nexpand wildcards (if any) and visit
> multiple files.  You can\nsuppress wildcard expansion by setting
> `find-file-wildcards' to nil.\n\nTo visit a file without any kind of
> conversion and without\nautomatically choosing a major mode, use
> \\[find-file-literally]." (interactive #f(compiled-function ()
> #)) #)
> "/home/mjpons/kde3-trinity/INSTALL-Trusty.org")
>   apply(ad-Advice-find-file #f(compiled-function (filename 
> wildcards) "Edit file FILENAME.\nSwitch to a buffer visiting file
> FILENAME,\ncreating one if

Re: Emacs version for Org 9.4?

2020-09-15 Thread Jeremie Juste
Hello Jens,

I'm afraid I cannot test your issue. I don't have the ability to switch
emacs version yet.

What I can tell you is that org-9.4 is working fine on GNU Emacs 27.1,
and on Emacs 28.0.50.

Does anyone have problem on the official Debian 10 repo emacs 
1:26.1+1-3.2+deb10u1?

Hope this helps,
Jeremie

- Org mode version 9.4 (release_9.4-9-g41a3c3 @
  /home/djj/src/org-mode/lisp/)
- GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.5, cairo 
version 1.16.0) of 2020-09-01

Jens Lechtenboerger  writes:

> Hi there,
>
> if I open an Org file on
> “GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of
> 2017-09-12 on hullmann, modified by Debian”
> I get this error (which I don’t know how to debug):
>
> Eager macro-expansion failure: (wrong-type-argument listp :pcase--succeed)
>
> Recipe:
> touch empty.org
> curl -L https://orgmode.org/elpa/org-plus-contrib-20200914.tar > org.tar
> mkdir org && tar xf org.tar -C org --strip-components 1
> rm -f org.tar
> emacs -Q -L org
> C-x C-f empty.org
>
> In ORG-NEWS, I only found that “Emacs 24.4 or above is suggested.”
> Did that change?
>
> Best wishes
> Jens



Re: setting up 'imenu'

2020-09-11 Thread Jeremie Juste
Hello Sharon,

I must have failed to grasp the subtleties of your workflow. And my
explanation was surely not very friendly. I apologize for that.

If your workflow works for you this is what matters. 
> Sorry, but I just feel that your system is over-complicated as compared
> to my simplistic way!

I cannot reproduce your error right now. But I would suggest a test.

If you start emacs without any configuration, on the command line
> emacs -Q

Then execute the code below. Does ido-goto-symbol work as you expect?

#+begin_src emacs-lisp
 (defun ido-goto-symbol ( symbol-list)
  "Refresh imenu and jump to a place in the buffer using Ido."
  (interactive)
  (unless (featurep 'imenu)
(require 'imenu nil t))
  (cond
   ((not symbol-list)
(let ((ido-mode ido-mode)
  (ido-enable-flex-matching
   (if (boundp 'ido-enable-flex-matching)
   ido-enable-flex-matching t))
  name-and-pos symbol-names position)
  (unless ido-mode
(ido-mode 1)
(setq ido-enable-flex-matching t))
  (while (progn
   (imenu--cleanup)
   (setq imenu--index-alist nil)
   (ido-goto-symbol (imenu--make-index-alist))
   (setq selected-symbol
 (ido-completing-read "Symbol? " symbol-names))
   (string= (car imenu--rescan-item) selected-symbol)))
  (unless (and (boundp 'mark-active) mark-active)
(push-mark nil t nil))
  (setq position (cdr (assoc selected-symbol name-and-pos)))
  (cond
   ((overlayp position)
(goto-char (overlay-start position)))
   (t
(goto-char position)
   ((listp symbol-list)
(dolist (symbol symbol-list)
  (let (name position)
(cond
 ((and (listp symbol) (imenu--subalist-p symbol))
  (ido-goto-symbol symbol))
 ((listp symbol)
  (setq name (car symbol))
  (setq position (cdr symbol)))
 ((stringp symbol)
  (setq name symbol)
  (setq position
(get-text-property 1 'org-imenu-marker symbol
(unless (or (null position) (null name)
(string= (car imenu--rescan-item) name))
  (add-to-list 'symbol-names name)
  (add-to-list 'name-and-pos (cons name position

(global-set-key (kbd "C-c i") 'ido-goto-symbol) ; or any key you see fit
   #+end_src


Best regards,

Jeremie






Re: setting up 'imenu'

2020-09-10 Thread Jeremie Juste


Hello Sharon,

Unfortunately I cannot reproduce your issue. I created a list of 56 sub heading 
and I
can view the heading Still a sample 0 until Still a sample 56.


** TODO * etc and onwards
** TODO * and another one
** Still a sample 0
** Still a sample 1
** Still a sample 2
** Still a sample 3
** Still a sample 4

It might be because I am using [1] this  modification from  emacswiki
https://www.emacswiki.org/emacs/ImenuMode.

I another workflow comes to my mind when reading yours.
Instead of using "TODO * ..." I would use the TODO keywords and tell org-mode to
list all the todos.

For instance with the command M-x org-show-todo-tree.

A another way of working might be the following.

--- file - writings.org
#+TODO: TODO(t) TOWRITE(w) | DONE(d)

* TOWRITE This is article 1
* TOWRITE This is article 2
* DONE This is  article 2

#+begin_src elisp
   (org-agenda-file-to-front)
#+end_src
--- EOF

Add the file to the agenda ( by default C-[ ), or execute the lisp chunk
in the file writings.org. Then you can M-x org-todo-list. To view all
your todo|towrite|done articles.


Hope this help,
Jeremie

[1] ;; * imenu

(defun ido-goto-symbol ( symbol-list)
  "Refresh imenu and jump to a place in the buffer using Ido."
  (interactive)
  (unless (featurep 'imenu)
(require 'imenu nil t))
  (cond
   ((not symbol-list)
(let ((ido-mode ido-mode)
  (ido-enable-flex-matching
   (if (boundp 'ido-enable-flex-matching)
   ido-enable-flex-matching t))
  name-and-pos symbol-names position)
  (unless ido-mode
(ido-mode 1)
(setq ido-enable-flex-matching t))
  (while (progn
   (imenu--cleanup)
   (setq imenu--index-alist nil)
   (ido-goto-symbol (imenu--make-index-alist))
   (setq selected-symbol
 (ido-completing-read "Symbol? " symbol-names))
   (string= (car imenu--rescan-item) selected-symbol)))
  (unless (and (boundp 'mark-active) mark-active)
(push-mark nil t nil))
  (setq position (cdr (assoc selected-symbol name-and-pos)))
  (cond
   ((overlayp position)
(goto-char (overlay-start position)))
   (t
(goto-char position)
   ((listp symbol-list)
(dolist (symbol symbol-list)
  (let (name position)
(cond
 ((and (listp symbol) (imenu--subalist-p symbol))
  (ido-goto-symbol symbol))
 ((listp symbol)
  (setq name (car symbol))
  (setq position (cdr symbol)))
 ((stringp symbol)
  (setq name symbol)
  (setq position
(get-text-property 1 'org-imenu-marker symbol
(unless (or (null position) (null name)
(string= (car imenu--rescan-item) name))
  (add-to-list 'symbol-names name)
  (add-to-list 'name-and-pos (cons name position

(global-set-key (kbd "C-c i") 'ido-goto-symbol) ; or any key you see fit








Re: org-store link does not work in gnus article-mode

2020-09-04 Thread Jeremie Juste
Hello Bastien,

Bastien  writes:
> Did you (require 'ol-gnus) ?
Yes (require 'ol-gnus) did the trick. Many thanks.

Best regards,
Jeremie




  1   2   >