bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#32510: acknowledged by developer (control message for bug #32510)


From: Dmitry Gutov
Subject: bug#32510: acknowledged by developer (control message for bug #32510)
Date: Tue, 30 Jul 2019 03:06:18 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2

On 14.07.2019 8:21, Eli Zaretskii wrote:
From: Ludovic Brenta <address@hidden>
Date: Sat, 13 Jul 2019 21:34:26 +0200

This bug report states that a useful functionality of find-tag is *not*
provided by its official replacement, xref-find-definitions.  This is a
regression.  Just because you think this missing functionality should be
provided elsewhere is not a good reason to close this bug without
providing any solution.

With the patch below, you should be able to have what you want if you
add tag-partial-file-name-match-p to the list in

Finally got around to reviewing it...

diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index 7bf5753..b092c63 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -2070,13 +2070,16 @@ etags--xref-find-definitions
                (beginning-of-line)
                (pcase-let* ((tag-info (etags-snarf-tag))
                             (`(,hint ,line . _) tag-info))
-                (unless (eq hint t) ; hint==t if we are in a filename line
+                (unless (and (eq hint t) ; we are in a filename line
+                             (not (eq order-fun
+                                      'tag-partial-file-name-match-p)))

First, I was thinking we shouldn't check for the exact order-fun value (because others could be used, too) and replace it with something like

                              (save-excursion
                               (forward-line 0)
                               (forward-char -2)
                               (not (looking-at "\f\n")))

But then, I'm not sure why that check is there in the first place (the order functions make sure not to match the wrong like). Maybe because the code inside couldn't handle hint=t? So if it does now, the (unless ...) conditional can be removed.

                    (let* ((file (file-of-tag))
                           (mark-key (cons file line)))
                      (unless (gethash mark-key marks)
                        (let ((loc (xref-make-etags-location
                                    tag-info (expand-file-name file))))
-                        (push (xref-make hint loc) xrefs)
+                        (push (xref-make (if (eq hint t) pattern hint) loc)
+                               xrefs)

I'm not sure using pattern as a hint works well. How about we say something like "(file name match)" instead? Or you could pick a better wording. The full proposed patch is below.

I see that it doesn't work exactly perfectly, e.g. moving point within the quotes in

  #include "composite.h"

and pressing M-. brings up three matches (composite.c, composite.h and composite.el), whereas only one of them is correct, but find-tag probably has the same problem anyway. Maybe CC Mode should set up find-tag-default-function to return the full file name when inside #include statements.

diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index 7bf575340e..a052ad2ce5 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -2070,14 +2070,15 @@ etags--xref-find-definitions
               (beginning-of-line)
               (pcase-let* ((tag-info (etags-snarf-tag))
                            (`(,hint ,line . _) tag-info))
-                (unless (eq hint t) ; hint==t if we are in a filename line
-                  (let* ((file (file-of-tag))
-                         (mark-key (cons file line)))
-                    (unless (gethash mark-key marks)
-                      (let ((loc (xref-make-etags-location
-                                  tag-info (expand-file-name file))))
-                        (push (xref-make hint loc) xrefs)
-                        (puthash mark-key t marks)))))))))))
+                (let* ((file (file-of-tag))
+                       (mark-key (cons file line)))
+                  (unless (gethash mark-key marks)
+                    (let ((loc (xref-make-etags-location
+                                tag-info (expand-file-name file))))
+ (push (xref-make (if (eq hint t) "(filename match)" hint)
+                                       loc)
+                            xrefs)
+                      (puthash mark-key t marks))))))))))
     (nreverse xrefs)))

 (defclass xref-etags-location (xref-location)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]