-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
consult-buffer preview: problem with tramp buffers and slow/unreachable hosts #224
Comments
Thank you for the report. It is a known problem that "problematic buffers" do not work well with Consult preview. A similar problem occurred for example with EXWM buffers (#204). The solution for EXWM buffers is to exclude those from the preview by configuring your own buffer sources, see https://github.com/minad/consult/wiki#do-not-preview-x-windows-exwm in the wiki. However in contrast to EXWM, tramp is a built-in Emacs problem, so we could feel more inclined to offer this configuration in Consult out of the box. On the other hand, if you have multiple open buffers with unreachable hosts it will lead to problems anyway, so we could also decide to not fix anything here. Another option is to disable preview for consult-buffer and use a manual preview key instead. Is this answer helpful? |
Thanks. I'm also in contact with the tramp maintainer, who is very helpful. regarding the exwm solution, how would a similar solution look for tramp? If we have a workaround it would be easier to think about the more general solution. |
That's good to hear.
The EXWM solution filters the buffers depending on the EXWM mode. For TRAMP we could do a similar thing - e.g., filter remote buffers, such that they are never previewed. I think I would like to keep Consult as is, requiring users to configure their own buffer sources for such cases instead of adding a configuration layer on top which filters the candidates. (defun consult-buffer-state-no-tramp ()
"Buffer state function that doesn't preview X buffers."
(let ((orig-state (consult--buffer-state))
(filter (lambda (cand restore)
(if (or restore
(let ((buffer (get-buffer cand)))
(and buffer
(not (file-remote-p (buffer-local-value 'default-directory buffer))))))
cand
nil))))
(lambda (cand restore)
(funcall orig-state (funcall filter cand restore) restore))))
(setq consult--source-buffer
(plist-put consult--source-buffer :state #'consult-buffer-state-no-tramp)) |
I close this issue since I don't see how we can solve this problem differently than with the proposed buffer filtering solution. I added the snippet to the wiki. If some other approach becomes possible in the future we can revisit the issue, e.g., when Tramp adds some freeze/unfreeze mechanism. |
thanks! |
This doesn't seem to work at all... |
… connections If `default-directory' is a remote file name at the time `consult-buffer' is started, tramp will try to start a new connection. This mostly happens to me in vterm when I've used ssh to get to a remote host, and then want to switch buffers. Maybe related to minad/consult#224 Note: this issue with tramp doesn't happen with the built in `switch-to-buffer' function.
I had to change the function to open recently visited file without preview (defun consult-buffer-state-no-tramp ()
"Buffer state function that doesn't preview recentf and remote files"
(let ((orig-state (consult--buffer-state))
(filter (lambda (cand restore)
(if (or (string-equal "return" cand)
restore
(let ((buffer (get-buffer cand)))
(and buffer
(not (file-remote-p (buffer-local-value 'default-directory buffer))))))
cand
nil))))
(lambda (cand restore)
(funcall orig-state (funcall filter cand restore) restore)))) Update: ye actually |
Edit a file using ssh on a remote host with tramp. consult-buffer works smoothly as long as the remote host is up.
If the remote host goes down, the situation changes. As soon as consult-buffer tries to preview the remote buffer emacs hangs.
This happens a lot when changing buffers.
Granted, this is also a tramp problem, but perhaps things could be done in consult buffer to alleviate the situation, by detecting that the remote host is down and not trying to preview it in that case.
The text was updated successfully, but these errors were encountered: