unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: Tassilo Horn <tsdh@gnu.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: My read-buffer-function doesn't work when called by switch-to-buffer
Date: Sun, 12 Mar 2023 04:32:44 +0100	[thread overview]
Message-ID: <874jqq63vn.fsf@web.de> (raw)
In-Reply-To: <87fsabslcj.fsf@gnu.org> (Tassilo Horn's message of "Sat, 11 Mar 2023 09:58:11 +0100")

Tassilo Horn <tsdh@gnu.org> 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
this?


Michael.



  parent reply	other threads:[~2023-03-12  3:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10 21:10 My read-buffer-function doesn't work when called by switch-to-buffer Tassilo Horn
2023-03-11  0:32 ` Michael Heerdegen
2023-03-11  8:58   ` Tassilo Horn
2023-03-11 20:40     ` `when-let' (was: Re: My read-buffer-function doesn't work when called by switch-to-buffer) Emanuel Berg
2023-03-12  3:32     ` Michael Heerdegen [this message]
2023-03-12 18:51       ` My read-buffer-function doesn't work when called by switch-to-buffer Tassilo Horn
2023-03-13  0:32         ` Michael Heerdegen
2023-03-15  9:06           ` Tassilo Horn
2023-03-15 18:57             ` Michael Heerdegen
2023-03-16  9:18               ` Tassilo Horn
2023-03-16 16:59                 ` Tassilo Horn
2023-03-16 23:46                 ` Michael Heerdegen
2023-03-17  7:04                   ` Tassilo Horn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874jqq63vn.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=help-gnu-emacs@gnu.org \
    --cc=tsdh@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).