Subject: Re: bug#36483: 12.1.2; 'lacheck' and 'chktex' results not recongnized by compilation mode when filename has spaces

From: Ikumi Keita <[email-masked]>
Date: Tue, 16 Jul 2019 00:49:24 +0900

Hi Gustavo,

>>>>> Gustavo Barros <[email-masked]> writes:
> When I reported, I did fear this might ultimately rely on some change
> in compilation mode.  However, I still reported it here, because I
> thought that was the most appropriate place for me to do it.  Indeed,
> while I’m a regular user of AUCTeX, I’m deeply unacquainted with the
> workings of compilation mode. To the point I’d feel it inappropriate
> to simply ask the maintainer there to accept file names with spaces.

> Still, even if the solution may rely on some change in compilation
> mode, the workings of AUCTeX in this respect do not correspond to the
> behavior described in AUCTeX’s documentation in a case where it is
> reasonable to expect it would.

> Furthermore, error navigation for file names with spaces does work for
> other TeX commands which, as you mentioned, are equally left for
> compilation mode to handle.  It doesn’t just for 'lacheck' and
> 'chktex'.

> I just happened to stumble upon this while rereading the
> documentation, tracked down the source of the problem, and reported
> where I saw it was fittest.  It’s really up to you to assess if this
> is relevant enough from AUCTeX’s perspective.  (And I really mean it,
> I just reported in a constructive spirit, without presumptions.)

I reported this problem in [email-masked], but didn't get any
response unfortunately.  What we can do tentatively now is to add an
ad-hoc workaround like a patch quoted below to AUCTeX.

What do you think about this?

Regards,
Ikumi Keita

diff --git a/tex-buf.el b/tex-buf.el
index 8b87c4c6..cf3ada95 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -1293,7 +1293,17 @@ run of `TeX-run-TeX', use
 (defun TeX-run-compile (_name command _file)
   "Ignore first and third argument, start compile with second argument."
   (let ((default-directory (TeX-master-directory)))
-    (setq TeX-command-buffer (compile command))))
+    (setq TeX-command-buffer (compile command)))
+  ;; Make `compilation-mode' to recognize file names with spaces.
+  ;; (bug#36483)
+  (with-current-buffer TeX-command-buffer
+    (make-local-variable 'compilation-error-regexp-alist)
+    (add-to-list 'compilation-error-regexp-alist
+		 ;; Add slightly modified entry of the one associated
+		 ;; with `comma' in `compilation-error-regexp-alist-alist'
+		 ;; to pick up file names with spaces.
+		 '("^\"\\([^,\"\n\t]+\\)\", line \\([0-9]+\\)\
+\\(?:[(. pos]+\\([0-9]+\\))?\\)?[:.,; (-]\\( warning:\\|[-0-9 ]*(W)\\)?" 1 2 3 (4)) t))))
 
 (defun TeX-run-shell (_name command _file)
   "Ignore first and third argument, start shell-command with second argument."