Re: [O] org babel, ess, R

2017-07-05 Thread Charles C. Berry

On Wed, 5 Jul 2017, Vikas Rawal wrote:



"... I'd like Org to pick up the fact that there's a :session
argument with a custom name and use that for C-RET in the edit buffer;
otherwise it generates the default *R* session there, but if you C-c
C-c the block later it puts it into the custom session name."


This is what `org-babel-switch-to-session-with-code' does.  BTW, it 
also handles Vikas' original issue of displaying both the edit buffer 
and the process buffer during editing src blocks.


So you might want is to use `org-babel-switch-to-session-with-code' 
rather than `org-edit-src-code’.


Indeed this does what I was originally looking for. How does one exit 
from this neatly? What is the equivalent of org-edit-src-exit to use 
with this? Using org-edit-src-exit after 
org-babel-switch-to-session-with-code does not close the session window.




It doesn't do that now, but see below.

I do not think I'd want to replace `org-edit-src-code' in 
`org-edit-special' with that function by default, since it forces a 
session to start and displays the process buffer which is kind of 
annoying when all I want to do is browse code in an edit buffer.  It 
fails with an error when applied to a src block with no session, so 
that would need to be handled if `o-b-s-t-session-w-code' is supplied 
as an option.




Yes, that makes sense.



OTOH, maybe a call to `org-babel-switch-to-session-with-code' could 
replace the `(switch-to-buffer ...)' in `org-edit-special' so C-u C-c ' 
would display the process buffer (as it does now) and also the edit buffer 
and start a new process if necessary.


But there are a few things to fix. `org-babel-switch-to-session-with-code' 
needs to set `org-src--saved-temp-window-config' after the call to 
'org-edit-src-code' so `org-edit-src-exit' can restore the window setup.
Also, it might as well use 'info' which `org-edit-special' obtains for src 
blocks when ARG is set.



Chuck

Re: [O] org babel, ess, R

2017-07-05 Thread Vikas Rawal
>> 
>> "... I'd like Org to pick up the fact that there's a :session
>> argument with a custom name and use that for C-RET in the edit buffer;
>> otherwise it generates the default *R* session there, but if you C-c
>> C-c the block later it puts it into the custom session name."
> 
> This is what `org-babel-switch-to-session-with-code' does.  BTW, it also 
> handles Vikas' original issue of displaying both the edit buffer and the 
> process buffer during editing src blocks.
> 
> So you might want is to use `org-babel-switch-to-session-with-code' rather 
> than `org-edit-src-code’.

Indeed this does what I was originally looking for. How does one exit from this 
neatly? What is the equivalent of org-edit-src-exit to use with this? Using 
org-edit-src-exit after org-babel-switch-to-session-with-code does not close 
the session window.

> I do not think I'd want to replace `org-edit-src-code' in `org-edit-special' 
> with that function by default, since it forces a session to start and 
> displays the process buffer which is kind of annoying when all I want to do 
> is browse code in an edit buffer.  It fails with an error when applied to a 
> src block with no session, so that would need to be handled if 
> `o-b-s-t-session-w-code' is supplied as an option.
> 

Yes, that makes sense.

Thanks,

Vikas




Re: [O] org babel, ess, R

2017-07-05 Thread Charles C. Berry

On Wed, 5 Jul 2017, John Hendy wrote:


On Wed, Jul 5, 2017 at 4:22 PM, Nicolas Goaziou  wrote:

Hello,

Vikas Rawal  writes:


C-RET seems to be picking up the custom session name if it is already
there. But otherwise it generates the default *R* session there,


Is there a bug to fix? If so, could start a new thread about it, ideally
with an ECM demonstrating the issue?


I guess Vikas can speak for Vikas, but he was responding to my
observation of the same:

"... I'd like Org to pick up the fact that there's a :session
argument with a custom name and use that for C-RET in the edit buffer;
otherwise it generates the default *R* session there, but if you C-c
C-c the block later it puts it into the custom session name."


This is what `org-babel-switch-to-session-with-code' does.  BTW, it also 
handles Vikas' original issue of displaying both the edit buffer and the 
process buffer during editing src blocks.


So you might want is to use `org-babel-switch-to-session-with-code' rather 
than `org-edit-src-code'.


I do not think I'd want to replace `org-edit-src-code' in 
`org-edit-special' with that function by default, since it forces a 
session to start and displays the process buffer which is kind of annoying 
when all I want to do is browse code in an edit buffer.  It fails with an 
error when applied to a src block with no session, so that would need to 
be handled if `o-b-s-t-session-w-code' is supplied as an option.


HTH,

Chuck



Here's an ECM:

#+begin_example

* heading

#+name: x
#+begin_src R :session r

x <- 1:10

#+end_src

#+name: y
#+begin_src R :session r

y <- x^2

#+end_src

#+end_example

So, say I start working on a document for the day and enter the
editing buffer with C-c ' on block x. I then C-RET from the edit
buffer, which evaluates x and starts a new R session, *R*. Now I'm
done and go on to block y, but don't need to edit. Maybe I just want
to update a plot or other result in the document, so I C-c C-c:

