Mercurial > emacs
annotate lisp/cedet/semantic/complete.el @ 104493:a4e1a12c8b97
* files.el (auto-mode-alist): Use emacs-lisp-mode for Project.ede.
* cedet/semantic/bovine/gcc.el (semantic-gcc-test-output-parser)
(semantic-gcc-test-output-parser-this-machine):
* cedet/semantic/symref/filter.el (semantic-symref-test-count-hits-in-tag):
* cedet/semantic/db-global.el (semanticdb-test-gnu-global):
* cedet/semantic/tag-write.el (semantic-tag-write-test)
(semantic-tag-write-list-test):
* cedet/semantic/lex-spp.el (semantic-lex-spp-write-test)
(semantic-lex-spp-write-utest):
* cedet/semantic/lex.el (semantic-lex-test-region)
(semantic-lex-test-full-depth):
* cedet/semantic/idle.el (semantic-idle-pnf-test):
* cedet/semantic/fw.el (semantic-test-data-cache)
(semantic-test-throw-on-input):
* cedet/semantic/format.el (semantic-test-all-format-tag-functions):
* cedet/semantic/complete.el (semantic-complete-test):
* cedet/semantic/db-ebrowse.el (semanticdb-ebrowse-run-tests)
(semanticdb-ebrowse-dump): Test functions moved to
semantic-tests.el in the test/ directory.
* cedet/semantic/db-ref.el (semanticdb-ref-test): Doc fix.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 20 Sep 2009 03:44:02 +0000 |
parents | 6ccad1511df1 |
children | bbd7017a25d9 |
rev | line source |
---|---|
104439
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1 ;;; semantic/complete.el --- Routines for performing tag completion |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3 ;;; Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
4 ;;; Free Software Foundation, Inc. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
5 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
6 ;; Author: Eric M. Ludlam <zappo@gnu.org> |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
7 ;; Keywords: syntax |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
8 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
10 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
14 ;; (at your option) any later version. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
15 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
20 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
23 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
24 ;;; Commentary: |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
25 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
26 ;; Completion of tags by name using tables of semantic generated tags. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
27 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
28 ;; While it would be a simple matter of flattening all tag known |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
29 ;; tables to perform completion across them using `all-completions', |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
30 ;; or `try-completion', that process would be slow. In particular, |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
31 ;; when a system database is included in the mix, the potential for a |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
32 ;; ludicrous number of options becomes apparent. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
33 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
34 ;; As such, dynamically searching across tables using a prefix, |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
35 ;; regular expression, or other feature is needed to help find symbols |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
36 ;; quickly without resorting to "show me every possible option now". |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
37 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
38 ;; In addition, some symbol names will appear in multiple locations. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
39 ;; If it is important to distiguish, then a way to provide a choice |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
40 ;; over these locations is important as well. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
41 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
42 ;; Beyond brute force offers for completion of plain strings, |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
43 ;; using the smarts of semantic-analyze to provide reduced lists of |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
44 ;; symbols, or fancy tabbing to zoom into files to show multiple hits |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
45 ;; of the same name can be provided. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
46 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
47 ;;; How it works: |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
48 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
49 ;; There are several parts of any completion engine. They are: |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
50 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
51 ;; A. Collection of possible hits |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
52 ;; B. Typing or selecting an option |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
53 ;; C. Displaying possible unique completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
54 ;; D. Using the result |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
55 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
56 ;; Here, we will treat each section separately (excluding D) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
57 ;; They can then be strung together in user-visible commands to |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
58 ;; fullfill specific needs. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
59 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
60 ;; COLLECTORS: |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
61 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
62 ;; A collector is an object which represents the means by which tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
63 ;; to complete on are collected. It's first job is to find all the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
64 ;; tags which are to be completed against. It can also rename |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
65 ;; some tags if needed so long as `semantic-tag-clone' is used. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
66 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
67 ;; Some collectors will gather all tags to complete against first |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
68 ;; (for in buffer queries, or other small list situations). It may |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
69 ;; choose to do a broad search on each completion request. Built in |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
70 ;; functionality automatically focuses the cache in as the user types. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
71 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
72 ;; A collector choosing to create and rename tags could choose a |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
73 ;; plain name format, a postfix name such as method:class, or a |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
74 ;; prefix name such as class.method. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
75 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
76 ;; DISPLAYORS |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
77 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
78 ;; A displayor is in charge if showing the user interesting things |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
79 ;; about available completions, and can optionally provide a focus. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
80 ;; The simplest display just lists all available names in a separate |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
81 ;; window. It may even choose to show short names when there are |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
82 ;; many to choose from, or long names when there are fewer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
83 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
84 ;; A complex displayor could opt to help the user 'focus' on some |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
85 ;; range. For example, if 4 tags all have the same name, subsequent |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
86 ;; calls to the displayor may opt to show each tag one at a time in |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
87 ;; the buffer. When the user likes one, selection would cause the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
88 ;; 'focus' item to be selected. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
89 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
90 ;; CACHE FORMAT |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
91 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
92 ;; The format of the tag lists used to perform the completions are in |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
93 ;; semanticdb "find" format, like this: |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
94 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
95 ;; ( ( DBTABLE1 TAG1 TAG2 ...) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
96 ;; ( DBTABLE2 TAG1 TAG2 ...) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
97 ;; ... ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
98 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
99 ;; INLINE vs MINIBUFFER |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
100 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
101 ;; Two major ways completion is used in Emacs is either through a |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
102 ;; minibuffer query, or via completion in a normal editing buffer, |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
103 ;; encompassing some small range of characters. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
104 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
105 ;; Structure for both types of completion are provided here. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
106 ;; `semantic-complete-read-tag-engine' will use the minibuffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
107 ;; `semantic-complete-inline-tag-engine' will complete text in |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
108 ;; a buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
109 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
110 (require 'eieio) |
104439
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
111 (require 'eieio-opt) |
104444
2bf481006ba4
lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
104442
diff
changeset
|
112 (require 'semantic) |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
113 (require 'semantic/analyze) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
114 (require 'semantic/ctxt) |
104439
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
115 (require 'semantic/decorate) |
104444
2bf481006ba4
lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
104442
diff
changeset
|
116 (require 'semantic/format) |
104439
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
117 |
104444
2bf481006ba4
lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
104442
diff
changeset
|
118 (eval-when-compile |
2bf481006ba4
lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
104442
diff
changeset
|
119 ;; For the semantic-find-tags-for-completion macro. |
2bf481006ba4
lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
104442
diff
changeset
|
120 (require 'semantic/find)) |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
121 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
122 (eval-when-compile |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
123 (condition-case nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
124 ;; Tooltip not available in older emacsen. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
125 (require 'tooltip) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
126 (error nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
127 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
128 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
129 ;;; Code: |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
130 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
131 ;;; Compatibility |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
132 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
133 (if (fboundp 'minibuffer-contents) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
134 (eval-and-compile (defalias 'semantic-minibuffer-contents 'minibuffer-contents)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
135 (eval-and-compile (defalias 'semantic-minibuffer-contents 'buffer-string))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
136 (if (fboundp 'delete-minibuffer-contents) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
137 (eval-and-compile (defalias 'semantic-delete-minibuffer-contents 'delete-minibuffer-contents)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
138 (eval-and-compile (defalias 'semantic-delete-minibuffer-contents 'erase-buffer))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
139 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
140 (defvar semantic-complete-inline-overlay nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
141 "The overlay currently active while completing inline.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
142 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
143 (defun semantic-completion-inline-active-p () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
144 "Non-nil if inline completion is active." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
145 (when (and semantic-complete-inline-overlay |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
146 (not (semantic-overlay-live-p semantic-complete-inline-overlay))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
147 (semantic-overlay-delete semantic-complete-inline-overlay) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
148 (setq semantic-complete-inline-overlay nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
149 semantic-complete-inline-overlay) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
150 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
151 ;;; ------------------------------------------------------------ |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
152 ;;; MINIBUFFER or INLINE utils |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
153 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
154 (defun semantic-completion-text () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
155 "Return the text that is currently in the completion buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
156 For a minibuffer prompt, this is the minibuffer text. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
157 For inline completion, this is the text wrapped in the inline completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
158 overlay." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
159 (if semantic-complete-inline-overlay |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
160 (semantic-complete-inline-text) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
161 (semantic-minibuffer-contents))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
162 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
163 (defun semantic-completion-delete-text () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
164 "Delete the text that is actively being completed. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
165 Presumably if you call this you will insert something new there." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
166 (if semantic-complete-inline-overlay |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
167 (semantic-complete-inline-delete-text) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
168 (semantic-delete-minibuffer-contents))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
169 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
170 (defun semantic-completion-message (fmt &rest args) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
171 "Display the string FMT formatted with ARGS at the end of the minibuffer." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
172 (if semantic-complete-inline-overlay |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
173 (apply 'message fmt args) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
174 (message (concat (buffer-string) (apply 'format fmt args))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
175 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
176 ;;; ------------------------------------------------------------ |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
177 ;;; MINIBUFFER: Option Selection harnesses |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
178 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
179 (defvar semantic-completion-collector-engine nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
180 "The tag collector for the current completion operation. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
181 Value should be an object of a subclass of |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
182 `semantic-completion-engine-abstract'.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
183 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
184 (defvar semantic-completion-display-engine nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
185 "The tag display engine for the current completion operation. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
186 Value should be a ... what?") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
187 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
188 (defvar semantic-complete-key-map |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
189 (let ((km (make-sparse-keymap))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
190 (define-key km " " 'semantic-complete-complete-space) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
191 (define-key km "\t" 'semantic-complete-complete-tab) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
192 (define-key km "\C-m" 'semantic-complete-done) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
193 (define-key km "\C-g" 'abort-recursive-edit) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
194 (define-key km "\M-n" 'next-history-element) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
195 (define-key km "\M-p" 'previous-history-element) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
196 (define-key km "\C-n" 'next-history-element) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
197 (define-key km "\C-p" 'previous-history-element) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
198 ;; Add history navigation |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
199 km) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
200 "Keymap used while completing across a list of tags.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
201 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
202 (defvar semantic-completion-default-history nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
203 "Default history variable for any unhistoried prompt. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
204 Keeps STRINGS only in the history.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
205 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
206 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
207 (defun semantic-complete-read-tag-engine (collector displayor prompt |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
208 default-tag initial-input |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
209 history) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
210 "Read a semantic tag, and return a tag for the selection. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
211 Argument COLLECTOR is an object which can be used to to calculate |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
212 a list of possible hits. See `semantic-completion-collector-engine' |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
213 for details on COLLECTOR. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
214 Argumeng DISPLAYOR is an object used to display a list of possible |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
215 completions for a given prefix. See`semantic-completion-display-engine' |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
216 for details on DISPLAYOR. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
217 PROMPT is a string to prompt with. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
218 DEFAULT-TAG is a semantic tag or string to use as the default value. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
219 If INITIAL-INPUT is non-nil, insert it in the minibuffer initially. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
220 HISTORY is a symbol representing a variable to story the history in." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
221 (let* ((semantic-completion-collector-engine collector) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
222 (semantic-completion-display-engine displayor) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
223 (semantic-complete-active-default nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
224 (semantic-complete-current-matched-tag nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
225 (default-as-tag (semantic-complete-default-to-tag default-tag)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
226 (default-as-string (when (semantic-tag-p default-as-tag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
227 (semantic-tag-name default-as-tag))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
228 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
229 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
230 (when default-as-string |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
231 ;; Add this to the prompt. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
232 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
233 ;; I really want to add a lookup of the symbol in those |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
234 ;; tags available to the collector and only add it if it |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
235 ;; is available as a possibility, but I'm too lazy right |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
236 ;; now. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
237 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
238 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
239 ;; @todo - move from () to into the editable area |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
240 (if (string-match ":" prompt) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
241 (setq prompt (concat |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
242 (substring prompt 0 (match-beginning 0)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
243 " (" default-as-string ")" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
244 (substring prompt (match-beginning 0)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
245 (setq prompt (concat prompt " (" default-as-string "): ")))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
246 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
247 ;; Perform the Completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
248 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
249 (unwind-protect |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
250 (read-from-minibuffer prompt |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
251 initial-input |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
252 semantic-complete-key-map |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
253 nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
254 (or history |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
255 'semantic-completion-default-history) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
256 default-tag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
257 (semantic-collector-cleanup semantic-completion-collector-engine) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
258 (semantic-displayor-cleanup semantic-completion-display-engine) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
259 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
260 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
261 ;; Extract the tag from the completion machinery. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
262 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
263 semantic-complete-current-matched-tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
264 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
265 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
266 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
267 ;;; Util for basic completion prompts |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
268 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
269 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
270 (defvar semantic-complete-active-default nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
271 "The current default tag calculated for this prompt.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
272 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
273 (defun semantic-complete-default-to-tag (default) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
274 "Convert a calculated or passed in DEFAULT into a tag." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
275 (if (semantic-tag-p default) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
276 ;; Just return what was passed in. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
277 (setq semantic-complete-active-default default) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
278 ;; If none was passed in, guess. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
279 (if (null default) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
280 (setq default (semantic-ctxt-current-thing))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
281 (if (null default) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
282 ;; Do nothing |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
283 nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
284 ;; Turn default into something useful. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
285 (let ((str |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
286 (cond |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
287 ;; Semantic-ctxt-current-symbol will return a list of |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
288 ;; strings. Technically, we should use the analyzer to |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
289 ;; fully extract what we need, but for now, just grab the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
290 ;; first string |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
291 ((and (listp default) (stringp (car default))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
292 (car default)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
293 ((stringp default) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
294 default) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
295 ((symbolp default) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
296 (symbol-name default)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
297 (t |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
298 (signal 'wrong-type-argument |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
299 (list default 'semantic-tag-p))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
300 (tag nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
301 ;; Now that we have that symbol string, look it up using the active |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
302 ;; collector. If we get a match, use it. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
303 (save-excursion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
304 (semantic-collector-calculate-completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
305 semantic-completion-collector-engine |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
306 str nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
307 ;; Do we have the perfect match??? |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
308 (let ((ml (semantic-collector-current-exact-match |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
309 semantic-completion-collector-engine))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
310 (when ml |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
311 ;; We don't care about uniqueness. Just guess for convenience |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
312 (setq tag (semanticdb-find-result-nth-in-buffer ml 0)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
313 ;; save it |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
314 (setq semantic-complete-active-default tag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
315 ;; Return it.. .whatever it may be |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
316 tag)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
317 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
318 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
319 ;;; Prompt Return Value |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
320 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
321 ;; Getting a return value out of this completion prompt is a bit |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
322 ;; challenging. The read command returns the string typed in. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
323 ;; We need to convert this into a valid tag. We can exit the minibuffer |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
324 ;; for different reasons. If we purposely exit, we must make sure |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
325 ;; the focused tag is calculated... preferably once. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
326 (defvar semantic-complete-current-matched-tag nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
327 "Variable used to pass the tags being matched to the prompt.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
328 |
104439
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
329 ;; semantic-displayor-focus-abstract-child-p is part of the |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
330 ;; semantic-displayor-focus-abstract class, defined later in this |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
331 ;; file. |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
332 (declare-function semantic-displayor-focus-abstract-child-p "semantic/complete") |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
333 |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
334 (defun semantic-complete-current-match () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
335 "Calculate a match from the current completion environment. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
336 Save this in our completion variable. Make sure that variable |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
337 is cleared if any other keypress is made. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
338 Return value can be: |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
339 tag - a single tag that has been matched. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
340 string - a message to show in the minibuffer." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
341 ;; Query the environment for an active completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
342 (let ((collector semantic-completion-collector-engine) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
343 (displayor semantic-completion-display-engine) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
344 (contents (semantic-completion-text)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
345 matchlist |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
346 answer) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
347 (if (string= contents "") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
348 ;; The user wants the defaults! |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
349 (setq answer semantic-complete-active-default) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
350 ;; This forces a full calculation of completion on CR. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
351 (save-excursion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
352 (semantic-collector-calculate-completions collector contents nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
353 (semantic-complete-try-completion) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
354 (cond |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
355 ;; Input match displayor focus entry |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
356 ((setq answer (semantic-displayor-current-focus displayor)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
357 ;; We have answer, continue |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
358 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
359 ;; One match from the collector |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
360 ((setq matchlist (semantic-collector-current-exact-match collector)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
361 (if (= (semanticdb-find-result-length matchlist) 1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
362 (setq answer (semanticdb-find-result-nth-in-buffer matchlist 0)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
363 (if (semantic-displayor-focus-abstract-child-p displayor) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
364 ;; For focusing displayors, we can claim this is |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
365 ;; not unique. Multiple focuses can choose the correct |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
366 ;; one. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
367 (setq answer "Not Unique") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
368 ;; If we don't have a focusing displayor, we need to do something |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
369 ;; graceful. First, see if all the matches have the same name. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
370 (let ((allsame t) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
371 (firstname (semantic-tag-name |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
372 (car |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
373 (semanticdb-find-result-nth matchlist 0))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
374 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
375 (cnt 1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
376 (max (semanticdb-find-result-length matchlist))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
377 (while (and allsame (< cnt max)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
378 (if (not (string= |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
379 firstname |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
380 (semantic-tag-name |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
381 (car |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
382 (semanticdb-find-result-nth matchlist cnt))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
383 (setq allsame nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
384 (setq cnt (1+ cnt)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
385 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
386 ;; Now we know if they are all the same. If they are, just |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
387 ;; accept the first, otherwise complain. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
388 (if allsame |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
389 (setq answer (semanticdb-find-result-nth-in-buffer |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
390 matchlist 0)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
391 (setq answer "Not Unique")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
392 )))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
393 ;; No match |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
394 (t |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
395 (setq answer "No Match"))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
396 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
397 ;; Set it into our completion target. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
398 (when (semantic-tag-p answer) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
399 (setq semantic-complete-current-matched-tag answer) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
400 ;; Make sure it is up to date by clearing it if the user dares |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
401 ;; to touch the keyboard. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
402 (add-hook 'pre-command-hook |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
403 (lambda () (setq semantic-complete-current-matched-tag nil))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
404 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
405 ;; Return it |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
406 answer |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
407 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
408 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
409 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
410 ;;; Keybindings |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
411 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
412 ;; Keys are bound to to perform completion using our mechanisms. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
413 ;; Do that work here. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
414 (defun semantic-complete-done () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
415 "Accept the current input." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
416 (interactive) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
417 (let ((ans (semantic-complete-current-match))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
418 (if (stringp ans) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
419 (semantic-completion-message (concat " [" ans "]")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
420 (exit-minibuffer))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
421 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
422 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
423 (defun semantic-complete-complete-space () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
424 "Complete the partial input in the minibuffer." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
425 (interactive) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
426 (semantic-complete-do-completion t)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
427 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
428 (defun semantic-complete-complete-tab () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
429 "Complete the partial input in the minibuffer as far as possible." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
430 (interactive) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
431 (semantic-complete-do-completion)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
432 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
433 ;;; Completion Functions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
434 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
435 ;; Thees routines are functional entry points to performing completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
436 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
437 (defun semantic-complete-hack-word-boundaries (original new) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
438 "Return a string to use for completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
439 ORIGINAL is the text in the minibuffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
440 NEW is the new text to insert into the minibuffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
441 Within the difference bounds of ORIGINAL and NEW, shorten NEW |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
442 to the nearest word boundary, and return that." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
443 (save-match-data |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
444 (let* ((diff (substring new (length original))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
445 (end (string-match "\\>" diff)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
446 (start (string-match "\\<" diff))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
447 (cond |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
448 ((and start (> start 0)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
449 ;; If start is greater than 0, include only the new |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
450 ;; white-space stuff |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
451 (concat original (substring diff 0 start))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
452 (end |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
453 (concat original (substring diff 0 end))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
454 (t new))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
455 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
456 (defun semantic-complete-try-completion (&optional partial) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
457 "Try a completion for the current minibuffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
458 If PARTIAL, do partial completion stopping at spaces." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
459 (let ((comp (semantic-collector-try-completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
460 semantic-completion-collector-engine |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
461 (semantic-completion-text)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
462 (cond |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
463 ((null comp) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
464 (semantic-completion-message " [No Match]") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
465 (ding) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
466 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
467 ((stringp comp) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
468 (if (string= (semantic-completion-text) comp) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
469 (when partial |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
470 ;; Minibuffer isn't changing AND the text is not unique. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
471 ;; Test for partial completion over a word separator character. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
472 ;; If there is one available, use that so that SPC can |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
473 ;; act like a SPC insert key. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
474 (let ((newcomp (semantic-collector-current-whitespace-completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
475 semantic-completion-collector-engine))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
476 (when newcomp |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
477 (semantic-completion-delete-text) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
478 (insert newcomp)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
479 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
480 (when partial |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
481 (let ((orig (semantic-completion-text))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
482 ;; For partial completion, we stop and step over |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
483 ;; word boundaries. Use this nifty function to do |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
484 ;; that calculation for us. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
485 (setq comp |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
486 (semantic-complete-hack-word-boundaries orig comp)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
487 ;; Do the replacement. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
488 (semantic-completion-delete-text) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
489 (insert comp)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
490 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
491 ((and (listp comp) (semantic-tag-p (car comp))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
492 (unless (string= (semantic-completion-text) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
493 (semantic-tag-name (car comp))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
494 ;; A fully unique completion was available. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
495 (semantic-completion-delete-text) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
496 (insert (semantic-tag-name (car comp)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
497 ;; The match is complete |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
498 (if (= (length comp) 1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
499 (semantic-completion-message " [Complete]") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
500 (semantic-completion-message " [Complete, but not unique]")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
501 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
502 (t nil)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
503 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
504 (defun semantic-complete-do-completion (&optional partial inline) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
505 "Do a completion for the current minibuffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
506 If PARTIAL, do partial completion stopping at spaces. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
507 if INLINE, then completion is happening inline in a buffer." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
508 (let* ((collector semantic-completion-collector-engine) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
509 (displayor semantic-completion-display-engine) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
510 (contents (semantic-completion-text)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
511 (ans nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
512 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
513 (save-excursion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
514 (semantic-collector-calculate-completions collector contents partial)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
515 (let* ((na (semantic-complete-next-action partial))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
516 (cond |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
517 ;; We're all done, but only from a very specific |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
518 ;; area of completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
519 ((eq na 'done) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
520 (semantic-completion-message " [Complete]") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
521 (setq ans 'done)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
522 ;; Perform completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
523 ((or (eq na 'complete) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
524 (eq na 'complete-whitespace)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
525 (semantic-complete-try-completion partial) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
526 (setq ans 'complete)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
527 ;; We need to display the completions. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
528 ;; Set the completions into the display engine |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
529 ((or (eq na 'display) (eq na 'displayend)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
530 (semantic-displayor-set-completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
531 displayor |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
532 (or |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
533 (and (not (eq na 'displayend)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
534 (semantic-collector-current-exact-match collector)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
535 (semantic-collector-all-completions collector contents)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
536 contents) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
537 ;; Ask the displayor to display them. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
538 (semantic-displayor-show-request displayor)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
539 ((eq na 'scroll) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
540 (semantic-displayor-scroll-request displayor) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
541 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
542 ((eq na 'focus) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
543 (semantic-displayor-focus-next displayor) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
544 (semantic-displayor-focus-request displayor) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
545 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
546 ((eq na 'empty) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
547 (semantic-completion-message " [No Match]")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
548 (t nil))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
549 ans)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
550 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
551 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
552 ;;; ------------------------------------------------------------ |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
553 ;;; INLINE: tag completion harness |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
554 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
555 ;; Unlike the minibuffer, there is no mode nor other traditional |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
556 ;; means of reading user commands in completion mode. Instead |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
557 ;; we use a pre-command-hook to inset in our commands, and to |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
558 ;; push ourselves out of this mode on alternate keypresses. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
559 (defvar semantic-complete-inline-map |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
560 (let ((km (make-sparse-keymap))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
561 (define-key km "\C-i" 'semantic-complete-inline-TAB) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
562 (define-key km "\M-p" 'semantic-complete-inline-up) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
563 (define-key km "\M-n" 'semantic-complete-inline-down) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
564 (define-key km "\C-m" 'semantic-complete-inline-done) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
565 (define-key km "\C-\M-c" 'semantic-complete-inline-exit) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
566 (define-key km "\C-g" 'semantic-complete-inline-quit) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
567 (define-key km "?" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
568 (lambda () (interactive) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
569 (describe-variable 'semantic-complete-inline-map))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
570 km) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
571 "Keymap used while performing Semantic inline completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
572 \\{semantic-complete-inline-map}") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
573 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
574 (defface semantic-complete-inline-face |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
575 '((((class color) (background dark)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
576 (:underline "yellow")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
577 (((class color) (background light)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
578 (:underline "brown"))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
579 "*Face used to show the region being completed inline. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
580 The face is used in `semantic-complete-inline-tag-engine'." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
581 :group 'semantic-faces) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
582 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
583 (defun semantic-complete-inline-text () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
584 "Return the text that is being completed inline. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
585 Similar to `minibuffer-contents' when completing in the minibuffer." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
586 (let ((s (semantic-overlay-start semantic-complete-inline-overlay)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
587 (e (semantic-overlay-end semantic-complete-inline-overlay))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
588 (if (= s e) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
589 "" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
590 (buffer-substring-no-properties s e )))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
591 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
592 (defun semantic-complete-inline-delete-text () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
593 "Delete the text currently being completed in the current buffer." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
594 (delete-region |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
595 (semantic-overlay-start semantic-complete-inline-overlay) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
596 (semantic-overlay-end semantic-complete-inline-overlay))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
597 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
598 (defun semantic-complete-inline-done () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
599 "This completion thing is DONE, OR, insert a newline." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
600 (interactive) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
601 (let* ((displayor semantic-completion-display-engine) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
602 (tag (semantic-displayor-current-focus displayor))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
603 (if tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
604 (let ((txt (semantic-completion-text))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
605 (insert (substring (semantic-tag-name tag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
606 (length txt))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
607 (semantic-complete-inline-exit)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
608 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
609 ;; Get whatever binding RET usually has. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
610 (let ((fcn |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
611 (condition-case nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
612 (lookup-key (current-active-maps) (this-command-keys)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
613 (error |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
614 ;; I don't know why, but for some reason the above |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
615 ;; throws an error sometimes. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
616 (lookup-key (current-global-map) (this-command-keys)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
617 )))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
618 (when fcn |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
619 (funcall fcn))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
620 ))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
621 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
622 (defun semantic-complete-inline-quit () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
623 "Quit an inline edit." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
624 (interactive) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
625 (semantic-complete-inline-exit) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
626 (keyboard-quit)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
627 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
628 (defun semantic-complete-inline-exit () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
629 "Exit inline completion mode." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
630 (interactive) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
631 ;; Remove this hook FIRST! |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
632 (remove-hook 'pre-command-hook 'semantic-complete-pre-command-hook) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
633 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
634 (condition-case nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
635 (progn |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
636 (when semantic-completion-collector-engine |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
637 (semantic-collector-cleanup semantic-completion-collector-engine)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
638 (when semantic-completion-display-engine |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
639 (semantic-displayor-cleanup semantic-completion-display-engine)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
640 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
641 (when semantic-complete-inline-overlay |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
642 (let ((wc (semantic-overlay-get semantic-complete-inline-overlay |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
643 'window-config-start)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
644 (buf (semantic-overlay-buffer semantic-complete-inline-overlay)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
645 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
646 (semantic-overlay-delete semantic-complete-inline-overlay) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
647 (setq semantic-complete-inline-overlay nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
648 ;; DONT restore the window configuration if we just |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
649 ;; switched windows! |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
650 (when (eq buf (current-buffer)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
651 (set-window-configuration wc)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
652 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
653 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
654 (setq semantic-completion-collector-engine nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
655 semantic-completion-display-engine nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
656 (error nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
657 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
658 ;; Remove this hook LAST!!! |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
659 ;; This will force us back through this function if there was |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
660 ;; some sort of error above. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
661 (remove-hook 'post-command-hook 'semantic-complete-post-command-hook) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
662 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
663 ;;(message "Exiting inline completion.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
664 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
665 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
666 (defun semantic-complete-pre-command-hook () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
667 "Used to redefine what commands are being run while completing. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
668 When installed as a `pre-command-hook' the special keymap |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
669 `semantic-complete-inline-map' is queried to replace commands normally run. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
670 Commands which edit what is in the region of interest operate normally. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
671 Commands which would take us out of the region of interest, or our |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
672 quit hook, will exit this completion mode." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
673 (let ((fcn (lookup-key semantic-complete-inline-map |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
674 (this-command-keys) nil))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
675 (cond ((commandp fcn) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
676 (setq this-command fcn)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
677 (t nil))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
678 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
679 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
680 (defun semantic-complete-post-command-hook () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
681 "Used to determine if we need to exit inline completion mode. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
682 If completion mode is active, check to see if we are within |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
683 the bounds of `semantic-complete-inline-overlay', or within |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
684 a reasonable distance." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
685 (condition-case nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
686 ;; Exit if something bad happened. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
687 (if (not semantic-complete-inline-overlay) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
688 (progn |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
689 ;;(message "Inline Hook installed, but overlay deleted.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
690 (semantic-complete-inline-exit)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
691 ;; Exit if commands caused us to exit the area of interest |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
692 (let ((s (semantic-overlay-start semantic-complete-inline-overlay)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
693 (e (semantic-overlay-end semantic-complete-inline-overlay)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
694 (b (semantic-overlay-buffer semantic-complete-inline-overlay)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
695 (txt nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
696 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
697 (cond |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
698 ;; EXIT when we are no longer in a good place. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
699 ((or (not (eq b (current-buffer))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
700 (< (point) s) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
701 (> (point) e)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
702 ;;(message "Exit: %S %S %S" s e (point)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
703 (semantic-complete-inline-exit) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
704 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
705 ;; Exit if the user typed in a character that is not part |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
706 ;; of the symbol being completed. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
707 ((and (setq txt (semantic-completion-text)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
708 (not (string= txt "")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
709 (and (/= (point) s) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
710 (save-excursion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
711 (forward-char -1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
712 (not (looking-at "\\(\\w\\|\\s_\\)"))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
713 ;;(message "Non symbol character.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
714 (semantic-complete-inline-exit)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
715 ((lookup-key semantic-complete-inline-map |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
716 (this-command-keys) nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
717 ;; If the last command was one of our completion commands, |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
718 ;; then do nothing. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
719 nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
720 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
721 (t |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
722 ;; Else, show completions now |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
723 (semantic-complete-inline-force-display) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
724 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
725 )))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
726 ;; If something goes terribly wrong, clean up after ourselves. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
727 (error (semantic-complete-inline-exit)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
728 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
729 (defun semantic-complete-inline-force-display () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
730 "Force the display of whatever the current completions are. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
731 DO NOT CALL THIS IF THE INLINE COMPLETION ENGINE IS NOT ACTIVE." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
732 (condition-case e |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
733 (save-excursion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
734 (let ((collector semantic-completion-collector-engine) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
735 (displayor semantic-completion-display-engine) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
736 (contents (semantic-completion-text))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
737 (when collector |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
738 (semantic-collector-calculate-completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
739 collector contents nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
740 (semantic-displayor-set-completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
741 displayor |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
742 (semantic-collector-all-completions collector contents) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
743 contents) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
744 ;; Ask the displayor to display them. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
745 (semantic-displayor-show-request displayor)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
746 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
747 (error (message "Bug Showing Completions: %S" e)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
748 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
749 (defun semantic-complete-inline-tag-engine |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
750 (collector displayor buffer start end) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
751 "Perform completion based on semantic tags in a buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
752 Argument COLLECTOR is an object which can be used to to calculate |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
753 a list of possible hits. See `semantic-completion-collector-engine' |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
754 for details on COLLECTOR. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
755 Argumeng DISPLAYOR is an object used to display a list of possible |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
756 completions for a given prefix. See`semantic-completion-display-engine' |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
757 for details on DISPLAYOR. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
758 BUFFER is the buffer in which completion will take place. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
759 START is a location for the start of the full symbol. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
760 If the symbol being completed is \"foo.ba\", then START |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
761 is on the \"f\" character. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
762 END is at the end of the current symbol being completed." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
763 ;; Set us up for doing completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
764 (setq semantic-completion-collector-engine collector |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
765 semantic-completion-display-engine displayor) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
766 ;; Create an overlay |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
767 (setq semantic-complete-inline-overlay |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
768 (semantic-make-overlay start end buffer nil t)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
769 (semantic-overlay-put semantic-complete-inline-overlay |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
770 'face |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
771 'semantic-complete-inline-face) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
772 (semantic-overlay-put semantic-complete-inline-overlay |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
773 'window-config-start |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
774 (current-window-configuration)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
775 ;; Install our command hooks |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
776 (add-hook 'pre-command-hook 'semantic-complete-pre-command-hook) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
777 (add-hook 'post-command-hook 'semantic-complete-post-command-hook) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
778 ;; Go! |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
779 (semantic-complete-inline-force-display) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
780 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
781 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
782 ;;; Inline Completion Keymap Functions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
783 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
784 (defun semantic-complete-inline-TAB () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
785 "Perform inline completion." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
786 (interactive) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
787 (let ((cmpl (semantic-complete-do-completion nil t))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
788 (cond |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
789 ((eq cmpl 'complete) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
790 (semantic-complete-inline-force-display)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
791 ((eq cmpl 'done) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
792 (semantic-complete-inline-done)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
793 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
794 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
795 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
796 (defun semantic-complete-inline-down() |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
797 "Focus forwards through the displayor." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
798 (interactive) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
799 (let ((displayor semantic-completion-display-engine)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
800 (semantic-displayor-focus-next displayor) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
801 (semantic-displayor-focus-request displayor) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
802 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
803 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
804 (defun semantic-complete-inline-up () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
805 "Focus backwards through the displayor." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
806 (interactive) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
807 (let ((displayor semantic-completion-display-engine)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
808 (semantic-displayor-focus-previous displayor) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
809 (semantic-displayor-focus-request displayor) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
810 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
811 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
812 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
813 ;;; ------------------------------------------------------------ |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
814 ;;; Interactions between collection and displaying |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
815 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
816 ;; Functional routines used to help collectors communicate with |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
817 ;; the current displayor, or for the previous section. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
818 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
819 (defun semantic-complete-next-action (partial) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
820 "Determine what the next completion action should be. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
821 PARTIAL is non-nil if we are doing partial completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
822 First, the collector can determine if we should perform a completion or not. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
823 If there is nothing to complete, then the displayor determines if we are |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
824 to show a completion list, scroll, or perhaps do a focus (if it is capable.) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
825 Expected return values are: |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
826 done -> We have a singular match |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
827 empty -> There are no matches to the current text |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
828 complete -> Perform a completion action |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
829 complete-whitespace -> Complete next whitespace type character. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
830 display -> Show the list of completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
831 scroll -> The completions have been shown, and the user keeps hitting |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
832 the complete button. If possible, scroll the completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
833 focus -> The displayor knows how to shift focus among possible completions. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
834 Let it do that. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
835 displayend -> Whatever options the displayor had for repeating options, there |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
836 are none left. Try something new." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
837 (let ((ans1 (semantic-collector-next-action |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
838 semantic-completion-collector-engine |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
839 partial)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
840 (ans2 (semantic-displayor-next-action |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
841 semantic-completion-display-engine)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
842 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
843 (cond |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
844 ;; No collector answer, use displayor answer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
845 ((not ans1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
846 ans2) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
847 ;; Displayor selection of 'scroll, 'display, or 'focus trumps |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
848 ;; 'done |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
849 ((and (eq ans1 'done) ans2) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
850 ans2) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
851 ;; Use ans1 when we have it. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
852 (t |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
853 ans1)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
854 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
855 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
856 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
857 ;;; ------------------------------------------------------------ |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
858 ;;; Collection Engines |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
859 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
860 ;; Collection engines can scan tags from the current environment and |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
861 ;; provide lists of possible completions. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
862 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
863 ;; General features of the abstract collector: |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
864 ;; * Cache completion lists between uses |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
865 ;; * Cache itself per buffer. Handle reparse hooks |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
866 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
867 ;; Key Interface Functions to implement: |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
868 ;; * semantic-collector-next-action |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
869 ;; * semantic-collector-calculate-completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
870 ;; * semantic-collector-try-completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
871 ;; * semantic-collector-all-completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
872 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
873 (defvar semantic-collector-per-buffer-list nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
874 "List of collectors active in this buffer.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
875 (make-variable-buffer-local 'semantic-collector-per-buffer-list) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
876 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
877 (defvar semantic-collector-list nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
878 "List of global collectors active this session.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
879 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
880 (defclass semantic-collector-abstract () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
881 ((buffer :initarg :buffer |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
882 :type buffer |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
883 :documentation "Originating buffer for this collector. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
884 Some collectors use a given buffer as a starting place while looking up |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
885 tags.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
886 (cache :initform nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
887 :type (or null semanticdb-find-result-with-nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
888 :documentation "Cache of tags. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
889 These tags are re-used during a completion session. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
890 Sometimes these tags are cached between completion sessions.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
891 (last-all-completions :initarg nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
892 :type semanticdb-find-result-with-nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
893 :documentation "Last result of `all-completions'. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
894 This result can be used for refined completions as `last-prefix' gets |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
895 closer to a specific result.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
896 (last-prefix :type string |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
897 :protection :protected |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
898 :documentation "The last queried prefix. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
899 This prefix can be used to cache intermediate completion offers. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
900 making the action of homing in on a token faster.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
901 (last-completion :type (or null string) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
902 :documentation "The last calculated completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
903 This completion is calculated and saved for future use.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
904 (last-whitespace-completion :type (or null string) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
905 :documentation "The last whitespace completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
906 For partial completion, SPC will disabiguate over whitespace type |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
907 characters. This is the last calculated version.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
908 (current-exact-match :type list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
909 :protection :protected |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
910 :documentation "The list of matched tags. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
911 When tokens are matched, they are added to this list.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
912 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
913 "Root class for completion engines. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
914 The baseclass provides basic functionality for interacting with |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
915 a completion displayor object, and tracking the current progress |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
916 of a completion." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
917 :abstract t) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
918 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
919 (defmethod semantic-collector-cleanup ((obj semantic-collector-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
920 "Clean up any mess this collector may have." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
921 nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
922 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
923 (defmethod semantic-collector-next-action |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
924 ((obj semantic-collector-abstract) partial) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
925 "What should we do next? OBJ can predict a next good action. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
926 PARTIAL indicates if we are doing a partial completion." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
927 (if (and (slot-boundp obj 'last-completion) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
928 (string= (semantic-completion-text) (oref obj last-completion))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
929 (let* ((cem (semantic-collector-current-exact-match obj)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
930 (cemlen (semanticdb-find-result-length cem)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
931 (cac (semantic-collector-all-completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
932 obj (semantic-completion-text))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
933 (caclen (semanticdb-find-result-length cac))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
934 (cond ((and cem (= cemlen 1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
935 cac (> caclen 1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
936 (eq last-command this-command)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
937 ;; Defer to the displayor... |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
938 nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
939 ((and cem (= cemlen 1)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
940 'done) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
941 ((and (not cem) (not cac)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
942 'empty) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
943 ((and partial (semantic-collector-try-completion-whitespace |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
944 obj (semantic-completion-text))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
945 'complete-whitespace))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
946 'complete)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
947 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
948 (defmethod semantic-collector-last-prefix= ((obj semantic-collector-abstract) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
949 last-prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
950 "Return non-nil if OBJ's prefix matches PREFIX." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
951 (and (slot-boundp obj 'last-prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
952 (string= (oref obj last-prefix) last-prefix))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
953 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
954 (defmethod semantic-collector-get-cache ((obj semantic-collector-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
955 "Get the raw cache of tags for completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
956 Calculate the cache if there isn't one." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
957 (or (oref obj cache) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
958 (semantic-collector-calculate-cache obj))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
959 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
960 (defmethod semantic-collector-calculate-completions-raw |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
961 ((obj semantic-collector-abstract) prefix completionlist) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
962 "Calculate the completions for prefix from completionlist. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
963 Output must be in semanticdb Find result format." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
964 ;; Must output in semanticdb format |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
965 (let ((table (save-excursion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
966 (set-buffer (oref obj buffer)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
967 semanticdb-current-table)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
968 (result (semantic-find-tags-for-completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
969 prefix |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
970 ;; To do this kind of search with a pre-built completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
971 ;; list, we need to strip it first. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
972 (semanticdb-strip-find-results completionlist))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
973 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
974 (if result |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
975 (list (cons table result))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
976 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
977 (defmethod semantic-collector-calculate-completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
978 ((obj semantic-collector-abstract) prefix partial) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
979 "Calculate completions for prefix as setup for other queries." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
980 (let* ((case-fold-search semantic-case-fold) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
981 (same-prefix-p (semantic-collector-last-prefix= obj prefix)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
982 (completionlist |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
983 (if (or same-prefix-p |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
984 (and (slot-boundp obj 'last-prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
985 (eq (compare-strings (oref obj last-prefix) 0 nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
986 prefix 0 (length prefix)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
987 t))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
988 ;; New prefix is subset of old prefix |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
989 (oref obj last-all-completions) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
990 (semantic-collector-get-cache obj))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
991 ;; Get the result |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
992 (answer (if same-prefix-p |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
993 completionlist |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
994 (semantic-collector-calculate-completions-raw |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
995 obj prefix completionlist)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
996 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
997 (completion nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
998 (complete-not-uniq nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
999 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1000 ;;(semanticdb-find-result-test answer) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1001 (when (not same-prefix-p) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1002 ;; Save results if it is interesting and beneficial |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1003 (oset obj last-prefix prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1004 (oset obj last-all-completions answer)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1005 ;; Now calculate the completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1006 (setq completion (try-completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1007 prefix |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1008 (semanticdb-strip-find-results answer))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1009 (oset obj last-whitespace-completion nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1010 (oset obj current-exact-match nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1011 ;; Only do this if a completion was found. Letting a nil in |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1012 ;; could cause a full semanticdb search by accident. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1013 (when completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1014 (oset obj last-completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1015 (cond |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1016 ;; Unique match in AC. Last completion is a match. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1017 ;; Also set the current-exact-match. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1018 ((eq completion t) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1019 (oset obj current-exact-match answer) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1020 prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1021 ;; It may be complete (a symbol) but still not unique. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1022 ;; We can capture a match |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1023 ((setq complete-not-uniq |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1024 (semanticdb-find-tags-by-name |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1025 prefix |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1026 answer)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1027 (oset obj current-exact-match |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1028 complete-not-uniq) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1029 prefix |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1030 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1031 ;; Non unique match, return the string that handles |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1032 ;; completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1033 (t (or completion prefix)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1034 ))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1035 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1036 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1037 (defmethod semantic-collector-try-completion-whitespace |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1038 ((obj semantic-collector-abstract) prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1039 "For OBJ, do whatepsace completion based on PREFIX. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1040 This implies that if there are two completions, one matching |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1041 the test \"preifx\\>\", and one not, the one matching the full |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1042 word version of PREFIX will be chosen, and that text returned. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1043 This function requires that `semantic-collector-calculate-completions' |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1044 has been run first." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1045 (let* ((ac (semantic-collector-all-completions obj prefix)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1046 (matchme (concat "^" prefix "\\>")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1047 (compare (semanticdb-find-tags-by-name-regexp matchme ac)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1048 (numtag (semanticdb-find-result-length compare)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1049 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1050 (if compare |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1051 (let* ((idx 0) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1052 (cutlen (1+ (length prefix))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1053 (twws (semanticdb-find-result-nth compare idx))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1054 ;; Is our tag with whitespace a match that has whitespace |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1055 ;; after it, or just an already complete symbol? |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1056 (while (and (< idx numtag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1057 (< (length (semantic-tag-name (car twws))) cutlen)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1058 (setq idx (1+ idx) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1059 twws (semanticdb-find-result-nth compare idx))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1060 (when (and twws (car-safe twws)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1061 ;; If COMPARE has succeeded, then we should take the very |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1062 ;; first match, and extend prefix by one character. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1063 (oset obj last-whitespace-completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1064 (substring (semantic-tag-name (car twws)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1065 0 cutlen)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1066 ))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1067 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1068 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1069 (defmethod semantic-collector-current-exact-match ((obj semantic-collector-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1070 "Return the active valid MATCH from the semantic collector. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1071 For now, just return the first element from our list of available |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1072 matches. For semanticdb based results, make sure the file is loaded |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1073 into a buffer." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1074 (when (slot-boundp obj 'current-exact-match) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1075 (oref obj current-exact-match))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1076 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1077 (defmethod semantic-collector-current-whitespace-completion ((obj semantic-collector-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1078 "Return the active whitespace completion value." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1079 (when (slot-boundp obj 'last-whitespace-completion) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1080 (oref obj last-whitespace-completion))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1081 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1082 (defmethod semantic-collector-get-match ((obj semantic-collector-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1083 "Return the active valid MATCH from the semantic collector. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1084 For now, just return the first element from our list of available |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1085 matches. For semanticdb based results, make sure the file is loaded |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1086 into a buffer." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1087 (when (slot-boundp obj 'current-exact-match) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1088 (semanticdb-find-result-nth-in-buffer (oref obj current-exact-match) 0))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1089 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1090 (defmethod semantic-collector-all-completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1091 ((obj semantic-collector-abstract) prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1092 "For OBJ, retrieve all completions matching PREFIX. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1093 The returned list consists of all the tags currently |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1094 matching PREFIX." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1095 (when (slot-boundp obj 'last-all-completions) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1096 (oref obj last-all-completions))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1097 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1098 (defmethod semantic-collector-try-completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1099 ((obj semantic-collector-abstract) prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1100 "For OBJ, attempt to match PREFIX. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1101 See `try-completion' for details on how this works. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1102 Return nil for no match. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1103 Return a string for a partial match. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1104 For a unique match of PREFIX, return the list of all tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1105 with that name." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1106 (if (slot-boundp obj 'last-completion) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1107 (oref obj last-completion))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1108 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1109 (defmethod semantic-collector-calculate-cache |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1110 ((obj semantic-collector-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1111 "Calculate the completion cache for OBJ." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1112 nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1113 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1114 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1115 (defmethod semantic-collector-flush ((this semantic-collector-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1116 "Flush THIS collector object, clearing any caches and prefix." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1117 (oset this cache nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1118 (slot-makeunbound this 'last-prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1119 (slot-makeunbound this 'last-completion) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1120 (slot-makeunbound this 'last-all-completions) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1121 (slot-makeunbound this 'current-exact-match) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1122 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1123 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1124 ;;; PER BUFFER |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1125 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1126 (defclass semantic-collector-buffer-abstract (semantic-collector-abstract) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1127 () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1128 "Root class for per-buffer completion engines. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1129 These collectors track themselves on a per-buffer basis." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1130 :abstract t) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1131 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1132 (defmethod constructor :STATIC ((this semantic-collector-buffer-abstract) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1133 newname &rest fields) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1134 "Reuse previously created objects of this type in buffer." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1135 (let ((old nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1136 (bl semantic-collector-per-buffer-list)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1137 (while (and bl (null old)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1138 (if (eq (object-class (car bl)) this) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1139 (setq old (car bl)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1140 (unless old |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1141 (let ((new (call-next-method))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1142 (add-to-list 'semantic-collector-per-buffer-list new) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1143 (setq old new))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1144 (slot-makeunbound old 'last-completion) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1145 (slot-makeunbound old 'last-prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1146 (slot-makeunbound old 'current-exact-match) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1147 old)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1148 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1149 ;; Buffer specific collectors should flush themselves |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1150 (defun semantic-collector-buffer-flush (newcache) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1151 "Flush all buffer collector objects. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1152 NEWCACHE is the new tag table, but we ignore it." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1153 (condition-case nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1154 (let ((l semantic-collector-per-buffer-list)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1155 (while l |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1156 (if (car l) (semantic-collector-flush (car l))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1157 (setq l (cdr l)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1158 (error nil))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1159 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1160 (add-hook 'semantic-after-toplevel-cache-change-hook |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1161 'semantic-collector-buffer-flush) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1162 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1163 ;;; DEEP BUFFER SPECIFIC COMPLETION |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1164 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1165 (defclass semantic-collector-buffer-deep |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1166 (semantic-collector-buffer-abstract) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1167 () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1168 "Completion engine for tags in the current buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1169 When searching for a tag, uses semantic deep searche functions. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1170 Basics search only in the current buffer.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1171 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1172 (defmethod semantic-collector-calculate-cache |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1173 ((obj semantic-collector-buffer-deep)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1174 "Calculate the completion cache for OBJ. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1175 Uses `semantic-flatten-tags-table'" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1176 (oset obj cache |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1177 ;; Must create it in SEMANTICDB find format. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1178 ;; ( ( DBTABLE TAG TAG ... ) ... ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1179 (list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1180 (cons semanticdb-current-table |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1181 (semantic-flatten-tags-table (oref obj buffer)))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1182 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1183 ;;; PROJECT SPECIFIC COMPLETION |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1184 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1185 (defclass semantic-collector-project-abstract (semantic-collector-abstract) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1186 ((path :initarg :path |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1187 :initform nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1188 :documentation "List of database tables to search. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1189 At creation time, it can be anything accepted by |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1190 `semanticdb-find-translate-path' as a PATH argument.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1191 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1192 "Root class for project wide completion engines. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1193 Uses semanticdb for searching all tags in the current project." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1194 :abstract t) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1195 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1196 ;;; Project Search |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1197 (defclass semantic-collector-project (semantic-collector-project-abstract) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1198 () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1199 "Completion engine for tags in a project.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1200 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1201 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1202 (defmethod semantic-collector-calculate-completions-raw |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1203 ((obj semantic-collector-project) prefix completionlist) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1204 "Calculate the completions for prefix from completionlist." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1205 (semanticdb-find-tags-for-completion prefix (oref obj path))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1206 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1207 ;;; Brutish Project search |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1208 (defclass semantic-collector-project-brutish (semantic-collector-project-abstract) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1209 () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1210 "Completion engine for tags in a project.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1211 |
104444
2bf481006ba4
lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
104442
diff
changeset
|
1212 (declare-function semanticdb-brute-deep-find-tags-for-completion |
2bf481006ba4
lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
104442
diff
changeset
|
1213 "semantic/db-find") |
2bf481006ba4
lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
104442
diff
changeset
|
1214 |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1215 (defmethod semantic-collector-calculate-completions-raw |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1216 ((obj semantic-collector-project-brutish) prefix completionlist) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1217 "Calculate the completions for prefix from completionlist." |
104444
2bf481006ba4
lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
104442
diff
changeset
|
1218 (require 'semantic/db-find) |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1219 (semanticdb-brute-deep-find-tags-for-completion prefix (oref obj path))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1220 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1221 (defclass semantic-collector-analyze-completions (semantic-collector-abstract) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1222 ((context :initarg :context |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1223 :type semantic-analyze-context |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1224 :documentation "An analysis context. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1225 Specifies some context location from whence completion lists will be drawn." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1226 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1227 (first-pass-completions :type list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1228 :documentation "List of valid completion tags. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1229 This list of tags is generated when completion starts. All searches |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1230 derive from this list.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1231 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1232 "Completion engine that uses the context analyzer to provide options. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1233 The only options available for completion are those which can be logically |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1234 inserted into the current context.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1235 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1236 (defmethod semantic-collector-calculate-completions-raw |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1237 ((obj semantic-collector-analyze-completions) prefix completionlist) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1238 "calculate the completions for prefix from completionlist." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1239 ;; if there are no completions yet, calculate them. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1240 (if (not (slot-boundp obj 'first-pass-completions)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1241 (oset obj first-pass-completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1242 (semantic-analyze-possible-completions (oref obj context)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1243 ;; search our cached completion list. make it look like a semanticdb |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1244 ;; results type. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1245 (list (cons (save-excursion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1246 (set-buffer (oref (oref obj context) buffer)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1247 semanticdb-current-table) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1248 (semantic-find-tags-for-completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1249 prefix |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1250 (oref obj first-pass-completions))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1251 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1252 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1253 ;;; ------------------------------------------------------------ |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1254 ;;; Tag List Display Engines |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1255 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1256 ;; A typical displayor accepts a pre-determined list of completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1257 ;; generated by a collector. This format is in semanticdb search |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1258 ;; form. This vaguely standard form is a bit challenging to navigate |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1259 ;; because the tags do not contain buffer info, but the file assocated |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1260 ;; with the tags preceed the tag in the list. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1261 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1262 ;; Basic displayors don't care, and can strip the results. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1263 ;; Advanced highlighting displayors need to know when they need |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1264 ;; to load a file so that the tag in question can be highlighted. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1265 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1266 ;; Key interface methods to a displayor are: |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1267 ;; * semantic-displayor-next-action |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1268 ;; * semantic-displayor-set-completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1269 ;; * semantic-displayor-current-focus |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1270 ;; * semantic-displayor-show-request |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1271 ;; * semantic-displayor-scroll-request |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1272 ;; * semantic-displayor-focus-request |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1273 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1274 (defclass semantic-displayor-abstract () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1275 ((table :type (or null semanticdb-find-result-with-nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1276 :initform nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1277 :protection :protected |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1278 :documentation "List of tags this displayor is showing.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1279 (last-prefix :type string |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1280 :protection :protected |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1281 :documentation "Prefix associated with slot `table'") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1282 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1283 "Abstract displayor baseclass. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1284 Manages the display of some number of tags. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1285 Provides the basics for a displayor, including interacting with |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1286 a collector, and tracking tables of completion to display." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1287 :abstract t) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1288 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1289 (defmethod semantic-displayor-cleanup ((obj semantic-displayor-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1290 "Clean up any mess this displayor may have." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1291 nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1292 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1293 (defmethod semantic-displayor-next-action ((obj semantic-displayor-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1294 "The next action to take on the minibuffer related to display." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1295 (if (and (slot-boundp obj 'last-prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1296 (string= (oref obj last-prefix) (semantic-completion-text)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1297 (eq last-command this-command)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1298 'scroll |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1299 'display)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1300 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1301 (defmethod semantic-displayor-set-completions ((obj semantic-displayor-abstract) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1302 table prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1303 "Set the list of tags to be completed over to TABLE." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1304 (oset obj table table) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1305 (oset obj last-prefix prefix)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1306 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1307 (defmethod semantic-displayor-show-request ((obj semantic-displayor-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1308 "A request to show the current tags table." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1309 (ding)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1310 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1311 (defmethod semantic-displayor-focus-request ((obj semantic-displayor-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1312 "A request to for the displayor to focus on some tag option." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1313 (ding)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1314 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1315 (defmethod semantic-displayor-scroll-request ((obj semantic-displayor-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1316 "A request to for the displayor to scroll the completion list (if needed)." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1317 (scroll-other-window)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1318 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1319 (defmethod semantic-displayor-focus-previous ((obj semantic-displayor-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1320 "Set the current focus to the previous item." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1321 nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1322 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1323 (defmethod semantic-displayor-focus-next ((obj semantic-displayor-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1324 "Set the current focus to the next item." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1325 nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1326 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1327 (defmethod semantic-displayor-current-focus ((obj semantic-displayor-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1328 "Return a single tag currently in focus. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1329 This object type doesn't do focus, so will never have a focus object." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1330 nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1331 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1332 ;; Traditional displayor |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1333 (defcustom semantic-completion-displayor-format-tag-function |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1334 #'semantic-format-tag-name |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1335 "*A Tag format function to use when showing completions." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1336 :group 'semantic |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1337 :type semantic-format-tag-custom-list) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1338 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1339 (defclass semantic-displayor-traditional (semantic-displayor-abstract) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1340 () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1341 "Display options in *Completions* buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1342 Traditional display mechanism for a list of possible completions. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1343 Completions are showin in a new buffer and listed with the ability |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1344 to click on the items to aid in completion.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1345 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1346 (defmethod semantic-displayor-show-request ((obj semantic-displayor-traditional)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1347 "A request to show the current tags table." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1348 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1349 ;; NOTE TO SELF. Find the character to type next, and emphesize it. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1350 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1351 (with-output-to-temp-buffer "*Completions*" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1352 (display-completion-list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1353 (mapcar semantic-completion-displayor-format-tag-function |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1354 (semanticdb-strip-find-results (oref obj table)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1355 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1356 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1357 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1358 ;;; Abstract baseclass for any displayor which supports focus |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1359 (defclass semantic-displayor-focus-abstract (semantic-displayor-abstract) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1360 ((focus :type number |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1361 :protection :protected |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1362 :documentation "A tag index from `table' which has focus. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1363 Multiple calls to the display function can choose to focus on a |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1364 given tag, by highlighting its location.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1365 (find-file-focus |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1366 :allocation :class |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1367 :initform nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1368 :documentation |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1369 "Non-nil if focusing requires a tag's buffer be in memory.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1370 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1371 "Abstract displayor supporting `focus'. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1372 A displayor which has the ability to focus in on one tag. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1373 Focusing is a way of differentiationg between multiple tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1374 which have the same name." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1375 :abstract t) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1376 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1377 (defmethod semantic-displayor-next-action ((obj semantic-displayor-focus-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1378 "The next action to take on the minibuffer related to display." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1379 (if (and (slot-boundp obj 'last-prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1380 (string= (oref obj last-prefix) (semantic-completion-text)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1381 (eq last-command this-command)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1382 (if (and |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1383 (slot-boundp obj 'focus) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1384 (slot-boundp obj 'table) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1385 (<= (semanticdb-find-result-length (oref obj table)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1386 (1+ (oref obj focus)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1387 ;; We are at the end of the focus road. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1388 'displayend |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1389 ;; Focus on some item. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1390 'focus) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1391 'display)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1392 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1393 (defmethod semantic-displayor-set-completions ((obj semantic-displayor-focus-abstract) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1394 table prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1395 "Set the list of tags to be completed over to TABLE." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1396 (call-next-method) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1397 (slot-makeunbound obj 'focus)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1398 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1399 (defmethod semantic-displayor-focus-previous ((obj semantic-displayor-focus-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1400 "Set the current focus to the previous item. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1401 Not meaningful return value." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1402 (when (and (slot-boundp obj 'table) (oref obj table)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1403 (with-slots (table) obj |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1404 (if (or (not (slot-boundp obj 'focus)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1405 (<= (oref obj focus) 0)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1406 (oset obj focus (1- (semanticdb-find-result-length table))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1407 (oset obj focus (1- (oref obj focus))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1408 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1409 ))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1410 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1411 (defmethod semantic-displayor-focus-next ((obj semantic-displayor-focus-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1412 "Set the current focus to the next item. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1413 Not meaningful return value." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1414 (when (and (slot-boundp obj 'table) (oref obj table)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1415 (with-slots (table) obj |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1416 (if (not (slot-boundp obj 'focus)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1417 (oset obj focus 0) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1418 (oset obj focus (1+ (oref obj focus))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1419 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1420 (if (<= (semanticdb-find-result-length table) (oref obj focus)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1421 (oset obj focus 0)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1422 ))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1423 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1424 (defmethod semantic-displayor-focus-tag ((obj semantic-displayor-focus-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1425 "Return the next tag OBJ should focus on." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1426 (when (and (slot-boundp obj 'table) (oref obj table)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1427 (with-slots (table) obj |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1428 (semanticdb-find-result-nth table (oref obj focus))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1429 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1430 (defmethod semantic-displayor-current-focus ((obj semantic-displayor-focus-abstract)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1431 "Return the tag currently in focus, or call parent method." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1432 (if (and (slot-boundp obj 'focus) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1433 (slot-boundp obj 'table) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1434 ;; Only return the current focus IFF the minibuffer reflects |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1435 ;; the list this focus was derived from. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1436 (slot-boundp obj 'last-prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1437 (string= (semantic-completion-text) (oref obj last-prefix)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1438 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1439 ;; We need to focus |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1440 (if (oref obj find-file-focus) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1441 (semanticdb-find-result-nth-in-buffer (oref obj table) (oref obj focus)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1442 ;; result-nth returns a cons with car being the tag, and cdr the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1443 ;; database. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1444 (car (semanticdb-find-result-nth (oref obj table) (oref obj focus)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1445 ;; Do whatever |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1446 (call-next-method))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1447 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1448 ;;; Simple displayor which performs traditional display completion, |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1449 ;; and also focuses with highlighting. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1450 (defclass semantic-displayor-traditional-with-focus-highlight |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1451 (semantic-displayor-focus-abstract semantic-displayor-traditional) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1452 ((find-file-focus :initform t)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1453 "Display completions in *Completions* buffer, with focus highlight. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1454 A traditional displayor which can focus on a tag by showing it. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1455 Same as `semantic-displayor-traditional', but with selection between |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1456 multiple tags with the same name done by 'focusing' on the source |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1457 location of the different tags to differentiate them.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1458 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1459 (defmethod semantic-displayor-focus-request |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1460 ((obj semantic-displayor-traditional-with-focus-highlight)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1461 "Focus in on possible tag completions. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1462 Focus is performed by cycling through the tags and highlighting |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1463 one in the source buffer." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1464 (let* ((tablelength (semanticdb-find-result-length (oref obj table))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1465 (focus (semantic-displayor-focus-tag obj)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1466 ;; Raw tag info. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1467 (rtag (car focus)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1468 (rtable (cdr focus)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1469 ;; Normalize |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1470 (nt (semanticdb-normalize-one-tag rtable rtag)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1471 (tag (cdr nt)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1472 (table (car nt)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1473 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1474 ;; If we fail to normalize, resete. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1475 (when (not tag) (setq table rtable tag rtag)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1476 ;; Do the focus. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1477 (let ((buf (or (semantic-tag-buffer tag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1478 (and table (semanticdb-get-buffer table))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1479 ;; If no buffer is provided, then we can make up a summary buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1480 (when (not buf) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1481 (save-excursion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1482 (set-buffer (get-buffer-create "*Completion Focus*")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1483 (erase-buffer) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1484 (insert "Focus on tag: \n") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1485 (insert (semantic-format-tag-summarize tag nil t) "\n\n") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1486 (when table |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1487 (insert "From table: \n") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1488 (insert (object-name table) "\n\n")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1489 (when buf |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1490 (insert "In buffer: \n\n") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1491 (insert (format "%S" buf))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1492 (setq buf (current-buffer)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1493 ;; Show the tag in the buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1494 (if (get-buffer-window buf) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1495 (select-window (get-buffer-window buf)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1496 (switch-to-buffer-other-window buf t) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1497 (select-window (get-buffer-window buf))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1498 ;; Now do some positioning |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1499 (unwind-protect |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1500 (if (semantic-tag-with-position-p tag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1501 ;; Full tag positional information available |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1502 (progn |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1503 (goto-char (semantic-tag-start tag)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1504 ;; This avoids a dangerous problem if we just loaded a tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1505 ;; from a file, but the original position was not updated |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1506 ;; in the TAG variable we are currently using. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1507 (semantic-momentary-highlight-tag (semantic-current-tag)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1508 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1509 (select-window (minibuffer-window))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1510 ;; Calculate text difference between contents and the focus item. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1511 (let* ((mbc (semantic-completion-text)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1512 (ftn (semantic-tag-name tag)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1513 (diff (substring ftn (length mbc)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1514 (semantic-completion-message |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1515 (format "%s [%d of %d matches]" diff (1+ (oref obj focus)) tablelength))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1516 ))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1517 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1518 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1519 ;;; Tooltip completion lister |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1520 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1521 ;; Written and contributed by Masatake YAMATO <jet@gyve.org> |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1522 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1523 ;; Modified by Eric Ludlam for |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1524 ;; * Safe compatibility for tooltip free systems. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1525 ;; * Don't use 'avoid package for tooltip positioning. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1526 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1527 (defclass semantic-displayor-tooltip (semantic-displayor-traditional) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1528 ((max-tags :type integer |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1529 :initarg :max-tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1530 :initform 5 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1531 :custom integer |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1532 :documentation |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1533 "Max number of tags displayed on tooltip at once. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1534 If `force-show' is 1, this value is ignored with typing tab or space twice continuously. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1535 if `force-show' is 0, this value is always ignored.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1536 (force-show :type integer |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1537 :initarg :force-show |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1538 :initform 1 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1539 :custom (choice (const |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1540 :tag "Show when double typing" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1541 1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1542 (const |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1543 :tag "Show always" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1544 0) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1545 (const |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1546 :tag "Show if the number of tags is less than `max-tags'." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1547 -1)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1548 :documentation |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1549 "Control the behavior of the number of tags is greater than `max-tags'. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1550 -1 means tags are never shown. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1551 0 means the tags are always shown. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1552 1 means tags are shown if space or tab is typed twice continuously.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1553 (typing-count :type integer |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1554 :initform 0 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1555 :documentation |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1556 "Counter holding how many times the user types space or tab continuously before showing tags.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1557 (shown :type boolean |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1558 :initform nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1559 :documentation |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1560 "Flag representing whether tags is shown once or not.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1561 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1562 "Display completions options in a tooltip. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1563 Display mechanism using tooltip for a list of possible completions.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1564 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1565 (defmethod initialize-instance :AFTER ((obj semantic-displayor-tooltip) &rest args) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1566 "Make sure we have tooltips required." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1567 (condition-case nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1568 (require 'tooltip) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1569 (error nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1570 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1571 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1572 (defmethod semantic-displayor-show-request ((obj semantic-displayor-tooltip)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1573 "A request to show the current tags table." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1574 (if (or (not (featurep 'tooltip)) (not tooltip-mode)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1575 ;; If we cannot use tooltips, then go to the normal mode with |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1576 ;; a traditional completion buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1577 (call-next-method) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1578 (let* ((tablelong (semanticdb-strip-find-results (oref obj table))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1579 (table (semantic-unique-tag-table-by-name tablelong)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1580 (l (mapcar semantic-completion-displayor-format-tag-function table)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1581 (ll (length l)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1582 (typing-count (oref obj typing-count)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1583 (force-show (oref obj force-show)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1584 (matchtxt (semantic-completion-text)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1585 msg) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1586 (if (or (oref obj shown) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1587 (< ll (oref obj max-tags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1588 (and (<= 0 force-show) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1589 (< (1- force-show) typing-count))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1590 (progn |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1591 (oset obj typing-count 0) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1592 (oset obj shown t) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1593 (if (eq 1 ll) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1594 ;; We Have only one possible match. There could be two cases. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1595 ;; 1) input text != single match. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1596 ;; --> Show it! |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1597 ;; 2) input text == single match. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1598 ;; --> Complain about it, but still show the match. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1599 (if (string= matchtxt (semantic-tag-name (car table))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1600 (setq msg (concat "[COMPLETE]\n" (car l))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1601 (setq msg (car l))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1602 ;; Create the long message. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1603 (setq msg (mapconcat 'identity l "\n")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1604 ;; If there is nothing, say so! |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1605 (if (eq 0 (length msg)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1606 (setq msg "[NO MATCH]"))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1607 (semantic-displayor-tooltip-show msg)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1608 ;; The typing count determines if the user REALLY REALLY |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1609 ;; wanted to show that much stuff. Only increment |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1610 ;; if the current command is a completion command. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1611 (if (and (stringp (this-command-keys)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1612 (string= (this-command-keys) "\C-i")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1613 (oset obj typing-count (1+ typing-count))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1614 ;; At this point, we know we have too many items. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1615 ;; Lets be brave, and truncate l |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1616 (setcdr (nthcdr (oref obj max-tags) l) nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1617 (setq msg (mapconcat 'identity l "\n")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1618 (cond |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1619 ((= force-show -1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1620 (semantic-displayor-tooltip-show (concat msg "\n..."))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1621 ((= force-show 1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1622 (semantic-displayor-tooltip-show (concat msg "\n(TAB for more)"))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1623 ))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1624 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1625 ;;; Compatibility |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1626 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1627 (eval-and-compile |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1628 (if (fboundp 'window-inside-edges) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1629 ;; Emacs devel. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1630 (defalias 'semantic-displayor-window-edges |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1631 'window-inside-edges) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1632 ;; Emacs 21 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1633 (defalias 'semantic-displayor-window-edges |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1634 'window-edges) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1635 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1636 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1637 (defun semantic-displayor-point-position () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1638 "Return the location of POINT as positioned on the selected frame. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1639 Return a cons cell (X . Y)" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1640 (let* ((frame (selected-frame)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1641 (left (frame-parameter frame 'left)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1642 (top (frame-parameter frame 'top)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1643 (point-pix-pos (posn-x-y (posn-at-point))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1644 (edges (window-inside-pixel-edges (selected-window)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1645 (cons (+ (car point-pix-pos) (car edges) left) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1646 (+ (cdr point-pix-pos) (cadr edges) top)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1647 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1648 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1649 (defun semantic-displayor-tooltip-show (text) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1650 "Display a tooltip with TEXT near cursor." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1651 (let ((point-pix-pos (semantic-displayor-point-position)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1652 (tooltip-frame-parameters |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1653 (append tooltip-frame-parameters nil))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1654 (push |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1655 (cons 'left (+ (car point-pix-pos) (frame-char-width))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1656 tooltip-frame-parameters) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1657 (push |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1658 (cons 'top (+ (cdr point-pix-pos) (frame-char-height))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1659 tooltip-frame-parameters) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1660 (tooltip-show text))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1661 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1662 (defmethod semantic-displayor-scroll-request ((obj semantic-displayor-tooltip)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1663 "A request to for the displayor to scroll the completion list (if needed)." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1664 ;; Do scrolling in the tooltip. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1665 (oset obj max-tags 30) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1666 (semantic-displayor-show-request obj) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1667 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1668 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1669 ;; End code contributed by Masatake YAMATO <jet@gyve.org> |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1670 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1671 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1672 ;;; Ghost Text displayor |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1673 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1674 (defclass semantic-displayor-ghost (semantic-displayor-focus-abstract) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1675 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1676 ((ghostoverlay :type overlay |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1677 :documentation |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1678 "The overlay the ghost text is displayed in.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1679 (first-show :initform t |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1680 :documentation |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1681 "Non nil if we have not seen our first show request.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1682 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1683 "Cycle completions inline with ghost text. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1684 Completion displayor using ghost chars after point for focus options. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1685 Whichever completion is currently in focus will be displayed as ghost |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1686 text using overlay options.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1687 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1688 (defmethod semantic-displayor-next-action ((obj semantic-displayor-ghost)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1689 "The next action to take on the inline completion related to display." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1690 (let ((ans (call-next-method)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1691 (table (when (slot-boundp obj 'table) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1692 (oref obj table)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1693 (if (and (eq ans 'displayend) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1694 table |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1695 (= (semanticdb-find-result-length table) 1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1696 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1697 nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1698 ans))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1699 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1700 (defmethod semantic-displayor-cleanup ((obj semantic-displayor-ghost)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1701 "Clean up any mess this displayor may have." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1702 (when (slot-boundp obj 'ghostoverlay) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1703 (semantic-overlay-delete (oref obj ghostoverlay))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1704 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1705 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1706 (defmethod semantic-displayor-set-completions ((obj semantic-displayor-ghost) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1707 table prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1708 "Set the list of tags to be completed over to TABLE." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1709 (call-next-method) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1710 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1711 (semantic-displayor-cleanup obj) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1712 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1713 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1714 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1715 (defmethod semantic-displayor-show-request ((obj semantic-displayor-ghost)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1716 "A request to show the current tags table." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1717 ; (if (oref obj first-show) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1718 ; (progn |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1719 ; (oset obj first-show nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1720 (semantic-displayor-focus-next obj) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1721 (semantic-displayor-focus-request obj) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1722 ; ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1723 ;; Only do the traditional thing if the first show request |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1724 ;; has been seen. Use the first one to start doing the ghost |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1725 ;; text display. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1726 ; (call-next-method) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1727 ; ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1728 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1729 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1730 (defmethod semantic-displayor-focus-request |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1731 ((obj semantic-displayor-ghost)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1732 "Focus in on possible tag completions. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1733 Focus is performed by cycling through the tags and showing a possible |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1734 completion text in ghost text." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1735 (let* ((tablelength (semanticdb-find-result-length (oref obj table))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1736 (focus (semantic-displayor-focus-tag obj)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1737 (tag (car focus)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1738 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1739 (if (not tag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1740 (semantic-completion-message "No tags to focus on.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1741 ;; Display the focus completion as ghost text after the current |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1742 ;; inline text. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1743 (when (or (not (slot-boundp obj 'ghostoverlay)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1744 (not (semantic-overlay-live-p (oref obj ghostoverlay)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1745 (oset obj ghostoverlay |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1746 (semantic-make-overlay (point) (1+ (point)) (current-buffer) t))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1747 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1748 (let* ((lp (semantic-completion-text)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1749 (os (substring (semantic-tag-name tag) (length lp))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1750 (ol (oref obj ghostoverlay)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1751 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1752 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1753 (put-text-property 0 (length os) 'face 'region os) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1754 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1755 (semantic-overlay-put |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1756 ol 'display (concat os (buffer-substring (point) (1+ (point))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1757 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1758 ;; Calculate text difference between contents and the focus item. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1759 (let* ((mbc (semantic-completion-text)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1760 (ftn (concat (semantic-tag-name tag))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1761 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1762 (put-text-property (length mbc) (length ftn) 'face |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1763 'bold ftn) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1764 (semantic-completion-message |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1765 (format "%s [%d of %d matches]" ftn (1+ (oref obj focus)) tablelength))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1766 ))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1767 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1768 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1769 ;;; ------------------------------------------------------------ |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1770 ;;; Specific queries |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1771 ;; |
104439
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1772 (defvar semantic-complete-inline-custom-type |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1773 (append '(radio) |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1774 (mapcar |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1775 (lambda (class) |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1776 (let* ((C (intern (car class))) |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1777 (doc (documentation-property C 'variable-documentation)) |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1778 (doc1 (car (split-string doc "\n"))) |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1779 ) |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1780 (list 'const |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1781 :tag doc1 |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1782 C))) |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1783 (eieio-build-class-alist semantic-displayor-abstract t)) |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1784 ) |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1785 "Possible options for inlince completion displayors. |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1786 Use this to enable custom editing.") |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1787 |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1788 (defcustom semantic-complete-inline-analyzer-displayor-class |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1789 'semantic-displayor-traditional |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1790 "*Class for displayor to use with inline completion." |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1791 :group 'semantic |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1792 :type semantic-complete-inline-custom-type |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1793 ) |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1794 |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1795 (defun semantic-complete-read-tag-buffer-deep (prompt &optional |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1796 default-tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1797 initial-input |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1798 history) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1799 "Ask for a tag by name from the current buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1800 Available tags are from the current buffer, at any level. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1801 Completion options are presented in a traditional way, with highlighting |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1802 to resolve same-name collisions. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1803 PROMPT is a string to prompt with. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1804 DEFAULT-TAG is a semantic tag or string to use as the default value. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1805 If INITIAL-INPUT is non-nil, insert it in the minibuffer initially. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1806 HISTORY is a symbol representing a variable to store the history in." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1807 (semantic-complete-read-tag-engine |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1808 (semantic-collector-buffer-deep prompt :buffer (current-buffer)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1809 (semantic-displayor-traditional-with-focus-highlight "simple") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1810 ;;(semantic-displayor-tooltip "simple") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1811 prompt |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1812 default-tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1813 initial-input |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1814 history) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1815 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1816 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1817 (defun semantic-complete-read-tag-project (prompt &optional |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1818 default-tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1819 initial-input |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1820 history) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1821 "Ask for a tag by name from the current project. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1822 Available tags are from the current project, at the top level. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1823 Completion options are presented in a traditional way, with highlighting |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1824 to resolve same-name collisions. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1825 PROMPT is a string to prompt with. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1826 DEFAULT-TAG is a semantic tag or string to use as the default value. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1827 If INITIAL-INPUT is non-nil, insert it in the minibuffer initially. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1828 HISTORY is a symbol representing a variable to store the history in." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1829 (semantic-complete-read-tag-engine |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1830 (semantic-collector-project-brutish prompt |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1831 :buffer (current-buffer) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1832 :path (current-buffer) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1833 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1834 (semantic-displayor-traditional-with-focus-highlight "simple") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1835 prompt |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1836 default-tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1837 initial-input |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1838 history) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1839 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1840 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1841 (defun semantic-complete-inline-tag-project () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1842 "Complete a symbol name by name from within the current project. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1843 This is similar to `semantic-complete-read-tag-project', except |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1844 that the completion interaction is in the buffer where the context |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1845 was calculated from. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1846 Customize `semantic-complete-inline-analyzer-displayor-class' |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1847 to control how completion options are displayed. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1848 See `semantic-complete-inline-tag-engine' for details on how |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1849 completion works." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1850 (let* ((collector (semantic-collector-project-brutish |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1851 "inline" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1852 :buffer (current-buffer) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1853 :path (current-buffer))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1854 (sbounds (semantic-ctxt-current-symbol-and-bounds)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1855 (syms (car sbounds)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1856 (start (car (nth 2 sbounds))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1857 (end (cdr (nth 2 sbounds))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1858 (rsym (reverse syms)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1859 (thissym (nth 1 sbounds)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1860 (nextsym (car-safe (cdr rsym))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1861 (complst nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1862 (when (and thissym (or (not (string= thissym "")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1863 nextsym)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1864 ;; Do a quick calcuation of completions. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1865 (semantic-collector-calculate-completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1866 collector thissym nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1867 ;; Get the master list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1868 (setq complst (semanticdb-strip-find-results |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1869 (semantic-collector-all-completions collector thissym))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1870 ;; Shorten by name |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1871 (setq complst (semantic-unique-tag-table-by-name complst)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1872 (if (or (and (= (length complst) 1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1873 ;; Check to see if it is the same as what is there. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1874 ;; if so, we can offer to complete. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1875 (let ((compname (semantic-tag-name (car complst)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1876 (not (string= compname thissym)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1877 (> (length complst) 1)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1878 ;; There are several options. Do the completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1879 (semantic-complete-inline-tag-engine |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1880 collector |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1881 (funcall semantic-complete-inline-analyzer-displayor-class |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1882 "inline displayor") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1883 ;;(semantic-displayor-tooltip "simple") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1884 (current-buffer) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1885 start end)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1886 ))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1887 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1888 (defun semantic-complete-read-tag-analyzer (prompt &optional |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1889 context |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1890 history) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1891 "Ask for a tag by name based on the current context. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1892 The function `semantic-analyze-current-context' is used to |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1893 calculate the context. `semantic-analyze-possible-completions' is used |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1894 to generate the list of possible completions. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1895 PROMPT is the first part of the prompt. Additional prompt |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1896 is added based on the contexts full prefix. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1897 CONTEXT is the semantic analyzer context to start with. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1898 HISTORY is a symbol representing a variable to stor the history in. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1899 usually a default-tag and initial-input are available for completion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1900 prompts. these are calculated from the CONTEXT variable passed in." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1901 (if (not context) (setq context (semantic-analyze-current-context (point)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1902 (let* ((syms (semantic-ctxt-current-symbol (point))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1903 (inp (car (reverse syms)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1904 (setq syms (nreverse (cdr (nreverse syms)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1905 (semantic-complete-read-tag-engine |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1906 (semantic-collector-analyze-completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1907 prompt |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1908 :buffer (oref context buffer) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1909 :context context) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1910 (semantic-displayor-traditional-with-focus-highlight "simple") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1911 (save-excursion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1912 (set-buffer (oref context buffer)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1913 (goto-char (cdr (oref context bounds))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1914 (concat prompt (mapconcat 'identity syms ".") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1915 (if syms "." "") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1916 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1917 nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1918 inp |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1919 history))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1920 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1921 (defun semantic-complete-inline-analyzer (context) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1922 "Complete a symbol name by name based on the current context. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1923 This is similar to `semantic-complete-read-tag-analyze', except |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1924 that the completion interaction is in the buffer where the context |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1925 was calculated from. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1926 CONTEXT is the semantic analyzer context to start with. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1927 Customize `semantic-complete-inline-analyzer-displayor-class' |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1928 to control how completion options are displayed. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1929 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1930 See `semantic-complete-inline-tag-engine' for details on how |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1931 completion works." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1932 (if (not context) (setq context (semantic-analyze-current-context (point)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1933 (if (not context) (error "Nothing to complete on here")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1934 (let* ((collector (semantic-collector-analyze-completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1935 "inline" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1936 :buffer (oref context buffer) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1937 :context context)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1938 (syms (semantic-ctxt-current-symbol (point))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1939 (rsym (reverse syms)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1940 (thissym (car rsym)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1941 (nextsym (car-safe (cdr rsym))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1942 (complst nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1943 (when (and thissym (or (not (string= thissym "")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1944 nextsym)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1945 ;; Do a quick calcuation of completions. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1946 (semantic-collector-calculate-completions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1947 collector thissym nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1948 ;; Get the master list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1949 (setq complst (semanticdb-strip-find-results |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1950 (semantic-collector-all-completions collector thissym))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1951 ;; Shorten by name |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1952 (setq complst (semantic-unique-tag-table-by-name complst)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1953 (if (or (and (= (length complst) 1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1954 ;; Check to see if it is the same as what is there. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1955 ;; if so, we can offer to complete. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1956 (let ((compname (semantic-tag-name (car complst)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1957 (not (string= compname thissym)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1958 (> (length complst) 1)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1959 ;; There are several options. Do the completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1960 (semantic-complete-inline-tag-engine |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1961 collector |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1962 (funcall semantic-complete-inline-analyzer-displayor-class |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1963 "inline displayor") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1964 ;;(semantic-displayor-tooltip "simple") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1965 (oref context buffer) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1966 (car (oref context bounds)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1967 (cdr (oref context bounds)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1968 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1969 ))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1970 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1971 (defcustom semantic-complete-inline-analyzer-idle-displayor-class |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1972 'semantic-displayor-ghost |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1973 "*Class for displayor to use with inline completion at idle time." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1974 :group 'semantic |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1975 :type semantic-complete-inline-custom-type |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1976 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1977 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1978 (defun semantic-complete-inline-analyzer-idle (context) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1979 "Complete a symbol name by name based on the current context for idle time. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1980 CONTEXT is the semantic analyzer context to start with. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1981 This function is used from `semantic-idle-completions-mode'. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1982 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1983 This is the same as `semantic-complete-inline-analyzer', except that |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1984 it uses `semantic-complete-inline-analyzer-idle-displayor-class' |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1985 to control how completions are displayed. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1986 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1987 See `semantic-complete-inline-tag-engine' for details on how |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1988 completion works." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1989 (let ((semantic-complete-inline-analyzer-displayor-class |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1990 semantic-complete-inline-analyzer-idle-displayor-class)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1991 (semantic-complete-inline-analyzer context) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1992 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1993 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1994 |
104457
724ff52eda98
lisp/cedet/semantic/complete.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
1995 ;;;###autoload |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1996 (defun semantic-complete-jump-local () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1997 "Jump to a semantic symbol." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1998 (interactive) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1999 (let ((tag (semantic-complete-read-tag-buffer-deep "Symbol: "))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2000 (when (semantic-tag-p tag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2001 (push-mark) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2002 (goto-char (semantic-tag-start tag)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2003 (semantic-momentary-highlight-tag tag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2004 (message "%S: %s " |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2005 (semantic-tag-class tag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2006 (semantic-tag-name tag))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2007 |
104457
724ff52eda98
lisp/cedet/semantic/complete.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
2008 ;;;###autoload |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2009 (defun semantic-complete-jump () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2010 "Jump to a semantic symbol." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2011 (interactive) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2012 (let* ((tag (semantic-complete-read-tag-project "Symbol: "))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2013 (when (semantic-tag-p tag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2014 (push-mark) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2015 (semantic-go-to-tag tag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2016 (switch-to-buffer (current-buffer)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2017 (semantic-momentary-highlight-tag tag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2018 (message "%S: %s " |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2019 (semantic-tag-class tag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2020 (semantic-tag-name tag))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2021 |
104457
724ff52eda98
lisp/cedet/semantic/complete.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
2022 ;;;###autoload |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2023 (defun semantic-complete-analyze-and-replace () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2024 "Perform prompt completion to do in buffer completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2025 `semantic-analyze-possible-completions' is used to determine the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2026 possible values. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2027 The minibuffer is used to perform the completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2028 The result is inserted as a replacement of the text that was there." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2029 (interactive) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2030 (let* ((c (semantic-analyze-current-context (point))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2031 (tag (save-excursion (semantic-complete-read-tag-analyzer "" c)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2032 ;; Take tag, and replace context bound with its name. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2033 (goto-char (car (oref c bounds))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2034 (delete-region (point) (cdr (oref c bounds))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2035 (insert (semantic-tag-name tag)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2036 (message "%S" (semantic-format-tag-summarize tag)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2037 |
104457
724ff52eda98
lisp/cedet/semantic/complete.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
2038 ;;;###autoload |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2039 (defun semantic-complete-analyze-inline () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2040 "Perform prompt completion to do in buffer completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2041 `semantic-analyze-possible-completions' is used to determine the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2042 possible values. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2043 The function returns immediately, leaving the buffer in a mode that |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2044 will perform the completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2045 Configure `semantic-complete-inline-analyzer-displayor-class' to change |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2046 how completion options are displayed." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2047 (interactive) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2048 ;; Only do this if we are not already completing something. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2049 (if (not (semantic-completion-inline-active-p)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2050 (semantic-complete-inline-analyzer |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2051 (semantic-analyze-current-context (point)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2052 ;; Report a message if things didn't startup. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2053 (if (and (interactive-p) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2054 (not (semantic-completion-inline-active-p))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2055 (message "Inline completion not needed.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2056 ;; Since this is most likely bound to something, and not used |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2057 ;; at idle time, throw in a TAB for good measure. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2058 (semantic-complete-inline-TAB) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2059 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2060 |
104457
724ff52eda98
lisp/cedet/semantic/complete.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
2061 ;;;###autoload |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2062 (defun semantic-complete-analyze-inline-idle () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2063 "Perform prompt completion to do in buffer completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2064 `semantic-analyze-possible-completions' is used to determine the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2065 possible values. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2066 The function returns immediately, leaving the buffer in a mode that |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2067 will perform the completion. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2068 Configure `semantic-complete-inline-analyzer-idle-displayor-class' |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2069 to change how completion options are displayed." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2070 (interactive) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2071 ;; Only do this if we are not already completing something. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2072 (if (not (semantic-completion-inline-active-p)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2073 (semantic-complete-inline-analyzer-idle |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2074 (semantic-analyze-current-context (point)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2075 ;; Report a message if things didn't startup. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2076 (if (and (interactive-p) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2077 (not (semantic-completion-inline-active-p))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2078 (message "Inline completion not needed.")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2079 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2080 |
104457
724ff52eda98
lisp/cedet/semantic/complete.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
2081 ;;;###autoload |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2082 (defun semantic-complete-self-insert (arg) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2083 "Like `self-insert-command', but does completion afterwards. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2084 ARG is passed to `self-insert-command'. If ARG is nil, |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2085 use `semantic-complete-analyze-inline' to complete." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2086 (interactive "p") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2087 ;; If we are already in a completion scenario, exit now, and then start over. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2088 (semantic-complete-inline-exit) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2089 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2090 ;; Insert the key |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2091 (self-insert-command arg) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2092 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2093 ;; Prepare for doing completion, but exit quickly if there is keyboard |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2094 ;; input. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2095 (when (and (not (semantic-exit-on-input 'csi |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2096 (semantic-fetch-tags) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2097 (semantic-throw-on-input 'csi) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2098 nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2099 (= arg 1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2100 (not (semantic-exit-on-input 'csi |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2101 (semantic-analyze-current-context) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2102 (semantic-throw-on-input 'csi) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2103 nil))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2104 (condition-case nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2105 (semantic-complete-analyze-inline) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2106 ;; Ignore errors. Seems likely that we'll get some once in a while. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2107 (error nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2108 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2109 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2110 ;; @TODO - I can't find where this fcn is used. Delete? |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2111 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2112 ;;;;###autoload |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2113 ;(defun semantic-complete-inline-project () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2114 ; "Perform inline completion for any symbol in the current project. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2115 ;`semantic-analyze-possible-completions' is used to determine the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2116 ;possible values. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2117 ;The function returns immediately, leaving the buffer in a mode that |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2118 ;will perform the completion." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2119 ; (interactive) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2120 ; ;; Only do this if we are not already completing something. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2121 ; (if (not (semantic-completion-inline-active-p)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2122 ; (semantic-complete-inline-tag-project)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2123 ; ;; Report a message if things didn't startup. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2124 ; (if (and (interactive-p) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2125 ; (not (semantic-completion-inline-active-p))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2126 ; (message "Inline completion not needed.")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2127 ; ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2128 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2129 ;; End |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2130 (provide 'semantic/complete) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2131 |
104457
724ff52eda98
lisp/cedet/semantic/complete.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
2132 ;; Local variables: |
724ff52eda98
lisp/cedet/semantic/complete.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
2133 ;; generated-autoload-file: "loaddefs.el" |
724ff52eda98
lisp/cedet/semantic/complete.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
2134 ;; generated-autoload-feature: semantic/loaddefs |
724ff52eda98
lisp/cedet/semantic/complete.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
2135 ;; generated-autoload-load-name: "semantic/complete" |
724ff52eda98
lisp/cedet/semantic/complete.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
2136 ;; End: |
724ff52eda98
lisp/cedet/semantic/complete.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
2137 |
104439
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
2138 ;;; semantic/complete.el ends here |