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