Mercurial > emacs
annotate lisp/progmodes/etags.el @ 2459:fd35248ff0d1
* s/vms.h (EXEC_SUFFIXES): Add definition for this.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Mon, 05 Apr 1993 21:00:51 +0000 |
parents | 0d7fdb12dcdb |
children | 9dace03bd76c |
rev | line source |
---|---|
2229
bd3c525fa6fc
Added standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1976
diff
changeset
|
1 ;;; etags.el --- etags facility for Emacs |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
804
diff
changeset
|
2 |
1806
da47cfb7624e
(visit-tags-table-buffer): Error if called with 'same and no current table.
Roland McGrath <roland@gnu.org>
parents:
1724
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1988, 1989, 1992, 1993 |
da47cfb7624e
(visit-tags-table-buffer): Error if called with 'same and no current table.
Roland McGrath <roland@gnu.org>
parents:
1724
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
824
diff
changeset
|
5 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
804
diff
changeset
|
6 ;; Author: Roland McGrath <roland@gnu.ai.mit.edu> |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
804
diff
changeset
|
7 ;; Keywords: tools |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
804
diff
changeset
|
8 |
342 | 9 ;; This file is part of GNU Emacs. |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
727 | 13 ;; the Free Software Foundation; either version 2, or (at your option) |
342 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
804
diff
changeset
|
25 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
804
diff
changeset
|
26 |
360 | 27 ;;;###autoload |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
28 (defvar tags-file-name nil |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
29 "*File name of tags table. |
799 | 30 To switch to a new tags table, setting this variable is sufficient. |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
31 If you set this variable, do not also set `tags-table-list'. |
799 | 32 Use the `etags' program to make a tags table file.") |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
33 ;; Make M-x set-variable tags-file-name like M-x visit-tags-table. |
824 | 34 ;;;###autoload (put 'tags-file-name 'variable-interactive "fVisit tags table: ") |
799 | 35 |
36 ;;;###autoload | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
37 ;; Use `visit-tags-table-buffer' to cycle through tags tables in this list. |
799 | 38 (defvar tags-table-list nil |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
39 "*List of file names of tags tables to search. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
40 An element that is a directory means the file \"TAGS\" in that directory. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
41 To switch to a new list of tags tables, setting this variable is sufficient. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
42 If you set this variable, do not also set `tags-file-name'. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
43 Use the `etags' program to make a tags table file.") |
799 | 44 |
45 (defvar tags-table-list-pointer nil | |
1149 | 46 "Pointer into `tags-table-list' where the current state of searching is. |
47 Might instead point into a list of included tags tables. | |
48 Use `visit-tags-table-buffer' to cycle through tags tables in this list.") | |
49 | |
50 (defvar tags-table-list-started-at nil | |
51 "Pointer into `tags-table-list', where the current search started.") | |
342 | 52 |
799 | 53 (defvar tags-table-parent-pointer-list nil |
1149 | 54 "Saved state of the tags table that included this one. |
55 Each element is (POINTER . STARTED-AT), giving the values of | |
56 `tags-table-list-pointer' and `tags-table-list-started-at' from | |
57 before we moved into the current table.") | |
799 | 58 |
59 (defvar tags-table-set-list nil | |
60 "List of sets of tags table which have been used together in the past. | |
61 Each element is a list of strings which are file names.") | |
342 | 62 |
799 | 63 ;;;###autoload |
64 (defvar find-tag-hook nil | |
65 "*Hook to be run by \\[find-tag] after finding a tag. See `run-hooks'. | |
66 The value in the buffer in which \\[find-tag] is done is used, | |
67 not the value in the buffer \\[find-tag] goes to.") | |
68 | |
69 ;;;###autoload | |
70 (defvar find-tag-default-function nil | |
1149 | 71 "*A function of no arguments used by \\[find-tag] to pick a default tag. |
72 If nil, and the symbol that is the value of `major-mode' | |
799 | 73 has a `find-tag-default-function' property (see `put'), that is used. |
74 Otherwise, `find-tag-default' is used.") | |
342 | 75 |
360 | 76 ;;;###autoload |
799 | 77 (defvar default-tags-table-function nil |
78 "*If non-nil, a function of no arguments to choose a default tags file | |
79 for a particular buffer.") | |
80 | |
81 ;; Tags table state. | |
82 ;; These variables are local in tags table buffers. | |
83 | |
84 (defvar tag-lines-already-matched nil | |
85 "List of positions of beginnings of lines within the tags table | |
86 that are already matched.") | |
87 | |
88 (defvar tags-table-files nil | |
89 "List of file names covered by current tags table. | |
90 nil means it has not yet been computed; use `tags-table-files' to do so.") | |
91 | |
92 (defvar tags-completion-table nil | |
93 "Alist of tag names defined in current tags table.") | |
94 | |
95 (defvar tags-included-tables nil | |
96 "List of tags tables included by the current tags table.") | |
97 | |
98 (defvar next-file-list nil | |
99 "List of files for \\[next-file] to process.") | |
100 | |
101 ;; Hooks for file formats. | |
102 | |
103 (defvar tags-table-format-hooks '(etags-recognize-tags-table | |
824 | 104 recognize-empty-tags-table) |
799 | 105 "List of functions to be called in a tags table buffer to identify |
106 the type of tags table. The functions are called in order, with no arguments, | |
107 until one returns non-nil. The function should make buffer-local bindings | |
108 of the format-parsing tags function variables if successful.") | |
109 | |
110 (defvar file-of-tag-function nil | |
111 "Function to do the work of `file-of-tag' (which see).") | |
112 (defvar tags-table-files-function nil | |
113 "Function to do the work of `tags-table-files' (which see).") | |
114 (defvar tags-completion-table-function nil | |
115 "Function to build the tags-completion-table.") | |
116 (defvar snarf-tag-function nil | |
117 "Function to get info about a matched tag for `goto-tag-location-function'.") | |
118 (defvar goto-tag-location-function nil | |
119 "Function of to go to the location in the buffer specified by a tag. | |
120 One argument, the tag info returned by `snarf-tag-function'.") | |
121 (defvar find-tag-regexp-search-function nil | |
122 "Search function passed to `find-tag-in-order' for finding a regexp tag.") | |
123 (defvar find-tag-regexp-tag-order nil | |
124 "Tag order passed to `find-tag-in-order' for finding a regexp tag.") | |
125 (defvar find-tag-regexp-next-line-after-failure-p nil | |
126 "Flag passed to `find-tag-in-order' for finding a regexp tag.") | |
127 (defvar find-tag-search-function nil | |
128 "Search function passed to `find-tag-in-order' for finding a tag.") | |
129 (defvar find-tag-tag-order nil | |
130 "Tag order passed to `find-tag-in-order' for finding a tag.") | |
131 (defvar find-tag-next-line-after-failure-p nil | |
132 "Flag passed to `find-tag-in-order' for finding a tag.") | |
133 (defvar list-tags-function nil | |
134 "Function to do the work of `list-tags' (which see).") | |
135 (defvar tags-apropos-function nil | |
136 "Function to do the work of `tags-apropos' (which see).") | |
137 (defvar tags-included-tables-function nil | |
138 "Function to do the work of `tags-included-tables' (which see).") | |
139 (defvar verify-tags-table-function nil | |
140 "Function to return t iff the current buffer vontains a valid | |
141 \(already initialized\) tags file.") | |
142 | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
143 ;; Initialize the tags table in the current buffer. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
144 ;; Returns non-nil iff it is a valid tags table. On |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
145 ;; non-nil return, the tags table state variable are |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
146 ;; made buffer-local and initialized to nil. |
799 | 147 (defun initialize-new-tags-table () |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
148 (set (make-local-variable 'tag-lines-already-matched) nil) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
149 (set (make-local-variable 'tags-table-files) nil) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
150 (set (make-local-variable 'tags-completion-table) nil) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
151 (set (make-local-variable 'tags-included-tables) nil) |
799 | 152 ;; Value is t if we have found a valid tags table buffer. |
153 (let ((hooks tags-table-format-hooks)) | |
154 (while (and hooks | |
155 (not (funcall (car hooks)))) | |
156 (setq hooks (cdr hooks))) | |
157 hooks)) | |
158 | |
159 ;;;###autoload | |
160 (defun visit-tags-table (file &optional local) | |
161 "Tell tags commands to use tags table file FILE. | |
342 | 162 FILE should be the name of a file created with the `etags' program. |
799 | 163 A directory name is ok too; it means file TAGS in that directory. |
164 | |
165 Normally \\[visit-tags-table] sets the global value of `tags-file-name'. | |
166 With a prefix arg, set the buffer-local value instead. | |
167 When you find a tag with \\[find-tag], the buffer it finds the tag | |
168 in is given a local value of this variable which is the name of the tags | |
169 file the tag was in." | |
342 | 170 (interactive (list (read-file-name "Visit tags table: (default TAGS) " |
171 default-directory | |
799 | 172 (expand-file-name "TAGS" |
173 default-directory) | |
174 t) | |
175 current-prefix-arg)) | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
176 ;; Calling visit-tags-table-buffer with tags-file-name set to FILE will |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
177 ;; initialize a buffer for FILE and set tags-file-name to the |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
178 ;; fully-expanded name. |
1138 | 179 (let ((tags-file-name file)) |
180 (save-excursion | |
1149 | 181 (or (visit-tags-table-buffer 'same) |
1138 | 182 (signal 'file-error (list "Visiting tags table" |
183 "file does not exist" | |
184 file))) | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
185 ;; Set FILE to the expanded name. |
1138 | 186 (setq file tags-file-name))) |
799 | 187 (if local |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
188 ;; Set the local value of tags-file-name. |
1149 | 189 (set (make-local-variable 'tags-file-name) file) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
190 ;; Set the global value of tags-file-name. |
1138 | 191 (setq-default tags-file-name file))) |
192 | |
193 ;; Move tags-table-list-pointer along and set tags-file-name. | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
194 ;; If NO-INCLUDES is non-nil, ignore included tags tables. |
1138 | 195 ;; Returns nil when out of tables. |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
196 (defun tags-next-table (&optional no-includes) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
197 ;; Do we have any included tables? |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
198 (if (and (not no-includes) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
199 (visit-tags-table-buffer 'same) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
200 (tags-included-tables)) |
1149 | 201 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
202 ;; Move into the included tags tables. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
203 (setq tags-table-parent-pointer-list |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
204 ;; Save the current state of what table we are in. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
205 (cons (cons tags-table-list-pointer tags-table-list-started-at) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
206 tags-table-parent-pointer-list) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
207 ;; Start the pointer in the list of included tables. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
208 tags-table-list-pointer tags-included-tables |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
209 tags-table-list-started-at tags-included-tables) |
1149 | 210 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
211 ;; No included tables. Go to the next table in the list. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
212 (setq tags-table-list-pointer |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
213 (cdr tags-table-list-pointer)) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
214 (or tags-table-list-pointer |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
215 ;; Wrap around. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
216 (setq tags-table-list-pointer tags-table-list)) |
1149 | 217 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
218 (if (eq tags-table-list-pointer tags-table-list-started-at) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
219 ;; We have come full circle. No more tables. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
220 (if tags-table-parent-pointer-list |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
221 ;; Pop back to the tags table which includes this one. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
222 (progn |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
223 ;; Restore the state variables. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
224 (setq tags-table-list-pointer |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
225 (car (car tags-table-parent-pointer-list)) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
226 tags-table-list-started-at |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
227 (cdr (car tags-table-parent-pointer-list)) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
228 tags-table-parent-pointer-list |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
229 (cdr tags-table-parent-pointer-list)) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
230 ;; Recurse to skip to the next table after the parent. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
231 (tags-next-table t)) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
232 ;; All out of tags tables. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
233 (setq tags-table-list-pointer nil)))) |
1149 | 234 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
235 (and tags-table-list-pointer |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
236 ;; Set tags-file-name to the fully-expanded name. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
237 (setq tags-file-name |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
238 (tags-expand-table-name (car tags-table-list-pointer))))) |
1149 | 239 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
240 ;; Expand tags table name FILE into a complete file name. |
1149 | 241 (defun tags-expand-table-name (file) |
242 (setq file (expand-file-name file)) | |
243 (if (file-directory-p file) | |
244 (expand-file-name "TAGS" file) | |
245 file)) | |
1138 | 246 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
247 ;; Return the cdr of LIST (default: tags-table-list) whose car |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
248 ;; is equal to FILE after tags-expand-table-name on both sides. |
1149 | 249 (defun tags-table-list-member (file &optional list) |
250 (or list | |
251 (setq list tags-table-list)) | |
252 (setq file (tags-expand-table-name file)) | |
253 (while (and list | |
254 (not (string= file (tags-expand-table-name (car list))))) | |
255 (setq list (cdr list))) | |
256 list) | |
257 | |
258 ;; Subroutine of visit-tags-table-buffer. Frobs its local vars. | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
259 ;; Search TABLES for one that has tags for THIS-FILE. Recurses |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
260 ;; on included tables. Returns the tail of TABLES (or of an |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
261 ;; inner included list) whose car is a table listing THIS-FILE. |
1149 | 262 (defun tags-table-including (this-file tables &optional recursing) |
263 (let ((found nil)) | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
264 ;; Loop over TABLES, looking for one containing tags for THIS-FILE. |
1149 | 265 (while (and (not found) |
266 tables) | |
267 (let ((tags-file-name (tags-expand-table-name (car tables)))) | |
268 (if (or (get-file-buffer tags-file-name) | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
269 (file-exists-p tags-file-name)) ;XXX check all in core first. |
1149 | 270 (progn |
271 ;; Select the tags table buffer and get the file list up to date. | |
272 (visit-tags-table-buffer 'same) | |
273 (or tags-table-files | |
274 (setq tags-table-files | |
275 (funcall tags-table-files-function))) | |
276 | |
277 (cond ((member this-file tags-table-files) | |
278 ;; Found it. | |
279 (setq found tables)) | |
1138 | 280 |
1149 | 281 ((tags-included-tables) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
282 ;; This table has included tables. Check them. |
1149 | 283 (let ((old tags-table-parent-pointer-list)) |
284 (unwind-protect | |
285 (progn | |
286 (or recursing | |
287 ;; At top level (not in an included tags | |
288 ;; table), set the list to nil so we can | |
289 ;; collect just the elts from this run. | |
290 (setq tags-table-parent-pointer-list nil)) | |
291 (setq found | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
292 ;; Recurse on the list of included tables. |
1149 | 293 (tags-table-including this-file |
294 tags-included-tables | |
295 t)) | |
296 (if found | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
297 ;; One of them lists THIS-FILE. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
298 ;; Set the table list state variables to move |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
299 ;; us inside the list of included tables. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
300 (setq tags-table-parent-pointer-list |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
301 (cons |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
302 (cons tags-table-list-pointer |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
303 tags-table-list-started-at) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
304 tags-table-parent-pointer-list) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
305 tags-table-list-pointer found |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
306 tags-table-list-started-at found |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
307 ;; CONT is a local variable of |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
308 ;; our caller, visit-tags-table-buffer. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
309 ;; Set it so we won't frob lists later. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
310 cont 'included))) |
1149 | 311 (or recursing |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
312 ;; tags-table-parent-pointer-list now describes |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
313 ;; the path of included tables taken by recursive |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
314 ;; invocations of this function. The recursive |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
315 ;; calls have consed onto the front of the list, |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
316 ;; so it is now outermost first. We want it |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
317 ;; innermost first, so reverse it. Then append |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
318 ;; the old list (from before we were called the |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
319 ;; outermost time), to get the complete current |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
320 ;; state of included tables. |
1149 | 321 (setq tags-table-parent-pointer-list |
322 (nconc (nreverse | |
323 tags-table-parent-pointer-list) | |
324 old)))))))))) | |
325 (setq tables (cdr tables))) | |
326 found)) | |
799 | 327 |
328 (defun visit-tags-table-buffer (&optional cont) | |
329 "Select the buffer containing the current tags table. | |
330 If optional arg is t, visit the next table in `tags-table-list'. | |
331 If optional arg is the atom `same', don't look for a new table; | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
332 just select the buffer visiting `tags-file-name'. |
1149 | 333 If arg is nil or absent, choose a first buffer from information in |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
334 `tags-file-name', `tags-table-list', `tags-table-list-pointer'. |
799 | 335 Returns t if it visits a tags table, or nil if there are no more in the list." |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
336 |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
337 ;; Set tags-file-name to the tags table file we want to visit. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
338 (cond ((eq cont 'same) |
1806
da47cfb7624e
(visit-tags-table-buffer): Error if called with 'same and no current table.
Roland McGrath <roland@gnu.org>
parents:
1724
diff
changeset
|
339 ;; Use the ambient value of tags-file-name. |
da47cfb7624e
(visit-tags-table-buffer): Error if called with 'same and no current table.
Roland McGrath <roland@gnu.org>
parents:
1724
diff
changeset
|
340 (or tags-file-name |
da47cfb7624e
(visit-tags-table-buffer): Error if called with 'same and no current table.
Roland McGrath <roland@gnu.org>
parents:
1724
diff
changeset
|
341 (error (substitute-command-keys |
da47cfb7624e
(visit-tags-table-buffer): Error if called with 'same and no current table.
Roland McGrath <roland@gnu.org>
parents:
1724
diff
changeset
|
342 (concat "No tags table in use! " |
da47cfb7624e
(visit-tags-table-buffer): Error if called with 'same and no current table.
Roland McGrath <roland@gnu.org>
parents:
1724
diff
changeset
|
343 "Use \\[visit-tags-table] to select one.")))) |
da47cfb7624e
(visit-tags-table-buffer): Error if called with 'same and no current table.
Roland McGrath <roland@gnu.org>
parents:
1724
diff
changeset
|
344 ;; Set CONT to nil so the code below will make sure tags-file-name |
da47cfb7624e
(visit-tags-table-buffer): Error if called with 'same and no current table.
Roland McGrath <roland@gnu.org>
parents:
1724
diff
changeset
|
345 ;; is in tags-table-list. |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
346 (setq cont nil)) |
1138 | 347 |
1149 | 348 (cont |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
349 ;; Find the next table. |
1149 | 350 (if (tags-next-table) |
351 ;; Skip over nonexistent files. | |
352 (while (and (let ((file (tags-expand-table-name tags-file-name))) | |
353 (not (or (get-file-buffer file) | |
354 (file-exists-p file)))) | |
355 (tags-next-table))))) | |
342 | 356 |
1149 | 357 (t |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
358 ;; Pick a table out of our hat. |
1149 | 359 (setq tags-file-name |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
360 (or |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
361 ;; First, try a local variable. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
362 (cdr (assq 'tags-file-name (buffer-local-variables))) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
363 ;; Second, try a user-specified function to guess. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
364 (and default-tags-table-function |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
365 (funcall default-tags-table-function)) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
366 ;; Third, look for a tags table that contains |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
367 ;; tags for the current buffer's file. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
368 ;; If one is found, the lists will be frobnicated, |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
369 ;; and CONT will be set non-nil so we don't do it below. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
370 (car (save-excursion (tags-table-including buffer-file-name |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
371 tags-table-list))) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
372 ;; Fourth, use the user variable tags-file-name, if it is not |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
373 ;; already in tags-table-list. |
1697
f14e1a6ac205
(visit-tags-table-buffer): Don't look in list for tags-file-name if nil.
Roland McGrath <roland@gnu.org>
parents:
1696
diff
changeset
|
374 (and tags-file-name |
f14e1a6ac205
(visit-tags-table-buffer): Don't look in list for tags-file-name if nil.
Roland McGrath <roland@gnu.org>
parents:
1696
diff
changeset
|
375 (not (tags-table-list-member tags-file-name)) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
376 tags-file-name) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
377 ;; Fifth, use the user variable giving the table list. |
1724
2dccfada2107
(visit-tags-table-buffer): When picking a table and using tags-table-list,
Roland McGrath <roland@gnu.org>
parents:
1723
diff
changeset
|
378 ;; Find the first element of the list that actually exists. |
2dccfada2107
(visit-tags-table-buffer): When picking a table and using tags-table-list,
Roland McGrath <roland@gnu.org>
parents:
1723
diff
changeset
|
379 (let ((list tags-table-list) |
2dccfada2107
(visit-tags-table-buffer): When picking a table and using tags-table-list,
Roland McGrath <roland@gnu.org>
parents:
1723
diff
changeset
|
380 file) |
2dccfada2107
(visit-tags-table-buffer): When picking a table and using tags-table-list,
Roland McGrath <roland@gnu.org>
parents:
1723
diff
changeset
|
381 (while (and list |
2dccfada2107
(visit-tags-table-buffer): When picking a table and using tags-table-list,
Roland McGrath <roland@gnu.org>
parents:
1723
diff
changeset
|
382 (setq file (tags-expand-table-name (car list))) |
2dccfada2107
(visit-tags-table-buffer): When picking a table and using tags-table-list,
Roland McGrath <roland@gnu.org>
parents:
1723
diff
changeset
|
383 (not (get-file-buffer file)) |
2dccfada2107
(visit-tags-table-buffer): When picking a table and using tags-table-list,
Roland McGrath <roland@gnu.org>
parents:
1723
diff
changeset
|
384 (not (file-exists-p file))) |
2dccfada2107
(visit-tags-table-buffer): When picking a table and using tags-table-list,
Roland McGrath <roland@gnu.org>
parents:
1723
diff
changeset
|
385 (setq list (cdr list))) |
2dccfada2107
(visit-tags-table-buffer): When picking a table and using tags-table-list,
Roland McGrath <roland@gnu.org>
parents:
1723
diff
changeset
|
386 (car list)) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
387 ;; Finally, prompt the user for a file name. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
388 (expand-file-name |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
389 (read-file-name "Visit tags table: (default TAGS) " |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
390 default-directory |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
391 "TAGS" |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
392 t)))))) |
1149 | 393 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
394 ;; Expand the table name into a full file name. |
1149 | 395 (setq tags-file-name (tags-expand-table-name tags-file-name)) |
396 | |
1156 | 397 (if (and (eq cont t) (null tags-table-list-pointer)) |
1149 | 398 ;; All out of tables. |
399 nil | |
1138 | 400 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
401 ;; Verify that tags-file-name is a valid tags table. |
1149 | 402 (if (if (get-file-buffer tags-file-name) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
403 ;; The file is already in a buffer. Check for the visited file |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
404 ;; having changed since we last used it. |
1149 | 405 (let (win) |
406 (set-buffer (get-file-buffer tags-file-name)) | |
407 (setq win (or verify-tags-table-function | |
408 (initialize-new-tags-table))) | |
409 (if (or (verify-visited-file-modtime (current-buffer)) | |
410 (not (yes-or-no-p | |
411 "Tags file has changed, read new contents? "))) | |
412 (and win (funcall verify-tags-table-function)) | |
413 (revert-buffer t t) | |
414 (initialize-new-tags-table))) | |
415 (set-buffer (find-file-noselect tags-file-name)) | |
416 (or (string= tags-file-name buffer-file-name) | |
417 ;; find-file-noselect has changed the file name. | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
418 ;; Propagate the change to tags-file-name and tags-table-list. |
1807
1059b972916c
(visit-tags-table-buffer): When propagating a change of name after
Roland McGrath <roland@gnu.org>
parents:
1806
diff
changeset
|
419 (let ((tail (member tags-file-name tags-table-list))) |
1149 | 420 (if tail |
421 (setcar tail buffer-file-name)) | |
422 (setq tags-file-name buffer-file-name))) | |
423 (initialize-new-tags-table)) | |
424 | |
425 ;; We have a valid tags table. | |
426 (progn | |
427 ;; Bury the tags table buffer so it | |
428 ;; doesn't get in the user's way. | |
429 (bury-buffer (current-buffer)) | |
799 | 430 |
1149 | 431 (if cont |
432 ;; No list frobbing required. | |
433 nil | |
434 | |
435 ;; Look in the list for the table we chose. | |
436 (let ((elt (tags-table-list-member tags-file-name))) | |
437 (or elt | |
438 ;; The table is not in the current set. | |
439 ;; Try to find it in another previously used set. | |
440 (let ((sets tags-table-set-list)) | |
441 (while (and sets | |
442 (not (setq elt (tags-table-list-member | |
443 tags-file-name (car sets))))) | |
444 (setq sets (cdr sets))) | |
445 (if sets | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
446 ;; Found in some other set. Switch to that set. |
1149 | 447 (progn |
1138 | 448 (or (memq tags-table-list tags-table-set-list) |
1149 | 449 ;; Save the current list. |
1138 | 450 (setq tags-table-set-list |
451 (cons tags-table-list | |
452 tags-table-set-list))) | |
1149 | 453 (setq tags-table-list (car sets))) |
454 | |
455 ;; Not found in any existing set. | |
456 (if (and tags-table-list | |
457 (y-or-n-p (concat "Add " tags-file-name | |
458 " to current list" | |
459 " of tags tables? "))) | |
460 ;; Add it to the current list. | |
461 (setq tags-table-list (cons tags-file-name | |
462 tags-table-list)) | |
463 ;; Make a fresh list, and store the old one. | |
464 (or (memq tags-table-list tags-table-set-list) | |
465 (setq tags-table-set-list | |
466 (cons tags-table-list tags-table-set-list))) | |
467 (setq tags-table-list (list tags-file-name))) | |
468 (setq elt tags-table-list)))) | |
469 | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
470 ;; Set the tags table list state variables to point at the table |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
471 ;; we want to use first. |
1149 | 472 (setq tags-table-list-started-at elt |
1156 | 473 tags-table-list-pointer elt))) |
474 | |
475 ;; Return of t says the tags table is valid. | |
476 t) | |
1149 | 477 |
478 ;; The buffer was not valid. Don't use it again. | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
479 (let ((file tags-file-name)) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
480 (kill-local-variable 'tags-file-name) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
481 (if (eq file tags-file-name) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
482 (setq tags-file-name nil))) |
1149 | 483 (error "File %s is not a valid tags table" buffer-file-name)))) |
1397
d469afe703c4
(visit-tags-table-buffer): When trying to pick table, call
Roland McGrath <roland@gnu.org>
parents:
1156
diff
changeset
|
484 |
342 | 485 (defun file-of-tag () |
486 "Return the file name of the file whose tags point is within. | |
799 | 487 Assumes the tags table is the current buffer. |
488 File name returned is relative to tags table file's directory." | |
489 (funcall file-of-tag-function)) | |
342 | 490 |
360 | 491 ;;;###autoload |
799 | 492 (defun tags-table-files () |
493 "Return a list of files in the current tags table. | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
494 Assumes the tags table is the current buffer. |
342 | 495 File names returned are absolute." |
1397
d469afe703c4
(visit-tags-table-buffer): When trying to pick table, call
Roland McGrath <roland@gnu.org>
parents:
1156
diff
changeset
|
496 (or tags-table-files |
d469afe703c4
(visit-tags-table-buffer): When trying to pick table, call
Roland McGrath <roland@gnu.org>
parents:
1156
diff
changeset
|
497 (setq tags-table-files |
d469afe703c4
(visit-tags-table-buffer): When trying to pick table, call
Roland McGrath <roland@gnu.org>
parents:
1156
diff
changeset
|
498 (funcall tags-table-files-function)))) |
799 | 499 |
500 (defun tags-included-tables () | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
501 "Return a list of tags tables included by the current table. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
502 Assumes the tags table is the current buffer." |
799 | 503 (or tags-included-tables |
504 (setq tags-included-tables (funcall tags-included-tables-function)))) | |
505 | |
506 ;; Build tags-completion-table on demand. The single current tags table | |
507 ;; and its included tags tables (and their included tables, etc.) have | |
508 ;; their tags included in the completion table. | |
509 (defun tags-completion-table () | |
510 (or tags-completion-table | |
511 (condition-case () | |
512 (prog2 | |
513 (message "Making tags completion table for %s..." buffer-file-name) | |
514 (let ((included (tags-included-tables)) | |
515 (table (funcall tags-completion-table-function))) | |
516 (save-excursion | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
517 ;; Iterate over the list of included tables, and combine each |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
518 ;; included table's completion obarray to the parent obarray. |
799 | 519 (while included |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
520 ;; Visit the buffer. |
799 | 521 (let ((tags-file-name (car included))) |
1149 | 522 (visit-tags-table-buffer 'same)) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
523 ;; Recurse in that buffer to compute its completion table. |
799 | 524 (if (tags-completion-table) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
525 ;; Combine the tables. |
799 | 526 (mapatoms (function |
527 (lambda (sym) | |
528 (intern (symbol-name sym) table))) | |
529 tags-completion-table)) | |
530 (setq included (cdr included)))) | |
531 (setq tags-completion-table table)) | |
532 (message "Making tags completion table for %s...done" | |
533 buffer-file-name)) | |
534 (quit (message "Tags completion table construction aborted.") | |
535 (setq tags-completion-table nil))))) | |
536 | |
537 ;; Completion function for tags. Does normal try-completion, | |
538 ;; but builds tags-completion-table on demand. | |
539 (defun tags-complete-tag (string predicate what) | |
540 (save-excursion | |
541 (visit-tags-table-buffer) | |
542 (if (eq what t) | |
543 (all-completions string (tags-completion-table) predicate) | |
544 (try-completion string (tags-completion-table) predicate)))) | |
1397
d469afe703c4
(visit-tags-table-buffer): When trying to pick table, call
Roland McGrath <roland@gnu.org>
parents:
1156
diff
changeset
|
545 |
342 | 546 ;; Return a default tag to search for, based on the text at point. |
547 (defun find-tag-default () | |
548 (save-excursion | |
549 (while (looking-at "\\sw\\|\\s_") | |
550 (forward-char 1)) | |
799 | 551 (if (or (re-search-backward "\\sw\\|\\s_" |
552 (save-excursion (beginning-of-line) (point)) | |
553 t) | |
554 (re-search-forward "\\(\\sw\\|\\s_\\)+" | |
555 (save-excursion (end-of-line) (point)) | |
556 t)) | |
557 (progn (goto-char (match-end 0)) | |
342 | 558 (buffer-substring (point) |
559 (progn (forward-sexp -1) | |
560 (while (looking-at "\\s'") | |
561 (forward-char 1)) | |
562 (point)))) | |
563 nil))) | |
564 | |
799 | 565 ;; Read a tag name from the minibuffer with defaulting and completion. |
342 | 566 (defun find-tag-tag (string) |
799 | 567 (let* ((default (funcall (or find-tag-default-function |
568 (get major-mode 'find-tag-default-function) | |
569 'find-tag-default))) | |
570 (spec (completing-read (if default | |
571 (format "%s(default %s) " string default) | |
572 string) | |
573 'tags-complete-tag))) | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
574 (if (equal spec "") |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
575 (or default (error "There is no default tag")) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
576 spec))) |
342 | 577 |
852 | 578 (defvar last-tag nil |
579 "Last tag found by \\[find-tag].") | |
580 | |
799 | 581 ;;;###autoload |
582 (defun find-tag-noselect (tagname &optional next-p regexp-p) | |
583 "Find tag (in current tags table) whose name contains TAGNAME. | |
1555
695c6eb2ff31
* etags.el (find-tag-noselect): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1397
diff
changeset
|
584 Returns the buffer containing the tag's definition and moves its point there, |
799 | 585 but does not select the buffer. |
586 The default for TAGNAME is the expression in the buffer near point. | |
474 | 587 |
799 | 588 If second arg NEXT-P is non-nil (interactively, with prefix arg), search |
589 for another tag that matches the last tagname or regexp used. When there | |
590 are multiple matches for a tag, more exact matches are found first. | |
450
0bac8c701777
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
449
diff
changeset
|
591 |
799 | 592 If third arg REGEXP-P is non-nil, treat TAGNAME as a regexp. |
342 | 593 |
799 | 594 See documentation of variable `tags-file-name'." |
342 | 595 (interactive (if current-prefix-arg |
596 '(nil t) | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
597 (list (find-tag-tag "Find tag: ")))) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
598 ;; Save the current buffer's value of `find-tag-hook' before selecting the |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
599 ;; tags table buffer. |
799 | 600 (let ((local-find-tag-hook find-tag-hook)) |
852 | 601 (if next-p |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
602 ;; Find the same table we last used. |
981 | 603 (visit-tags-table-buffer 'same) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
604 ;; Pick a table to use. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
605 (visit-tags-table-buffer) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
606 ;; Record TAGNAME for a future call with NEXT-P non-nil. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
607 (setq last-tag tagname)) |
852 | 608 (prog1 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
609 ;; find-tag-in-order does the real work. |
852 | 610 (find-tag-in-order (if next-p last-tag tagname) |
611 (if regexp-p | |
612 find-tag-regexp-search-function | |
613 find-tag-search-function) | |
614 (if regexp-p | |
615 find-tag-regexp-tag-order | |
616 find-tag-tag-order) | |
617 (if regexp-p | |
618 find-tag-regexp-next-line-after-failure-p | |
619 find-tag-next-line-after-failure-p) | |
620 (if regexp-p "matching" "containing") | |
621 (not next-p)) | |
622 (run-hooks 'local-find-tag-hook)))) | |
360 | 623 |
624 ;;;###autoload | |
799 | 625 (defun find-tag (tagname &optional next-p) |
626 "Find tag (in current tags table) whose name contains TAGNAME. | |
627 Select the buffer containing the tag's definition, and move point there. | |
628 The default for TAGNAME is the expression in the buffer around or before point. | |
342 | 629 |
799 | 630 If second arg NEXT-P is non-nil (interactively, with prefix arg), search |
631 for another tag that matches the last tagname used. When there are | |
632 multiple matches, more exact matches are found first. | |
633 | |
634 See documentation of variable `tags-file-name'." | |
342 | 635 (interactive (if current-prefix-arg |
636 '(nil t) | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
637 (list (find-tag-tag "Find tag: ")))) |
799 | 638 (switch-to-buffer (find-tag-noselect tagname next-p))) |
639 ;;;###autoload (define-key esc-map "." 'find-tag) | |
342 | 640 |
727 | 641 ;;;###autoload |
799 | 642 (defun find-tag-other-window (tagname &optional next-p) |
643 "Find tag (in current tags table) whose name contains TAGNAME. | |
644 Select the buffer containing the tag's definition | |
645 in another window, and move point there. | |
646 The default for TAGNAME is the expression in the buffer around or before point. | |
647 | |
648 If second arg NEXT-P is non-nil (interactively, with prefix arg), search | |
649 for another tag that matches the last tagname used. When there are | |
650 multiple matches, more exact matches are found first. | |
651 | |
652 See documentation of variable `tags-file-name'." | |
653 (interactive (if current-prefix-arg | |
654 '(nil t) | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
655 (list (find-tag-tag "Find tag other window: ")))) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
656 ;; This hair is to deal with the case where the tag is found in the |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
657 ;; selected window's buffer; without the hair, point is moved in both |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
658 ;; windows. To prevent this, we save the selected window's point before |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
659 ;; doing find-tag-noselect, and restore it after. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
660 (let* ((window-point (window-point (selected-window))) |
1976
eda7eec8f8ad
* etags.el (find-tag-other-window): If another window is already
Jim Blandy <jimb@redhat.com>
parents:
1816
diff
changeset
|
661 (tagbuf (find-tag-noselect tagname next-p)) |
eda7eec8f8ad
* etags.el (find-tag-other-window): If another window is already
Jim Blandy <jimb@redhat.com>
parents:
1816
diff
changeset
|
662 (tagpoint (progn (set-buffer tagbuf) (point)))) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
663 (set-window-point (prog1 |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
664 (selected-window) |
1976
eda7eec8f8ad
* etags.el (find-tag-other-window): If another window is already
Jim Blandy <jimb@redhat.com>
parents:
1816
diff
changeset
|
665 (switch-to-buffer-other-window tagbuf) |
eda7eec8f8ad
* etags.el (find-tag-other-window): If another window is already
Jim Blandy <jimb@redhat.com>
parents:
1816
diff
changeset
|
666 ;; We have to set this new window's point; it |
eda7eec8f8ad
* etags.el (find-tag-other-window): If another window is already
Jim Blandy <jimb@redhat.com>
parents:
1816
diff
changeset
|
667 ;; might already have been displaying a |
eda7eec8f8ad
* etags.el (find-tag-other-window): If another window is already
Jim Blandy <jimb@redhat.com>
parents:
1816
diff
changeset
|
668 ;; different portion of tagbuf, in which case |
eda7eec8f8ad
* etags.el (find-tag-other-window): If another window is already
Jim Blandy <jimb@redhat.com>
parents:
1816
diff
changeset
|
669 ;; switch-to-buffer-other-window doesn't set |
eda7eec8f8ad
* etags.el (find-tag-other-window): If another window is already
Jim Blandy <jimb@redhat.com>
parents:
1816
diff
changeset
|
670 ;; the window's point from the buffer. |
eda7eec8f8ad
* etags.el (find-tag-other-window): If another window is already
Jim Blandy <jimb@redhat.com>
parents:
1816
diff
changeset
|
671 (set-window-point (selected-window) tagpoint)) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
672 window-point))) |
799 | 673 ;;;###autoload (define-key ctl-x-4-map "." 'find-tag-other-window) |
674 | |
804 | 675 ;;;###autoload |
799 | 676 (defun find-tag-other-frame (tagname &optional next-p) |
727 | 677 "Find tag (in current tag table) whose name contains TAGNAME. |
678 Selects the buffer that the tag is contained in in another frame | |
679 and puts point at its definition. | |
680 If TAGNAME is a null string, the expression in the buffer | |
681 around or before point is used as the tag name. | |
799 | 682 If second arg NEXT-P is non-nil (interactively, with prefix arg), |
727 | 683 searches for the next tag in the tag table |
684 that matches the tagname used in the previous find-tag. | |
685 | |
799 | 686 See documentation of variable `tags-file-name'." |
727 | 687 (interactive (if current-prefix-arg |
688 '(nil t) | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
689 (list (find-tag-tag "Find tag other window: ")))) |
799 | 690 (let ((pop-up-frames t)) |
691 (find-tag-other-window tagname next-p))) | |
692 ;;;###autoload (define-key ctl-x-5-map "." 'find-tag-other-frame) | |
342 | 693 |
360 | 694 ;;;###autoload |
799 | 695 (defun find-tag-regexp (regexp &optional next-p other-window) |
696 "Find tag (in current tags table) whose name matches REGEXP. | |
697 Select the buffer containing the tag's definition and move point there. | |
698 | |
699 If second arg NEXT-P is non-nil (interactively, with prefix arg), search | |
700 for another tag that matches the last tagname used. | |
701 | |
702 If third arg OTHER-WINDOW is non-nil, select the buffer in another window. | |
703 | |
704 See documentation of variable `tags-file-name'." | |
705 (interactive (if current-prefix-arg | |
706 '(nil t) | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
707 (list (read-string "Find tag regexp: ")))) |
799 | 708 (funcall (if other-window 'switch-to-buffer-other-window 'switch-to-buffer) |
709 (find-tag-noselect regexp next-p t))) | |
710 | |
711 ;; Internal tag finding function. | |
712 | |
713 ;; PATTERN is a string to pass to second arg SEARCH-FORWARD-FUNC, and to | |
714 ;; any member of the function list ORDER (third arg). If ORDER is nil, | |
715 ;; use saved state to continue a previous search. | |
716 | |
717 ;; Fourth arg MATCHING is a string, an English '-ing' word, to be used in | |
718 ;; an error message. | |
719 | |
720 ;; Fifth arg NEXT-LINE-AFTER-FAILURE-P is non-nil if after a failed match, | |
721 ;; point should be moved to the next line. | |
722 | |
723 ;; Algorithm is as follows. For each qualifier-func in ORDER, go to | |
724 ;; beginning of tags file, and perform inner loop: for each naive match for | |
725 ;; PATTERN found using SEARCH-FORWARD-FUNC, qualify the naive match using | |
726 ;; qualifier-func. If it qualifies, go to the specified line in the | |
727 ;; specified source file and return. Qualified matches are remembered to | |
728 ;; avoid repetition. State is saved so that the loop can be continued. | |
729 | |
1555
695c6eb2ff31
* etags.el (find-tag-noselect): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1397
diff
changeset
|
730 (defun find-tag-in-order (pattern |
695c6eb2ff31
* etags.el (find-tag-noselect): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1397
diff
changeset
|
731 search-forward-func |
695c6eb2ff31
* etags.el (find-tag-noselect): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1397
diff
changeset
|
732 order |
695c6eb2ff31
* etags.el (find-tag-noselect): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1397
diff
changeset
|
733 next-line-after-failure-p |
695c6eb2ff31
* etags.el (find-tag-noselect): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1397
diff
changeset
|
734 matching |
695c6eb2ff31
* etags.el (find-tag-noselect): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1397
diff
changeset
|
735 first-search) |
799 | 736 (let (file ;name of file containing tag |
737 tag-info ;where to find the tag in FILE | |
738 tags-table-file ;name of tags file | |
739 (first-table t) | |
740 (tag-order order) | |
741 goto-func | |
742 ) | |
743 (save-excursion | |
1149 | 744 (or first-search ;find-tag-noselect has already done it. |
745 (visit-tags-table-buffer 'same)) | |
746 | |
799 | 747 ;; Get a qualified match. |
748 (catch 'qualified-match-found | |
1149 | 749 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
750 ;; Iterate over the list of tags tables. |
799 | 751 (while (or first-table |
752 (visit-tags-table-buffer t)) | |
753 | |
754 (if first-search | |
755 (setq tag-lines-already-matched nil)) | |
756 | |
884 | 757 (and first-search first-table |
758 ;; Start at beginning of tags file. | |
759 (goto-char (point-min))) | |
760 (setq first-table nil) | |
799 | 761 |
762 (setq tags-table-file buffer-file-name) | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
763 ;; Iterate over the list of ordering predicates. |
799 | 764 (while order |
765 (while (funcall search-forward-func pattern nil t) | |
766 ;; Naive match found. Qualify the match. | |
767 (and (funcall (car order) pattern) | |
768 ;; Make sure it is not a previous qualified match. | |
769 ;; Use of `memq' depends on numbers being eq. | |
770 (not (memq (save-excursion (beginning-of-line) (point)) | |
771 tag-lines-already-matched)) | |
772 (throw 'qualified-match-found nil)) | |
773 (if next-line-after-failure-p | |
774 (forward-line 1))) | |
775 ;; Try the next flavor of match. | |
776 (setq order (cdr order)) | |
777 (goto-char (point-min))) | |
778 (setq order tag-order)) | |
779 ;; We throw out on match, so only get here if there were no matches. | |
780 (error "No %stags %s %s" (if first-search "" "more ") | |
781 matching pattern)) | |
782 | |
783 ;; Found a tag; extract location info. | |
784 (beginning-of-line) | |
785 (setq tag-lines-already-matched (cons (point) | |
786 tag-lines-already-matched)) | |
787 ;; Expand the filename, using the tags table buffer's default-directory. | |
788 (setq file (expand-file-name (file-of-tag)) | |
789 tag-info (funcall snarf-tag-function)) | |
790 | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
791 ;; Get the local value in the tags table buffer before switching buffers. |
799 | 792 (setq goto-func goto-tag-location-function) |
793 | |
794 ;; Find the right line in the specified file. | |
795 (set-buffer (find-file-noselect file)) | |
796 (widen) | |
797 (push-mark) | |
798 (funcall goto-func tag-info) | |
799 | |
800 ;; Give this buffer a local value of tags-file-name. | |
801 ;; The next time visit-tags-table-buffer is called, | |
802 ;; it will use the same tags table that found a match in this buffer. | |
803 (make-local-variable 'tags-file-name) | |
804 (setq tags-file-name tags-table-file) | |
805 | |
806 ;; Return the buffer where the tag was found. | |
807 (current-buffer)))) | |
808 | |
809 ;; `etags' TAGS file format support. | |
810 | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
811 ;; If the current buffer is a valid etags TAGS file, give it local values of |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
812 ;; the tags table format variables, and return non-nil. |
799 | 813 (defun etags-recognize-tags-table () |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
814 (and (etags-verify-tags-table) |
1136 | 815 ;; It is annoying to flash messages on the screen briefly, |
816 ;; and this message is not useful. -- rms | |
817 ;; (message "%s is an `etags' TAGS file" buffer-file-name) | |
799 | 818 (mapcar (function (lambda (elt) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
819 (set (make-local-variable (car elt)) (cdr elt)))) |
799 | 820 '((file-of-tag-function . etags-file-of-tag) |
821 (tags-table-files-function . etags-tags-table-files) | |
822 (tags-completion-table-function . etags-tags-completion-table) | |
823 (snarf-tag-function . etags-snarf-tag) | |
824 (goto-tag-location-function . etags-goto-tag-location) | |
825 (find-tag-regexp-search-function . re-search-forward) | |
826 (find-tag-regexp-tag-order . (tag-re-match-p)) | |
827 (find-tag-regexp-next-line-after-failuire-p . t) | |
828 (find-tag-search-function . search-forward) | |
829 (find-tag-tag-order . (tag-exact-match-p tag-word-match-p | |
830 tag-any-match-p)) | |
831 (find-tag-next-line-after-failure-p . nil) | |
832 (list-tags-function . etags-list-tags) | |
833 (tags-apropos-function . etags-tags-apropos) | |
834 (tags-included-tables-function . etags-tags-included-tables) | |
835 (verify-tags-table-function . etags-verify-tags-table) | |
836 )))) | |
837 | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
838 ;; Return non-nil iff the current buffer is a valid etags TAGS file. |
799 | 839 (defun etags-verify-tags-table () |
1723
4023bea27d64
(etags-verify-tags-table): Use eq instead of = in case char-after returns
Roland McGrath <roland@gnu.org>
parents:
1697
diff
changeset
|
840 ;; Use eq instead of = in case char-after returns nil. |
4023bea27d64
(etags-verify-tags-table): Use eq instead of = in case char-after returns
Roland McGrath <roland@gnu.org>
parents:
1697
diff
changeset
|
841 (eq (char-after 1) ?\f)) |
799 | 842 |
843 (defun etags-file-of-tag () | |
844 (save-excursion | |
845 (search-backward "\f\n") | |
846 (forward-char 2) | |
847 (buffer-substring (point) | |
848 (progn (skip-chars-forward "^,") (point))))) | |
849 | |
850 (defun etags-tags-completion-table () | |
851 (let ((table (make-vector 511 0))) | |
852 (save-excursion | |
853 (goto-char (point-min)) | |
2448
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
854 ;; This monster regexp matches an etags tag line. |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
855 ;; \1 is the string to match; |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
856 ;; \2 is not interesting; |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
857 ;; \3 is the guessed tag name; XXX guess should be better eg DEFUN |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
858 ;; \4 is the char to start searching at; |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
859 ;; \5 is the line to start searching at; |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
860 ;; \6 is not interesting; |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
861 ;; \7 is the explicitly-specified tag name. |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
862 (while (re-search-forward |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
863 "^\\(\\(.+[ \t]+\\)?\\([-a-zA-Z0-9_$]+\\)[^-a-zA-Z0-9_$]*\\)\177\ |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
864 \\([0-9]+\\),\\([0-9]+\\)\\(,\001\\([^\n]+\\)\\)?\n" |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
865 nil t) |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
866 (intern (if (match-beginning 6) |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
867 ;; There is an explicit tag name. |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
868 (buffer-substring (match-beginning 6) (match-end 6)) |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
869 ;; No explicit tag name. Best guess. |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
870 (buffer-substring (match-beginning 3) (match-end 3))) |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
871 table))) |
799 | 872 table)) |
873 | |
874 (defun etags-snarf-tag () | |
875 (let (tag-text startpos) | |
876 (search-forward "\177") | |
877 (setq tag-text (buffer-substring (1- (point)) | |
878 (save-excursion (beginning-of-line) | |
879 (point)))) | |
880 (search-forward ",") | |
881 (setq startpos (string-to-int (buffer-substring | |
882 (point) | |
883 (progn (skip-chars-forward "0-9") | |
884 (point))))) | |
885 ;; Leave point on the next line of the tags file. | |
886 (forward-line 1) | |
887 (cons tag-text startpos))) | |
888 | |
889 (defun etags-goto-tag-location (tag-info) | |
890 (let ((startpos (cdr tag-info)) | |
891 ;; This constant is 1/2 the initial search window. | |
892 ;; There is no sense in making it too small, | |
893 ;; since just going around the loop once probably | |
894 ;; costs about as much as searching 2000 chars. | |
895 (offset 1000) | |
896 (found nil) | |
897 (pat (concat "^" (regexp-quote (car tag-info))))) | |
898 (or startpos | |
899 (setq startpos (point-min))) | |
900 (while (and (not found) | |
901 (progn | |
902 (goto-char (- startpos offset)) | |
903 (not (bobp)))) | |
904 (setq found | |
905 (re-search-forward pat (+ startpos offset) t) | |
906 offset (* 3 offset))) ; expand search window | |
907 (or found | |
908 (re-search-forward pat nil t) | |
909 (error "`%s' not found in %s; time to rerun etags" | |
910 pat buffer-file-name))) | |
911 (beginning-of-line)) | |
912 | |
913 (defun etags-list-tags (file) | |
914 (goto-char 1) | |
915 (if (not (search-forward (concat "\f\n" file ",") nil t)) | |
916 nil | |
917 (forward-line 1) | |
918 (while (not (or (eobp) (looking-at "\f"))) | |
919 (princ (buffer-substring (point) | |
920 (progn (skip-chars-forward "^\177") | |
921 (point)))) | |
922 (terpri) | |
923 (forward-line 1)))) | |
924 | |
925 (defun etags-tags-apropos (string) | |
926 (goto-char 1) | |
927 (while (re-search-forward string nil t) | |
928 (beginning-of-line) | |
929 (princ (buffer-substring (point) | |
930 (progn (skip-chars-forward "^\177") | |
931 (point)))) | |
932 (terpri) | |
933 (forward-line 1))) | |
934 | |
935 (defun etags-tags-table-files () | |
936 (let ((files nil) | |
937 beg) | |
938 (goto-char (point-min)) | |
939 (while (search-forward "\f\n" nil t) | |
940 (setq beg (point)) | |
941 (skip-chars-forward "^,\n") | |
942 (or (looking-at ",include$") | |
943 ;; Expand in the default-directory of the tags table buffer. | |
944 (setq files (cons (expand-file-name (buffer-substring beg (point))) | |
945 files)))) | |
946 (nreverse files))) | |
947 | |
948 (defun etags-tags-included-tables () | |
949 (let ((files nil) | |
950 beg) | |
951 (goto-char (point-min)) | |
952 (while (search-forward "\f\n" nil t) | |
953 (setq beg (point)) | |
954 (skip-chars-forward "^,\n") | |
955 (if (looking-at ",include$") | |
956 ;; Expand in the default-directory of the tags table buffer. | |
957 (setq files (cons (expand-file-name (buffer-substring beg (point))) | |
958 files)))) | |
959 (nreverse files))) | |
960 | |
961 ;; Empty tags file support. | |
962 | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
963 ;; Recognize an empty file and give it local values of the tags table format |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
964 ;; variables which do nothing. |
799 | 965 (defun recognize-empty-tags-table () |
966 (and (zerop (buffer-size)) | |
967 (mapcar (function (lambda (sym) | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
968 (set (make-local-variable sym) 'ignore))) |
799 | 969 '(tags-table-files-function |
970 tags-completion-table-function | |
971 find-tag-regexp-search-function | |
972 find-tag-search-function | |
973 tags-apropos-function | |
974 tags-included-tables-function)) | |
975 (set (make-local-variable 'verify-tags-table-function) | |
976 (function (lambda () | |
977 (zerop (buffer-size))))))) | |
978 | |
979 ;;; Match qualifier functions for tagnames. | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
980 ;;; XXX these functions assume etags file format. |
799 | 981 |
884 | 982 ;; This might be a neat idea, but it's too hairy at the moment. |
983 ;;(defmacro tags-with-syntax (&rest body) | |
984 ;; (` (let ((current (current-buffer)) | |
985 ;; (otable (syntax-table)) | |
986 ;; (buffer (find-file-noselect (file-of-tag))) | |
987 ;; table) | |
988 ;; (unwind-protect | |
989 ;; (progn | |
990 ;; (set-buffer buffer) | |
991 ;; (setq table (syntax-table)) | |
992 ;; (set-buffer current) | |
993 ;; (set-syntax-table table) | |
994 ;; (,@ body)) | |
995 ;; (set-syntax-table otable))))) | |
996 ;;(put 'tags-with-syntax 'edebug-form-spec '(&rest form)) | |
877 | 997 |
799 | 998 ;; t if point is at a tag line that matches TAG "exactly". |
999 ;; point should be just after a string that matches TAG. | |
884 | 1000 (defun tag-exact-match-p (tag) |
1001 (and (looking-at "\\Sw.*\177") (looking-at "\\S_.*\177") ;not a symbol char | |
1002 (save-excursion | |
1003 (backward-char (1+ (length tag))) | |
1004 (and (looking-at "\\Sw") (looking-at "\\S_"))))) | |
799 | 1005 |
1006 ;; t if point is at a tag line that matches TAG as a word. | |
1007 ;; point should be just after a string that matches TAG. | |
1008 (defun tag-word-match-p (tag) | |
1009 (and (looking-at "\\b.*\177") | |
1010 (save-excursion (backward-char (1+ (length tag))) | |
1011 (looking-at "\\b")))) | |
1012 | |
1013 ;; t if point is in a tag line with a tag containing TAG as a substring. | |
1014 (defun tag-any-match-p (tag) | |
1015 (looking-at ".*\177")) | |
1016 | |
1017 ;; t if point is at a tag line that matches RE as a regexp. | |
1018 (defun tag-re-match-p (re) | |
1019 (save-excursion | |
1020 (beginning-of-line) | |
1021 (let ((bol (point))) | |
1022 (and (search-forward "\177" (save-excursion (end-of-line) (point)) t) | |
1023 (re-search-backward re bol t))))) | |
1024 | |
1025 ;;;###autoload | |
1026 (defun next-file (&optional initialize novisit) | |
1027 "Select next file among files in current tags table. | |
1028 Non-nil first argument (prefix arg, if interactive) | |
1029 initializes to the beginning of the list of files in the tags table. | |
1030 | |
1031 Non-nil second argument NOVISIT means use a temporary buffer | |
1032 to save time and avoid uninteresting warnings. | |
1033 | |
1034 Value is nil if the file was already visited; | |
1035 if the file was newly read in, the value is the filename." | |
342 | 1036 (interactive "P") |
799 | 1037 (and initialize |
1038 (save-excursion | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
1039 ;; Visit the tags table buffer to get its list of files. |
1149 | 1040 (visit-tags-table-buffer) |
799 | 1041 (setq next-file-list (tags-table-files)))) |
342 | 1042 (or next-file-list |
799 | 1043 (save-excursion |
1397
d469afe703c4
(visit-tags-table-buffer): When trying to pick table, call
Roland McGrath <roland@gnu.org>
parents:
1156
diff
changeset
|
1044 ;; Get the files from the next tags table. |
1152 | 1045 ;; When doing (visit-tags-table-buffer t), |
799 | 1046 ;; the tags table buffer must be current. |
1047 (if (and (visit-tags-table-buffer 'same) | |
1048 (visit-tags-table-buffer t)) | |
1049 (setq next-file-list (tags-table-files)) | |
1050 (and novisit | |
1051 (get-buffer " *next-file*") | |
1052 (kill-buffer " *next-file*")) | |
1053 (error "All files processed.")))) | |
1054 (let ((new (not (get-file-buffer (car next-file-list))))) | |
1055 (if (not (and new novisit)) | |
1056 (set-buffer (find-file-noselect (car next-file-list) novisit)) | |
1057 ;; Like find-file, but avoids random warning messages. | |
1058 (set-buffer (get-buffer-create " *next-file*")) | |
1059 (kill-all-local-variables) | |
1060 (erase-buffer) | |
1061 (setq new (car next-file-list)) | |
1062 (insert-file-contents new nil)) | |
1063 (setq next-file-list (cdr next-file-list)) | |
1064 new)) | |
342 | 1065 |
799 | 1066 (defvar tags-loop-operate nil |
1067 "Form for `tags-loop-continue' to eval to change one file.") | |
1068 | |
1808
60685747963c
(tags-loop-scan): Set default value to an error form.
Roland McGrath <roland@gnu.org>
parents:
1807
diff
changeset
|
1069 (defvar tags-loop-scan |
60685747963c
(tags-loop-scan): Set default value to an error form.
Roland McGrath <roland@gnu.org>
parents:
1807
diff
changeset
|
1070 '(error (substitute-command-keys |
60685747963c
(tags-loop-scan): Set default value to an error form.
Roland McGrath <roland@gnu.org>
parents:
1807
diff
changeset
|
1071 "No \\[tags-search] or \\[tags-query-replace] in progress.")) |
799 | 1072 "Form for `tags-loop-continue' to eval to scan one file. |
1073 If it returns non-nil, this file needs processing by evalling | |
1074 \`tags-loop-operate'. Otherwise, move on to the next file.") | |
342 | 1075 |
360 | 1076 ;;;###autoload |
342 | 1077 (defun tags-loop-continue (&optional first-time) |
1078 "Continue last \\[tags-search] or \\[tags-query-replace] command. | |
799 | 1079 Used noninteractively with non-nil argument to begin such a command. |
1080 Two variables control the processing we do on each file: | |
1081 the value of `tags-loop-scan' is a form to be executed on each file | |
1082 to see if it is interesting (it returns non-nil if so) | |
1083 and `tags-loop-operate' is a form to execute to operate on an interesting file | |
1084 If the latter returns non-nil, we exit; otherwise we scan the next file." | |
342 | 1085 (interactive) |
799 | 1086 (let (new |
1087 (messaged nil)) | |
1088 (while | |
1089 (progn | |
1090 ;; Scan files quickly for the first or next interesting one. | |
1091 (while (or first-time | |
1092 (save-restriction | |
1093 (widen) | |
1094 (not (eval tags-loop-scan)))) | |
1095 (setq new (next-file first-time t)) | |
1096 ;; If NEW is non-nil, we got a temp buffer, | |
1097 ;; and NEW is the file name. | |
1098 (if (or messaged | |
1099 (and (not first-time) | |
1100 (> baud-rate search-slow-speed) | |
1101 (setq messaged t))) | |
1102 (message "Scanning file %s..." (or new buffer-file-name))) | |
1103 (setq first-time nil) | |
1104 (goto-char (point-min))) | |
1105 | |
1106 ;; If we visited it in a temp buffer, visit it now for real. | |
1107 (if new | |
1108 (let ((pos (point))) | |
1109 (erase-buffer) | |
1110 (set-buffer (find-file-noselect new)) | |
1111 (widen) | |
1112 (goto-char pos))) | |
1113 | |
1114 (switch-to-buffer (current-buffer)) | |
1115 | |
1116 ;; Now operate on the file. | |
1117 ;; If value is non-nil, continue to scan the next file. | |
1118 (eval tags-loop-operate))) | |
1119 (and messaged | |
1120 (null tags-loop-operate) | |
1121 (message "Scanning file %s...found" buffer-file-name)))) | |
1122 ;;;###autoload (define-key esc-map "," 'tags-loop-continue) | |
342 | 1123 |
360 | 1124 ;;;###autoload |
342 | 1125 (defun tags-search (regexp) |
799 | 1126 "Search through all files listed in tags table for match for REGEXP. |
342 | 1127 Stops when a match is found. |
1128 To continue searching for next match, use command \\[tags-loop-continue]. | |
1129 | |
799 | 1130 See documentation of variable `tags-file-name'." |
342 | 1131 (interactive "sTags search (regexp): ") |
1132 (if (and (equal regexp "") | |
799 | 1133 (eq (car tags-loop-scan) 're-search-forward) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
1134 (null tags-loop-operate)) |
799 | 1135 ;; Continue last tags-search as if by M-,. |
342 | 1136 (tags-loop-continue nil) |
799 | 1137 (setq tags-loop-scan |
1138 (list 're-search-forward regexp nil t) | |
1139 tags-loop-operate nil) | |
342 | 1140 (tags-loop-continue t))) |
1141 | |
360 | 1142 ;;;###autoload |
342 | 1143 (defun tags-query-replace (from to &optional delimited) |
799 | 1144 "Query-replace-regexp FROM with TO through all files listed in tags table. |
342 | 1145 Third arg DELIMITED (prefix arg) means replace only word-delimited matches. |
799 | 1146 If you exit (\\[keyboard-quit] or ESC), you can resume the query-replace |
342 | 1147 with the command \\[tags-loop-continue]. |
1148 | |
799 | 1149 See documentation of variable `tags-file-name'." |
1150 (interactive | |
1151 "sTags query replace (regexp): \nsTags query replace %s by: \nP") | |
804 | 1152 (setq tags-loop-scan (list 'prog1 |
1816 | 1153 (list 'if (list 're-search-forward from nil t) |
804 | 1154 ;; When we find a match, move back |
1155 ;; to the beginning of it so perform-replace | |
1156 ;; will see it. | |
1157 '(goto-char (match-beginning 0)))) | |
799 | 1158 tags-loop-operate (list 'perform-replace from to t t delimited)) |
342 | 1159 (tags-loop-continue t)) |
799 | 1160 |
1161 ;;;###autoload | |
1162 (defun list-tags (file) | |
1163 "Display list of tags in file FILE. | |
1164 FILE should not contain a directory specification | |
1165 unless it has one in the tags table." | |
1166 (interactive (list (completing-read "List tags in file: " nil | |
1167 'tags-table-files t nil))) | |
1168 (with-output-to-temp-buffer "*Tags List*" | |
1169 (princ "Tags in file ") | |
1170 (princ file) | |
1171 (terpri) | |
1172 (save-excursion | |
1173 (let ((first-time t) | |
1174 (gotany nil)) | |
1149 | 1175 (while (visit-tags-table-buffer (not first-time)) |
799 | 1176 (if (funcall list-tags-function file) |
1177 (setq gotany t))) | |
1178 (or gotany | |
1179 (error "File %s not in current tags tables")))))) | |
342 | 1180 |
360 | 1181 ;;;###autoload |
799 | 1182 (defun tags-apropos (regexp) |
1183 "Display list of all tags in tags table REGEXP matches." | |
1184 (interactive "sTags apropos (regexp): ") | |
342 | 1185 (with-output-to-temp-buffer "*Tags List*" |
799 | 1186 (princ "Tags matching regexp ") |
1187 (prin1 regexp) | |
342 | 1188 (terpri) |
1189 (save-excursion | |
1149 | 1190 (let ((first-time t)) |
1191 (while (visit-tags-table-buffer (not first-time)) | |
1192 (setq first-time nil) | |
1151 | 1193 (funcall tags-apropos-function regexp)))))) |
799 | 1194 |
1195 ;;; XXX Kludge interface. | |
342 | 1196 |
799 | 1197 ;; XXX If a file is in multiple tables, selection may get the wrong one. |
804 | 1198 ;;;###autoload |
799 | 1199 (defun select-tags-table () |
1200 "Select a tags table file from a menu of those you have already used. | |
1201 The list of tags tables to select from is stored in `tags-table-file-list'; | |
1202 see the doc of that variable if you want to add names to the list." | |
1203 (interactive) | |
1204 (pop-to-buffer "*Tags Table List*") | |
1205 (setq buffer-read-only nil) | |
1206 (erase-buffer) | |
1207 (setq selective-display t | |
1208 selective-display-ellipses nil) | |
1209 (let ((set-list tags-table-set-list) | |
1210 (desired-point nil)) | |
1211 (if tags-table-list | |
1212 (progn | |
1213 (setq desired-point (point-marker)) | |
1214 (princ tags-table-list (current-buffer)) | |
1215 (insert "\C-m") | |
1216 (prin1 (car tags-table-list) (current-buffer)) ;invisible | |
1217 (insert "\n"))) | |
1218 (while set-list | |
1219 (if (eq (car set-list) tags-table-list) | |
1220 ;; Already printed it. | |
1221 () | |
1222 (princ (car set-list) (current-buffer)) | |
1223 (insert "\C-m") | |
1224 (prin1 (car (car set-list)) (current-buffer)) ;invisible | |
1225 (insert "\n")) | |
1226 (setq set-list (cdr set-list))) | |
1227 (if tags-file-name | |
1228 (progn | |
1229 (or desired-point | |
1230 (setq desired-point (point-marker))) | |
1231 (insert tags-file-name "\C-m") | |
1232 (prin1 tags-file-name (current-buffer)) ;invisible | |
1233 (insert "\n"))) | |
1234 (setq set-list (delete tags-file-name | |
1235 (apply 'nconc (cons tags-table-list | |
1236 (mapcar 'copy-sequence | |
1237 tags-table-set-list))))) | |
1238 (while set-list | |
1239 (insert (car set-list) "\C-m") | |
1240 (prin1 (car set-list) (current-buffer)) ;invisible | |
1241 (insert "\n") | |
1242 (setq set-list (delete (car set-list) set-list))) | |
1243 (goto-char 1) | |
1244 (insert-before-markers | |
1245 "Type `t' to select a tags table or set of tags tables:\n\n") | |
1246 (if desired-point | |
1247 (goto-char desired-point)) | |
1248 (set-window-start (selected-window) 1 t)) | |
1249 (set-buffer-modified-p nil) | |
1250 (setq buffer-read-only t | |
1251 mode-name "Select Tags Table") | |
1252 (let ((map (make-sparse-keymap))) | |
1253 (define-key map "t" 'select-tags-table-select) | |
1254 (define-key map " " 'next-line) | |
1255 (define-key map "\^?" 'previous-line) | |
1256 (define-key map "n" 'next-line) | |
1257 (define-key map "p" 'previous-line) | |
1258 (define-key map "q" 'select-tags-table-quit) | |
1259 (use-local-map map))) | |
1260 | |
1261 (defun select-tags-table-select () | |
1262 "Select the tags table named on this line." | |
1263 (interactive) | |
1264 (search-forward "\C-m") | |
1265 (let ((name (read (current-buffer)))) | |
1266 (visit-tags-table name) | |
1267 (select-tags-table-quit) | |
1268 (message "Tags table now %s" name))) | |
1269 | |
1270 (defun select-tags-table-quit () | |
1271 "Kill the buffer and delete the selected window." | |
1272 (interactive) | |
1273 (kill-buffer (current-buffer)) | |
1274 (or (one-window-p) | |
1275 (delete-window))) | |
1276 | |
360 | 1277 ;;;###autoload |
799 | 1278 (defun complete-tag () |
1279 "Perform tags completion on the text around point. | |
1280 Completes to the set of names listed in the current tags table. | |
1281 The string to complete is chosen in the same way as the default | |
981 | 1282 for \\[find-tag] (which see)." |
799 | 1283 (interactive) |
981 | 1284 (or tags-table-list |
1285 tags-file-name | |
1286 (error (substitute-command-keys | |
1287 "No tags table loaded. Try \\[visit-tags-table]."))) | |
799 | 1288 (let ((pattern (funcall (or find-tag-default-function |
1289 (get major-mode 'find-tag-default-function) | |
1290 'find-tag-default))) | |
1291 beg | |
1292 completion) | |
1293 (or pattern | |
1294 (error "Nothing to complete")) | |
1295 (search-backward pattern) | |
1296 (setq beg (point)) | |
1297 (forward-char (length pattern)) | |
1298 (setq completion (try-completion pattern 'tags-complete-tag nil)) | |
1299 (cond ((eq completion t)) | |
1300 ((null completion) | |
1301 (message "Can't find completion for \"%s\"" pattern) | |
1302 (ding)) | |
1303 ((not (string= pattern completion)) | |
1304 (delete-region beg (point)) | |
1305 (insert completion)) | |
1306 (t | |
1307 (message "Making completion list...") | |
1308 (with-output-to-temp-buffer " *Completions*" | |
1309 (display-completion-list | |
1310 (all-completions pattern 'tags-complete-tag nil))) | |
1311 (message "Making completion list...%s" "done"))))) | |
884 | 1312 |
1313 ;;;###autoload (define-key esc-map "\t" 'complete-tag) | |
799 | 1314 |
584 | 1315 (provide 'etags) |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
804
diff
changeset
|
1316 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
804
diff
changeset
|
1317 ;;; etags.el ends here |