aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland McGrath1995-12-14 06:34:54 +0000
committerRoland McGrath1995-12-14 06:34:54 +0000
commit83287e5be35f018da090208ef3480fe081ceb7e4 (patch)
treeb356912c155bede5a3b3396a675f9d24f8d628ea
parent66fc2bf5cfbd56abccb005b2b9692924b0db4603 (diff)
downloademacs-83287e5be35f018da090208ef3480fe081ceb7e4.tar.gz
emacs-83287e5be35f018da090208ef3480fe081ceb7e4.zip
Fix completely broken changes of 4 Feb 95 by brat@htilbom.ernet.in,
which were obviously never tested or even examined closely before being installed. (find-tag-file-order): Variable removed. (find-tag-noselect): Remove gratuitously added variable SEARCH-TAG and bogus clobbering of find-tag-order for patterns ending in dot (serious braindamage here). (find-tag-in-order): Remove gratuitously added variable TAGS-TABLE-FILE. Remove variable MATCH-TYPE and code testing it for stupid special case. (etags-recognize-tags-table): Put tag-exact-file-name-match-p first in find-tag-tag-order list. Don't set bogus find-tag-file-order variable. (etags-snarf-tag): Notice file name match and return tag info with t in place of tag text. (etags-goto-tag-location): If (car TAG-INFO) is t, go directly to the specified location. (tag-exact-file-name-match-p): Renamed from tag-filename-match-p, and fixed. (tags-table-files): Doc fix: names are returned unexpanded. (etags-tags-table-files): Don't expand file names. (tags-table-including, next-file): Expand result of (tags-table-files). (tags-complete-tags-table-file): New function, helper for interactive spec of list-tags. (list-tags): Revert to original code, but use that function to lazify the completion table. (tags-list-functions-in-file, tags-locate-file-in-tags-table): Functions removed.
-rw-r--r--lisp/progmodes/etags.el315
1 files changed, 136 insertions, 179 deletions
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index 2f21bacbeec..403fe0b7f9c 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -136,8 +136,6 @@ of the format-parsing tags function variables if successful.")
136(defvar goto-tag-location-function nil 136(defvar goto-tag-location-function nil
137 "Function of to go to the location in the buffer specified by a tag. 137 "Function of to go to the location in the buffer specified by a tag.
138One argument, the tag info returned by `snarf-tag-function'.") 138One argument, the tag info returned by `snarf-tag-function'.")
139(defvar find-tag-file-order nil
140 "Function which checks for complete and correct match, for file name as tag.")
141(defvar find-tag-regexp-search-function nil 139(defvar find-tag-regexp-search-function nil
142 "Search function passed to `find-tag-in-order' for finding a regexp tag.") 140 "Search function passed to `find-tag-in-order' for finding a regexp tag.")
143(defvar find-tag-regexp-tag-order nil 141(defvar find-tag-regexp-tag-order nil
@@ -227,7 +225,7 @@ file the tag was in."
227 (while tables 225 (while tables
228 (setq computed (cons (car tables) computed) 226 (setq computed (cons (car tables) computed)
229 table-buffer (get-file-buffer (car tables))) 227 table-buffer (get-file-buffer (car tables)))
230 (if (and table-buffer 228 (if (and table-buffer
231 ;; There is a buffer visiting the file. Now make sure 229 ;; There is a buffer visiting the file. Now make sure
232 ;; it is initialized as a tag table buffer. 230 ;; it is initialized as a tag table buffer.
233 (save-excursion 231 (save-excursion
@@ -364,7 +362,8 @@ Returns non-nil iff it is a valid table."
364 ;; Select the tags table buffer and get the file list up to date. 362 ;; Select the tags table buffer and get the file list up to date.
365 (let ((tags-file-name (car tables))) 363 (let ((tags-file-name (car tables)))
366 (visit-tags-table-buffer 'same) 364 (visit-tags-table-buffer 'same)
367 (if (member this-file (tags-table-files)) 365 (if (member this-file (mapcar 'expand-file-name
366 (tags-table-files)))
368 ;; Found it. 367 ;; Found it.
369 (setq found tables)))) 368 (setq found tables))))
370 (setq tables (cdr tables))) 369 (setq tables (cdr tables)))
@@ -387,7 +386,7 @@ Returns non-nil iff it is a valid table."
387 (setq elt (cdr elt)))) 386 (setq elt (cdr elt))))
388 ;; The last element we found in the computed list before FOUND 387 ;; The last element we found in the computed list before FOUND
389 ;; that appears in the user's list will be the table that 388 ;; that appears in the user's list will be the table that
390 ;; included the one we found. 389 ;; included the one we found.
391 could-be)))) 390 could-be))))
392 391
393;; Subroutine of visit-tags-table-buffer. Move tags-table-list-pointer 392;; Subroutine of visit-tags-table-buffer. Move tags-table-list-pointer
@@ -454,7 +453,7 @@ Returns t if it visits a tags table, or nil if there are no more in the list."
454 ;; be frobnicated, and CONT will be set non-nil so we don't 453 ;; be frobnicated, and CONT will be set non-nil so we don't
455 ;; do it below. 454 ;; do it below.
456 (and buffer-file-name 455 (and buffer-file-name
457 (or 456 (or
458 ;; First check only tables already in buffers. 457 ;; First check only tables already in buffers.
459 (tags-table-including buffer-file-name t) 458 (tags-table-including buffer-file-name t)
460 ;; Since that didn't find any, now do the 459 ;; Since that didn't find any, now do the
@@ -595,8 +594,9 @@ File name returned is relative to tags table file's directory."
595;;;###autoload 594;;;###autoload
596(defun tags-table-files () 595(defun tags-table-files ()
597 "Return a list of files in the current tags table. 596 "Return a list of files in the current tags table.
598Assumes the tags table is the current buffer. 597Assumes the tags table is the current buffer. The file names are returned
599File names returned are absolute." 598as they appeared in the `etags' command that created the table, usually
599without directory names."
600 (or tags-table-files 600 (or tags-table-files
601 (setq tags-table-files 601 (setq tags-table-files
602 (funcall tags-table-files-function)))) 602 (funcall tags-table-files-function))))
@@ -717,8 +717,7 @@ See documentation of variable `tags-file-name'."
717 (setq find-tag-history (cons tagname find-tag-history)) 717 (setq find-tag-history (cons tagname find-tag-history))
718 ;; Save the current buffer's value of `find-tag-hook' before selecting the 718 ;; Save the current buffer's value of `find-tag-hook' before selecting the
719 ;; tags table buffer. 719 ;; tags table buffer.
720 (let ((local-find-tag-hook find-tag-hook) 720 (let ((local-find-tag-hook find-tag-hook))
721 (search-tag))
722 (if (eq '- next-p) 721 (if (eq '- next-p)
723 ;; Pop back to a previous location. 722 ;; Pop back to a previous location.
724 (if (null tags-location-stack) 723 (if (null tags-location-stack)
@@ -744,7 +743,6 @@ See documentation of variable `tags-file-name'."
744 ;; Record the location so we can pop back to it later. 743 ;; Record the location so we can pop back to it later.
745 (let ((marker (make-marker))) 744 (let ((marker (make-marker)))
746 (save-excursion 745 (save-excursion
747 (setq search-tag (if next-p last-tag tagname))
748 (set-buffer 746 (set-buffer
749 ;; find-tag-in-order does the real work. 747 ;; find-tag-in-order does the real work.
750 (find-tag-in-order 748 (find-tag-in-order
@@ -754,9 +752,7 @@ See documentation of variable `tags-file-name'."
754 find-tag-search-function) 752 find-tag-search-function)
755 (if regexp-p 753 (if regexp-p
756 find-tag-regexp-tag-order 754 find-tag-regexp-tag-order
757 (if (string-match "\\b.*\\.\\w*" search-tag) 755 find-tag-tag-order)
758 find-tag-file-order
759 find-tag-tag-order))
760 (if regexp-p 756 (if regexp-p
761 find-tag-regexp-next-line-after-failure-p 757 find-tag-regexp-next-line-after-failure-p
762 find-tag-next-line-after-failure-p) 758 find-tag-next-line-after-failure-p)
@@ -886,19 +882,16 @@ See documentation of variable `tags-file-name'."
886 first-search) 882 first-search)
887 (let (file ;name of file containing tag 883 (let (file ;name of file containing tag
888 tag-info ;where to find the tag in FILE 884 tag-info ;where to find the tag in FILE
889 tags-table-file ;name of tags file
890 (first-table t) 885 (first-table t)
891 (tag-order order) 886 (tag-order order)
892 goto-func 887 goto-func
893 match-type
894 ) 888 )
895 (save-excursion 889 (save-excursion
896 (or first-search ;find-tag-noselect has already done it. 890 (or first-search ;find-tag-noselect has already done it.
897 (visit-tags-table-buffer 'same)) 891 (visit-tags-table-buffer 'same))
898 892
899 ;; Get a qualified match. 893 ;; Get a qualified match.
900 (setq match-type 894 (catch 'qualified-match-found
901 (catch 'qualified-match-found
902 895
903 ;; Iterate over the list of tags tables. 896 ;; Iterate over the list of tags tables.
904 (while (or first-table 897 (while (or first-table
@@ -910,12 +903,9 @@ See documentation of variable `tags-file-name'."
910 (and first-search first-table 903 (and first-search first-table
911 ;; Start at beginning of tags file. 904 ;; Start at beginning of tags file.
912 (goto-char (point-min))) 905 (goto-char (point-min)))
913 (or first-table
914 (goto-char (point-min)))
915 906
916 (setq first-table nil) 907 (setq first-table nil)
917 908
918 (setq tags-table-file buffer-file-name)
919 ;; Iterate over the list of ordering predicates. 909 ;; Iterate over the list of ordering predicates.
920 (while order 910 (while order
921 (while (funcall search-forward-func pattern nil t) 911 (while (funcall search-forward-func pattern nil t)
@@ -934,8 +924,8 @@ See documentation of variable `tags-file-name'."
934 (setq order tag-order)) 924 (setq order tag-order))
935 ;; We throw out on match, so only get here if there were no matches. 925 ;; We throw out on match, so only get here if there were no matches.
936 (error "No %stags %s %s" (if first-search "" "more ") 926 (error "No %stags %s %s" (if first-search "" "more ")
937 matching pattern))) 927 matching pattern))
938 928
939 ;; Found a tag; extract location info. 929 ;; Found a tag; extract location info.
940 (beginning-of-line) 930 (beginning-of-line)
941 (setq tag-lines-already-matched (cons (point) 931 (setq tag-lines-already-matched (cons (point)
@@ -951,10 +941,8 @@ See documentation of variable `tags-file-name'."
951 (set-buffer (find-file-noselect file)) 941 (set-buffer (find-file-noselect file))
952 (widen) 942 (widen)
953 (push-mark) 943 (push-mark)
954 (if (eq match-type 'tag-filename-match-p) 944 (funcall goto-func tag-info)
955 (goto-char (point-min)) 945
956 (funcall goto-func tag-info))
957
958 ;; Return the buffer where the tag was found. 946 ;; Return the buffer where the tag was found.
959 (current-buffer)))) 947 (current-buffer))))
960 948
@@ -978,12 +966,11 @@ See documentation of variable `tags-file-name'."
978 (find-tag-regexp-tag-order . (tag-re-match-p)) 966 (find-tag-regexp-tag-order . (tag-re-match-p))
979 (find-tag-regexp-next-line-after-failure-p . t) 967 (find-tag-regexp-next-line-after-failure-p . t)
980 (find-tag-search-function . search-forward) 968 (find-tag-search-function . search-forward)
981 (find-tag-tag-order . (tag-filename-match-p 969 (find-tag-tag-order . (tag-exact-file-name-match-p
982 tag-exact-match-p 970 tag-exact-match-p
983 tag-symbol-match-p 971 tag-symbol-match-p
984 tag-word-match-p 972 tag-word-match-p
985 tag-any-match-p)) 973 tag-any-match-p))
986 (find-tag-file-order . (tag-filename-match-p))
987 (find-tag-next-line-after-failure-p . nil) 974 (find-tag-next-line-after-failure-p . nil)
988 (list-tags-function . etags-list-tags) 975 (list-tags-function . etags-list-tags)
989 (tags-apropos-function . etags-tags-apropos) 976 (tags-apropos-function . etags-tags-apropos)
@@ -1031,74 +1018,93 @@ See documentation of variable `tags-file-name'."
1031 1018
1032(defun etags-snarf-tag () 1019(defun etags-snarf-tag ()
1033 (let (tag-text line startpos) 1020 (let (tag-text line startpos)
1034 (search-forward "\177") 1021 (if (save-excursion
1035 (setq tag-text (buffer-substring (1- (point)) 1022 (forward-line -1)
1036 (save-excursion (beginning-of-line) 1023 (looking-at "\f\n"))
1037 (point)))) 1024 ;; The match was for a source file name, not any tag within a file.
1038 ;; Skip explicit tag name if present. 1025 ;; Give text of t, meaning to go exactly to the location we specify,
1039 (search-forward "\001" (save-excursion (forward-line 1) (point)) t) 1026 ;; the beginning of the file.
1040 (if (looking-at "[0-9]") 1027 (setq tag-text t
1041 (setq line (string-to-int (buffer-substring 1028 line nil
1042 (point) 1029 startpos 1)
1043 (progn (skip-chars-forward "0-9") 1030
1044 (point)))))) 1031 ;; Find the end of the tag and record the whole tag text.
1045 (search-forward ",") 1032 (search-forward "\177")
1046 (if (looking-at "[0-9]") 1033 (setq tag-text (buffer-substring (1- (point))
1047 (setq startpos (string-to-int (buffer-substring 1034 (save-excursion (beginning-of-line)
1048 (point) 1035 (point))))
1049 (progn (skip-chars-forward "0-9") 1036 ;; Skip explicit tag name if present.
1050 (point)))))) 1037 (search-forward "\001" (save-excursion (forward-line 1) (point)) t)
1038 (if (looking-at "[0-9]")
1039 (setq line (string-to-int (buffer-substring
1040 (point)
1041 (progn (skip-chars-forward "0-9")
1042 (point))))))
1043 (search-forward ",")
1044 (if (looking-at "[0-9]")
1045 (setq startpos (string-to-int (buffer-substring
1046 (point)
1047 (progn (skip-chars-forward "0-9")
1048 (point)))))))
1051 ;; Leave point on the next line of the tags file. 1049 ;; Leave point on the next line of the tags file.
1052 (forward-line 1) 1050 (forward-line 1)
1053 (cons tag-text (cons line startpos)))) 1051 (cons tag-text (cons line startpos))))
1054 1052
1055;; TAG-INFO is a cons (TEXT LINE . POSITION) where TEXT is the initial part 1053;; TAG-INFO is a cons (TEXT LINE . POSITION) where TEXT is the initial part
1056;; of a line containing the tag and POSITION is the character position of 1054;; of a line containing the tag and POSITION is the character position of
1057;; TEXT within the file (starting from 1); LINE is the line number. Either 1055;; TEXT within the file (starting from 1); LINE is the line number. If
1056;; TEXT is t, it means the tag refers to exactly LINE or POSITION
1057;; (whichever is present, LINE having preference, no searching. Either
1058;; LINE or POSITION may be nil; POSITION is used if present. If the tag 1058;; LINE or POSITION may be nil; POSITION is used if present. If the tag
1059;; isn't exactly at the given position then look around that position using 1059;; isn't exactly at the given position then look around that position using
1060;; a search window which expands until it hits the start of file. 1060;; a search window which expands until it hits the start of file.
1061(defun etags-goto-tag-location (tag-info) 1061(defun etags-goto-tag-location (tag-info)
1062 (let ((startpos (cdr (cdr tag-info))) 1062 (let ((startpos (cdr (cdr tag-info)))
1063 ;; This constant is 1/2 the initial search window. 1063 offset found pat)
1064 ;; There is no sense in making it too small, 1064 (if (eq (car tag-info) t)
1065 ;; since just going around the loop once probably 1065 ;; Direct file tag.
1066 ;; costs about as much as searching 2000 chars. 1066 (cond (line (goto-line line))
1067 (offset 1000) 1067 (position (goto-char position))
1068 (found nil) 1068 (t (error "etags.el BUG: bogus direct file tag")))
1069 (pat (concat (if (eq selective-display t) 1069 ;; This constant is 1/2 the initial search window.
1070 "\\(^\\|\^m\\)" "^") 1070 ;; There is no sense in making it too small,
1071 (regexp-quote (car tag-info))))) 1071 ;; since just going around the loop once probably
1072 ;; The character position in the tags table is 0-origin. 1072 ;; costs about as much as searching 2000 chars.
1073 ;; Convert it to a 1-origin Emacs character position. 1073 (setq offset 1000
1074 (if startpos (setq startpos (1+ startpos))) 1074 found nil
1075 ;; If no char pos was given, try the given line number. 1075 pat (concat (if (eq selective-display t)
1076 (or startpos 1076 "\\(^\\|\^m\\)" "^")
1077 (if (car (cdr tag-info)) 1077 (regexp-quote (car tag-info))))
1078 (setq startpos (progn (goto-line (car (cdr tag-info))) 1078 ;; The character position in the tags table is 0-origin.
1079 (point))))) 1079 ;; Convert it to a 1-origin Emacs character position.
1080 (or startpos 1080 (if startpos (setq startpos (1+ startpos)))
1081 (setq startpos (point-min))) 1081 ;; If no char pos was given, try the given line number.
1082 ;; First see if the tag is right at the specified location. 1082 (or startpos
1083 (goto-char startpos) 1083 (if (car (cdr tag-info))
1084 (setq found (looking-at pat)) 1084 (setq startpos (progn (goto-line (car (cdr tag-info)))
1085 (while (and (not found) 1085 (point)))))
1086 (progn 1086 (or startpos
1087 (goto-char (- startpos offset)) 1087 (setq startpos (point-min)))
1088 (not (bobp)))) 1088 ;; First see if the tag is right at the specified location.
1089 (setq found 1089 (goto-char startpos)
1090 (re-search-forward pat (+ startpos offset) t) 1090 (setq found (looking-at pat))
1091 offset (* 3 offset))) ; expand search window 1091 (while (and (not found)
1092 (or found 1092 (progn
1093 (re-search-forward pat nil t) 1093 (goto-char (- startpos offset))
1094 (error "Rerun etags: `%s' not found in %s" 1094 (not (bobp))))
1095 pat buffer-file-name))) 1095 (setq found
1096 ;; Position point at the right place 1096 (re-search-forward pat (+ startpos offset) t)
1097 ;; if the search string matched an extra Ctrl-m at the beginning. 1097 offset (* 3 offset))) ; expand search window
1098 (and (eq selective-display t) 1098 (or found
1099 (looking-at "\^m") 1099 (re-search-forward pat nil t)
1100 (forward-char 1)) 1100 (error "Rerun etags: `%s' not found in %s"
1101 (beginning-of-line)) 1101 pat buffer-file-name)))
1102 ;; Position point at the right place
1103 ;; if the search string matched an extra Ctrl-m at the beginning.
1104 (and (eq selective-display t)
1105 (looking-at "\^m")
1106 (forward-char 1))
1107 (beginning-of-line)))
1102 1108
1103(defun etags-list-tags (file) 1109(defun etags-list-tags (file)
1104 (goto-char 1) 1110 (goto-char 1)
@@ -1138,9 +1144,7 @@ See documentation of variable `tags-file-name'."
1138 (end-of-line) 1144 (end-of-line)
1139 (skip-chars-backward "^," beg) 1145 (skip-chars-backward "^," beg)
1140 (or (looking-at "include$") 1146 (or (looking-at "include$")
1141 ;; Expand in the default-directory of the tags table buffer. 1147 (setq files (cons (buffer-substring beg (1- (point))) files))))
1142 (setq files (cons (expand-file-name (buffer-substring beg (1- (point))))
1143 files))))
1144 (nreverse files))) 1148 (nreverse files)))
1145 1149
1146(defun etags-tags-included-tables () 1150(defun etags-tags-included-tables ()
@@ -1218,10 +1222,10 @@ See documentation of variable `tags-file-name'."
1218 (save-excursion (backward-char (1+ (length tag))) 1222 (save-excursion (backward-char (1+ (length tag)))
1219 (looking-at "\\b")))) 1223 (looking-at "\\b"))))
1220 1224
1221(defun tag-filename-match-p (tag) 1225(defun tag-exact-file-name-match-p (tag)
1222 (and (looking-at ",") 1226 (and (looking-at ",")
1223 (save-excursion (backward-char (1+ (length tag))) 1227 (save-excursion (backward-char (1+ (length tag)))
1224 (looking-at "\\b")))) 1228 (looking-at "\f\n"))))
1225 1229
1226;; t if point is in a tag line with a tag containing TAG as a substring. 1230;; t if point is in a tag line with a tag containing TAG as a substring.
1227(defun tag-any-match-p (tag) 1231(defun tag-any-match-p (tag)
@@ -1258,8 +1262,9 @@ if the file was newly read in, the value is the filename."
1258 (save-excursion 1262 (save-excursion
1259 ;; Visit the tags table buffer to get its list of files. 1263 ;; Visit the tags table buffer to get its list of files.
1260 (visit-tags-table-buffer) 1264 (visit-tags-table-buffer)
1261 ;; Copy the list so we can setcdr below. 1265 ;; Copy the list so we can setcdr below, and expand the file
1262 (setq next-file-list (copy-sequence (tags-table-files))) 1266 ;; names while we are at it, in this buffer's default directory.
1267 (setq next-file-list (mapcar 'expand-file-name (tags-table-files)))
1263 ;; Iterate over all the tags table files, collecting 1268 ;; Iterate over all the tags table files, collecting
1264 ;; a complete list of referenced file names. 1269 ;; a complete list of referenced file names.
1265 (while (visit-tags-table-buffer t) 1270 (while (visit-tags-table-buffer t)
@@ -1271,8 +1276,9 @@ if the file was newly read in, the value is the filename."
1271 ;; Use a copy so the next loop iteration will not modify the 1276 ;; Use a copy so the next loop iteration will not modify the
1272 ;; list later returned by (tags-table-files). 1277 ;; list later returned by (tags-table-files).
1273 (if tail 1278 (if tail
1274 (setcdr tail (copy-sequence (tags-table-files))) 1279 (setcdr tail (mapcar 'expand-file-name (tags-table-files)))
1275 (setq next-file-list (copy-sequence (tags-table-files)))))))) 1280 (setq next-file-list (mapcar 'expand-file-name
1281 (tags-table-files))))))))
1276 (t 1282 (t
1277 ;; Initialize the list by evalling the argument. 1283 ;; Initialize the list by evalling the argument.
1278 (setq next-file-list (eval initialize)))) 1284 (setq next-file-list (eval initialize))))
@@ -1397,18 +1403,39 @@ See documentation of variable `tags-file-name'."
1397 t t (list 'quote delimited))) 1403 t t (list 'quote delimited)))
1398 (tags-loop-continue (or file-list-form t))) 1404 (tags-loop-continue (or file-list-form t)))
1399 1405
1406(defun tags-complete-tags-table-file (string predicate what)
1407 (save-excursion
1408 ;; If we need to ask for the tag table, allow that.
1409 (let ((enable-recursive-minibuffers t))
1410 (visit-tags-table-buffer))
1411 (if (eq what t)
1412 (all-completions string (mapcar 'list (tags-table-files))
1413 predicate)
1414 (try-completion string (mapcar 'list (tags-table-files))
1415 predicate))))
1416
1400;;;###autoload 1417;;;###autoload
1401(defun list-tags (filename &optional next-match) 1418(defun list-tags (file &optional next-match)
1402 "Gives the list of functions available in file \"filename\" 1419 "Display list of tags in file FILE.
1403Searches only in \"tags-file-name\"." 1420This searches only the first table in the list, and no included tables.
1404 (interactive "sFunctions in File: ") 1421FILE should be as it appeared in the `etags' command, usually without a
1405 (let (file-list) 1422directory specification."
1406 (setq file-list (tags-locate-file-in-tags-table filename 1423 (interactive (list (completing-read "List tags in file: "
1407 (if next-match next-match nil))) 1424 'tags-complete-tags-table-file
1408 (if file-list 1425 nil t nil)))
1409 (tags-list-functions-in-file (nth 1 (car file-list)) 1426 (with-output-to-temp-buffer "*Tags List*"
1410 (nth 2 (car file-list))) 1427 (princ "Tags in file ")
1411 (message (format "%s not found in tags table" filename))))) 1428 (princ file)
1429 (terpri)
1430 (save-excursion
1431 (let ((first-time t)
1432 (gotany nil))
1433 (while (visit-tags-table-buffer (not first-time))
1434 (setq first-time nil)
1435 (if (funcall list-tags-function file)
1436 (setq gotany t)))
1437 (or gotany
1438 (error "File %s not in current tags tables" file))))))
1412 1439
1413;;;###autoload 1440;;;###autoload
1414(defun tags-apropos (regexp) 1441(defun tags-apropos (regexp)
@@ -1501,7 +1528,7 @@ see the doc of that variable if you want to add names to the list."
1501 (use-local-map select-tags-table-mode-map) 1528 (use-local-map select-tags-table-mode-map)
1502 (setq selective-display t 1529 (setq selective-display t
1503 selective-display-ellipses nil)) 1530 selective-display-ellipses nil))
1504 1531
1505(defun select-tags-table-select () 1532(defun select-tags-table-select ()
1506 "Select the tags table named on this line." 1533 "Select the tags table named on this line."
1507 (interactive) 1534 (interactive)
@@ -1516,12 +1543,12 @@ see the doc of that variable if you want to add names to the list."
1516 (interactive) 1543 (interactive)
1517 (kill-buffer (current-buffer)) 1544 (kill-buffer (current-buffer))
1518 (or (one-window-p) 1545 (or (one-window-p)
1519 (delete-window))) 1546 (delete-window)))
1520 1547
1521;;;###autoload 1548;;;###autoload
1522(defun complete-tag () 1549(defun complete-tag ()
1523 "Perform tags completion on the text around point. 1550 "Perform tags completion on the text around point.
1524Completes to the set of names listed in the current tags table. 1551Completes to the set of names listed in the current tags table.
1525The string to complete is chosen in the same way as the default 1552The string to complete is chosen in the same way as the default
1526for \\[find-tag] (which see)." 1553for \\[find-tag] (which see)."
1527 (interactive) 1554 (interactive)
@@ -1556,76 +1583,6 @@ for \\[find-tag] (which see)."
1556 1583
1557;;;###autoload (define-key esc-map "\t" 'complete-tag) 1584;;;###autoload (define-key esc-map "\t" 'complete-tag)
1558 1585
1559(defun tags-list-functions-in-file (pos tag-file)
1560 "Lists the functions for the given file. Backend for `list-tags'."
1561 (let ((tag-buf (find-file-noselect tag-file))
1562 (result-buf (get-buffer-create "*Tags Function List*"))
1563 function
1564 beg
1565 map)
1566 (save-excursion
1567 (set-buffer result-buf)
1568 (erase-buffer)
1569 (set-buffer tag-buf)
1570 (goto-char pos)
1571 (forward-line 1)
1572 (beginning-of-line)
1573 ; C-l marks end of information of a file in TAGS.
1574 (while (and (not (looking-at "^\C-l")) (not (eobp)))
1575 ; skip mere #defines, typedefs and struct definitions
1576 (if (not (or (looking-at "^#define\\s-+[a-zA-Z0-9_]+\\s-+")
1577 (looking-at "^typedef\\s-+")
1578 (looking-at "^\\s-*}")))
1579 (progn
1580 (setq beg (point))
1581 (skip-chars-forward "^\C-?(")
1582 (setq function (buffer-substring beg (point)))
1583 (save-excursion
1584 (set-buffer result-buf)
1585 (insert (concat function "\n")))))
1586 (forward-line 1)
1587 (beginning-of-line)))
1588 (switch-to-buffer "*Tags Function List*")
1589 (goto-char 1)
1590 (set-buffer-modified-p nil)
1591 (setq buffer-read-only t)))
1592
1593(defun tags-locate-file-in-tags-table (filename first-search)
1594 "This function is used to locate `filename' in `tags-table-list'.
1595 Its internally used by the functions `find-file-from-tags' and
1596 `tags-list-tags-in-file'. If `first-search' is t, search continues from where
1597 it left off last time. Else, its a fresh search."
1598 (let (tag-list current-tags-buffer beg file found-file-list next-tag-file)
1599 (setq tag-list tags-table-list)
1600 (catch 'found-file
1601 (setq found-file-list nil
1602 next-tag-file nil)
1603 (while tag-list
1604 (setq current-tags-buffer (find-file-noselect (car tag-list)))
1605 (save-excursion
1606 (set-buffer current-tags-buffer)
1607 (if (or next-tag-file
1608 (not first-search))
1609 (goto-char (point-min)))
1610 (if (search-forward filename nil t)
1611 (if (tag-filename-match-p filename)
1612 (progn
1613 (beginning-of-line)
1614 (setq beg (point))
1615 (skip-chars-forward "^,")
1616 (or (looking-at ",include$")
1617 (setq file (expand-file-name (buffer-substring beg
1618 (point)))))
1619 (if (string-match filename (file-name-nondirectory file))
1620 (progn
1621 (setq found-file-list (cons (list file (point)
1622 (buffer-file-name))
1623 found-file-list))
1624 (throw 'found-file found-file-list))))))
1625 (setq tag-list (cdr tag-list))
1626 (setq next-tag-file 't)))
1627 (throw 'found-file found-file-list))))
1628
1629(provide 'etags) 1586(provide 'etags)
1630 1587
1631;;; etags.el ends here 1588;;; etags.el ends here