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

Improve exit when match required #338

Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ The format is based on [Keep a Changelog].
default is t) ([#261]).

### Enhancements
* Improved exit behaviour of `selectrum-select-current-candidate`. The
commands gives feedback now when match is required and submission
not possible. Also it allows submission of the prompt when a match
is required and the prompt is a member of candidates ([#338]).
* You can now configure `completion-styles` for the initial filtering
of `selectrum-completion-in-region` using
`selectrum-completion-in-region-styles` ([#331]).
Expand Down Expand Up @@ -190,6 +194,7 @@ The format is based on [Keep a Changelog].
[#334]: https://github.com/raxod502/selectrum/issues/334
[#335]: https://github.com/raxod502/selectrum/pull/335
[#337]: https://github.com/raxod502/selectrum/pull/337
[#338]: https://github.com/raxod502/selectrum/pull/338
[#339]: https://github.com/raxod502/selectrum/pull/339

## 3.0 (released 2020-10-20)
Expand Down
24 changes: 14 additions & 10 deletions selectrum.el
Original file line number Diff line number Diff line change
Expand Up @@ -1457,16 +1457,20 @@ indices."
(user-error "Cannot select a candidate when Selectrum is not active"))
(with-selected-window (active-minibuffer-window)
(let ((index (selectrum--index-for-arg arg)))
(when (or (not selectrum--match-required-p)
(and index (>= index 0))
(and minibuffer-completing-file-name
(file-exists-p
(substitute-in-file-name
(minibuffer-contents))))
(string-empty-p
(minibuffer-contents)))
(selectrum--exit-with
(selectrum--get-candidate index))))))
(if (or (not selectrum--match-required-p)
(string-empty-p
(minibuffer-contents))
(and index (>= index 0))
(if minibuffer-completing-file-name
(file-exists-p
(substitute-in-file-name
(minibuffer-contents)))
(member (minibuffer-contents)
selectrum--refined-candidates)))
(selectrum--exit-with
(selectrum--get-candidate index))
(minibuffer-message
(propertize "Match required" 'face 'minibuffer-prompt))))))

(defun selectrum-submit-exact-input ()
"Exit minibuffer, using the current user input.
Expand Down