help-gnu-emacs
[Top][All Lists]
Advanced

[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: Sat, 11 Mar 2023 01:32:07 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Tassilo Horn <tsdh@gnu.org> writes:

> (defun th/read-buffer-or-recentf (prompt &optional
>                                          def require-match predicate)
>   (when-let ((result (completing-read
>                       prompt
>                       (completion-table-in-turn #'internal-complete-buffer
>                                                 (completion-table-dynamic
>                                                  (lambda (s) recentf-list)))
>                       predicate require-match nil 'buffer-name-history def)))
>     (cond
>      ((get-buffer result) result)
>      ((file-exists-p result) (buffer-name (find-file-noselect result)))
>      (t result))))
>
> (setq read-buffer-function #'th/read-buffer-or-recentf)
> [...]
> However, when I do C-x b (switch-to-buffer), no matter what, recent
> files are not provided as completion candidates.  But edebug convinces
> me that my function th/read-buffer-or-recentf is called.  It just seems
> that the same completing-read call behaves differently when called
> directly and when being called by switch-to-buffer.  Why is that and
> what can I do against it?

Seems this happens because `read-buffer-to-switch' sets
`minibuffer-completion-table'.

Michael.




reply via email to

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