From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adam Porter Subject: Re: How to capture export prepended header numbering Date: Mon, 30 Dec 2019 18:31:53 -0600 Message-ID: <87eewljpxi.fsf@alphapapa.net> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:51322) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1im5SB-00059x-MP for emacs-orgmode@gnu.org; Mon, 30 Dec 2019 19:32:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1im5S9-0004zo-Oe for emacs-orgmode@gnu.org; Mon, 30 Dec 2019 19:32:07 -0500 Received: from 195-159-176-226.customer.powertech.no ([195.159.176.226]:45748 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1im5S9-0004t0-Gp for emacs-orgmode@gnu.org; Mon, 30 Dec 2019 19:32:05 -0500 Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1im5S6-0009I9-8e for emacs-orgmode@gnu.org; Tue, 31 Dec 2019 01:32:02 +0100 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: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain There is no built-in way to do that, and no way independent of org-export to get the numbers, AFAIK. Here's some ugly old code that shows outline numbering as overlays in an Org buffer. It doesn't update automatically, so you have to run it again when the outline changes. But it seems to work well. It uses dash.el and let-alist, in case you don't have them loaded. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=mike-0ac22.el Content-Transfer-Encoding: quoted-printable Content-Description: ap/org-outline-numbers (defun ap/org-outline-numbers () (interactive) (save-excursion (let* ((positions-levels (progn (goto-char (point-min)) (when (org-before-first-heading-p) (outline-next-heading)) (cl-loop while (not (eobp)) collect (cons (point) (org-current-= level)) do (outline-next-heading)))) (tree (cl-loop with current-top-level =3D 0 with current-subtree-numbers with results with previous-level for (position . level) in positions-levels if (=3D 1 level) do (progn (setq current-subtree-numbers nil) (setq previous-level level) (push (list (cons 'heading (save-excursion (goto-char posi= tion) (substring-no-p= roperties (org-get-headi= ng t t)))) (cons 'position position) (cons 'level level) (cons 'number (concat (number-to= -string (setq cur= rent-top-level (1+ current-top-level))) "."))) results)) else do (let* ((current-level-number (cond ((<=3D= level previous-level) (incf= (map-elt current-subtree-numbers level))) ((> le= vel previous-level) 1))) text-number) (setq previous-level level) (map-put current-subtree-numbers level = current-level-number) (setq text-number (cl-loop for lookup from level do= wnto 1 for lookedup =3D (map-el= t current-subtree-numbers lookup) if lookedup collect lookedup into re= sult else collect current-top= -level into result finally return (s-join "= ." (mapcar #'number-to-string (nreverse result))))) (push (list (cons 'heading (save-excurs= ion (goto-char= position) (substring= -no-properties (org-get-= heading t t)))) (cons 'position position) (cons 'level level) (cons 'number text-number)) results)) finally return (nreverse results)))) (remove-overlays nil nil 'org-outline-numbers) (--each tree (let-alist it (let ((ov (make-overlay (+ .position (1- .level)) (+ .position .l= evel)))) (overlay-put ov 'display .number) (overlay-put ov 'org-outline-numbers t))))))) --=-=-=--