From mboxrd@z Thu Jan 1 00:00:00 1970 From: Karl Fogel Subject: [PROPOSAL] New function `org-headings-to-point' and displayer. Date: Mon, 02 Dec 2019 20:56:53 -0600 Message-ID: <878snui0ay.fsf@red-bean.com> Reply-To: Karl Fogel 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]:54201) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibyN0-0002wq-4r for emacs-orgmode@gnu.org; Mon, 02 Dec 2019 21:56:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ibyMz-0005xJ-0i for emacs-orgmode@gnu.org; Mon, 02 Dec 2019 21:56:57 -0500 Received: from mail-yb1-xb30.google.com ([2607:f8b0:4864:20::b30]:41006) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ibyMy-0005vJ-PL for emacs-orgmode@gnu.org; Mon, 02 Dec 2019 21:56:56 -0500 Received: by mail-yb1-xb30.google.com with SMTP id d95so964172ybi.8 for ; Mon, 02 Dec 2019 18:56:56 -0800 (PST) Received: from kwork (c-67-173-70-191.hsd1.il.comcast.net. [67.173.70.191]) by smtp.gmail.com with ESMTPSA id a22sm843393ywh.93.2019.12.02.18.56.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 18:56:54 -0800 (PST) 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: Org-mode 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 t= o package it up as a patch, with ChangeLog entry, NEWS, etc, and post it he= re 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 "=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))))