Re: [PATCH] Re: How to stop results being hidden when using ":results drawer"?

2022-07-30 Thread Ihor Radchenko
Ihor Radchenko  writes:

> In fact, forcefully folding the drawers is relatively recent addition by
> Nicolas in 1027e0256903bc2.
>
> I am attaching the patch making drawer folding controllable via optional
> argument. WDYT?

No objections have been given.
Applied onto main via 785f003de with slight modifications to address 
https://orgmode.org/list/m2a68zthgq@ntnu.no.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=785f003de527487d1557cb724dd4b8867b5ea657

Best,
Ihor



Re: [PATCH] Re: How to stop results being hidden when using ":results drawer"?

2022-05-13 Thread Ihor Radchenko
Eric S Fraga  writes:

> On Friday, 13 May 2022 at 21:35, Ihor Radchenko wrote:
>> In fact, forcefully folding the drawers is relatively recent addition by
>> Nicolas in 1027e0256903bc2.
>
> I wonder if this is related to my issue with ediff-ing org buffers and
> having drawers hidden?  I've not had time yet to investigate but
> interesting coincidence maybe?

If I recall correctly, you had some drawers folded and some not in
ediff. That is a different issue and it should be fixed on the latest
main.

Best,
Ihor



Re: [PATCH] Re: How to stop results being hidden when using ":results drawer"?

2022-05-13 Thread Eric S Fraga
On Friday, 13 May 2022 at 21:35, Ihor Radchenko wrote:
> In fact, forcefully folding the drawers is relatively recent addition by
> Nicolas in 1027e0256903bc2.

I wonder if this is related to my issue with ediff-ing org buffers and
having drawers hidden?  I've not had time yet to investigate but
interesting coincidence maybe?

-- 
: Eric S Fraga, with org release_9.5.3-481-gaea24b in Emacs 29.0.50



[PATCH] Re: How to stop results being hidden when using ":results drawer"?

2022-05-13 Thread Ihor Radchenko
John Kitchin  writes:

> This issue is specific to using a scimax function
> `scimax-ob-execute-and-next-block` that executes the current block then
> moves to the next or creates a new block if needed. This is a UI feature
> from jupyter notebooks that I like to use.
>
> That function uses `(org-babel-next-src-block)`, which uses
> org-next-block, which calls org-show-context, which uses
> org-show-set-visibility, which calls org-show-entry, which hides the
> drawers.
>
> It isn't an org-core issue perhaps, other than it is not obvious why
> org-show-entry has a hard-coded line to hide drawers in it.

I'd say that it is org-core issue. The current behaviour does not really
follow what org-fold-show-entry docstring promises:

>> Show the body directly following its heading.

>> Show the heading too, if it is currently invisible.

In fact, forcefully folding the drawers is relatively recent addition by
Nicolas in 1027e0256903bc2.

I am attaching the patch making drawer folding controllable via optional
argument. WDYT?

Best,
Ihor

>From bd3c7ac6162d64a19eff370b7b22ba233f8480ad Mon Sep 17 00:00:00 2001
Message-Id: 
From: Ihor Radchenko 
Date: Fri, 13 May 2022 21:30:46 +0800
Subject: [PATCH] org-fold-show-entry: Do not fold drawers unless requested

* lisp/org-fold.el (org-fold-show-entry): Do not fold drawers in the
unfolded entry unless the new optional argument is non-nil.  Folding
the drawers was introduced in 1027e0256903bc2, but does not follow the
function docstring.  Moreover, folding drawers creates unexpected
behaviour in some cases.  See
https://orgmode.org/list/m2a6bl4mmr@andrew.cmu.edu

* etc/ORG-NEWS (~org-fold-show-entry~ does not fold drawers by default
anymore): Document the change.

* lisp/org-agenda.el (org-agenda-show):
(org-agenda-show-and-scroll-up):
(org-agenda-show-1):
* lisp/org-clock.el (org-clock-goto):
* lisp/org-compat.el (outline-toggle-children):
* lisp/org-timer.el (org-timer--get-timer-title):
* lisp/org.el (org-move-subtree-down):
(org-return): Explicitly request folding drawers inside the revealed
entry in the places where it appears to make sense.
---
 etc/ORG-NEWS   | 7 +++
 lisp/org-agenda.el | 6 +++---
 lisp/org-clock.el  | 2 +-
 lisp/org-compat.el | 2 +-
 lisp/org-fold.el   | 4 ++--
 lisp/org-timer.el  | 2 +-
 lisp/org.el| 4 ++--
 7 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 582816534..15986c935 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -190,6 +190,13 @@ installed. It uses Emacs' font-lock information, and so tends to
 produce results superior to Minted or Listings.
 
 ** New functions and changes in function arguments
