Mercurial > emacs
annotate lisp/imenu.el @ 56674:302e4e1415d3
term/x-win.el (x-selection-value): If utf8 was successful but
ctext was not, use utf8 string.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 16 Aug 2004 00:04:03 +0000 |
parents | 7e0e6be19969 |
children | dee43d88905e c08afac24467 |
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 | 2 |
56549
7e0e6be19969
(imenu-prev-index-position-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55826
diff
changeset
|
3 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 2003, 2004 |
7e0e6be19969
(imenu-prev-index-position-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55826
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
6230 | 5 |
6 ;; Author: Ake Stenhoff <etxaksf@aom.ericsson.se> | |
7 ;; Lars Lindberg <lli@sypro.cap.se> | |
17970 | 8 ;; Maintainer: FSF |
6230 | 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 | 11 |
12 ;; This file is part of GNU Emacs. | |
13 | |
14 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
6230 | 15 ;; it under the terms of the GNU General Public License as published by |
16 ;; the Free Software Foundation; either version 2, or (at your option) | |
17 ;; any later version. | |
14169 | 18 |
19 ;; GNU Emacs is distributed in the hope that it will be useful, | |
6230 | 20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 ;; GNU General Public License for more details. | |
14169 | 23 |
6230 | 24 ;; You should have received a copy of the GNU General Public License |
14169 | 25 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
27 ;; Boston, MA 02111-1307, USA. | |
6230 | 28 |
29 ;;; Commentary: | |
14169 | 30 |
6230 | 31 ;; Purpose of this package: |
32 ;; To present a framework for mode-specific buffer indexes. | |
33 ;; A buffer index is an alist of names and buffer positions. | |
34 ;; For instance all functions in a C-file and their positions. | |
35 ;; | |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
36 ;; 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
|
37 ;; |
6230 | 38 ;; How it works: |
39 | |
40 ;; A mode-specific function is called to generate the index. It is | |
41 ;; then presented to the user, who can choose from this index. | |
42 ;; | |
43 ;; The package comes with a set of example functions for how to | |
44 ;; utilize this package. | |
45 | |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
46 ;; 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
|
47 ;; 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
|
48 ;; 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
|
49 ;; index position is also supplied. |
6230 | 50 |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
51 ;;; History: |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
52 ;; Thanks go to |
6241 | 53 ;; [simon] - Simon Leinen simon@lia.di.epfl.ch |
54 ;; [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
|
55 ;; [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
|
56 ;; [greg] - Greg Thompson gregt@porsche.visix.COM |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
57 ;; [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
|
58 ;; [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
|
59 ;; [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
|
60 ;; [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
|
61 ;; [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
|
62 |
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
36637
diff
changeset
|
63 ;;; Code: |
14169 | 64 |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
65 (eval-when-compile (require 'cl)) |
6230 | 66 |
67 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
68 ;;; | |
69 ;;; Customizable variables | |
70 ;;; | |
71 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
72 |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
73 (defgroup imenu nil |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
74 "Mode-specific buffer indexes." |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
75 :group 'matching |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
76 :group 'frames |
22250
a77d473867b8
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21959
diff
changeset
|
77 :group 'convenience |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
78 :link '(custom-manual "(elisp)Imenu")) |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
79 |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
80 (defcustom imenu-use-markers t |
17307
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
81 "*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
|
82 |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
83 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
|
84 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
|
85 |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
86 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
|
87 :type 'boolean |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
88 :group 'imenu) |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
89 |
17307
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
90 |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
91 (defcustom imenu-max-item-length 60 |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
92 "*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
|
93 :type '(choice integer |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
94 (const :tag "Unlimited")) |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
95 :group 'imenu) |
17307
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
96 |
17677
3ab08563e855
(imenu-auto-rescan): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
17634
diff
changeset
|
97 (defcustom imenu-auto-rescan nil |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
98 "*Non-nil means Imenu should always rescan the buffers." |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
99 :type 'boolean |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
100 :group 'imenu) |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
101 |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
102 (defcustom imenu-auto-rescan-maxout 60000 |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
103 "*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
|
104 This variable is buffer-local." |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
105 :type 'integer |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
106 :group 'imenu) |
6230 | 107 |
46894
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
108 (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
|
109 (make-obsolete-variable '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
|
110 'imenu-use-popup-menu "21.4") |
6230 | 111 |
46894
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
112 (defcustom imenu-use-popup-menu |
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
113 (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
|
114 (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
|
115 'on-mouse) |
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
116 "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
|
117 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
|
118 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
|
119 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
|
120 :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
|
121 (const :tag "Never" nil) |
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
122 (other :tag "Always" t))) |
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
123 |
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
124 (defcustom imenu-eager-completion-buffer |
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
125 (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
|
126 "If non-nil, eagerly popup the completion buffer." |
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
127 :type 'boolean) |
6230 | 128 |
25810
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
129 (defcustom imenu-after-jump-hook nil |
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
130 "*Hooks called after jumping to a place in the buffer. |
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
131 |
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
132 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
|
133 \(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
|
134 :type 'hook |
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
135 :group 'imenu) |
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
136 |
22798
434ac4a14be3
(imenu-create-index-function): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
22628
diff
changeset
|
137 ;;;###autoload |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
138 (defcustom imenu-sort-function nil |
6230 | 139 "*The function to use for sorting the index mouse-menu. |
140 | |
141 Affects only the mouse index menu. | |
142 | |
143 Set this to nil if you don't want any sorting (faster). | |
144 The items in the menu are then presented in the order they were found | |
145 in the buffer. | |
146 | |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
147 Set it to `imenu--sort-by-name' if you want alphabetic sorting. |
6230 | 148 |
23358
3812bb3ae006
(imenu--generic-function): Sort each submenu by position.
Karl Heuer <kwzh@gnu.org>
parents:
22798
diff
changeset
|
149 The function should take two arguments and return t if the first |
6230 | 150 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
|
151 \(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
|
152 :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
|
153 (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
|
154 (function :tag "Another function")) |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
155 :group 'imenu) |
6230 | 156 |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
157 (defcustom imenu-max-items 25 |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
158 "*Maximum number of elements in a mouse menu for Imenu." |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
159 :type 'integer |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
160 :group 'imenu) |
6230 | 161 |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
162 (defcustom imenu-scanning-message "Scanning buffer for index (%3d%%)" |
6230 | 163 "*Progress message during the index scanning of the buffer. |
16460
4d7d18a39871
(imenu-scanning-message): Use ellipsis.
Karl Heuer <kwzh@gnu.org>
parents:
16382
diff
changeset
|
164 If non-nil, user gets a message during the scanning of the buffer. |
6230 | 165 |
166 Relevant only if the mode-specific function that creates the buffer | |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
167 index use `imenu-progress-message', and not useful if that is fast, in |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
168 which case you might as well set this to nil." |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
169 :type '(choice string |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
170 (const :tag "None" nil)) |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
171 :group 'imenu) |
6230 | 172 |
22628
d5a086ed37f5
(imenu-space-replacement): Use `.'.
Richard M. Stallman <rms@gnu.org>
parents:
22586
diff
changeset
|
173 (defcustom imenu-space-replacement "." |
6230 | 174 "*The replacement string for spaces in index names. |
22628
d5a086ed37f5
(imenu-space-replacement): Use `.'.
Richard M. Stallman <rms@gnu.org>
parents:
22586
diff
changeset
|
175 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
|
176 names work as tokens." |
46894
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
177 :type '(choice string (const nil)) |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
178 :group 'imenu) |
6230 | 179 |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
180 (defcustom imenu-level-separator ":" |
6230 | 181 "*The separator between index names of different levels. |
182 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
|
183 with name concatenation." |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
184 :type 'string |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17307
diff
changeset
|
185 :group 'imenu) |
6230 | 186 |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
187 ;;;###autoload |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
188 (defvar imenu-generic-expression nil |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
189 "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
|
190 |
16698
13920eac02e0
(imenu-generic-expression): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
16612
diff
changeset
|
191 If non-nil this pattern is passed to `imenu--generic-function' |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
192 to create a buffer index. |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
193 |
16271
00bece0cd6c2
(imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents:
16244
diff
changeset
|
194 The value should be an alist with elements that look like this: |
00bece0cd6c2
(imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents:
16244
diff
changeset
|
195 (MENU-TITLE REGEXP INDEX) |
00bece0cd6c2
(imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents:
16244
diff
changeset
|
196 or like this: |
00bece0cd6c2
(imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents:
16244
diff
changeset
|
197 (MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...) |
00bece0cd6c2
(imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents:
16244
diff
changeset
|
198 with zero or more ARGUMENTS. The former format creates a simple element in |
00bece0cd6c2
(imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents:
16244
diff
changeset
|
199 the index alist when it matches; the latter creates a special element |
29552
4c89037af077
(imenu-generic-expression): Docstring fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29078
diff
changeset
|
200 of the form (NAME POSITION-MARKER FUNCTION ARGUMENTS...) |
4c89037af077
(imenu-generic-expression): Docstring fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29078
diff
changeset
|
201 with FUNCTION and ARGUMENTS copied from `imenu-generic-expression'. |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
202 |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
203 MENU-TITLE is a string used as the title for the submenu or nil if the |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
204 entries are not nested. |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
205 |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
206 REGEXP is a regexp that should match a construct in the buffer that is |
12664
ce1cae301efe
(imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents:
12635
diff
changeset
|
207 to be displayed in the menu; i.e., function or variable definitions, |
ce1cae301efe
(imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents:
12635
diff
changeset
|
208 etc. It contains a substring which is the name to appear in the |
ce1cae301efe
(imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents:
12635
diff
changeset
|
209 menu. See the info section on Regexps for more information. |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
210 |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
211 INDEX points to the substring in REGEXP that contains the name (of the |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
212 function, variable or type) that is to appear in the menu. |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
213 |
20769
aa3481dd4d84
(imenu-case-fold-search): New buffer-local variable.
Dave Love <fx@gnu.org>
parents:
20249
diff
changeset
|
214 The variable is buffer-local. |
aa3481dd4d84
(imenu-case-fold-search): New buffer-local variable.
Dave Love <fx@gnu.org>
parents:
20249
diff
changeset
|
215 |
aa3481dd4d84
(imenu-case-fold-search): New buffer-local variable.
Dave Love <fx@gnu.org>
parents:
20249
diff
changeset
|
216 The variable `imenu-case-fold-search' determines whether or not the |
36013
fc00137bf0bf
(imenu-generic-expression): Doc fix.
Dave Love <fx@gnu.org>
parents:
35688
diff
changeset
|
217 regexp matches are case sensitive, and `imenu-syntax-alist' can be |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
218 used to alter the syntax table for the search. |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
219 |
41305
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
220 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
|
221 `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
|
222 characters which normally have \"symbol\" syntax \"word\" syntax |
fc00137bf0bf
(imenu-generic-expression): Doc fix.
Dave Love <fx@gnu.org>
parents:
35688
diff
changeset
|
223 during matching.") |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
224 |
14816
485422b900d3
(imenu-generic-expression): Autoload the make-variable-buffer-local call.
Richard M. Stallman <rms@gnu.org>
parents:
14798
diff
changeset
|
225 ;;;###autoload |
12664
ce1cae301efe
(imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents:
12635
diff
changeset
|
226 (make-variable-buffer-local 'imenu-generic-expression) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
227 |
6230 | 228 ;;;; Hooks |
229 | |
22798
434ac4a14be3
(imenu-create-index-function): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
22628
diff
changeset
|
230 ;;;###autoload |
6230 | 231 (defvar imenu-create-index-function 'imenu-default-create-index-function |
232 "The function to use for creating a buffer index. | |
233 | |
234 It should be a function that takes no arguments and returns an index | |
16271
00bece0cd6c2
(imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents:
16244
diff
changeset
|
235 of the current buffer as an alist. |
00bece0cd6c2
(imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents:
16244
diff
changeset
|
236 |
00bece0cd6c2
(imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents:
16244
diff
changeset
|
237 Simple elements in the alist look like (INDEX-NAME . INDEX-POSITION). |
20857
185fa242a2ea
(imenu-generic-expression): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20770
diff
changeset
|
238 Special elements look like (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...). |
16271
00bece0cd6c2
(imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents:
16244
diff
changeset
|
239 A nested sub-alist element looks like (INDEX-NAME SUB-ALIST). |
00bece0cd6c2
(imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents:
16244
diff
changeset
|
240 The function `imenu--subalist-p' tests an element and returns t |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
241 if it is a sub-alist. |
6230 | 242 |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
243 This function is called within a `save-excursion'. |
6230 | 244 |
245 The variable is buffer-local.") | |
22798
434ac4a14be3
(imenu-create-index-function): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
22628
diff
changeset
|
246 ;;;###autoload |
6230 | 247 (make-variable-buffer-local 'imenu-create-index-function) |
248 | |
22798
434ac4a14be3
(imenu-create-index-function): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
22628
diff
changeset
|
249 ;;;###autoload |
7319
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
250 (defvar imenu-prev-index-position-function 'beginning-of-defun |
6230 | 251 "Function for finding the next index position. |
252 | |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
253 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
|
254 `imenu-default-create-index-function', then you must set this variable |
6230 | 255 to a function that will find the next index, looking backwards in the |
256 file. | |
257 | |
258 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
|
259 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
|
260 ;;;###autoload |
7319
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
261 (make-variable-buffer-local 'imenu-prev-index-position-function) |
6230 | 262 |
22798
434ac4a14be3
(imenu-create-index-function): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
22628
diff
changeset
|
263 ;;;###autoload |
7319
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
264 (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
|
265 "Function for extracting the index item name, given a position. |
6230 | 266 |
20857
185fa242a2ea
(imenu-generic-expression): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20770
diff
changeset
|
267 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
|
268 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
|
269 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
|
270 ;;;###autoload |
7319
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
271 (make-variable-buffer-local 'imenu-extract-index-name-function) |
6230 | 272 |
22798
434ac4a14be3
(imenu-create-index-function): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
22628
diff
changeset
|
273 ;;;###autoload |
25810
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
274 (defvar imenu-name-lookup-function nil |
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
275 "Function to compare string with index item. |
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
276 |
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
277 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
|
278 non-nil if they match. |
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
279 |
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
280 If nil, comparison is done with `string='. |
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
281 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
|
282 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
|
283 arguments match\".") |
25810
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
284 ;;;###autoload |
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
285 (make-variable-buffer-local 'imenu-name-lookup-function) |
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
286 |
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
287 ;;;###autoload |
17229
b48a8dd2d8ce
(imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents:
16698
diff
changeset
|
288 (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
|
289 "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
|
290 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
|
291 ;;;###autoload |
17229
b48a8dd2d8ce
(imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents:
16698
diff
changeset
|
292 (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
|
293 |
b48a8dd2d8ce
(imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents:
16698
diff
changeset
|
294 |
16271
00bece0cd6c2
(imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents:
16244
diff
changeset
|
295 (defun imenu--subalist-p (item) |
00bece0cd6c2
(imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents:
16244
diff
changeset
|
296 (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
|
297 (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
|
298 |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
299 ;; 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
|
300 ;; 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
|
301 ;; 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
|
302 ;; is calculated. |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
303 ;; 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
|
304 (defmacro imenu-progress-message (prevpos &optional relpos reverse) |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
305 `(and |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
306 imenu-scanning-message |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
307 (let ((pos ,(if relpos |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
308 relpos |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
309 `(imenu--relative-position ,reverse)))) |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
310 (if ,(if relpos t |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
311 `(> pos (+ 5 ,prevpos))) |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
312 (progn |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
313 (message imenu-scanning-message pos) |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
314 (setq ,prevpos pos)))))) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
315 |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
316 |
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 ;;;; |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
319 ;;;; Some examples of functions utilizing the framework of this |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
320 ;;;; package. |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
321 ;;;; |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
322 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
323 |
12707
06608e9272b5
(imenu-generic-lisp-expression)
Karl Heuer <kwzh@gnu.org>
parents:
12664
diff
changeset
|
324 ;; Return the current/previous sexp and the location of the sexp (its |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
325 ;; beginning) without moving the point. |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
326 (defun imenu-example--name-and-position () |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
327 (save-excursion |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
328 (forward-sexp -1) |
17307
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
329 ;; [ydi] modified for imenu-use-markers |
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
330 (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
|
331 (end (progn (forward-sexp) (point)))) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
332 (cons (buffer-substring beg end) |
17307
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
333 beg)))) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
334 |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
335 ;;; |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
336 ;;; Lisp |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
337 ;;; |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
338 |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
339 (defun imenu-example--lisp-extract-index-name () |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
340 ;; 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
|
341 ;; 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
|
342 (save-match-data |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
343 (and (looking-at "(def") |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
344 (condition-case nil |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
345 (progn |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
346 (down-list 1) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
347 (forward-sexp 2) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
348 (let ((beg (point)) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
349 (end (progn (forward-sexp -1) (point)))) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
350 (buffer-substring beg end))) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
351 (error nil))))) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
352 |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
353 (defun imenu-example--create-lisp-index () |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
354 ;; Example of a candidate for `imenu-create-index-function'. |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
355 ;; It will generate a nested index of definitions. |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
356 (let ((index-alist '()) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
357 (index-var-alist '()) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
358 (index-type-alist '()) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
359 (index-unknown-alist '()) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
360 prev-pos) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
361 (goto-char (point-max)) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
362 (imenu-progress-message prev-pos 0) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
363 ;; Search for the function |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
364 (while (beginning-of-defun) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
365 (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
|
366 (save-match-data |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
367 (and (looking-at "(def") |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
368 (save-excursion |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
369 (down-list 1) |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
370 (cond |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
371 ((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
|
372 (forward-sexp 2) |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
373 (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
|
374 index-var-alist)) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
375 ((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
|
376 (forward-sexp 2) |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
377 (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
|
378 index-alist)) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
379 ((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
|
380 (forward-sexp 2) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
381 (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
|
382 (progn |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
383 (forward-sexp -1) |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
384 (down-list 1) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
385 (forward-sexp 1))) |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
386 (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
|
387 index-type-alist)) |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
388 (t |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
389 (forward-sexp 2) |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
390 (push (imenu-example--name-and-position) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
391 index-unknown-alist))))))) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
392 (imenu-progress-message prev-pos 100) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
393 (and index-var-alist |
14726
35e1cfdd29a4
(imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents:
14725
diff
changeset
|
394 (push (cons "Variables" index-var-alist) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
395 index-alist)) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
396 (and index-type-alist |
14726
35e1cfdd29a4
(imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents:
14725
diff
changeset
|
397 (push (cons "Types" index-type-alist) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
398 index-alist)) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
399 (and index-unknown-alist |
14726
35e1cfdd29a4
(imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents:
14725
diff
changeset
|
400 (push (cons "Syntax-unknown" index-unknown-alist) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
401 index-alist)) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
402 index-alist)) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
403 |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
404 ;; Regular expression to find C functions |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
405 (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
|
406 (concat |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
407 "^[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
|
408 "\\([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
|
409 "\\([a-zA-Z0-9_*]+[ \t]+\\)?" |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
410 "\\([*&]+[ \t]*\\)?" ; pointer |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
411 "\\([a-zA-Z0-9_*]+\\)[ \t]*(" ; name |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
412 )) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
413 |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
414 (defun imenu-example--create-c-index (&optional regexp) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
415 (let ((index-alist '()) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
416 prev-pos char) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
417 (goto-char (point-min)) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
418 (imenu-progress-message prev-pos 0) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
419 ;; Search for the function |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
420 (save-match-data |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
421 (while (re-search-forward |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
422 (or regexp imenu-example--function-name-regexp-c) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
423 nil t) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
424 (imenu-progress-message prev-pos) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
425 (backward-up-list 1) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
426 (save-excursion |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
427 (goto-char (scan-sexps (point) 1)) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
428 (setq char (following-char))) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
429 ;; 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
|
430 (if (not (eq char ?\;)) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
431 (push (imenu-example--name-and-position) index-alist)))) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
432 (imenu-progress-message prev-pos 100) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
433 (nreverse index-alist))) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
434 |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
435 |
6230 | 436 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
437 ;;; | |
438 ;;; Internal variables | |
439 ;;; | |
440 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
441 | |
442 ;; The item to use in the index for rescanning the buffer. | |
443 (defconst imenu--rescan-item '("*Rescan*" . -99)) | |
444 | |
445 ;; The latest buffer index. | |
446 ;; Buffer local. | |
20857
185fa242a2ea
(imenu-generic-expression): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20770
diff
changeset
|
447 (defvar imenu--index-alist nil |
185fa242a2ea
(imenu-generic-expression): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20770
diff
changeset
|
448 "The buffer index computed for this buffer in Imenu. |
185fa242a2ea
(imenu-generic-expression): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20770
diff
changeset
|
449 Simple elements in the alist look like (INDEX-NAME . INDEX-POSITION). |
185fa242a2ea
(imenu-generic-expression): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20770
diff
changeset
|
450 Special elements look like (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...). |
56549
7e0e6be19969
(imenu-prev-index-position-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55826
diff
changeset
|
451 A nested sub-alist element looks like (INDEX-NAME SUB-ALIST).") |
20857
185fa242a2ea
(imenu-generic-expression): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20770
diff
changeset
|
452 |
6230 | 453 (make-variable-buffer-local 'imenu--index-alist) |
454 | |
24270
02ae21f066ec
(imenu--last-menubar-index-alist): Add doc.
Richard M. Stallman <rms@gnu.org>
parents:
24233
diff
changeset
|
455 (defvar imenu--last-menubar-index-alist nil |
02ae21f066ec
(imenu--last-menubar-index-alist): Add doc.
Richard M. Stallman <rms@gnu.org>
parents:
24233
diff
changeset
|
456 "The latest buffer index used to update the menu bar menu.") |
02ae21f066ec
(imenu--last-menubar-index-alist): Add doc.
Richard M. Stallman <rms@gnu.org>
parents:
24233
diff
changeset
|
457 |
13798
4eac65d000d3
(imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents:
13645
diff
changeset
|
458 (make-variable-buffer-local 'imenu--last-menubar-index-alist) |
4eac65d000d3
(imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents:
13645
diff
changeset
|
459 |
6230 | 460 ;; 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
|
461 ;; Making this buffer local caused it not to work! |
6230 | 462 (defvar imenu--history-list nil) |
463 | |
464 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
465 ;;; | |
466 ;;; Internal support functions | |
467 ;;; | |
468 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
469 | |
470 ;;; | |
471 ;;; Sort function | |
472 ;;; 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
|
473 ;;; An item looks like (NAME . POSITION). |
6230 | 474 ;;; |
475 (defun imenu--sort-by-name (item1 item2) | |
476 (string-lessp (car item1) (car item2))) | |
477 | |
23358
3812bb3ae006
(imenu--generic-function): Sort each submenu by position.
Karl Heuer <kwzh@gnu.org>
parents:
22798
diff
changeset
|
478 (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
|
479 (< (cdr item1) (cdr item2))) |
3812bb3ae006
(imenu--generic-function): Sort each submenu by position.
Karl Heuer <kwzh@gnu.org>
parents:
22798
diff
changeset
|
480 |
6230 | 481 (defun imenu--relative-position (&optional reverse) |
482 ;; Support function to calculate relative position in buffer | |
483 ;; Beginning of buffer is 0 and end of buffer is 100 | |
484 ;; If REVERSE is non-nil then the beginning is 100 and the end is 0. | |
485 (let ((pos (point)) | |
486 (total (buffer-size))) | |
487 (and reverse (setq pos (- total pos))) | |
488 (if (> total 50000) | |
489 ;; Avoid overflow from multiplying by 100! | |
490 (/ (1- pos) (max (/ total 100) 1)) | |
491 (/ (* 100 (1- pos)) (max total 1))))) | |
492 | |
493 ;; Split LIST into sublists of max length N. | |
494 ;; Example (imenu--split '(1 2 3 4 5 6 7 8) 3)-> '((1 2 3) (4 5 6) (7 8)) | |
495 (defun imenu--split (list n) | |
496 (let ((remain list) | |
497 (result '()) | |
498 (sublist '()) | |
499 (i 0)) | |
500 (while remain | |
501 (push (pop remain) sublist) | |
502 (incf i) | |
503 (and (= i n) | |
504 ;; We have finished a sublist | |
505 (progn (push (nreverse sublist) result) | |
506 (setq i 0) | |
507 (setq sublist '())))) | |
508 ;; There might be a sublist (if the length of LIST mod n is != 0) | |
509 ;; that has to be added to the result list. | |
510 (and sublist | |
511 (push (nreverse sublist) result)) | |
512 (nreverse result))) | |
513 | |
14726
35e1cfdd29a4
(imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents:
14725
diff
changeset
|
514 ;;; 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
|
515 ;;; In any case, add TITLE to the front of the alist. |
6230 | 516 (defun imenu--split-menu (menulist title) |
16272
b64d00e44e7b
(imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents:
16271
diff
changeset
|
517 (let (keep-at-top tail) |
b64d00e44e7b
(imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents:
16271
diff
changeset
|
518 (if (memq 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 keep-at-top (cons imenu--rescan-item nil) |
b64d00e44e7b
(imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents:
16271
diff
changeset
|
520 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
|
521 (setq tail menulist) |
41305
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
522 (dolist (item tail) |
51024
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
523 (when (imenu--subalist-p item) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
524 (push item keep-at-top) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
525 (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
|
526 (if imenu-sort-function |
51024
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
527 (setq menulist (sort menulist imenu-sort-function))) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
528 (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
|
529 (setq menulist |
51024
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
530 (mapcar |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
531 (lambda (menu) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
532 (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
|
533 (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
|
534 (cons title |
b64d00e44e7b
(imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents:
16271
diff
changeset
|
535 (nconc (nreverse keep-at-top) menulist)))) |
14726
35e1cfdd29a4
(imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents:
14725
diff
changeset
|
536 |
35e1cfdd29a4
(imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents:
14725
diff
changeset
|
537 ;;; 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
|
538 ;;; into nested alists. |
35e1cfdd29a4
(imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents:
14725
diff
changeset
|
539 (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
|
540 (mapcar (function |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
541 (lambda (elt) |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
542 (if (and (consp elt) |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
543 (stringp (car elt)) |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
544 (listp (cdr elt))) |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
545 (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
|
546 elt))) |
14726
35e1cfdd29a4
(imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents:
14725
diff
changeset
|
547 alist)) |
6230 | 548 |
17307
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
549 ;;; 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
|
550 (defun imenu--truncate-items (menulist) |
35243
569b2a1b20df
(imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents:
32780
diff
changeset
|
551 (mapcar (function |
569b2a1b20df
(imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents:
32780
diff
changeset
|
552 (lambda (item) |
569b2a1b20df
(imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents:
32780
diff
changeset
|
553 (cond |
569b2a1b20df
(imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents:
32780
diff
changeset
|
554 ((consp (cdr item)) |
569b2a1b20df
(imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents:
32780
diff
changeset
|
555 (imenu--truncate-items (cdr item))) |
569b2a1b20df
(imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents:
32780
diff
changeset
|
556 (t |
569b2a1b20df
(imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents:
32780
diff
changeset
|
557 ;; truncate if necessary |
569b2a1b20df
(imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents:
32780
diff
changeset
|
558 (if (and (numberp imenu-max-item-length) |
569b2a1b20df
(imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents:
32780
diff
changeset
|
559 (> (length (car item)) imenu-max-item-length)) |
569b2a1b20df
(imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents:
32780
diff
changeset
|
560 (setcar item (substring (car item) 0 |
569b2a1b20df
(imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents:
32780
diff
changeset
|
561 imenu-max-item-length))))))) |
569b2a1b20df
(imenu--truncate-items): Revert last change.
Dave Love <fx@gnu.org>
parents:
32780
diff
changeset
|
562 menulist)) |
17307
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
563 |
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
564 |
16369
187e7c8aaff5
(imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents:
16315
diff
changeset
|
565 (defun imenu--make-index-alist (&optional noerror) |
187e7c8aaff5
(imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents:
16315
diff
changeset
|
566 "Create an index-alist for the definitions in the current buffer. |
6230 | 567 |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
568 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
|
569 non-nil. |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
570 |
16369
187e7c8aaff5
(imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents:
16315
diff
changeset
|
571 Simple elements in the alist look like (INDEX-NAME . INDEX-POSITION). |
187e7c8aaff5
(imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents:
16315
diff
changeset
|
572 Special elements look like (INDEX-NAME FUNCTION ARGUMENTS...). |
187e7c8aaff5
(imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents:
16315
diff
changeset
|
573 A nested sub-alist element looks like (INDEX-NAME SUB-ALIST). |
187e7c8aaff5
(imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents:
16315
diff
changeset
|
574 The function `imenu--subalist-p' tests an element and returns t |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
575 if it is a sub-alist. |
16369
187e7c8aaff5
(imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents:
16315
diff
changeset
|
576 |
187e7c8aaff5
(imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents:
16315
diff
changeset
|
577 There is one simple element with negative POSITION; that's intended |
187e7c8aaff5
(imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents:
16315
diff
changeset
|
578 as a way for the user to ask to recalculate the buffer's index alist." |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
579 (or (and imenu--index-alist |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
580 (or (not imenu-auto-rescan) |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
581 (and imenu-auto-rescan |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
582 (> (buffer-size) imenu-auto-rescan-maxout)))) |
17307
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
583 ;; Get the index; truncate if necessary |
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
584 (progn |
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
585 (setq imenu--index-alist |
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
586 (save-excursion |
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
587 (save-restriction |
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
588 (widen) |
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
589 (funcall imenu-create-index-function)))) |
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
590 (imenu--truncate-items imenu--index-alist))) |
13798
4eac65d000d3
(imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents:
13645
diff
changeset
|
591 (or imenu--index-alist noerror |
4eac65d000d3
(imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents:
13645
diff
changeset
|
592 (error "No items suitable for an index found in this buffer")) |
6230 | 593 (or imenu--index-alist |
13798
4eac65d000d3
(imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents:
13645
diff
changeset
|
594 (setq imenu--index-alist (list nil))) |
6230 | 595 ;; Add a rescan option to the index. |
596 (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
|
597 |
8408
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
598 ;;; 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
|
599 ;;; them point nowhere. |
16315
cca1c6324cab
(imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents:
16272
diff
changeset
|
600 ;;; 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
|
601 ;;; non-nil arguments are in recursivecalls. |
cca1c6324cab
(imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents:
16272
diff
changeset
|
602 (defvar imenu--cleanup-seen) |
cca1c6324cab
(imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents:
16272
diff
changeset
|
603 |
8408
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
604 (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
|
605 ;; 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
|
606 ;; 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
|
607 ;; and use imenu--index-alist. |
cca1c6324cab
(imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents:
16272
diff
changeset
|
608 (if alist |
cca1c6324cab
(imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents:
16272
diff
changeset
|
609 (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
|
610 (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
|
611 |
10795
8cbc8846b19b
(imenu--cleanup): Set alist to its default just once, at the beginning.
Richard M. Stallman <rms@gnu.org>
parents:
10221
diff
changeset
|
612 (and alist |
31560
5dd0eccb46c5
(imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents:
29552
diff
changeset
|
613 (mapc |
5dd0eccb46c5
(imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents:
29552
diff
changeset
|
614 (lambda (item) |
5dd0eccb46c5
(imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents:
29552
diff
changeset
|
615 (cond |
5dd0eccb46c5
(imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents:
29552
diff
changeset
|
616 ((markerp (cdr item)) |
5dd0eccb46c5
(imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents:
29552
diff
changeset
|
617 (set-marker (cdr item) nil)) |
5dd0eccb46c5
(imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents:
29552
diff
changeset
|
618 ;; Don't process one alist twice. |
5dd0eccb46c5
(imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents:
29552
diff
changeset
|
619 ((memq (cdr item) imenu--cleanup-seen)) |
5dd0eccb46c5
(imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents:
29552
diff
changeset
|
620 ((imenu--subalist-p item) |
5dd0eccb46c5
(imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents:
29552
diff
changeset
|
621 (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
|
622 alist) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
623 t)) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
624 |
51024
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
625 (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
|
626 (list* 'keymap title |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
627 (mapcar |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
628 (lambda (item) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
629 (list* (car item) (car item) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
630 (cond |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
631 ((imenu--subalist-p item) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
632 (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
|
633 (t |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
634 `(lambda () (interactive) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
635 ,(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
|
636 alist))) |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
637 |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
638 (defun imenu--in-alist (str alist) |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
639 "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
|
640 (let (elt head tail res) |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
641 (setq res nil) |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
642 (while alist |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
643 (setq elt (car alist) |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
644 tail (cdr elt) |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
645 alist (cdr alist) |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
646 head (car elt)) |
15929
955269257adf
(imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents:
15831
diff
changeset
|
647 ;; 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
|
648 ;; (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
|
649 ;; 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
|
650 ;; (INDEX-NAME . INDEX-POSITION) |
955269257adf
(imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents:
15831
diff
changeset
|
651 ;; 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
|
652 ;; 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
|
653 (cond ((listp tail) |
955269257adf
(imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents:
15831
diff
changeset
|
654 (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
|
655 (setq alist nil))) |
25810
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
656 ((if imenu-name-lookup-function |
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
657 (funcall imenu-name-lookup-function str head) |
f1417ed050c0
(imenu-after-jump-hook): New variable.
Phillip Rulon <pjr@gnu.org>
parents:
24578
diff
changeset
|
658 (string= str head)) |
15929
955269257adf
(imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents:
15831
diff
changeset
|
659 (setq alist nil res elt)))) |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
660 res)) |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
661 |
20770
31a8ad177c4c
(imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents:
20769
diff
changeset
|
662 (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
|
663 "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
|
664 |
31a8ad177c4c
(imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents:
20769
diff
changeset
|
665 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
|
666 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
|
667 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
|
668 |
31a8ad177c4c
(imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents:
20769
diff
changeset
|
669 This is typically used to give word syntax to characters which |
22260 | 670 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
|
671 and speed-up matching.") |
35688
8b295a5d2192
(imenu-syntax-alist): Add autoload cookie for
Gerd Moellmann <gerd@gnu.org>
parents:
35243
diff
changeset
|
672 ;;;###autoload |
20770
31a8ad177c4c
(imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents:
20769
diff
changeset
|
673 (make-variable-buffer-local 'imenu-syntax-alist) |
31a8ad177c4c
(imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents:
20769
diff
changeset
|
674 |
6230 | 675 (defun imenu-default-create-index-function () |
676 "*Wrapper for index searching functions. | |
677 | |
678 Moves point to end of buffer and then repeatedly calls | |
7319
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
679 `imenu-prev-index-position-function' and `imenu-extract-index-name-function'. |
6230 | 680 Their results are gathered into an index alist." |
7350
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
681 ;; 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
|
682 ;; 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
|
683 (cond ((and imenu-prev-index-position-function |
c42156dab61b
(imenu-default-create-index-function):
Karl Heuer <kwzh@gnu.org>
parents:
20051
diff
changeset
|
684 imenu-extract-index-name-function) |
7350
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
685 (let ((index-alist '()) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
686 prev-pos name) |
7350
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
687 (goto-char (point-max)) |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
688 (imenu-progress-message prev-pos 0 t) |
7350
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
689 ;; 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
|
690 (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
|
691 (imenu-progress-message prev-pos nil t) |
7350
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
692 (save-excursion |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
693 (setq name (funcall imenu-extract-index-name-function))) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
694 (and (stringp name) |
17307
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
695 ;; [ydi] updated for imenu-use-markers |
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
696 (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
|
697 index-alist))) |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
698 (imenu-progress-message prev-pos 100 t) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
699 index-alist)) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
700 ;; Use generic expression if possible. |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
701 ((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
|
702 (imenu--generic-function imenu-generic-expression)) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
703 (t |
17307
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
704 (error "This buffer cannot use `imenu-default-create-index-function'")))) |
6230 | 705 |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
706 ;; Not used and would require cl at run time |
51024
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
707 ;; (defun imenu--flatten-index-alist (index-alist &optional concat-names prefix) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
708 ;; ;; Takes a nested INDEX-ALIST and returns a flat index alist. |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
709 ;; ;; If optional CONCAT-NAMES is non-nil, then a nested index has its |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
710 ;; ;; name and a space concatenated to the names of the children. |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
711 ;; ;; Third argument PREFIX is for internal use only. |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
712 ;; (mapcan |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
713 ;; (lambda (item) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
714 ;; (let* ((name (car item)) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
715 ;; (pos (cdr item)) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
716 ;; (new-prefix (and concat-names |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
717 ;; (if prefix |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
718 ;; (concat prefix imenu-level-separator name) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
719 ;; name)))) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
720 ;; (cond |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
721 ;; ((or (markerp pos) (numberp pos)) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
722 ;; (list (cons new-prefix pos))) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
723 ;; (t |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
724 ;; (imenu--flatten-index-alist pos new-prefix))))) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
725 ;; index-alist)) |
6230 | 726 |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
727 ;;; |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
728 ;;; Generic index gathering function. |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
729 ;;; |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
730 |
20769
aa3481dd4d84
(imenu-case-fold-search): New buffer-local variable.
Dave Love <fx@gnu.org>
parents:
20249
diff
changeset
|
731 (defvar imenu-case-fold-search t |
aa3481dd4d84
(imenu-case-fold-search): New buffer-local variable.
Dave Love <fx@gnu.org>
parents:
20249
diff
changeset
|
732 "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
|
733 |
41305
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
734 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
|
735 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
|
736 `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
|
737 ;;;###autoload |
20769
aa3481dd4d84
(imenu-case-fold-search): New buffer-local variable.
Dave Love <fx@gnu.org>
parents:
20249
diff
changeset
|
738 (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
|
739 |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
740 ;; Originally "Built on some ideas that Erik Naggum <erik@naggum.no> |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
741 ;; once posted to comp.emacs" but since substantially re-written. |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
742 (defun imenu--generic-function (patterns) |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
743 "Return an index of the current buffer as an alist. |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
744 |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
745 PATTERNS is an alist with elements that look like this: |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
746 (MENU-TITLE REGEXP INDEX). |
52733
9cb896b7b7e2
(imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
747 or like this: |
9cb896b7b7e2
(imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
748 (MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...) |
9cb896b7b7e2
(imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
749 with zero or more ARGUMENTS. |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
750 |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
751 MENU-TITLE is a string used as the title for the submenu or nil if the |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
752 entries are not nested. |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
753 |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
754 REGEXP is a regexp that should match a construct in the buffer that is |
12664
ce1cae301efe
(imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents:
12635
diff
changeset
|
755 to be displayed in the menu; i.e., function or variable definitions, |
ce1cae301efe
(imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents:
12635
diff
changeset
|
756 etc. It contains a substring which is the name to appear in the |
ce1cae301efe
(imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents:
12635
diff
changeset
|
757 menu. See the info section on Regexps for more information. |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
758 |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
759 INDEX points to the substring in REGEXP that contains the name (of the |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
760 function, variable or type) that is to appear in the menu. |
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
761 |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
762 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
|
763 |
12664
ce1cae301efe
(imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents:
12635
diff
changeset
|
764 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
|
765 the alist look like: |
9cb896b7b7e2
(imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
766 (INDEX-NAME . INDEX-POSITION) |
9cb896b7b7e2
(imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
767 or like: |
9cb896b7b7e2
(imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
768 (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...) |
9cb896b7b7e2
(imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
769 They may also be nested index alists like: |
9cb896b7b7e2
(imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
770 (INDEX-NAME . INDEX-ALIST) |
9cb896b7b7e2
(imenu--generic-function): Docstring fix.
Lute Kamstra <lute@gnu.org>
parents:
52401
diff
changeset
|
771 depending on PATTERNS." |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
772 |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
773 (let ((index-alist (list 'dummy)) |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
774 prev-pos beg |
50846
1ac6f8245bff
(imenu--generic-function): Use font-lock-defaults
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46981
diff
changeset
|
775 (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
|
776 (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
|
777 imenu-case-fold-search |
1ac6f8245bff
(imenu--generic-function): Use font-lock-defaults
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46981
diff
changeset
|
778 (nth 2 font-lock-defaults))) |
20770
31a8ad177c4c
(imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents:
20769
diff
changeset
|
779 (old-table (syntax-table)) |
31a8ad177c4c
(imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents:
20769
diff
changeset
|
780 (table (copy-syntax-table (syntax-table))) |
31a8ad177c4c
(imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents:
20769
diff
changeset
|
781 (slist imenu-syntax-alist)) |
31a8ad177c4c
(imenu-syntax-alist): New buffer-local variable.
Dave Love <fx@gnu.org>
parents:
20769
diff
changeset
|
782 ;; 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
|
783 (dolist (syn slist) |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
784 ;; 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
|
785 (if (numberp (car syn)) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
786 (modify-syntax-entry (car syn) (cdr syn) table) |
46977
54ce0e6e293f
(imenu--generic-function): Use mapc.
Glenn Morris <rgm@gnu.org>
parents:
46894
diff
changeset
|
787 (mapc (lambda (c) |
54ce0e6e293f
(imenu--generic-function): Use mapc.
Glenn Morris <rgm@gnu.org>
parents:
46894
diff
changeset
|
788 (modify-syntax-entry c (cdr syn) table)) |
54ce0e6e293f
(imenu--generic-function): Use mapc.
Glenn Morris <rgm@gnu.org>
parents:
46894
diff
changeset
|
789 (car syn)))) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
790 (goto-char (point-max)) |
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
791 (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
|
792 (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
|
793 (save-match-data |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
794 (set-syntax-table table) |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
795 ;; 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
|
796 ;; (typically functions, variables ...) |
41305
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
797 (dolist (pat patterns) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
798 (let ((menu-title (car pat)) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
799 (regexp (nth 1 pat)) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
800 (index (nth 2 pat)) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
801 (function (nth 3 pat)) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
802 (rest (nthcdr 4 pat))) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
803 ;; 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
|
804 (goto-char (point-max)) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
805 (while (re-search-backward regexp nil t) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
806 (imenu-progress-message prev-pos nil t) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
807 (setq beg (match-beginning index)) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
808 ;; Add this sort of submenu only when we've found an |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
809 ;; item for it, avoiding empty, duff menus. |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
810 (unless (assoc menu-title index-alist) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
811 (push (list menu-title) index-alist)) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
812 (if imenu-use-markers |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
813 (setq beg (copy-marker beg))) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
814 (let ((item |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
815 (if function |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
816 (nconc (list (match-string-no-properties index) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
817 beg function) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
818 rest) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
819 (cons (match-string-no-properties index) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
820 beg))) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
821 ;; This is the desired submenu, |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
822 ;; starting with its title (or nil). |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
823 (menu (assoc menu-title index-alist))) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
824 ;; Insert the item unless it is already present. |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
825 (unless (member item (cdr menu)) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
826 (setcdr menu |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
827 (cons item (cdr menu)))))))) |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
828 (set-syntax-table old-table))) |
14726
35e1cfdd29a4
(imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents:
14725
diff
changeset
|
829 (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
|
830 ;; Sort each submenu by position. |
3812bb3ae006
(imenu--generic-function): Sort each submenu by position.
Karl Heuer <kwzh@gnu.org>
parents:
22798
diff
changeset
|
831 ;; 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
|
832 (dolist (item index-alist) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
833 (when (listp item) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
834 (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
|
835 (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
|
836 (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
|
837 (cdr main-element))))) |
10093
caafb376e619
(imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
10072
diff
changeset
|
838 |
6230 | 839 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
840 ;;; | |
841 ;;; The main functions for this package! | |
842 ;;; | |
843 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
844 | |
41305
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
845 ;; 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
|
846 (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
|
847 "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
|
848 (catch 'found |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
849 (let ((case-fold-search t)) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
850 (if (assoc guess completions) guess |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
851 (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
|
852 (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 (regexp-quote guess))) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
855 (dolist (x completions) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
856 (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
|
857 |
6230 | 858 (defun imenu--completion-buffer (index-alist &optional prompt) |
859 "Let the user select from INDEX-ALIST in a completion buffer with PROMPT. | |
860 | |
861 Returns t for rescan and otherwise a position number." | |
862 ;; 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
|
863 (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
|
864 choice |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
865 (prepared-index-alist |
46894
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
866 (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
|
867 (mapcar |
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
868 (lambda (item) |
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
869 (cons (subst-char-in-string ?\ (aref imenu-space-replacement 0) |
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
870 (car item)) |
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
871 (cdr item))) |
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
872 index-alist)))) |
41305
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
873 (when (stringp name) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
874 (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
|
875 (cond (prompt) |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
876 ((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
|
877 (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
|
878 (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
|
879 (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
|
880 ;; Display the completion buffer. |
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
881 (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
|
882 (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
|
883 (setq name (completing-read prompt |
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
884 prepared-index-alist |
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
885 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
|
886 |
41305
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
887 (cond ((not (stringp name)) nil) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
888 ((string= name (car imenu--rescan-item)) t) |
7350
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
889 (t |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
890 (setq choice (assoc name prepared-index-alist)) |
16271
00bece0cd6c2
(imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents:
16244
diff
changeset
|
891 (if (imenu--subalist-p choice) |
7350
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
892 (imenu--completion-buffer (cdr choice) prompt) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
893 choice))))) |
7319
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
894 |
6230 | 895 (defun imenu--mouse-menu (index-alist event &optional title) |
896 "Let the user select from a buffer index from a mouse menu. | |
897 | |
898 INDEX-ALIST is the buffer index and EVENT is a mouse event. | |
899 | |
16148
8ca583c0b988
(imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents:
15929
diff
changeset
|
900 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
|
901 (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
|
902 (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
|
903 (map (imenu--create-keymap (car menu) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
904 (cdr (if (< 1 (length (cdr menu))) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
905 menu |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
906 (car (cdr menu))))))) |
41305
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
907 (popup-menu map event))) |
6230 | 908 |
6241 | 909 (defun imenu-choose-buffer-index (&optional prompt alist) |
6230 | 910 "Let the user select from a buffer index and return the chosen index. |
911 | |
912 If the user originally activated this function with the mouse, a mouse | |
913 menu is used. Otherwise a completion buffer is used and the user is | |
914 prompted with PROMPT. | |
915 | |
6241 | 916 If you call this function with index alist ALIST, then it lets the user |
917 select from ALIST. | |
918 | |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
919 With no index alist ALIST, it calls `imenu--make-index-alist' to |
6241 | 920 create the index alist. |
921 | |
46894
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
922 If `imenu-use-popup-menu' is non-nil, then the |
6230 | 923 completion buffer is always used, no matter if the mouse was used or |
924 not. | |
925 | |
16369
187e7c8aaff5
(imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents:
16315
diff
changeset
|
926 The returned value is of the form (INDEX-NAME . INDEX-POSITION)." |
6230 | 927 (let (index-alist |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
928 (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
|
929 (result t)) |
6230 | 930 ;; If selected by mouse, see to that the window where the mouse is |
931 ;; really is selected. | |
932 (and mouse-triggered | |
12396
d0c82df80d70
(imenu-choose-buffer-index): Understand that (menu-bar)
Richard M. Stallman <rms@gnu.org>
parents:
12394
diff
changeset
|
933 (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
|
934 (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
|
935 (or (framep window) (null window) (select-window window)))) |
6230 | 936 ;; Create a list for this buffer only when needed. |
937 (while (eq result t) | |
6241 | 938 (setq index-alist (if alist alist (imenu--make-index-alist))) |
6230 | 939 (setq result |
46894
f8b45e2dec81
(imenu-always-use-completion-buffer-p): Make obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43982
diff
changeset
|
940 (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
|
941 (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
|
942 (imenu--mouse-menu index-alist last-nonmenu-event) |
6230 | 943 (imenu--completion-buffer index-alist prompt))) |
944 (and (eq result t) | |
8408
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
945 (imenu--cleanup) |
6230 | 946 (setq imenu--index-alist nil))) |
947 result)) | |
948 | |
12394
4fbc70e4d5e7
(imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
10795
diff
changeset
|
949 ;;;###autoload |
8408
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
950 (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
|
951 "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
|
952 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
|
953 See the command `imenu' for more information." |
13798
4eac65d000d3
(imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents:
13645
diff
changeset
|
954 (interactive "sImenu menu item name: ") |
20249
c42156dab61b
(imenu-default-create-index-function):
Karl Heuer <kwzh@gnu.org>
parents:
20051
diff
changeset
|
955 (if (or (and imenu-prev-index-position-function |
c42156dab61b
(imenu-default-create-index-function):
Karl Heuer <kwzh@gnu.org>
parents:
20051
diff
changeset
|
956 imenu-extract-index-name-function) |
c42156dab61b
(imenu-default-create-index-function):
Karl Heuer <kwzh@gnu.org>
parents:
20051
diff
changeset
|
957 imenu-generic-expression |
c42156dab61b
(imenu-default-create-index-function):
Karl Heuer <kwzh@gnu.org>
parents:
20051
diff
changeset
|
958 (not (eq imenu-create-index-function |
c42156dab61b
(imenu-default-create-index-function):
Karl Heuer <kwzh@gnu.org>
parents:
20051
diff
changeset
|
959 'imenu-default-create-index-function))) |
31560
5dd0eccb46c5
(imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents:
29552
diff
changeset
|
960 (let ((newmap (make-sparse-keymap))) |
5dd0eccb46c5
(imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents:
29552
diff
changeset
|
961 (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
|
962 (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
|
963 (define-key newmap [menu-bar index] |
32284
700a91f9a4b4
(imenu-add-to-menubar): Fix again.
Dave Love <fx@gnu.org>
parents:
32279
diff
changeset
|
964 `(menu-item ,name ,(make-sparse-keymap "Imenu"))) |
31560
5dd0eccb46c5
(imenu--truncate-items, imenu--cleanup)
Dave Love <fx@gnu.org>
parents:
29552
diff
changeset
|
965 (use-local-map newmap) |
20249
c42156dab61b
(imenu-default-create-index-function):
Karl Heuer <kwzh@gnu.org>
parents:
20051
diff
changeset
|
966 (add-hook 'menu-bar-update-hook 'imenu-update-menubar)) |
17229
b48a8dd2d8ce
(imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents:
16698
diff
changeset
|
967 (error "The mode `%s' does not support Imenu" mode-name))) |
13798
4eac65d000d3
(imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents:
13645
diff
changeset
|
968 |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
969 ;;;###autoload |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
970 (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
|
971 "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
|
972 |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
973 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
|
974 (interactive) |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
975 (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
|
976 |
14642
01e8fdb45deb
(imenu-buffer-menubar): Add defvar.
Karl Heuer <kwzh@gnu.org>
parents:
14575
diff
changeset
|
977 (defvar imenu-buffer-menubar nil) |
01e8fdb45deb
(imenu-buffer-menubar): Add defvar.
Karl Heuer <kwzh@gnu.org>
parents:
14575
diff
changeset
|
978 |
43982
a40fcee55faa
(imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
43832
diff
changeset
|
979 (defvar imenu-menubar-modified-tick 0 |
43832
5d834c3f5d18
(imenu-update-menubar-modified-tick): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
41305
diff
changeset
|
980 "The value of (buffer-modified-tick) as of last call to `imenu-update-menubar'. |
5d834c3f5d18
(imenu-update-menubar-modified-tick): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
41305
diff
changeset
|
981 This value becomes local in every buffer when it is set.") |
43982
a40fcee55faa
(imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
43832
diff
changeset
|
982 (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
|
983 |
13798
4eac65d000d3
(imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents:
13645
diff
changeset
|
984 (defun imenu-update-menubar () |
43982
a40fcee55faa
(imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
43832
diff
changeset
|
985 (when (and (current-local-map) |
a40fcee55faa
(imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
43832
diff
changeset
|
986 (keymapp (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
|
987 (not (eq (buffer-modified-tick) |
a40fcee55faa
(imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
43832
diff
changeset
|
988 imenu-menubar-modified-tick))) |
a40fcee55faa
(imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
43832
diff
changeset
|
989 (setq imenu-menubar-modified-tick (buffer-modified-tick)) |
a40fcee55faa
(imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
43832
diff
changeset
|
990 (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
|
991 ;; 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
|
992 ;; since the last time we did it. |
a40fcee55faa
(imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
43832
diff
changeset
|
993 (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
|
994 (let (menu menu1 old) |
a40fcee55faa
(imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
43832
diff
changeset
|
995 (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
|
996 (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
|
997 (setq menu (imenu--split-menu index-alist |
a40fcee55faa
(imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
43832
diff
changeset
|
998 (buffer-name))) |
51024
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
999 (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
|
1000 (cdr (if (< 1 (length (cdr menu))) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
1001 menu |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
1002 (car (cdr menu)))) |
4efabfff9aa1
(imenu--split-menu): Remove unused var `count'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50846
diff
changeset
|
1003 'imenu--menubar-select)) |
43982
a40fcee55faa
(imenu-menubar-modified-tick): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
43832
diff
changeset
|
1004 (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
|
1005 (setcdr old (cdr menu1))))))) |
13798
4eac65d000d3
(imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents:
13645
diff
changeset
|
1006 |
4eac65d000d3
(imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents:
13645
diff
changeset
|
1007 (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
|
1008 "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
|
1009 (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
|
1010 (progn |
29e7001fecf0
(imenu--menubar-select): Handle the "rescan" item.
Richard M. Stallman <rms@gnu.org>
parents:
14733
diff
changeset
|
1011 (imenu--cleanup) |
55826
e7bdb5b77df2
(imenu--menubar-select): Set imenu-menubar-modified-tick
Richard M. Stallman <rms@gnu.org>
parents:
52733
diff
changeset
|
1012 ;; 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
|
1013 (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
|
1014 (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
|
1015 (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
|
1016 (imenu-update-menubar) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
1017 t) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
1018 (imenu item) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
1019 nil)) |
8408
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
1020 |
17229
b48a8dd2d8ce
(imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents:
16698
diff
changeset
|
1021 (defun imenu-default-goto-function (name position &optional rest) |
21852
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
1022 "Move the point to the given position. |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
1023 |
5898cd2e4cd6
(imenu--generic-function): Doc fix. Rewritten to be faster.
Richard M. Stallman <rms@gnu.org>
parents:
20857
diff
changeset
|
1024 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
|
1025 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
|
1026 function placed in a special index-item." |
17307
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
1027 (if (or (< position (point-min)) |
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
1028 (> position (point-max))) |
17229
b48a8dd2d8ce
(imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents:
16698
diff
changeset
|
1029 ;; widen if outside narrowing |
b48a8dd2d8ce
(imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents:
16698
diff
changeset
|
1030 (widen)) |
17307
830ad59547e4
(imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents:
17230
diff
changeset
|
1031 (goto-char position)) |
17229
b48a8dd2d8ce
(imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents:
16698
diff
changeset
|
1032 |
7319
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
1033 ;;;###autoload |
12664
ce1cae301efe
(imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents:
12635
diff
changeset
|
1034 (defun imenu (index-item) |
7319
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
1035 "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
|
1036 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
|
1037 for more information." |
16698
13920eac02e0
(imenu-generic-expression): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
16612
diff
changeset
|
1038 (interactive (list (imenu-choose-buffer-index))) |
13798
4eac65d000d3
(imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents:
13645
diff
changeset
|
1039 ;; Convert a string to an alist element. |
4eac65d000d3
(imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents:
13645
diff
changeset
|
1040 (if (stringp index-item) |
4eac65d000d3
(imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents:
13645
diff
changeset
|
1041 (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
|
1042 (when index-item |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
1043 (push-mark) |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
1044 (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
|
1045 (function |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
1046 (if is-special-item |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
1047 (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
|
1048 (position (if is-special-item |
71197bcff33c
(imenu--split-menu): Use dolist and copy-sequence.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
1049 (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
|
1050 (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
|
1051 (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
|
1052 (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
|
1053 |
29078 | 1054 (dolist (mess |
1055 '("^No items suitable for an index found in this buffer$" | |
1056 "^This buffer cannot use `imenu-default-create-index-function'$" | |
1057 "^The mode `.*' does not support Imenu$")) | |
1058 (add-to-list 'debug-ignored-errors mess)) | |
1059 | |
6230 | 1060 (provide 'imenu) |
1061 | |
52401 | 1062 ;;; arch-tag: 98a2f5f5-4b91-4704-b18c-3aacf77d77a7 |
6230 | 1063 ;;; imenu.el ends here |