help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Listing headings in dedicated buffer with imenu.


From: Stephen Berman
Subject: Re: Listing headings in dedicated buffer with imenu.
Date: Mon, 29 Jul 2024 11:33:31 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

On Mon, 29 Jul 2024 08:48:38 +0000 Heime <heimeborgia@protonmail.com> wrote:

> I wish to list headings in a dedicated buffer with imenu.
> The listing should be in the order in which headings occur
> in the buffer.
>
> Have done the following, but the buffer ends up empty.
>
> (defun vodil-imenu-bfh ()
>   "Insert imenu headings in order in a dedicated buffer."
>   (interactive)
>
>   (let ((imenu-items (imenu--make-index-alist t))
>         (buffer-name "*Imenu Headings*"))
>     (with-current-buffer (get-buffer-create buffer-name)
>       (erase-buffer)
>       (dolist (item imenu-items)
>         (let ((name (car item))
>               (position (cdr item)))
>           (when (and (stringp name) (number-or-marker-p position))
>             (insert (format "%s\n" name)))))
>       (goto-char (point-min)))
>     (pop-to-buffer buffer-name)))

It works for me, as long as imenu.el is loaded.

Steve Berman



reply via email to

[Prev in Thread] Current Thread [Next in Thread]