From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Cheong Yiu Fung" Subject: Re: [PROPOSAL] New function `org-headings-to-point' and displayer. Date: Tue, 03 Dec 2019 16:47:30 +0800 Message-ID: <02346040-dd56-4179-9be4-a2b43ede9319@www.fastmail.com> References: <878snui0ay.fsf@red-bean.com> Mime-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:44547) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ic3qf-0000UD-0A for emacs-orgmode@gnu.org; Tue, 03 Dec 2019 03:47:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ic3qd-0006XV-Ox for emacs-orgmode@gnu.org; Tue, 03 Dec 2019 03:47:56 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:46339) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ic3qd-0006MG-92 for emacs-orgmode@gnu.org; Tue, 03 Dec 2019 03:47:55 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 505752275F for ; Tue, 3 Dec 2019 03:47:52 -0500 (EST) In-Reply-To: <878snui0ay.fsf@red-bean.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Charles Millar via Emacs-orgmode 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. >=20 > If people like this and want it in Org Mode, I'll do the rest of the=20= > work to package it up as a patch, with ChangeLog entry, NEWS, etc, and= =20 > post it here for review before committing. >=20 > To try it out, just evaluate both functions and then run >=20 > `M-x org-display-headings-to-point' >=20 > from somewhere deep in an org subtree. Comments/feedback welcome. >=20 > Best regards, > -Karl >=20 > (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))) >=20 > (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 lev= el." > (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 "=E2=80=A2 " title) > (concat "\n"=20 > (make-string (* level 2) ?= ) > "=E2=86=92 " title)) > (setq level (1+ level)))) > heading-titles))) > (display-message-or-buffer (string-join hierarchy)))) >=20 >