[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: My read-buffer-function doesn't work when called by switch-to-buffer

From: Michael Heerdegen
Subject: Re: My read-buffer-function doesn't work when called by switch-to-buffer
Date: Sun, 12 Mar 2023 04:32:44 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Tassilo Horn <> writes:

> But why is that needed?  I had expected that when I give a completion
> table to completing-read, it would be used...

AFAIU both the outer call and your (original!) `completing-read' call
both set `minibuffer-completion-table' - the former (via
`read-buffer-to-switch') directly by using `minibuffer-with-setup-hook',
your code indirectly by calling `completing-read' (see
`completing-read-default' which does

  (setq-local minibuffer-completion-table collection)

in a `minibuffer-with-setup-hook').  Which one wins?  Since
`minibuffer-with-setup-hook' prepends to the hook by default, the outer
call wins.

I think the lesson is that it's better to avoid nested `completing-read'
calls.  It is probably not intended to allow to change the completion
table in `read-buffer-function'.  Maybe an advice of a higher level
function would better fit your wished-for behavior.

> And a bonus question: I use vertico + marginalia, so the buffers (and
> files in C-x C-f, variables/functions in C-h v/f,...) are nicely
> annotated, e.g., with the buffer's mode or the file's permissions.  What
> do I have to do that the recentf candidates also get those niceties?
> Wrap the recentf completion table so that it responds to metadata
> requests?

Dunno.  I don't use these packages.  Maybe using :annotation-function in
`completion-extra-properties' also works?  How do these packages achieve


reply via email to

[Prev in Thread] Current Thread [Next in Thread]