On 2023-11-10, 11:26 +0000, Fabio Natali <m...@fabionatali.com> wrote:
> On 2023-11-10, 11:13 +0000, Fabio Natali <m...@fabionatali.com> wrote:
>> Brilliant. I think the second branch should read `(not (file-remote-p
>> file))', i.e. `file' instead of `associated'? It seems to work with that
>> micro amendment.
> Hm, I stand corrected, I retested it end-to-end and no, it doesn't seem
> to work. I'll post more details later. Cheers, Fabio.

Hi Ihor,

Sorry for the delay. My results below, after testing a couple of
different cases.

If the remote file had been saved before losing connection, then the
patch below will fix the problem. TRAMP will still hang for a while, as
it tries to reach the server but the buffer will be closed immediately
when using `tramp-cleanup-all-buffers' (or a variant thereof).

--- /tmp/test-0.el      2023-11-11 09:27:33.477117451 +0000
+++ /tmp/test-1.el      2023-11-11 09:27:14.217129703 +0000
@@ -5,7 +5,8 @@
      (unless (stringp associated)
        (setq associated (cadr associated)))
      (let* ((rtn `(:file ,associated))
-            (inode (and (fboundp 'file-attribute-inode-number)
+            (inode (and (not (file-remote-p associated))
+                       (fboundp 'file-attribute-inode-number)
                          (file-attributes associated)))))
        (when inode (plist-put rtn :inode inode))
@@ -25,6 +26,7 @@
                      (or (buffer-base-buffer associated)
          (setq inode (when (and file
+                               (not (file-remote-p file))
                                 (fboundp 'file-attribute-inode-number))
                         (file-attributes file))))

(Apologies, the patch is badly formatted and not meant for the
repository.) The gist is that I replaced an occurrence of `associated'
with `file' in your latest patch, Ihor. It seems to work, what do you

However, if the remote file hadn't been saved, then TRAMP will still
hang indefinitely. Quitting will reveal the following backtrace:

Debugger entered--Lisp error: (quit "")
  signal(quit (""))
  tramp-error(nil quit "")
  tramp-signal-hook-function(quit (""))
  signal(quit (""))
  tramp-maybe-open-connection((tramp-file-name "ssh" nil nil "" 
nil "~/.#test.org" nil))
  tramp-send-command((tramp-file-name "ssh" nil nil "" nil 
"~/.#test.org" nil) "echo ~ 2>/dev/null; echo tramp_exit_status $?")
  tramp-send-command-and-check((tramp-file-name "ssh" nil nil "" 
nil "~/.#test.org" nil) "echo ~")
  tramp-sh-handle-get-home-directory((tramp-file-name "ssh" nil nil 
"" nil "~/.#test.org" nil) "")
  tramp-sh-file-name-handler(tramp-get-home-directory (tramp-file-name "ssh" 
nil nil "" nil "~/.#test.org" nil) "")
  apply(tramp-sh-file-name-handler tramp-get-home-directory ((tramp-file-name 
"ssh" nil nil "" nil "~/.#test.org" nil) ""))
  tramp-file-name-handler(tramp-get-home-directory (tramp-file-name "ssh" nil 
nil "" nil "~/.#test.org" nil) "")
  tramp-get-home-directory((tramp-file-name "ssh" nil nil "" nil 
"~/.#test.org" nil) "")
  tramp-sh-handle-expand-file-name("/ssh:" nil)
  tramp-sh-file-name-handler(expand-file-name "/ssh:" 
  apply(tramp-sh-file-name-handler expand-file-name 
("/ssh:" nil))
  tramp-file-name-handler(expand-file-name "/ssh:" 
  files--transform-file-name("/ssh:" nil ".#" "")
  tramp-run-real-handler(make-lock-file-name ("/ssh:"))
  apply(tramp-sh-file-name-handler make-lock-file-name 
  tramp-file-name-handler(make-lock-file-name "/ssh:")
  tramp-sh-file-name-handler(unlock-file "/ssh:")
  apply(tramp-sh-file-name-handler unlock-file "/ssh:")
  tramp-file-name-handler(unlock-file "/ssh:")
  funcall-interactively(kill-buffer "test.org")

This seems to be on the TRAMP side?

Cheers, Fabio.

Reply via email to