-(defun etags-xref-find (action id)
- (pcase action
- (`definitions (etags--xref-find-definitions id))
- (`references
- (let ((dirs (if tags-table-list
- (mapcar #'file-name-directory tags-table-list)
- ;; If no tags files are loaded, prompt for the dir.
- (list (read-directory-name "In directory: " nil nil t)))))
- (cl-mapcan
- (lambda (dir)
- (xref-collect-references id dir))
- dirs)))
- (`apropos (etags--xref-find-definitions id t))))
+(defun etags--xref-backend () 'etags)
+
+(cl-defmethod xref-backend-identifier-at-point ((_backend (eql etags)))
+ (find-tag--default))
+
+(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql etags)))
+ (tags-lazy-completion-table))
+
+(cl-defmethod xref-backend-definitions ((_backend (eql etags)) symbol)
+ (etags--xref-find-definitions symbol))
+
+(cl-defmethod xref-backend-apropos ((_backend (eql etags)) symbol)
+ (etags--xref-find-definitions symbol t))