Mercurial > emacs
comparison lisp/progmodes/etags.el @ 95579:bf49392d93fe
(tags-verify-table): Be careful to use and update
tags-file-name and tags-table-list from the right buffer.
(tags-table-check-computed-list, tags-table-extend-computed-list)
(find-tag-noselect): Use with-current-buffer.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 05 Jun 2008 05:55:37 +0000 |
parents | 52b7a8c22af5 |
children | c94868f48d3d |
comparison
equal
deleted
inserted
replaced
95578:73464776c892 | 95579:bf49392d93fe |
---|---|
299 default-directory) | 299 default-directory) |
300 t) | 300 t) |
301 current-prefix-arg)) | 301 current-prefix-arg)) |
302 (or (stringp file) (signal 'wrong-type-argument (list 'stringp file))) | 302 (or (stringp file) (signal 'wrong-type-argument (list 'stringp file))) |
303 ;; Bind tags-file-name so we can control below whether the local or | 303 ;; Bind tags-file-name so we can control below whether the local or |
304 ;; global value gets set. Calling visit-tags-table-buffer will | 304 ;; global value gets set. |
305 ;; initialize a buffer for the file and set tags-file-name to the | |
306 ;; Calling visit-tags-table-buffer with tags-file-name set to FILE will | 305 ;; Calling visit-tags-table-buffer with tags-file-name set to FILE will |
307 ;; initialize a buffer for FILE and set tags-file-name to the | 306 ;; initialize a buffer for FILE and set tags-file-name to the |
308 ;; fully-expanded name. | 307 ;; fully-expanded name. |
309 (let ((tags-file-name file)) | 308 (let ((tags-file-name file)) |
310 (save-excursion | 309 (save-excursion |
336 (if (and table-buffer | 335 (if (and table-buffer |
337 ;; There is a buffer visiting the file. Now make sure | 336 ;; There is a buffer visiting the file. Now make sure |
338 ;; it is initialized as a tag table buffer. | 337 ;; it is initialized as a tag table buffer. |
339 (save-excursion | 338 (save-excursion |
340 (tags-verify-table (buffer-file-name table-buffer)))) | 339 (tags-verify-table (buffer-file-name table-buffer)))) |
341 (save-excursion | 340 (with-current-buffer table-buffer |
342 (set-buffer table-buffer) | |
343 (if (tags-included-tables) | 341 (if (tags-included-tables) |
344 ;; Insert the included tables into the list we | 342 ;; Insert the included tables into the list we |
345 ;; are processing. | 343 ;; are processing. |
346 (setcdr tables (nconc (mapcar 'tags-expand-table-name | 344 (setcdr tables (nconc (mapcar 'tags-expand-table-name |
347 (tags-included-tables)) | 345 (tags-included-tables)) |
376 table-buffer) | 374 table-buffer) |
377 (while tables | 375 (while tables |
378 (setq computed (cons (car tables) computed) | 376 (setq computed (cons (car tables) computed) |
379 table-buffer (get-file-buffer (car tables))) | 377 table-buffer (get-file-buffer (car tables))) |
380 (if table-buffer | 378 (if table-buffer |
381 (save-excursion | 379 (with-current-buffer table-buffer |
382 (set-buffer table-buffer) | |
383 (if (tags-included-tables) | 380 (if (tags-included-tables) |
384 ;; Insert the included tables into the list we | 381 ;; Insert the included tables into the list we |
385 ;; are processing. | 382 ;; are processing. |
386 (setcdr tables (append (tags-included-tables) | 383 (setcdr tables (append (tags-included-tables) |
387 tables)))) | 384 tables)))) |
446 file))))) | 443 file))))) |
447 (and verify-tags-table-function | 444 (and verify-tags-table-function |
448 (funcall verify-tags-table-function)) | 445 (funcall verify-tags-table-function)) |
449 (revert-buffer t t) | 446 (revert-buffer t t) |
450 (tags-table-mode))) | 447 (tags-table-mode))) |
451 (and (file-exists-p file) | 448 (when (file-exists-p file) |
452 (progn | 449 (let* ((buf (find-file-noselect file)) |
453 (set-buffer (find-file-noselect file)) | 450 (newfile (buffer-file-name buf))) |
454 (or (string= file buffer-file-name) | 451 (unless (string= file newfile) |
455 ;; find-file-noselect has changed the file name. | 452 ;; find-file-noselect has changed the file name. |
456 ;; Propagate the change to tags-file-name and tags-table-list. | 453 ;; Propagate the change to tags-file-name and tags-table-list. |
457 (let ((tail (member file tags-table-list))) | 454 (let ((tail (member file tags-table-list))) |
458 (if tail | 455 (if tail (setcar tail newfile))) |
459 (setcar tail buffer-file-name)) | 456 (if (eq file tags-file-name) (setq tags-file-name newfile))) |
460 (if (eq file tags-file-name) | 457 ;; Only change buffer now that we're done using potentially |
461 (setq tags-file-name buffer-file-name)))) | 458 ;; buffer-local variables. |
462 (tags-table-mode))))) | 459 (set-buffer buf) |
460 (tags-table-mode))))) | |
463 | 461 |
464 ;; Subroutine of visit-tags-table-buffer. Search the current tags tables | 462 ;; Subroutine of visit-tags-table-buffer. Search the current tags tables |
465 ;; for one that has tags for THIS-FILE (or that includes a table that | 463 ;; for one that has tags for THIS-FILE (or that includes a table that |
466 ;; does). Return the name of the first table table listing THIS-FILE; if | 464 ;; does). Return the name of the first table table listing THIS-FILE; if |
467 ;; the table is one included by another table, it is the master table that | 465 ;; the table is one included by another table, it is the master table that |
881 (visit-tags-table-buffer) | 879 (visit-tags-table-buffer) |
882 ;; Record TAGNAME for a future call with NEXT-P non-nil. | 880 ;; Record TAGNAME for a future call with NEXT-P non-nil. |
883 (setq last-tag tagname)) | 881 (setq last-tag tagname)) |
884 ;; Record the location so we can pop back to it later. | 882 ;; Record the location so we can pop back to it later. |
885 (let ((marker (make-marker))) | 883 (let ((marker (make-marker))) |
886 (save-excursion | 884 (with-current-buffer |
887 (set-buffer | 885 ;; find-tag-in-order does the real work. |
888 ;; find-tag-in-order does the real work. | 886 (find-tag-in-order |
889 (find-tag-in-order | 887 (if (and next-p last-tag) last-tag tagname) |
890 (if (and next-p last-tag) last-tag tagname) | 888 (if regexp-p |
891 (if regexp-p | 889 find-tag-regexp-search-function |
892 find-tag-regexp-search-function | 890 find-tag-search-function) |
893 find-tag-search-function) | 891 (if regexp-p |
894 (if regexp-p | 892 find-tag-regexp-tag-order |
895 find-tag-regexp-tag-order | 893 find-tag-tag-order) |
896 find-tag-tag-order) | 894 (if regexp-p |
897 (if regexp-p | 895 find-tag-regexp-next-line-after-failure-p |
898 find-tag-regexp-next-line-after-failure-p | 896 find-tag-next-line-after-failure-p) |
899 find-tag-next-line-after-failure-p) | 897 (if regexp-p "matching" "containing") |
900 (if regexp-p "matching" "containing") | 898 (or (not next-p) (not last-tag))) |
901 (or (not next-p) (not last-tag)))) | |
902 (set-marker marker (point)) | 899 (set-marker marker (point)) |
903 (run-hooks 'local-find-tag-hook) | 900 (run-hooks 'local-find-tag-hook) |
904 (ring-insert tags-location-ring marker) | 901 (ring-insert tags-location-ring marker) |
905 (current-buffer)))))) | 902 (current-buffer)))))) |
906 | 903 |
1558 ;; Match qualifier functions for tagnames. | 1555 ;; Match qualifier functions for tagnames. |
1559 ;; These functions assume the etags file format defined in etc/ETAGS.EBNF. | 1556 ;; These functions assume the etags file format defined in etc/ETAGS.EBNF. |
1560 | 1557 |
1561 ;; This might be a neat idea, but it's too hairy at the moment. | 1558 ;; This might be a neat idea, but it's too hairy at the moment. |
1562 ;;(defmacro tags-with-syntax (&rest body) | 1559 ;;(defmacro tags-with-syntax (&rest body) |
1563 ;; `(let ((current (current-buffer)) | 1560 ;; `(with-syntax-table |
1564 ;; (otable (syntax-table)) | 1561 ;; (with-current-buffer (find-file-noselect (file-of-tag)) |
1565 ;; (buffer (find-file-noselect (file-of-tag))) | 1562 ;; (syntax-table)) |
1566 ;; table) | 1563 ;; ,@body)) |
1567 ;; (unwind-protect | |
1568 ;; (progn | |
1569 ;; (set-buffer buffer) | |
1570 ;; (setq table (syntax-table)) | |
1571 ;; (set-buffer current) | |
1572 ;; (set-syntax-table table) | |
1573 ;; ,@body) | |
1574 ;; (set-syntax-table otable)))) | |
1575 ;;(put 'tags-with-syntax 'edebug-form-spec '(&rest form)) | 1564 ;;(put 'tags-with-syntax 'edebug-form-spec '(&rest form)) |
1576 | 1565 |
1577 ;; exact file name match, i.e. searched tag must match complete file | 1566 ;; exact file name match, i.e. searched tag must match complete file |
1578 ;; name including directories parts if there are some. | 1567 ;; name including directories parts if there are some. |
1579 (defun tag-exact-file-name-match-p (tag) | 1568 (defun tag-exact-file-name-match-p (tag) |