annotate lisp/imenu.el @ 100678:902eaa5d8429

Add bug id for recently fixed bug
author Jason Rumney <jasonr@gnu.org>
date Thu, 25 Dec 2008 01:07:49 +0000
parents d42aff5ca541
children a9dc0e7c3f2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 36637
diff changeset
1 ;;; imenu.el --- framework for mode-specific buffer indexes
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
74442
b2e5081b9320 Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 72595
diff changeset
3 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 2001, 2002, 2003, 2004,
87567
4c3c683cdff8 * erc-ibuffer.el (erc-channel-modes):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78492
diff changeset
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Author: Ake Stenhoff <etxaksf@aom.ericsson.se>
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Lars Lindberg <lli@sypro.cap.se>
17970
720d1f98ae42 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17677
diff changeset
8 ;; Maintainer: FSF
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; Created: 8 Feb 1994
22250
a77d473867b8 *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21959
diff changeset
10 ;; Keywords: tools convenience
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
11
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
12 ;; This file is part of GNU Emacs.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
13
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87567
diff changeset
14 ;; GNU Emacs is free software: you can redistribute it and/or modify
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87567
diff changeset
16 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87567
diff changeset
17 ;; (at your option) any later version.
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
18
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; GNU General Public License for more details.
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
23
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87567
diff changeset
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
28
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; Purpose of this package:
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; To present a framework for mode-specific buffer indexes.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; A buffer index is an alist of names and buffer positions.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; For instance all functions in a C-file and their positions.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;;
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
34 ;; It is documented in the Emacs Lisp manual.
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
35 ;;
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; How it works:
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; A mode-specific function is called to generate the index. It is
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; then presented to the user, who can choose from this index.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; The package comes with a set of example functions for how to
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; utilize this package.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
44 ;; There are *examples* for index gathering functions/regular
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
45 ;; expressions for C/C++ and Lisp/Emacs Lisp but it is easy to
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
46 ;; customize for other modes. A function for jumping to the chosen
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
47 ;; index position is also supplied.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
49 ;;; History:
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
50 ;; Thanks go to
6241
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
51 ;; [simon] - Simon Leinen simon@lia.di.epfl.ch
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
52 ;; [dean] - Dean Andrews ada@unison.com
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
53 ;; [alon] - Alon Albert al@mercury.co.il
9176
5646f9ac8ec3 (imenu--cleanup): Changed 'mapc' to 'mapcar'.
Richard M. Stallman <rms@gnu.org>
parents: 8408
diff changeset
54 ;; [greg] - Greg Thompson gregt@porsche.visix.COM
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
55 ;; [wolfgang] - Wolfgang Bangerth zcg51122@rpool1.rus.uni-stuttgart.de
10072
a7b70665c937 (imenu): Widen temporary before scan the file.
Richard M. Stallman <rms@gnu.org>
parents: 9176
diff changeset
56 ;; [kai] - Kai Grossjohann grossjoh@linus.informatik.uni-dortmund.de
10221
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
57 ;; [david] - David M. Smith dsmith@stats.adelaide.edu.au
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
58 ;; [christian] - Christian Egli Christian.Egli@hcsd.hac.com
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
59 ;; [karl] - Karl Fogel kfogel@floss.life.uiuc.edu
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
60
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 36637
diff changeset
61 ;;; Code:
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
62
6909
9e59751db725 Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents: 6241
diff changeset
63 (eval-when-compile (require 'cl))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;;; Customizable variables
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
70
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
71 (defgroup imenu nil
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
72 "Mode-specific buffer indexes."
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
73 :group 'matching
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
74 :group 'frames
22250
a77d473867b8 *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21959
diff changeset
75 :group 'convenience
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
76 :link '(custom-manual "(elisp)Imenu"))
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
77
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
78 (defcustom imenu-use-markers t
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 98404
diff changeset
79 "Non-nil means use markers instead of integers for Imenu buffer positions.
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
80
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
81 Setting this to nil makes Imenu work a little faster but editing the
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
82 buffer will make the generated index positions wrong.
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
83
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
84 This might not yet be honored by all index-building functions."
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
85 :type 'boolean
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
86 :group 'imenu)
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
87
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
88
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
89 (defcustom imenu-max-item-length 60
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 98404
diff changeset
90 "If a number, truncate Imenu entries to that length."
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
91 :type '(choice integer
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
92 (const :tag "Unlimited"))
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
93 :group 'imenu)
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
94
17677
3ab08563e855 (imenu-auto-rescan): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents: 17634
diff changeset
95 (defcustom imenu-auto-rescan nil
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 98404
diff changeset
96 "Non-nil means Imenu should always rescan the buffers."
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
97 :type 'boolean
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
98 :group 'imenu)
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
99
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
100 (defcustom imenu-auto-rescan-maxout 60000
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 98404
diff changeset
101 "Imenu auto-rescan is disabled in buffers larger than this size (in bytes).
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
102 This variable is buffer-local."
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
103 :type 'integer
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
104 :group 'imenu)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105
46894
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
106 (defvar imenu-always-use-completion-buffer-p nil)
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
107 (make-obsolete-variable 'imenu-always-use-completion-buffer-p
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59568
diff changeset
108 'imenu-use-popup-menu "22.1")
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109
46894
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
110 (defcustom imenu-use-popup-menu
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
111 (if imenu-always-use-completion-buffer-p
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
112 (not (eq imenu-always-use-completion-buffer-p 'never))
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
113 'on-mouse)
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
114 "Use a popup menu rather than a minibuffer prompt.
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
115 If nil, always use a minibuffer prompt.
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
116 If t, always use a popup menu,
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
117 If `on-mouse' use a popup menu when `imenu' was invoked with the mouse."
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
118 :type '(choice (const :tag "On Mouse" on-mouse)
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
119 (const :tag "Never" nil)
62531
c905fcf5e3d9 Specify missing group (and type, if simple) in defcustom.
Juanma Barranquero <lekktu@gmail.com>
parents: 61769
diff changeset
120 (other :tag "Always" t))
c905fcf5e3d9 Specify missing group (and type, if simple) in defcustom.
Juanma Barranquero <lekktu@gmail.com>
parents: 61769
diff changeset
121 :group 'imenu)
46894
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
122
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
123 (defcustom imenu-eager-completion-buffer
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
124 (not (eq imenu-always-use-completion-buffer-p 'never))
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
125 "If non-nil, eagerly popup the completion buffer."
57926
f697668630d7 (imenu-eager-completion-buffer): Add :version.
Richard M. Stallman <rms@gnu.org>
parents: 57775
diff changeset
126 :type 'boolean
f697668630d7 (imenu-eager-completion-buffer): Add :version.
Richard M. Stallman <rms@gnu.org>
parents: 57775
diff changeset
127 :group 'imenu
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59568
diff changeset
128 :version "22.1")
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
25810
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
130 (defcustom imenu-after-jump-hook nil
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 98404
diff changeset
131 "Hooks called after jumping to a place in the buffer.
25810
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
132
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
133 Useful things to use here include `reposition-window', `recenter', and
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
134 \(lambda () (recenter 0)) to show at top of screen."
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
135 :type 'hook
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
136 :group 'imenu)
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
137
22798
434ac4a14be3 (imenu-create-index-function): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 22628
diff changeset
138 ;;;###autoload
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
139 (defcustom imenu-sort-function nil
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 98404
diff changeset
140 "The function to use for sorting the index mouse-menu.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 Affects only the mouse index menu.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 Set this to nil if you don't want any sorting (faster).
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 The items in the menu are then presented in the order they were found
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 in the buffer.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147
6909
9e59751db725 Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents: 6241
diff changeset
148 Set it to `imenu--sort-by-name' if you want alphabetic sorting.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149
23358
3812bb3ae006 (imenu--generic-function): Sort each submenu by position.
Karl Heuer <kwzh@gnu.org>
parents: 22798
diff changeset
150 The function should take two arguments and return t if the first
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 element should come before the second. The arguments are cons cells;
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
152 \(NAME . POSITION). Look at `imenu--sort-by-name' for an example."
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
153 :type '(choice (const :tag "No sorting" nil)
24233
5e43fcb42e81 (imenu-sort-function): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 23358
diff changeset
154 (const :tag "Sort by name" imenu--sort-by-name)
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
155 (function :tag "Another function"))
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
156 :group 'imenu)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
158 (defcustom imenu-max-items 25
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 98404
diff changeset
159 "Maximum number of elements in a mouse menu for Imenu."
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
160 :type 'integer
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
161 :group 'imenu)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162
57775
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
163 ;; No longer used. KFS 2004-10-27
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
164 ;; (defcustom imenu-scanning-message "Scanning buffer for index (%3d%%)"
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
165 ;; "*Progress message during the index scanning of the buffer.
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
166 ;; If non-nil, user gets a message during the scanning of the buffer.
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
167 ;;
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
168 ;; Relevant only if the mode-specific function that creates the buffer
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
169 ;; index use `imenu-progress-message', and not useful if that is fast, in
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
170 ;; which case you might as well set this to nil."
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
171 ;; :type '(choice string
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
172 ;; (const :tag "None" nil))
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
173 ;; :group 'imenu)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174
22628
d5a086ed37f5 (imenu-space-replacement): Use `.'.
Richard M. Stallman <rms@gnu.org>
parents: 22586
diff changeset
175 (defcustom imenu-space-replacement "."
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 98404
diff changeset
176 "The replacement string for spaces in index names.
22628
d5a086ed37f5 (imenu-space-replacement): Use `.'.
Richard M. Stallman <rms@gnu.org>
parents: 22586
diff changeset
177 Used when presenting the index in a completion buffer to make the
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
178 names work as tokens."
46894
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
179 :type '(choice string (const nil))
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
180 :group 'imenu)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
182 (defcustom imenu-level-separator ":"
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 98404
diff changeset
183 "The separator between index names of different levels.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 Used for making mouse-menu titles and for flattening nested indexes
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
185 with name concatenation."
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
186 :type 'string
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
187 :group 'imenu)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
189 ;;;###autoload
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
190 (defvar imenu-generic-expression nil
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
191 "The regex pattern to use for creating a buffer index.
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
192
62568
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
193 If non-nil this pattern is passed to `imenu--generic-function' to
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
194 create a buffer index. Look there for the documentation of this
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
195 pattern's structure.
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
196
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
197 For example, see the value of `fortran-imenu-generic-expression' used by
36013
fc00137bf0bf (imenu-generic-expression): Doc fix.
Dave Love <fx@gnu.org>
parents: 35688
diff changeset
198 `fortran-mode' with `imenu-syntax-alist' set locally to give the
fc00137bf0bf (imenu-generic-expression): Doc fix.
Dave Love <fx@gnu.org>
parents: 35688
diff changeset
199 characters which normally have \"symbol\" syntax \"word\" syntax
fc00137bf0bf (imenu-generic-expression): Doc fix.
Dave Love <fx@gnu.org>
parents: 35688
diff changeset
200 during matching.")
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
201
14816
485422b900d3 (imenu-generic-expression): Autoload the make-variable-buffer-local call.
Richard M. Stallman <rms@gnu.org>
parents: 14798
diff changeset
202 ;;;###autoload
12664
ce1cae301efe (imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents: 12635
diff changeset
203 (make-variable-buffer-local 'imenu-generic-expression)
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
204
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 ;;;; Hooks
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206
22798
434ac4a14be3 (imenu-create-index-function): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 22628
diff changeset
207 ;;;###autoload
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (defvar imenu-create-index-function 'imenu-default-create-index-function
70098
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
209 "The function to use for creating an index alist of the current buffer.
16271
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
210
70098
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
211 It should be a function that takes no arguments and returns
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
212 an index alist of the current buffer. The function is
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
213 called within a `save-excursion'.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214
70098
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
215 See `imenu--index-alist' for the format of the buffer index alist.")
22798
434ac4a14be3 (imenu-create-index-function): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 22628
diff changeset
216 ;;;###autoload
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (make-variable-buffer-local 'imenu-create-index-function)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218
22798
434ac4a14be3 (imenu-create-index-function): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 22628
diff changeset
219 ;;;###autoload
7319
cd73ba498964 (imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents: 6909
diff changeset
220 (defvar imenu-prev-index-position-function 'beginning-of-defun
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 "Function for finding the next index position.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222
6909
9e59751db725 Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents: 6241
diff changeset
223 If `imenu-create-index-function' is set to
9e59751db725 Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents: 6241
diff changeset
224 `imenu-default-create-index-function', then you must set this variable
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 to a function that will find the next index, looking backwards in the
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 file.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 The function should leave point at the place to be connected to the
56549
7e0e6be19969 (imenu-prev-index-position-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55826
diff changeset
229 index and it should return nil when it doesn't find another index.")
22798
434ac4a14be3 (imenu-create-index-function): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 22628
diff changeset
230 ;;;###autoload
7319
cd73ba498964 (imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents: 6909
diff changeset
231 (make-variable-buffer-local 'imenu-prev-index-position-function)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232
22798
434ac4a14be3 (imenu-create-index-function): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 22628
diff changeset
233 ;;;###autoload
7319
cd73ba498964 (imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents: 6909
diff changeset
234 (defvar imenu-extract-index-name-function nil
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
235 "Function for extracting the index item name, given a position.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236
20857
185fa242a2ea (imenu-generic-expression): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20770
diff changeset
237 This function is called after `imenu-prev-index-position-function'
185fa242a2ea (imenu-generic-expression): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20770
diff changeset
238 finds a position for an index item, with point at that position.
56549
7e0e6be19969 (imenu-prev-index-position-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55826
diff changeset
239 It should return the name for that index item.")
22798
434ac4a14be3 (imenu-create-index-function): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 22628
diff changeset
240 ;;;###autoload
7319
cd73ba498964 (imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents: 6909
diff changeset
241 (make-variable-buffer-local 'imenu-extract-index-name-function)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242
22798
434ac4a14be3 (imenu-create-index-function): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 22628
diff changeset
243 ;;;###autoload
25810
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
244 (defvar imenu-name-lookup-function nil
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
245 "Function to compare string with index item.
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
246
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
247 This function will be called with two strings, and should return
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
248 non-nil if they match.
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
249
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
250 If nil, comparison is done with `string='.
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
251 Set this to some other function for more advanced comparisons,
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
252 such as \"begins with\" or \"name matches and number of
56549
7e0e6be19969 (imenu-prev-index-position-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55826
diff changeset
253 arguments match\".")
25810
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
254 ;;;###autoload
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
255 (make-variable-buffer-local 'imenu-name-lookup-function)
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
256
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
257 ;;;###autoload
17229
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
258 (defvar imenu-default-goto-function 'imenu-default-goto-function
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
259 "The default function called when selecting an Imenu item.
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
260 The function in this variable is called when selecting a normal index-item.")
22798
434ac4a14be3 (imenu-create-index-function): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 22628
diff changeset
261 ;;;###autoload
17229
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
262 (make-variable-buffer-local 'imenu-default-goto-function)
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
263
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
264
16271
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
265 (defun imenu--subalist-p (item)
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
266 (and (consp (cdr item)) (listp (cadr item))
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
267 (not (eq (car (cadr item)) 'lambda))))
16271
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
268
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
269 ;; Macro to display a progress message.
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
270 ;; RELPOS is the relative position to display.
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
271 ;; If RELPOS is nil, then the relative position in the buffer
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
272 ;; is calculated.
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
273 ;; PREVPOS is the variable in which we store the last position displayed.
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
274 (defmacro imenu-progress-message (prevpos &optional relpos reverse)
57775
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
275
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
276 ;; Made obsolete/empty, as computers are now faster than the eye, and
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
277 ;; it had problems updating the messages correctly, and could shadow
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
278 ;; more important messages/prompts in the minibuffer. KFS 2004-10-27.
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
279
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
280 ;; `(and
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
281 ;; imenu-scanning-message
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
282 ;; (let ((pos ,(if relpos
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
283 ;; relpos
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
284 ;; `(imenu--relative-position ,reverse))))
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
285 ;; (if ,(if relpos t
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
286 ;; `(> pos (+ 5 ,prevpos)))
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
287 ;; (progn
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
288 ;; (message imenu-scanning-message pos)
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
289 ;; (setq ,prevpos pos)))))
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
290 )
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
291
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
292
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
293 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
294 ;;;;
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
295 ;;;; Some examples of functions utilizing the framework of this
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
296 ;;;; package.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
297 ;;;;
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
298 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
299
57417
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
300 ;; FIXME: This is the only imenu-example-* definition that's actually used,
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
301 ;; and it seems to only be used by cperl-mode.el. We should just move it to
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
302 ;; cperl-mode.el and remove the rest.
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
303 (defun imenu-example--name-and-position ()
57417
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
304 "Return the current/previous sexp and its (beginning) location.
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
305 Don't move point."
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
306 (save-excursion
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
307 (forward-sexp -1)
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
308 ;; [ydi] modified for imenu-use-markers
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
309 (let ((beg (if imenu-use-markers (point-marker) (point)))
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
310 (end (progn (forward-sexp) (point))))
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
311 (cons (buffer-substring beg end)
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
312 beg))))
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
313
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
314 ;;;
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
315 ;;; Lisp
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
316 ;;;
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
317
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
318 (defun imenu-example--lisp-extract-index-name ()
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
319 ;; Example of a candidate for `imenu-extract-index-name-function'.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
320 ;; This will generate a flat index of definitions in a lisp file.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
321 (save-match-data
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
322 (and (looking-at "(def")
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
323 (condition-case nil
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
324 (progn
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
325 (down-list 1)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
326 (forward-sexp 2)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
327 (let ((beg (point))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
328 (end (progn (forward-sexp -1) (point))))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
329 (buffer-substring beg end)))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
330 (error nil)))))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
331
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
332 (defun imenu-example--create-lisp-index ()
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
333 ;; Example of a candidate for `imenu-create-index-function'.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
334 ;; It will generate a nested index of definitions.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
335 (let ((index-alist '())
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
336 (index-var-alist '())
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
337 (index-type-alist '())
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
338 (index-unknown-alist '())
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
339 prev-pos)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
340 (goto-char (point-max))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
341 (imenu-progress-message prev-pos 0)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
342 ;; Search for the function
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
343 (while (beginning-of-defun)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
344 (imenu-progress-message prev-pos nil t)
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
345 (save-match-data
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
346 (and (looking-at "(def")
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
347 (save-excursion
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
348 (down-list 1)
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
349 (cond
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
350 ((looking-at "def\\(var\\|const\\)")
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
351 (forward-sexp 2)
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
352 (push (imenu-example--name-and-position)
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
353 index-var-alist))
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
354 ((looking-at "def\\(un\\|subst\\|macro\\|advice\\)")
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
355 (forward-sexp 2)
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
356 (push (imenu-example--name-and-position)
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
357 index-alist))
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
358 ((looking-at "def\\(type\\|struct\\|class\\|ine-condition\\)")
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
359 (forward-sexp 2)
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
360 (if (= (char-after (1- (point))) ?\))
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
361 (progn
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
362 (forward-sexp -1)
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
363 (down-list 1)
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
364 (forward-sexp 1)))
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
365 (push (imenu-example--name-and-position)
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
366 index-type-alist))
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
367 (t
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
368 (forward-sexp 2)
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
369 (push (imenu-example--name-and-position)
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
370 index-unknown-alist)))))))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
371 (imenu-progress-message prev-pos 100)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
372 (and index-var-alist
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
373 (push (cons "Variables" index-var-alist)
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
374 index-alist))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
375 (and index-type-alist
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
376 (push (cons "Types" index-type-alist)
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
377 index-alist))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
378 (and index-unknown-alist
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
379 (push (cons "Syntax-unknown" index-unknown-alist)
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
380 index-alist))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
381 index-alist))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
382
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
383 ;; Regular expression to find C functions
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
384 (defvar imenu-example--function-name-regexp-c
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
385 (concat
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
386 "^[a-zA-Z0-9]+[ \t]?" ; type specs; there can be no
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
387 "\\([a-zA-Z0-9_*]+[ \t]+\\)?" ; more than 3 tokens, right?
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
388 "\\([a-zA-Z0-9_*]+[ \t]+\\)?"
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
389 "\\([*&]+[ \t]*\\)?" ; pointer
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
390 "\\([a-zA-Z0-9_*]+\\)[ \t]*(" ; name
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
391 ))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
392
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
393 (defun imenu-example--create-c-index (&optional regexp)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
394 (let ((index-alist '())
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
395 prev-pos char)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
396 (goto-char (point-min))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
397 (imenu-progress-message prev-pos 0)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
398 ;; Search for the function
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
399 (save-match-data
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
400 (while (re-search-forward
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
401 (or regexp imenu-example--function-name-regexp-c)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
402 nil t)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
403 (imenu-progress-message prev-pos)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
404 (backward-up-list 1)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
405 (save-excursion
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
406 (goto-char (scan-sexps (point) 1))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
407 (setq char (following-char)))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
408 ;; Skip this function name if it is a prototype declaration.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
409 (if (not (eq char ?\;))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
410 (push (imenu-example--name-and-position) index-alist))))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
411 (imenu-progress-message prev-pos 100)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
412 (nreverse index-alist)))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
413
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
414
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 ;;; Internal variables
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 ;; The item to use in the index for rescanning the buffer.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (defconst imenu--rescan-item '("*Rescan*" . -99))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 ;; The latest buffer index.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 ;; Buffer local.
20857
185fa242a2ea (imenu-generic-expression): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20770
diff changeset
426 (defvar imenu--index-alist nil
70098
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
427 "The buffer index alist computed for this buffer in Imenu.
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
428
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
429 Simple elements in the alist look like (INDEX-NAME . POSITION).
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
430 POSITION is the buffer position of the item; to go to the item
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
431 is simply to move point to that position.
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
432
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
433 Special elements look like (INDEX-NAME POSITION FUNCTION ARGUMENTS...).
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
434 To \"go to\" a special element means applying FUNCTION
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
435 to INDEX-NAME, POSITION, and the ARGUMENTS.
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
436
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
437 A nested sub-alist element looks like (INDEX-NAME SUB-ALIST).
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
438 The function `imenu--subalist-p' tests an element and returns t
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
439 if it is a sub-alist.
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
440
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
441 There is one simple element with negative POSITION; selecting that
70105
ed33247a09d2 (imenu--index-alist): Balance parentheses.
Luc Teirlinck <teirllm@auburn.edu>
parents: 70098
diff changeset
442 element recalculates the buffer's index alist.")
20857
185fa242a2ea (imenu-generic-expression): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20770
diff changeset
443
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 (make-variable-buffer-local 'imenu--index-alist)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445
24270
02ae21f066ec (imenu--last-menubar-index-alist): Add doc.
Richard M. Stallman <rms@gnu.org>
parents: 24233
diff changeset
446 (defvar imenu--last-menubar-index-alist nil
70098
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
447 "The latest buffer index alist used to update the menu bar menu.")
24270
02ae21f066ec (imenu--last-menubar-index-alist): Add doc.
Richard M. Stallman <rms@gnu.org>
parents: 24233
diff changeset
448
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
449 (make-variable-buffer-local 'imenu--last-menubar-index-alist)
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
450
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 ;; History list for 'jump-to-function-in-buffer'.
12664
ce1cae301efe (imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents: 12635
diff changeset
452 ;; Making this buffer local caused it not to work!
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 (defvar imenu--history-list nil)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 ;;; Internal support functions
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 ;;; Sort function
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 ;;; Sorts the items depending on their index name.
23358
3812bb3ae006 (imenu--generic-function): Sort each submenu by position.
Karl Heuer <kwzh@gnu.org>
parents: 22798
diff changeset
464 ;;; An item looks like (NAME . POSITION).
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 (defun imenu--sort-by-name (item1 item2)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 (string-lessp (car item1) (car item2)))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468
23358
3812bb3ae006 (imenu--generic-function): Sort each submenu by position.
Karl Heuer <kwzh@gnu.org>
parents: 22798
diff changeset
469 (defun imenu--sort-by-position (item1 item2)
3812bb3ae006 (imenu--generic-function): Sort each submenu by position.
Karl Heuer <kwzh@gnu.org>
parents: 22798
diff changeset
470 (< (cdr item1) (cdr item2)))
3812bb3ae006 (imenu--generic-function): Sort each submenu by position.
Karl Heuer <kwzh@gnu.org>
parents: 22798
diff changeset
471
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 (defun imenu--relative-position (&optional reverse)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 ;; Support function to calculate relative position in buffer
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 ;; Beginning of buffer is 0 and end of buffer is 100
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 ;; If REVERSE is non-nil then the beginning is 100 and the end is 0.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 (let ((pos (point))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 (total (buffer-size)))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 (and reverse (setq pos (- total pos)))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (if (> total 50000)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 ;; Avoid overflow from multiplying by 100!
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (/ (1- pos) (max (/ total 100) 1))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 (/ (* 100 (1- pos)) (max total 1)))))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 ;; Split LIST into sublists of max length N.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 ;; Example (imenu--split '(1 2 3 4 5 6 7 8) 3)-> '((1 2 3) (4 5 6) (7 8))
98404
16ab17bf44bb Daniel Colascione <danc at merrillpress.com>
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
486 ;;
16ab17bf44bb Daniel Colascione <danc at merrillpress.com>
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
487 ;; The returned list DOES NOT share structure with LIST.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 (defun imenu--split (list n)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (let ((remain list)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 (result '())
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (sublist '())
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 (i 0))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (while remain
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (push (pop remain) sublist)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 (incf i)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 (and (= i n)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 ;; We have finished a sublist
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 (progn (push (nreverse sublist) result)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 (setq i 0)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (setq sublist '()))))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 ;; There might be a sublist (if the length of LIST mod n is != 0)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 ;; that has to be added to the result list.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 (and sublist
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 (push (nreverse sublist) result))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 (nreverse result)))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
507 ;;; Split the alist MENULIST into a nested alist, if it is long enough.
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
508 ;;; In any case, add TITLE to the front of the alist.
98404
16ab17bf44bb Daniel Colascione <danc at merrillpress.com>
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
509 ;;; If IMENU--RESCAN-ITEM is present in MENULIST, it is moved to the
16ab17bf44bb Daniel Colascione <danc at merrillpress.com>
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
510 ;;; beginning of the returned alist.
16ab17bf44bb Daniel Colascione <danc at merrillpress.com>
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
511 ;;;
16ab17bf44bb Daniel Colascione <danc at merrillpress.com>
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
512 ;;; The returned alist DOES NOT share structure with MENULIST.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (defun imenu--split-menu (menulist title)
98404
16ab17bf44bb Daniel Colascione <danc at merrillpress.com>
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
514 (let ((menulist (copy-sequence menulist))
16ab17bf44bb Daniel Colascione <danc at merrillpress.com>
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
515 keep-at-top tail)
16272
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
516 (if (memq imenu--rescan-item menulist)
98404
16ab17bf44bb Daniel Colascione <danc at merrillpress.com>
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
517 (setq keep-at-top (list imenu--rescan-item)
16272
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
518 menulist (delq imenu--rescan-item menulist)))
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
519 (setq tail menulist)
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
520 (dolist (item tail)
51024
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
521 (when (imenu--subalist-p item)
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
522 (push item keep-at-top)
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
523 (setq menulist (delq item menulist))))
16272
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
524 (if imenu-sort-function
98404
16ab17bf44bb Daniel Colascione <danc at merrillpress.com>
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
525 (setq menulist (sort menulist imenu-sort-function)))
51024
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
526 (if (> (length menulist) imenu-max-items)
16272
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
527 (setq menulist
51024
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
528 (mapcar
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
529 (lambda (menu)
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
530 (cons (format "From: %s" (caar menu)) menu))
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
531 (imenu--split menulist imenu-max-items))))
16272
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
532 (cons title
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
533 (nconc (nreverse keep-at-top) menulist))))
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
534
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
535 ;;; Split up each long alist that are nested within ALIST
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
536 ;;; into nested alists.
98404
16ab17bf44bb Daniel Colascione <danc at merrillpress.com>
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
537 ;;;
16ab17bf44bb Daniel Colascione <danc at merrillpress.com>
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
538 ;;; Return a split and sorted copy of ALIST. The returned alist DOES
16ab17bf44bb Daniel Colascione <danc at merrillpress.com>
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
539 ;;; NOT share structure with ALIST.
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
540 (defun imenu--split-submenus (alist)
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
541 (mapcar (function
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
542 (lambda (elt)
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
543 (if (and (consp elt)
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
544 (stringp (car elt))
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
545 (listp (cdr elt)))
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
546 (imenu--split-menu (cdr elt) (car elt))
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
547 elt)))
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
548 alist))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
550 ;;; Truncate all strings in MENULIST to imenu-max-item-length
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
551 (defun imenu--truncate-items (menulist)
35243
569b2a1b20df (imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents: 32780
diff changeset
552 (mapcar (function
569b2a1b20df (imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents: 32780
diff changeset
553 (lambda (item)
569b2a1b20df (imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents: 32780
diff changeset
554 (cond
569b2a1b20df (imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents: 32780
diff changeset
555 ((consp (cdr item))
569b2a1b20df (imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents: 32780
diff changeset
556 (imenu--truncate-items (cdr item)))
57417
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
557 ;; truncate if necessary
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
558 ((and (numberp imenu-max-item-length)
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
559 (> (length (car item)) imenu-max-item-length))
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
560 (setcar item (substring (car item) 0 imenu-max-item-length))))))
35243
569b2a1b20df (imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents: 32780
diff changeset
561 menulist))
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
562
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
563
16369
187e7c8aaff5 (imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents: 16315
diff changeset
564 (defun imenu--make-index-alist (&optional noerror)
70098
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
565 "Create an index alist for the definitions in the current buffer.
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
566 This works by using the hook function `imenu-create-index-function'.
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
567 Report an error if the list is empty unless NOERROR is supplied and
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
568 non-nil.
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
569
70098
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
570 See `imenu--index-alist' for the format of the index alist."
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
571 (or (and imenu--index-alist
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
572 (or (not imenu-auto-rescan)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
573 (and imenu-auto-rescan
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
574 (> (buffer-size) imenu-auto-rescan-maxout))))
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
575 ;; Get the index; truncate if necessary
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
576 (progn
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
577 (setq imenu--index-alist
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
578 (save-excursion
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
579 (save-restriction
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
580 (widen)
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
581 (funcall imenu-create-index-function))))
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
582 (imenu--truncate-items imenu--index-alist)))
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
583 (or imenu--index-alist noerror
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
584 (error "No items suitable for an index found in this buffer"))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 (or imenu--index-alist
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
586 (setq imenu--index-alist (list nil)))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 ;; Add a rescan option to the index.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 (cons imenu--rescan-item imenu--index-alist))
16315
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
589
8408
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
590 ;;; Find all markers in alist and makes
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
591 ;;; them point nowhere.
16315
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
592 ;;; The top-level call uses nil as the argument;
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
593 ;;; non-nil arguments are in recursivecalls.
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
594 (defvar imenu--cleanup-seen)
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
595
8408
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
596 (defun imenu--cleanup (&optional alist)
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
597 ;; If alist is provided use that list.
16315
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
598 ;; If not, empty the table of lists already seen
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
599 ;; and use imenu--index-alist.
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
600 (if alist
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
601 (setq imenu--cleanup-seen (cons alist imenu--cleanup-seen))
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
602 (setq alist imenu--index-alist imenu--cleanup-seen (list alist)))
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
603
10795
8cbc8846b19b (imenu--cleanup): Set alist to its default just once, at the beginning.
Richard M. Stallman <rms@gnu.org>
parents: 10221
diff changeset
604 (and alist
31560
5dd0eccb46c5 (imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents: 29552
diff changeset
605 (mapc
5dd0eccb46c5 (imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents: 29552
diff changeset
606 (lambda (item)
5dd0eccb46c5 (imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents: 29552
diff changeset
607 (cond
5dd0eccb46c5 (imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents: 29552
diff changeset
608 ((markerp (cdr item))
5dd0eccb46c5 (imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents: 29552
diff changeset
609 (set-marker (cdr item) nil))
5dd0eccb46c5 (imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents: 29552
diff changeset
610 ;; Don't process one alist twice.
5dd0eccb46c5 (imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents: 29552
diff changeset
611 ((memq (cdr item) imenu--cleanup-seen))
5dd0eccb46c5 (imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents: 29552
diff changeset
612 ((imenu--subalist-p item)
5dd0eccb46c5 (imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents: 29552
diff changeset
613 (imenu--cleanup (cdr item)))))
10795
8cbc8846b19b (imenu--cleanup): Set alist to its default just once, at the beginning.
Richard M. Stallman <rms@gnu.org>
parents: 10221
diff changeset
614 alist)
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
615 t))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
616
51024
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
617 (defun imenu--create-keymap (title alist &optional cmd)
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
618 (list* 'keymap title
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
619 (mapcar
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
620 (lambda (item)
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
621 (list* (car item) (car item)
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
622 (cond
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
623 ((imenu--subalist-p item)
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
624 (imenu--create-keymap (car item) (cdr item) cmd))
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
625 (t
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
626 `(lambda () (interactive)
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
627 ,(if cmd `(,cmd ',item) (list 'quote item)))))))
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
628 alist)))
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
629
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
630 (defun imenu--in-alist (str alist)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
631 "Check whether the string STR is contained in multi-level ALIST."
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
632 (let (elt head tail res)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
633 (setq res nil)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
634 (while alist
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
635 (setq elt (car alist)
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
636 tail (cdr elt)
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
637 alist (cdr alist)
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
638 head (car elt))
15929
955269257adf (imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents: 15831
diff changeset
639 ;; A nested ALIST element looks like
955269257adf (imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents: 15831
diff changeset
640 ;; (INDEX-NAME (INDEX-NAME . INDEX-POSITION) ...)
955269257adf (imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents: 15831
diff changeset
641 ;; while a bottom-level element looks like
955269257adf (imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents: 15831
diff changeset
642 ;; (INDEX-NAME . INDEX-POSITION)
955269257adf (imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents: 15831
diff changeset
643 ;; We are only interested in the bottom-level elements, so we need to
955269257adf (imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents: 15831
diff changeset
644 ;; recurse if TAIL is a list.
955269257adf (imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents: 15831
diff changeset
645 (cond ((listp tail)
955269257adf (imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents: 15831
diff changeset
646 (if (setq res (imenu--in-alist str tail))
955269257adf (imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents: 15831
diff changeset
647 (setq alist nil)))
25810
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
648 ((if imenu-name-lookup-function
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
649 (funcall imenu-name-lookup-function str head)
f1417ed050c0 (imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents: 24578
diff changeset
650 (string= str head))
15929
955269257adf (imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents: 15831
diff changeset
651 (setq alist nil res elt))))
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
652 res))
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
653
20770
31a8ad177c4c (imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20769
diff changeset
654 (defvar imenu-syntax-alist nil
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
655 "Alist of syntax table modifiers to use while in `imenu--generic-function'.
20770
31a8ad177c4c (imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20769
diff changeset
656
31a8ad177c4c (imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20769
diff changeset
657 The car of the assocs may be either a character or a string and the
46981
db48206dc290 (imenu-syntax-alist): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 46977
diff changeset
658 cdr is a syntax description appropriate for `modify-syntax-entry'. For
20770
31a8ad177c4c (imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20769
diff changeset
659 a string, all the characters in the string get the specified syntax.
31a8ad177c4c (imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20769
diff changeset
660
31a8ad177c4c (imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20769
diff changeset
661 This is typically used to give word syntax to characters which
22260
b9120925ef93 (imenu-syntax-alist): Doc fix.
Dave Love <fx@gnu.org>
parents: 22250
diff changeset
662 normally have symbol syntax to simplify `imenu-expression'
20770
31a8ad177c4c (imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20769
diff changeset
663 and speed-up matching.")
35688
8b295a5d2192 (imenu-syntax-alist): Add autoload cookie for
Gerd Moellmann <gerd@gnu.org>
parents: 35243
diff changeset
664 ;;;###autoload
20770
31a8ad177c4c (imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20769
diff changeset
665 (make-variable-buffer-local 'imenu-syntax-alist)
31a8ad177c4c (imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20769
diff changeset
666
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 (defun imenu-default-create-index-function ()
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 98404
diff changeset
668 "Default function to create an index alist of the current buffer.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669
70098
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
670 The most general method is to move point to end of buffer, then repeatedly call
7319
cd73ba498964 (imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents: 6909
diff changeset
671 `imenu-prev-index-position-function' and `imenu-extract-index-name-function'.
70098
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
672 All the results returned by the latter are gathered into an index alist.
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
673 This method is used if those two variables are non-nil.
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
674
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
675 The alternate method, which is the one most often used, is to call
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
676 `imenu--generic-function' with `imenu-generic-expression' as argument."
7350
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
677 ;; These should really be done by setting imenu-create-index-function
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
678 ;; in these major modes. But save that change for later.
20249
c42156dab61b (imenu-default-create-index-function):
Karl Heuer <kwzh@gnu.org>
parents: 20051
diff changeset
679 (cond ((and imenu-prev-index-position-function
c42156dab61b (imenu-default-create-index-function):
Karl Heuer <kwzh@gnu.org>
parents: 20051
diff changeset
680 imenu-extract-index-name-function)
7350
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
681 (let ((index-alist '())
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
682 prev-pos name)
7350
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
683 (goto-char (point-max))
8296
b2b493c007ff (imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents: 8256
diff changeset
684 (imenu-progress-message prev-pos 0 t)
7350
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
685 ;; Search for the function
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
686 (while (funcall imenu-prev-index-position-function)
8296
b2b493c007ff (imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents: 8256
diff changeset
687 (imenu-progress-message prev-pos nil t)
7350
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
688 (save-excursion
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
689 (setq name (funcall imenu-extract-index-name-function)))
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
690 (and (stringp name)
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
691 ;; [ydi] updated for imenu-use-markers
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
692 (push (cons name (if imenu-use-markers (point-marker) (point)))
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
693 index-alist)))
8296
b2b493c007ff (imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents: 8256
diff changeset
694 (imenu-progress-message prev-pos 100 t)
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
695 index-alist))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
696 ;; Use generic expression if possible.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
697 ((and imenu-generic-expression)
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
698 (imenu--generic-function imenu-generic-expression))
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
699 (t
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
700 (error "This buffer cannot use `imenu-default-create-index-function'"))))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
702 ;;;
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
703 ;;; Generic index gathering function.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
704 ;;;
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
705
20769
aa3481dd4d84 (imenu-case-fold-search): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20249
diff changeset
706 (defvar imenu-case-fold-search t
aa3481dd4d84 (imenu-case-fold-search): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20249
diff changeset
707 "Defines whether `imenu--generic-function' should fold case when matching.
aa3481dd4d84 (imenu-case-fold-search): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20249
diff changeset
708
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
709 This variable should be set (only) by initialization code
50846
1ac6f8245bff (imenu--generic-function): Use font-lock-defaults
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46981
diff changeset
710 for modes which use `imenu--generic-function'. If it is not set, but
1ac6f8245bff (imenu--generic-function): Use font-lock-defaults
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46981
diff changeset
711 `font-lock-defaults' is set, then font-lock's setting is used.")
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
712 ;;;###autoload
20769
aa3481dd4d84 (imenu-case-fold-search): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20249
diff changeset
713 (make-variable-buffer-local 'imenu-case-fold-search)
aa3481dd4d84 (imenu-case-fold-search): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20249
diff changeset
714
58489
5df4ac03694d Don't always require newcomment.
Richard M. Stallman <rms@gnu.org>
parents: 58364
diff changeset
715 ;; This function can be called with quitting disabled,
5df4ac03694d Don't always require newcomment.
Richard M. Stallman <rms@gnu.org>
parents: 58364
diff changeset
716 ;; so it needs to be careful never to loop!
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
717 (defun imenu--generic-function (patterns)
70098
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
718 "Return an index alist of the current buffer based on PATTERNS.
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
719
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
720 PATTERNS is an alist with elements that look like this:
62568
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
721 (MENU-TITLE REGEXP INDEX)
52733
9cb896b7b7e2 (imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
722 or like this:
9cb896b7b7e2 (imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
723 (MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...)
62568
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
724 with zero or more ARGUMENTS. The former format creates a simple
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
725 element in the index alist when it matches; the latter creates a
70098
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
726 special element of the form (INDEX-NAME POSITION-MARKER FUNCTION
bd71e8bcb103 (imenu-create-index-function, imenu--index-alist)
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
727 ARGUMENTS...) with FUNCTION and ARGUMENTS copied from PATTERNS.
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
728
62568
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
729 MENU-TITLE is a string used as the title for the submenu or nil
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
730 if the entries are not nested.
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
731
62568
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
732 REGEXP is a regexp that should match a construct in the buffer
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
733 that is to be displayed in the menu; i.e., function or variable
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
734 definitions, etc. It contains a substring which is the name to
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
735 appear in the menu. See the info section on Regexps for more
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
736 information. REGEXP may also be a function, called without
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
737 arguments. It is expected to search backwards. It shall return
78492
7c8949dbfa0d Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
738 true and set `match-data' if it finds another element.
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
739
62568
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
740 INDEX points to the substring in REGEXP that contains the
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
741 name (of the function, variable or type) that is to appear in the
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
742 menu.
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
743
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
744 The variable `imenu-case-fold-search' determines whether or not the
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
745 regexp matches are case sensitive, and `imenu-syntax-alist' can be
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
746 used to alter the syntax table for the search.
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
747
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
748 See `lisp-imenu-generic-expression' for an example of PATTERNS.
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
749
12664
ce1cae301efe (imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents: 12635
diff changeset
750 Returns an index of the current buffer as an alist. The elements in
52733
9cb896b7b7e2 (imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
751 the alist look like:
9cb896b7b7e2 (imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
752 (INDEX-NAME . INDEX-POSITION)
9cb896b7b7e2 (imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
753 or like:
9cb896b7b7e2 (imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
754 (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...)
57775
206e30bf844c (imenu-scanning-message): Remove.
Kim F. Storm <storm@cua.dk>
parents: 57717
diff changeset
755 They may also be nested index alists like:
52733
9cb896b7b7e2 (imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
756 (INDEX-NAME . INDEX-ALIST)
9cb896b7b7e2 (imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
757 depending on PATTERNS."
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
758
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
759 (let ((index-alist (list 'dummy))
61769
ff6d0a7e180e (imenu--generic-function): The official position of a
Richard M. Stallman <rms@gnu.org>
parents: 59996
diff changeset
760 prev-pos
50846
1ac6f8245bff (imenu--generic-function): Use font-lock-defaults
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46981
diff changeset
761 (case-fold-search (if (or (local-variable-p 'imenu-case-fold-search)
1ac6f8245bff (imenu--generic-function): Use font-lock-defaults
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46981
diff changeset
762 (not (local-variable-p 'font-lock-defaults)))
1ac6f8245bff (imenu--generic-function): Use font-lock-defaults
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46981
diff changeset
763 imenu-case-fold-search
1ac6f8245bff (imenu--generic-function): Use font-lock-defaults
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46981
diff changeset
764 (nth 2 font-lock-defaults)))
20770
31a8ad177c4c (imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20769
diff changeset
765 (old-table (syntax-table))
31a8ad177c4c (imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20769
diff changeset
766 (table (copy-syntax-table (syntax-table)))
31a8ad177c4c (imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20769
diff changeset
767 (slist imenu-syntax-alist))
31a8ad177c4c (imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents: 20769
diff changeset
768 ;; Modify the syntax table used while matching regexps.
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
769 (dolist (syn slist)
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
770 ;; The character(s) to modify may be a single char or a string.
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
771 (if (numberp (car syn))
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
772 (modify-syntax-entry (car syn) (cdr syn) table)
46977
54ce0e6e293f (imenu--generic-function): Use mapc.
Glenn Morris <rgm@gnu.org>
parents: 46894
diff changeset
773 (mapc (lambda (c)
54ce0e6e293f (imenu--generic-function): Use mapc.
Glenn Morris <rgm@gnu.org>
parents: 46894
diff changeset
774 (modify-syntax-entry c (cdr syn) table))
54ce0e6e293f (imenu--generic-function): Use mapc.
Glenn Morris <rgm@gnu.org>
parents: 46894
diff changeset
775 (car syn))))
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
776 (goto-char (point-max))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
777 (imenu-progress-message prev-pos 0 t)
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
778 (unwind-protect ; for syntax table
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
779 (save-match-data
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
780 (set-syntax-table table)
58489
5df4ac03694d Don't always require newcomment.
Richard M. Stallman <rms@gnu.org>
parents: 58364
diff changeset
781
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
782 ;; map over the elements of imenu-generic-expression
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
783 ;; (typically functions, variables ...)
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
784 (dolist (pat patterns)
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
785 (let ((menu-title (car pat))
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
786 (regexp (nth 1 pat))
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
787 (index (nth 2 pat))
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
788 (function (nth 3 pat))
57717
d198f03d3ba5 (imenu--generic-function): Skip matches in comments.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 57417
diff changeset
789 (rest (nthcdr 4 pat))
61769
ff6d0a7e180e (imenu--generic-function): The official position of a
Richard M. Stallman <rms@gnu.org>
parents: 59996
diff changeset
790 start beg)
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
791 ;; Go backwards for convenience of adding items in order.
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
792 (goto-char (point-max))
62568
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
793 (while (and (if (functionp regexp)
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
794 (funcall regexp)
7be08219b736 (imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
Daniel Pfeiffer <occitan@esperanto.org>
parents: 62531
diff changeset
795 (re-search-backward regexp nil t))
58489
5df4ac03694d Don't always require newcomment.
Richard M. Stallman <rms@gnu.org>
parents: 58364
diff changeset
796 ;; Exit the loop if we get an empty match,
5df4ac03694d Don't always require newcomment.
Richard M. Stallman <rms@gnu.org>
parents: 58364
diff changeset
797 ;; because it means a bad regexp was specified.
5df4ac03694d Don't always require newcomment.
Richard M. Stallman <rms@gnu.org>
parents: 58364
diff changeset
798 (not (= (match-beginning 0) (match-end 0))))
58364
c8e69a3cb57f (imenu--generic-function):
Richard M. Stallman <rms@gnu.org>
parents: 57926
diff changeset
799 (setq start (point))
61769
ff6d0a7e180e (imenu--generic-function): The official position of a
Richard M. Stallman <rms@gnu.org>
parents: 59996
diff changeset
800 ;; Record the start of the line in which the match starts.
59568
3c6c2682ad8f (imenu--split-menu): Copy menulist before sorting.
Richard M. Stallman <rms@gnu.org>
parents: 58743
diff changeset
801 ;; That's the official position of this definition.
61769
ff6d0a7e180e (imenu--generic-function): The official position of a
Richard M. Stallman <rms@gnu.org>
parents: 59996
diff changeset
802 (goto-char (match-beginning index))
ff6d0a7e180e (imenu--generic-function): The official position of a
Richard M. Stallman <rms@gnu.org>
parents: 59996
diff changeset
803 (beginning-of-line)
ff6d0a7e180e (imenu--generic-function): The official position of a
Richard M. Stallman <rms@gnu.org>
parents: 59996
diff changeset
804 (setq beg (point))
58743
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
805 (imenu-progress-message prev-pos nil t)
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
806 ;; Add this sort of submenu only when we've found an
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
807 ;; item for it, avoiding empty, duff menus.
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
808 (unless (assoc menu-title index-alist)
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
809 (push (list menu-title) index-alist))
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
810 (if imenu-use-markers
61769
ff6d0a7e180e (imenu--generic-function): The official position of a
Richard M. Stallman <rms@gnu.org>
parents: 59996
diff changeset
811 (setq beg (copy-marker beg)))
58743
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
812 (let ((item
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
813 (if function
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
814 (nconc (list (match-string-no-properties index)
61769
ff6d0a7e180e (imenu--generic-function): The official position of a
Richard M. Stallman <rms@gnu.org>
parents: 59996
diff changeset
815 beg function)
58743
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
816 rest)
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
817 (cons (match-string-no-properties index)
61769
ff6d0a7e180e (imenu--generic-function): The official position of a
Richard M. Stallman <rms@gnu.org>
parents: 59996
diff changeset
818 beg)))
58743
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
819 ;; This is the desired submenu,
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
820 ;; starting with its title (or nil).
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
821 (menu (assoc menu-title index-alist)))
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
822 ;; Insert the item unless it is already present.
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
823 (unless (member item (cdr menu))
6abce81016a6 (imenu--generic-function): Delete code to exclude matches in comments.
Richard M. Stallman <rms@gnu.org>
parents: 58489
diff changeset
824 (setcdr menu
61769
ff6d0a7e180e (imenu--generic-function): The official position of a
Richard M. Stallman <rms@gnu.org>
parents: 59996
diff changeset
825 (cons item (cdr menu)))))
ff6d0a7e180e (imenu--generic-function): The official position of a
Richard M. Stallman <rms@gnu.org>
parents: 59996
diff changeset
826 ;; Go to the start of the match, to make sure we
ff6d0a7e180e (imenu--generic-function): The official position of a
Richard M. Stallman <rms@gnu.org>
parents: 59996
diff changeset
827 ;; keep making progress backwards.
ff6d0a7e180e (imenu--generic-function): The official position of a
Richard M. Stallman <rms@gnu.org>
parents: 59996
diff changeset
828 (goto-char start))))
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
829 (set-syntax-table old-table)))
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
830 (imenu-progress-message prev-pos 100 t)
23358
3812bb3ae006 (imenu--generic-function): Sort each submenu by position.
Karl Heuer <kwzh@gnu.org>
parents: 22798
diff changeset
831 ;; Sort each submenu by position.
3812bb3ae006 (imenu--generic-function): Sort each submenu by position.
Karl Heuer <kwzh@gnu.org>
parents: 22798
diff changeset
832 ;; This is in case one submenu gets items from two different regexps.
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
833 (dolist (item index-alist)
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
834 (when (listp item)
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
835 (setcdr item (sort (cdr item) 'imenu--sort-by-position))))
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
836 (let ((main-element (assq nil index-alist)))
16272
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
837 (nconc (delq main-element (delq 'dummy index-alist))
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
838 (cdr main-element)))))
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
839
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 ;;; The main functions for this package!
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
846 ;; See also info-lookup-find-item
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
847 (defun imenu-find-default (guess completions)
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
848 "Fuzzily find an item based on GUESS inside the alist COMPLETIONS."
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
849 (catch 'found
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
850 (let ((case-fold-search t))
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
851 (if (assoc guess completions) guess
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
852 (dolist (re (list (concat "\\`" (regexp-quote guess) "\\'")
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
853 (concat "\\`" (regexp-quote guess))
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
854 (concat (regexp-quote guess) "\\'")
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
855 (regexp-quote guess)))
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
856 (dolist (x completions)
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
857 (if (string-match re (car x)) (throw 'found (car x)))))))))
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
858
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 (defun imenu--completion-buffer (index-alist &optional prompt)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 "Let the user select from INDEX-ALIST in a completion buffer with PROMPT.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861
57417
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
862 Return one of the entries in index-alist or nil."
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 ;; Create a list for this buffer only when needed.
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
864 (let ((name (thing-at-point 'symbol))
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
865 choice
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
866 (prepared-index-alist
46894
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
867 (if (not imenu-space-replacement) index-alist
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
868 (mapcar
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
869 (lambda (item)
63848
65786fe1837b (imenu--completion-buffer): Change space constants followed by a sexp to "?\s ".
Juanma Barranquero <lekktu@gmail.com>
parents: 62568
diff changeset
870 (cons (subst-char-in-string ?\s (aref imenu-space-replacement 0)
46894
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
871 (car item))
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
872 (cdr item)))
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
873 index-alist))))
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
874 (when (stringp name)
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
875 (setq name (or (imenu-find-default name prepared-index-alist) name)))
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
876 (cond (prompt)
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
877 ((and name (imenu--in-alist name prepared-index-alist))
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
878 (setq prompt (format "Index item (default %s): " name)))
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
879 (t (setq prompt "Index item: ")))
46894
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
880 (let ((minibuffer-setup-hook minibuffer-setup-hook))
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
881 ;; Display the completion buffer.
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
882 (if (not imenu-eager-completion-buffer)
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
883 (add-hook 'minibuffer-setup-hook 'minibuffer-completion-help))
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
884 (setq name (completing-read prompt
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
885 prepared-index-alist
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
886 nil t nil 'imenu--history-list name)))
55826
e7bdb5b77df2 (imenu--menubar-select): Set imenu-menubar-modified-tick
Richard M. Stallman <rms@gnu.org>
parents: 52733
diff changeset
887
57417
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
888 (when (stringp name)
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
889 (setq choice (assoc name prepared-index-alist))
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
890 (if (imenu--subalist-p choice)
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
891 (imenu--completion-buffer (cdr choice) prompt)
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
892 choice))))
7319
cd73ba498964 (imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents: 6909
diff changeset
893
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 (defun imenu--mouse-menu (index-alist event &optional title)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 "Let the user select from a buffer index from a mouse menu.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 INDEX-ALIST is the buffer index and EVENT is a mouse event.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898
16148
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
899 Returns t for rescan and otherwise an element or subelement of INDEX-ALIST."
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
900 (setq index-alist (imenu--split-submenus index-alist))
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
901 (let* ((menu (imenu--split-menu index-alist (or title (buffer-name))))
51024
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
902 (map (imenu--create-keymap (car menu)
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
903 (cdr (if (< 1 (length (cdr menu)))
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
904 menu
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
905 (car (cdr menu)))))))
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
906 (popup-menu map event)))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907
6241
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
908 (defun imenu-choose-buffer-index (&optional prompt alist)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909 "Let the user select from a buffer index and return the chosen index.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911 If the user originally activated this function with the mouse, a mouse
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912 menu is used. Otherwise a completion buffer is used and the user is
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913 prompted with PROMPT.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
914
6241
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
915 If you call this function with index alist ALIST, then it lets the user
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
916 select from ALIST.
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
917
6909
9e59751db725 Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents: 6241
diff changeset
918 With no index alist ALIST, it calls `imenu--make-index-alist' to
6241
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
919 create the index alist.
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
920
71725
240e662ee053 (imenu-choose-buffer-index): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 70105
diff changeset
921 If `imenu-use-popup-menu' is nil, then the completion buffer
240e662ee053 (imenu-choose-buffer-index): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 70105
diff changeset
922 is always used, no matter if the mouse was used or not.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
923
16369
187e7c8aaff5 (imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents: 16315
diff changeset
924 The returned value is of the form (INDEX-NAME . INDEX-POSITION)."
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925 (let (index-alist
8296
b2b493c007ff (imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents: 8256
diff changeset
926 (mouse-triggered (listp last-nonmenu-event))
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
927 (result t))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 ;; If selected by mouse, see to that the window where the mouse is
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929 ;; really is selected.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 (and mouse-triggered
12396
d0c82df80d70 (imenu-choose-buffer-index): Understand that (menu-bar)
Richard M. Stallman <rms@gnu.org>
parents: 12394
diff changeset
931 (not (equal last-nonmenu-event '(menu-bar)))
8296
b2b493c007ff (imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents: 8256
diff changeset
932 (let ((window (posn-window (event-start last-nonmenu-event))))
12635
f12b1374fb5b (imenu-choose-buffer-index): Avoid trying to select WINDOW if it is nil.
Richard M. Stallman <rms@gnu.org>
parents: 12396
diff changeset
933 (or (framep window) (null window) (select-window window))))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934 ;; Create a list for this buffer only when needed.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935 (while (eq result t)
6241
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
936 (setq index-alist (if alist alist (imenu--make-index-alist)))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 (setq result
46894
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
938 (if (and imenu-use-popup-menu
f8b45e2dec81 (imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43982
diff changeset
939 (or (eq imenu-use-popup-menu t) mouse-triggered))
8296
b2b493c007ff (imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents: 8256
diff changeset
940 (imenu--mouse-menu index-alist last-nonmenu-event)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
941 (imenu--completion-buffer index-alist prompt)))
57417
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
942 (and (equal result imenu--rescan-item)
8408
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
943 (imenu--cleanup)
57417
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
944 (setq result t imenu--index-alist nil)))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945 result))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
947 ;;;###autoload
8408
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
948 (defun imenu-add-to-menubar (name)
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
949 "Add an `imenu' entry to the menu bar for the current buffer.
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
950 NAME is a string used to name the menu bar item.
14657
4bedd113757f (imenu-add-to-menubar): Add menu item for current buf only.
Richard M. Stallman <rms@gnu.org>
parents: 14656
diff changeset
951 See the command `imenu' for more information."
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
952 (interactive "sImenu menu item name: ")
20249
c42156dab61b (imenu-default-create-index-function):
Karl Heuer <kwzh@gnu.org>
parents: 20051
diff changeset
953 (if (or (and imenu-prev-index-position-function
c42156dab61b (imenu-default-create-index-function):
Karl Heuer <kwzh@gnu.org>
parents: 20051
diff changeset
954 imenu-extract-index-name-function)
c42156dab61b (imenu-default-create-index-function):
Karl Heuer <kwzh@gnu.org>
parents: 20051
diff changeset
955 imenu-generic-expression
c42156dab61b (imenu-default-create-index-function):
Karl Heuer <kwzh@gnu.org>
parents: 20051
diff changeset
956 (not (eq imenu-create-index-function
c42156dab61b (imenu-default-create-index-function):
Karl Heuer <kwzh@gnu.org>
parents: 20051
diff changeset
957 'imenu-default-create-index-function)))
31560
5dd0eccb46c5 (imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents: 29552
diff changeset
958 (let ((newmap (make-sparse-keymap)))
5dd0eccb46c5 (imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents: 29552
diff changeset
959 (set-keymap-parent newmap (current-local-map))
24270
02ae21f066ec (imenu--last-menubar-index-alist): Add doc.
Richard M. Stallman <rms@gnu.org>
parents: 24233
diff changeset
960 (setq imenu--last-menubar-index-alist nil)
32279
869a035f39fa (imenu-add-to-menubar): Fix last change.
Dave Love <fx@gnu.org>
parents: 31560
diff changeset
961 (define-key newmap [menu-bar index]
32284
700a91f9a4b4 (imenu-add-to-menubar): Fix again.
Dave Love <fx@gnu.org>
parents: 32279
diff changeset
962 `(menu-item ,name ,(make-sparse-keymap "Imenu")))
31560
5dd0eccb46c5 (imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents: 29552
diff changeset
963 (use-local-map newmap)
20249
c42156dab61b (imenu-default-create-index-function):
Karl Heuer <kwzh@gnu.org>
parents: 20051
diff changeset
964 (add-hook 'menu-bar-update-hook 'imenu-update-menubar))
87567
4c3c683cdff8 * erc-ibuffer.el (erc-channel-modes):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78492
diff changeset
965 (error "The mode `%s' does not support Imenu"
4c3c683cdff8 * erc-ibuffer.el (erc-channel-modes):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78492
diff changeset
966 (format-mode-line mode-name))))
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
967
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
968 ;;;###autoload
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
969 (defun imenu-add-menubar-index ()
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
970 "Add an Imenu \"Index\" entry on the menu bar for the current buffer.
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
971
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
972 A trivial interface to `imenu-add-to-menubar' suitable for use in a hook."
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
973 (interactive)
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
974 (imenu-add-to-menubar "Index"))
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
975
14642
01e8fdb45deb (imenu-buffer-menubar): Add defvar.
Karl Heuer <kwzh@gnu.org>
parents: 14575
diff changeset
976 (defvar imenu-buffer-menubar nil)
01e8fdb45deb (imenu-buffer-menubar): Add defvar.
Karl Heuer <kwzh@gnu.org>
parents: 14575
diff changeset
977
43982
a40fcee55faa (imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 43832
diff changeset
978 (defvar imenu-menubar-modified-tick 0
72595
c1a0f40d53a7 * imenu.el (imenu-update-menubar): Use buffer-chars-modified-tick.
Chong Yidong <cyd@stupidchicken.com>
parents: 71725
diff changeset
979 "The value of (buffer-chars-modified-tick) as of the last call
c1a0f40d53a7 * imenu.el (imenu-update-menubar): Use buffer-chars-modified-tick.
Chong Yidong <cyd@stupidchicken.com>
parents: 71725
diff changeset
980 to `imenu-update-menubar'.")
43982
a40fcee55faa (imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 43832
diff changeset
981 (make-variable-buffer-local 'imenu-menubar-modified-tick)
43832
5d834c3f5d18 (imenu-update-menubar-modified-tick): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 41305
diff changeset
982
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
983 (defun imenu-update-menubar ()
43982
a40fcee55faa (imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 43832
diff changeset
984 (when (and (current-local-map)
a40fcee55faa (imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 43832
diff changeset
985 (keymapp (lookup-key (current-local-map) [menu-bar index]))
72595
c1a0f40d53a7 * imenu.el (imenu-update-menubar): Use buffer-chars-modified-tick.
Chong Yidong <cyd@stupidchicken.com>
parents: 71725
diff changeset
986 (/= (buffer-chars-modified-tick) imenu-menubar-modified-tick))
c1a0f40d53a7 * imenu.el (imenu-update-menubar): Use buffer-chars-modified-tick.
Chong Yidong <cyd@stupidchicken.com>
parents: 71725
diff changeset
987 (setq imenu-menubar-modified-tick (buffer-chars-modified-tick))
43982
a40fcee55faa (imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 43832
diff changeset
988 (let ((index-alist (imenu--make-index-alist t)))
a40fcee55faa (imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 43832
diff changeset
989 ;; Don't bother updating if the index-alist has not changed
a40fcee55faa (imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 43832
diff changeset
990 ;; since the last time we did it.
a40fcee55faa (imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 43832
diff changeset
991 (unless (equal index-alist imenu--last-menubar-index-alist)
a40fcee55faa (imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 43832
diff changeset
992 (let (menu menu1 old)
a40fcee55faa (imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 43832
diff changeset
993 (setq imenu--last-menubar-index-alist index-alist)
a40fcee55faa (imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 43832
diff changeset
994 (setq index-alist (imenu--split-submenus index-alist))
a40fcee55faa (imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 43832
diff changeset
995 (setq menu (imenu--split-menu index-alist
a40fcee55faa (imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 43832
diff changeset
996 (buffer-name)))
51024
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
997 (setq menu1 (imenu--create-keymap (car menu)
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
998 (cdr (if (< 1 (length (cdr menu)))
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
999 menu
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
1000 (car (cdr menu))))
4efabfff9aa1 (imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50846
diff changeset
1001 'imenu--menubar-select))
43982
a40fcee55faa (imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 43832
diff changeset
1002 (setq old (lookup-key (current-local-map) [menu-bar index]))
a40fcee55faa (imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 43832
diff changeset
1003 (setcdr old (cdr menu1)))))))
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
1004
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
1005 (defun imenu--menubar-select (item)
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1006 "Use Imenu to select the function or variable named in this menu ITEM."
17229
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
1007 (if (equal item imenu--rescan-item)
14796
29e7001fecf0 (imenu--menubar-select): Handle the "rescan" item.
Richard M. Stallman <rms@gnu.org>
parents: 14733
diff changeset
1008 (progn
29e7001fecf0 (imenu--menubar-select): Handle the "rescan" item.
Richard M. Stallman <rms@gnu.org>
parents: 14733
diff changeset
1009 (imenu--cleanup)
55826
e7bdb5b77df2 (imenu--menubar-select): Set imenu-menubar-modified-tick
Richard M. Stallman <rms@gnu.org>
parents: 52733
diff changeset
1010 ;; Make sure imenu-update-menubar redoes everything.
e7bdb5b77df2 (imenu--menubar-select): Set imenu-menubar-modified-tick
Richard M. Stallman <rms@gnu.org>
parents: 52733
diff changeset
1011 (setq imenu-menubar-modified-tick -1)
14796
29e7001fecf0 (imenu--menubar-select): Handle the "rescan" item.
Richard M. Stallman <rms@gnu.org>
parents: 14733
diff changeset
1012 (setq imenu--index-alist nil)
55826
e7bdb5b77df2 (imenu--menubar-select): Set imenu-menubar-modified-tick
Richard M. Stallman <rms@gnu.org>
parents: 52733
diff changeset
1013 (setq imenu--last-menubar-index-alist nil)
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1014 (imenu-update-menubar)
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1015 t)
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1016 (imenu item)
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1017 nil))
8408
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
1018
17229
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
1019 (defun imenu-default-goto-function (name position &optional rest)
57417
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
1020 "Move to the given position.
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
1021
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
1022 NAME is ignored. POSITION is where to move. REST is also ignored.
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
1023 The ignored args just make this function have the same interface as a
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
1024 function placed in a special index-item."
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
1025 (if (or (< position (point-min))
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
1026 (> position (point-max)))
17229
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
1027 ;; widen if outside narrowing
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
1028 (widen))
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
1029 (goto-char position))
17229
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
1030
7319
cd73ba498964 (imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents: 6909
diff changeset
1031 ;;;###autoload
12664
ce1cae301efe (imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents: 12635
diff changeset
1032 (defun imenu (index-item)
7319
cd73ba498964 (imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents: 6909
diff changeset
1033 "Jump to a place in the buffer chosen using a buffer menu or mouse menu.
21852
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
1034 INDEX-ITEM specifies the position. See `imenu-choose-buffer-index'
5898cd2e4cd6 (imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents: 20857
diff changeset
1035 for more information."
16698
13920eac02e0 (imenu-generic-expression): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16612
diff changeset
1036 (interactive (list (imenu-choose-buffer-index)))
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
1037 ;; Convert a string to an alist element.
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
1038 (if (stringp index-item)
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
1039 (setq index-item (assoc index-item (imenu--make-index-alist))))
41305
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1040 (when index-item
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1041 (push-mark)
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1042 (let* ((is-special-item (listp (cdr index-item)))
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1043 (function
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1044 (if is-special-item
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1045 (nth 2 index-item) imenu-default-goto-function))
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1046 (position (if is-special-item
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1047 (cadr index-item) (cdr index-item)))
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1048 (rest (if is-special-item (cddr index-item))))
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1049 (apply function (car index-item) position rest))
71197bcff33c (imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1050 (run-hooks 'imenu-after-jump-hook)))
8408
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
1051
29078
2e20146198ce Add to debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 25810
diff changeset
1052 (dolist (mess
2e20146198ce Add to debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 25810
diff changeset
1053 '("^No items suitable for an index found in this buffer$"
2e20146198ce Add to debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 25810
diff changeset
1054 "^This buffer cannot use `imenu-default-create-index-function'$"
2e20146198ce Add to debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 25810
diff changeset
1055 "^The mode `.*' does not support Imenu$"))
2e20146198ce Add to debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 25810
diff changeset
1056 (add-to-list 'debug-ignored-errors mess))
2e20146198ce Add to debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 25810
diff changeset
1057
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1058 (provide 'imenu)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1059
57417
1389687cfa0a (imenu--completion-buffer): Don't return t for rescan.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56683
diff changeset
1060 ;; arch-tag: 98a2f5f5-4b91-4704-b18c-3aacf77d77a7
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1061 ;;; imenu.el ends here