Skip to content
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

Respect predicate passed to `selectrum-read-buffer' (fix #32) #33

Merged
merged 6 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions selectrum.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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'.")
Expand Down