emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] org.el (org-show-context-detail): add option 'ancestors-with-ent


From: Cheong Yiu Fung
Subject: [PATCH] org.el (org-show-context-detail): add option 'ancestors-with-entry
Date: Fri, 16 Apr 2021 21:39:29 +0800

Hi, I'm proposing a new option in `org-show-context-detail', which shows
current headline, its ancestors, *and the entry itself*. This is useful
when export matched subtrees and their contents quickly with least
manual intervention.

Consider when working on different aspects of a project and taking notes
as we go:

* Project
A project tree
** Task1
** Task2
*** ASK Something to align
Something for discussion
** Task3
** Task4
*** ASK Something else to align
Something else.

At some point, we may wish to export only certain contents. For example,
to export headings with TODO keyword of "ASK", along with the task
context (ancestors TASK<N> heading name), and their own content for
discussion with colleagues. Ideally, this can be done by
org-sparse-tree, followed by org-export with visible-only + subtree-only
option.

Expected output:
* Project
** Task2
*** ASK Something to align
Something for discussion
** Task4
*** ASK Something else to align
Something else.

Current options, though, either require manual expansion to show both
ancestors AND entry, which becomes tedious soon;

* Project
** Task2
*** ASK Something to align
** Task4
*** ASK Something else to align

or it shows extra contents (`local' will include the *next* heading, in
this example, the non-related Task3)

* Project
*** ASK Something to align
Something for discussion
** Task3
*** ASK Something else to align
Something else.

`ancestor-with-entries' is a long name that pose some difficulties to
updating documentations, so I wish to have some feedbacks before moving
on. Is there better way to achieve this effect? Am I overlooking
something?

Yiufung

>From 38703eace6062ec4e4ccdf1912a641b266efbf61 Mon Sep 17 00:00:00 2001
From: Cheong Yiu Fung <cheongyiufung@gmail.com>
Date: Fri, 16 Apr 2021 18:35:17 +0800
Subject: [PATCH] org.el (org-show-context-detail): add option
 'ancestors-with-entry

* lisp/org.el: Add option 'ancestors-with-entry to
`org-show-context-detail', which shows current headline, entry, and
its direct ancestors.
---
 lisp/org.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 675a614e2..0e625d9ed 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1240,6 +1240,7 @@ more context."
                           (const minimal)
                           (const local)
                           (const ancestors)
+                           (const ancestors-with-entry)
                           (const lineage)
                           (const tree)
                           (const canonical))))))
@@ -6763,7 +6764,7 @@ DETAIL is either nil, `minimal', `local', `ancestors', 
`lineage',
 information."
   ;; Show current heading and possibly its entry, following headline
   ;; or all children.
-  (if (and (org-at-heading-p) (not (eq detail 'local)))
+  (if (and (org-at-heading-p) (not (memq detail '(local 
ancestors-with-entry))))
       (org-flag-heading nil)
     (org-show-entry)
     ;; If point is hidden within a drawer or a block, make sure to
@@ -6775,14 +6776,14 @@ information."
       (org-with-limited-levels
        (cl-case detail
         ((tree canonical t) (org-show-children))
-        ((nil minimal ancestors))
+        ((nil minimal ancestors ancestors-with-entry))
         (t (save-excursion
              (outline-next-heading)
              (org-flag-heading nil)))))))
   ;; 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-with-entry lineage tree canonical 
t))
     (save-excursion
       (while (org-up-heading-safe)
        (org-flag-heading nil)
-- 
2.31.0


reply via email to

[Prev in Thread] Current Thread [Next in Thread]