I'm tracing through the code in the solution and it looks to me that it sets filter to a lambda that returns either cand (the candidate) or nil (which it does when the candidate is a remote file):
But even when I change the filter lambda so that it always returns nil, consult-buffer still gives me previews:
(defun consult-buffer-state-no-tramp ()
"Buffer state function that doesn't preview any buffers."
(let ((orig-state (consult--buffer-state))
(filter (lambda (action cand)
(if (and cand
(or (eq action 'return)
(let ((buffer (get-buffer cand)))
(and buffer
(not (file-remote-p (buffer-local-value 'default-directory buffer)))))))
nil ;; always return nil - for remote and local buffers
nil))))
(lambda (action cand)
(funcall orig-state action (funcall filter action cand)))))
(setq consult--source-buffer
(plist-put consult--source-buffer :state #'consult-buffer-state-no-trampl))
I would expect that the above would disable previews for all buffers, but it doesn't.
Simplifying it further, the following code also fails to disable previews:
(defun consult-buffer-state-never-preview ()
"Buffer state function that doesn't preview any buffers."
(let ((orig-state (consult--buffer-state)))
(lambda (action cand)
(funcall orig-state action nil))))
(setq consult--source-buffer
(plist-put consult--source-buffer :state #'consult-buffer-state-never-preview))
I don't know enough about the consult internals to know why these don't work. I went looking for the definition of consult--buffer-state but it's docs say that it is defined as a closure, not a defun, and I'm afraid I'm at the limit of my elisp skills!
I have been trying to disable consult buffer preview for remote buffers, but I am unable to get the solution in https://github.com/minad/consult/issues/224 and the wiki to work.
I'm tracing through the code in the solution and it looks to me that it sets
filter
to a lambda that returns eithercand
(the candidate) ornil
(which it does when the candidate is a remote file):But even when I change the
filter
lambda so that it always returnsnil
,consult-buffer
still gives me previews:I would expect that the above would disable previews for all buffers, but it doesn't.
Simplifying it further, the following code also fails to disable previews:
I don't know enough about the consult internals to know why these don't work. I went looking for the definition of
consult--buffer-state
but it's docs say that it is defined as a closure, not adefun
, and I'm afraid I'm at the limit of my elisp skills!