diff --git a/CHANGELOG.md b/CHANGELOG.md index 402800fb..88d7d652 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,10 +18,14 @@ The format is based on [Keep a Changelog]. * You can now use the undo system in the minibuffer. Previously, trying to do so would break Selectrum ([#31]). * Passing a list of symbols to `selectrum-completing-read` works now. +* Previously, `selectrum-read-buffer` ignored its PREDICATE argument. + This has now been fixed ([#32, #33]). [#25]: https://github.com/raxod502/selectrum/pull/25 [#30]: https://github.com/raxod502/selectrum/issues/30 [#31]: https://github.com/raxod502/selectrum/issues/31 +[#32]: https://github.com/raxod502/selectrum/issues/31 +[#33]: https://github.com/raxod502/selectrum/issues/31 ## 1.0 (released 2020-03-23) ### Added diff --git a/selectrum.el b/selectrum.el index ec4d5fd5..278e7b74 100644 --- a/selectrum.el +++ b/selectrum.el @@ -715,7 +715,10 @@ PREDICATE, see `read-buffer'." (selectrum-preprocess-candidates-function #'ignore) (selectrum-refine-candidates-function (lambda (input _) - (let ((candidates (mapcar #'buffer-name (buffer-list)))) + (let* ((buffers (mapcar #'buffer-name (buffer-list))) + (candidates (if predicate + (cl-delete-if-not predicate buffers) + buffers))) (if (string-prefix-p " " input) (progn (setq input (substring input 1)) @@ -736,8 +739,10 @@ PREDICATE, see `read-buffer'." orig-preprocess-function candidates))) (input . ,input)))))) - (selectrum-completing-read - prompt nil predicate require-match nil nil def))) + (selectrum-read + prompt nil + :default-candidate def + :require-match require-match))) (defvar selectrum--old-read-buffer-function nil "Previous value of `read-buffer-function'.")