Hi Arash, > Thanks, I think your suggestion makes sense. I have only one comment > below. > > ... > > Can we rewrite the (cond ...) part to: > > ... > > I think it is much easier to read. WDYT?
Agreed. I noticed a few other places where it seemed the readability of the affected code could be improved (see attached). Look OK to you? Thanks, best, Paul
>From 0d05cc80ed7693804c419cb4bfb09af63e9a6ceb 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 | 53 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/tex.el b/tex.el index 7c14a135..601855bf 100644 --- a/tex.el +++ b/tex.el @@ -9768,7 +9768,7 @@ value is not used here." (TeX-translate-location-offset offset) (TeX-translate-location-context context) (TeX-translate-location-string string) - error-file-buffer start) + error-file-buffer) (run-hooks 'TeX-translate-location-hook) @@ -9788,26 +9788,37 @@ 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-min (point-min)) + (visible-max (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)) + (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) + (let ((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)))) + (setq target-pos (point)))) + (when (and target-pos narrowed + (not (<= visible-min target-pos visible-max))) + ;; The error lies outside the restriction, so widen first. + (widen)) + (when target-pos + (goto-char target-pos)))) ;; When the file cannot be determined stay here but issue a ;; warning. (message "Could not determine file for %s" -- 2.50.1 (Apple Git-155)
_______________________________________________ bug-auctex mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-auctex
