From: Shankar Rao <shankar.rao@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Insert outline breadcrumbs just before headings text in agenda view
Date: Tue, 31 Aug 2021 16:02:00 +0200 [thread overview]
Message-ID: <CAGEgU=hGnXj7TSGV6pvdSeWFWP_iVwe8WRu+uh8Hjh_7NNRKLw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 3137 bytes --]
In Emacs org-mode, I have a set of TODOs in the following format:
* H1
** H2
*** H3
**** TODO [#A] File Taxes
If I activate breadcrumbs in org-agenda-prefix-format (i.e., by
doing (setf (alist-get 'agenda org-agenda-prefix-format)
" %i %-12:c%?-12t% s%b")), when I look at the agenda-todo view, it
shows up as:
H1->H2->H3->TODO [#A] File Taxes
However, I would like it to instead be displayed like this:
TODO [#A] H1->H2->H3->File Taxes
I asked about this on Reddit
<https://www.reddit.com/r/orgmode/comments/p828af/rearrange_headline_with_breadcrumbs_in_agenda/>
and Stack Exchange
<https://emacs.stackexchange.com/questions/68225/orgmode-rearrange-headline-with-breadcrumbs-in-agenda-todo-list>,
and since it
appeared that no one had already come up with a solution for
this, I decided to cook up my own using an advice function:
(defvar org-agenda-breadcrumbs-level 1
"Highest level subtree to include in Org agenda breadcrumb.")
(defun org-agenda-breadcrumbs-string ()
"Create formatted string with outline of Org subtree at point.
The outline goes up to subtree level
`org-agenda-breadcrumbs-level` and the subtree headings are
separated by `org-agenda-breadcrumbs-separator`."
(org-format-outline-path (nthcdr (1- org-agenda-breadcrumbs-level)
(org-get-outline-path))
(1- (frame-width))
nil org-agenda-breadcrumbs-separator))
(defun org-agenda-insert-breadcrumbs-before-text (args)
"In Org agenda, insert outline breadcrumbs just before heading text in ARGS.
This is an advice function for use with `org-agenda-format-item`
by doing:
(advice-add #'org-agenda-format-item :filter-args
#'org-agenda-insert-breadcrumbs-before-text)
Since ARGS is the list of arguments to be passed to
`org-agenda-format-item`, the second list element of ARGS
contains the heading text to be modified."
(org-with-point-at (org-get-at-bol 'org-marker)
(let* ((txt (org-get-heading t t t t))
(index (or (cl-search txt (cadr args)) 0))
(bc (let ((s (org-agenda-breadcrumbs-string)))
(if (eq "" s)
""
(concat s org-agenda-breadcrumbs-separator)))))
(setf (substring (cadr args) index index) bc)
args)))
(advice-add #'org-agenda-format-item :filter-args
#'org-agenda-insert-breadcrumbs-before-text)
In my init.el, because I don't want the top level headings in the
outline breadcrumbs, I also have the following:
(setq org-agenda-breadcrumbs-level 2)
In my opinion, a feature like this is of sufficiently broad
interest that it should be included in Org so that it can be enabled
without the use of an advice function. However, it's not clear to me
what would be the best interface for configuring it. For example,
it doesn't make sense to add an option for this to
org-agenda-prefix-format, since this modifies the heading text
rather than the prefix.
If people agree that this feature is of broad interest, and have
suggestions on a good configuration interface, I would be happy
to submit this as a patch.
Shankar Rao
[-- Attachment #2: Type: text/html, Size: 4025 bytes --]
reply other threads:[~2021-08-31 14:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
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='CAGEgU=hGnXj7TSGV6pvdSeWFWP_iVwe8WRu+uh8Hjh_7NNRKLw@mail.gmail.com' \
--to=shankar.rao@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).