Hi Nicolas,

On Wed, Apr 21, 2021, at 5:15 PM, Cheong Yiu Fung wrote:
> The first patch implements the changes. I took the liberty to show 
> entry of its ancestors
> too (4 in the test case). Many users, I believe, rarely put text there, 
> so it does not
> make a difference. 

I would like to rescind my previous comments. It's awkward for me to realize I 
do have a
lot of ancestor text that I do not wish to be exported.

Please ignore patches in the previous message and use the latest ones attached. 
Thanks!

Yiufung
From 203364db88d25e5aea4cf295584617757c18591c Mon Sep 17 00:00:00 2001
From: Cheong Yiu Fung <m...@yiufung.net>
Date: Wed, 21 Apr 2021 16:27:03 +0800
Subject: [PATCH 2/2] org-manual.org: add hints for visible-only export

---
 doc/org-manual.org | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index efe956877..16dd4a52f 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -11524,7 +11524,8 @@ further alter what is exported, and how.
 
   Toggle visible-only export.  This is useful for exporting only
   certain parts of an Org document by adjusting the visibility of
-  particular headings.
+  particular headings.  See also the variable
+  ~org-show-context-detail~ and the command ~org-sparse-tree~.
 
 ** Export Settings
 :PROPERTIES:
-- 
2.31.1

From ad1611831535a602c1d4b0bd8c92fea2ddde0551 Mon Sep 17 00:00:00 2001
From: Cheong Yiu Fung <m...@yiufung.net>
Date: Wed, 21 Apr 2021 16:26:14 +0800
Subject: [PATCH 1/2] org.el (org-show-context-detail): add option
 'ancestors-full

* lisp/org.el: Add option 'ancestors-full to
`org-show-context-detail', update `org-show-set-visibility'
accordingly
* testing/lisp/test-org.el: Add tests.
---
 lisp/org.el              | 15 ++++++++++-----
 testing/lisp/test-org.el |  4 ++++
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 675a614e2..ac006eb6d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1199,6 +1199,8 @@ Allowed visibility spans are
   ancestors      show current headline and its direct ancestors; if
                  point is not on headline, also show entry
 
+  ancestors-full show current subtree and its direct ancestors
+
   lineage        show current headline, its direct ancestors and all
                  their children; if point is not on headline, also show
                  entry and first child
@@ -1240,6 +1242,7 @@ more context."
 			   (const minimal)
 			   (const local)
 			   (const ancestors)
+                           (const ancestors-full)
 			   (const lineage)
 			   (const tree)
 			   (const canonical))))))
@@ -6758,9 +6761,9 @@ be shown."
 
 (defun org-show-set-visibility (detail)
   "Set visibility around point according to DETAIL.
-DETAIL is either nil, `minimal', `local', `ancestors', `lineage',
-`tree', `canonical' or t.  See `org-show-context-detail' for more
-information."
+DETAIL is either nil, `minimal', `local', `ancestors',
+`ancestors-full', `lineage', `tree', `canonical' or t.  See
+`org-show-context-detail' for more information."
   ;; Show current heading and possibly its entry, following headline
   ;; or all children.
   (if (and (org-at-heading-p) (not (eq detail 'local)))
@@ -6775,14 +6778,16 @@ information."
       (org-with-limited-levels
        (cl-case detail
 	 ((tree canonical t) (org-show-children))
-	 ((nil minimal ancestors))
+	 ((nil minimal ancestors ancestors-full))
 	 (t (save-excursion
 	      (outline-next-heading)
 	      (org-flag-heading nil)))))))
+  ;; Show whole subtree.
+  (when (eq detail 'ancestors-full) (org-show-subtree))
   ;; Show all siblings.
   (when (eq detail 'lineage) (org-show-siblings))
   ;; Show ancestors, possibly with their children.
-  (when (memq detail '(ancestors lineage tree canonical t))
+  (when (memq detail '(ancestors ancestors-full lineage tree canonical t))
     (save-excursion
       (while (org-up-heading-safe)
 	(org-flag-heading nil)
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index f6fb4b3ca..47732dfa3 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -7982,6 +7982,10 @@ CLOCK: [2012-03-29 Thu 10:00]--[2012-03-29 Thu 16:40] =>  6:40"
     (should (equal '(0 7 8 9) (funcall list-visible-lines 'local nil)))
     (should (equal '(0 3 7) (funcall list-visible-lines 'ancestors t)))
     (should (equal '(0 3 7 8) (funcall list-visible-lines 'ancestors nil)))
+    (should (equal '(0 3 7 8 9 10 11)
+                   (funcall list-visible-lines 'ancestors-full t)))
+    (should (equal '(0 3 7 8 9 10 11)
+                   (funcall list-visible-lines 'ancestors-full nil)))
     (should (equal '(0 3 5 7 12) (funcall list-visible-lines 'lineage t)))
     (should (equal '(0 3 5 7 8 9 12) (funcall list-visible-lines 'lineage nil)))
     (should (equal '(0 1 3 5 7 12 13) (funcall list-visible-lines 'tree t)))
-- 
2.31.1

Reply via email to