comparison lisp/progmodes/etags.el @ 4661:8ca17ed2aeb8

(next-file): If arg is neither t nor nil, then eval it to return initial list of files. (tags-loop-continue): Doc fix. (tags-search, tags-query-replace): Take optional final arg and pass to tags-loop-continue (through to next-file) instead of t if non-nil.
author Roland McGrath <roland@gnu.org>
date Mon, 30 Aug 1993 16:17:35 +0000
parents 3ab31f82a529
children 674082454a0c
comparison
equal deleted inserted replaced
4660:2516bc453477 4661:8ca17ed2aeb8
1095 (re-search-backward re bol t))))) 1095 (re-search-backward re bol t)))))
1096 1096
1097 ;;;###autoload 1097 ;;;###autoload
1098 (defun next-file (&optional initialize novisit) 1098 (defun next-file (&optional initialize novisit)
1099 "Select next file among files in current tags table. 1099 "Select next file among files in current tags table.
1100 Non-nil first argument (prefix arg, if interactive) 1100
1101 initializes to the beginning of the list of files in the tags table. 1101 A first argument of t (prefix arg, if interactive) initializes to the
1102 beginning of the list of files in the tags table. If the argument is
1103 neither nil nor t, it is evalled to initialize the list of files.
1102 1104
1103 Non-nil second argument NOVISIT means use a temporary buffer 1105 Non-nil second argument NOVISIT means use a temporary buffer
1104 to save time and avoid uninteresting warnings. 1106 to save time and avoid uninteresting warnings.
1105 1107
1106 Value is nil if the file was already visited; 1108 Value is nil if the file was already visited;
1107 if the file was newly read in, the value is the filename." 1109 if the file was newly read in, the value is the filename."
1108 (interactive "P") 1110 (interactive "P")
1109 (and initialize 1111 (cond ((not initialize)
1110 (save-excursion 1112 ;; Not the first run.
1111 ;; Visit the tags table buffer to get its list of files. 1113 )
1112 (visit-tags-table-buffer) 1114 ((eq initialize t)
1113 (setq next-file-list (tags-table-files)))) 1115 ;; Initialize the list from the tags table.
1116 (save-excursion
1117 ;; Visit the tags table buffer to get its list of files.
1118 (visit-tags-table-buffer)
1119 (setq next-file-list (tags-table-files))))
1120 (t
1121 ;; Initialize the list by evalling the argument.
1122 (setq next-file-list (eval initialize))))
1114 (or next-file-list 1123 (or next-file-list
1115 (save-excursion 1124 (save-excursion
1116 ;; Get the files from the next tags table. 1125 ;; Get the files from the next tags table.
1117 ;; When doing (visit-tags-table-buffer t), 1126 ;; When doing (visit-tags-table-buffer t),
1118 ;; the tags table buffer must be current. 1127 ;; the tags table buffer must be current.
1146 \`tags-loop-operate'. Otherwise, move on to the next file.") 1155 \`tags-loop-operate'. Otherwise, move on to the next file.")
1147 1156
1148 ;;;###autoload 1157 ;;;###autoload
1149 (defun tags-loop-continue (&optional first-time) 1158 (defun tags-loop-continue (&optional first-time)
1150 "Continue last \\[tags-search] or \\[tags-query-replace] command. 1159 "Continue last \\[tags-search] or \\[tags-query-replace] command.
1151 Used noninteractively with non-nil argument to begin such a command. 1160 Used noninteractively with non-nil argument to begin such a command (the
1161 argument is passed to `next-file', which see).
1152 Two variables control the processing we do on each file: 1162 Two variables control the processing we do on each file:
1153 the value of `tags-loop-scan' is a form to be executed on each file 1163 the value of `tags-loop-scan' is a form to be executed on each file
1154 to see if it is interesting (it returns non-nil if so) 1164 to see if it is interesting (it returns non-nil if so)
1155 and `tags-loop-operate' is a form to execute to operate on an interesting file 1165 and `tags-loop-operate' is a form to execute to operate on an interesting file
1156 If the latter returns non-nil, we exit; otherwise we scan the next file." 1166 If the latter returns non-nil, we exit; otherwise we scan the next file."
1192 (null tags-loop-operate) 1202 (null tags-loop-operate)
1193 (message "Scanning file %s...found" buffer-file-name)))) 1203 (message "Scanning file %s...found" buffer-file-name))))
1194 ;;;###autoload (define-key esc-map "," 'tags-loop-continue) 1204 ;;;###autoload (define-key esc-map "," 'tags-loop-continue)
1195 1205
1196 ;;;###autoload 1206 ;;;###autoload
1197 (defun tags-search (regexp) 1207 (defun tags-search (regexp &optional file-list-form)
1198 "Search through all files listed in tags table for match for REGEXP. 1208 "Search through all files listed in tags table for match for REGEXP.
1199 Stops when a match is found. 1209 Stops when a match is found.
1200 To continue searching for next match, use command \\[tags-loop-continue]. 1210 To continue searching for next match, use command \\[tags-loop-continue].
1201 1211
1202 See documentation of variable `tags-file-name'." 1212 See documentation of variable `tags-file-name'."
1207 ;; Continue last tags-search as if by M-,. 1217 ;; Continue last tags-search as if by M-,.
1208 (tags-loop-continue nil) 1218 (tags-loop-continue nil)
1209 (setq tags-loop-scan 1219 (setq tags-loop-scan
1210 (list 're-search-forward regexp nil t) 1220 (list 're-search-forward regexp nil t)
1211 tags-loop-operate nil) 1221 tags-loop-operate nil)
1212 (tags-loop-continue t))) 1222 (tags-loop-continue (or file-list-form t))))
1213 1223
1214 ;;;###autoload 1224 ;;;###autoload
1215 (defun tags-query-replace (from to &optional delimited) 1225 (defun tags-query-replace (from to &optional delimited file-list-form)
1216 "Query-replace-regexp FROM with TO through all files listed in tags table. 1226 "Query-replace-regexp FROM with TO through all files listed in tags table.
1217 Third arg DELIMITED (prefix arg) means replace only word-delimited matches. 1227 Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
1218 If you exit (\\[keyboard-quit] or ESC), you can resume the query-replace 1228 If you exit (\\[keyboard-quit] or ESC), you can resume the query-replace
1219 with the command \\[tags-loop-continue]. 1229 with the command \\[tags-loop-continue].
1220 1230
1226 ;; When we find a match, move back 1236 ;; When we find a match, move back
1227 ;; to the beginning of it so perform-replace 1237 ;; to the beginning of it so perform-replace
1228 ;; will see it. 1238 ;; will see it.
1229 '(goto-char (match-beginning 0)))) 1239 '(goto-char (match-beginning 0))))
1230 tags-loop-operate (list 'perform-replace from to t t delimited)) 1240 tags-loop-operate (list 'perform-replace from to t t delimited))
1231 (tags-loop-continue t)) 1241 (tags-loop-continue (or file-list-form t)))
1232 1242
1233 ;;;###autoload 1243 ;;;###autoload
1234 (defun list-tags (file) 1244 (defun list-tags (file)
1235 "Display list of tags in file FILE. 1245 "Display list of tags in file FILE.
1236 FILE should not contain a directory specification 1246 FILE should not contain a directory specification