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. In this regard, xref--goto-char does the right thing: (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). Now I fixed goto-line to use the same condition as in xref--goto-char (and (<= (point-min) p) (<= p (point-max))) to widen only when the found position is outside accessible part of buffer: