-
-
Notifications
You must be signed in to change notification settings - Fork 105
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--read: Introduce new :state function protocol (BREAKING API CHANGE) #546
Conversation
…HANGE) We need a fine-grained protocol in order to undo buffer preview (See #354). See `consult--with-preview` for details.
I apologize for the breakage! The API change was necessary to implement preview This API change affects these MELPA projects which make use of preview: |
Do you think it would be a good idea for embark-consult to add pre and post actions hooks that disable and reenable the preview for every action? I've been thinking about that for a while now, but the old exposed preview function didn't let me do that if I recall correctly. See oantolin/embark#352, for example. |
I am not sure I understand 352 correctly. When I preview a bookmark, switch to the buffer, move the point around, go back to the minibuffer press (EDIT: Ah I misunderstood oantolin/embark#352. I got it now and I will think about it.) |
We can discuss that issue over there to keep this place free for the people you pinged about their packages to ask questions. |
Change the consult-org-roam--node-preview to conform with consult's API change (announced in minad/consult#546)
Thanks for informing me about the breaking change, @minad. Best regards, |
thanks @minad. i haven't looked with great care at the new protocol, so
maybe i'm missing something, but a naive attempt replacing the previous
state function:
```elisp
(defun consult-notmuch--preview (candidate _restore)
"Open resulting CANDIDATE in ‘notmuch-show’ view, in a preview buffer."
(consult-notmuch--close-preview)
(when-let ((thread-id (consult-notmuch--thread-id candidate)))
(notmuch-show thread-id nil nil nil consult-notmuch--buffer-name)))
```
with
```elisp
(defun consult-notmuch--preview (action cand)
(cond ((eq action 'exit) (funcall (consult--temporary-files)))
((eq action 'preview)
(when-let ((thread-id (consult-notmuch--thread-id cand)))
(notmuch-show thread-id nil nil nil
consult-notmuch--buffer-name)))))
```
is not working for me: the state function is called with 'init and
'preview for the first selected candidate, but when i move from one
candidate to another in the completions buffer (i'm using mct), the
state function is not called again... most probably something related to
mct, or to the fact that i haven't restarted emacs... i will,
eventually. i just wanted to ask if the new version looks correct to
you?
thanks,
jao
--
One will rarely err if extreme actions be ascribed to vanity, ordinary
actions to habit, and mean actions to fear. -Friedrich Nietzsche,
philosopher (1844-1900)
|
Regarding the correctness of your preview function:
|
ah, on second read i think you meant this should be enough?
(defun consult-notmuch--preview (action cand)
(when (eq action 'preview)
(when-let ((thread-id (consult-notmuch--thread-id cand)))
(notmuch-show thread-id nil nil nil consult-notmuch--buffer-name))))
it seems that, with the new protocol, i only need to care of the preview
action...
|
@jaor Yes if you don't need additional setup/cleanup. |
On Fri, Apr 08 2022, Daniel Mendler wrote:
it seems that, with the new protocol, i only need to care of the preview
action...
@jaor Yes if you don't need additional setup/cleanup.
excellent, thanks for your help.
|
Hi. I've updated |
On Fri, Apr 08 2022, Daniel Mendler wrote:
Regarding the correctness of your preview function:
* (funcall (consult--temporary-files)) does not look right. This should be a nop.
i was looking at this:
(defun consult--file-preview ()
"Create preview function for files."
(let ((open (consult--temporary-files))
(preview (consult--buffer-preview)))
(lambda (action cand)
(when (eq action 'exit)
(funcall open))
so i don't follow, sorry: what shoud be a nop? do you mean that, when
called within an active consult--read, (consult--temporary-files)
returns a no-op?
for what is worth, it seems to be working just fine with your new
consult.el...
|
We need a fine-grained protocol in order to undo buffer preview (See #354).
See
consult--with-preview
for details:consult/consult.el
Lines 1434 to 1475 in a79b620