Subject: Re: bug#45518: Ctrl-G Fails to Interrupt Hung Tramp Remote-Compile in Emacs 27.1

From: Michael Albinus <[email-masked]>
Date: Tue, 12 Jan 2021 16:02:32 +0100

Duncan Greatwood <[email-masked]> writes:

Hi Duncan,

> Meanwhile, good luck with debugging these bug#45518 issues.

Finally, I nailed it down. In the (remote) compilation process, there is
a process filter, which calls `file-truename' if it detects an
error. This works one or two times, but then the (remote) compilation
process comes in conflict with the (remote) Tramp process responsible
for `file-truename'.

The following patch has fixed the issue for me on my FreeBSD machine. It
is on top of Emacs' git master; but likely it works also for your Emacs
27 (not tested by me). Could you check, whether this helps you?

> Thanks again!

Best regards, Michael.

*** /tmp/ediffZ4hAwi	2021-01-12 16:00:49.593081437 +0100
--- /home/albinus/src/emacs/lisp/progmodes/compile.el	2021-01-12 15:52:02.111270252 +0100
***************
*** 3041,3047 ****
  	    ;; Get the specified directory from FILE.
  	    (spec-directory
               (if (cdr file)
! 		 (file-truename (concat comint-file-name-prefix (cdr file))))))

  	;; Check for a comint-file-name-prefix and prepend it if appropriate.
  	;; (This is very useful for compilation-minor-mode in an rlogin-mode
--- 3041,3052 ----
  	    ;; Get the specified directory from FILE.
  	    (spec-directory
               (if (cdr file)
!                  ;; This function is active in `compilation-filter'.
!                  ;; There could be problems to call `file-truename'
!                  ;; for remote compilation processes.
! 		 (if (file-remote-p default-directory)
! 		     (concat comint-file-name-prefix (cdr file))
! 		   (file-truename (concat comint-file-name-prefix (cdr file)))))))

  	;; Check for a comint-file-name-prefix and prepend it if appropriate.
  	;; (This is very useful for compilation-minor-mode in an rlogin-mode