|
From: | Dmitry Gutov |
Subject: | bug#44294: No widen by xref-find-definitions |
Date: | Thu, 29 Oct 2020 23:33:44 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
On 29.10.2020 23:18, Juri Linkov wrote:
reopen 44294 stop- (user-error "Rerun etags: `%s' not found in %s" - pat buffer-file-name))) + (if (or (= (point-min) 1) (not widen-automatically)) + (user-error "Rerun etags: `%s' not found in %s" + pat buffer-file-name) + ;; Rerun after removing narrowing + (widen) + (etags-goto-tag-location tag-info))))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.
In this regard, xref--goto-char does the right thing:
Yes.
(defun xref--goto-char (pos) (cond ((and (<= (point-min) pos) (<= pos (point-max)))) (widen-automatically (widen)) (t (user-error "Position is outside accessible part of buffer"))) (goto-char pos)) It widens only when position is outside accessible part of buffer (and widen-automatically is non-nil).
And this code runs whether the backend is elisp, etags, or whatever else.
[Prev in Thread] | Current Thread | [Next in Thread] |