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

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

bug#44294: No widen by xref-find-definitions


From: Juri Linkov
Subject: bug#44294: No widen by xref-find-definitions
Date: Fri, 30 Oct 2020 09:38:24 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>>> By the way... have you tried to use the same method here as in elisp-mode?
>>> Meaning, widen unconditionally inside 'save-restriction'.
>>>
>>> There should be no reason for backends to do it differently. And this way,
>>> you don't have to always search twice for a missing tag when inside
>>> a narrowing.
>> It should not widen unnecessarily when the found position is within the
>> narrowed region.
>
> Hence the use of save-restriction in elisp-mode which you added.
>
> etags can use the exact same approach.

I see now what you mean.  Then maybe better to revert the change in
etags-goto-tag-location to restore its original behavior, and
fix only its usage by xref, i.e. exactly the same change
for xref-location-marker ((l xref-etags-location)) as was made
for xref-location-marker ((l xref-elisp-location)):

diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index 41ed317766..8879726ad5 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -2140,8 +2135,10 @@ xref-location-marker
     (let ((buffer (find-file-noselect file)))
       (with-current-buffer buffer
         (save-excursion
-          (etags-goto-tag-location tag-info)
-          (point-marker))))))
+          (save-restriction
+            (widen)
+            (etags-goto-tag-location tag-info)
+            (point-marker)))))))
 
 (cl-defmethod xref-location-line ((l xref-etags-location))
   (with-slots (tag-info) l





reply via email to

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