Error: object 'x' not found

This really, really common for my work. I define a setup block
somewhere in which I load libraries, read in thousands of lines of
sensor code, and process things (moving averages, summary stats, etc.)
and create my sort of "master object." From there I have sections of a
report that subset the data, plot various things, but typically have
them all set to :eval no by default. If I pick up work on a file, edit
my setup code block, but only interactively because I forget I need to
C-c C-c something first to kick off the custom session, the work was
sort of for naught as everything is in the wrong session.

In this example, I realize the error and go back to block x and C-c
C-c after failing on block y. At that point, when I go to a block
interactively to do C-RET again, I get this in the minibuffer.

Process to load into: {r | *R* | *new* }

Then I switch to *R* to quit() and end the spurious session.

Really, it was a comment about how Org behaves, not necessarily a bug.
That said, speaking for myself, I would never want a default session
in interactive mode when I've defined one in the code heading. I'd
love if Org could pick up on that setting, such that the first C-RET
of the day dropped into the session named by the block I'm editing. At
present, interactive mode appears to ignore this.


Hope that helps clarify,
John






Regards,

--
Nicolas Goaziou





Charles C. Berry Dept of Family Medicine & Public Health
cberry at ucsd edu   UC San Diego / La Jolla, CA 92093-0901
http://biostat.ucsd.edu/ccberry.htm



Re: [O] org-plus-contrib, where is library-of-babel.org?

2017-07-05 Thread Thomas S. Dye
Aloha Kaushal Modi,

Kaushal Modi writes:

> On Wed, Jul 5, 2017, 10:41 PM Thomas S. Dye  wrote:
>
>> Aloha all,
>>
>> Where has the Library of Babel gone?
>>
>
> I had never heard of that document, but it looks cool!
>
> I see that jt is here:
> http://orgmode.org/cgit.cgi/org-mode.git/tree/doc/library-of-babel.org
>
> (It got moved in 2013:
> http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=321f806fafb596b53da7c944267f53f34d05af3e
> )

Org-plus-contrib from ELPA doesn't have the doc folder and is likewise
missing the library-of-babel.org file.

All the best,
Tom

--
Thomas S. Dye
http://www.tsdye.com



Re: [O] org-plus-contrib, where is library-of-babel.org?

2017-07-05 Thread Kaushal Modi
On Wed, Jul 5, 2017, 10:41 PM Thomas S. Dye  wrote:

> Aloha all,
>
> Where has the Library of Babel gone?
>

I had never heard of that document, but it looks cool!

I see that jt is here:
http://orgmode.org/cgit.cgi/org-mode.git/tree/doc/library-of-babel.org

(It got moved in 2013:
http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=321f806fafb596b53da7c944267f53f34d05af3e
)


-- 

Kaushal Modi


[O] org-plus-contrib, where is library-of-babel.org?

2017-07-05 Thread Thomas S. Dye
Aloha all,

Where has the Library of Babel gone?

All the best,
Tom

--
Thomas S. Dye
http://www.tsdye.com



Re: [O] Emacs-orgmode Digest, Vol 137, Issue 4

2017-07-05 Thread edgar

Date: Tue, 04 Jul 2017 09:54:13 +0100
From: Eric S Fraga 

I may be wrong but I thought that the library of babel provides a means
of calling (#+CALL: or inline) the codes in the library but not
necessarily use noweb to include them in other codes?


Oh! interesting. I have been calling functions like
#+BEGIN_SRC python :noweb yes :dir "../Data/Raw"
<>
#+END_SRC

with partial success (without "nesting"--calling a block with a 
reference to yet another block). I guess that "nested" calling of Noweb 
blocks is not really possible. Thank you for the answer :)


-

ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the 
NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!  
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!  



[O] Patch on org-agenda-cmp-user-defined not called

2017-07-05 Thread Li Zhuo
-- 
lizhuo
From ed3ca2c1ea88b452fe3d324216740664de83a218 Mon Sep 17 00:00:00 2001
From: Vacker 
Date: Wed, 5 Jul 2017 19:38:01 +0800
Subject: [PATCH] fix `org-agenda-cmp-user-defined` not called when user has
 defined it

---
 lisp/org-agenda.el | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 652fada..3a0248e 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -7007,10 +7007,9 @@ their type."
 	 (alpha-down  (if alpha-up (- alpha-up) nil))
 	 (need-user-cmp   (org-em 'user-defined-up 'user-defined-down ss))
 	 user-defined-up user-defined-down)
