Mercurial > emacs
annotate lisp/cedet/semantic/util.el @ 106196:2721ecb2b07c
* cedet/semantic/ia.el (semantic-ia-completion-format-tag-function):
Use semantic-format-tag-prototype.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 22 Nov 2009 23:09:17 +0000 |
parents | 3fe6da4a95a9 |
children | 019d906c8f48 |
rev | line source |
---|---|
104446
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
1 ;;; semantic/util.el --- Utilities for use with semantic tag tables |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3 ;;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
4 ;;; 2008, 2009 Free Software Foundation, Inc. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
5 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
6 ;; Author: Eric M. Ludlam <zappo@gnu.org> |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
7 ;; Keywords: syntax |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
8 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
10 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
14 ;; (at your option) any later version. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
15 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
20 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
23 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
24 ;;; Commentary: |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
25 ;; |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
26 ;; Semantic utility API for use with semantic tag tables. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
27 ;; |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
28 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
29 (require 'semantic) |
104447
273e528a9f9b
* emacs-lisp/autoload.el (generated-autoload-load-name): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
104446
diff
changeset
|
30 |
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104519
diff
changeset
|
31 (eval-when-compile |
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104519
diff
changeset
|
32 (require 'semantic/db-find) |
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104519
diff
changeset
|
33 ;; For semantic-find-tags-by-class, semantic--find-tags-by-function, |
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104519
diff
changeset
|
34 ;; and semantic-brute-find-tag-standard: |
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104519
diff
changeset
|
35 (require 'semantic/find)) |
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104519
diff
changeset
|
36 |
104447
273e528a9f9b
* emacs-lisp/autoload.el (generated-autoload-load-name): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
104446
diff
changeset
|
37 (declare-function data-debug-insert-stuff-list "data-debug") |
273e528a9f9b
* emacs-lisp/autoload.el (generated-autoload-load-name): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
104446
diff
changeset
|
38 (declare-function data-debug-insert-thing "data-debug") |
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104519
diff
changeset
|
39 (declare-function semantic-ctxt-current-symbol-and-bounds "semantic/ctxt") |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
40 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
41 ;;; Code: |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
42 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
43 (defvar semantic-type-relation-separator-character '(".") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
44 "Character strings used to separate a parent/child relationship. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
45 This list of strings are used for displaying or finding separators |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
46 in variable field dereferencing. The first character will be used for |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
47 display. In C, a type field is separated like this: \"type.field\" |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
48 thus, the character is a \".\". In C, and additional value of \"->\" |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
49 would be in the list, so that \"type->field\" could be found.") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
50 (make-variable-buffer-local 'semantic-type-relation-separator-character) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
51 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
52 (defvar semantic-equivalent-major-modes nil |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
53 "List of major modes which are considered equivalent. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
54 Equivalent modes share a parser, and a set of override methods. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
55 A value of nil means that the current major mode is the only one.") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
56 (make-variable-buffer-local 'semantic-equivalent-major-modes) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
57 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
58 ;; These semanticdb calls will throw warnings in the byte compiler. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
59 ;; Doing the right thing to make them available at compile time |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
60 ;; really messes up the compilation sequence. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
61 (defun semantic-file-tag-table (file) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
62 "Return a tag table for FILE. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
63 If it is loaded, return the stream after making sure it's ok. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
64 If FILE is not loaded, check to see if `semanticdb' feature exists, |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
65 and use it to get tags from files not in memory. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
66 If FILE is not loaded, and semanticdb is not available, find the file |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
67 and parse it." |
104492
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104477
diff
changeset
|
68 (save-match-data |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104477
diff
changeset
|
69 (if (find-buffer-visiting file) |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105760
diff
changeset
|
70 (with-current-buffer (find-buffer-visiting file) |
104492
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104477
diff
changeset
|
71 (semantic-fetch-tags)) |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104477
diff
changeset
|
72 ;; File not loaded |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104477
diff
changeset
|
73 (if (and (require 'semantic/db-mode) |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104477
diff
changeset
|
74 (semanticdb-minor-mode-p)) |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104477
diff
changeset
|
75 ;; semanticdb is around, use it. |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104477
diff
changeset
|
76 (semanticdb-file-stream file) |
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104477
diff
changeset
|
77 ;; Get the stream ourselves. |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105760
diff
changeset
|
78 (with-current-buffer (find-file-noselect file) |
104492
8db96f200ac8
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104477
diff
changeset
|
79 (semantic-fetch-tags)))))) |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
80 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
81 (semantic-alias-obsolete 'semantic-file-token-stream |
105760
d0906291f75b
* cedet/semantic/fw.el (semantic-alias-obsolete)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105750
diff
changeset
|
82 'semantic-file-tag-table "23.2") |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
83 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
84 (defun semantic-something-to-tag-table (something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
85 "Convert SOMETHING into a semantic tag table. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
86 Something can be a tag with a valid BUFFER property, a tag table, a |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
87 buffer, or a filename. If SOMETHING is nil return nil." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
88 (cond |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
89 ;; A list of tags |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
90 ((and (listp something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
91 (semantic-tag-p (car something))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
92 something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
93 ;; A buffer |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
94 ((bufferp something) |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105760
diff
changeset
|
95 (with-current-buffer something |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
96 (semantic-fetch-tags))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
97 ;; A Tag: Get that tag's buffer |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
98 ((and (semantic-tag-with-position-p something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
99 (semantic-tag-in-buffer-p something)) |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105760
diff
changeset
|
100 (with-current-buffer (semantic-tag-buffer something) |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
101 (semantic-fetch-tags))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
102 ;; Tag with a file name in it |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
103 ((and (semantic-tag-p something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
104 (semantic-tag-file-name something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
105 (file-exists-p (semantic-tag-file-name something))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
106 (semantic-file-tag-table |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
107 (semantic-tag-file-name something))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
108 ;; A file name |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
109 ((and (stringp something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
110 (file-exists-p something)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
111 (semantic-file-tag-table something)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
112 ;; A Semanticdb table |
104447
273e528a9f9b
* emacs-lisp/autoload.el (generated-autoload-load-name): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
104446
diff
changeset
|
113 ((and (featurep 'semantic/db) |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
114 (semanticdb-minor-mode-p) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
115 (semanticdb-abstract-table-child-p something)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
116 (semanticdb-refresh-table something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
117 (semanticdb-get-tags something)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
118 ;; Semanticdb find-results |
104447
273e528a9f9b
* emacs-lisp/autoload.el (generated-autoload-load-name): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
104446
diff
changeset
|
119 ((and (featurep 'semantic/db) |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
120 (semanticdb-minor-mode-p) |
104447
273e528a9f9b
* emacs-lisp/autoload.el (generated-autoload-load-name): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
104446
diff
changeset
|
121 (require 'semantic/db-find) |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
122 (semanticdb-find-results-p something)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
123 (semanticdb-strip-find-results something)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
124 ;; NOTE: This commented out since if a search result returns |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
125 ;; empty, that empty would turn into everything on the next search. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
126 ;; Use the current buffer for nil |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
127 ;; ((null something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
128 ;; (semantic-fetch-tags)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
129 ;; don't know what it is |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
130 (t nil))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
131 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
132 (semantic-alias-obsolete 'semantic-something-to-stream |
105760
d0906291f75b
* cedet/semantic/fw.el (semantic-alias-obsolete)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105750
diff
changeset
|
133 'semantic-something-to-tag-table "23.2") |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
134 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
135 ;;; Recursive searching through dependency trees |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
136 ;; |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
137 ;; This will depend on the general searching APIS defined above. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
138 ;; but will add full recursion through the dependencies list per |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
139 ;; stream. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
140 (defun semantic-recursive-find-nonterminal-by-name (name buffer) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
141 "Recursively find the first occurrence of NAME. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
142 Start search with BUFFER. Recurse through all dependencies till found. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
143 The return item is of the form (BUFFER TOKEN) where BUFFER is the buffer |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
144 in which TOKEN (the token found to match NAME) was found. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
145 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
146 THIS ISN'T USED IN SEMANTIC. DELETE ME SOON." |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105760
diff
changeset
|
147 (with-current-buffer buffer |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
148 (let* ((stream (semantic-fetch-tags)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
149 (includelist (or (semantic-find-tags-by-class 'include stream) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
150 "empty.silly.thing")) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
151 (found (semantic-find-first-tag-by-name name stream)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
152 (unfound nil)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
153 (while (and (not found) includelist) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
154 (let ((fn (semantic-dependency-tag-file (car includelist)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
155 (if (and fn (not (member fn unfound))) |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105760
diff
changeset
|
156 (with-current-buffer (save-match-data |
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105760
diff
changeset
|
157 (find-file-noselect fn)) |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
158 (message "Scanning %s" (buffer-file-name)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
159 (setq stream (semantic-fetch-tags)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
160 (setq found (semantic-find-first-tag-by-name name stream)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
161 (if found |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
162 (setq found (cons (current-buffer) (list found))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
163 (setq includelist |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
164 (append includelist |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
165 (semantic-find-tags-by-class |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
166 'include stream)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
167 (setq unfound (cons fn unfound))))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
168 (setq includelist (cdr includelist))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
169 found))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
170 (make-obsolete 'semantic-recursive-find-nonterminal-by-name |
105750
a81c63f1a19f
* cedet/semantic/util.el (semantic-recursive-find-nonterminal-by-name):
Chong Yidong <cyd@stupidchicken.com>
parents:
105377
diff
changeset
|
171 "Do not use this function." "23.2") |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
172 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
173 ;;; Completion APIs |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
174 ;; |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
175 ;; These functions provide minibuffer reading/completion for lists of |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
176 ;; nonterminals. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
177 (defvar semantic-read-symbol-history nil |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
178 "History for a symbol read.") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
179 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
180 (defun semantic-read-symbol (prompt &optional default stream filter) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
181 "Read a symbol name from the user for the current buffer. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
182 PROMPT is the prompt to use. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
183 Optional arguments: |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
184 DEFAULT is the default choice. If no default is given, one is read |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
185 from under point. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
186 STREAM is the list of tokens to complete from. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
187 FILTER is provides a filter on the types of things to complete. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
188 FILTER must be a function to call on each element." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
189 (if (not default) (setq default (thing-at-point 'symbol))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
190 (if (not stream) (setq stream (semantic-fetch-tags))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
191 (setq stream |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
192 (if filter |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
193 (semantic--find-tags-by-function filter stream) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
194 (semantic-brute-find-tag-standard stream))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
195 (if (and default (string-match ":" prompt)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
196 (setq prompt |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
197 (concat (substring prompt 0 (match-end 0)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
198 " (default: " default ") "))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
199 (completing-read prompt stream nil t "" |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
200 'semantic-read-symbol-history |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
201 default)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
202 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
203 (defun semantic-read-variable (prompt &optional default stream) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
204 "Read a variable name from the user for the current buffer. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
205 PROMPT is the prompt to use. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
206 Optional arguments: |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
207 DEFAULT is the default choice. If no default is given, one is read |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
208 from under point. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
209 STREAM is the list of tokens to complete from." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
210 (semantic-read-symbol |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
211 prompt default |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
212 (or (semantic-find-tags-by-class |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
213 'variable (or stream (current-buffer))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
214 (error "No local variables")))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
215 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
216 (defun semantic-read-function (prompt &optional default stream) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
217 "Read a function name from the user for the current buffer. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
218 PROMPT is the prompt to use. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
219 Optional arguments: |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
220 DEFAULT is the default choice. If no default is given, one is read |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
221 from under point. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
222 STREAM is the list of tags to complete from." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
223 (semantic-read-symbol |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
224 prompt default |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
225 (or (semantic-find-tags-by-class |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
226 'function (or stream (current-buffer))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
227 (error "No local functions")))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
228 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
229 (defun semantic-read-type (prompt &optional default stream) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
230 "Read a type name from the user for the current buffer. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
231 PROMPT is the prompt to use. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
232 Optional arguments: |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
233 DEFAULT is the default choice. If no default is given, one is read |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
234 from under point. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
235 STREAM is the list of tags to complete from." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
236 (semantic-read-symbol |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
237 prompt default |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
238 (or (semantic-find-tags-by-class |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
239 'type (or stream (current-buffer))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
240 (error "No local types")))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
241 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
242 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
243 ;;; Interactive Functions for |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
244 ;; |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
245 (defun semantic-describe-tag (&optional tag) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
246 "Describe TAG in the minibuffer. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
247 If TAG is nil, describe the tag under the cursor." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
248 (interactive) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
249 (if (not tag) (setq tag (semantic-current-tag))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
250 (semantic-fetch-tags) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
251 (if tag (message (semantic-format-tag-summarize tag)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
252 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
253 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
254 ;;; Putting keys on tags. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
255 ;; |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
256 (defun semantic-add-label (label value &optional tag) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
257 "Add a LABEL with VALUE on TAG. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
258 If TAG is not specified, use the tag at point." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
259 (interactive "sLabel: \nXValue (eval): ") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
260 (if (not tag) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
261 (progn |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
262 (semantic-fetch-tags) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
263 (setq tag (semantic-current-tag)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
264 (semantic--tag-put-property tag (intern label) value) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
265 (message "Added label %s with value %S" label value)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
266 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
267 (defun semantic-show-label (label &optional tag) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
268 "Show the value of LABEL on TAG. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
269 If TAG is not specified, use the tag at point." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
270 (interactive "sLabel: ") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
271 (if (not tag) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
272 (progn |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
273 (semantic-fetch-tags) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
274 (setq tag (semantic-current-tag)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
275 (message "%s: %S" label (semantic--tag-get-property tag (intern label)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
276 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
277 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
278 ;;; Hacks |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
279 ;; |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
280 ;; Some hacks to help me test these functions |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
281 (defun semantic-describe-buffer-var-helper (varsym buffer) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
282 "Display to standard out the value of VARSYM in BUFFER." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
283 (require 'data-debug) |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105760
diff
changeset
|
284 (let ((value (with-current-buffer buffer |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
285 (symbol-value varsym)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
286 (cond |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
287 ((and (consp value) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
288 (< (length value) 10)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
289 ;; Draw the list of things in the list. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
290 (princ (format " %s: #<list of %d items>\n" |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
291 varsym (length value))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
292 (data-debug-insert-stuff-list |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
293 value " " ) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
294 ) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
295 (t |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
296 ;; Else do a one-liner. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
297 (data-debug-insert-thing |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
298 value " " (concat " " (symbol-name varsym) ": ")) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
299 )))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
300 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
301 (defun semantic-describe-buffer () |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
302 "Describe the semantic environment for the current buffer." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
303 (interactive) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
304 (let ((buff (current-buffer)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
305 ) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
306 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
307 (with-output-to-temp-buffer (help-buffer) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
308 (help-setup-xref (list #'semantic-describe-buffer) (interactive-p)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
309 (with-current-buffer standard-output |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
310 (princ "Semantic Configuration in ") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
311 (princ (buffer-name buff)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
312 (princ "\n\n") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
313 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
314 (princ "Buffer specific configuration items:\n") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
315 (let ((vars '(major-mode |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
316 semantic-case-fold |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
317 semantic-expand-nonterminal |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
318 semantic-parser-name |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
319 semantic-parse-tree-state |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
320 semantic-lex-analyzer |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
321 semantic-lex-reset-hooks |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
322 ))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
323 (dolist (V vars) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
324 (semantic-describe-buffer-var-helper V buff))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
325 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
326 (princ "\nGeneral configuration items:\n") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
327 (let ((vars '(semantic-inhibit-functions |
104513
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104508
diff
changeset
|
328 semantic-init-hook |
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104508
diff
changeset
|
329 semantic-init-db-hook |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
330 semantic-unmatched-syntax-hook |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
331 semantic--before-fetch-tags-hook |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
332 semantic-after-toplevel-bovinate-hook |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
333 semantic-after-toplevel-cache-change-hook |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
334 semantic-before-toplevel-cache-flush-hook |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
335 semantic-dump-parse |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
336 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
337 ))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
338 (dolist (V vars) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
339 (semantic-describe-buffer-var-helper V buff))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
340 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
341 (princ "\n\n") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
342 (mode-local-describe-bindings-2 buff) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
343 ))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
344 ) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
345 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
346 (defun semantic-current-tag-interactive (p) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
347 "Display the current token. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
348 Argument P is the point to search from in the current buffer." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
349 (interactive "d") |
104447
273e528a9f9b
* emacs-lisp/autoload.el (generated-autoload-load-name): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
104446
diff
changeset
|
350 (require 'semantic/find) |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
351 (let ((tok (semantic-brute-find-innermost-tag-by-position |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
352 p (current-buffer)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
353 (message (mapconcat 'semantic-abbreviate-nonterminal tok ",")) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
354 (car tok)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
355 ) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
356 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
357 (defun semantic-hack-search () |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
358 "Display info about something under the cursor using generic methods." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
359 (interactive) |
104447
273e528a9f9b
* emacs-lisp/autoload.el (generated-autoload-load-name): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
104446
diff
changeset
|
360 (require 'semantic/find) |
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104519
diff
changeset
|
361 (let ((strm (cdr (semantic-fetch-tags))) |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
362 (res nil)) |
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104519
diff
changeset
|
363 (setq res (semantic-brute-find-tag-by-position (point) strm)) |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
364 (if res |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
365 (progn |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
366 (pop-to-buffer "*SEMANTIC HACK RESULTS*") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
367 (require 'pp) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
368 (erase-buffer) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
369 (insert (pp-to-string res) "\n") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
370 (goto-char (point-min)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
371 (shrink-window-if-larger-than-buffer)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
372 (message "nil")))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
373 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
374 (defun semantic-assert-valid-token (tok) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
375 "Assert that TOK is a valid token." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
376 (if (semantic-tag-p tok) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
377 (if (semantic-tag-with-position-p tok) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
378 (let ((o (semantic-tag-overlay tok))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
379 (if (and (semantic-overlay-p o) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
380 (not (semantic-overlay-live-p o))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
381 (let ((debug-on-error t)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
382 (error "Tag %s is invalid!" (semantic-tag-name tok))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
383 ;; else, tag is OK. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
384 )) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
385 ;; Positionless tags are also ok. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
386 ) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
387 (let ((debug-on-error t)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
388 (error "Not a semantic tag: %S" tok)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
389 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
390 (defun semantic-sanity-check (&optional cache over notfirst) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
391 "Perform a sanity check on the current buffer. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
392 The buffer's set of overlays, and those overlays found via the cache |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
393 are verified against each other. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
394 CACHE, and OVER are the semantic cache, and the overlay list. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
395 NOTFIRST indicates that this was not the first call in the recursive use." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
396 (interactive) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
397 (if (and (not cache) (not over) (not notfirst)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
398 (setq cache semantic--buffer-cache |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
399 over (semantic-overlays-in (point-min) (point-max)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
400 (while cache |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
401 (let ((chil (semantic-tag-components-with-overlays (car cache)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
402 (if (not (memq (semantic-tag-overlay (car cache)) over)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
403 (message "Tag %s not in buffer overlay list." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
404 (semantic-format-tag-concise-prototype (car cache)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
405 (setq over (delq (semantic-tag-overlay (car cache)) over)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
406 (setq over (semantic-sanity-check chil over t)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
407 (setq cache (cdr cache)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
408 (if (not notfirst) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
409 ;; Strip out all overlays which aren't semantic overlays |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
410 (let ((o nil)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
411 (while over |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
412 (when (and (semantic-overlay-get (car over) 'semantic) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
413 (not (eq (semantic-overlay-get (car over) 'semantic) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
414 'unmatched))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
415 (setq o (cons (car over) o))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
416 (setq over (cdr over))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
417 (message "Remaining overlays: %S" o))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
418 over) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
419 |
104508
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
420 ;;; Interactive commands (from Senator). |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
421 |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
422 ;; The Senator library from upstream CEDET is not included in the |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
423 ;; built-in version of Emacs. The plan is to fold it into the |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
424 ;; different parts of CEDET and Emacs, so that it works |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
425 ;; "transparently". Here are some interactive commands based on |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
426 ;; Senator. |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
427 |
104513
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104508
diff
changeset
|
428 ;; Symbol completion |
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104508
diff
changeset
|
429 |
104508
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
430 (defun semantic-find-tag-for-completion (prefix) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
431 "Find all tags with name starting with PREFIX. |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
432 This uses `semanticdb' when available." |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
433 (let (result ctxt) |
104513
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104508
diff
changeset
|
434 ;; Try the Semantic analyzer |
104508
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
435 (condition-case nil |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
436 (and (featurep 'semantic/analyze) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
437 (setq ctxt (semantic-analyze-current-context)) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
438 (setq result (semantic-analyze-possible-completions ctxt))) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
439 (error nil)) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
440 (or result |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
441 ;; If the analyzer fails, then go into boring completion. |
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104519
diff
changeset
|
442 (if (and (featurep 'semantic/db) |
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104519
diff
changeset
|
443 (semanticdb-minor-mode-p) |
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104519
diff
changeset
|
444 (require 'semantic/db-find)) |
104508
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
445 (semanticdb-fast-strip-find-results |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
446 (semanticdb-deep-find-tags-for-completion prefix)) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
447 (semantic-deep-find-tags-for-completion prefix (current-buffer)))))) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
448 |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
449 (defun semantic-complete-symbol (&optional predicate) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
450 "Complete the symbol under point, using Semantic facilities. |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
451 When called from a program, optional arg PREDICATE is a predicate |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
452 determining which symbols are considered." |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
453 (interactive) |
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104519
diff
changeset
|
454 (require 'semantic/ctxt) |
104508
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
455 (let* ((start (car (nth 2 (semantic-ctxt-current-symbol-and-bounds |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
456 (point))))) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
457 (pattern (regexp-quote (buffer-substring start (point)))) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
458 collection completion) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
459 (when start |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
460 (if (and semantic--completion-cache |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
461 (eq (nth 0 semantic--completion-cache) (current-buffer)) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
462 (= (nth 1 semantic--completion-cache) start) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
463 (save-excursion |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
464 (goto-char start) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
465 (looking-at (nth 3 semantic--completion-cache)))) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
466 ;; Use cached value. |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
467 (setq collection (nthcdr 4 semantic--completion-cache)) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
468 ;; Perform new query. |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
469 (setq collection (semantic-find-tag-for-completion pattern)) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
470 (setq semantic--completion-cache |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
471 (append (list (current-buffer) start 0 pattern) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
472 collection)))) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
473 (if (null collection) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
474 (let ((str (if pattern (format " for \"%s\"" pattern) ""))) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
475 (if (window-minibuffer-p (selected-window)) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
476 (minibuffer-message (format " [No completions%s]" str)) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
477 (message "Can't find completion%s" str))) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
478 (setq completion (try-completion pattern collection predicate)) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
479 (if (string= pattern completion) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
480 (let ((list (all-completions pattern collection predicate))) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
481 (setq list (sort list 'string<)) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
482 (if (> (length list) 1) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
483 (with-output-to-temp-buffer "*Completions*" |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
484 (display-completion-list list pattern)) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
485 ;; Bury any out-of-date completions buffer. |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
486 (let ((win (get-buffer-window "*Completions*" 0))) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
487 (if win (with-selected-window win (bury-buffer)))))) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
488 ;; Exact match |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
489 (delete-region start (point)) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
490 (insert completion) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
491 ;; Bury any out-of-date completions buffer. |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
492 (let ((win (get-buffer-window "*Completions*" 0))) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
493 (if win (with-selected-window win (bury-buffer)))))))) |
90ca5d588aa9
* cedet/semantic.el: Add autoloads for semantic/idle functions.
Chong Yidong <cyd@stupidchicken.com>
parents:
104492
diff
changeset
|
494 |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
495 (provide 'semantic/util) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
496 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
497 ;;; Minor modes |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
498 ;; |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
499 (require 'semantic/util-modes) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
500 |
105377 | 501 ;; arch-tag: eaa7808d-83b9-43fe-adf0-4fb742dcb956 |
104446
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104416
diff
changeset
|
502 ;;; semantic/util.el ends here |