emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Cheong Yiu Fung <mail@yiufung.net>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org.el (org-show-context-detail): add option 'ancestors-with-entry
Date: Fri, 16 Apr 2021 21:39:29 +0800	[thread overview]
Message-ID: <878s5inyb2.fsf@yiufung.net> (raw)

[-- 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

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


[-- 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

* 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',
   ;; 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)
     ;; If point is hidden within a drawer or a block, make sure to
@@ -6775,14 +6776,14 @@ information."
        (cl-case detail
 	 ((tree canonical t) (org-show-children))
-	 ((nil minimal ancestors))
+	 ((nil minimal ancestors ancestors-with-entry))
 	 (t (save-excursion
 	      (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))
       (while (org-up-heading-safe)
 	(org-flag-heading nil)

             reply	other threads:[~2021-04-16 13:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16 13:39 Cheong Yiu Fung [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878s5inyb2.fsf@yiufung.net \
    --to=mail@yiufung.net \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: [PATCH] org.el (org-show-context-detail): add option '\''ancestors-with-entry' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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


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).