diff options
| author | Roland McGrath | 1994-03-08 05:49:24 +0000 |
|---|---|---|
| committer | Roland McGrath | 1994-03-08 05:49:24 +0000 |
| commit | e1dec509bd44a36813ab1b22d9f80a4dfa7606e7 (patch) | |
| tree | 4bcbd1e33a1ed524026bb51a6b369f3887232750 | |
| parent | 362fb47a7c53fa4d440639b18ad3e75d4a5dc4ef (diff) | |
| download | emacs-e1dec509bd44a36813ab1b22d9f80a4dfa7606e7.tar.gz emacs-e1dec509bd44a36813ab1b22d9f80a4dfa7606e7.zip | |
(etags-tags-completion-table): Let the line number or char pos be empty.
(etags-snarf-tag): Look for line number as well as char pos. Let either be
empty; return both.
(etags-goto-tag-location): Arg also contains line number.
If char pos is nil, use line number.
| -rw-r--r-- | lisp/progmodes/etags.el | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el index 969927fbe86..75c949f8555 100644 --- a/lisp/progmodes/etags.el +++ b/lisp/progmodes/etags.el | |||
| @@ -935,7 +935,8 @@ See documentation of variable `tags-file-name'." | |||
| 935 | ;; \7 is the char to start searching at. | 935 | ;; \7 is the char to start searching at. |
| 936 | (while (re-search-forward | 936 | (while (re-search-forward |
| 937 | "^\\(\\(.+[^-a-zA-Z0-9_$]+\\)?\\([-a-zA-Z0-9_$]+\\)\ | 937 | "^\\(\\(.+[^-a-zA-Z0-9_$]+\\)?\\([-a-zA-Z0-9_$]+\\)\ |
| 938 | \[^-a-zA-Z0-9_$]*\\)\177\\(\\([^\n\001]+\\)\001\\)?\\([0-9]+\\),\\([0-9]+\\)\n" | 938 | \[^-a-zA-Z0-9_$]*\\)\177\\(\\([^\n\001]+\\)\001\\)?\ |
| 939 | \\([0-9]+\\)?,\\([0-9]+\\)?\n" | ||
| 939 | nil t) | 940 | nil t) |
| 940 | (intern (if (match-beginning 5) | 941 | (intern (if (match-beginning 5) |
| 941 | ;; There is an explicit tag name. | 942 | ;; There is an explicit tag name. |
| @@ -946,29 +947,36 @@ See documentation of variable `tags-file-name'." | |||
| 946 | table)) | 947 | table)) |
| 947 | 948 | ||
| 948 | (defun etags-snarf-tag () | 949 | (defun etags-snarf-tag () |
| 949 | (let (tag-text startpos) | 950 | (let (tag-text line startpos) |
| 950 | (search-forward "\177") | 951 | (search-forward "\177") |
| 951 | (setq tag-text (buffer-substring (1- (point)) | 952 | (setq tag-text (buffer-substring (1- (point)) |
| 952 | (save-excursion (beginning-of-line) | 953 | (save-excursion (beginning-of-line) |
| 953 | (point)))) | 954 | (point)))) |
| 954 | ;; Skip explicit tag name if present. | 955 | ;; Skip explicit tag name if present. |
| 955 | (search-forward "\001" (save-excursion (forward-line 1) (point)) t) | 956 | (search-forward "\001" (save-excursion (forward-line 1) (point)) t) |
| 956 | (search-forward ",") | 957 | (if (looking-at "[0-9]") |
| 957 | (setq startpos (string-to-int (buffer-substring | 958 | (setq line (string-to-int (buffer-substring |
| 958 | (point) | 959 | (point) |
| 959 | (progn (skip-chars-forward "0-9") | 960 | (progn (skip-chars-forward "0-9") |
| 960 | (point))))) | 961 | (point)))))) |
| 962 | (search-forward ",") | ||
| 963 | (if (looking-at "[0-9]") | ||
| 964 | (setq startpos (string-to-int (buffer-substring | ||
| 965 | (point) | ||
| 966 | (progn (skip-chars-forward "0-9") | ||
| 967 | (point)))))) | ||
| 961 | ;; Leave point on the next line of the tags file. | 968 | ;; Leave point on the next line of the tags file. |
| 962 | (forward-line 1) | 969 | (forward-line 1) |
| 963 | (cons tag-text startpos))) | 970 | (cons tag-text (cons line startpos)))) |
| 964 | 971 | ||
| 965 | ;; TAG-INFO is a cons (TEXT . POSITION) where TEXT is the initial part of a | 972 | ;; TAG-INFO is a cons (TEXT LINE . POSITION) where TEXT is the initial part |
| 966 | ;; line containing the tag and POSITION is the character position of TEXT | 973 | ;; of a line containing the tag and POSITION is the character position of |
| 967 | ;; within the file (starting from 1). If the tag isn't exactly at the | 974 | ;; TEXT within the file (starting from 1); LINE is the line number. Either |
| 968 | ;; given position then look around that position using a search window | 975 | ;; LINE or POSITION may be nil; POSITION is used if present. If the tag |
| 969 | ;; which expands until it hits the start of file. | 976 | ;; isn't exactly at the given position then look around that position using |
| 977 | ;; a search window which expands until it hits the start of file. | ||
| 970 | (defun etags-goto-tag-location (tag-info) | 978 | (defun etags-goto-tag-location (tag-info) |
| 971 | (let ((startpos (cdr tag-info)) | 979 | (let ((startpos (cdr (cdr tag-info))) |
| 972 | ;; This constant is 1/2 the initial search window. | 980 | ;; This constant is 1/2 the initial search window. |
| 973 | ;; There is no sense in making it too small, | 981 | ;; There is no sense in making it too small, |
| 974 | ;; since just going around the loop once probably | 982 | ;; since just going around the loop once probably |
| @@ -978,6 +986,11 @@ See documentation of variable `tags-file-name'." | |||
| 978 | (pat (concat (if (eq selective-display t) | 986 | (pat (concat (if (eq selective-display t) |
| 979 | "\\(^\\|\^m\\)" "^") | 987 | "\\(^\\|\^m\\)" "^") |
| 980 | (regexp-quote (car tag-info))))) | 988 | (regexp-quote (car tag-info))))) |
| 989 | ;; If no char pos was given, try the given line number. | ||
| 990 | (or startpos | ||
| 991 | (if (car (cdr tag-info)) | ||
| 992 | (setq startpos (progn (goto-line (car (cdr tag-info))) | ||
| 993 | (point))))) | ||
| 981 | (or startpos | 994 | (or startpos |
| 982 | (setq startpos (point-min))) | 995 | (setq startpos (point-min))) |
| 983 | ;; First see if the tag is right at the specified location. | 996 | ;; First see if the tag is right at the specified location. |