diff options
| author | Roland McGrath | 1996-06-07 17:31:33 +0000 |
|---|---|---|
| committer | Roland McGrath | 1996-06-07 17:31:33 +0000 |
| commit | b7089f3c839945ffbb60253b69dba0fac14695ab (patch) | |
| tree | c443103a57934361d5e9044cadeeea5fa2c8344a | |
| parent | 8eae7766a413119524bd89cbab761478245e0c1d (diff) | |
| download | emacs-b7089f3c839945ffbb60253b69dba0fac14695ab.tar.gz emacs-b7089f3c839945ffbb60253b69dba0fac14695ab.zip | |
Fri Jun 7 13:06:53 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* etags.el (tag-lines-already-matched): Remove defvar.
(initialize-new-tags-table): Don't make that var local.
(tag-lines-already-matched): Add docless defvar near find-tag-in-order
defun; this is a global state variable for that one function.
(find-tag-in-order): Move clearing of tag-lines-already-matched out of
loop. Make it a list of markers and search it with member; it is now
global, not buffer-local in the tags table, and records all matches in
any tags table during a single find-tag loop. When we run out of
matches, clear it and null out the markers.
| -rw-r--r-- | lisp/progmodes/etags.el | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el index 64f2e1d7afb..8954b1364b6 100644 --- a/lisp/progmodes/etags.el +++ b/lisp/progmodes/etags.el | |||
| @@ -100,10 +100,6 @@ Pop back to the last location with \\[negative-argument] \\[find-tag].") | |||
| 100 | ;; Tags table state. | 100 | ;; Tags table state. |
| 101 | ;; These variables are local in tags table buffers. | 101 | ;; These variables are local in tags table buffers. |
| 102 | 102 | ||
| 103 | (defvar tag-lines-already-matched nil | ||
| 104 | "List of positions of beginnings of lines within the tags table | ||
| 105 | that are already matched.") | ||
| 106 | |||
| 107 | (defvar tags-table-files nil | 103 | (defvar tags-table-files nil |
| 108 | "List of file names covered by current tags table. | 104 | "List of file names covered by current tags table. |
| 109 | nil means it has not yet been computed; use `tags-table-files' to do so.") | 105 | nil means it has not yet been computed; use `tags-table-files' to do so.") |
| @@ -164,7 +160,6 @@ One argument, the tag info returned by `snarf-tag-function'.") | |||
| 164 | ;; non-nil return, the tags table state variable are | 160 | ;; non-nil return, the tags table state variable are |
| 165 | ;; made buffer-local and initialized to nil. | 161 | ;; made buffer-local and initialized to nil. |
| 166 | (defun initialize-new-tags-table () | 162 | (defun initialize-new-tags-table () |
| 167 | (set (make-local-variable 'tag-lines-already-matched) nil) | ||
| 168 | (set (make-local-variable 'tags-table-files) nil) | 163 | (set (make-local-variable 'tags-table-files) nil) |
| 169 | (set (make-local-variable 'tags-completion-table) nil) | 164 | (set (make-local-variable 'tags-completion-table) nil) |
| 170 | (set (make-local-variable 'tags-included-tables) nil) | 165 | (set (make-local-variable 'tags-included-tables) nil) |
| @@ -876,6 +871,8 @@ See documentation of variable `tags-file-name'." | |||
| 876 | ;; specified source file and return. Qualified matches are remembered to | 871 | ;; specified source file and return. Qualified matches are remembered to |
| 877 | ;; avoid repetition. State is saved so that the loop can be continued. | 872 | ;; avoid repetition. State is saved so that the loop can be continued. |
| 878 | 873 | ||
| 874 | (defvar tag-lines-already-matched nil) ;matches remembered here between calls | ||
| 875 | |||
| 879 | (defun find-tag-in-order (pattern | 876 | (defun find-tag-in-order (pattern |
| 880 | search-forward-func | 877 | search-forward-func |
| 881 | order | 878 | order |
| @@ -886,11 +883,23 @@ See documentation of variable `tags-file-name'." | |||
| 886 | tag-info ;where to find the tag in FILE | 883 | tag-info ;where to find the tag in FILE |
| 887 | (first-table t) | 884 | (first-table t) |
| 888 | (tag-order order) | 885 | (tag-order order) |
| 886 | (match-marker (make-marker)) | ||
| 889 | goto-func | 887 | goto-func |
| 890 | ) | 888 | ) |
| 891 | (save-excursion | 889 | (save-excursion |
| 892 | (or first-search ;find-tag-noselect has already done it. | 890 | |
| 893 | (visit-tags-table-buffer 'same)) | 891 | (if first-search |
| 892 | ;; This is the start of a search for a fresh tag. | ||
| 893 | ;; Clear the list of tags matched by the previous search. | ||
| 894 | ;; find-tag-noselect has already put us in the first tags table | ||
| 895 | ;; buffer before we got called. | ||
| 896 | (setq tag-lines-already-matched nil) | ||
| 897 | ;; Continuing to search for the tag specified last time. | ||
| 898 | ;; tag-lines-already-matched lists locations matched in previous | ||
| 899 | ;; calls so we don't visit the same tag twice if it matches twice | ||
| 900 | ;; during two passes with different qualification predicates. | ||
| 901 | ;; Switch to the current tags table buffer. | ||
| 902 | (visit-tags-table-buffer 'same)) | ||
| 894 | 903 | ||
| 895 | ;; Get a qualified match. | 904 | ;; Get a qualified match. |
| 896 | (catch 'qualified-match-found | 905 | (catch 'qualified-match-found |
| @@ -899,9 +908,6 @@ See documentation of variable `tags-file-name'." | |||
| 899 | (while (or first-table | 908 | (while (or first-table |
| 900 | (visit-tags-table-buffer t)) | 909 | (visit-tags-table-buffer t)) |
| 901 | 910 | ||
| 902 | (if first-search | ||
| 903 | (setq tag-lines-already-matched nil)) | ||
| 904 | |||
| 905 | (and first-search first-table | 911 | (and first-search first-table |
| 906 | ;; Start at beginning of tags file. | 912 | ;; Start at beginning of tags file. |
| 907 | (goto-char (point-min))) | 913 | (goto-char (point-min))) |
| @@ -914,9 +920,10 @@ See documentation of variable `tags-file-name'." | |||
| 914 | ;; Naive match found. Qualify the match. | 920 | ;; Naive match found. Qualify the match. |
| 915 | (and (funcall (car order) pattern) | 921 | (and (funcall (car order) pattern) |
| 916 | ;; Make sure it is not a previous qualified match. | 922 | ;; Make sure it is not a previous qualified match. |
| 917 | ;; Use of `memq' depends on numbers being eq. | 923 | (not (member (set-marker match-marker (save-excursion |
| 918 | (not (memq (save-excursion (beginning-of-line) (point)) | 924 | (beginning-of-line) |
| 919 | tag-lines-already-matched)) | 925 | (point))) |
| 926 | tag-lines-already-matched)) | ||
| 920 | (throw 'qualified-match-found nil)) | 927 | (throw 'qualified-match-found nil)) |
| 921 | (if next-line-after-failure-p | 928 | (if next-line-after-failure-p |
| 922 | (forward-line 1))) | 929 | (forward-line 1))) |
| @@ -925,12 +932,18 @@ See documentation of variable `tags-file-name'." | |||
| 925 | (goto-char (point-min))) | 932 | (goto-char (point-min))) |
| 926 | (setq order tag-order)) | 933 | (setq order tag-order)) |
| 927 | ;; We throw out on match, so only get here if there were no matches. | 934 | ;; We throw out on match, so only get here if there were no matches. |
| 935 | ;; Clear out the markers we use to avoid duplicate matches so they | ||
| 936 | ;; don't slow down editting and are immediately available for GC. | ||
| 937 | (while tag-lines-already-matched | ||
| 938 | (set-marker (car tag-lines-already-matched) nil nil) | ||
| 939 | (setq tag-lines-already-matched (cdr tag-lines-already-matched))) | ||
| 940 | (set-marker match-marker nil nil) | ||
| 928 | (error "No %stags %s %s" (if first-search "" "more ") | 941 | (error "No %stags %s %s" (if first-search "" "more ") |
| 929 | matching pattern)) | 942 | matching pattern)) |
| 930 | 943 | ||
| 931 | ;; Found a tag; extract location info. | 944 | ;; Found a tag; extract location info. |
| 932 | (beginning-of-line) | 945 | (beginning-of-line) |
| 933 | (setq tag-lines-already-matched (cons (point) | 946 | (setq tag-lines-already-matched (cons match-marker |
| 934 | tag-lines-already-matched)) | 947 | tag-lines-already-matched)) |
| 935 | ;; Expand the filename, using the tags table buffer's default-directory. | 948 | ;; Expand the filename, using the tags table buffer's default-directory. |
| 936 | (setq file (expand-file-name (file-of-tag)) | 949 | (setq file (expand-file-name (file-of-tag)) |