diff options
Diffstat (limited to 'lisp/progmodes/etags.el')
-rw-r--r-- | lisp/progmodes/etags.el | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el index 869529ab2db..a1f806ae8c9 100644 --- a/lisp/progmodes/etags.el +++ b/lisp/progmodes/etags.el @@ -836,11 +836,7 @@ If no tags table is loaded, do nothing and return nil." "Read a tag name, with defaulting and completion." (let* ((completion-ignore-case (find-tag--completion-ignore-case)) (default (find-tag--default)) - (spec (completing-read (if default - (format "%s (default %s): " - (substring string 0 (string-match "[ :]+\\'" string)) - default) - string) + (spec (completing-read (format-prompt string default) (tags-lazy-completion-table) nil nil nil nil default))) (if (equal spec "") @@ -899,7 +895,7 @@ onto a ring and may be popped back to with \\[pop-tag-mark]. Contrast this with the ring of marks gone to by the command. See documentation of variable `tags-file-name'." - (interactive (find-tag-interactive "Find tag: ")) + (interactive (find-tag-interactive "Find tag")) (setq find-tag-history (cons tagname find-tag-history)) ;; Save the current buffer's value of `find-tag-hook' before @@ -971,7 +967,7 @@ Contrast this with the ring of marks gone to by the command. See documentation of variable `tags-file-name'." (declare (obsolete xref-find-definitions "25.1")) - (interactive (find-tag-interactive "Find tag: ")) + (interactive (find-tag-interactive "Find tag")) (let* ((buf (find-tag-noselect tagname next-p regexp-p)) (pos (with-current-buffer buf (point)))) (condition-case nil @@ -1000,7 +996,7 @@ Contrast this with the ring of marks gone to by the command. See documentation of variable `tags-file-name'." (declare (obsolete xref-find-definitions-other-window "25.1")) - (interactive (find-tag-interactive "Find tag other window: ")) + (interactive (find-tag-interactive "Find tag other window")) ;; This hair is to deal with the case where the tag is found in the ;; selected window's buffer; without the hair, point is moved in both @@ -1041,7 +1037,7 @@ Contrast this with the ring of marks gone to by the command. See documentation of variable `tags-file-name'." (declare (obsolete xref-find-definitions-other-frame "25.1")) - (interactive (find-tag-interactive "Find tag other frame: ")) + (interactive (find-tag-interactive "Find tag other frame")) (let ((pop-up-frames t)) (with-suppressed-warnings ((obsolete find-tag-other-window)) (find-tag-other-window tagname next-p)))) @@ -1065,7 +1061,7 @@ Contrast this with the ring of marks gone to by the command. See documentation of variable `tags-file-name'." (declare (obsolete xref-find-apropos "25.1")) - (interactive (find-tag-interactive "Find tag regexp: " t)) + (interactive (find-tag-interactive "Find tag regexp" t)) ;; We go through find-tag-other-window to do all the display hair there. (funcall (if other-window 'find-tag-other-window 'find-tag) regexp next-p t)) @@ -1604,11 +1600,11 @@ that do nothing." ;; This might be a neat idea, but it's too hairy at the moment. ;;(defmacro tags-with-syntax (&rest body) +;; (declare (debug t)) ;; `(with-syntax-table ;; (with-current-buffer (find-file-noselect (file-of-tag)) ;; (syntax-table)) ;; ,@body)) -;;(put 'tags-with-syntax 'edebug-form-spec '(&rest form)) ;; exact file name match, i.e. searched tag must match complete file ;; name including directories parts if there are some. @@ -1812,7 +1808,7 @@ argument is passed to `next-file', which see)." (defun tags-search (regexp &optional files) "Search through all files listed in tags table for match for REGEXP. Stops when a match is found. -To continue searching for next match, use command \\[tags-loop-continue]. +To continue searching for next match, use the command \\[fileloop-continue]. If FILES if non-nil should be a list or an iterator returning the files to search. The search will be restricted to these files. @@ -1838,7 +1834,7 @@ Also see the documentation of the `tags-file-name' variable." "Do `query-replace-regexp' of FROM with TO on all files listed in tags table. Third arg DELIMITED (prefix arg) means replace only word-delimited matches. If you exit (\\[keyboard-quit], RET or q), you can resume the query replace -with the command \\[tags-loop-continue]. +with the command \\[fileloop-continue]. For non-interactive use, superseded by `fileloop-initialize-replace'." (declare (advertised-calling-convention (from to &optional delimited) "27.1")) (interactive (query-replace-read-args "Tags query replace (regexp)" t t)) @@ -2063,22 +2059,43 @@ for \\[find-tag] (which see)." If you want `xref-find-definitions' to find the tagged files by their file name, add `tag-partial-file-name-match-p' to the list value.") +(defcustom etags-xref-prefer-current-file nil + "Non-nil means show the matches in the current file first." + :type 'boolean + :version "28.1") + ;;;###autoload (defun etags--xref-backend () 'etags) -(cl-defmethod xref-backend-identifier-at-point ((_backend (eql etags))) +(cl-defmethod xref-backend-identifier-at-point ((_backend (eql 'etags))) (find-tag--default)) -(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql etags))) +(cl-defmethod xref-backend-identifier-completion-table ((_backend + (eql 'etags))) (tags-lazy-completion-table)) -(cl-defmethod xref-backend-identifier-completion-ignore-case ((_backend (eql etags))) +(cl-defmethod xref-backend-identifier-completion-ignore-case ((_backend + (eql 'etags))) (find-tag--completion-ignore-case)) -(cl-defmethod xref-backend-definitions ((_backend (eql etags)) symbol) - (etags--xref-find-definitions symbol)) - -(cl-defmethod xref-backend-apropos ((_backend (eql etags)) pattern) +(cl-defmethod xref-backend-definitions ((_backend (eql 'etags)) symbol) + (let ((file (and buffer-file-name (expand-file-name buffer-file-name))) + (definitions (etags--xref-find-definitions symbol)) + same-file-definitions) + (when (and etags-xref-prefer-current-file file) + (cl-delete-if + (lambda (definition) + (when (equal file + (xref-location-group + (xref-item-location definition))) + (push definition same-file-definitions) + t)) + definitions) + (setq definitions (nconc (nreverse same-file-definitions) + definitions))) + definitions)) + +(cl-defmethod xref-backend-apropos ((_backend (eql 'etags)) pattern) (etags--xref-find-definitions (xref-apropos-regexp pattern) t)) (defun etags--xref-find-definitions (pattern &optional regexp?) |