+*** ~org-fold-show-entry~ does not fold drawers by default anymore
+
+~org-fold-show-entry~ now accepts an optional argument HIDE-DRAWERS.
+When the argument is non-nil, the function folds all the drawers
+inside entry.  This was the default previously.
+
+Now, ~org-fold-show-entry~ does not fold drawers by default.
 
 *** New function ~org-element-cache-map~ for quick mapping across Org elements
 
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 0479a0e1f..6fd0e4498 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -9701,7 +9701,7 @@ (defun org-agenda-show ( full-entry)
   (interactive "P")
   (let ((win (selected-window)))
 (org-agenda-goto t)
-(when full-entry (org-fold-show-entry))
+(when full-entry (org-fold-show-entry 'hide-drawers))
 (select-window win)))
 
 (defvar org-agenda-show-window nil)
@@ -9720,7 +9720,7 @@ (defun org-agenda-show-and-scroll-up ( arg)
 	  (select-window org-agenda-show-window)
 	  (ignore-errors (scroll-up)))
   (org-agenda-goto t)
-  (org-fold-show-entry)
+  (org-fold-show-entry 'hide-drawers)
   (if arg (org-cycle-hide-drawers 'children)
 	(org-with-wide-buffer
 	 (narrow-to-region (org-entry-beginning-position)
@@ -9764,7 +9764,7 @@ (defun org-agenda-show-1 ( more)
  ((and (called-interactively-p 'any) (= more 1))
   (message "Remote: show with default settings"))
  ((= more 2)
-  (org-fold-show-entry)
+  (org-fold-show-entry 'hide-drawers)
   (org-fold-show-children)
   (save-excursion
 	(org-back-to-heading)
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index ec87aaf8a..c04a8fdcf 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1849,7 +1849,7 @@ (defun org-clock-goto ( select)
 (pop-to-buffer-same-window (marker-buffer m))
 (if (or (< m (point-min)) (> m (point-max))) (widen))
 (goto-char m)
-(org-fold-show-entry)
+(org-fold-show-entry 'hide-drawers)
 (org-back-to-heading t)
 (recenter org-clock-goto-before-context)
 (org-fold-reveal)
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 704197645..8553500d6 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -1400,7 +1400,7 @@ (defadvice outline-toggle-children (around outline-toggle-children@fix-for-org-f
   (if (not (org-fold-folded-p 

Re: How to stop results being hidden when using ":results drawer"?

2022-05-13 Thread John Kitchin
If you add this and click on it:


[[elisp:(org-show-entry)]]

The drawer will collapse.

This issue is specific to using a scimax function
`scimax-ob-execute-and-next-block` that executes the current block then
moves to the next or creates a new block if needed. This is a UI feature
from jupyter notebooks that I like to use.

That function uses `(org-babel-next-src-block)`, which uses
org-next-block, which calls org-show-context, which uses
org-show-set-visibility, which calls org-show-entry, which hides the
drawers.

It isn't an org-core issue perhaps, other than it is not obvious why
org-show-entry has a hard-coded line to hide drawers in it.


Ihor Radchenko  writes:

> John Kitchin  writes:
>
>> This does not change anything for me.
>>
>> The function that causes folding for me is `org-entry-show'. Presumably
>> because of this line: (org-cycle-hide-drawers 'children)
>>
>> My solution was an override advice that makes this function not run when
>> point is in a src-block
>> (https://github.com/jkitchin/scimax/blob/master/scimax-jupyter.el#L281).
>
> Could you elaborate? I am not sure how `org-entry-show' has anything to
> do with hiding results.
>
> I tried the following Org file with latest Org main (after (require 
> 'ob-python)):
>
> * test heading
>
> #+begin_src python :results drawer output
>   print(1+2)
> #+end_src
>
> #+RESULTS:
> :results:
> 3
> :end:
>
> The drawer does not get hidden.
>
> Best,
> Ihor


-- 
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
Pronouns: he/him/his



Re: How to stop results being hidden when using ":results drawer"?

2022-05-13 Thread Ihor Radchenko
John Kitchin  writes:

> This does not change anything for me.
>
> The function that causes folding for me is `org-entry-show'. Presumably
> because of this line: (org-cycle-hide-drawers 'children)
>
> My solution was an override advice that makes this function not run when
> point is in a src-block
> (https://github.com/jkitchin/scimax/blob/master/scimax-jupyter.el#L281).

Could you elaborate? I am not sure how `org-entry-show' has anything to
do with hiding results.

I tried the following Org file with latest Org main (after (require 
'ob-python)):

* test heading

#+begin_src python :results drawer output
  print(1+2)
#+end_src

#+RESULTS:
:results:
3
:end:

The drawer does not get hidden.

Best,
Ihor



Re: How to stop results being hidden when using ":results drawer"?

2022-05-12 Thread Richard H. Stanton


>> I’m creating documents where I run Python code blocks that create LaTeX 
>> mathematical output that I want to be able to export to either LaTeX/PDF or 
>> HTML. 
>> 
>> Using :wrap in the header works fine, except that LaTeX complains about the 
>> unknown environment “results” (it still compiles the file to PDF fine).
>> 
>> Using :wrap export latex works fine for LaTeX export, but I can’t get HTML 
>> that way.
>> 
>> The recommended method seems to be to use :results drawer. This works fine 
>> from an export perspective to both LaTeX/PDF and to HTML. However, it has 
>> one significant drawback when I’m actually creating the document: the 
>> results drawer starts out hidden and to see what’s there I have to click on 
>> it. This makes debugging the code in the first place a lot less convenient.
>> 
>> Is there a way to use :results drawer and have the results NOT hidden by 
>> default?
> 
> I think that you are experiencing the same issue with
> https://list.orgmode.org/80k0ar1lml@felesatra.moe/T/#u
> 
> Does it help when you run
> M-: (setq org-fold-core-first-unfold-functionsp nil) 
> before running the code block?
> 
> Best,
> Ihor

Thanks for the suggestion, Ihor, but like John, this doesn’t solve my problem. 
For now, I'm using :wrap flushleft, which allows exporting to both LaTeX and 
HTML without errors, allows xenops to preview my LaTeX output, and doesn’t have 
any hiding issues. I’ve also reported the issue to the author of xenops.



Re: How to stop results being hidden when using ":results drawer"?

2022-05-12 Thread John Kitchin
This does not change anything for me.

The function that causes folding for me is `org-entry-show'. Presumably
because of this line: (org-cycle-hide-drawers 'children)

My solution was an override advice that makes this function not run when
point is in a src-block
(https://github.com/jkitchin/scimax/blob/master/scimax-jupyter.el#L281).


Ihor Radchenko  writes:

> Richard Stanton  writes:
>
>> I’m creating documents where I run Python code blocks that create LaTeX 
>> mathematical output that I want to be able to export to either LaTeX/PDF or 
>> HTML. 
>>
>> Using :wrap in the header works fine, except that LaTeX complains about the 
>> unknown environment “results” (it still compiles the file to PDF fine).
>>
>> Using :wrap export latex works fine for LaTeX export, but I can’t get HTML 
>> that way.
>>
>> The recommended method seems to be to use :results drawer. This works fine
>> from an export perspective to both LaTeX/PDF and to HTML. However, it has one
>> significant drawback when I’m actually creating the document: the results
>> drawer starts out hidden and to see what’s there I have to click on it. This
>> makes debugging the code in the first place a lot less convenient.
>>
>> Is there a way to use :results drawer and have the results NOT hidden by 
>> default?
>
> I think that you are experiencing the same issue with
> https://list.orgmode.org/80k0ar1lml@felesatra.moe/T/#u
>
> Does it help when you run
> M-: (setq org-fold-core-first-unfold-functionsp nil) 
> before running the code block?
>
> Best,
> Ihor


-- 
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
Pronouns: he/him/his



Re: How to stop results being hidden when using ":results drawer"?

2022-05-12 Thread Ihor Radchenko
Richard Stanton  writes:

> I’m creating documents where I run Python code blocks that create LaTeX 
> mathematical output that I want to be able to export to either LaTeX/PDF or 
> HTML. 
>
> Using :wrap in the header works fine, except that LaTeX complains about the 
> unknown environment “results” (it still compiles the file to PDF fine).
>
> Using :wrap export latex works fine for LaTeX export, but I can’t get HTML 
> that way.
>
> The recommended method seems to be to use :results drawer. This works fine 
> from an export perspective to both LaTeX/PDF and to HTML. However, it has one 
> significant drawback when I’m actually creating the document: the results 
> drawer starts out hidden and to see what’s there I have to click on it. This 
> makes debugging the code in the first place a lot less convenient.
>
> Is there a way to use :results drawer and have the results NOT hidden by 
> default?

I think that you are experiencing the same issue with
https://list.orgmode.org/80k0ar1lml@felesatra.moe/T/#u

Does it help when you run
M-: (setq org-fold-core-first-unfold-functionsp nil) 
before running the code block?

Best,
Ihor



Re: How to stop results being hidden when using ":results drawer"?

2022-05-11 Thread John Kitchin
hm. what is xenops doing? That isn't a package I use, but my results
drawers are also closed when opening a file.

John

---
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



On Wed, May 11, 2022 at 4:16 PM Richard Stanton 
wrote:

> It works fine when I use emacs -Q, so I did some hunting around and
> discovered that it’s a bad interaction with the xenops package. A shame, as
> this package does a great job of almost-real-time previewing of LaTeX
> equations, figure and tables.
>
>
> > On May 11, 2022, at 10:51 AM, Richard Stanton 
> wrote:
> >
> > I see that the same question was asked by John Kitchin in 2016. The
> accepted answer back then was either to put
> >
> > #+STARTUP: showeverything
> >
> > at the top of the org file or to use (setq org-startup-folded
> "showeverything”).
> >
> > I don’t know if something has changed in org since then, but neither of
> these seems to work for me at the moment. All of my :results: drawers start
> out and remain hidden until I click on them and press TAB.
> >
> >
> >> On May 11, 2022, at 9:52 AM, Richard Stanton 
> wrote:
> >>
> >> I’m creating documents where I run Python code blocks that create LaTeX
> mathematical output that I want to be able to export to either LaTeX/PDF or
> HTML.
> >>
> >> Using :wrap in the header works fine, except that LaTeX complains about
> the unknown environment “results” (it still compiles the file to PDF fine).
> >>
> >> Using :wrap export latex works fine for LaTeX export, but I can’t get
> HTML that way.
> >>
> >> The recommended method seems to be to use :results drawer. This works
> fine from an export perspective to both LaTeX/PDF and to HTML. However, it
> has one significant drawback when I’m actually creating the document: the
> results drawer starts out hidden and to see what’s there I have to click on
> it. This makes debugging the code in the first place a lot less convenient.
> >>
> >> Is there a way to use :results drawer and have the results NOT hidden
> by default?
> >>
> >> Thanks for any suggestions!
> >>
> >> Richard Stanton
> >>
> >>
> >
>
>
>


Re: How to stop results being hidden when using ":results drawer"?

2022-05-11 Thread Richard Stanton
It works fine when I use emacs -Q, so I did some hunting around and discovered 
that it’s a bad interaction with the xenops package. A shame, as this package 
does a great job of almost-real-time previewing of LaTeX equations, figure and 
tables.


> On May 11, 2022, at 10:51 AM, Richard Stanton  wrote:
> 
> I see that the same question was asked by John Kitchin in 2016. The accepted 
> answer back then was either to put
> 
> #+STARTUP: showeverything
> 
> at the top of the org file or to use (setq org-startup-folded 
> "showeverything”).
> 
> I don’t know if something has changed in org since then, but neither of these 
> seems to work for me at the moment. All of my :results: drawers start out and 
> remain hidden until I click on them and press TAB.
> 
> 
>> On May 11, 2022, at 9:52 AM, Richard Stanton  wrote:
>> 
>> I’m creating documents where I run Python code blocks that create LaTeX 
>> mathematical output that I want to be able to export to either LaTeX/PDF or 
>> HTML. 
>> 
>> Using :wrap in the header works fine, except that LaTeX complains about the 
>> unknown environment “results” (it still compiles the file to PDF fine).
>> 
>> Using :wrap export latex works fine for LaTeX export, but I can’t get HTML 
>> that way.
>> 
>> The recommended method seems to be to use :results drawer. This works fine 
>> from an export perspective to both LaTeX/PDF and to HTML. However, it has 
>> one significant drawback when I’m actually creating the document: the 
>> results drawer starts out hidden and to see what’s there I have to click on 
>> it. This makes debugging the code in the first place a lot less convenient.
>> 
>> Is there a way to use :results drawer and have the results NOT hidden by 
>> default?
>> 
>> Thanks for any suggestions!
>> 
>> Richard Stanton
>> 
>> 
> 




Re: How to stop results being hidden when using ":results drawer"?

2022-05-11 Thread Richard Stanton
I see that the same question was asked by John Kitchin in 2016. The accepted 
answer back then was either to put

#+STARTUP: showeverything

at the top of the org file or to use (setq org-startup-folded "showeverything”).

I don’t know if something has changed in org since then, but neither of these 
seems to work for me at the moment. All of my :results: drawers start out and 
remain hidden until I click on them and press TAB.


> On May 11, 2022, at 9:52 AM, Richard Stanton  wrote:
> 
> I’m creating documents where I run Python code blocks that create LaTeX 
> mathematical output that I want to be able to export to either LaTeX/PDF or 
> HTML. 
> 
> Using :wrap in the header works fine, except that LaTeX complains about the 
> unknown environment “results” (it still compiles the file to PDF fine).
> 
> Using :wrap export latex works fine for LaTeX export, but I can’t get HTML 
> that way.
> 
> The recommended method seems to be to use :results drawer. This works fine 
> from an export perspective to both LaTeX/PDF and to HTML. However, it has one 
> significant drawback when I’m actually creating the document: the results 
> drawer starts out hidden and to see what’s there I have to click on it. This 
> makes debugging the code in the first place a lot less convenient.
> 
> Is there a way to use :results drawer and have the results NOT hidden by 
> default?
> 
> Thanks for any suggestions!
> 
> Richard Stanton
> 
>