From: Sharon Kimble <boudiccas@skimble09.plus.com>
To: Stephen Berman <stephen.berman@gmx.net>
Cc: Heime <heimeborgia@protonmail.com>,
Heime via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org>
Subject: Re: Listing headings in dedicated buffer with imenu.
Date: Mon, 29 Jul 2024 12:43:47 +0100 [thread overview]
Message-ID: <871q3cfmoc.fsf@skimble09.plus.com> (raw)
In-Reply-To: <87a5i0tro1.fsf@gmx.net> (Stephen Berman's message of "Mon, 29 Jul 2024 12:32:14 +0200")
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Stephen Berman <stephen.berman@gmx.net> writes:
> On Mon, 29 Jul 2024 10:26:22 +0000 Heime <heimeborgia@protonmail.com> wrote:
>
>> Sent with Proton Mail secure email.
>>
>> On Monday, July 29th, 2024 at 9:33 PM, Stephen Berman <stephen.berman@gmx.net> wrote:
>>
>>> 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
>>
>> What would I need to load it ?
>
> One way is this:
>
> (defun vodil-imenu-bfh ()
> "Insert imenu headings in order in a dedicated buffer."
> (interactive)
> (eval-when-compile
> (require 'imenu))
> (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)))
>
> Steve Berman
This is what I've been suing for years now, I hope it helps you?
===
** Imenu
*** imenu
#+BEGIN_SRC emacs-lisp
(require 'imenu)
(setq imenu-auto-rescan t
imenu-auto-rescan-maxout (* 1024 1024 10)
imenu-max-item-length 80
imenu-max-items 25
imenu-use-markers t
imenu-sort-function nil
imenu-use-popup-menu 'on-mouse
imenup-sort-ignores-case-flag t
imenu-list-auto-resize t
imenu-list-position 'left
imenu-list-size 0.1)
#+END_SRC
[2020-09-12 Sat 10:07]
#+BEGIN_SRC emacs-lisp
(set-default 'imenu-auto-rescan t)
#+END_SRC
[2020-09-14 Mon 11:17]
#+BEGIN_SRC emacs-lisp
;; setting up 'imenu'
(local-set-key "\C-x\C-a" 'outline-show-all)
(add-hook 'org-mode-hook
(lambda () (imenu-add-to-menubar "Imenu")))
(setq org-imenu-depth 4)
;;(add-hook 'rst-mode-hook
;;(lambda () (imenu-add-to-menubar "Imenu")))
;;(setq adoc-imenu-depth 2)
;;(add-hook 'markdown-mode-hook
;;(lambda () (imenu-add-to-menubar "Imenu")))
;;(setq adoc-imenu-depth 2)
;; (add-hook 'LaTeX-mode-hook
;; (lambda () (imenu-add-to-menubar "Imenu")))
;; (setq latex-imenu-depth 2)
;; (add-hook 'projectile-mode-hook
;; (lambda () (imenu-add-to-menubar "Imenu")))
;; (setq org-imenu-depth 0)
#+END_SRC
[2015-04-08 Wed 23:54]
[2017-01-17 Tue 11:04]
[2021-01-19 Tue 04:05]
*** imenu+
#+BEGIN_SRC emacs-lisp
(require 'imenu+)
(global-set-key (kbd "C-x 2") 'imenu-add-to-menubar)
#+END_SRC
[2020-09-13 Sun 15:14]
http://www.howardism.org/Technical/Emacs/imenu.html
*** imenu-3
#+BEGIN_SRC emacs-lisp
;; Jump to a definition in the current file. (This is awesome.)
(global-set-key (kbd "M-i") 'prelude-ido-goto-symbol)
(require 'imenu)
(set-default 'imenu-auto-rescan t)
(defun prelude-ido-goto-symbol (&optional symbol-list)
"Refresh imenu and jump to a place in the buffer using Ido."
(interactive)
(unless (featurep 'imenu)
(require 'imenu nil t))
(cond
((not symbol-list)
(let ((ido-mode ido-mode)
(ido-enable-flex-matching
(if (boundp 'ido-enable-flex-matching)
ido-enable-flex-matching t))
name-and-pos symbol-names position)
(unless ido-mode
(ido-mode 1)
(setq ido-enable-flex-matching t))
(while (progn
(imenu--cleanup)
(setq imenu--index-alist nil)
(prelude-ido-goto-symbol (imenu--make-index-alist))
(setq selected-symbol
(ido-completing-read "Symbol " symbol-names))
(string= (car imenu--rescan-item) selected-symbol)))
(unless (and (boundp 'mark-active) mark-active)
(push-mark nil t nil))
(setq position (cdr (assoc selected-symbol name-and-pos)))
(cond
((overlayp position)
(goto-char (overlay-start position)))
(t
(goto-char position)))))
((listp symbol-list)
(dolist (symbol symbol-list)
(let (name position)
(cond
((and (listp symbol) (imenu--subalist-p symbol))
(prelude-ido-goto-symbol symbol))
((listp symbol)
(setq name (car symbol))
(setq position (cdr symbol)))
((stringp symbol)
(setq name symbol)
(setq position
(get-text-property 1 'org-imenu-marker symbol))))
(unless (or (null position) (null name)
(string= (car imenu--rescan-item) name))
(add-to-list 'symbol-names name)
(add-to-list 'name-and-pos (cons name position))))))))
#+END_SRC
[2014-11-16 Sun 16:09]
[2017-01-16 Mon 23:49]
https://www.emacswiki.org/emacs/ImenuMode
*** imenu-list
#+BEGIN_SRC emacs-lisp
(require 'imenu-list)
(setq imenu-list-size 0.1)
;;(global-set-key (kbd "M-g 1") #'imenu-list-smart-toggle)
(global-set-key (kbd "C-c C-`") #'imenu-list-smart-toggle)
(setq imenu-list-focus-after-activation t)
(setq imenu-list-auto-resize t)
(setq imenu-list-position 'left)
(setq imenu-list-after-jump-hook nil)
#+END_SRC
===
Thanks
Sharon.
- --
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk
Debian 12.6, Fluxbox 1.3.7, emacs 30.0.50, org 9.7.8
-----BEGIN PGP SIGNATURE-----
iQJRBAEBCgA7FiEELSc/6QwVBIYugJDbNoGAGQr4g1sFAmangHMdHGJvdWRpY2Nh
c0Bza2ltYmxlMDkucGx1cy5jb20ACgkQNoGAGQr4g1tdoA//RQnIMxX9N0tiW1fn
EOxe0yKZC8T8ei/8K1fH/bYbkLIBhJTwopV7XLK8vVuCHm8io6fsD6bkNt2+Vrvq
vTmCilSt/as6i9xJO16LA2Ptl42MUyo9W9v8dQHVvOR9I/LnfG2Vq3DB0KS+RcFc
Vgyl8GDv1i4gqlOwKscKKsexwGZ2sejuy2H/GtlPa9QN8FPbSyW8XCptZVO1CnsG
be3d1yteMCzRKF0LRewb5MWKvxqTicr3+uMsT7W8FylKfIjrmmur37k6kZVhE+rZ
IYqR2zt8cU6MLoVMe0vB7pg+kG4FMe1+R0eL5lVglQ9LUX8DyZKgDhNUeNuUd4dd
rZU5vNtin84HUrMkuI+nhgOuhwPxQOQOwpIGXFeslXMA7eeom1/yMlgXbaGoKtVH
IHeASSIOUn5r+IwX6MOam5j4oQOC+lqUedeTK898oDYp2VzqL5SXBXaNzikXc3Uc
X0bKoTIGt7QbrLIK0ncs4i35tr3Zdr4Ig8xqs5i0Ry3WLwwlT8CJV4/BYp2l+F2O
XpOXBcrjTnfixcsS+OtcqfXBTb/jxRxoJfAlzI7DxX5UwFI7Yk36lfeXhry0OfE8
1KK31FQulLw9pafTROs5hvTifou0X0aC6l+qT8GVugGK2Fa3BQdOzEjQ5srZc5wx
OyYPdacnHKwUxAOXKPktcDQQUX4=
=hDTk
-----END PGP SIGNATURE-----
prev parent reply other threads:[~2024-07-29 11:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-29 8:48 Listing headings in dedicated buffer with imenu Heime
2024-07-29 9:33 ` Stephen Berman
2024-07-29 10:26 ` Heime
2024-07-29 10:32 ` Heime
2024-07-29 10:32 ` Stephen Berman
2024-07-29 10:41 ` Heime
2024-07-29 10:51 ` Stephen Berman
2024-07-29 11:29 ` Heime
2024-07-29 11:45 ` Stephen Berman
2024-07-29 11:53 ` Heime
2024-07-29 13:02 ` Stephen Berman
2024-07-30 15:59 ` Heime
2024-07-30 21:30 ` Heime
2024-07-31 8:35 ` Stephen Berman
2024-07-29 11:43 ` Sharon Kimble [this message]
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.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871q3cfmoc.fsf@skimble09.plus.com \
--to=boudiccas@skimble09.plus.com \
--cc=heimeborgia@protonmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=stephen.berman@gmx.net \
/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.
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).