annotate lisp/cedet/semantic/imenu.el @ 110763:0fe64d68a522

Merge changes made in Gnus trunk. shr.el: Implement table rendering. shr.el (shr-make-table): Tweak table generation. shr.el (shr-make-table): Fix typo. nnimap.el (nnimap-open-connection): Allow tls as a synonym for ssl. gnus-util.el (gnus-emacs-completing-read): Mapcar collection to list, for XEmacs. nnimap.el (nnimap-close-server): Implement. gnus-salt.el: Remove all gnus-carpal stuff -- it's not useful. nnir.el (nnir-run-imap): Remove spurious space in search string. message.el (message-idna-to-ascii-rhs-1): Don't bug out on addresses without @ signs. gnus-sum.el (gnus-widen-article-window): New variable. shr.el (browse-url): Required. shr.el (shr-ensure-paragraph): Don't insert a new newline after empty-ish lines. shr.el (shr-show-alt-text, shr-browse-image): New commands. gravatar.el (gravatar-retrieved): kill buffer when retrieved. shr.el (shr-browse-url, shr-copy-url): New commands. shr.el (shr-render-td): Protect against too-wide text. spam-report.el (spam-report-url-ping-plain): Don't query about killing the process. nnimap.el (nnimap-finish-retrieve-group-infos): Message while waiting for data. shr.el (shr-tag-blockquote): Ensure paragraph after quote, too. mml-smime.el: Fix gnus-completing-read usage. shr.el (shr-get-image-data): Ensure against the cache file missing. nnimap.el (nnimap-open-connection): Give an error if nnimap-stream is unknown.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Mon, 04 Oct 2010 22:26:51 +0000
parents a5ad4f188e19
children 9814473572d4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
107497
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; semantic/imenu.el --- Use Semantic as an imenu tag generator
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
3 ;;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2010
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4 ;; Free Software Foundation, Inc.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6 ;; Author: Eric M. Ludlam <zappo@gnu.org>
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; Maintainer: Eric Ludlam
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; (at your option) any later version.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; GNU General Public License for more details.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;;; Commentary:
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;;
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;; This support function can be used in any buffer which supports
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 ;; the bovinator to create the imenu index.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;;
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;; To use this in a buffer, do this in a hook.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;;
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;; (add-hook 'mode-hook
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 ;; (lambda ()
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 ;; (setq imenu-create-index-function 'semantic-create-imenu-index)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;; ))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 (require 'semantic)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 (require 'semantic/format)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 (require 'semantic/db)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 (require 'semantic/db-file)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 (require 'semantic/sort)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 (require 'imenu)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 (declare-function pulse-momentary-highlight-one-line "pulse" (o &optional face))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 (declare-function semanticdb-semantic-init-hook-fcn "db-mode")
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 ;; Because semantic imenu tags will hose the current imenu handling
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 ;; code in speedbar, force semantic/sb in.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 (if (featurep 'speedbar)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 (require 'semantic/sb)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 (add-hook 'speedbar-load-hook (lambda () (require 'semantic/sb))))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 (defgroup semantic-imenu nil
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 "Semantic interface to Imenu."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 :group 'semantic
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 :group 'imenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 )
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 ;;;###autoload
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 (defcustom semantic-imenu-summary-function 'semantic-format-tag-abbreviate
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 "*Function to use when creating items in Imenu.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 Some useful functions are found in `semantic-format-tag-functions'."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 :group 'semantic-imenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 :type semantic-format-tag-custom-list)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 (make-variable-buffer-local 'semantic-imenu-summary-function)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 ;;;###autoload
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 (defcustom semantic-imenu-bucketize-file t
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 "*Non-nil if tags in a file are to be grouped into buckets."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 :group 'semantic-imenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 :type 'boolean)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 (make-variable-buffer-local 'semantic-imenu-bucketize-file)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 (defcustom semantic-imenu-adopt-external-members t
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 "*Non-nil if types in a file should adopt externally defined members.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 C++ and CLOS can define methods that are not in the body of a class
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 definition."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 :group 'semantic-imenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 :type 'boolean)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 (defcustom semantic-imenu-buckets-to-submenu t
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 "*Non-nil if buckets of tags are to be turned into submenus.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 This option is ignored if `semantic-imenu-bucketize-file' is nil."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 :group 'semantic-imenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 :type 'boolean)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 (make-variable-buffer-local 'semantic-imenu-buckets-to-submenu)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 ;;;###autoload
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 (defcustom semantic-imenu-expand-type-members t
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 "*Non-nil if types should have submenus with members in them."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 :group 'semantic-imenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 :type 'boolean)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 (make-variable-buffer-local 'semantic-imenu-expand-type-members)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 (semantic-varalias-obsolete 'semantic-imenu-expand-type-parts
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 'semantic-imenu-expand-type-members "23.2")
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 (defcustom semantic-imenu-bucketize-type-members t
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 "*Non-nil if members of a type should be grouped into buckets.
107760
719f64798991 Fix typos in semantic/imenu.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 107499
diff changeset
98 A nil value means to keep them in the same order.
107497
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 Overriden to nil if `semantic-imenu-bucketize-file' is nil."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 :group 'semantic-imenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 :type 'boolean)
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 107760
diff changeset
102 (make-variable-buffer-local 'semantic-imenu-bucketize-type-members)
107497
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 (semantic-varalias-obsolete 'semantic-imenu-bucketize-type-parts
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 'semantic-imenu-bucketize-type-members "23.2")
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 (defcustom semantic-imenu-sort-bucket-function nil
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 "*Function to use when sorting tags in the buckets of functions.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 See `semantic-bucketize' and the FILTER argument for more details on this function."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 :group 'semantic-imenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 :type '(radio (const :tag "No Sorting" nil)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 (const semantic-sort-tags-by-name-increasing)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 (const semantic-sort-tags-by-name-decreasing)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 (const semantic-sort-tags-by-type-increasing)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 (const semantic-sort-tags-by-type-decreasing)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 (const semantic-sort-tags-by-name-increasing-ci)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 (const semantic-sort-tags-by-name-decreasing-ci)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 (const semantic-sort-tags-by-type-increasing-ci)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 (const semantic-sort-tags-by-type-decreasing-ci)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 (function)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 (make-variable-buffer-local 'semantic-imenu-sort-bucket-function)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 (defcustom semantic-imenu-index-directory nil
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 "*Non nil to index the entire directory for tags.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 Doesn't actually parse the entire directory, but displays tags for all files
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 currently listed in the current Semantic database.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 This variable has no meaning if semanticdb is not active."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 :group 'semantic-imenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 :type 'boolean)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 (defcustom semantic-imenu-auto-rebuild-directory-indexes nil
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 "*If non-nil automatically rebuild directory index imenus.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 That is when a directory index imenu is updated, automatically rebuild
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 other buffer local ones based on the same semanticdb."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 :group 'semantic-imenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 :type 'boolean)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 (defvar semantic-imenu-directory-current-file nil
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 "When building a file index, this is the file name currently being built.")
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 (defvar semantic-imenu-auto-rebuild-running nil
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 "Non-nil if `semantic-imenu-rebuild-directory-indexes' is running.")
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 ;;;###autoload
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 (defvar semantic-imenu-expandable-tag-classes '(type)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 "List of expandable tag classes.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 Tags of those classes will be given submenu with children.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 By default, a `type' has interesting children. In Texinfo, however, a
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 `section' has interesting children.")
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 (make-variable-buffer-local 'semantic-imenu-expandable-tag-classes)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 (semantic-varalias-obsolete 'semantic-imenu-expandable-token
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 'semantic-imenu-expandable-tag-classes "23.2")
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 ;;; Code:
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 (defun semantic-imenu-tag-overlay (tag)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 "Return the overlay belonging to tag.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 If TAG doesn't have an overlay, and instead as a vector of positions,
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 concoct a combination of file name, and position."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 (let ((o (semantic-tag-overlay tag)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 (if (not (semantic-overlay-p o))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 (let ((v (make-vector 3 nil)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 (aset v 0 semantic-imenu-directory-current-file)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162 (aset v 1 (aref o 0))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 (aset v 2 (aref o 1))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 v)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 o)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 (defun semantic-imenu-goto-function (name position &optional rest)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 "Move point associated with NAME to POSITION.
107760
719f64798991 Fix typos in semantic/imenu.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 107499
diff changeset
170 Used to override function `imenu-default-goto-function' so that
719f64798991 Fix typos in semantic/imenu.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 107499
diff changeset
171 we can continue to use overlays to maintain the current position.
107497
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 Optional argument REST is some extra stuff."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 (require 'pulse)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 (if (semantic-overlay-p position)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 (let ((os (semantic-overlay-start position))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 (ob (semantic-overlay-buffer position)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 (if os
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 (progn
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 (if (not (eq ob (current-buffer)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 (switch-to-buffer ob))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 (imenu-default-goto-function name os rest)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 (pulse-momentary-highlight-one-line (point))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 )
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 ;; This should never happen, but check anyway.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 (message "Imenu is out of date, try again. (internal bug)")
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 (setq imenu--index-alist nil)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 ;; When the POSITION is actually a pair of numbers in an array, then
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 ;; the file isn't loaded into the current buffer.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 (if (vectorp position)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 (let ((file (aref position 0))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 (pos (aref position 1)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 (and file (find-file file))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 (imenu-default-goto-function name pos rest)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 (pulse-momentary-highlight-one-line (point))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 )
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 ;; When the POSITION is the symbol 'file-only' it means that this
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 ;; is a directory index entry and there is no tags in this
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 ;; file. So just jump to the beginning of the file.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 (if (eq position 'file-only)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 (progn
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 (find-file name)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 (imenu-default-goto-function name (point-min) rest)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203 (pulse-momentary-highlight-one-line (point))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 )
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 ;; Probably POSITION don't came from a semantic imenu. Try
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 ;; the default imenu goto function.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 (condition-case nil
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 (progn
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 (imenu-default-goto-function name position rest)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 (pulse-momentary-highlight-one-line (point))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 )
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 (error
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 (message "Semantic Imenu override problem. (Internal bug)")
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 (setq imenu--index-alist nil)))))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215 ))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 (defun semantic-imenu-flush-fcn (&optional ignore)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 "This function is called as a hook to clear the imenu cache.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 It is cleared after any parsing.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220 IGNORE arguments."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 (if (eq imenu-create-index-function 'semantic-create-imenu-index)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 (setq imenu--index-alist nil
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 imenu-menubar-modified-tick 0))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 (remove-hook 'semantic-after-toplevel-cache-change-hook
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 'semantic-imenu-flush-fcn t)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 (remove-hook 'semantic-after-partial-cache-change-hook
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 'semantic-imenu-flush-fcn t)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 )
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 ;;;###autoload
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 (defun semantic-create-imenu-index (&optional stream)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 "Create an imenu index for any buffer which supports Semantic.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 Uses the output of the Semantic parser to create the index.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 Optional argument STREAM is an optional stream of tags used to create menus."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235 (setq imenu-default-goto-function 'semantic-imenu-goto-function)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 (prog1
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 (if (and semantic-imenu-index-directory
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 (featurep 'semanticdb)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 (semanticdb-minor-mode-p))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 (semantic-create-imenu-directory-index
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 (or stream (semantic-fetch-tags-fast)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 (semantic-create-imenu-index-1
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243 (or stream (semantic-fetch-tags-fast)) nil))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 (semantic-make-local-hook 'semantic-after-toplevel-cache-change-hook)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 (add-hook 'semantic-after-toplevel-cache-change-hook
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 'semantic-imenu-flush-fcn nil t)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 (semantic-make-local-hook 'semantic-after-partial-cache-change-hook)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 (add-hook 'semantic-after-partial-cache-change-hook
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 'semantic-imenu-flush-fcn nil t)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 (defun semantic-create-imenu-directory-index (&optional stream)
107760
719f64798991 Fix typos in semantic/imenu.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 107499
diff changeset
252 "Create an imenu tag index based on all files active in semanticdb.
107497
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 Optional argument STREAM is the stream of tags for the current buffer."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 (if (not semanticdb-current-database)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 (semantic-create-imenu-index-1 stream nil)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 ;; We have a database, list all files, with the current file on top.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 (let ((index (list
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 (cons (oref semanticdb-current-table file)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 (or (semantic-create-imenu-index-1 stream nil)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 ;; No tags in this file
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 'file-only))))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 (tables (semanticdb-get-database-tables semanticdb-current-database)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 (while tables
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 (let ((semantic-imenu-directory-current-file
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 (oref (car tables) file))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 tags)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 (when (and (not (eq (car tables) semanticdb-current-table))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 (semanticdb-live-p (car tables))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 (semanticdb-equivalent-mode (car tables))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 )
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 (setq tags (oref (car tables) tags)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 index (cons (cons semantic-imenu-directory-current-file
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 (or (and tags
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 ;; don't pass nil stream because
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 ;; it will use the current
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 ;; buffer
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 (semantic-create-imenu-index-1
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 (oref (car tables) tags)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 nil))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 ;; no tags in the file
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 'file-only))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 index)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 (setq tables (cdr tables))))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 ;; If enabled automatically rebuild other imenu directory
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 ;; indexes based on the same Semantic database
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 (or (not semantic-imenu-auto-rebuild-directory-indexes)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 ;; If auto rebuild already in progress does nothing
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 semantic-imenu-auto-rebuild-running
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 (unwind-protect
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 (progn
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 (setq semantic-imenu-auto-rebuild-running t)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 (semantic-imenu-rebuild-directory-indexes
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 semanticdb-current-database))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 (setq semantic-imenu-auto-rebuild-running nil)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 (nreverse index))))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 (defun semantic-create-imenu-index-1 (stream &optional parent)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 "Create an imenu index for any buffer which supports Semantic.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 Uses the output of the Semantic parser to create the index.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 STREAM is a stream of tags used to create menus.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 Optional argument PARENT is a tag parent of STREAM."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 (let ((tags stream)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 (semantic-imenu-adopt-external-members
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 semantic-imenu-adopt-external-members))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 ;; If we should regroup, do so.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 (if semantic-imenu-adopt-external-members
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 (setq tags (semantic-adopt-external-members tags)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 ;; Don't allow recursion here.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 semantic-imenu-adopt-external-members nil))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 ;; Test for bucketing vs not.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 (if semantic-imenu-bucketize-file
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 (let ((buckets (semantic-bucketize
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 tags parent
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 semantic-imenu-sort-bucket-function))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 item name
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 index)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 (cond
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 ((null buckets)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 nil)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322 ((or (cdr-safe buckets) ;; if buckets has more than one item in it.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 (not semantic-imenu-buckets-to-submenu)) ;; to force separators between buckets
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 (while buckets
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 (setq name (car (car buckets))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 item (cdr (car buckets)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 (if semantic-imenu-buckets-to-submenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 (progn
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 ;; Make submenus
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 (if item
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 (setq index
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
332 (cons (cons name
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333 (semantic-create-imenu-subindex item))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 index))))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335 ;; Glom everything together with "---" between
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 (if item
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337 (setq index
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 (append index
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339 ;; do not create a menu separator in the parent menu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 ;; when creating a sub-menu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341 (if (memq (semantic-tag-class (car item))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342 semantic-imenu-expandable-tag-classes)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 (semantic-create-imenu-subindex item)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 (cons
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345 '("---")
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346 (semantic-create-imenu-subindex item)))))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347 ))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 (setq buckets (cdr buckets)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349 (if semantic-imenu-buckets-to-submenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 (nreverse index)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 index))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 (t
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 (setq name (car (car buckets))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 item (cdr (car buckets)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355 (semantic-create-imenu-subindex item))))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
356 ;; Else, group everything together
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
357 (semantic-create-imenu-subindex tags))))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 (defun semantic-create-imenu-subindex (tags)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 "From TAGS, create an imenu index of interesting things."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 (let ((notypecheck (not semantic-imenu-expand-type-members))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362 children index tag parts)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 (while tags
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 (setq tag (car tags)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 children (semantic-tag-components-with-overlays tag))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 (if (and (not notypecheck)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367 (memq (semantic-tag-class tag)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368 semantic-imenu-expandable-tag-classes)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 children
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 )
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 ;; to keep an homogeneous menu organisation, type menu items
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372 ;; always have a sub-menu with at least the *definition*
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373 ;; item (even if the tag has no type components)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 (progn
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 (setq parts children)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 ;; There is options which create the submenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377 ;; * Type has an overlay, but children do.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 ;; The type doesn't have to have it's own overlay,
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 ;; but a type with no overlay and no children should be
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380 ;; invalid.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 (setq index
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 (cons
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383 (cons
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 (funcall semantic-imenu-summary-function tag)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 ;; Add a menu for getting at the type definitions
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 (if (and parts
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387 ;; Note to self: enable menu items for
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 ;; sub parts even if they are not proper
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389 ;; tags.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 (semantic-tag-p (car parts)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 (let ((submenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 (if (and semantic-imenu-bucketize-type-members
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 semantic-imenu-bucketize-file)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 (semantic-create-imenu-index-1 parts tag)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 (semantic-create-imenu-subindex parts))))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 ;; Only add a *definition* if we have a postion
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 ;; in that type tag.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 (if (semantic-tag-with-position-p tag)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399 (cons
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 (cons "*definition*"
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 (semantic-imenu-tag-overlay tag))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 submenu)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 submenu))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 ;; There were no parts, or something like that, so
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 ;; instead just put the definition here.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 (if (semantic-tag-with-position-p tag)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407 (semantic-imenu-tag-overlay tag)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408 nil)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409 ))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410 index)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411 (if (semantic-tag-with-position-p tag)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
412 (setq index (cons
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413 (cons
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414 (funcall semantic-imenu-summary-function tag)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 (semantic-imenu-tag-overlay tag))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 index))))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417 (setq tags (cdr tags)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418 ;; `imenu--split-submenus' sort submenus according to
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 ;; `imenu-sort-function' setting and split them up if they are
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 ;; longer than `imenu-max-items'.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 (imenu--split-submenus (nreverse index))))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 ;;; directory imenu rebuilding.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 ;;
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
425 (defun semantic-imenu-rebuild-directory-indexes (db)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426 "Rebuild directory index imenus based on Semantic database DB."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427 (let ((l (buffer-list))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428 b)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 (while l
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 (setq b (car l)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431 l (cdr l))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 (if (and (not (eq b (current-buffer)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 (buffer-live-p b))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434 (with-current-buffer b
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435 ;; If there is a buffer local Semantic index directory
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436 ;; imenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 (when (and (eq imenu-create-index-function
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438 'semantic-create-imenu-index)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439 semanticdb-current-database
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440 (eq semanticdb-current-database db))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441 ;; Rebuild the imenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442 (imenu--cleanup)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443 (setq imenu--index-alist nil)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 (funcall
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
445 (if (fboundp 'imenu-menu-filter)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446 ;; XEmacs imenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 'imenu-menu-filter
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448 ;; Emacs imenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449 'imenu-update-menubar))))))))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
451 (defun semantic-imenu-semanticdb-hook ()
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452 "Function to be called from `semanticdb-mode-hook'.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
453 Clears all imenu menus that may be depending on the database."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
454 (require 'semantic/db-mode)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
455 (semantic-map-buffers
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
456 #'(lambda ()
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
457 ;; Set up semanticdb environment if enabled.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458 (if (semanticdb-minor-mode-p)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459 (semanticdb-semantic-init-hook-fcn))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
460 ;; Clear imenu cache to redraw the imenu.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
461 (semantic-imenu-flush-fcn))))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463 (add-hook 'semanticdb-mode-hook 'semantic-imenu-semanticdb-hook)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
464
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 ;;; Interactive Utilities
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
466 ;;
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
467 (defun semantic-imenu-toggle-bucketize-file ()
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468 "Toggle the ability of imenu to bucketize the current file."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
469 (interactive)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 (setq semantic-imenu-bucketize-file (not semantic-imenu-bucketize-file))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
471 ;; Force a rescan
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
472 (setq imenu--index-alist nil))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
474 (defun semantic-imenu-toggle-buckets-to-submenu ()
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
475 "Toggle the ability of imenu to turn buckets into submenus."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
476 (interactive)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
477 (setq semantic-imenu-buckets-to-submenu (not semantic-imenu-buckets-to-submenu))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478 ;; Force a rescan
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
479 (setq imenu--index-alist nil))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
480
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
481 (defun semantic-imenu-toggle-bucketize-type-parts ()
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
482 "Toggle the ability of imenu to bucketize the current file."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
483 (interactive)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
484 (setq semantic-imenu-bucketize-type-members (not semantic-imenu-bucketize-type-members))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
485 ;; Force a rescan
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
486 (setq imenu--index-alist nil))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
487
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
488 ;;; Which function support
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
489 ;;
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
490 ;; The which-function library will display the current function in the
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
491 ;; mode line. It tries do do this through imenu. With a semantic parsed
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
492 ;; buffer, there is a much more efficient way of doing this.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
493 ;; Advise `which-function' so that we optionally use semantic tags
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
494 ;; instead, and get better stuff.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
495 (require 'advice)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
496
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
497 (defvar semantic-which-function 'semantic-default-which-function
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
498 "Function to convert semantic tags into `which-function' text.")
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
499
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
500 (defcustom semantic-which-function-use-color nil
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
501 "*Use color when displaying the current function with `which-function'."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
502 :group 'semantic-imenu
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
503 :type 'boolean)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
504
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
505 (defun semantic-default-which-function (taglist)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
506 "Convert TAGLIST into a string usable by `which-function'.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
507 Returns the first tag name in the list, unless it is a type,
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
508 in which case it concatenates them together."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
509 (cond ((eq (length taglist) 1)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
510 (semantic-format-tag-abbreviate
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
511 (car taglist) nil semantic-which-function-use-color))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
512 ((memq (semantic-tag-class (car taglist))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
513 semantic-imenu-expandable-tag-classes)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
514 (concat (semantic-format-tag-name
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
515 (car taglist) nil semantic-which-function-use-color)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
516 (car semantic-type-relation-separator-character)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
517 ;; recurse until we no longer have a type
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
518 ;; or any tags left.
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
519 (semantic-default-which-function (cdr taglist))))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
520 (t (semantic-format-tag-abbreviate
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
521 (car taglist) nil semantic-which-function-use-color))))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
522
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
523 ;; (defadvice which-function (around semantic-which activate)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
524 ;; "Choose the function to display via semantic if it is currently active."
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
525 ;; (if (and (featurep 'semantic) semantic--buffer-cache)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
526 ;; (let ((ol (semantic-find-tag-by-overlay)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
527 ;; (setq ad-return-value (funcall semantic-which-function ol)))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
528 ;; ad-do-it))
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
529
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
530 (provide 'semantic/imenu)
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
531
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
532 ;; Local variables:
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
533 ;; generated-autoload-file: "loaddefs.el"
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
534 ;; generated-autoload-load-name: "semantic/imenu"
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
535 ;; End:
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
536
b09401cc9d96 * cedet/semantic/imenu.el: New file from the CEDET repository (Bug#5412).
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
537 ;;; semantic/imenu.el ends here