From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sharon Kimble Newsgroups: gmane.emacs.help Subject: Re: Listing headings in dedicated buffer with imenu. Date: Mon, 29 Jul 2024 12:43:47 +0100 Message-ID: <871q3cfmoc.fsf@skimble09.plus.com> References: <87ed7ctudw.fsf@gmx.net> <87a5i0tro1.fsf@gmx.net> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4299"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Heime , Heime via Users list for the GNU Emacs text editor To: Stephen Berman Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 29 13:44:36 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sYOnr-0000yg-Nd for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 29 Jul 2024 13:44:35 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sYOnM-0006to-10; Mon, 29 Jul 2024 07:44:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sYOnJ-0006t3-Tj for help-gnu-emacs@gnu.org; Mon, 29 Jul 2024 07:44:01 -0400 Original-Received: from avasout-peh-004.plus.net ([212.159.14.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sYOnF-0000VE-Jc for help-gnu-emacs@gnu.org; Mon, 29 Jul 2024 07:44:01 -0400 Original-Received: from london.london ([83.216.139.36]) by smtp with ESMTPA id YOn5sQs65X9c9YOn6sB4rw; Mon, 29 Jul 2024 12:43:49 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019; t=1722253429; bh=y6Ci11dMcxGIsfXiP4y3SjI3Aj5/CT0lx/4tbPhUCgg=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=VERD62jDEvXjB3MtHG7UvRNhQaGLRnMPvn0Y+Ui6saweFHOt6DOTLuPmvszDwt6dY PwUvA1oXb51s+Ig3SIMdDSEA7PcikwbZNURJINrwX5tr8lq1GhvdtncEjhnTQ0J2GZ j+JieRuBZrXAxnf4IzkWk49LMcJ3Omvkli8ZilNzgIp8ZidbILBFixEW7hpW9L57Dv 9BAgZv0tcYk/LhiGFreqD0xjCDIBOtF5UO/Lf1LfoSX4Rsyu13RQh8Qd8PrAupqTf1 Uv4vDI8EoKgNH5yEd/zNXJC0daezEbCZ7SGJ7xM0vZ9+DWRASrUEMuBVoloU65quxE DdjRgPAvekoHA== X-Clacks-Overhead: "GNU Terry Pratchett" X-CM-Score: 0.00 X-CNFS-Analysis: v=2.4 cv=NPx2+F6g c=1 sm=1 tr=0 ts=66a78075 a=SKv5+N4m1MpUyTdcxjs7ew==:117 a=SKv5+N4m1MpUyTdcxjs7ew==:17 a=VVlED5B4AAAA:8 a=sfOm8-O8AAAA:8 a=66WtEyHcAAAA:8 a=xY1_shhyAAAA:8 a=LlzXLoV6AAAA:8 a=iI7HsYTVAAAA:8 a=bAHfVwKlAAAA:8 a=wwt59CYJW49oEBiqtAEA:9 a=Sa0slu3GlkIA:10 a=Nww0Nbe_Bz4A:10 a=TvTJqdcANYtsRzA46cdi:22 a=68K7cVVMYdH6quYXLpCB:22 a=_qGpZPc723ggZ2AwnKam:22 a=diwpeB1DDhFXqWA7J4Up:22 a=KxyM1Xthmv57RbWRIpnN:22 a=fjrkRJ71zQ2jzMzczd-K:22 X-AUTH: skimble09@:2500 In-Reply-To: <87a5i0tro1.fsf@gmx.net> (Stephen Berman's message of "Mon, 29 Jul 2024 12:32:14 +0200") X-CMAE-Envelope: MS4xfIWgegRChiLTusJhC/7FN2csg0S+W2G92whBinWlceZM+fb8tirtOxt7RYTy1+NQt+Ss+7Lpf5q0g4neJYle9UYyCj0VwxgY0Y8usq0xyjkV7uEfLXqC sCHIFxH+sIf0SHiUYfmYjHmoquTAmqYJtO0OdzzQkXMuz9/VwQzUeC/oCI1UzYKSJQe9240a1n31rzSNmyWIrwOyazwXqy4K5Ds= Received-SPF: none client-ip=212.159.14.20; envelope-from=boudiccas@skimble09.plus.com; helo=avasout-peh-004.plus.net X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:147441 Archived-At: =2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Stephen Berman writes: > On Mon, 29 Jul 2024 10:26:22 +0000 Heime wro= te: > >> Sent with Proton Mail secure email. >> >> On Monday, July 29th, 2024 at 9:33 PM, Stephen Berman wrote: >> >>> On Mon, 29 Jul 2024 08:48:38 +0000 Heime heimeborgia@protonmail.com wro= te: >>> >>> > 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? =3D=3D=3D ** 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=3D (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=3D (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=20=20=20=20 =3D=3D=3D Thanks=20=20 Sharon. =2D --=20 A taste of linux =3D http://www.sharons.org.uk TGmeds =3D http://www.tgmeds.org.uk DrugFacts =3D https://www.drugfacts.org.uk Debian 12.6, Fluxbox 1.3.7, emacs 30.0.50, org 9.7.8=20 =2D----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=3D =3DhDTk =2D----END PGP SIGNATURE-----