Mercurial > emacs
annotate lisp/imenu.el @ 9580:bcc9342cf633
(x_set_unsplittable): New function.
(x_frame_parms): Add that function to the table.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Tue, 18 Oct 1994 02:32:43 +0000 |
parents | 5646f9ac8ec3 |
children | a7b70665c937 |
rev | line source |
---|---|
6230 | 1 ;;; imenu.el --- Framework for mode-specific buffer indexes. |
2 | |
3 ;; Copyright (C) 1994 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Ake Stenhoff <etxaksf@aom.ericsson.se> | |
6 ;; Lars Lindberg <lli@sypro.cap.se> | |
7 ;; Created: 8 Feb 1994 | |
9176
5646f9ac8ec3
(imenu--cleanup): Changed 'mapc' to 'mapcar'.
Richard M. Stallman <rms@gnu.org>
parents:
8408
diff
changeset
|
8 ;; Version: 1.12 |
6230 | 9 ;; Keywords: tools |
10 ;; | |
11 ;; This program is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 ;; | |
16 ;; This program is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 ;; | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with this program; if not, write to the Free Software | |
23 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | |
25 ;;; Commentary: | |
26 ;; | |
27 ;; Purpose of this package: | |
28 ;; To present a framework for mode-specific buffer indexes. | |
29 ;; A buffer index is an alist of names and buffer positions. | |
30 ;; For instance all functions in a C-file and their positions. | |
31 ;; | |
32 ;; How it works: | |
33 | |
34 ;; A mode-specific function is called to generate the index. It is | |
35 ;; then presented to the user, who can choose from this index. | |
36 ;; | |
37 ;; The package comes with a set of example functions for how to | |
38 ;; utilize this package. | |
39 | |
40 ;; There are *examples* for index gathering functions for C/C++ and | |
41 ;; Lisp/Emacs Lisp but it is easy to customize for other modes. A | |
42 ;; function for jumping to the chosen index position is also | |
43 ;; supplied. | |
44 | |
6241 | 45 ;;; Thanks goes to |
46 ;; [simon] - Simon Leinen simon@lia.di.epfl.ch | |
47 ;; [dean] - Dean Andrews ada@unison.com | |
8408
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
48 ;; [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
|
49 ;; [greg] - Greg Thompson gregt@porsche.visix.COM |
6241 | 50 |
6230 | 51 ;;; Code |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
52 (eval-when-compile (require 'cl)) |
6230 | 53 |
54 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
55 ;;; | |
56 ;;; Customizable variables | |
57 ;;; | |
58 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
59 | |
60 (defvar imenu-always-use-completion-buffer-p nil | |
61 "*Set this to non-nil for displaying the index in a completion buffer. | |
62 | |
63 Non-nil means always display the index in a completion buffer. | |
64 Nil means display the index as a mouse menu when the mouse was | |
7319
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
65 used to invoke `imenu'.") |
6230 | 66 |
67 (defvar imenu-sort-function nil | |
68 "*The function to use for sorting the index mouse-menu. | |
69 | |
70 Affects only the mouse index menu. | |
71 | |
72 Set this to nil if you don't want any sorting (faster). | |
73 The items in the menu are then presented in the order they were found | |
74 in the buffer. | |
75 | |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
76 Set it to `imenu--sort-by-name' if you want alphabetic sorting. |
6230 | 77 |
78 The function should take two arguments and return T if the first | |
79 element should come before the second. The arguments are cons cells; | |
7639 | 80 \(NAME . POSITION). Look at `imenu--sort-by-name' for an example.") |
6230 | 81 |
82 (defvar imenu-max-items 25 | |
83 "*Maximum number of elements in an index mouse-menu.") | |
84 | |
85 (defvar imenu-scanning-message "Scanning buffer for index. (%3d%%)" | |
86 "*Progress message during the index scanning of the buffer. | |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
87 If non-nil, user gets a message during the scanning of the buffer |
6230 | 88 |
89 Relevant only if the mode-specific function that creates the buffer | |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
90 index use `imenu-progress-message'.") |
6230 | 91 |
92 (defvar imenu-space-replacement "^" | |
93 "*The replacement string for spaces in index names. | |
94 Used when presenting the index in a completion-buffer to make the | |
95 names work as tokens.") | |
96 | |
97 (defvar imenu-level-separator ":" | |
98 "*The separator between index names of different levels. | |
99 Used for making mouse-menu titles and for flattening nested indexes | |
100 with name concatenation.") | |
101 | |
102 (defvar imenu-submenu-name-format "%s..." | |
103 "*The format for making a submenu name.") | |
104 | |
105 ;;;; Hooks | |
106 | |
107 (defvar imenu-create-index-function 'imenu-default-create-index-function | |
108 "The function to use for creating a buffer index. | |
109 | |
110 It should be a function that takes no arguments and returns an index | |
111 of the current buffer as an alist. The elements in the alist look | |
112 like: (INDEX-NAME . INDEX-POSITION). You may also nest index list like | |
7639 | 113 \(INDEX-NAME . INDEX-ALIST). |
6230 | 114 |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
115 This function is called within a `save-excursion'. |
6230 | 116 |
117 The variable is buffer-local.") | |
118 (make-variable-buffer-local 'imenu-create-index-function) | |
119 | |
7319
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
120 (defvar imenu-prev-index-position-function 'beginning-of-defun |
6230 | 121 "Function for finding the next index position. |
122 | |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
123 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
|
124 `imenu-default-create-index-function', then you must set this variable |
6230 | 125 to a function that will find the next index, looking backwards in the |
126 file. | |
127 | |
128 The function should leave point at the place to be connected to the | |
129 index and it should return nil when it doesn't find another index. ") | |
7319
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
130 (make-variable-buffer-local 'imenu-prev-index-position-function) |
6230 | 131 |
7319
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
132 (defvar imenu-extract-index-name-function nil |
6230 | 133 "Function for extracting the index name. |
134 | |
135 This function is called after the function pointed out by | |
7319
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
136 `imenu-prev-index-position-function'.") |
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
137 (make-variable-buffer-local 'imenu-extract-index-name-function) |
6230 | 138 |
139 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
140 ;;; | |
141 ;;; Internal variables | |
142 ;;; | |
143 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
144 | |
145 ;; The item to use in the index for rescanning the buffer. | |
146 (defconst imenu--rescan-item '("*Rescan*" . -99)) | |
147 | |
148 ;; The latest buffer index. | |
149 ;; Buffer local. | |
150 (defvar imenu--index-alist nil) | |
151 (make-variable-buffer-local 'imenu--index-alist) | |
152 | |
153 ;; History list for 'jump-to-function-in-buffer'. | |
154 ;; Buffer local. | |
155 (defvar imenu--history-list nil) | |
156 (make-variable-buffer-local 'imenu--history-list) | |
157 | |
158 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
159 ;;; | |
160 ;;; Internal support functions | |
161 ;;; | |
162 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
163 | |
164 ;;; | |
165 ;;; Sort function | |
166 ;;; Sorts the items depending on their index name. | |
167 ;;; An item look like (NAME . POSITION). | |
168 ;;; | |
169 (defun imenu--sort-by-name (item1 item2) | |
170 (string-lessp (car item1) (car item2))) | |
171 | |
172 (defun imenu--relative-position (&optional reverse) | |
173 ;; Support function to calculate relative position in buffer | |
174 ;; Beginning of buffer is 0 and end of buffer is 100 | |
175 ;; If REVERSE is non-nil then the beginning is 100 and the end is 0. | |
176 (let ((pos (point)) | |
177 (total (buffer-size))) | |
178 (and reverse (setq pos (- total pos))) | |
179 (if (> total 50000) | |
180 ;; Avoid overflow from multiplying by 100! | |
181 (/ (1- pos) (max (/ total 100) 1)) | |
182 (/ (* 100 (1- pos)) (max total 1))))) | |
183 | |
184 ;;; | |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
185 ;;; Macro to display a progress message. |
6230 | 186 ;;; RELPOS is the relative position to display. |
187 ;;; If RELPOS is nil, then the relative position in the buffer | |
188 ;;; is calculated. | |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
189 ;;; PREVPOS is the variable in which we store the last position displayed. |
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
190 (defmacro imenu-progress-message (prevpos &optional relpos reverse) |
6230 | 191 (` (and |
192 imenu-scanning-message | |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
193 (let ((pos (, (if relpos |
6230 | 194 relpos |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
195 (` (imenu--relative-position (, reverse))))))) |
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
196 (if (, (if relpos t |
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
197 (` (> pos (+ 5 (, prevpos)))))) |
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
198 (progn |
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
199 (message imenu-scanning-message pos) |
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
200 (setq (, prevpos) pos))))))) |
6230 | 201 |
202 ;;; | |
203 ;;; Function for suporting general looking submenu names. | |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
204 ;;; Uses `imenu-submenu-name-format' for creating the name. |
6230 | 205 ;;; NAME is the base of the new submenu name. |
206 ;;; | |
207 (defun imenu-create-submenu-name (name) | |
208 (format imenu-submenu-name-format name)) | |
209 | |
210 ;; Split LIST into sublists of max length N. | |
211 ;; Example (imenu--split '(1 2 3 4 5 6 7 8) 3)-> '((1 2 3) (4 5 6) (7 8)) | |
212 (defun imenu--split (list n) | |
213 (let ((remain list) | |
214 (result '()) | |
215 (sublist '()) | |
216 (i 0)) | |
217 (while remain | |
218 (push (pop remain) sublist) | |
219 (incf i) | |
220 (and (= i n) | |
221 ;; We have finished a sublist | |
222 (progn (push (nreverse sublist) result) | |
223 (setq i 0) | |
224 (setq sublist '())))) | |
225 ;; There might be a sublist (if the length of LIST mod n is != 0) | |
226 ;; that has to be added to the result list. | |
227 (and sublist | |
228 (push (nreverse sublist) result)) | |
229 (nreverse result))) | |
230 | |
231 ;;; | |
232 ;;; Split a menu in to several menus. | |
233 ;;; | |
234 (defun imenu--split-menu (menulist title) | |
235 (cons "Function menus" | |
236 (mapcar | |
237 (function | |
238 (lambda (menu) | |
239 (cons (format "(%s)" title) menu))) | |
240 (imenu--split menulist imenu-max-items)))) | |
241 | |
242 ;;; | |
243 ;;; Find all items in this buffer that should be in the index. | |
244 ;;; Returns an alist on the form | |
245 ;;; ((NAME . POSITION) (NAME . POSITION) ...) | |
246 ;;; | |
247 | |
248 (defun imenu--make-index-alist () | |
249 ;; Create a list for this buffer only when needed. | |
250 (or imenu--index-alist | |
251 ;; Get the index | |
252 (setq imenu--index-alist | |
253 (save-excursion | |
254 (funcall imenu-create-index-function)))) | |
255 (or imenu--index-alist | |
256 (error "No items suitable for an index found in this buffer.")) | |
257 ;; Add a rescan option to the index. | |
258 (cons imenu--rescan-item imenu--index-alist)) | |
8408
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
259 ;;; |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
260 ;;; 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
|
261 ;;; them point nowhere. |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
262 ;;; |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
263 (defun imenu--cleanup (&optional alist) |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
264 ;; Sets the markers in imenu--index-alist |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
265 ;; point nowhere. |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
266 ;; if alist is provided use that list. |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
267 (and imenu--index-alist |
9176
5646f9ac8ec3
(imenu--cleanup): Changed 'mapc' to 'mapcar'.
Richard M. Stallman <rms@gnu.org>
parents:
8408
diff
changeset
|
268 (mapcar |
8408
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
269 (function |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
270 (lambda (item) |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
271 (cond |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
272 ((markerp (cdr item)) |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
273 (set-marker (cdr item) nil)) |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
274 ((listp (cdr item)) |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
275 (imenu--cleanup (cdr item)))))) |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
276 (if alist alist imenu--index-alist)) |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
277 t)) |
6230 | 278 (defun imenu-default-create-index-function () |
279 "*Wrapper for index searching functions. | |
280 | |
281 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
|
282 `imenu-prev-index-position-function' and `imenu-extract-index-name-function'. |
6230 | 283 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
|
284 ;; 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
|
285 ;; in these major modes. But save that change for later. |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
286 (cond ((eq major-mode 'emacs-lisp-mode) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
287 (imenu-example--create-lisp-index)) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
288 ((eq major-mode 'lisp-mode) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
289 (imenu-example--create-lisp-index)) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
290 ((eq major-mode 'c++-mode) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
291 (imenu-example--create-c++-index)) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
292 ((eq major-mode 'c-mode) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
293 (imenu-example--create-c-index)) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
294 (t |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
295 (or (and (fboundp imenu-prev-index-position-function) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
296 (fboundp imenu-extract-index-name-function)) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
297 (error "The mode \"%s\" does not take full advantage of imenu.el yet." |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
298 mode-name)) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
299 (let ((index-alist '()) |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
300 name prev-pos) |
7350
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
301 (goto-char (point-max)) |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
302 (imenu-progress-message prev-pos 0 t) |
7350
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
303 ;; Search for the function |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
304 (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
|
305 (imenu-progress-message prev-pos nil t) |
7350
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
306 (save-excursion |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
307 (setq name (funcall imenu-extract-index-name-function))) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
308 (and (stringp name) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
309 (push (cons name (point)) index-alist))) |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
310 (imenu-progress-message prev-pos 100 t) |
7350
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
311 index-alist)))) |
6230 | 312 |
313 (defun imenu--replace-spaces (name replacement) | |
314 ;; Replace all spaces in NAME with REPLACEMENT. | |
315 ;; That second argument should be a string. | |
316 (mapconcat | |
317 (function | |
318 (lambda (ch) | |
319 (if (char-equal ch ?\ ) | |
320 replacement | |
321 (char-to-string ch)))) | |
322 name | |
323 "")) | |
324 | |
325 (defun imenu--flatten-index-alist (index-alist &optional concat-names prefix) | |
326 ;; Takes a nested INDEX-ALIST and returns a flat index alist. | |
327 ;; If optional CONCAT-NAMES is non-nil, then a nested index has its | |
328 ;; name and a space concatenated to the names of the children. | |
329 ;; Third argument PREFIX is for internal use only. | |
330 (mapcan | |
331 (function | |
332 (lambda (item) | |
333 (let* ((name (car item)) | |
334 (pos (cdr item)) | |
335 (new-prefix (and concat-names | |
336 (if prefix | |
337 (concat prefix imenu-level-separator name) | |
338 name)))) | |
339 (cond | |
8408
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
340 ((or (markerp pos) (numberp pos)) |
6230 | 341 (list (cons new-prefix pos))) |
342 (t | |
343 (imenu--flatten-index-alist pos new-prefix)))))) | |
344 index-alist)) | |
345 | |
346 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
347 ;;; | |
348 ;;; The main functions for this package! | |
349 ;;; | |
350 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
351 | |
352 (defun imenu--completion-buffer (index-alist &optional prompt) | |
353 "Let the user select from INDEX-ALIST in a completion buffer with PROMPT. | |
354 | |
355 Returns t for rescan and otherwise a position number." | |
356 ;; Create a list for this buffer only when needed. | |
357 (let (name choice | |
358 (prepared-index-alist | |
359 (mapcar | |
360 (function | |
361 (lambda (item) | |
362 (cons (imenu--replace-spaces (car item) imenu-space-replacement) | |
363 (cdr item)))) | |
364 index-alist))) | |
365 (save-window-excursion | |
366 ;; Display the completion buffer | |
367 (with-output-to-temp-buffer "*Completions*" | |
368 (display-completion-list | |
369 (all-completions "" prepared-index-alist ))) | |
7350
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
370 (let ((minibuffer-setup-hook |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
371 (function (lambda () |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
372 (let ((buffer (current-buffer))) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
373 (save-excursion |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
374 (set-buffer "*Completions*") |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
375 (setq completion-reference-buffer buffer))))))) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
376 ;; Make a completion question |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
377 (setq name (completing-read (or prompt "Index item: ") |
6230 | 378 prepared-index-alist |
7350
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
379 nil t nil 'imenu--history-list)))) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
380 (cond ((not (stringp name)) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
381 nil) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
382 ((string= name (car imenu--rescan-item)) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
383 t) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
384 (t |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
385 (setq choice (assoc name prepared-index-alist)) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
386 (if (listp (cdr choice)) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
387 (imenu--completion-buffer (cdr choice) prompt) |
542ab48d0f18
(imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents:
7319
diff
changeset
|
388 choice))))) |
7319
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
389 |
6230 | 390 (defun imenu--mouse-menu (index-alist event &optional title) |
391 "Let the user select from a buffer index from a mouse menu. | |
392 | |
393 INDEX-ALIST is the buffer index and EVENT is a mouse event. | |
394 | |
395 Returns t for rescan and otherwise a position number." | |
396 (let* ((menu (imenu--split-menu | |
397 (if imenu-sort-function | |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
398 (sort |
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
399 (let ((res nil) |
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
400 (oldlist index-alist)) |
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
401 ;; Copy list method from the cl package `copy-list' |
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
402 (while (consp oldlist) (push (pop oldlist) res)) |
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
403 (prog1 (nreverse res) (setcdr res oldlist))) |
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
404 imenu-sort-function) |
6230 | 405 index-alist) |
406 (or title (buffer-name)))) | |
407 position) | |
408 (setq position (x-popup-menu event menu)) | |
409 (cond | |
410 ((eq position nil) | |
411 position) | |
6241 | 412 ((listp position) |
6230 | 413 (imenu--mouse-menu position event |
414 (if title | |
415 (concat title imenu-level-separator | |
416 (car (rassq position index-alist))) | |
417 (car (rassq position index-alist))))) | |
418 ((= position (cdr imenu--rescan-item)) | |
419 t) | |
420 (t | |
421 (rassq position index-alist))))) | |
422 | |
6241 | 423 (defun imenu-choose-buffer-index (&optional prompt alist) |
6230 | 424 "Let the user select from a buffer index and return the chosen index. |
425 | |
426 If the user originally activated this function with the mouse, a mouse | |
427 menu is used. Otherwise a completion buffer is used and the user is | |
428 prompted with PROMPT. | |
429 | |
6241 | 430 If you call this function with index alist ALIST, then it lets the user |
431 select from ALIST. | |
432 | |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
433 With no index alist ALIST, it calls `imenu--make-index-alist' to |
6241 | 434 create the index alist. |
435 | |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
436 If `imenu-always-use-completion-buffer-p' is non-nil, then the |
6230 | 437 completion buffer is always used, no matter if the mouse was used or |
438 not. | |
439 | |
440 The returned value is on the form (INDEX-NAME . INDEX-POSITION)." | |
441 (let (index-alist | |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
442 (mouse-triggered (listp last-nonmenu-event)) |
6230 | 443 (result t) ) |
444 ;; If selected by mouse, see to that the window where the mouse is | |
445 ;; really is selected. | |
446 (and mouse-triggered | |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
447 (let ((window (posn-window (event-start last-nonmenu-event)))) |
6230 | 448 (or (framep window) (select-window window)))) |
449 ;; Create a list for this buffer only when needed. | |
450 (while (eq result t) | |
6241 | 451 (setq index-alist (if alist alist (imenu--make-index-alist))) |
6230 | 452 (setq result |
453 (if (and mouse-triggered | |
454 (not imenu-always-use-completion-buffer-p)) | |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
455 (imenu--mouse-menu index-alist last-nonmenu-event) |
6230 | 456 (imenu--completion-buffer index-alist prompt))) |
457 (and (eq result t) | |
8408
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
458 (imenu--cleanup) |
6230 | 459 (setq imenu--index-alist nil))) |
460 result)) | |
461 | |
8408
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
462 (defun imenu-add-to-menubar (name) |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
463 "Adds an \"imenu\" entry to the menubar for the |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
464 current local keymap. |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
465 NAME is the string naming the menu to be added. |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
466 See 'imenu' for more information." |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
467 (interactive "sMenu name: ") |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
468 (and window-system |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
469 (define-key (current-local-map) [menu-bar index] |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
470 (cons name 'imenu)))) |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
471 |
7319
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
472 ;;;###autoload |
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
473 (defun imenu () |
cd73ba498964
(imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents:
6909
diff
changeset
|
474 "Jump to a place in the buffer chosen using a buffer menu or mouse menu. |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
475 See `imenu-choose-buffer-index' for more information." |
6230 | 476 (interactive) |
477 (let ((index-item (imenu-choose-buffer-index))) | |
478 (and index-item | |
479 (progn | |
480 (push-mark) | |
8408
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
481 (cond |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
482 ((markerp (cdr index-item)) |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
483 (goto-char (marker-position (cdr index-item)))) |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
484 (t |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
485 (goto-char (cdr index-item)))))))) |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
486 |
6230 | 487 |
488 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
489 ;;;; | |
490 ;;;; Some examples of functions utilizing the framework of this | |
491 ;;;; package. | |
492 ;;;; | |
493 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
494 | |
8256 | 495 ;; Return the current/previous sexp and the location of the sexp (its |
6230 | 496 ;; beginning) without moving the point. |
497 (defun imenu-example--name-and-position () | |
498 (save-excursion | |
499 (forward-sexp -1) | |
500 (let ((beg (point)) | |
8408
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
501 (end (progn (forward-sexp) (point))) |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
502 (marker (make-marker))) |
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
503 (set-marker marker beg) |
6230 | 504 (cons (buffer-substring beg end) |
8408
109166e311ce
(imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents:
8296
diff
changeset
|
505 marker)))) |
6230 | 506 |
507 ;;; | |
508 ;;; Lisp | |
509 ;;; | |
510 | |
511 (defun imenu-example--lisp-extract-index-name () | |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
512 ;; Example of a candidate for `imenu-extract-index-name-function'. |
6230 | 513 ;; This will generate a flat index of definitions in a lisp file. |
514 (save-match-data | |
515 (and (looking-at "(def") | |
516 (condition-case nil | |
517 (progn | |
518 (down-list 1) | |
519 (forward-sexp 2) | |
520 (let ((beg (point)) | |
521 (end (progn (forward-sexp -1) (point)))) | |
522 (buffer-substring beg end))) | |
523 (error nil))))) | |
524 | |
525 (defun imenu-example--create-lisp-index () | |
6909
9e59751db725
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
6241
diff
changeset
|
526 ;; Example of a candidate for `imenu-create-index-function'. |
6230 | 527 ;; It will generate a nested index of definitions. |
528 (let ((index-alist '()) | |
529 (index-var-alist '()) | |
6241 | 530 (index-type-alist '()) |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
531 (index-unknown-alist '()) |
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
532 prev-pos) |
6230 | 533 (goto-char (point-max)) |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
534 (imenu-progress-message prev-pos 0) |
6230 | 535 ;; Search for the function |
536 (while (beginning-of-defun) | |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
537 (imenu-progress-message prev-pos nil t) |
6230 | 538 (save-match-data |
539 (and (looking-at "(def") | |
540 (save-excursion | |
541 (down-list 1) | |
542 (cond | |
543 ((looking-at "def\\(var\\|const\\)") | |
544 (forward-sexp 2) | |
545 (push (imenu-example--name-and-position) | |
546 index-var-alist)) | |
547 ((looking-at "def\\(un\\|subst\\|macro\\|advice\\)") | |
548 (forward-sexp 2) | |
549 (push (imenu-example--name-and-position) | |
550 index-alist)) | |
6241 | 551 ((looking-at "def\\(type\\|struct\\|class\\|ine-condition\\)") |
552 (forward-sexp 2) | |
553 (if (= (char-after (1- (point))) ?\)) | |
554 (progn | |
555 (forward-sexp -1) | |
556 (down-list 1) | |
557 (forward-sexp 1))) | |
558 (push (imenu-example--name-and-position) | |
559 index-type-alist)) | |
6230 | 560 (t |
561 (forward-sexp 2) | |
562 (push (imenu-example--name-and-position) | |
563 index-unknown-alist))))))) | |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
564 (imenu-progress-message prev-pos 100) |
6230 | 565 (and index-var-alist |
566 (push (cons (imenu-create-submenu-name "Variables") index-var-alist) | |
567 index-alist)) | |
6241 | 568 (and index-type-alist |
569 (push (cons (imenu-create-submenu-name "Types") index-type-alist) | |
570 index-alist)) | |
6230 | 571 (and index-unknown-alist |
572 (push (cons (imenu-create-submenu-name "Syntax-unknown") index-unknown-alist) | |
573 index-alist)) | |
574 index-alist)) | |
575 | |
576 | |
577 ;;; | |
578 ;;; C | |
579 ;;; | |
580 ;; Regular expression to find C functions | |
581 (defvar imenu-example--function-name-regexp-c | |
582 (concat | |
583 "^[a-zA-Z0-9]+[ \t]?" ; type specs; there can be no | |
584 "\\([a-zA-Z0-9_*]+[ \t]+\\)?" ; more than 3 tokens, right? | |
585 "\\([a-zA-Z0-9_*]+[ \t]+\\)?" | |
586 "\\([*&]+[ \t]*\\)?" ; pointer | |
587 "\\([a-zA-Z0-9_*]+\\)[ \t]*(" ; name | |
588 )) | |
589 | |
590 (defun imenu-example--create-c-index (&optional regexp) | |
591 (let ((index-alist '()) | |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
592 prev-pos char) |
6230 | 593 (goto-char (point-min)) |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
594 (imenu-progress-message prev-pos 0) |
6230 | 595 ;; Search for the function |
596 (save-match-data | |
597 (while (re-search-forward | |
598 (or regexp imenu-example--function-name-regexp-c) | |
599 nil t) | |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
600 (imenu-progress-message prev-pos) |
6230 | 601 (backward-up-list 1) |
602 (save-excursion | |
603 (goto-char (scan-sexps (point) 1)) | |
604 (setq char (following-char))) | |
605 ;; Skip this function name if it is a prototype declaration. | |
606 (if (not (eq char ?\;)) | |
607 (push (imenu-example--name-and-position) index-alist)))) | |
8296
b2b493c007ff
(imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents:
8256
diff
changeset
|
608 (imenu-progress-message prev-pos 100) |
6230 | 609 (nreverse index-alist))) |
610 | |
611 ;;; | |
612 ;;; C++ | |
613 ;;; | |
614 ;; Regular expression to find C++ functions | |
615 (defvar imenu-example--function-name-regexp-c++ | |
616 (concat | |
617 "^[a-zA-Z0-9:]+[ \t]?" ; type specs; there can be no | |
618 "\\([a-zA-Z0-9_:~*]+[ \t]+\\)?" ; more than 3 tokens, right? | |
619 "\\([a-zA-Z0-9_:~*]+[ \t]+\\)?" | |
620 "\\([*&]+[ \t]*\\)?" ; pointer | |
621 "\\([a-zA-Z0-9_:*]+\\)[ \t]*(" ; name | |
622 )) | |
623 (defun imenu-example--create-c++-index () | |
624 (imenu-example--create-c-index imenu-example--function-name-regexp-c++)) | |
625 | |
626 (provide 'imenu) | |
627 | |
628 ;;; imenu.el ends here |