emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org.el (org-show-context-detail): add option 'ancestors-with-entry
@ 2021-04-16 13:39 Cheong Yiu Fung
  2021-04-19  8:21 ` Nicolas Goaziou
  0 siblings, 1 reply; 10+ messages in thread
From: Cheong Yiu Fung @ 2021-04-16 13:39 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1639 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org.el-org-show-context-detail-add-option-ancestors-.patch --]
[-- Type: text/x-patch, Size: 1935 bytes --]

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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-04-27 20:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-16 13:39 [PATCH] org.el (org-show-context-detail): add option 'ancestors-with-entry Cheong Yiu Fung
2021-04-19  8:21 ` Nicolas Goaziou
2021-04-19 16:03   ` Cheong Yiu Fung
2021-04-20 13:15     ` Nicolas Goaziou
2021-04-20 13:38       ` Cheong Yiu Fung
2021-04-21  9:15         ` Cheong Yiu Fung
2021-04-21  9:51           ` Cheong Yiu Fung
2021-04-22 13:32             ` Nicolas Goaziou
2021-04-22 15:31               ` Cheong Yiu Fung
2021-04-27 20:31                 ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).