annotate lisp/imenu.el @ 18498:78a8721a690c

(forward-visible-line): Handle 0 arg correctly.
author Richard M. Stallman <rms@gnu.org>
date Sun, 29 Jun 1997 21:36:37 +0000
parents 720d1f98ae42
children 68621d697ee2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; imenu.el --- Framework for mode-specific buffer indexes.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
17230
1c853c91aaf0 Update copyright year.
Richard M. Stallman <rms@gnu.org>
parents: 17229
diff changeset
3 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Ake Stenhoff <etxaksf@aom.ericsson.se>
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Lars Lindberg <lli@sypro.cap.se>
17970
720d1f98ae42 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17677
diff changeset
7 ;; Maintainer: FSF
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; Created: 8 Feb 1994
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; Keywords: tools
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
10
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
11 ;; This file is part of GNU Emacs.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
12
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; any later version.
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
17
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; GNU General Public License for more details.
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
22
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
26 ;; Boston, MA 02111-1307, USA.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;;; Commentary:
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
29
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; Purpose of this package:
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; To present a framework for mode-specific buffer indexes.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; A buffer index is an alist of names and buffer positions.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; For instance all functions in a C-file and their positions.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; How it works:
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; A mode-specific function is called to generate the index. It is
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; then presented to the user, who can choose from this index.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; The package comes with a set of example functions for how to
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; utilize this package.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
43 ;; 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
44 ;; 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
45 ;; 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
46 ;; index position is also supplied.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
6241
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
48 ;;; Thanks goes to
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
49 ;; [simon] - Simon Leinen simon@lia.di.epfl.ch
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
50 ;; [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
51 ;; [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
52 ;; [greg] - Greg Thompson gregt@porsche.visix.COM
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
53 ;; [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
54 ;; [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
55 ;; [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
56 ;; [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
57 ;; [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
58
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;;; Code
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14139
diff changeset
60
6909
9e59751db725 Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents: 6241
diff changeset
61 (eval-when-compile (require 'cl))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;;; Customizable variables
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
68
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
69 (defgroup imenu nil
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
70 "Mode-specific buffer indexes."
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
71 :group 'matching
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
72 :group 'frames)
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
73
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
74 (defcustom imenu-use-markers t
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
75 "*Non-nil means use markers instead of integers for Imenu buffer positions.
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
76 Setting this to nil makes Imenu work faster.
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
77
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
78 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
79 :type 'boolean
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
80 :group 'imenu)
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
81
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
82
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
83 (defcustom imenu-max-item-length 60
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
84 "*If a number, truncate Imenu entries to that length."
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
85 :type 'integer
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
86 :group 'imenu)
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
87
17677
3ab08563e855 (imenu-auto-rescan): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents: 17634
diff changeset
88 (defcustom imenu-auto-rescan nil
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
89 "*Non-nil means Imenu should always rescan the buffers."
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
90 :type 'boolean
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
91 :group 'imenu)
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
92
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
93 (defcustom imenu-auto-rescan-maxout 60000
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
94 "*Imenu auto-rescan is disabled in buffers larger than this size.
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
95 This variable is buffer-local."
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
96 :type 'integer
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
97 :group 'imenu)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
99 (defcustom imenu-always-use-completion-buffer-p nil
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 "*Set this to non-nil for displaying the index in a completion buffer.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
102 `never' means never automatically display a listing of any kind.
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
103 A value of nil (the default) means display the index as a mouse menu
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
104 if the mouse was used to invoke `imenu'.
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
105 Another non-nil value means always display the index in a completion buffer."
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
106 :type '(choice (const :tag "On Mouse" nil)
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
107 (const :tag "Never" never)
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
108 (sexp :tag "Always" :format "%t\n" t))
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
109 :group 'imenu)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
111 (defcustom imenu-sort-function nil
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 "*The function to use for sorting the index mouse-menu.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 Affects only the mouse index menu.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 Set this to nil if you don't want any sorting (faster).
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 The items in the menu are then presented in the order they were found
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 in the buffer.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119
6909
9e59751db725 Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents: 6241
diff changeset
120 Set it to `imenu--sort-by-name' if you want alphabetic sorting.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 The function should take two arguments and return T if the first
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 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
124 \(NAME . POSITION). Look at `imenu--sort-by-name' for an example."
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
125 :type 'function
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
126 :group 'imenu)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
128 (defcustom imenu-max-items 25
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
129 "*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
130 :type 'integer
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
131 :group 'imenu)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
133 (defcustom imenu-scanning-message "Scanning buffer for index (%3d%%)"
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 "*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
135 If non-nil, user gets a message during the scanning of the buffer.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 Relevant only if the mode-specific function that creates the buffer
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
138 index use `imenu-progress-message'."
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
139 :type 'string
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
140 :group 'imenu)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
142 (defcustom imenu-space-replacement "^"
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 "*The replacement string for spaces in index names.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 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
145 names work as tokens."
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
146 :type 'string
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
147 :group 'imenu)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148
17634
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
149 (defcustom imenu-level-separator ":"
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 "*The separator between index names of different levels.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 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
152 with name concatenation."
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
153 :type 'string
247c2a11843d Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17307
diff changeset
154 :group 'imenu)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
156 ;;;###autoload
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
157 (defvar imenu-generic-expression nil
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
158 "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
159
16698
13920eac02e0 (imenu-generic-expression): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16612
diff changeset
160 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
161 to create a buffer index.
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
162
16271
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
163 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
164 (MENU-TITLE REGEXP INDEX)
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
165 or like this:
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
166 (MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...)
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
167 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
168 the index alist when it matches; the latter creates a special element
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
169 of the form (NAME FUNCTION NAME POSITION-MARKER ARGUMENTS...)
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
170 with FUNCTION and ARGUMENTS beiong copied from `imenu-generic-expression'.
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
171
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
172 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
173 entries are not nested.
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
174
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
175 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
176 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
177 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
178 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
179
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
180 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
181 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
182
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
183 For emacs-lisp-mode for example PATTERN would look like:
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
184
13645
9681c6008417 (imenu-generic-expression, imenu--generic-function): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12707
diff changeset
185 '((nil \"^\\\\s-*(def\\\\(un\\\\|subst\\\\|macro\\\\|advice\\\\)\\\\s-+\\\\([-A-Za-z0-9+]+\\\\)\" 2)
9681c6008417 (imenu-generic-expression, imenu--generic-function): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12707
diff changeset
186 (\"*Vars*\" \"^\\\\s-*(def\\\\(var\\\\|const\\\\)\\\\s-+\\\\([-A-Za-z0-9+]+\\\\)\" 2)
9681c6008417 (imenu-generic-expression, imenu--generic-function): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12707
diff changeset
187 (\"*Types*\" \"^\\\\s-*(def\\\\(type\\\\|struct\\\\|class\\\\|ine-condition\\\\)\\\\s-+\\\\([-A-Za-z0-9+]+\\\\)\" 2))
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
188
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
189 The variable is buffer-local.")
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
190
14816
485422b900d3 (imenu-generic-expression): Autoload the make-variable-buffer-local call.
Richard M. Stallman <rms@gnu.org>
parents: 14798
diff changeset
191 ;;;###autoload
12664
ce1cae301efe (imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents: 12635
diff changeset
192 (make-variable-buffer-local 'imenu-generic-expression)
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
193
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 ;;;; Hooks
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 (defvar imenu-create-index-function 'imenu-default-create-index-function
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 "The function to use for creating a buffer index.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 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
200 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
201
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
202 Simple elements in the alist look like (INDEX-NAME . INDEX-POSITION).
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
203 Special elements look like (INDEX-NAME FUNCTION ARGUMENTS...).
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
204 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
205 The function `imenu--subalist-p' tests an element and returns t
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
206 if it is a sub-alist.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207
6909
9e59751db725 Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents: 6241
diff changeset
208 This function is called within a `save-excursion'.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 The variable is buffer-local.")
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 (make-variable-buffer-local 'imenu-create-index-function)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212
7319
cd73ba498964 (imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents: 6909
diff changeset
213 (defvar imenu-prev-index-position-function 'beginning-of-defun
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 "Function for finding the next index position.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215
6909
9e59751db725 Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents: 6241
diff changeset
216 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
217 `imenu-default-create-index-function', then you must set this variable
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 to a function that will find the next index, looking backwards in the
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 file.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 The function should leave point at the place to be connected to the
12664
ce1cae301efe (imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents: 12635
diff changeset
222 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
223 (make-variable-buffer-local 'imenu-prev-index-position-function)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224
7319
cd73ba498964 (imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents: 6909
diff changeset
225 (defvar imenu-extract-index-name-function nil
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 "Function for extracting the index name.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 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
229 `imenu-prev-index-position-function'.")
cd73ba498964 (imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents: 6909
diff changeset
230 (make-variable-buffer-local 'imenu-extract-index-name-function)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231
17229
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
232 (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
233 "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
234 The function in this variable is called when selecting a normal index-item.")
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
235 (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
236
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
237
16271
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
238 (defun imenu--subalist-p (item)
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
239 (and (consp (cdr item)) (listp (cadr item))
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
240 (not (eq (caadr item) 'lambda))))
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
241
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
242 ;;;
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
243 ;;; Macro to display a progress message.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
244 ;;; RELPOS is the relative position to display.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
245 ;;; If RELPOS is nil, then the relative position in the buffer
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
246 ;;; is calculated.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
247 ;;; PREVPOS is the variable in which we store the last position displayed.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
248 (defmacro imenu-progress-message (prevpos &optional relpos reverse)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
249 (` (and
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
250 imenu-scanning-message
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
251 (let ((pos (, (if relpos
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
252 relpos
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
253 (` (imenu--relative-position (, reverse)))))))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
254 (if (, (if relpos t
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
255 (` (> pos (+ 5 (, prevpos))))))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
256 (progn
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
257 (message imenu-scanning-message pos)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
258 (setq (, prevpos) pos)))))))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
259
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
260
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
261 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
262 ;;;;
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
263 ;;;; Some examples of functions utilizing the framework of this
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
264 ;;;; package.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
265 ;;;;
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
266 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
267
12707
06608e9272b5 (imenu-generic-lisp-expression)
Karl Heuer <kwzh@gnu.org>
parents: 12664
diff changeset
268 ;; 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
269 ;; beginning) without moving the point.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
270 (defun imenu-example--name-and-position ()
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
271 (save-excursion
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
272 (forward-sexp -1)
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
273 ;; [ydi] modified for imenu-use-markers
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
274 (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
275 (end (progn (forward-sexp) (point))))
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
276 (cons (buffer-substring beg end)
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
277 beg))))
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
278
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
279 ;;;
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
280 ;;; Lisp
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
281 ;;;
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
282
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
283 (defun imenu-example--lisp-extract-index-name ()
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
284 ;; 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
285 ;; 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
286 (save-match-data
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
287 (and (looking-at "(def")
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
288 (condition-case nil
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
289 (progn
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
290 (down-list 1)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
291 (forward-sexp 2)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
292 (let ((beg (point))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
293 (end (progn (forward-sexp -1) (point))))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
294 (buffer-substring beg end)))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
295 (error nil)))))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
296
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
297 (defun imenu-example--create-lisp-index ()
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
298 ;; Example of a candidate for `imenu-create-index-function'.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
299 ;; It will generate a nested index of definitions.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
300 (let ((index-alist '())
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
301 (index-var-alist '())
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
302 (index-type-alist '())
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
303 (index-unknown-alist '())
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
304 prev-pos)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
305 (goto-char (point-max))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
306 (imenu-progress-message prev-pos 0)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
307 ;; Search for the function
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
308 (while (beginning-of-defun)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
309 (imenu-progress-message prev-pos nil t)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
310 (save-match-data
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
311 (and (looking-at "(def")
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
312 (save-excursion
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
313 (down-list 1)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
314 (cond
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
315 ((looking-at "def\\(var\\|const\\)")
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
316 (forward-sexp 2)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
317 (push (imenu-example--name-and-position)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
318 index-var-alist))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
319 ((looking-at "def\\(un\\|subst\\|macro\\|advice\\)")
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
320 (forward-sexp 2)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
321 (push (imenu-example--name-and-position)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
322 index-alist))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
323 ((looking-at "def\\(type\\|struct\\|class\\|ine-condition\\)")
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
324 (forward-sexp 2)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
325 (if (= (char-after (1- (point))) ?\))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
326 (progn
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
327 (forward-sexp -1)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
328 (down-list 1)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
329 (forward-sexp 1)))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
330 (push (imenu-example--name-and-position)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
331 index-type-alist))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
332 (t
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
333 (forward-sexp 2)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
334 (push (imenu-example--name-and-position)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
335 index-unknown-alist)))))))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
336 (imenu-progress-message prev-pos 100)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
337 (and index-var-alist
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
338 (push (cons "Variables" index-var-alist)
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
339 index-alist))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
340 (and index-type-alist
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
341 (push (cons "Types" index-type-alist)
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
342 index-alist))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
343 (and index-unknown-alist
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
344 (push (cons "Syntax-unknown" index-unknown-alist)
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
345 index-alist))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
346 index-alist))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
347
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
348 ;; Regular expression to find C functions
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
349 (defvar imenu-example--function-name-regexp-c
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
350 (concat
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
351 "^[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
352 "\\([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
353 "\\([a-zA-Z0-9_*]+[ \t]+\\)?"
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
354 "\\([*&]+[ \t]*\\)?" ; pointer
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
355 "\\([a-zA-Z0-9_*]+\\)[ \t]*(" ; name
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
356 ))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
357
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
358 (defun imenu-example--create-c-index (&optional regexp)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
359 (let ((index-alist '())
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
360 prev-pos char)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
361 (goto-char (point-min))
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 (save-match-data
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
365 (while (re-search-forward
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
366 (or regexp imenu-example--function-name-regexp-c)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
367 nil t)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
368 (imenu-progress-message prev-pos)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
369 (backward-up-list 1)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
370 (save-excursion
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
371 (goto-char (scan-sexps (point) 1))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
372 (setq char (following-char)))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
373 ;; 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
374 (if (not (eq char ?\;))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
375 (push (imenu-example--name-and-position) index-alist))))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
376 (imenu-progress-message prev-pos 100)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
377 (nreverse index-alist)))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
378
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
379
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 ;;; Internal variables
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 ;; The item to use in the index for rescanning the buffer.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (defconst imenu--rescan-item '("*Rescan*" . -99))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 ;; The latest buffer index.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 ;; Buffer local.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 (defvar imenu--index-alist nil)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 (make-variable-buffer-local 'imenu--index-alist)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
394 ;; The latest buffer index used to update the menu bar menu.
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
395 (defvar imenu--last-menubar-index-alist nil)
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
396 (make-variable-buffer-local 'imenu--last-menubar-index-alist)
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
397
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 ;; 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
399 ;; Making this buffer local caused it not to work!
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 (defvar imenu--history-list nil)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 ;;; Internal support functions
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 ;;; Sort function
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 ;;; Sorts the items depending on their index name.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 ;;; An item look like (NAME . POSITION).
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 (defun imenu--sort-by-name (item1 item2)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (string-lessp (car item1) (car item2)))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (defun imenu--relative-position (&optional reverse)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 ;; Support function to calculate relative position in buffer
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 ;; Beginning of buffer is 0 and end of buffer is 100
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 ;; If REVERSE is non-nil then the beginning is 100 and the end is 0.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (let ((pos (point))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (total (buffer-size)))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (and reverse (setq pos (- total pos)))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (if (> total 50000)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 ;; Avoid overflow from multiplying by 100!
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (/ (1- pos) (max (/ total 100) 1))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (/ (* 100 (1- pos)) (max total 1)))))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 ;; Split LIST into sublists of max length N.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 ;; Example (imenu--split '(1 2 3 4 5 6 7 8) 3)-> '((1 2 3) (4 5 6) (7 8))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (defun imenu--split (list n)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 (let ((remain list)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (result '())
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (sublist '())
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (i 0))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 (while remain
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 (push (pop remain) sublist)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 (incf i)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (and (= i n)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 ;; We have finished a sublist
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 (progn (push (nreverse sublist) result)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 (setq i 0)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 (setq sublist '()))))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 ;; There might be a sublist (if the length of LIST mod n is != 0)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 ;; that has to be added to the result list.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 (and sublist
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (push (nreverse sublist) result))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 (nreverse result)))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
449 ;;; 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
450 ;;; In any case, add TITLE to the front of the alist.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 (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
452 (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
453 (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
454 (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
455 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
456 (setq tail menulist)
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
457 (while tail
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
458 (if (imenu--subalist-p (car tail))
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
459 (setq keep-at-top (cons (car tail) keep-at-top)
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
460 menulist (delq (car tail) menulist)))
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
461 (setq tail (cdr tail)))
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
462 (if imenu-sort-function
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
463 (setq menulist
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
464 (sort
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
465 (let ((res nil)
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
466 (oldlist menulist))
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
467 ;; Copy list method from the cl package `copy-list'
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
468 (while (consp oldlist) (push (pop oldlist) res))
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
469 (prog1 (nreverse res) (setcdr res oldlist)))
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
470 imenu-sort-function)))
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
471 (if (> (length menulist) imenu-max-items)
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
472 (let ((count 0))
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
473 (setq menulist
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
474 (mapcar
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
475 (function
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
476 (lambda (menu)
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
477 (cons (format "From: %s" (caar menu)) menu)))
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
478 (imenu--split menulist imenu-max-items)))))
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
479 (cons title
b64d00e44e7b (imenu--split-menu): Keep the rescan item at top level.
Richard M. Stallman <rms@gnu.org>
parents: 16271
diff changeset
480 (nconc (nreverse keep-at-top) menulist))))
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
481
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
482 ;;; 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
483 ;;; into nested alists.
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
484 (defun imenu--split-submenus (alist)
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
485 (mapcar (function (lambda (elt)
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
486 (if (and (consp elt)
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
487 (stringp (car elt))
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
488 (listp (cdr elt)))
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
489 (imenu--split-menu (cdr elt) (car elt))
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
490 elt)))
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
491 alist))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
493 ;;; 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
494 (defun imenu--truncate-items (menulist)
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
495 (mapcar (function
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
496 (lambda (item)
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
497 (cond
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
498 ((consp (cdr item))
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
499 (imenu--truncate-items (cdr item)))
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
500 (t
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
501 ;; truncate if necessary
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
502 (if (and (numberp imenu-max-item-length)
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
503 (> (length (car item)) imenu-max-item-length))
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
504 (setcar item (substring (car item) 0 imenu-max-item-length)))))))
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
505 menulist))
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
506
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
507
16369
187e7c8aaff5 (imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents: 16315
diff changeset
508 (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
509 "Create an index-alist for the definitions in the current buffer.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510
16369
187e7c8aaff5 (imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents: 16315
diff changeset
511 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
512 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
513 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
514 The function `imenu--subalist-p' tests an element and returns t
187e7c8aaff5 (imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents: 16315
diff changeset
515 if it is a sub-alist.
187e7c8aaff5 (imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents: 16315
diff changeset
516
187e7c8aaff5 (imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents: 16315
diff changeset
517 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
518 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
519 (or (and imenu--index-alist
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
520 (or (not imenu-auto-rescan)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
521 (and imenu-auto-rescan
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
522 (> (buffer-size) imenu-auto-rescan-maxout))))
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
523 ;; Get the index; truncate if necessary
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
524 (progn
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
525 (setq imenu--index-alist
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
526 (save-excursion
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
527 (save-restriction
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
528 (widen)
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
529 (funcall imenu-create-index-function))))
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
530 (imenu--truncate-items imenu--index-alist)))
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
531 (or imenu--index-alist noerror
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
532 (error "No items suitable for an index found in this buffer"))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 (or imenu--index-alist
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
534 (setq imenu--index-alist (list nil)))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 ;; Add a rescan option to the index.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 (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
537
8408
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
538 ;;; 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
539 ;;; them point nowhere.
16315
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
540 ;;; 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
541 ;;; non-nil arguments are in recursivecalls.
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
542 (defvar imenu--cleanup-seen)
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
543
8408
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
544 (defun imenu--cleanup (&optional alist)
16315
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
545 ;; If alist is provided use that list.
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
546 ;; 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
547 ;; and use imenu--index-alist.
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
548 (if alist
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
549 (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
550 (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
551
10795
8cbc8846b19b (imenu--cleanup): Set alist to its default just once, at the beginning.
Richard M. Stallman <rms@gnu.org>
parents: 10221
diff changeset
552 (and alist
9176
5646f9ac8ec3 (imenu--cleanup): Changed 'mapc' to 'mapcar'.
Richard M. Stallman <rms@gnu.org>
parents: 8408
diff changeset
553 (mapcar
8408
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
554 (function
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
555 (lambda (item)
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
556 (cond
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
557 ((markerp (cdr item))
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
558 (set-marker (cdr item) nil))
16315
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
559 ;; Don't process one alist twice.
cca1c6324cab (imenu--cleanup): Handle shared structure in alist.
Richard M. Stallman <rms@gnu.org>
parents: 16272
diff changeset
560 ((memq (cdr item) imenu--cleanup-seen))
16271
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
561 ((imenu--subalist-p item)
8408
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
562 (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
563 alist)
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
564 t))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
565
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
566 (defun imenu--create-keymap-2 (alist counter &optional commands)
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
567 (let ((map nil))
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
568 (mapcar
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
569 (function
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
570 (lambda (item)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
571 (cond
16271
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
572 ((imenu--subalist-p item)
14114
b8c7c891ed63 (imenu--create-keymap-2): Fix bug in constructing
Karl Heuer <kwzh@gnu.org>
parents: 14040
diff changeset
573 (append (list (setq counter (1+ counter))
b8c7c891ed63 (imenu--create-keymap-2): Fix bug in constructing
Karl Heuer <kwzh@gnu.org>
parents: 14040
diff changeset
574 (car item) 'keymap (car item))
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
575 (imenu--create-keymap-2 (cdr item) (+ counter 10) commands)))
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
576 (t
14114
b8c7c891ed63 (imenu--create-keymap-2): Fix bug in constructing
Karl Heuer <kwzh@gnu.org>
parents: 14040
diff changeset
577 (let ((end (if commands `(lambda () (interactive)
b8c7c891ed63 (imenu--create-keymap-2): Fix bug in constructing
Karl Heuer <kwzh@gnu.org>
parents: 14040
diff changeset
578 (imenu--menubar-select ',item))
16148
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
579 (cons '(nil) item))))
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
580 (cons (car item)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
581 (cons (car item) end))))
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
582 )))
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
583 alist)))
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
584
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
585 ;; If COMMANDS is non-nil, make a real keymap
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
586 ;; with a real command used as the definition.
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
587 ;; If it is nil, make something suitable for x-popup-menu.
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
588 (defun imenu--create-keymap-1 (title alist &optional commands)
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
589 (append (list 'keymap title) (imenu--create-keymap-2 alist 0 commands)))
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
590
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
591
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
592 (defun imenu--in-alist (str alist)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
593 "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
594 (let (elt head tail res)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
595 (setq res nil)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
596 (while alist
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
597 (setq elt (car alist)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
598 tail (cdr elt)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
599 alist (cdr alist)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
600 head (car elt))
15929
955269257adf (imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents: 15831
diff changeset
601 ;; 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
602 ;; (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
603 ;; 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
604 ;; (INDEX-NAME . INDEX-POSITION)
955269257adf (imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents: 15831
diff changeset
605 ;; 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
606 ;; 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
607 (cond ((listp tail)
955269257adf (imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents: 15831
diff changeset
608 (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
609 (setq alist nil)))
955269257adf (imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents: 15831
diff changeset
610 ((string= str head)
955269257adf (imenu--in-alist): Accept only bottom-level matches.
Richard M. Stallman <rms@gnu.org>
parents: 15831
diff changeset
611 (setq alist nil res elt))))
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
612 res))
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
613
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 (defun imenu-default-create-index-function ()
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 "*Wrapper for index searching functions.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 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
618 `imenu-prev-index-position-function' and `imenu-extract-index-name-function'.
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 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
620 ;; 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
621 ;; in these major modes. But save that change for later.
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
622 (cond ((and (fboundp imenu-prev-index-position-function)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
623 (fboundp imenu-extract-index-name-function))
7350
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
624 (let ((index-alist '())
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
625 prev-pos name)
7350
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
626 (goto-char (point-max))
8296
b2b493c007ff (imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents: 8256
diff changeset
627 (imenu-progress-message prev-pos 0 t)
7350
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
628 ;; Search for the function
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
629 (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
630 (imenu-progress-message prev-pos nil t)
7350
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
631 (save-excursion
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
632 (setq name (funcall imenu-extract-index-name-function)))
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
633 (and (stringp name)
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
634 ;; [ydi] updated for imenu-use-markers
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
635 (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
636 index-alist)))
8296
b2b493c007ff (imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents: 8256
diff changeset
637 (imenu-progress-message prev-pos 100 t)
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
638 index-alist))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
639 ;; Use generic expression if possible.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
640 ((and imenu-generic-expression)
12707
06608e9272b5 (imenu-generic-lisp-expression)
Karl Heuer <kwzh@gnu.org>
parents: 12664
diff changeset
641 (imenu--generic-function imenu-generic-expression))
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
642 (t
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
643 (error "This buffer cannot use `imenu-default-create-index-function'"))))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 (defun imenu--replace-spaces (name replacement)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 ;; Replace all spaces in NAME with REPLACEMENT.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 ;; That second argument should be a string.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 (mapconcat
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 (function
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 (lambda (ch)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 (if (char-equal ch ?\ )
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 replacement
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 (char-to-string ch))))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 name
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 ""))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 (defun imenu--flatten-index-alist (index-alist &optional concat-names prefix)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 ;; Takes a nested INDEX-ALIST and returns a flat index alist.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 ;; If optional CONCAT-NAMES is non-nil, then a nested index has its
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 ;; name and a space concatenated to the names of the children.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 ;; Third argument PREFIX is for internal use only.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 (mapcan
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 (function
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 (lambda (item)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 (let* ((name (car item))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 (pos (cdr item))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 (new-prefix (and concat-names
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 (if prefix
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 (concat prefix imenu-level-separator name)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 name))))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 (cond
8408
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
672 ((or (markerp pos) (numberp pos))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 (list (cons new-prefix pos)))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 (t
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 (imenu--flatten-index-alist pos new-prefix))))))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 index-alist))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
678 ;;;
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
679 ;;; Generic index gathering function.
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
680 ;;;
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
681
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
682 (defun imenu--generic-function (patterns)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
683 ;; Built on some ideas that Erik Naggum <erik@naggum.no> once posted
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
684 ;; to comp.emacs
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
685 "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
686
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
687 PATTERN is an alist with elements that look like this: (MENU-TITLE
12664
ce1cae301efe (imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents: 12635
diff changeset
688 REGEXP INDEX).
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
689
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
690 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
691 entries are not nested.
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
692
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
693 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
694 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
695 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
696 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
697
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
698 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
699 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
700
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
701 For emacs-lisp-mode for example PATTERN would look like:
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
702
13645
9681c6008417 (imenu-generic-expression, imenu--generic-function): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12707
diff changeset
703 '((nil \"^\\\\s-*(def\\\\(un\\\\|subst\\\\|macro\\\\|advice\\\\)\\\\s-+\\\\([-A-Za-z0-9]+\\\\)\" 2)
9681c6008417 (imenu-generic-expression, imenu--generic-function): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12707
diff changeset
704 (\"*Vars*\" \"^\\\\s-*(def\\\\(var\\\\|const\\\\)\\\\s-+\\\\([-A-Za-z0-9]+\\\\)\" 2)
9681c6008417 (imenu-generic-expression, imenu--generic-function): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12707
diff changeset
705 (\"*Types*\" \"^\\\\s-*(def\\\\(type\\\\|struct\\\\|class\\\\|ine-condition\\\\)\\\\s-+\\\\([-A-Za-z0-9]+\\\\)\" 2))'
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
706
12664
ce1cae301efe (imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents: 12635
diff changeset
707 Returns an index of the current buffer as an alist. The elements in
ce1cae301efe (imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents: 12635
diff changeset
708 the alist look like: (INDEX-NAME . INDEX-POSITION). They may also be
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
709 nested index lists like (INDEX-NAME . INDEX-ALIST) depending on
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
710 pattern.
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
711
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
712 \(imenu--generic-function PATTERN\)."
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
713
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
714 (let ((index-alist (list 'dummy))
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
715 (found nil)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
716 (global-regexp
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
717 (concat "\\("
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
718 (mapconcat
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
719 (function (lambda (pattern) (identity (cadr pattern))))
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
720 patterns "\\)\\|\\(")
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
721 "\\)"))
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
722 prev-pos)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
723
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
724 (goto-char (point-max))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
725 (imenu-progress-message prev-pos 0 t)
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
726 (save-match-data
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
727 (while (re-search-backward global-regexp nil t)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
728 (imenu-progress-message prev-pos nil t)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
729 (setq found nil)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
730 (save-excursion
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
731 (goto-char (match-beginning 0))
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
732 (mapcar
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
733 (function
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
734 (lambda (pat)
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
735 (let ((menu-title (car pat))
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
736 (regexp (cadr pat))
16271
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
737 (index (caddr pat))
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
738 (function (cadddr pat))
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
739 (rest (cddddr pat)))
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
740 (if (and (not found) ; Only allow one entry;
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
741 (looking-at regexp))
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
742 (let ((beg (match-beginning index))
16271
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
743 (end (match-end index)))
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
744 (setq found t)
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
745 (push
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
746 (let ((name
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
747 (buffer-substring-no-properties beg end)))
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
748 ;; [ydi] updated for imenu-use-markers
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
749 (if imenu-use-markers
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
750 (setq beg (set-marker (make-marker) beg)))
16271
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
751 (if function
17229
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
752 (nconc (list name beg function)
16271
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
753 rest)
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
754 (cons name beg)))
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
755 (cdr
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
756 (or (assoc menu-title index-alist)
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
757 (car (push
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
758 (cons menu-title '())
00bece0cd6c2 (imenu--generic-function): Create a special entry
Richard M. Stallman <rms@gnu.org>
parents: 16244
diff changeset
759 index-alist))))))))))
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
760 patterns))))
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
761 (imenu-progress-message prev-pos 100 t)
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
762 (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
763 (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
764 (cdr main-element)))))
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
765
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 ;;; The main functions for this package!
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 ;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 (defun imenu--completion-buffer (index-alist &optional prompt)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 "Let the user select from INDEX-ALIST in a completion buffer with PROMPT.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 Returns t for rescan and otherwise a position number."
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 ;; Create a list for this buffer only when needed.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 (let (name choice
10093
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
778 (prepared-index-alist
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
779 (mapcar
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
780 (function
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
781 (lambda (item)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
782 (cons (imenu--replace-spaces (car item) imenu-space-replacement)
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
783 (cdr item))))
caafb376e619 (imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 10072
diff changeset
784 index-alist)))
10221
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
785 (if (eq imenu-always-use-completion-buffer-p 'never)
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
786 (setq name (completing-read (or prompt "Index item: ")
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
787 prepared-index-alist
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
788 nil t nil 'imenu--history-list))
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
789 (save-window-excursion
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
790 ;; Display the completion buffer
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
791 (with-output-to-temp-buffer "*Completions*"
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
792 (display-completion-list
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
793 (all-completions "" prepared-index-alist )))
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
794 (let ((minibuffer-setup-hook
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
795 (function (lambda ()
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
796 (let ((buffer (current-buffer)))
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
797 (save-excursion
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
798 (set-buffer "*Completions*")
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
799 (setq completion-reference-buffer buffer)))))))
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
800 ;; Make a completion question
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
801 (setq name (completing-read (or prompt "Index item: ")
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
802 prepared-index-alist
34b66bff7aec (imenu-always-use-completion-buffer-p): A value of
Richard M. Stallman <rms@gnu.org>
parents: 10093
diff changeset
803 nil t nil 'imenu--history-list)))))
7350
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
804 (cond ((not (stringp name))
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
805 nil)
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
806 ((string= name (car imenu--rescan-item))
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
807 t)
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
808 (t
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
809 (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
810 (if (imenu--subalist-p choice)
7350
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
811 (imenu--completion-buffer (cdr choice) prompt)
542ab48d0f18 (imenu-default-create-index-function):
Richard M. Stallman <rms@gnu.org>
parents: 7319
diff changeset
812 choice)))))
7319
cd73ba498964 (imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents: 6909
diff changeset
813
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 (defun imenu--mouse-menu (index-alist event &optional title)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 "Let the user select from a buffer index from a mouse menu.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 INDEX-ALIST is the buffer index and EVENT is a mouse event.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818
16148
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
819 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
820 (setq index-alist (imenu--split-submenus index-alist))
16148
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
821 (let* ((menu (imenu--split-menu index-alist
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 (or title (buffer-name))))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 position)
15374
6b1faae68eba (imenu--mouse-menu): Always use nested keymaps.
Richard M. Stallman <rms@gnu.org>
parents: 15335
diff changeset
824 (setq menu (imenu--create-keymap-1 (car menu)
6b1faae68eba (imenu--mouse-menu): Always use nested keymaps.
Richard M. Stallman <rms@gnu.org>
parents: 15335
diff changeset
825 (if (< 1 (length (cdr menu)))
6b1faae68eba (imenu--mouse-menu): Always use nested keymaps.
Richard M. Stallman <rms@gnu.org>
parents: 15335
diff changeset
826 (cdr menu)
16148
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
827 (cdr (car (cdr menu))))))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 (setq position (x-popup-menu event menu))
16148
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
829 (cond ((eq position nil)
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
830 position)
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
831 ;; If one call to x-popup-menu handled the nested menus,
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
832 ;; find the result by looking down the menus here.
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
833 ((and (listp position)
15411
9691904c57a5 (imenu--mouse-menu): Don't check imenu-use-keymap-menu.
Richard M. Stallman <rms@gnu.org>
parents: 15374
diff changeset
834 (numberp (car position))
9691904c57a5 (imenu--mouse-menu): Don't check imenu-use-keymap-menu.
Richard M. Stallman <rms@gnu.org>
parents: 15374
diff changeset
835 (stringp (nth (1- (length position)) position)))
16148
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
836 (let ((final menu))
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
837 (while position
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
838 (setq final (assoc (car position) final))
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
839 (setq position (cdr position)))
16236
52620db97569 (imenu--mouse-menu): Add special handling for rescan item.
Richard M. Stallman <rms@gnu.org>
parents: 16148
diff changeset
840 (or (string= (car final) (car imenu--rescan-item))
52620db97569 (imenu--mouse-menu): Add special handling for rescan item.
Richard M. Stallman <rms@gnu.org>
parents: 16148
diff changeset
841 (cdr (cdr (cdr final))))))
16148
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
842 ;; If x-popup-menu went just one level and found a leaf item,
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
843 ;; return the INDEX-ALIST element for that.
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
844 ((and (consp position)
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
845 (stringp (car position))
15411
9691904c57a5 (imenu--mouse-menu): Don't check imenu-use-keymap-menu.
Richard M. Stallman <rms@gnu.org>
parents: 15374
diff changeset
846 (null (cdr position)))
16148
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
847 (or (string= (car position) (car imenu--rescan-item))
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
848 (assq (car position) index-alist)))
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
849 ;; If x-popup-menu went just one level
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
850 ;; and found a non-leaf item (a submenu),
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
851 ;; recurse to handle the rest.
15411
9691904c57a5 (imenu--mouse-menu): Don't check imenu-use-keymap-menu.
Richard M. Stallman <rms@gnu.org>
parents: 15374
diff changeset
852 ((listp position)
9691904c57a5 (imenu--mouse-menu): Don't check imenu-use-keymap-menu.
Richard M. Stallman <rms@gnu.org>
parents: 15374
diff changeset
853 (imenu--mouse-menu position event
9691904c57a5 (imenu--mouse-menu): Don't check imenu-use-keymap-menu.
Richard M. Stallman <rms@gnu.org>
parents: 15374
diff changeset
854 (if title
9691904c57a5 (imenu--mouse-menu): Don't check imenu-use-keymap-menu.
Richard M. Stallman <rms@gnu.org>
parents: 15374
diff changeset
855 (concat title imenu-level-separator
9691904c57a5 (imenu--mouse-menu): Don't check imenu-use-keymap-menu.
Richard M. Stallman <rms@gnu.org>
parents: 15374
diff changeset
856 (car (rassq position index-alist)))
16148
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
857 (car (rassq position index-alist))))))))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858
6241
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
859 (defun imenu-choose-buffer-index (&optional prompt alist)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 "Let the user select from a buffer index and return the chosen index.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 If the user originally activated this function with the mouse, a mouse
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 menu is used. Otherwise a completion buffer is used and the user is
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 prompted with PROMPT.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865
6241
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
866 If you call this function with index alist ALIST, then it lets the user
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
867 select from ALIST.
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
868
6909
9e59751db725 Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents: 6241
diff changeset
869 With no index alist ALIST, it calls `imenu--make-index-alist' to
6241
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
870 create the index alist.
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
871
6909
9e59751db725 Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents: 6241
diff changeset
872 If `imenu-always-use-completion-buffer-p' is non-nil, then the
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 completion buffer is always used, no matter if the mouse was used or
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 not.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875
16369
187e7c8aaff5 (imenu--make-index-alist): Add doc string.
Richard M. Stallman <rms@gnu.org>
parents: 16315
diff changeset
876 The returned value is of the form (INDEX-NAME . INDEX-POSITION)."
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 (let (index-alist
8296
b2b493c007ff (imenu-choose-buffer-index): Use last-nonmenu-event
Richard M. Stallman <rms@gnu.org>
parents: 8256
diff changeset
878 (mouse-triggered (listp last-nonmenu-event))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 (result t) )
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 ;; If selected by mouse, see to that the window where the mouse is
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 ;; really is selected.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 (and mouse-triggered
12396
d0c82df80d70 (imenu-choose-buffer-index): Understand that (menu-bar)
Richard M. Stallman <rms@gnu.org>
parents: 12394
diff changeset
883 (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
884 (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
885 (or (framep window) (null window) (select-window window))))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 ;; Create a list for this buffer only when needed.
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 (while (eq result t)
6241
49538e6c482e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 6230
diff changeset
888 (setq index-alist (if alist alist (imenu--make-index-alist)))
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 (setq result
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 (if (and mouse-triggered
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891 (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
892 (imenu--mouse-menu index-alist last-nonmenu-event)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 (imenu--completion-buffer index-alist prompt)))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 (and (eq result t)
8408
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
895 (imenu--cleanup)
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896 (setq imenu--index-alist nil)))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 result))
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898
12394
4fbc70e4d5e7 (imenu-use-keymap-menu): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 10795
diff changeset
899 ;;;###autoload
8408
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
900 (defun imenu-add-to-menubar (name)
14657
4bedd113757f (imenu-add-to-menubar): Add menu item for current buf only.
Richard M. Stallman <rms@gnu.org>
parents: 14656
diff changeset
901 "Adds 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
902 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
903 See the command `imenu' for more information."
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
904 (interactive "sImenu menu item name: ")
17229
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
905 (if (or (and (fboundp imenu-prev-index-position-function)
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
906 (fboundp imenu-extract-index-name-function))
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
907 (and imenu-generic-expression))
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
908 (let ((newmap (make-sparse-keymap))
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
909 (menu-bar (lookup-key (current-local-map) [menu-bar])))
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
910 (define-key newmap [menu-bar]
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
911 (append (make-sparse-keymap) menu-bar))
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
912 (define-key newmap [menu-bar index]
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
913 (cons name (nconc (make-sparse-keymap "Imenu")
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
914 (make-sparse-keymap))))
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
915 (use-local-map (append newmap (current-local-map)))
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
916 (add-hook 'menu-bar-update-hook 'imenu-update-menubar))
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
917 (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
918
14642
01e8fdb45deb (imenu-buffer-menubar): Add defvar.
Karl Heuer <kwzh@gnu.org>
parents: 14575
diff changeset
919 (defvar imenu-buffer-menubar nil)
01e8fdb45deb (imenu-buffer-menubar): Add defvar.
Karl Heuer <kwzh@gnu.org>
parents: 14575
diff changeset
920
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
921 (defun imenu-update-menubar ()
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
922 (and (current-local-map)
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
923 (keymapp (lookup-key (current-local-map) [menu-bar index]))
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
924 (let ((index-alist (imenu--make-index-alist t)))
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
925 ;; Don't bother updating if the index-alist has not changed
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
926 ;; since the last time we did it.
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
927 (or (equal index-alist imenu--last-menubar-index-alist)
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
928 (let (menu menu1 old)
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
929 (setq imenu--last-menubar-index-alist index-alist)
14726
35e1cfdd29a4 (imenu--menubar-select): No longer interactive.
Richard M. Stallman <rms@gnu.org>
parents: 14725
diff changeset
930 (setq index-alist (imenu--split-submenus index-alist))
16148
8ca583c0b988 (imenu): Tests for when to widen were backwards.
Richard M. Stallman <rms@gnu.org>
parents: 15929
diff changeset
931 (setq menu (imenu--split-menu index-alist
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
932 (buffer-name)))
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
933 (setq menu1 (imenu--create-keymap-1 (car menu)
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
934 (if (< 1 (length (cdr menu)))
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
935 (cdr menu)
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
936 (cdr (car (cdr menu))))
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
937 t))
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
938 (setq old (lookup-key (current-local-map) [menu-bar index]))
15831
d110af120b19 (imenu-update-menubar): Fix code to install the new menu.
Richard M. Stallman <rms@gnu.org>
parents: 15411
diff changeset
939 (setcdr old (cdr menu1)))))))
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
940
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
941 (defun imenu--menubar-select (item)
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
942 "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
943 (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
944 (progn
29e7001fecf0 (imenu--menubar-select): Handle the "rescan" item.
Richard M. Stallman <rms@gnu.org>
parents: 14733
diff changeset
945 (imenu--cleanup)
29e7001fecf0 (imenu--menubar-select): Handle the "rescan" item.
Richard M. Stallman <rms@gnu.org>
parents: 14733
diff changeset
946 (setq imenu--index-alist nil)
29e7001fecf0 (imenu--menubar-select): Handle the "rescan" item.
Richard M. Stallman <rms@gnu.org>
parents: 14733
diff changeset
947 (imenu-update-menubar))
29e7001fecf0 (imenu--menubar-select): Handle the "rescan" item.
Richard M. Stallman <rms@gnu.org>
parents: 14733
diff changeset
948 (imenu item)))
8408
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
949
17229
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
950 (defun imenu-default-goto-function (name position &optional rest)
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
951 "This function is used for moving the point to POSITION.
17229
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
952 The NAME and REST parameters are not used, they are here just to make
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
953 this function have the same interface as a function placed in a special
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
954 index-item."
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
955 (if (or (< position (point-min))
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
956 (> position (point-max)))
17229
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
957 ;; widen if outside narrowing
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
958 (widen))
17307
830ad59547e4 (imenu-default-goto-function): Simplify.
Richard M. Stallman <rms@gnu.org>
parents: 17230
diff changeset
959 (goto-char position))
17229
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
960
7319
cd73ba498964 (imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents: 6909
diff changeset
961 ;;;###autoload
12664
ce1cae301efe (imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents: 12635
diff changeset
962 (defun imenu (index-item)
7319
cd73ba498964 (imenu): Renamed from goto-index-pos.
Richard M. Stallman <rms@gnu.org>
parents: 6909
diff changeset
963 "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
964 See `imenu-choose-buffer-index' for more information."
16698
13920eac02e0 (imenu-generic-expression): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16612
diff changeset
965 (interactive (list (imenu-choose-buffer-index)))
13798
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
966 ;; Convert a string to an alist element.
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
967 (if (stringp index-item)
4eac65d000d3 (imenu-update-menubar): New function.
Karl Heuer <kwzh@gnu.org>
parents: 13645
diff changeset
968 (setq index-item (assoc index-item (imenu--make-index-alist))))
12664
ce1cae301efe (imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents: 12635
diff changeset
969 (and index-item
ce1cae301efe (imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents: 12635
diff changeset
970 (progn
ce1cae301efe (imenu--history-list): Don't make this buffer-local.
Richard M. Stallman <rms@gnu.org>
parents: 12635
diff changeset
971 (push-mark)
17229
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
972 (let* ((is-special-item (listp (cdr index-item)))
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
973 (function
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
974 (if is-special-item
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
975 (caddr index-item) imenu-default-goto-function))
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
976 (position (if is-special-item
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
977 (cadr index-item) (cdr index-item)))
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
978 (rest (if is-special-item (cddr index-item))))
b48a8dd2d8ce (imenu-scanning-message): Support for bigger numbers.
Richard M. Stallman <rms@gnu.org>
parents: 16698
diff changeset
979 (apply function (car index-item) position rest)))))
8408
109166e311ce (imenu, imenu--flatten-index-alist): Add marker support.
Richard M. Stallman <rms@gnu.org>
parents: 8296
diff changeset
980
6230
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
981 (provide 'imenu)
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
982
4c72f80598ae Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
983 ;;; imenu.el ends here