Subject: bug#78489: 30.1.50; Using etags, Ada and xref-find-definitions doesn't find definitions

From: Troy Brown <[email-masked]>
Date: Mon, 26 May 2025 22:28:22 -0400

On Mon, May 26, 2025 at 4:13 PM Troy Brown <[email-masked]> wrote:
>
> In the testing I've done, this patch works correctly and addresses the
> original problem reported.  However, as I explored this a bit further
> I discovered another issue that involves completion.  After typing
> 'Displ' and then `M-x completion-at-point`, the tag including the
> suffix is completed (i.e., "Display_Message/p" is inserted into the
> buffer, instead of just "Display_Message").

I found a spot in `etags-tags-completion-table` that needed
adjustment.  After this fix, the completion works as expected too.

diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index 352356ddbc5..41b61dc0763 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -1288,7 +1288,7 @@ etags-tags-completion-table
       ;; This regexp matches an explicit tag name or the place where
       ;; it would start.
       (while (re-search-forward
-              "[\f\t\n\r()=,; ]?\177\\(?:\\([^\n\001]+\\)\001\\)?"
+              "[\f\t\n\r()=,;
]?\177\\(?:\\([^\n\001]+?\\)\\(/[fpsbtk]\\)?\001\\)?"
              nil t)
        (push   (prog1 (if (match-beginning 1)
                           ;; There is an explicit tag name.
@@ -1645,7 +1645,10 @@ tag-exact-match-p
   (or (and (eq (char-after (point)) ?\001)
           (eq (char-after (- (point) (length tag) 1)) ?\177))
       ;; We are not on the explicit tag name, but perhaps it follows.
-      (looking-at (concat "[^\177\n]*\177" (regexp-quote tag) "\001"))))
+      (looking-at (concat "[^\177\n]*\177"
+                          (regexp-quote tag)
+                          ;; The optional "/x" part is for Ada tags.
+                          "\\(/[fpsbtk]\\)?\001"))))

 ;; t if point is at a tag line that has an implicit name.
 ;; point should be just after a string that matches TAG.