(next-file): Initialize next-file-list all at once from all tables.
authorRoland McGrath <roland@gnu.org>
Thu, 20 Oct 1994 21:17:44 +0000 (21:17 +0000)
committerRoland McGrath <roland@gnu.org>
Thu, 20 Oct 1994 21:17:44 +0000 (21:17 +0000)
Never call visit-tags-table-buffer when INITIALIZE is not t.

lisp/progmodes/etags.el

index 42c43ee..2cab15a 100644 (file)
@@ -1231,22 +1231,28 @@ if the file was newly read in, the value is the filename."
         (save-excursion
           ;; Visit the tags table buffer to get its list of files.
           (visit-tags-table-buffer)
-          (setq next-file-list (tags-table-files))))
+          ;; Copy the list so we can setcdr below.
+          (setq next-file-list (copy-sequence (tags-table-files)))
+          ;; Iterate over all the tags table files, collecting
+          ;; a complete list of referenced file names.
+          (while (visit-tags-table-buffer t)
+            ;; Find the tail of the working list and chain on the new
+            ;; sublist for this tags table.
+            (let ((tail next-file-list))
+              (while (cdr tail)
+                (setq tail (cdr tail)))
+              ;; Use a copy so the next loop iteration will not modify the
+              ;; list later returned by (tags-table-files).
+              (setcdr tail (copy-sequence (tags-table-files)))))))
        (t
         ;; Initialize the list by evalling the argument.
         (setq next-file-list (eval initialize))))
-  (or next-file-list
-      (save-excursion
-       ;; Get the files from the next tags table.
-       ;; When doing (visit-tags-table-buffer t),
-       ;; the tags table buffer must be current.
-       (if (and (visit-tags-table-buffer 'same)
-                (visit-tags-table-buffer t))
-           (setq next-file-list (tags-table-files))
-         (and novisit
-              (get-buffer " *next-file*")
-              (kill-buffer " *next-file*"))
-         (error "All files processed."))))
+  (if next-file-list
+      ()
+    (and novisit
+        (get-buffer " *next-file*")
+        (kill-buffer " *next-file*"))
+    (error "All files processed."))
   (let ((new (not (get-file-buffer (car next-file-list)))))
     (if (not (and new novisit))
        (set-buffer (find-file-noselect (car next-file-list) novisit))