From: "Cheong Yiu Fung" <mail@yiufung.net>
To: Charles Millar via Emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: [PROPOSAL] New function `org-headings-to-point' and displayer.
Date: Tue, 03 Dec 2019 16:47:30 +0800 [thread overview]
Message-ID: <02346040-dd56-4179-9be4-a2b43ede9319@www.fastmail.com> (raw)
In-Reply-To: <878snui0ay.fsf@red-bean.com>
This is really useful. Thanks!
Yiufung
On Tue, Dec 3, 2019, at 10:56 AM, Karl Fogel wrote:
> Hi. I've been using this for a while and find it very handy.
>
> If people like this and want it in Org Mode, I'll do the rest of the
> work to package it up as a patch, with ChangeLog entry, NEWS, etc, and
> post it here for review before committing.
>
> To try it out, just evaluate both functions and then run
>
> `M-x org-display-headings-to-point'
>
> from somewhere deep in an org subtree. Comments/feedback welcome.
>
> Best regards,
> -Karl
>
> (defun org-headings-to-point ()
> "Return all the Org Mode headings leading to point."
> (when (not (eq major-mode 'org-mode))
> (error "ERROR: this only works in Org Mode"))
> (let ((headings (list (org-heading-components))))
> (save-excursion
> (save-match-data
> (save-restriction
> (widen)
> (while (org-up-heading-safe)
> (setq headings (cons (org-heading-components) headings)))))
> headings)))
>
> (defun org-display-headings-to-point ()
> "Display Org Mode heading titles from level 1 to current subtree.
> Display each title on its own line, indented proportionally to its level."
> (interactive)
> (let* ((heading-titles (mapcar (lambda (heading)
> (nth 4 heading))
> (org-headings-to-point)))
> (level 0)
> (hierarchy (mapcar (lambda (title)
> (prog1
> (if (zerop level)
> (concat "• " title)
> (concat "\n"
> (make-string (* level 2) ? )
> "→ " title))
> (setq level (1+ level))))
> heading-titles)))
> (display-message-or-buffer (string-join hierarchy))))
>
>
next prev parent reply other threads:[~2019-12-03 8:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-03 2:56 [PROPOSAL] New function `org-headings-to-point' and displayer Karl Fogel
2019-12-03 7:30 ` Diego Zamboni
2019-12-03 8:47 ` Cheong Yiu Fung [this message]
2019-12-03 22:06 ` Adam Porter
2019-12-03 23:34 ` Karl Fogel
2019-12-04 2:38 ` Adam Porter
2019-12-05 3:04 ` Karl Fogel
2019-12-05 8:42 ` Adam Porter
2019-12-05 8:47 ` Adam Porter
2019-12-05 22:36 ` Karl Fogel
2019-12-03 23:36 ` Karl Fogel
2019-12-04 2:20 ` Adam Porter
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=02346040-dd56-4179-9be4-a2b43ede9319@www.fastmail.com \
--to=mail@yiufung.net \
--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).