-(if (and need-user-cmp org-agenda-cmp-user-defined
-	 (functionp org-agenda-cmp-user-defined))
+(if (and need-user-cmp (functionp 'org-agenda-cmp-user-defined))
 	(setq user-defined-up
-	  (funcall org-agenda-cmp-user-defined a b)
+	  (funcall 'org-agenda-cmp-user-defined a b)
 	  user-defined-down (if user-defined-up (- user-defined-up) nil)))
 (cdr (assoc
 	  (eval (cons 'or org-agenda-sorting-strategy-selected))
-- 
2.7.4



Re: [O] org babel, ess, R

2017-07-05 Thread John Hendy
On Wed, Jul 5, 2017 at 4:22 PM, Nicolas Goaziou  wrote:
> Hello,
>
> Vikas Rawal  writes:
>
>> C-RET seems to be picking up the custom session name if it is already
>> there. But otherwise it generates the default *R* session there,
>
> Is there a bug to fix? If so, could start a new thread about it, ideally
> with an ECM demonstrating the issue?

I guess Vikas can speak for Vikas, but he was responding to my
observation of the same:

"... I'd like Org to pick up the fact that there's a :session
argument with a custom name and use that for C-RET in the edit buffer;
otherwise it generates the default *R* session there, but if you C-c
C-c the block later it puts it into the custom session name."

Here's an ECM:

#+begin_example

* heading

#+name: x
#+begin_src R :session r

x <- 1:10

#+end_src

#+name: y
#+begin_src R :session r

y <- x^2

#+end_src

#+end_example

So, say I start working on a document for the day and enter the
editing buffer with C-c ' on block x. I then C-RET from the edit
buffer, which evaluates x and starts a new R session, *R*. Now I'm
done and go on to block y, but don't need to edit. Maybe I just want
to update a plot or other result in the document, so I C-c C-c:

Error: object 'x' not found

This really, really common for my work. I define a setup block
somewhere in which I load libraries, read in thousands of lines of
sensor code, and process things (moving averages, summary stats, etc.)
and create my sort of "master object." From there I have sections of a
report that subset the data, plot various things, but typically have
them all set to :eval no by default. If I pick up work on a file, edit
my setup code block, but only interactively because I forget I need to
C-c C-c something first to kick off the custom session, the work was
sort of for naught as everything is in the wrong session.

In this example, I realize the error and go back to block x and C-c
C-c after failing on block y. At that point, when I go to a block
interactively to do C-RET again, I get this in the minibuffer.

Process to load into: {r | *R* | *new* }

Then I switch to *R* to quit() and end the spurious session.

Really, it was a comment about how Org behaves, not necessarily a bug.
That said, speaking for myself, I would never want a default session
in interactive mode when I've defined one in the code heading. I'd
love if Org could pick up on that setting, such that the first C-RET
of the day dropped into the session named by the block I'm editing. At
present, interactive mode appears to ignore this.


Hope that helps clarify,
John





> Regards,
>
> --
> Nicolas Goaziou



Re: [O] org babel, ess, R

2017-07-05 Thread Nicolas Goaziou
Hello,

Vikas Rawal  writes:

> C-RET seems to be picking up the custom session name if it is already
> there. But otherwise it generates the default *R* session there,

Is there a bug to fix? If so, could start a new thread about it, ideally
with an ECM demonstrating the issue?

Regards,

-- 
Nicolas Goaziou



Re: [O] Custom timestamps in date ranges

2017-07-05 Thread Nicolas Goaziou
Hello,

jeeger  writes:

> I have a single-line patch to contribute. In my org-mode version (Org
> mode version 9.0.9 (9.0.9-30-g796a78-elpa)), custom timestamps do not
> correctly apply to date ranges. Only the second date is replaced in
> the custom date format. I've tracked this down to org-activate-dates.
> The line
>
>   (if (match-end 3)
> (org-display-custom-time (match-beginning 3) (match-end 3))
> (org-display-custom-time (match-beginning 1) (match-end 1)))
>
> leads to only the second of the date range being fontified. The
> corrected version is:
>
>   (when (match-end 3)
>   (org-display-custom-time (match-beginning 3) (match-end 3)))
>   (org-display-custom-time (match-beginning 1) (match-end 1))
>
> This fontifies the first date correctly as well.

Thank you.

Would it makes sense to add a comment above the `when' explaining this
is about date ranges?

Also, could you use git format-patch and add an appropriate commit
message so I can apply your changes?

Regards,

-- 
Nicolas Goaziou



Re: [O] capture templates and ^{prompt}

2017-07-05 Thread Nicolas Goaziou
Hello,

Jean-Christophe Helary  writes:

> Sorry to send this question again:
>
>> Are there cases where %\1 ... %\N would be used *outside* of a string
>>in a template?

I don't think so.

Regards,

-- 
Nicolas Goaziou



[O] Custom timestamps in date ranges

2017-07-05 Thread jeeger

Hello!

I have a single-line patch to contribute. In my org-mode version (Org 
mode version 9.0.9 (9.0.9-30-g796a78-elpa)), custom timestamps do not 
correctly apply to date ranges. Only the second date is replaced in the 
custom date format. I've tracked this down to org-activate-dates. The 
line


  (if (match-end 3)
  (org-display-custom-time (match-beginning 3) (match-end 3))
  (org-display-custom-time (match-beginning 1) (match-end 1)))

leads to only the second of the date range being fontified. The 
corrected version is:


(when (match-end 3)
(org-display-custom-time (match-beginning 3) (match-end 3)))
(org-display-custom-time (match-beginning 1) (match-end 1))

This fontifies the first date correctly as well.

Regards,
Jan Seeger