applying that 'secure-hash' to the buffer file name. This avoids any
risk of excessively long file names.
+** New variable 'etags-xref-prefer-current-file' to change the order
+of definitions returned by the etags Xref backend.
+
\f
* Changes in Emacs 28.1 on Non-Free Operating Systems
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 to show the matches in the current file first."
+ :type 'boolean
+ :version "28.1")
+
;;;###autoload
(defun etags--xref-backend () 'etags)
(find-tag--completion-ignore-case))
(cl-defmethod xref-backend-definitions ((_backend (eql 'etags)) symbol)
- (etags--xref-find-definitions 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))