]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/etags.el
(gud-watch): Provide completion.
[gnu-emacs] / lisp / progmodes / etags.el
index ac2cc23048a400d0c8d508ac226491bfc21a5af1..30cfa1b7b21df6246ab02e31f44ad90e9b1f46c4 100644 (file)
@@ -1,7 +1,7 @@
 ;;; etags.el --- etags facility for Emacs
 
 ;; Copyright (C) 1985, 1986, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1998,
-;;               2000, 2001, 2002, 2003, 2004, 2005
+;;               2000, 2001, 2002, 2003, 2004, 2005, 2006
 ;;     Free Software Foundation, Inc.
 
 ;; Author: Roland McGrath <roland@gnu.org>
@@ -273,6 +273,14 @@ One argument, the tag info returned by `snarf-tag-function'.")
   ;; Value is t if we have found a valid tags table buffer.
   (run-hook-with-args-until-success 'tags-table-format-functions))
 
+;;;###autoload
+(defun tags-table-mode ()
+  "Major mode for tags table file buffers."
+  (interactive)
+  (setq major-mode 'tags-table-mode)
+  (setq mode-name "Tags Table")
+  (initialize-new-tags-table))
+
 ;;;###autoload
 (defun visit-tags-table (file &optional local)
   "Tell tags commands to use tags table file FILE.
@@ -415,7 +423,7 @@ Returns non-nil iff it is a valid table."
       ;; having changed since we last used it.
       (let (win)
        (set-buffer (get-file-buffer file))
-       (setq win (or verify-tags-table-function (initialize-new-tags-table)))
+       (setq win (or verify-tags-table-function (tags-table-mode)))
        (if (or (verify-visited-file-modtime (current-buffer))
                ;; Decide whether to revert the file.
                ;; revert-without-query can say to revert
@@ -434,7 +442,7 @@ Returns non-nil iff it is a valid table."
            (and verify-tags-table-function
                 (funcall verify-tags-table-function))
          (revert-buffer t t)
-         (initialize-new-tags-table)))
+         (tags-table-mode)))
     (and (file-exists-p file)
         (progn
           (set-buffer (find-file-noselect file))
@@ -446,7 +454,7 @@ Returns non-nil iff it is a valid table."
                     (setcar tail buffer-file-name))
                 (if (eq file tags-file-name)
                     (setq tags-file-name buffer-file-name))))
-          (initialize-new-tags-table)))))
+          (tags-table-mode)))))
 
 ;; Subroutine of visit-tags-table-buffer.  Search the current tags tables
 ;; for one that has tags for THIS-FILE (or that includes a table that
@@ -738,27 +746,25 @@ Assumes the tags table is the current buffer."
 ;; their tags included in the completion table.
 (defun tags-completion-table ()
   (or tags-completion-table
+      ;; No cached value for this buffer.
       (condition-case ()
-         (prog2
-          (message "Making tags completion table for %s..." buffer-file-name)
-          (let ((included (tags-included-tables))
-                (table (funcall tags-completion-table-function)))
-            (save-excursion
-              ;; Iterate over the list of included tables, and combine each
-              ;; included table's completion obarray to the parent obarray.
-              (while included
-                ;; Visit the buffer.
-                (let ((tags-file-name (car included)))
-                  (visit-tags-table-buffer 'same))
-                ;; Recurse in that buffer to compute its completion table.
-                (if (tags-completion-table)
-                    ;; Combine the tables.
-                    (mapatoms (lambda (sym) (intern (symbol-name sym) table))
-                              tags-completion-table))
-                (setq included (cdr included))))
-            (setq tags-completion-table table))
-          (message "Making tags completion table for %s...done"
-                   buffer-file-name))
+         (let (current-table combined-table)
+           (message "Making tags completion table for %s..." buffer-file-name)
+           (save-excursion
+             ;; Iterate over the current list of tags tables.
+             (while (visit-tags-table-buffer (and combined-table t))
+               ;; Find possible completions in this table.
+               (setq current-table (funcall tags-completion-table-function))
+               ;; Merge this buffer's completions into the combined table.
+               (if combined-table
+                   (mapatoms
+                    (lambda (sym) (intern (symbol-name sym) combined-table))
+                    current-table)
+                 (setq combined-table current-table))))
+           (message "Making tags completion table for %s...done"
+                    buffer-file-name)
+           ;; Cache the result a buffer-local variable.
+           (setq tags-completion-table combined-table))
        (quit (message "Tags completion table construction aborted.")
              (setq tags-completion-table nil)))))