*** /tmp/ediffuS9ebt 2021-02-11 16:14:54.793873579 +0100 --- /net/ford/albinus/src/tramp/lisp/tramp-integration.el 2021-02-11 16:10:01.276681568 +0100 *************** *** 261,266 **** --- 261,294 ---- (delete (info-lookup->mode-cache 'symbol ',mode) (info-lookup->topic-cache 'symbol)))))))) + ;; Compilation processes use `accept-process-output' such a way that + ;; Tramp's parallel `accept-process-output' blocks. See last part of + ;; Bug#45518. So we forbid them to run in parallel. There must be a + ;; better solution, though. + (with-eval-after-load 'compile + (add-hook 'compilation-start-hook + #'tramp-compile-advice-add) + (add-hook 'compilation-finish-functions + #'tramp-compile-advice-remove) + (add-hook 'tramp-integration-unload-hook + (lambda () + (remove-hook 'compilation-start-hook + #'tramp-compile-advice-add) + (remove-hook 'compilation-finish-functions + #'tramp-compile-advice-remove)))) + + (defun tramp-compile-advice-add (proc) + "Don't allow remote file operations while compiling." + (with-current-buffer (process-buffer proc) + (when (file-remote-p default-directory) + (advice-add 'ignore :override 'compile-goto-error)))) + + (defun tramp-compile-advice-remove (buffer _message) + "Reenable remote file operations." + (with-current-buffer buffer + (when (file-remote-p default-directory) + (advice-remove 'ignore 'compile-goto-error)))) + ;;; Default connection-local variables for Tramp: ;; `connection-local-set-profile-variables' and ;; `connection-local-set-profiles' exists since Emacs 26.1.