Hello! Right now 'TeX-help-error' finds the log file in order to extract the help text from it, and that causes some minor annoyances to me. E.g., it adds an entry to 'recentf-list'.
Honestly I do not think it is necessary to really visit the log file here. Inserting the contents into a temporary buffer works well for me. I wonder if I have overlooked something? If not, I would like to suggest the attached patch. Thanks in advance! Pengji PS I am not subscribed to this list, so please CC me when replying. Thanks!
>From 249097faa34c57ffdb17071f38de6d434e1d7d86 Mon Sep 17 00:00:00 2001 From: Pengji Zhang <m...@pengjiz.com> Date: Wed, 23 Oct 2024 08:15:50 +0800 Subject: [PATCH] Use temporary buffer for log file * tex.el (TeX-help-error): Insert contents of log file into a temporary buffer instead of visiting the file. This is to avoid polluting, for example, the user's buffer list and recentf list. --- tex.el | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/tex.el b/tex.el index 4e361e4c..27d7479b 100644 --- a/tex.el +++ b/tex.el @@ -10053,29 +10053,20 @@ a bad box." 'TeX-error-description-help) (let ((help (cdr (nth TeX-error-pointer error-description-list)))) - (save-excursion - (if (and (= (1+ TeX-error-pointer) - (length error-description-list)) - (let* ((log-buffer (find-buffer-visiting log-file))) - (if log-buffer - (progn - (set-buffer log-buffer) - (revert-buffer t t)) - (setq log-buffer - (find-file-noselect log-file)) - (set-buffer log-buffer)) - (auto-save-mode nil) - (setq buffer-read-only t) - (goto-char (point-min)) - (search-forward error nil t 1)) - (re-search-forward "^l\\." nil t) - (re-search-forward "^ [^\n]+$" nil t)) - (let ((start (1+ (point)))) - (forward-char 1) - (re-search-forward "^$") - (concat "From the .log file...\n\n" - (buffer-substring start (point)))) - help))))) + (or (and (= (1+ TeX-error-pointer) + (length error-description-list)) + (with-temp-buffer + (insert-file-contents log-file) + (goto-char (point-min)) + (when (and (search-forward error nil t 1) + (re-search-forward "^l\\." nil t) + (re-search-forward "^ [^\n]+$" nil t)) + (let ((start (1+ (point)))) + (forward-char 1) + (re-search-forward "^$") + (concat "From the .log file...\n\n" + (buffer-substring start (point))))))) + help)))) (goto-char (point-min)) (TeX-special-mode) (TeX-pop-to-buffer old-buffer nil t))) -- 2.47.0