aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-08-01 07:09:22 +0000
committerRichard M. Stallman1993-08-01 07:09:22 +0000
commita5024e2acead4459c2450ff3c2ba5c48a52f56ac (patch)
tree9b68e9f87d1931b7214fc2f7cdae8dfa26b26888
parent280a6a9f189e512c3de4e22ed146b4f4701d6765 (diff)
downloademacs-a5024e2acead4459c2450ff3c2ba5c48a52f56ac.tar.gz
emacs-a5024e2acead4459c2450ff3c2ba5c48a52f56ac.zip
(visit-tags-table-buffer): New local named
visit-tags-table-buffer-cont copies cont. (tags-table-including): Set that, instead of cont.
-rw-r--r--lisp/progmodes/etags.el314
1 files changed, 161 insertions, 153 deletions
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index 97ca5f816e8..d053fb079c2 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -259,6 +259,10 @@ file the tag was in."
259 (setq list (cdr list))) 259 (setq list (cdr list)))
260 list) 260 list)
261 261
262;; Local var in visit-tags-table-buffer-cont
263;; which is set by tags-table-including.
264(defvar visit-tags-table-buffer-cont)
265
262;; Subroutine of visit-tags-table-buffer. Frobs its local vars. 266;; Subroutine of visit-tags-table-buffer. Frobs its local vars.
263;; Search TABLES for one that has tags for THIS-FILE. Recurses on 267;; Search TABLES for one that has tags for THIS-FILE. Recurses on
264;; included tables. Returns the tail of TABLES (or of an inner 268;; included tables. Returns the tail of TABLES (or of an inner
@@ -312,10 +316,11 @@ file the tag was in."
312 tags-table-parent-pointer-list) 316 tags-table-parent-pointer-list)
313 tags-table-list-pointer found 317 tags-table-list-pointer found
314 tags-table-list-started-at found 318 tags-table-list-started-at found
315 ;; CONT is a local variable of 319 ;; Set a local variable of
316 ;; our caller, visit-tags-table-buffer. 320 ;; our caller, visit-tags-table-buffer.
317 ;; Set it so we won't frob lists later. 321 ;; Set it so we won't frob lists later.
318 cont 'included))) 322 visit-tags-table-buffer-cont
323 'included)))
319 (or recursing 324 (or recursing
320 ;; tags-table-parent-pointer-list now describes 325 ;; tags-table-parent-pointer-list now describes
321 ;; the path of included tables taken by recursive 326 ;; the path of included tables taken by recursive
@@ -343,160 +348,163 @@ If arg is nil or absent, choose a first buffer from information in
343Returns t if it visits a tags table, or nil if there are no more in the list." 348Returns t if it visits a tags table, or nil if there are no more in the list."
344 349
345 ;; Set tags-file-name to the tags table file we want to visit. 350 ;; Set tags-file-name to the tags table file we want to visit.
346 (cond ((eq cont 'same) 351 (let ((visit-tags-table-buffer-cont cont))
347 ;; Use the ambient value of tags-file-name. 352 (cond ((eq visit-tags-table-buffer-cont 'same)
348 (or tags-file-name 353 ;; Use the ambient value of tags-file-name.
349 (error (substitute-command-keys 354 (or tags-file-name
350 (concat "No tags table in use! " 355 (error (substitute-command-keys
351 "Use \\[visit-tags-table] to select one.")))) 356 (concat "No tags table in use! "
352 ;; Set CONT to nil so the code below will make sure tags-file-name 357 "Use \\[visit-tags-table] to select one."))))
353 ;; is in tags-table-list. 358 ;; Set VISIT-TAGS-TABLE-BUFFER-CONT to nil
354 (setq cont nil)) 359 ;; so the code below will make sure tags-file-name
355 360 ;; is in tags-table-list.
356 (cont 361 (setq visit-tags-table-buffer-cont nil))
357 ;; Find the next table. 362
358 (if (tags-next-table) 363 (visit-tags-table-buffer-cont
359 ;; Skip over nonexistent files. 364 ;; Find the next table.
360 (while (and (let ((file (tags-expand-table-name tags-file-name))) 365 (if (tags-next-table)
361 (not (or (get-file-buffer file) 366 ;; Skip over nonexistent files.
362 (file-exists-p file)))) 367 (while (and (let ((file (tags-expand-table-name tags-file-name)))
363 (tags-next-table))))) 368 (not (or (get-file-buffer file)
364 369 (file-exists-p file))))
365 (t 370 (tags-next-table)))))
366 ;; Pick a table out of our hat.
367 (setq tags-file-name
368 (or
369 ;; First, try a local variable.
370 (cdr (assq 'tags-file-name (buffer-local-variables)))
371 ;; Second, try a user-specified function to guess.
372 (and default-tags-table-function
373 (funcall default-tags-table-function))
374 ;; Third, look for a tags table that contains
375 ;; tags for the current buffer's file.
376 ;; If one is found, the lists will be frobnicated,
377 ;; and CONT will be set non-nil so we don't do it below.
378 (car (or
379 ;; First check only tables already in buffers.
380 (save-excursion (tags-table-including buffer-file-name
381 tags-table-list
382 t))
383 ;; Since that didn't find any, now do the
384 ;; expensive version: reading new files.
385 (save-excursion (tags-table-including buffer-file-name
386 tags-table-list
387 nil))))
388 ;; Fourth, use the user variable tags-file-name, if it is not
389 ;; already in tags-table-list.
390 (and tags-file-name
391 (not (tags-table-list-member tags-file-name))
392 tags-file-name)
393 ;; Fifth, use the user variable giving the table list.
394 ;; Find the first element of the list that actually exists.
395 (let ((list tags-table-list)
396 file)
397 (while (and list
398 (setq file (tags-expand-table-name (car list)))
399 (not (get-file-buffer file))
400 (not (file-exists-p file)))
401 (setq list (cdr list)))
402 (car list))
403 ;; Finally, prompt the user for a file name.
404 (expand-file-name
405 (read-file-name "Visit tags table: (default TAGS) "
406 default-directory
407 "TAGS"
408 t))))))
409
410 ;; Expand the table name into a full file name.
411 (setq tags-file-name (tags-expand-table-name tags-file-name))
412
413 (if (and (eq cont t) (null tags-table-list-pointer))
414 ;; All out of tables.
415 nil
416 371
417 ;; Verify that tags-file-name is a valid tags table. 372 (t
418 (if (if (get-file-buffer tags-file-name) 373 ;; Pick a table out of our hat.
419 ;; The file is already in a buffer. Check for the visited file 374 (setq tags-file-name
420 ;; having changed since we last used it. 375 (or
421 (let (win) 376 ;; First, try a local variable.
422 (set-buffer (get-file-buffer tags-file-name)) 377 (cdr (assq 'tags-file-name (buffer-local-variables)))
423 (setq win (or verify-tags-table-function 378 ;; Second, try a user-specified function to guess.
424 (initialize-new-tags-table))) 379 (and default-tags-table-function
425 (if (or (verify-visited-file-modtime (current-buffer)) 380 (funcall default-tags-table-function))
426 (not (yes-or-no-p 381 ;; Third, look for a tags table that contains
427 "Tags file has changed, read new contents? "))) 382 ;; tags for the current buffer's file.
428 (and win (funcall verify-tags-table-function)) 383 ;; If one is found, the lists will be frobnicated,
429 (revert-buffer t t) 384 ;; and VISIT-TAGS-TABLE-BUFFER-CONT
430 (initialize-new-tags-table))) 385 ;; will be set non-nil so we don't do it below.
431 (set-buffer (find-file-noselect tags-file-name)) 386 (car (or
432 (or (string= tags-file-name buffer-file-name) 387 ;; First check only tables already in buffers.
433 ;; find-file-noselect has changed the file name. 388 (save-excursion (tags-table-including buffer-file-name
434 ;; Propagate the change to tags-file-name and tags-table-list. 389 tags-table-list
435 (let ((tail (member tags-file-name tags-table-list))) 390 t))
436 (if tail 391 ;; Since that didn't find any, now do the
437 (setcar tail buffer-file-name)) 392 ;; expensive version: reading new files.
438 (setq tags-file-name buffer-file-name))) 393 (save-excursion (tags-table-including buffer-file-name
439 (initialize-new-tags-table)) 394 tags-table-list
440 395 nil))))
441 ;; We have a valid tags table. 396 ;; Fourth, use the user variable tags-file-name, if it is not
442 (progn 397 ;; already in tags-table-list.
443 ;; Bury the tags table buffer so it 398 (and tags-file-name
444 ;; doesn't get in the user's way. 399 (not (tags-table-list-member tags-file-name))
445 (bury-buffer (current-buffer)) 400 tags-file-name)
446 401 ;; Fifth, use the user variable giving the table list.
447 (if cont 402 ;; Find the first element of the list that actually exists.
448 ;; No list frobbing required. 403 (let ((list tags-table-list)
449 nil 404 file)
450 405 (while (and list
451 ;; Look in the list for the table we chose. 406 (setq file (tags-expand-table-name (car list)))
452 (let ((elt (tags-table-list-member tags-file-name))) 407 (not (get-file-buffer file))
453 (or elt 408 (not (file-exists-p file)))
454 ;; The table is not in the current set. 409 (setq list (cdr list)))
455 ;; Try to find it in another previously used set. 410 (car list))
456 (let ((sets tags-table-set-list)) 411 ;; Finally, prompt the user for a file name.
457 (while (and sets 412 (expand-file-name
458 (not (setq elt (tags-table-list-member 413 (read-file-name "Visit tags table: (default TAGS) "
459 tags-file-name (car sets))))) 414 default-directory
460 (setq sets (cdr sets))) 415 "TAGS"
461 (if sets 416 t))))))
462 ;; Found in some other set. Switch to that set. 417
463 (progn 418 ;; Expand the table name into a full file name.
419 (setq tags-file-name (tags-expand-table-name tags-file-name))
420
421 (if (and (eq visit-tags-table-buffer-cont t) (null tags-table-list-pointer))
422 ;; All out of tables.
423 nil
424
425 ;; Verify that tags-file-name is a valid tags table.
426 (if (if (get-file-buffer tags-file-name)
427 ;; The file is already in a buffer. Check for the visited file
428 ;; having changed since we last used it.
429 (let (win)
430 (set-buffer (get-file-buffer tags-file-name))
431 (setq win (or verify-tags-table-function
432 (initialize-new-tags-table)))
433 (if (or (verify-visited-file-modtime (current-buffer))
434 (not (yes-or-no-p
435 "Tags file has changed, read new contents? ")))
436 (and win (funcall verify-tags-table-function))
437 (revert-buffer t t)
438 (initialize-new-tags-table)))
439 (set-buffer (find-file-noselect tags-file-name))
440 (or (string= tags-file-name buffer-file-name)
441 ;; find-file-noselect has changed the file name.
442 ;; Propagate the change to tags-file-name and tags-table-list.
443 (let ((tail (member tags-file-name tags-table-list)))
444 (if tail
445 (setcar tail buffer-file-name))
446 (setq tags-file-name buffer-file-name)))
447 (initialize-new-tags-table))
448
449 ;; We have a valid tags table.
450 (progn
451 ;; Bury the tags table buffer so it
452 ;; doesn't get in the user's way.
453 (bury-buffer (current-buffer))
454
455 (if visit-tags-table-buffer-cont
456 ;; No list frobbing required.
457 nil
458
459 ;; Look in the list for the table we chose.
460 (let ((elt (tags-table-list-member tags-file-name)))
461 (or elt
462 ;; The table is not in the current set.
463 ;; Try to find it in another previously used set.
464 (let ((sets tags-table-set-list))
465 (while (and sets
466 (not (setq elt (tags-table-list-member
467 tags-file-name (car sets)))))
468 (setq sets (cdr sets)))
469 (if sets
470 ;; Found in some other set. Switch to that set.
471 (progn
472 (or (memq tags-table-list tags-table-set-list)
473 ;; Save the current list.
474 (setq tags-table-set-list
475 (cons tags-table-list
476 tags-table-set-list)))
477 (setq tags-table-list (car sets)))
478
479 ;; Not found in any existing set.
480 (if (and tags-table-list
481 (y-or-n-p (concat "Add " tags-file-name
482 " to current list"
483 " of tags tables? ")))
484 ;; Add it to the current list.
485 (setq tags-table-list (cons tags-file-name
486 tags-table-list))
487 ;; Make a fresh list, and store the old one.
464 (or (memq tags-table-list tags-table-set-list) 488 (or (memq tags-table-list tags-table-set-list)
465 ;; Save the current list.
466 (setq tags-table-set-list 489 (setq tags-table-set-list
467 (cons tags-table-list 490 (cons tags-table-list tags-table-set-list)))
468 tags-table-set-list))) 491 (setq tags-table-list (list tags-file-name)))
469 (setq tags-table-list (car sets))) 492 (setq elt tags-table-list))))
470 493
471 ;; Not found in any existing set. 494 ;; Set the tags table list state variables to point at the table
472 (if (and tags-table-list 495 ;; we want to use first.
473 (y-or-n-p (concat "Add " tags-file-name 496 (setq tags-table-list-started-at elt
474 " to current list" 497 tags-table-list-pointer elt)))
475 " of tags tables? "))) 498
476 ;; Add it to the current list. 499 ;; Return of t says the tags table is valid.
477 (setq tags-table-list (cons tags-file-name 500 t)
478 tags-table-list)) 501
479 ;; Make a fresh list, and store the old one. 502 ;; The buffer was not valid. Don't use it again.
480 (or (memq tags-table-list tags-table-set-list) 503 (let ((file tags-file-name))
481 (setq tags-table-set-list 504 (kill-local-variable 'tags-file-name)
482 (cons tags-table-list tags-table-set-list))) 505 (if (eq file tags-file-name)
483 (setq tags-table-list (list tags-file-name))) 506 (setq tags-file-name nil)))
484 (setq elt tags-table-list)))) 507 (error "File %s is not a valid tags table" buffer-file-name)))))
485
486 ;; Set the tags table list state variables to point at the table
487 ;; we want to use first.
488 (setq tags-table-list-started-at elt
489 tags-table-list-pointer elt)))
490
491 ;; Return of t says the tags table is valid.
492 t)
493
494 ;; The buffer was not valid. Don't use it again.
495 (let ((file tags-file-name))
496 (kill-local-variable 'tags-file-name)
497 (if (eq file tags-file-name)
498 (setq tags-file-name nil)))
499 (error "File %s is not a valid tags table" buffer-file-name))))
500 508
501(defun file-of-tag () 509(defun file-of-tag ()
502 "Return the file name of the file whose tags point is within. 510 "Return the file name of the file whose tags point is within.