Subject: Re: bug#52734: 28.0.90; [PATCH] xref-backend-definitions in etags.el duplicates list

From: Dmitry Gutov <[email-masked]>
Date: Fri, 24 Dec 2021 02:27:45 +0200

Hi Eli,

On 23.12.2021 12:12, Eli Zaretskii wrote:
> Dmitry, any comments?  The patch LGTM, FWIW.

How about the patch below instead?

And I'd like to apply it to emacs-28.

diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index f53b09d9e8..a63c3f3397 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -2084,14 +2084,15 @@ xref-backend-definitions
          (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
+            (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))