Mercurial > emacs
annotate lisp/progmodes/etags.el @ 7565:edf32f56ba70
(ispell-highlight): Do nothing unless window-system.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 19 May 1994 21:19:39 +0000 |
parents | 0e89007c19c6 |
children | 202339c81fa4 |
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 |
5712
6a26b8998df1
(visit-tags-table-buffer): Don't change VISIT-TAGS-TABLE-BUFFER-CONT when
Roland McGrath <roland@gnu.org>
parents:
5279
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1988, 1989, 1992, 1993, 1994 |
1806
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 |
6140
35fc497c9f4e
(tags-add-tables): Change default value to 'ask-user; update doc.
Roland McGrath <roland@gnu.org>
parents:
5892
diff
changeset
|
45 ;;;###autoload |
35fc497c9f4e
(tags-add-tables): Change default value to 'ask-user; update doc.
Roland McGrath <roland@gnu.org>
parents:
5892
diff
changeset
|
46 (defvar tags-add-tables 'ask-user |
7112
91ba2f787c8f
(tags-add-tables): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6245
diff
changeset
|
47 "*Control whether to add a new tags table to the current list. |
91ba2f787c8f
(tags-add-tables): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6245
diff
changeset
|
48 t means do; nil means don't (always start a new list). |
91ba2f787c8f
(tags-add-tables): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6245
diff
changeset
|
49 Any other value means ask the user whether to add a new tags table |
5174
bb40928e9e47
(tags-add-tables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5079
diff
changeset
|
50 to the current list (as opposed to starting a new list).") |
bb40928e9e47
(tags-add-tables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5079
diff
changeset
|
51 |
799 | 52 (defvar tags-table-list-pointer nil |
1149 | 53 "Pointer into `tags-table-list' where the current state of searching is. |
54 Might instead point into a list of included tags tables. | |
55 Use `visit-tags-table-buffer' to cycle through tags tables in this list.") | |
56 | |
57 (defvar tags-table-list-started-at nil | |
58 "Pointer into `tags-table-list', where the current search started.") | |
342 | 59 |
799 | 60 (defvar tags-table-parent-pointer-list nil |
1149 | 61 "Saved state of the tags table that included this one. |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
62 Each element is (LIST POINTER STARTED-AT), giving the values of |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
63 `tags-table-list', `tags-table-list-pointer' and |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
64 `tags-table-list-started-at' from before we moved into the current table.") |
799 | 65 |
66 (defvar tags-table-set-list nil | |
67 "List of sets of tags table which have been used together in the past. | |
68 Each element is a list of strings which are file names.") | |
342 | 69 |
799 | 70 ;;;###autoload |
71 (defvar find-tag-hook nil | |
72 "*Hook to be run by \\[find-tag] after finding a tag. See `run-hooks'. | |
73 The value in the buffer in which \\[find-tag] is done is used, | |
74 not the value in the buffer \\[find-tag] goes to.") | |
75 | |
76 ;;;###autoload | |
77 (defvar find-tag-default-function nil | |
1149 | 78 "*A function of no arguments used by \\[find-tag] to pick a default tag. |
79 If nil, and the symbol that is the value of `major-mode' | |
799 | 80 has a `find-tag-default-function' property (see `put'), that is used. |
81 Otherwise, `find-tag-default' is used.") | |
342 | 82 |
799 | 83 (defvar default-tags-table-function nil |
5174
bb40928e9e47
(tags-add-tables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5079
diff
changeset
|
84 "If non-nil, a function to choose a default tags file for a buffer. |
bb40928e9e47
(tags-add-tables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5079
diff
changeset
|
85 This function receives no arguments and should return the default |
bb40928e9e47
(tags-add-tables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5079
diff
changeset
|
86 tags table file to use for the current buffer.") |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
87 |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
88 (defvar tags-location-stack nil |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
89 "List of markers which are locations visited by \\[find-tag]. |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
90 Pop back to the last location with \\[negative-argument] \\[find-tag].") |
799 | 91 |
92 ;; Tags table state. | |
93 ;; These variables are local in tags table buffers. | |
94 | |
95 (defvar tag-lines-already-matched nil | |
96 "List of positions of beginnings of lines within the tags table | |
97 that are already matched.") | |
98 | |
99 (defvar tags-table-files nil | |
100 "List of file names covered by current tags table. | |
101 nil means it has not yet been computed; use `tags-table-files' to do so.") | |
102 | |
103 (defvar tags-completion-table nil | |
104 "Alist of tag names defined in current tags table.") | |
105 | |
106 (defvar tags-included-tables nil | |
107 "List of tags tables included by the current tags table.") | |
108 | |
109 (defvar next-file-list nil | |
110 "List of files for \\[next-file] to process.") | |
111 | |
112 ;; Hooks for file formats. | |
113 | |
114 (defvar tags-table-format-hooks '(etags-recognize-tags-table | |
824 | 115 recognize-empty-tags-table) |
799 | 116 "List of functions to be called in a tags table buffer to identify |
117 the type of tags table. The functions are called in order, with no arguments, | |
118 until one returns non-nil. The function should make buffer-local bindings | |
119 of the format-parsing tags function variables if successful.") | |
120 | |
121 (defvar file-of-tag-function nil | |
122 "Function to do the work of `file-of-tag' (which see).") | |
123 (defvar tags-table-files-function nil | |
124 "Function to do the work of `tags-table-files' (which see).") | |
125 (defvar tags-completion-table-function nil | |
126 "Function to build the tags-completion-table.") | |
127 (defvar snarf-tag-function nil | |
128 "Function to get info about a matched tag for `goto-tag-location-function'.") | |
129 (defvar goto-tag-location-function nil | |
130 "Function of to go to the location in the buffer specified by a tag. | |
131 One argument, the tag info returned by `snarf-tag-function'.") | |
132 (defvar find-tag-regexp-search-function nil | |
133 "Search function passed to `find-tag-in-order' for finding a regexp tag.") | |
134 (defvar find-tag-regexp-tag-order nil | |
135 "Tag order passed to `find-tag-in-order' for finding a regexp tag.") | |
136 (defvar find-tag-regexp-next-line-after-failure-p nil | |
137 "Flag passed to `find-tag-in-order' for finding a regexp tag.") | |
138 (defvar find-tag-search-function nil | |
139 "Search function passed to `find-tag-in-order' for finding a tag.") | |
140 (defvar find-tag-tag-order nil | |
141 "Tag order passed to `find-tag-in-order' for finding a tag.") | |
142 (defvar find-tag-next-line-after-failure-p nil | |
143 "Flag passed to `find-tag-in-order' for finding a tag.") | |
144 (defvar list-tags-function nil | |
145 "Function to do the work of `list-tags' (which see).") | |
146 (defvar tags-apropos-function nil | |
147 "Function to do the work of `tags-apropos' (which see).") | |
148 (defvar tags-included-tables-function nil | |
149 "Function to do the work of `tags-included-tables' (which see).") | |
150 (defvar verify-tags-table-function nil | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3548
diff
changeset
|
151 "Function to return t iff the current buffer contains a valid |
799 | 152 \(already initialized\) tags file.") |
153 | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
154 ;; Initialize the tags table in the current buffer. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
155 ;; 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
|
156 ;; 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
|
157 ;; made buffer-local and initialized to nil. |
799 | 158 (defun initialize-new-tags-table () |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
159 (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
|
160 (set (make-local-variable 'tags-table-files) nil) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
161 (set (make-local-variable 'tags-completion-table) nil) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
162 (set (make-local-variable 'tags-included-tables) nil) |
799 | 163 ;; Value is t if we have found a valid tags table buffer. |
164 (let ((hooks tags-table-format-hooks)) | |
165 (while (and hooks | |
166 (not (funcall (car hooks)))) | |
167 (setq hooks (cdr hooks))) | |
168 hooks)) | |
169 | |
170 ;;;###autoload | |
171 (defun visit-tags-table (file &optional local) | |
172 "Tell tags commands to use tags table file FILE. | |
342 | 173 FILE should be the name of a file created with the `etags' program. |
799 | 174 A directory name is ok too; it means file TAGS in that directory. |
175 | |
176 Normally \\[visit-tags-table] sets the global value of `tags-file-name'. | |
177 With a prefix arg, set the buffer-local value instead. | |
178 When you find a tag with \\[find-tag], the buffer it finds the tag | |
179 in is given a local value of this variable which is the name of the tags | |
180 file the tag was in." | |
342 | 181 (interactive (list (read-file-name "Visit tags table: (default TAGS) " |
182 default-directory | |
799 | 183 (expand-file-name "TAGS" |
184 default-directory) | |
185 t) | |
186 current-prefix-arg)) | |
7287
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
187 (or (stringp file) (signal 'wrong-type-argument (list 'stringp file))) |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
188 ;; Bind tags-file-name so we can control below whether the local or |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
189 ;; global value gets set. Calling visit-tags-table-buffer will |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
190 ;; initialize a buffer for the file and set tags-file-name to the |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
191 ;; fully-expanded name. |
1138 | 192 (let ((tags-file-name file)) |
193 (save-excursion | |
7287
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
194 (or (visit-tags-table-buffer file) |
1138 | 195 (signal 'file-error (list "Visiting tags table" |
196 "file does not exist" | |
197 file))) | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
198 ;; Set FILE to the expanded name. |
1138 | 199 (setq file tags-file-name))) |
799 | 200 (if local |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
201 ;; Set the local value of tags-file-name. |
1149 | 202 (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
|
203 ;; Set the global value of tags-file-name. |
1138 | 204 (setq-default tags-file-name file))) |
205 | |
206 ;; 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
|
207 ;; If NO-INCLUDES is non-nil, ignore included tags tables. |
1138 | 208 ;; Returns nil when out of tables. |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
209 (defun tags-next-table (&optional no-includes) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
210 ;; Do we have any included tables? |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
211 (if (and (not no-includes) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
212 (visit-tags-table-buffer 'same) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
213 (tags-included-tables)) |
1149 | 214 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
215 ;; Move into the included tags tables. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
216 (setq tags-table-parent-pointer-list |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
217 ;; Save the current state of what table we are in. |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
218 (cons (list tags-table-list |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
219 tags-table-list-pointer |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
220 tags-table-list-started-at) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
221 tags-table-parent-pointer-list) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
222 ;; Start the pointer in the list of included tables. |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
223 tags-table-list tags-included-tables |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
224 tags-table-list-pointer tags-included-tables |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
225 tags-table-list-started-at tags-included-tables) |
1149 | 226 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
227 ;; 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
|
228 (setq tags-table-list-pointer |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
229 (cdr tags-table-list-pointer)) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
230 (or tags-table-list-pointer |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
231 ;; Wrap around. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
232 (setq tags-table-list-pointer tags-table-list)) |
1149 | 233 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
234 (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
|
235 ;; We have come full circle. No more tables. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
236 (if tags-table-parent-pointer-list |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
237 ;; 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
|
238 (progn |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
239 ;; Restore the state variables. |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
240 (setq tags-table-list |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
241 (nth 0 (car tags-table-parent-pointer-list)) |
7287
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
242 tags-file-name (car tags-table-list) |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
243 tags-table-list-pointer |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
244 (nth 1 (car tags-table-parent-pointer-list)) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
245 tags-table-list-started-at |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
246 (nth 2 (car tags-table-parent-pointer-list)) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
247 tags-table-parent-pointer-list |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
248 (cdr tags-table-parent-pointer-list)) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
249 ;; 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
|
250 (tags-next-table t)) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
251 ;; All out of tags tables. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
252 (setq tags-table-list-pointer nil)))) |
1149 | 253 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
254 (and tags-table-list-pointer |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
255 ;; 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
|
256 (setq tags-file-name |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
257 (tags-expand-table-name (car tags-table-list-pointer))))) |
1149 | 258 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
259 ;; Expand tags table name FILE into a complete file name. |
1149 | 260 (defun tags-expand-table-name (file) |
261 (setq file (expand-file-name file)) | |
262 (if (file-directory-p file) | |
263 (expand-file-name "TAGS" file) | |
264 file)) | |
1138 | 265 |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
266 ;; Search for FILE in LIST (default: tags-table-list); also search |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
267 ;; tables that are already in core for FILE being included by them. Return t |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
268 ;; if we find it, nil if not. Comparison is done after tags-expand-table-name |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
269 ;; on both sides. If MOVE-TO is non-nil, update tags-table-list and the list |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
270 ;; pointers to point to the table found. In recursive calls, MOVE-TO is a list |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
271 ;; value for tags-table-parent-pointer-list describing the position of the |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
272 ;; caller's search. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
273 (defun tags-find-table-in-list (file move-to &optional list) |
1149 | 274 (or list |
275 (setq list tags-table-list)) | |
276 (setq file (tags-expand-table-name file)) | |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
277 (let (;; Set up the MOVE-TO argument used for the recursive calls we will do |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
278 ;; for included tables. This is a list value for |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
279 ;; tags-table-parent-pointer-list describing the included tables we are |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
280 ;; descending; we cons our position onto the list from our recursive |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
281 ;; caller (which is searching a list that contains the table whose |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
282 ;; included tables we are searching). The atom `in-progress' is a |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
283 ;; placeholder; when a recursive call locates FILE, we replace |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
284 ;; 'in-progress with the tail of LIST whose car contained FILE. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
285 (recursing-move-to (if move-to |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
286 (cons (list list 'in-progress 'in-progress) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
287 (if (eq move-to t) nil move-to)))) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
288 this-file) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
289 (while (and (consp list) ; We set LIST to t when we locate FILE. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
290 (not (string= file |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
291 (setq this-file |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
292 (tags-expand-table-name (car list)))))) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
293 (if (get-file-buffer this-file) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
294 ;; This table is already in core. Visit it and recurse to check |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
295 ;; its included tables. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
296 (save-excursion |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
297 (let ((tags-file-name this-file) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
298 found) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
299 (visit-tags-table-buffer 'same) |
7284
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
300 (and (tags-included-tables) |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
301 ;; We have some included tables; check them. |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
302 (tags-find-table-in-list file recursing-move-to |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
303 tags-included-tables) |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
304 (progn |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
305 ;; We found FILE in the included table. |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
306 (if move-to |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
307 (progn |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
308 ;; The recursive call has already frobbed the list |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
309 ;; pointers. It set tags-table-parent-pointer-list |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
310 ;; to a list including RECURSING-MOVE-TO. Now we |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
311 ;; must mutate that cons so its list pointers show |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
312 ;; the position where we found this included table. |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
313 (setcar (cdr (car recursing-move-to)) list) |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
314 (setcar (cdr (cdr (car recursing-move-to))) list) |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
315 ;; Don't do further list frobnication below. |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
316 (setq move-to nil))) |
87be9630459d
(tags-find-table-in-list): Only recurse if (tags-included-tables) returns
Roland McGrath <roland@gnu.org>
parents:
7211
diff
changeset
|
317 (setq list t)))))) |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
318 (if (consp list) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
319 (setq list (cdr list)))) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
320 (and list move-to |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
321 (progn |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
322 ;; We have located FILE in the list. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
323 ;; Now frobnicate the list pointers to point to it. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
324 (setq tags-table-list-started-at list |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
325 tags-table-list-pointer list) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
326 (if (consp move-to) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
327 ;; We are in a recursive call. MOVE-TO is the value for |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
328 ;; tags-table-parent-pointer-list that describes the tables |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
329 ;; descended by the caller (and its callers, recursively). |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
330 (setq tags-table-parent-pointer-list move-to))))) |
1149 | 331 list) |
332 | |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
333 ;; Local var in visit-tags-table-buffer |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
334 ;; which is set by tags-table-including. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
335 (defvar visit-tags-table-buffer-cont) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
336 |
1149 | 337 ;; Subroutine of visit-tags-table-buffer. Frobs its local vars. |
2768
82797c755adc
(tags-table-including): Take new third arg CORE-ONLY. If non-nil,
Roland McGrath <roland@gnu.org>
parents:
2590
diff
changeset
|
338 ;; Search TABLES for one that has tags for THIS-FILE. Recurses on |
82797c755adc
(tags-table-including): Take new third arg CORE-ONLY. If non-nil,
Roland McGrath <roland@gnu.org>
parents:
2590
diff
changeset
|
339 ;; included tables. Returns the tail of TABLES (or of an inner |
82797c755adc
(tags-table-including): Take new third arg CORE-ONLY. If non-nil,
Roland McGrath <roland@gnu.org>
parents:
2590
diff
changeset
|
340 ;; included list) whose car is a table listing THIS-FILE. If |
82797c755adc
(tags-table-including): Take new third arg CORE-ONLY. If non-nil,
Roland McGrath <roland@gnu.org>
parents:
2590
diff
changeset
|
341 ;; CORE-ONLY is non-nil, check only tags tables that are already in |
82797c755adc
(tags-table-including): Take new third arg CORE-ONLY. If non-nil,
Roland McGrath <roland@gnu.org>
parents:
2590
diff
changeset
|
342 ;; buffers--don't visit any new files. |
82797c755adc
(tags-table-including): Take new third arg CORE-ONLY. If non-nil,
Roland McGrath <roland@gnu.org>
parents:
2590
diff
changeset
|
343 (defun tags-table-including (this-file tables core-only &optional recursing) |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
344 (let ((starting-tables tables) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
345 (found nil)) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
346 ;; Loop over TABLES, looking for one containing tags for THIS-FILE. |
1149 | 347 (while (and (not found) |
348 tables) | |
349 (let ((tags-file-name (tags-expand-table-name (car tables)))) | |
350 (if (or (get-file-buffer tags-file-name) | |
2768
82797c755adc
(tags-table-including): Take new third arg CORE-ONLY. If non-nil,
Roland McGrath <roland@gnu.org>
parents:
2590
diff
changeset
|
351 (and (not core-only) |
82797c755adc
(tags-table-including): Take new third arg CORE-ONLY. If non-nil,
Roland McGrath <roland@gnu.org>
parents:
2590
diff
changeset
|
352 (file-exists-p tags-file-name))) |
1149 | 353 (progn |
354 ;; Select the tags table buffer and get the file list up to date. | |
355 (visit-tags-table-buffer 'same) | |
356 (or tags-table-files | |
357 (setq tags-table-files | |
358 (funcall tags-table-files-function))) | |
359 | |
360 (cond ((member this-file tags-table-files) | |
361 ;; Found it. | |
362 (setq found tables)) | |
1138 | 363 |
1149 | 364 ((tags-included-tables) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
365 ;; This table has included tables. Check them. |
1149 | 366 (let ((old tags-table-parent-pointer-list)) |
367 (unwind-protect | |
368 (progn | |
369 (or recursing | |
370 ;; At top level (not in an included tags | |
371 ;; table), set the list to nil so we can | |
372 ;; collect just the elts from this run. | |
373 (setq tags-table-parent-pointer-list nil)) | |
374 (setq found | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
375 ;; Recurse on the list of included tables. |
1149 | 376 (tags-table-including this-file |
377 tags-included-tables | |
2768
82797c755adc
(tags-table-including): Take new third arg CORE-ONLY. If non-nil,
Roland McGrath <roland@gnu.org>
parents:
2590
diff
changeset
|
378 core-only |
1149 | 379 t)) |
380 (if found | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
381 ;; One of them lists THIS-FILE. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
382 ;; Set the table list state variables to move |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
383 ;; us inside the list of included tables. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
384 (setq tags-table-parent-pointer-list |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
385 (cons |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
386 (list tags-table-list |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
387 tags-table-list-pointer |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
388 tags-table-list-started-at) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
389 tags-table-parent-pointer-list) |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
390 tags-table-list starting-tables |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
391 tags-table-list-pointer found |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
392 tags-table-list-started-at found |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
393 ;; Set a local variable of |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
394 ;; our caller, visit-tags-table-buffer. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
395 ;; Set it so we won't frob lists later. |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
396 visit-tags-table-buffer-cont |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
397 'included))) |
1149 | 398 (or recursing |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
399 ;; tags-table-parent-pointer-list now describes |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
400 ;; the path of included tables taken by recursive |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
401 ;; invocations of this function. The recursive |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
402 ;; 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
|
403 ;; 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
|
404 ;; innermost first, so reverse it. Then append |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
405 ;; 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
|
406 ;; outermost time), to get the complete current |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
407 ;; state of included tables. |
1149 | 408 (setq tags-table-parent-pointer-list |
409 (nconc (nreverse | |
410 tags-table-parent-pointer-list) | |
411 old)))))))))) | |
412 (setq tables (cdr tables))) | |
413 found)) | |
799 | 414 |
415 (defun visit-tags-table-buffer (&optional cont) | |
416 "Select the buffer containing the current tags table. | |
7287
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
417 If optional arg is a string, visit that file as a tags table. |
799 | 418 If optional arg is t, visit the next table in `tags-table-list'. |
419 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
|
420 just select the buffer visiting `tags-file-name'. |
1149 | 421 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
|
422 `tags-file-name', `tags-table-list', `tags-table-list-pointer'. |
799 | 423 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
|
424 |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
425 ;; Set tags-file-name to the tags table file we want to visit. |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
426 (let ((visit-tags-table-buffer-cont cont)) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
427 (cond ((eq visit-tags-table-buffer-cont 'same) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
428 ;; Use the ambient value of tags-file-name. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
429 (or tags-file-name |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
430 (error (substitute-command-keys |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
431 (concat "No tags table in use! " |
5712
6a26b8998df1
(visit-tags-table-buffer): Don't change VISIT-TAGS-TABLE-BUFFER-CONT when
Roland McGrath <roland@gnu.org>
parents:
5279
diff
changeset
|
432 "Use \\[visit-tags-table] to select one."))))) |
1138 | 433 |
7287
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
434 ((eq t visit-tags-table-buffer-cont) |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
435 ;; Find the next table. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
436 (if (tags-next-table) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
437 ;; Skip over nonexistent files. |
5712
6a26b8998df1
(visit-tags-table-buffer): Don't change VISIT-TAGS-TABLE-BUFFER-CONT when
Roland McGrath <roland@gnu.org>
parents:
5279
diff
changeset
|
438 (let (file) |
6a26b8998df1
(visit-tags-table-buffer): Don't change VISIT-TAGS-TABLE-BUFFER-CONT when
Roland McGrath <roland@gnu.org>
parents:
5279
diff
changeset
|
439 (while (and (setq file |
6a26b8998df1
(visit-tags-table-buffer): Don't change VISIT-TAGS-TABLE-BUFFER-CONT when
Roland McGrath <roland@gnu.org>
parents:
5279
diff
changeset
|
440 (tags-expand-table-name tags-file-name)) |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
441 (not (or (get-file-buffer file) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
442 (file-exists-p file)))) |
5712
6a26b8998df1
(visit-tags-table-buffer): Don't change VISIT-TAGS-TABLE-BUFFER-CONT when
Roland McGrath <roland@gnu.org>
parents:
5279
diff
changeset
|
443 (tags-next-table))))) |
342 | 444 |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
445 (t |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
446 ;; We are visiting a table anew, so throw away the previous |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
447 ;; context of what included tables we were inside of. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
448 (while tags-table-parent-pointer-list |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
449 ;; Set the pointer as if we had iterated through all the |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
450 ;; tables in the list. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
451 (setq tags-table-list-pointer tags-table-list-started-at) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
452 ;; Fetching the next table will pop the included-table state. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
453 (tags-next-table)) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
454 |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
455 ;; Pick a table out of our hat. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
456 (setq tags-file-name |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
457 (or |
7287
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
458 ;; If passed a string, use that. |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
459 (if (stringp visit-tags-table-buffer-cont) |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
460 (prog1 visit-tags-table-buffer-cont |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
461 (setq visit-tags-table-buffer-cont nil))) |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
462 ;; First, try a local variable. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
463 (cdr (assq 'tags-file-name (buffer-local-variables))) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
464 ;; Second, try a user-specified function to guess. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
465 (and default-tags-table-function |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
466 (funcall default-tags-table-function)) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
467 ;; Third, look for a tags table that contains |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
468 ;; tags for the current buffer's file. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
469 ;; If one is found, the lists will be frobnicated, |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
470 ;; and VISIT-TAGS-TABLE-BUFFER-CONT |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
471 ;; will be set non-nil so we don't do it below. |
7287
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
472 (and buffer-file-name |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
473 (car (or |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
474 ;; First check only tables already in buffers. |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
475 (save-excursion |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
476 (tags-table-including buffer-file-name |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
477 tags-table-list |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
478 t)) |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
479 ;; Since that didn't find any, now do the |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
480 ;; expensive version: reading new files. |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
481 (save-excursion |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
482 (tags-table-including buffer-file-name |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
483 tags-table-list |
0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Roland McGrath <roland@gnu.org>
parents:
7284
diff
changeset
|
484 nil))))) |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
485 ;; Fourth, use the user variable tags-file-name, if it is |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
486 ;; not already in tags-table-list. |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
487 (and tags-file-name |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
488 (not (tags-find-table-in-list tags-file-name nil)) |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
489 tags-file-name) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
490 ;; Fifth, use the user variable giving the table list. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
491 ;; Find the first element of the list that actually exists. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
492 (let ((list tags-table-list) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
493 file) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
494 (while (and list |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
495 (setq file (tags-expand-table-name (car list))) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
496 (not (get-file-buffer file)) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
497 (not (file-exists-p file))) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
498 (setq list (cdr list))) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
499 (car list)) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
500 ;; Finally, prompt the user for a file name. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
501 (expand-file-name |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
502 (read-file-name "Visit tags table: (default TAGS) " |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
503 default-directory |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
504 "TAGS" |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
505 t)))))) |
1149 | 506 |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
507 ;; Expand the table name into a full file name. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
508 (setq tags-file-name (tags-expand-table-name tags-file-name)) |
1149 | 509 |
5712
6a26b8998df1
(visit-tags-table-buffer): Don't change VISIT-TAGS-TABLE-BUFFER-CONT when
Roland McGrath <roland@gnu.org>
parents:
5279
diff
changeset
|
510 (if (and (eq visit-tags-table-buffer-cont t) |
6a26b8998df1
(visit-tags-table-buffer): Don't change VISIT-TAGS-TABLE-BUFFER-CONT when
Roland McGrath <roland@gnu.org>
parents:
5279
diff
changeset
|
511 (null tags-table-list-pointer)) |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
512 ;; All out of tables. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
513 nil |
1138 | 514 |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
515 ;; Verify that tags-file-name is a valid tags table. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
516 (if (if (get-file-buffer tags-file-name) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
517 ;; The file is already in a buffer. Check for the visited file |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
518 ;; having changed since we last used it. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
519 (let (win) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
520 (set-buffer (get-file-buffer tags-file-name)) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
521 (setq win (or verify-tags-table-function |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
522 (initialize-new-tags-table))) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
523 (if (or (verify-visited-file-modtime (current-buffer)) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
524 (not (yes-or-no-p |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
525 "Tags file has changed, read new contents? "))) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
526 (and win (funcall verify-tags-table-function)) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
527 (revert-buffer t t) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
528 (initialize-new-tags-table))) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
529 (set-buffer (find-file-noselect tags-file-name)) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
530 (or (string= tags-file-name buffer-file-name) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
531 ;; find-file-noselect has changed the file name. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
532 ;; Propagate the change to tags-file-name and tags-table-list. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
533 (let ((tail (member tags-file-name tags-table-list))) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
534 (if tail |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
535 (setcar tail buffer-file-name)) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
536 (setq tags-file-name buffer-file-name))) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
537 (initialize-new-tags-table)) |
1149 | 538 |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
539 ;; We have a valid tags table. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
540 (progn |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
541 ;; Bury the tags table buffer so it |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
542 ;; doesn't get in the user's way. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
543 (bury-buffer (current-buffer)) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
544 |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
545 ;; If this was a new table selection (CONT is nil), make sure |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
546 ;; tags-table-list includes the chosen table, and update the |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
547 ;; list pointer variables. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
548 (or visit-tags-table-buffer-cont |
5712
6a26b8998df1
(visit-tags-table-buffer): Don't change VISIT-TAGS-TABLE-BUFFER-CONT when
Roland McGrath <roland@gnu.org>
parents:
5279
diff
changeset
|
549 ;; Look in the list for the table we chose. |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
550 ;; This updates the list pointers if it finds the table. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
551 (or (tags-find-table-in-list tags-file-name t) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
552 ;; The table is not in the current set. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
553 ;; Try to find it in another previously used set. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
554 (let ((sets tags-table-set-list)) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
555 (while (and sets |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
556 (not (tags-find-table-in-list tags-file-name |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
557 t (car sets)))) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
558 (setq sets (cdr sets))) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
559 (if sets |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
560 ;; Found in some other set. Switch to that set. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
561 (progn |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
562 (or (memq tags-table-list tags-table-set-list) |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
563 ;; Save the current list. |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
564 (setq tags-table-set-list |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
565 (cons tags-table-list |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
566 tags-table-set-list))) |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
567 ;; The list pointers are already up to date; |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
568 ;; we need only set tags-table-list. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
569 (setq tags-table-list (car sets))) |
1149 | 570 |
7211
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
571 ;; Not found in any existing set. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
572 (if (and tags-table-list |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
573 (or (eq t tags-add-tables) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
574 (and tags-add-tables |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
575 (y-or-n-p |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
576 (concat "Keep current list of " |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
577 "tags tables also? "))))) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
578 ;; Add it to the current list. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
579 (setq tags-table-list (cons tags-file-name |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
580 tags-table-list)) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
581 ;; Make a fresh list, and store the old one. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
582 (message "Starting a new list of tags tables") |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
583 (or (null tags-table-list) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
584 (memq tags-table-list tags-table-set-list) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
585 (setq tags-table-set-list |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
586 (cons tags-table-list |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
587 tags-table-set-list))) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
588 (setq tags-table-list (list tags-file-name))) |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
589 |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
590 ;; Set the tags table list state variables to point |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
591 ;; at the table we want to use first. |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
592 (setq tags-table-list-started-at tags-table-list |
b2485e94101a
(tags-table-parent-pointer-list): Doc fix; elts are now 3-elt lists.
Roland McGrath <roland@gnu.org>
parents:
7112
diff
changeset
|
593 tags-table-list-pointer tags-table-list))))) |
1156 | 594 |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
595 ;; Return of t says the tags table is valid. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
596 t) |
1149 | 597 |
4391
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
598 ;; The buffer was not valid. Don't use it again. |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
599 (let ((file tags-file-name)) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
600 (kill-local-variable 'tags-file-name) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
601 (if (eq file tags-file-name) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
602 (setq tags-file-name nil))) |
2f181ad12c41
(visit-tags-table-buffer): New local named
Richard M. Stallman <rms@gnu.org>
parents:
4389
diff
changeset
|
603 (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
|
604 |
342 | 605 (defun file-of-tag () |
606 "Return the file name of the file whose tags point is within. | |
799 | 607 Assumes the tags table is the current buffer. |
608 File name returned is relative to tags table file's directory." | |
609 (funcall file-of-tag-function)) | |
342 | 610 |
360 | 611 ;;;###autoload |
799 | 612 (defun tags-table-files () |
613 "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
|
614 Assumes the tags table is the current buffer. |
342 | 615 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
|
616 (or tags-table-files |
d469afe703c4
(visit-tags-table-buffer): When trying to pick table, call
Roland McGrath <roland@gnu.org>
parents:
1156
diff
changeset
|
617 (setq tags-table-files |
d469afe703c4
(visit-tags-table-buffer): When trying to pick table, call
Roland McGrath <roland@gnu.org>
parents:
1156
diff
changeset
|
618 (funcall tags-table-files-function)))) |
799 | 619 |
620 (defun tags-included-tables () | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
621 "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
|
622 Assumes the tags table is the current buffer." |
799 | 623 (or tags-included-tables |
624 (setq tags-included-tables (funcall tags-included-tables-function)))) | |
625 | |
626 ;; Build tags-completion-table on demand. The single current tags table | |
627 ;; and its included tags tables (and their included tables, etc.) have | |
628 ;; their tags included in the completion table. | |
629 (defun tags-completion-table () | |
630 (or tags-completion-table | |
631 (condition-case () | |
632 (prog2 | |
633 (message "Making tags completion table for %s..." buffer-file-name) | |
634 (let ((included (tags-included-tables)) | |
635 (table (funcall tags-completion-table-function))) | |
636 (save-excursion | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
637 ;; 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
|
638 ;; included table's completion obarray to the parent obarray. |
799 | 639 (while included |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
640 ;; Visit the buffer. |
799 | 641 (let ((tags-file-name (car included))) |
1149 | 642 (visit-tags-table-buffer 'same)) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
643 ;; Recurse in that buffer to compute its completion table. |
799 | 644 (if (tags-completion-table) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
645 ;; Combine the tables. |
799 | 646 (mapatoms (function |
647 (lambda (sym) | |
648 (intern (symbol-name sym) table))) | |
649 tags-completion-table)) | |
650 (setq included (cdr included)))) | |
651 (setq tags-completion-table table)) | |
652 (message "Making tags completion table for %s...done" | |
653 buffer-file-name)) | |
654 (quit (message "Tags completion table construction aborted.") | |
655 (setq tags-completion-table nil))))) | |
656 | |
657 ;; Completion function for tags. Does normal try-completion, | |
658 ;; but builds tags-completion-table on demand. | |
659 (defun tags-complete-tag (string predicate what) | |
660 (save-excursion | |
5079
1d253bc912d8
(tags-complete-tag): Bind enable-recursive-minibuffers to t.
Richard M. Stallman <rms@gnu.org>
parents:
4940
diff
changeset
|
661 ;; If we need to ask for the tag table, allow that. |
1d253bc912d8
(tags-complete-tag): Bind enable-recursive-minibuffers to t.
Richard M. Stallman <rms@gnu.org>
parents:
4940
diff
changeset
|
662 (let ((enable-recursive-minibuffers t)) |
1d253bc912d8
(tags-complete-tag): Bind enable-recursive-minibuffers to t.
Richard M. Stallman <rms@gnu.org>
parents:
4940
diff
changeset
|
663 (visit-tags-table-buffer)) |
799 | 664 (if (eq what t) |
665 (all-completions string (tags-completion-table) predicate) | |
666 (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
|
667 |
342 | 668 ;; Return a default tag to search for, based on the text at point. |
669 (defun find-tag-default () | |
670 (save-excursion | |
671 (while (looking-at "\\sw\\|\\s_") | |
672 (forward-char 1)) | |
799 | 673 (if (or (re-search-backward "\\sw\\|\\s_" |
674 (save-excursion (beginning-of-line) (point)) | |
675 t) | |
676 (re-search-forward "\\(\\sw\\|\\s_\\)+" | |
677 (save-excursion (end-of-line) (point)) | |
678 t)) | |
679 (progn (goto-char (match-end 0)) | |
342 | 680 (buffer-substring (point) |
681 (progn (forward-sexp -1) | |
682 (while (looking-at "\\s'") | |
683 (forward-char 1)) | |
684 (point)))) | |
685 nil))) | |
686 | |
799 | 687 ;; Read a tag name from the minibuffer with defaulting and completion. |
342 | 688 (defun find-tag-tag (string) |
799 | 689 (let* ((default (funcall (or find-tag-default-function |
690 (get major-mode 'find-tag-default-function) | |
691 'find-tag-default))) | |
692 (spec (completing-read (if default | |
693 (format "%s(default %s) " string default) | |
694 string) | |
695 'tags-complete-tag))) | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
696 (if (equal spec "") |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
697 (or default (error "There is no default tag")) |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
698 spec))) |
342 | 699 |
852 | 700 (defvar last-tag nil |
701 "Last tag found by \\[find-tag].") | |
702 | |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
703 ;; Get interactive args for find-tag{-noselect,-other-window,-regexp}. |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
704 (defun find-tag-interactive (prompt &optional no-default) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
705 (if current-prefix-arg |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
706 (list nil (if (< (prefix-numeric-value current-prefix-arg) 0) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
707 '- |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
708 t)) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
709 (list (if no-default |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
710 (read-string prompt) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
711 (find-tag-tag prompt))))) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
712 |
799 | 713 ;;;###autoload |
714 (defun find-tag-noselect (tagname &optional next-p regexp-p) | |
715 "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
|
716 Returns the buffer containing the tag's definition and moves its point there, |
799 | 717 but does not select the buffer. |
718 The default for TAGNAME is the expression in the buffer near point. | |
474 | 719 |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
720 If second arg NEXT-P is t (interactively, with prefix arg), search for |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
721 another tag that matches the last tagname or regexp used. When there are |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
722 multiple matches for a tag, more exact matches are found first. If NEXT-P |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
723 is the atom `-' (interactively, with prefix arg that is a negative number |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
724 or just \\[negative-argument]), pop back to the previous tag gone to. |
450
0bac8c701777
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
449
diff
changeset
|
725 |
799 | 726 If third arg REGEXP-P is non-nil, treat TAGNAME as a regexp. |
342 | 727 |
799 | 728 See documentation of variable `tags-file-name'." |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
729 (interactive (find-tag-interactive "Find tag: ")) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
730 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
731 ;; 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
|
732 ;; tags table buffer. |
799 | 733 (let ((local-find-tag-hook find-tag-hook)) |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
734 (if (eq '- next-p) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
735 ;; Pop back to a previous location. |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
736 (if (null tags-location-stack) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
737 (error "No previous tag locations") |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
738 (let ((marker (car tags-location-stack))) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
739 ;; Pop the stack. |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
740 (setq tags-location-stack (cdr tags-location-stack)) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
741 (prog1 |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
742 ;; Move to the saved location. |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
743 (set-buffer (marker-buffer marker)) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
744 (goto-char (marker-position marker)) |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3548
diff
changeset
|
745 ;; Kill that marker so it doesn't slow down editing. |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
746 (set-marker marker nil nil) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
747 ;; Run the user's hook. Do we really want to do this for pop? |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
748 (run-hooks 'local-find-tag-hook)))) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
749 (if next-p |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
750 ;; Find the same table we last used. |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
751 (visit-tags-table-buffer 'same) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
752 ;; Pick a table to use. |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
753 (visit-tags-table-buffer) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
754 ;; Record TAGNAME for a future call with NEXT-P non-nil. |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
755 (setq last-tag tagname)) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
756 (prog1 |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
757 ;; Record the location so we can pop back to it later. |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
758 (marker-buffer |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
759 (car |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
760 (setq tags-location-stack |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
761 (cons (let ((marker (make-marker))) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
762 (save-excursion |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
763 (set-buffer |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
764 ;; find-tag-in-order does the real work. |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
765 (find-tag-in-order |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
766 (if next-p last-tag tagname) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
767 (if regexp-p |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
768 find-tag-regexp-search-function |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
769 find-tag-search-function) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
770 (if regexp-p |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
771 find-tag-regexp-tag-order |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
772 find-tag-tag-order) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
773 (if regexp-p |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
774 find-tag-regexp-next-line-after-failure-p |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
775 find-tag-next-line-after-failure-p) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
776 (if regexp-p "matching" "containing") |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
777 (not next-p))) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
778 (set-marker marker (point)))) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
779 tags-location-stack)))) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
780 (run-hooks 'local-find-tag-hook))))) |
360 | 781 |
782 ;;;###autoload | |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
783 (defun find-tag (tagname &optional next-p regexp-p) |
799 | 784 "Find tag (in current tags table) whose name contains TAGNAME. |
785 Select the buffer containing the tag's definition, and move point there. | |
786 The default for TAGNAME is the expression in the buffer around or before point. | |
342 | 787 |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
788 If second arg NEXT-P is t (interactively, with prefix arg), search for |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
789 another tag that matches the last tagname or regexp used. When there are |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
790 multiple matches for a tag, more exact matches are found first. If NEXT-P |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
791 is the atom `-' (interactively, with prefix arg that is a negative number |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
792 or just \\[negative-argument]), pop back to the previous tag gone to. |
799 | 793 |
794 See documentation of variable `tags-file-name'." | |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
795 (interactive (find-tag-interactive "Find tag: ")) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
796 (switch-to-buffer (find-tag-noselect tagname next-p regexp-p))) |
799 | 797 ;;;###autoload (define-key esc-map "." 'find-tag) |
342 | 798 |
727 | 799 ;;;###autoload |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
800 (defun find-tag-other-window (tagname &optional next-p regexp-p) |
799 | 801 "Find tag (in current tags table) whose name contains TAGNAME. |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
802 Select the buffer containing the tag's definition in another window, and |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
803 move point there. The default for TAGNAME is the expression in the buffer |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
804 around or before point. |
799 | 805 |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
806 If second arg NEXT-P is t (interactively, with prefix arg), search for |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
807 another tag that matches the last tagname or regexp used. When there are |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
808 multiple matches for a tag, more exact matches are found first. If NEXT-P |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
809 is negative (interactively, with prefix arg that is a negative number or |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
810 just \\[negative-argument]), pop back to the previous tag gone to. |
799 | 811 |
812 See documentation of variable `tags-file-name'." | |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
813 (interactive (find-tag-interactive "Find tag other window: ")) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
814 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
815 ;; 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
|
816 ;; 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
|
817 ;; 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
|
818 ;; doing find-tag-noselect, and restore it after. |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
819 (let* ((window-point (window-point (selected-window))) |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
820 (tagbuf (find-tag-noselect tagname next-p regexp-p)) |
1976
eda7eec8f8ad
* etags.el (find-tag-other-window): If another window is already
Jim Blandy <jimb@redhat.com>
parents:
1816
diff
changeset
|
821 (tagpoint (progn (set-buffer tagbuf) (point)))) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
822 (set-window-point (prog1 |
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
823 (selected-window) |
1976
eda7eec8f8ad
* etags.el (find-tag-other-window): If another window is already
Jim Blandy <jimb@redhat.com>
parents:
1816
diff
changeset
|
824 (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
|
825 ;; 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
|
826 ;; 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
|
827 ;; 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
|
828 ;; 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
|
829 ;; 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
|
830 (set-window-point (selected-window) tagpoint)) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
831 window-point))) |
799 | 832 ;;;###autoload (define-key ctl-x-4-map "." 'find-tag-other-window) |
833 | |
804 | 834 ;;;###autoload |
799 | 835 (defun find-tag-other-frame (tagname &optional next-p) |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
836 "Find tag (in current tags table) whose name contains TAGNAME. |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
837 Select the buffer containing the tag's definition in another frame, and |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
838 move point there. The default for TAGNAME is the expression in the buffer |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
839 around or before point. |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
840 |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
841 If second arg NEXT-P is t (interactively, with prefix arg), search for |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
842 another tag that matches the last tagname or regexp used. When there are |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
843 multiple matches for a tag, more exact matches are found first. If NEXT-P |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
844 is negative (interactively, with prefix arg that is a negative number or |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
845 just \\[negative-argument]), pop back to the previous tag gone to. |
727 | 846 |
799 | 847 See documentation of variable `tags-file-name'." |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
848 (interactive (find-tag-interactive "Find tag other frame: ")) |
799 | 849 (let ((pop-up-frames t)) |
850 (find-tag-other-window tagname next-p))) | |
851 ;;;###autoload (define-key ctl-x-5-map "." 'find-tag-other-frame) | |
342 | 852 |
360 | 853 ;;;###autoload |
799 | 854 (defun find-tag-regexp (regexp &optional next-p other-window) |
855 "Find tag (in current tags table) whose name matches REGEXP. | |
856 Select the buffer containing the tag's definition and move point there. | |
857 | |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
858 If second arg NEXT-P is t (interactively, with prefix arg), search for |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
859 another tag that matches the last tagname or regexp used. When there are |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
860 multiple matches for a tag, more exact matches are found first. If NEXT-P |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
861 is negative (interactively, with prefix arg that is a negative number or |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
862 just \\[negative-argument]), pop back to the previous tag gone to. |
799 | 863 |
864 If third arg OTHER-WINDOW is non-nil, select the buffer in another window. | |
865 | |
866 See documentation of variable `tags-file-name'." | |
2590
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
867 (interactive (find-tag-interactive "Find tag regexp: " t)) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
868 ;; We go through find-tag-other-window to do all the display hair there. |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
869 (funcall (if other-window 'find-tag-other-window 'find-tag) |
9dace03bd76c
(find-tag-interactive): New function to read args for find-tag et al.
Roland McGrath <roland@gnu.org>
parents:
2448
diff
changeset
|
870 regexp next-p t)) |
799 | 871 |
872 ;; Internal tag finding function. | |
873 | |
874 ;; PATTERN is a string to pass to second arg SEARCH-FORWARD-FUNC, and to | |
875 ;; any member of the function list ORDER (third arg). If ORDER is nil, | |
876 ;; use saved state to continue a previous search. | |
877 | |
878 ;; Fourth arg MATCHING is a string, an English '-ing' word, to be used in | |
879 ;; an error message. | |
880 | |
881 ;; Fifth arg NEXT-LINE-AFTER-FAILURE-P is non-nil if after a failed match, | |
882 ;; point should be moved to the next line. | |
883 | |
884 ;; Algorithm is as follows. For each qualifier-func in ORDER, go to | |
885 ;; beginning of tags file, and perform inner loop: for each naive match for | |
886 ;; PATTERN found using SEARCH-FORWARD-FUNC, qualify the naive match using | |
887 ;; qualifier-func. If it qualifies, go to the specified line in the | |
888 ;; specified source file and return. Qualified matches are remembered to | |
889 ;; avoid repetition. State is saved so that the loop can be continued. | |
890 | |
1555
695c6eb2ff31
* etags.el (find-tag-noselect): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1397
diff
changeset
|
891 (defun find-tag-in-order (pattern |
695c6eb2ff31
* etags.el (find-tag-noselect): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1397
diff
changeset
|
892 search-forward-func |
695c6eb2ff31
* etags.el (find-tag-noselect): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1397
diff
changeset
|
893 order |
695c6eb2ff31
* etags.el (find-tag-noselect): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1397
diff
changeset
|
894 next-line-after-failure-p |
695c6eb2ff31
* etags.el (find-tag-noselect): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1397
diff
changeset
|
895 matching |
695c6eb2ff31
* etags.el (find-tag-noselect): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1397
diff
changeset
|
896 first-search) |
799 | 897 (let (file ;name of file containing tag |
898 tag-info ;where to find the tag in FILE | |
899 tags-table-file ;name of tags file | |
900 (first-table t) | |
901 (tag-order order) | |
902 goto-func | |
903 ) | |
904 (save-excursion | |
1149 | 905 (or first-search ;find-tag-noselect has already done it. |
906 (visit-tags-table-buffer 'same)) | |
907 | |
799 | 908 ;; Get a qualified match. |
909 (catch 'qualified-match-found | |
1149 | 910 |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
911 ;; Iterate over the list of tags tables. |
799 | 912 (while (or first-table |
913 (visit-tags-table-buffer t)) | |
914 | |
915 (if first-search | |
916 (setq tag-lines-already-matched nil)) | |
917 | |
884 | 918 (and first-search first-table |
919 ;; Start at beginning of tags file. | |
920 (goto-char (point-min))) | |
921 (setq first-table nil) | |
799 | 922 |
923 (setq tags-table-file buffer-file-name) | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
924 ;; Iterate over the list of ordering predicates. |
799 | 925 (while order |
926 (while (funcall search-forward-func pattern nil t) | |
927 ;; Naive match found. Qualify the match. | |
928 (and (funcall (car order) pattern) | |
929 ;; Make sure it is not a previous qualified match. | |
930 ;; Use of `memq' depends on numbers being eq. | |
931 (not (memq (save-excursion (beginning-of-line) (point)) | |
932 tag-lines-already-matched)) | |
933 (throw 'qualified-match-found nil)) | |
934 (if next-line-after-failure-p | |
935 (forward-line 1))) | |
936 ;; Try the next flavor of match. | |
937 (setq order (cdr order)) | |
938 (goto-char (point-min))) | |
939 (setq order tag-order)) | |
940 ;; We throw out on match, so only get here if there were no matches. | |
941 (error "No %stags %s %s" (if first-search "" "more ") | |
942 matching pattern)) | |
943 | |
944 ;; Found a tag; extract location info. | |
945 (beginning-of-line) | |
946 (setq tag-lines-already-matched (cons (point) | |
947 tag-lines-already-matched)) | |
948 ;; Expand the filename, using the tags table buffer's default-directory. | |
949 (setq file (expand-file-name (file-of-tag)) | |
950 tag-info (funcall snarf-tag-function)) | |
951 | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
952 ;; Get the local value in the tags table buffer before switching buffers. |
799 | 953 (setq goto-func goto-tag-location-function) |
954 | |
955 ;; Find the right line in the specified file. | |
956 (set-buffer (find-file-noselect file)) | |
957 (widen) | |
958 (push-mark) | |
959 (funcall goto-func tag-info) | |
960 | |
961 ;; Give this buffer a local value of tags-file-name. | |
962 ;; The next time visit-tags-table-buffer is called, | |
963 ;; it will use the same tags table that found a match in this buffer. | |
964 (make-local-variable 'tags-file-name) | |
965 (setq tags-file-name tags-table-file) | |
966 | |
967 ;; Return the buffer where the tag was found. | |
968 (current-buffer)))) | |
969 | |
970 ;; `etags' TAGS file format support. | |
971 | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
972 ;; 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
|
973 ;; the tags table format variables, and return non-nil. |
799 | 974 (defun etags-recognize-tags-table () |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
975 (and (etags-verify-tags-table) |
1136 | 976 ;; It is annoying to flash messages on the screen briefly, |
977 ;; and this message is not useful. -- rms | |
978 ;; (message "%s is an `etags' TAGS file" buffer-file-name) | |
799 | 979 (mapcar (function (lambda (elt) |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
980 (set (make-local-variable (car elt)) (cdr elt)))) |
799 | 981 '((file-of-tag-function . etags-file-of-tag) |
982 (tags-table-files-function . etags-tags-table-files) | |
983 (tags-completion-table-function . etags-tags-completion-table) | |
984 (snarf-tag-function . etags-snarf-tag) | |
985 (goto-tag-location-function . etags-goto-tag-location) | |
986 (find-tag-regexp-search-function . re-search-forward) | |
987 (find-tag-regexp-tag-order . (tag-re-match-p)) | |
3548
54b82ecde27b
(etags-recognize-tags-table): Fix misspelling of
Richard M. Stallman <rms@gnu.org>
parents:
2768
diff
changeset
|
988 (find-tag-regexp-next-line-after-failure-p . t) |
799 | 989 (find-tag-search-function . search-forward) |
990 (find-tag-tag-order . (tag-exact-match-p tag-word-match-p | |
991 tag-any-match-p)) | |
992 (find-tag-next-line-after-failure-p . nil) | |
993 (list-tags-function . etags-list-tags) | |
994 (tags-apropos-function . etags-tags-apropos) | |
995 (tags-included-tables-function . etags-tags-included-tables) | |
996 (verify-tags-table-function . etags-verify-tags-table) | |
997 )))) | |
998 | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
999 ;; Return non-nil iff the current buffer is a valid etags TAGS file. |
799 | 1000 (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
|
1001 ;; 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
|
1002 (eq (char-after 1) ?\f)) |
799 | 1003 |
1004 (defun etags-file-of-tag () | |
1005 (save-excursion | |
1006 (search-backward "\f\n") | |
1007 (forward-char 2) | |
1008 (buffer-substring (point) | |
1009 (progn (skip-chars-forward "^,") (point))))) | |
1010 | |
1011 (defun etags-tags-completion-table () | |
1012 (let ((table (make-vector 511 0))) | |
1013 (save-excursion | |
1014 (goto-char (point-min)) | |
2448
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
1015 ;; 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
|
1016 ;; \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
|
1017 ;; \2 is not interesting; |
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
1018 ;; \3 is the guessed tag name; XXX guess should be better eg DEFUN |
4407
5568d8e60c21
(etags-tags-completion-table): Fixed regexp for today's format.
Roland McGrath <roland@gnu.org>
parents:
4391
diff
changeset
|
1019 ;; \4 is not interesting; |
5568d8e60c21
(etags-tags-completion-table): Fixed regexp for today's format.
Roland McGrath <roland@gnu.org>
parents:
4391
diff
changeset
|
1020 ;; \5 is the explicitly-specified tag name. |
5568d8e60c21
(etags-tags-completion-table): Fixed regexp for today's format.
Roland McGrath <roland@gnu.org>
parents:
4391
diff
changeset
|
1021 ;; \6 is the line to start searching at; |
5568d8e60c21
(etags-tags-completion-table): Fixed regexp for today's format.
Roland McGrath <roland@gnu.org>
parents:
4391
diff
changeset
|
1022 ;; \7 is the char to start searching at. |
2448
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
1023 (while (re-search-forward |
3702
5bcb8bd982d0
(etags-tags-completion-table): When skipping the noise
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1024 "^\\(\\(.+[^-a-zA-Z0-9_$]+\\)?\\([-a-zA-Z0-9_$]+\\)\ |
6244
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1025 \[^-a-zA-Z0-9_$]*\\)\177\\(\\([^\n\001]+\\)\001\\)?\ |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1026 \\([0-9]+\\)?,\\([0-9]+\\)?\n" |
2448
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
1027 nil t) |
4407
5568d8e60c21
(etags-tags-completion-table): Fixed regexp for today's format.
Roland McGrath <roland@gnu.org>
parents:
4391
diff
changeset
|
1028 (intern (if (match-beginning 5) |
2448
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
1029 ;; There is an explicit tag name. |
4407
5568d8e60c21
(etags-tags-completion-table): Fixed regexp for today's format.
Roland McGrath <roland@gnu.org>
parents:
4391
diff
changeset
|
1030 (buffer-substring (match-beginning 5) (match-end 5)) |
2448
0d7fdb12dcdb
(etags-tags-completion-table): Rewritten with a mondo regexp.
Roland McGrath <roland@gnu.org>
parents:
2445
diff
changeset
|
1031 ;; 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
|
1032 (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
|
1033 table))) |
799 | 1034 table)) |
1035 | |
1036 (defun etags-snarf-tag () | |
6244
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1037 (let (tag-text line startpos) |
799 | 1038 (search-forward "\177") |
1039 (setq tag-text (buffer-substring (1- (point)) | |
1040 (save-excursion (beginning-of-line) | |
1041 (point)))) | |
4407
5568d8e60c21
(etags-tags-completion-table): Fixed regexp for today's format.
Roland McGrath <roland@gnu.org>
parents:
4391
diff
changeset
|
1042 ;; Skip explicit tag name if present. |
5568d8e60c21
(etags-tags-completion-table): Fixed regexp for today's format.
Roland McGrath <roland@gnu.org>
parents:
4391
diff
changeset
|
1043 (search-forward "\001" (save-excursion (forward-line 1) (point)) t) |
6244
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1044 (if (looking-at "[0-9]") |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1045 (setq line (string-to-int (buffer-substring |
799 | 1046 (point) |
1047 (progn (skip-chars-forward "0-9") | |
6244
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1048 (point)))))) |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1049 (search-forward ",") |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1050 (if (looking-at "[0-9]") |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1051 (setq startpos (string-to-int (buffer-substring |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1052 (point) |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1053 (progn (skip-chars-forward "0-9") |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1054 (point)))))) |
799 | 1055 ;; Leave point on the next line of the tags file. |
1056 (forward-line 1) | |
6244
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1057 (cons tag-text (cons line startpos)))) |
799 | 1058 |
6244
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1059 ;; TAG-INFO is a cons (TEXT LINE . POSITION) where TEXT is the initial part |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1060 ;; of a line containing the tag and POSITION is the character position of |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1061 ;; TEXT within the file (starting from 1); LINE is the line number. Either |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1062 ;; LINE or POSITION may be nil; POSITION is used if present. If the tag |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1063 ;; isn't exactly at the given position then look around that position using |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1064 ;; a search window which expands until it hits the start of file. |
799 | 1065 (defun etags-goto-tag-location (tag-info) |
6244
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1066 (let ((startpos (cdr (cdr tag-info))) |
799 | 1067 ;; This constant is 1/2 the initial search window. |
1068 ;; There is no sense in making it too small, | |
1069 ;; since just going around the loop once probably | |
1070 ;; costs about as much as searching 2000 chars. | |
1071 (offset 1000) | |
1072 (found nil) | |
4389
102019d30432
(etags-goto-tag-location): Handle selective display.
Richard M. Stallman <rms@gnu.org>
parents:
3702
diff
changeset
|
1073 (pat (concat (if (eq selective-display t) |
102019d30432
(etags-goto-tag-location): Handle selective display.
Richard M. Stallman <rms@gnu.org>
parents:
3702
diff
changeset
|
1074 "\\(^\\|\^m\\)" "^") |
102019d30432
(etags-goto-tag-location): Handle selective display.
Richard M. Stallman <rms@gnu.org>
parents:
3702
diff
changeset
|
1075 (regexp-quote (car tag-info))))) |
6244
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1076 ;; If no char pos was given, try the given line number. |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1077 (or startpos |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1078 (if (car (cdr tag-info)) |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1079 (setq startpos (progn (goto-line (car (cdr tag-info))) |
3ad3a0150b6d
(etags-tags-completion-table): Let the line number or char pos be empty.
Roland McGrath <roland@gnu.org>
parents:
6140
diff
changeset
|
1080 (point))))) |
799 | 1081 (or startpos |
1082 (setq startpos (point-min))) | |
5892
c9b930106073
(etags-goto-tag-location): First go directly to STARTPOS and see if PAT is
Roland McGrath <roland@gnu.org>
parents:
5712
diff
changeset
|
1083 ;; First see if the tag is right at the specified location. |
c9b930106073
(etags-goto-tag-location): First go directly to STARTPOS and see if PAT is
Roland McGrath <roland@gnu.org>
parents:
5712
diff
changeset
|
1084 (goto-char startpos) |
c9b930106073
(etags-goto-tag-location): First go directly to STARTPOS and see if PAT is
Roland McGrath <roland@gnu.org>
parents:
5712
diff
changeset
|
1085 (setq found (looking-at pat)) |
799 | 1086 (while (and (not found) |
1087 (progn | |
1088 (goto-char (- startpos offset)) | |
1089 (not (bobp)))) | |
1090 (setq found | |
1091 (re-search-forward pat (+ startpos offset) t) | |
1092 offset (* 3 offset))) ; expand search window | |
1093 (or found | |
1094 (re-search-forward pat nil t) | |
5279
5de9297274f4
(visit-tags-table-buffer): Change "Add to list" question.
Richard M. Stallman <rms@gnu.org>
parents:
5174
diff
changeset
|
1095 (error "Rerun etags: `%s' not found in %s" |
799 | 1096 pat buffer-file-name))) |
4486
3ab31f82a529
(etags-goto-tag-location): If match started with Ctrl-m,
Richard M. Stallman <rms@gnu.org>
parents:
4407
diff
changeset
|
1097 ;; Position point at the right place |
3ab31f82a529
(etags-goto-tag-location): If match started with Ctrl-m,
Richard M. Stallman <rms@gnu.org>
parents:
4407
diff
changeset
|
1098 ;; if the search string matched an extra Ctrl-m at the beginning. |
3ab31f82a529
(etags-goto-tag-location): If match started with Ctrl-m,
Richard M. Stallman <rms@gnu.org>
parents:
4407
diff
changeset
|
1099 (and (eq selective-display t) |
3ab31f82a529
(etags-goto-tag-location): If match started with Ctrl-m,
Richard M. Stallman <rms@gnu.org>
parents:
4407
diff
changeset
|
1100 (looking-at "\^m") |
3ab31f82a529
(etags-goto-tag-location): If match started with Ctrl-m,
Richard M. Stallman <rms@gnu.org>
parents:
4407
diff
changeset
|
1101 (forward-char 1)) |
799 | 1102 (beginning-of-line)) |
1103 | |
1104 (defun etags-list-tags (file) | |
1105 (goto-char 1) | |
1106 (if (not (search-forward (concat "\f\n" file ",") nil t)) | |
1107 nil | |
1108 (forward-line 1) | |
1109 (while (not (or (eobp) (looking-at "\f"))) | |
6245
c05d1d7bc400
(etags-list-tags): Check for explicit tag names.
Roland McGrath <roland@gnu.org>
parents:
6244
diff
changeset
|
1110 (let ((tag (buffer-substring (point) |
c05d1d7bc400
(etags-list-tags): Check for explicit tag names.
Roland McGrath <roland@gnu.org>
parents:
6244
diff
changeset
|
1111 (progn (skip-chars-forward "^\177") |
c05d1d7bc400
(etags-list-tags): Check for explicit tag names.
Roland McGrath <roland@gnu.org>
parents:
6244
diff
changeset
|
1112 (point))))) |
c05d1d7bc400
(etags-list-tags): Check for explicit tag names.
Roland McGrath <roland@gnu.org>
parents:
6244
diff
changeset
|
1113 (princ (if (looking-at "[^\n]+\001") |
c05d1d7bc400
(etags-list-tags): Check for explicit tag names.
Roland McGrath <roland@gnu.org>
parents:
6244
diff
changeset
|
1114 ;; There is an explicit tag name; use that. |
c05d1d7bc400
(etags-list-tags): Check for explicit tag names.
Roland McGrath <roland@gnu.org>
parents:
6244
diff
changeset
|
1115 (buffer-substring (point) |
c05d1d7bc400
(etags-list-tags): Check for explicit tag names.
Roland McGrath <roland@gnu.org>
parents:
6244
diff
changeset
|
1116 (progn (skip-chars-forward "^\001") |
c05d1d7bc400
(etags-list-tags): Check for explicit tag names.
Roland McGrath <roland@gnu.org>
parents:
6244
diff
changeset
|
1117 (point))) |
c05d1d7bc400
(etags-list-tags): Check for explicit tag names.
Roland McGrath <roland@gnu.org>
parents:
6244
diff
changeset
|
1118 tag))) |
799 | 1119 (terpri) |
4940
2f65b0f9c6fc
(etags-list-tags): Return t if found the file.
Richard M. Stallman <rms@gnu.org>
parents:
4857
diff
changeset
|
1120 (forward-line 1)) |
2f65b0f9c6fc
(etags-list-tags): Return t if found the file.
Richard M. Stallman <rms@gnu.org>
parents:
4857
diff
changeset
|
1121 t)) |
799 | 1122 |
1123 (defun etags-tags-apropos (string) | |
1124 (goto-char 1) | |
1125 (while (re-search-forward string nil t) | |
1126 (beginning-of-line) | |
1127 (princ (buffer-substring (point) | |
1128 (progn (skip-chars-forward "^\177") | |
1129 (point)))) | |
1130 (terpri) | |
1131 (forward-line 1))) | |
1132 | |
1133 (defun etags-tags-table-files () | |
1134 (let ((files nil) | |
1135 beg) | |
1136 (goto-char (point-min)) | |
1137 (while (search-forward "\f\n" nil t) | |
1138 (setq beg (point)) | |
1139 (skip-chars-forward "^,\n") | |
1140 (or (looking-at ",include$") | |
1141 ;; Expand in the default-directory of the tags table buffer. | |
1142 (setq files (cons (expand-file-name (buffer-substring beg (point))) | |
1143 files)))) | |
1144 (nreverse files))) | |
1145 | |
1146 (defun etags-tags-included-tables () | |
1147 (let ((files nil) | |
1148 beg) | |
1149 (goto-char (point-min)) | |
1150 (while (search-forward "\f\n" nil t) | |
1151 (setq beg (point)) | |
1152 (skip-chars-forward "^,\n") | |
1153 (if (looking-at ",include$") | |
1154 ;; Expand in the default-directory of the tags table buffer. | |
1155 (setq files (cons (expand-file-name (buffer-substring beg (point))) | |
1156 files)))) | |
1157 (nreverse files))) | |
1158 | |
1159 ;; Empty tags file support. | |
1160 | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
1161 ;; 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
|
1162 ;; variables which do nothing. |
799 | 1163 (defun recognize-empty-tags-table () |
1164 (and (zerop (buffer-size)) | |
1165 (mapcar (function (lambda (sym) | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
1166 (set (make-local-variable sym) 'ignore))) |
799 | 1167 '(tags-table-files-function |
1168 tags-completion-table-function | |
1169 find-tag-regexp-search-function | |
1170 find-tag-search-function | |
1171 tags-apropos-function | |
1172 tags-included-tables-function)) | |
1173 (set (make-local-variable 'verify-tags-table-function) | |
1174 (function (lambda () | |
1175 (zerop (buffer-size))))))) | |
1176 | |
1177 ;;; Match qualifier functions for tagnames. | |
1696
cceb5375ce40
Many comments added and docstrings fixed.
Roland McGrath <roland@gnu.org>
parents:
1555
diff
changeset
|
1178 ;;; XXX these functions assume etags file format. |
799 | 1179 |
884 | 1180 ;; This might be a neat idea, but it's too hairy at the moment. |
1181 ;;(defmacro tags-with-syntax (&rest body) | |
1182 ;; (` (let ((current (current-buffer)) | |
1183 ;; (otable (syntax-table)) | |
1184 ;; (buffer (find-file-noselect (file-of-tag))) | |
1185 ;; table) | |
1186 ;; (unwind-protect | |
1187 ;; (progn | |
1188 ;; (set-buffer buffer) | |
1189 ;; (setq table (syntax-table)) | |
1190 ;; (set-buffer current) | |
1191 ;; (set-syntax-table table) | |
1192 ;; (,@ body)) | |
1193 ;; (set-syntax-table otable))))) | |
1194 ;;(put 'tags-with-syntax 'edebug-form-spec '(&rest form)) | |
877 | 1195 |
799 | 1196 ;; t if point is at a tag line that matches TAG "exactly". |
1197 ;; point should be just after a string that matches TAG. | |
884 | 1198 (defun tag-exact-match-p (tag) |
4666
674082454a0c
(tag-exact-match-p): Return true if TAG is the explicit tag name.
Roland McGrath <roland@gnu.org>
parents:
4661
diff
changeset
|
1199 ;; The match is really exact if there is an explicit tag name. |
674082454a0c
(tag-exact-match-p): Return true if TAG is the explicit tag name.
Roland McGrath <roland@gnu.org>
parents:
4661
diff
changeset
|
1200 (or (looking-at (concat "[^\177]*\177" (regexp-quote tag) "\001")) |
674082454a0c
(tag-exact-match-p): Return true if TAG is the explicit tag name.
Roland McGrath <roland@gnu.org>
parents:
4661
diff
changeset
|
1201 ;; We also call it "exact" if it is surrounded by symbol boundaries. |
674082454a0c
(tag-exact-match-p): Return true if TAG is the explicit tag name.
Roland McGrath <roland@gnu.org>
parents:
4661
diff
changeset
|
1202 ;; This is needed because etags does not always generate explicit names. |
674082454a0c
(tag-exact-match-p): Return true if TAG is the explicit tag name.
Roland McGrath <roland@gnu.org>
parents:
4661
diff
changeset
|
1203 (and (looking-at "\\Sw.*\177") (looking-at "\\S_.*\177") |
674082454a0c
(tag-exact-match-p): Return true if TAG is the explicit tag name.
Roland McGrath <roland@gnu.org>
parents:
4661
diff
changeset
|
1204 (save-excursion |
674082454a0c
(tag-exact-match-p): Return true if TAG is the explicit tag name.
Roland McGrath <roland@gnu.org>
parents:
4661
diff
changeset
|
1205 (backward-char (1+ (length tag))) |
674082454a0c
(tag-exact-match-p): Return true if TAG is the explicit tag name.
Roland McGrath <roland@gnu.org>
parents:
4661
diff
changeset
|
1206 (and (looking-at "\\Sw") (looking-at "\\S_")))))) |
799 | 1207 |
1208 ;; t if point is at a tag line that matches TAG as a word. | |
1209 ;; point should be just after a string that matches TAG. | |
1210 (defun tag-word-match-p (tag) | |
1211 (and (looking-at "\\b.*\177") | |
1212 (save-excursion (backward-char (1+ (length tag))) | |
1213 (looking-at "\\b")))) | |
1214 | |
1215 ;; t if point is in a tag line with a tag containing TAG as a substring. | |
1216 (defun tag-any-match-p (tag) | |
1217 (looking-at ".*\177")) | |
1218 | |
1219 ;; t if point is at a tag line that matches RE as a regexp. | |
1220 (defun tag-re-match-p (re) | |
1221 (save-excursion | |
1222 (beginning-of-line) | |
1223 (let ((bol (point))) | |
1224 (and (search-forward "\177" (save-excursion (end-of-line) (point)) t) | |
1225 (re-search-backward re bol t))))) | |
1226 | |
1227 ;;;###autoload | |
1228 (defun next-file (&optional initialize novisit) | |
1229 "Select next file among files in current tags table. | |
4661
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1230 |
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1231 A first argument of t (prefix arg, if interactive) initializes to the |
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1232 beginning of the list of files in the tags table. If the argument is |
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1233 neither nil nor t, it is evalled to initialize the list of files. |
799 | 1234 |
1235 Non-nil second argument NOVISIT means use a temporary buffer | |
1236 to save time and avoid uninteresting warnings. | |
1237 | |
1238 Value is nil if the file was already visited; | |
1239 if the file was newly read in, the value is the filename." | |
342 | 1240 (interactive "P") |
4661
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1241 (cond ((not initialize) |
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1242 ;; Not the first run. |
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1243 ) |
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1244 ((eq initialize t) |
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1245 ;; Initialize the list from the tags table. |
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1246 (save-excursion |
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1247 ;; Visit the tags table buffer to get its list of files. |
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1248 (visit-tags-table-buffer) |
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1249 (setq next-file-list (tags-table-files)))) |
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1250 (t |
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1251 ;; Initialize the list by evalling the argument. |
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1252 (setq next-file-list (eval initialize)))) |
342 | 1253 (or next-file-list |
799 | 1254 (save-excursion |
1397
d469afe703c4
(visit-tags-table-buffer): When trying to pick table, call
Roland McGrath <roland@gnu.org>
parents:
1156
diff
changeset
|
1255 ;; Get the files from the next tags table. |
1152 | 1256 ;; When doing (visit-tags-table-buffer t), |
799 | 1257 ;; the tags table buffer must be current. |
1258 (if (and (visit-tags-table-buffer 'same) | |
1259 (visit-tags-table-buffer t)) | |
1260 (setq next-file-list (tags-table-files)) | |
1261 (and novisit | |
1262 (get-buffer " *next-file*") | |
1263 (kill-buffer " *next-file*")) | |
1264 (error "All files processed.")))) | |
1265 (let ((new (not (get-file-buffer (car next-file-list))))) | |
1266 (if (not (and new novisit)) | |
1267 (set-buffer (find-file-noselect (car next-file-list) novisit)) | |
1268 ;; Like find-file, but avoids random warning messages. | |
1269 (set-buffer (get-buffer-create " *next-file*")) | |
1270 (kill-all-local-variables) | |
1271 (erase-buffer) | |
1272 (setq new (car next-file-list)) | |
1273 (insert-file-contents new nil)) | |
1274 (setq next-file-list (cdr next-file-list)) | |
1275 new)) | |
342 | 1276 |
799 | 1277 (defvar tags-loop-operate nil |
1278 "Form for `tags-loop-continue' to eval to change one file.") | |
1279 | |
1808
60685747963c
(tags-loop-scan): Set default value to an error form.
Roland McGrath <roland@gnu.org>
parents:
1807
diff
changeset
|
1280 (defvar tags-loop-scan |
60685747963c
(tags-loop-scan): Set default value to an error form.
Roland McGrath <roland@gnu.org>
parents:
1807
diff
changeset
|
1281 '(error (substitute-command-keys |
60685747963c
(tags-loop-scan): Set default value to an error form.
Roland McGrath <roland@gnu.org>
parents:
1807
diff
changeset
|
1282 "No \\[tags-search] or \\[tags-query-replace] in progress.")) |
799 | 1283 "Form for `tags-loop-continue' to eval to scan one file. |
1284 If it returns non-nil, this file needs processing by evalling | |
1285 \`tags-loop-operate'. Otherwise, move on to the next file.") | |
342 | 1286 |
360 | 1287 ;;;###autoload |
342 | 1288 (defun tags-loop-continue (&optional first-time) |
1289 "Continue last \\[tags-search] or \\[tags-query-replace] command. | |
4661
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1290 Used noninteractively with non-nil argument to begin such a command (the |
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1291 argument is passed to `next-file', which see). |
799 | 1292 Two variables control the processing we do on each file: |
1293 the value of `tags-loop-scan' is a form to be executed on each file | |
1294 to see if it is interesting (it returns non-nil if so) | |
1295 and `tags-loop-operate' is a form to execute to operate on an interesting file | |
1296 If the latter returns non-nil, we exit; otherwise we scan the next file." | |
342 | 1297 (interactive) |
799 | 1298 (let (new |
1299 (messaged nil)) | |
1300 (while | |
1301 (progn | |
1302 ;; Scan files quickly for the first or next interesting one. | |
1303 (while (or first-time | |
1304 (save-restriction | |
1305 (widen) | |
1306 (not (eval tags-loop-scan)))) | |
1307 (setq new (next-file first-time t)) | |
1308 ;; If NEW is non-nil, we got a temp buffer, | |
1309 ;; and NEW is the file name. | |
1310 (if (or messaged | |
1311 (and (not first-time) | |
1312 (> baud-rate search-slow-speed) | |
1313 (setq messaged t))) | |
1314 (message "Scanning file %s..." (or new buffer-file-name))) | |
1315 (setq first-time nil) | |
1316 (goto-char (point-min))) | |
1317 | |
1318 ;; If we visited it in a temp buffer, visit it now for real. | |
1319 (if new | |
1320 (let ((pos (point))) | |
1321 (erase-buffer) | |
1322 (set-buffer (find-file-noselect new)) | |
1323 (widen) | |
1324 (goto-char pos))) | |
1325 | |
1326 (switch-to-buffer (current-buffer)) | |
1327 | |
1328 ;; Now operate on the file. | |
1329 ;; If value is non-nil, continue to scan the next file. | |
1330 (eval tags-loop-operate))) | |
1331 (and messaged | |
1332 (null tags-loop-operate) | |
1333 (message "Scanning file %s...found" buffer-file-name)))) | |
1334 ;;;###autoload (define-key esc-map "," 'tags-loop-continue) | |
342 | 1335 |
360 | 1336 ;;;###autoload |
4661
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1337 (defun tags-search (regexp &optional file-list-form) |
799 | 1338 "Search through all files listed in tags table for match for REGEXP. |
342 | 1339 Stops when a match is found. |
1340 To continue searching for next match, use command \\[tags-loop-continue]. | |
1341 | |
799 | 1342 See documentation of variable `tags-file-name'." |
342 | 1343 (interactive "sTags search (regexp): ") |
1344 (if (and (equal regexp "") | |
799 | 1345 (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
|
1346 (null tags-loop-operate)) |
799 | 1347 ;; Continue last tags-search as if by M-,. |
342 | 1348 (tags-loop-continue nil) |
799 | 1349 (setq tags-loop-scan |
1350 (list 're-search-forward regexp nil t) | |
1351 tags-loop-operate nil) | |
4661
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1352 (tags-loop-continue (or file-list-form t)))) |
342 | 1353 |
360 | 1354 ;;;###autoload |
4661
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1355 (defun tags-query-replace (from to &optional delimited file-list-form) |
799 | 1356 "Query-replace-regexp FROM with TO through all files listed in tags table. |
342 | 1357 Third arg DELIMITED (prefix arg) means replace only word-delimited matches. |
799 | 1358 If you exit (\\[keyboard-quit] or ESC), you can resume the query-replace |
342 | 1359 with the command \\[tags-loop-continue]. |
1360 | |
799 | 1361 See documentation of variable `tags-file-name'." |
1362 (interactive | |
1363 "sTags query replace (regexp): \nsTags query replace %s by: \nP") | |
804 | 1364 (setq tags-loop-scan (list 'prog1 |
1816 | 1365 (list 'if (list 're-search-forward from nil t) |
804 | 1366 ;; When we find a match, move back |
1367 ;; to the beginning of it so perform-replace | |
1368 ;; will see it. | |
1369 '(goto-char (match-beginning 0)))) | |
799 | 1370 tags-loop-operate (list 'perform-replace from to t t delimited)) |
4661
8ca17ed2aeb8
(next-file): If arg is neither t nor nil, then eval it to return initial
Roland McGrath <roland@gnu.org>
parents:
4486
diff
changeset
|
1371 (tags-loop-continue (or file-list-form t))) |
799 | 1372 |
1373 ;;;###autoload | |
1374 (defun list-tags (file) | |
1375 "Display list of tags in file FILE. | |
4940
2f65b0f9c6fc
(etags-list-tags): Return t if found the file.
Richard M. Stallman <rms@gnu.org>
parents:
4857
diff
changeset
|
1376 FILE should not contain a directory specification." |
4857
3ca316ec55e3
(list-tags): Fix completing-read call interactive spec; TABLE and PREDICATE
Roland McGrath <roland@gnu.org>
parents:
4666
diff
changeset
|
1377 (interactive (list (completing-read "List tags in file: " |
3ca316ec55e3
(list-tags): Fix completing-read call interactive spec; TABLE and PREDICATE
Roland McGrath <roland@gnu.org>
parents:
4666
diff
changeset
|
1378 (save-excursion |
3ca316ec55e3
(list-tags): Fix completing-read call interactive spec; TABLE and PREDICATE
Roland McGrath <roland@gnu.org>
parents:
4666
diff
changeset
|
1379 (visit-tags-table-buffer) |
4940
2f65b0f9c6fc
(etags-list-tags): Return t if found the file.
Richard M. Stallman <rms@gnu.org>
parents:
4857
diff
changeset
|
1380 (mapcar 'list |
2f65b0f9c6fc
(etags-list-tags): Return t if found the file.
Richard M. Stallman <rms@gnu.org>
parents:
4857
diff
changeset
|
1381 (mapcar 'file-name-nondirectory |
2f65b0f9c6fc
(etags-list-tags): Return t if found the file.
Richard M. Stallman <rms@gnu.org>
parents:
4857
diff
changeset
|
1382 (tags-table-files)))) |
4857
3ca316ec55e3
(list-tags): Fix completing-read call interactive spec; TABLE and PREDICATE
Roland McGrath <roland@gnu.org>
parents:
4666
diff
changeset
|
1383 nil t nil))) |
799 | 1384 (with-output-to-temp-buffer "*Tags List*" |
1385 (princ "Tags in file ") | |
1386 (princ file) | |
1387 (terpri) | |
1388 (save-excursion | |
1389 (let ((first-time t) | |
1390 (gotany nil)) | |
1149 | 1391 (while (visit-tags-table-buffer (not first-time)) |
4940
2f65b0f9c6fc
(etags-list-tags): Return t if found the file.
Richard M. Stallman <rms@gnu.org>
parents:
4857
diff
changeset
|
1392 (setq first-time nil) |
799 | 1393 (if (funcall list-tags-function file) |
1394 (setq gotany t))) | |
1395 (or gotany | |
4940
2f65b0f9c6fc
(etags-list-tags): Return t if found the file.
Richard M. Stallman <rms@gnu.org>
parents:
4857
diff
changeset
|
1396 (error "File %s not in current tags tables" file)))))) |
342 | 1397 |
360 | 1398 ;;;###autoload |
799 | 1399 (defun tags-apropos (regexp) |
1400 "Display list of all tags in tags table REGEXP matches." | |
1401 (interactive "sTags apropos (regexp): ") | |
342 | 1402 (with-output-to-temp-buffer "*Tags List*" |
799 | 1403 (princ "Tags matching regexp ") |
1404 (prin1 regexp) | |
342 | 1405 (terpri) |
1406 (save-excursion | |
1149 | 1407 (let ((first-time t)) |
1408 (while (visit-tags-table-buffer (not first-time)) | |
1409 (setq first-time nil) | |
1151 | 1410 (funcall tags-apropos-function regexp)))))) |
799 | 1411 |
1412 ;;; XXX Kludge interface. | |
342 | 1413 |
799 | 1414 ;; XXX If a file is in multiple tables, selection may get the wrong one. |
804 | 1415 ;;;###autoload |
799 | 1416 (defun select-tags-table () |
1417 "Select a tags table file from a menu of those you have already used. | |
1418 The list of tags tables to select from is stored in `tags-table-file-list'; | |
1419 see the doc of that variable if you want to add names to the list." | |
1420 (interactive) | |
1421 (pop-to-buffer "*Tags Table List*") | |
1422 (setq buffer-read-only nil) | |
1423 (erase-buffer) | |
1424 (setq selective-display t | |
1425 selective-display-ellipses nil) | |
1426 (let ((set-list tags-table-set-list) | |
1427 (desired-point nil)) | |
1428 (if tags-table-list | |
1429 (progn | |
1430 (setq desired-point (point-marker)) | |
1431 (princ tags-table-list (current-buffer)) | |
1432 (insert "\C-m") | |
1433 (prin1 (car tags-table-list) (current-buffer)) ;invisible | |
1434 (insert "\n"))) | |
1435 (while set-list | |
1436 (if (eq (car set-list) tags-table-list) | |
1437 ;; Already printed it. | |
1438 () | |
1439 (princ (car set-list) (current-buffer)) | |
1440 (insert "\C-m") | |
1441 (prin1 (car (car set-list)) (current-buffer)) ;invisible | |
1442 (insert "\n")) | |
1443 (setq set-list (cdr set-list))) | |
1444 (if tags-file-name | |
1445 (progn | |
1446 (or desired-point | |
1447 (setq desired-point (point-marker))) | |
1448 (insert tags-file-name "\C-m") | |
1449 (prin1 tags-file-name (current-buffer)) ;invisible | |
1450 (insert "\n"))) | |
1451 (setq set-list (delete tags-file-name | |
1452 (apply 'nconc (cons tags-table-list | |
1453 (mapcar 'copy-sequence | |
1454 tags-table-set-list))))) | |
1455 (while set-list | |
1456 (insert (car set-list) "\C-m") | |
1457 (prin1 (car set-list) (current-buffer)) ;invisible | |
1458 (insert "\n") | |
1459 (setq set-list (delete (car set-list) set-list))) | |
1460 (goto-char 1) | |
1461 (insert-before-markers | |
1462 "Type `t' to select a tags table or set of tags tables:\n\n") | |
1463 (if desired-point | |
1464 (goto-char desired-point)) | |
1465 (set-window-start (selected-window) 1 t)) | |
1466 (set-buffer-modified-p nil) | |
1467 (setq buffer-read-only t | |
1468 mode-name "Select Tags Table") | |
1469 (let ((map (make-sparse-keymap))) | |
1470 (define-key map "t" 'select-tags-table-select) | |
1471 (define-key map " " 'next-line) | |
1472 (define-key map "\^?" 'previous-line) | |
1473 (define-key map "n" 'next-line) | |
1474 (define-key map "p" 'previous-line) | |
1475 (define-key map "q" 'select-tags-table-quit) | |
1476 (use-local-map map))) | |
1477 | |
1478 (defun select-tags-table-select () | |
1479 "Select the tags table named on this line." | |
1480 (interactive) | |
1481 (search-forward "\C-m") | |
1482 (let ((name (read (current-buffer)))) | |
1483 (visit-tags-table name) | |
1484 (select-tags-table-quit) | |
1485 (message "Tags table now %s" name))) | |
1486 | |
1487 (defun select-tags-table-quit () | |
1488 "Kill the buffer and delete the selected window." | |
1489 (interactive) | |
1490 (kill-buffer (current-buffer)) | |
1491 (or (one-window-p) | |
1492 (delete-window))) | |
1493 | |
360 | 1494 ;;;###autoload |
799 | 1495 (defun complete-tag () |
1496 "Perform tags completion on the text around point. | |
1497 Completes to the set of names listed in the current tags table. | |
1498 The string to complete is chosen in the same way as the default | |
981 | 1499 for \\[find-tag] (which see)." |
799 | 1500 (interactive) |
981 | 1501 (or tags-table-list |
1502 tags-file-name | |
1503 (error (substitute-command-keys | |
1504 "No tags table loaded. Try \\[visit-tags-table]."))) | |
799 | 1505 (let ((pattern (funcall (or find-tag-default-function |
1506 (get major-mode 'find-tag-default-function) | |
1507 'find-tag-default))) | |
1508 beg | |
1509 completion) | |
1510 (or pattern | |
1511 (error "Nothing to complete")) | |
1512 (search-backward pattern) | |
1513 (setq beg (point)) | |
1514 (forward-char (length pattern)) | |
1515 (setq completion (try-completion pattern 'tags-complete-tag nil)) | |
1516 (cond ((eq completion t)) | |
1517 ((null completion) | |
1518 (message "Can't find completion for \"%s\"" pattern) | |
1519 (ding)) | |
1520 ((not (string= pattern completion)) | |
1521 (delete-region beg (point)) | |
1522 (insert completion)) | |
1523 (t | |
1524 (message "Making completion list...") | |
1525 (with-output-to-temp-buffer " *Completions*" | |
1526 (display-completion-list | |
1527 (all-completions pattern 'tags-complete-tag nil))) | |
1528 (message "Making completion list...%s" "done"))))) | |
884 | 1529 |
1530 ;;;###autoload (define-key esc-map "\t" 'complete-tag) | |
799 | 1531 |
584 | 1532 (provide 'etags) |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
804
diff
changeset
|
1533 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
804
diff
changeset
|
1534 ;;; etags.el ends here |