Mercurial > emacs
comparison lisp/progmodes/etags.el @ 7287:0e89007c19c6
(visit-tags-tbale-buffer): If CONT is stringp, use it for tags-file-name.
Don't bother calling tags-table-including when buffer-file-name is nil.
(visit-tags-table): Signal error FILE is not stringp.
Call visit-tags-table-buffer with FILE instead of 'same.
(tags-next-table): When restoring state vars, set tags-file-name too.
author | Roland McGrath <roland@gnu.org> |
---|---|
date | Tue, 03 May 1994 00:26:48 +0000 |
parents | 87be9630459d |
children | 202339c81fa4 |
comparison
equal
deleted
inserted
replaced
7286:15bf025e8f8c | 7287:0e89007c19c6 |
---|---|
182 default-directory | 182 default-directory |
183 (expand-file-name "TAGS" | 183 (expand-file-name "TAGS" |
184 default-directory) | 184 default-directory) |
185 t) | 185 t) |
186 current-prefix-arg)) | 186 current-prefix-arg)) |
187 ;; Calling visit-tags-table-buffer with tags-file-name set to FILE will | 187 (or (stringp file) (signal 'wrong-type-argument (list 'stringp file))) |
188 ;; initialize a buffer for FILE and set tags-file-name to the | 188 ;; Bind tags-file-name so we can control below whether the local or |
189 ;; global value gets set. Calling visit-tags-table-buffer will | |
190 ;; initialize a buffer for the file and set tags-file-name to the | |
189 ;; fully-expanded name. | 191 ;; fully-expanded name. |
190 (let ((tags-file-name file)) | 192 (let ((tags-file-name file)) |
191 (save-excursion | 193 (save-excursion |
192 (or (visit-tags-table-buffer 'same) | 194 (or (visit-tags-table-buffer file) |
193 (signal 'file-error (list "Visiting tags table" | 195 (signal 'file-error (list "Visiting tags table" |
194 "file does not exist" | 196 "file does not exist" |
195 file))) | 197 file))) |
196 ;; Set FILE to the expanded name. | 198 ;; Set FILE to the expanded name. |
197 (setq file tags-file-name))) | 199 (setq file tags-file-name))) |
235 ;; Pop back to the tags table which includes this one. | 237 ;; Pop back to the tags table which includes this one. |
236 (progn | 238 (progn |
237 ;; Restore the state variables. | 239 ;; Restore the state variables. |
238 (setq tags-table-list | 240 (setq tags-table-list |
239 (nth 0 (car tags-table-parent-pointer-list)) | 241 (nth 0 (car tags-table-parent-pointer-list)) |
242 tags-file-name (car tags-table-list) | |
240 tags-table-list-pointer | 243 tags-table-list-pointer |
241 (nth 1 (car tags-table-parent-pointer-list)) | 244 (nth 1 (car tags-table-parent-pointer-list)) |
242 tags-table-list-started-at | 245 tags-table-list-started-at |
243 (nth 2 (car tags-table-parent-pointer-list)) | 246 (nth 2 (car tags-table-parent-pointer-list)) |
244 tags-table-parent-pointer-list | 247 tags-table-parent-pointer-list |
409 (setq tables (cdr tables))) | 412 (setq tables (cdr tables))) |
410 found)) | 413 found)) |
411 | 414 |
412 (defun visit-tags-table-buffer (&optional cont) | 415 (defun visit-tags-table-buffer (&optional cont) |
413 "Select the buffer containing the current tags table. | 416 "Select the buffer containing the current tags table. |
417 If optional arg is a string, visit that file as a tags table. | |
414 If optional arg is t, visit the next table in `tags-table-list'. | 418 If optional arg is t, visit the next table in `tags-table-list'. |
415 If optional arg is the atom `same', don't look for a new table; | 419 If optional arg is the atom `same', don't look for a new table; |
416 just select the buffer visiting `tags-file-name'. | 420 just select the buffer visiting `tags-file-name'. |
417 If arg is nil or absent, choose a first buffer from information in | 421 If arg is nil or absent, choose a first buffer from information in |
418 `tags-file-name', `tags-table-list', `tags-table-list-pointer'. | 422 `tags-file-name', `tags-table-list', `tags-table-list-pointer'. |
425 (or tags-file-name | 429 (or tags-file-name |
426 (error (substitute-command-keys | 430 (error (substitute-command-keys |
427 (concat "No tags table in use! " | 431 (concat "No tags table in use! " |
428 "Use \\[visit-tags-table] to select one."))))) | 432 "Use \\[visit-tags-table] to select one."))))) |
429 | 433 |
430 (visit-tags-table-buffer-cont | 434 ((eq t visit-tags-table-buffer-cont) |
431 ;; Find the next table. | 435 ;; Find the next table. |
432 (if (tags-next-table) | 436 (if (tags-next-table) |
433 ;; Skip over nonexistent files. | 437 ;; Skip over nonexistent files. |
434 (let (file) | 438 (let (file) |
435 (while (and (setq file | 439 (while (and (setq file |
449 (tags-next-table)) | 453 (tags-next-table)) |
450 | 454 |
451 ;; Pick a table out of our hat. | 455 ;; Pick a table out of our hat. |
452 (setq tags-file-name | 456 (setq tags-file-name |
453 (or | 457 (or |
458 ;; If passed a string, use that. | |
459 (if (stringp visit-tags-table-buffer-cont) | |
460 (prog1 visit-tags-table-buffer-cont | |
461 (setq visit-tags-table-buffer-cont nil))) | |
454 ;; First, try a local variable. | 462 ;; First, try a local variable. |
455 (cdr (assq 'tags-file-name (buffer-local-variables))) | 463 (cdr (assq 'tags-file-name (buffer-local-variables))) |
456 ;; Second, try a user-specified function to guess. | 464 ;; Second, try a user-specified function to guess. |
457 (and default-tags-table-function | 465 (and default-tags-table-function |
458 (funcall default-tags-table-function)) | 466 (funcall default-tags-table-function)) |
459 ;; Third, look for a tags table that contains | 467 ;; Third, look for a tags table that contains |
460 ;; tags for the current buffer's file. | 468 ;; tags for the current buffer's file. |
461 ;; If one is found, the lists will be frobnicated, | 469 ;; If one is found, the lists will be frobnicated, |
462 ;; and VISIT-TAGS-TABLE-BUFFER-CONT | 470 ;; and VISIT-TAGS-TABLE-BUFFER-CONT |
463 ;; will be set non-nil so we don't do it below. | 471 ;; will be set non-nil so we don't do it below. |
464 (car (or | 472 (and buffer-file-name |
465 ;; First check only tables already in buffers. | 473 (car (or |
466 (save-excursion (tags-table-including buffer-file-name | 474 ;; First check only tables already in buffers. |
467 tags-table-list | 475 (save-excursion |
468 t)) | 476 (tags-table-including buffer-file-name |
469 ;; Since that didn't find any, now do the | 477 tags-table-list |
470 ;; expensive version: reading new files. | 478 t)) |
471 (save-excursion (tags-table-including buffer-file-name | 479 ;; Since that didn't find any, now do the |
472 tags-table-list | 480 ;; expensive version: reading new files. |
473 nil)))) | 481 (save-excursion |
482 (tags-table-including buffer-file-name | |
483 tags-table-list | |
484 nil))))) | |
474 ;; Fourth, use the user variable tags-file-name, if it is | 485 ;; Fourth, use the user variable tags-file-name, if it is |
475 ;; not already in tags-table-list. | 486 ;; not already in tags-table-list. |
476 (and tags-file-name | 487 (and tags-file-name |
477 (not (tags-find-table-in-list tags-file-name nil)) | 488 (not (tags-find-table-in-list tags-file-name nil)) |
478 tags-file-name) | 489 tags-file-name) |