Hi Paul, "Paul D. Nelson" <[email protected]> writes:
> I noticed that error navigation (via 'C-c `') does not work correctly in > narrowed buffers. > > The main issue is that in a buffer where the current restriction omits N > lines at the top, 'C-c `' moves to N lines beyond where it should, due > to the difference between relative and absolute line numbers. > > A secondary issue is that 'C-c `' does not navigate to errors outside > the current restriction. > > The patch addresses both in the expected way. For the secondary issue, > it made sense to widen when jumping to errors outside the current > restriction because this behavior mirrors that of similar commands in > Emacs (e.g., grep + next-error). > > Any feedback welcome. Thanks, I think your suggestion makes sense. I have only one comment below. > From ddab8605baefada76c52d8cc89718901fea4e213 Mon Sep 17 00:00:00 2001 > From: Paul Nelson <[email protected]> > Date: Tue, 2 Dec 2025 06:06:53 +0100 > Subject: [PATCH] Fix navigation to errors in narrowed buffers > > * tex.el (TeX-find-display-help): When searching for errors, > widen temporarily. If the error lies outside the current > restriction, then widen to make the error visible before > navigating to it. > --- > tex.el | 55 +++++++++++++++++++++++++++++++++++-------------------- > 1 file changed, 35 insertions(+), 20 deletions(-) > > diff --git a/tex.el b/tex.el > index 7c14a135..8560a1fb 100644 > --- a/tex.el > +++ b/tex.el > @@ -9788,26 +9788,41 @@ value is not used here." > (setq-local TeX-command-buffer command-buffer) > > ;; Find the location of the error or warning. > - (when TeX-translate-location-line > - (goto-char (point-min)) > - (forward-line (+ TeX-translate-location-offset > - TeX-translate-location-line -1)) > - (cond > - ;; Error. > - ((equal type 'error) > - (if (not (string= TeX-translate-location-string " ")) > - (search-forward TeX-translate-location-string nil t))) > - ;; Warning or bad box. > - (t > - (beginning-of-line 0) > - (setq start (point)) > - (goto-char (point-min)) > - (forward-line (+ TeX-translate-location-offset > - line-end -1)) > - (end-of-line) > - (when TeX-translate-location-string > - (search-backward TeX-translate-location-string start t) > - (search-forward TeX-translate-location-string nil t)))))) > + (let ((narrowed (buffer-narrowed-p)) > + (visible-start (point-min)) > + (visible-end (point-max)) > + target-pos) > + (when TeX-translate-location-line > + (save-restriction > + (widen) > + (goto-char (point-min)) > + (forward-line (+ TeX-translate-location-offset > + TeX-translate-location-line -1)) > + (cond > + ;; Error. > + ((equal type 'error) > + (if (not (string= TeX-translate-location-string " ")) > + (search-forward TeX-translate-location-string nil t))) > + ;; Warning or bad box. > + (t > + (beginning-of-line 0) > + (setq start (point)) > + (goto-char (point-min)) > + (forward-line (+ TeX-translate-location-offset > + line-end -1)) > + (end-of-line) > + (when TeX-translate-location-string > + (search-backward TeX-translate-location-string start t) > + (search-forward TeX-translate-location-string nil t)))) Can we rewrite the (cond ...) part to: (if (equal type 'error) ;; Error. (unless (string= TeX-translate-location-string " ") (search-forward TeX-translate-location-string nil t)) ;; Warning or bad box. (beginning-of-line 0) (setq start (point)) (goto-char (point-min)) (forward-line (+ TeX-translate-location-offset line-end -1)) (end-of-line) (when TeX-translate-location-string (search-backward TeX-translate-location-string start t) (search-forward TeX-translate-location-string nil t))) I think it is much easier to read. WDYT? Best, Arash _______________________________________________ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
