Skip to content

Commit

Permalink
Ensure enabled recursive minibuffers for special commands (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
clemera authored Jan 26, 2021
1 parent 257224b commit 69342da
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ The format is based on [Keep a Changelog].
default is t) ([#261]).

### Enhancements
* Selectrum will allow recursive sessions for
`selectrum-completion-in-region` and `selectrum-select-from-history`
so these commands work even if `enable-recursive-minibuffers` is not
set by the user ([#100], [#397]).
* In file completions where the directory path of the input does not
exist, the candidates are automatically gathered by interpreting the
input as an partial-completion style input pattern (see
Expand Down Expand Up @@ -216,6 +220,7 @@ The format is based on [Keep a Changelog].
property in file completions were overwritten for directories and
not displayed, which has been fixed ([#256], [#255]).

[#100]: https://github.com/raxod502/selectrum/issues/100
[#194]: https://github.com/raxod502/selectrum/issues/194
[#200]: https://github.com/raxod502/selectrum/pull/200
[#208]: https://github.com/raxod502/selectrum/pull/208
Expand Down Expand Up @@ -307,6 +312,7 @@ The format is based on [Keep a Changelog].
[#389]: https://github.com/raxod502/selectrum/pull/389
[#390]: https://github.com/raxod502/selectrum/pull/390
[#393]: https://github.com/raxod502/selectrum/pull/393
[#397]: https://github.com/raxod502/selectrum/pull/397

## 3.0 (released 2020-10-20)
### Breaking changes
Expand Down
48 changes: 25 additions & 23 deletions selectrum.el
Original file line number Diff line number Diff line change
Expand Up @@ -1891,28 +1891,29 @@ history item and exit use `selectrum-select-current-candidate'."
(let ((history (symbol-value minibuffer-history-variable)))
(when (eq history t)
(user-error "No history is recorded for this command"))
(let ((result
(minibuffer-with-setup-hook
(lambda ()
(setq-local enable-recursive-minibuffers t)
(setq-local selectrum-should-sort-p nil)
(setq-local selectrum-candidate-inserted-hook nil)
(setq-local selectrum-candidate-selected-hook nil)
(use-local-map (make-composed-keymap nil (current-local-map)))
(define-key (current-local-map)
[remap selectrum-insert-current-candidate]
'selectrum--insert-history)
(let ((inhibit-read-only t))
(goto-char (or (search-backward ":" nil t)
(1- (minibuffer-prompt-end))))
(insert
(apply
#'propertize
" [history]"
(text-properties-at (point))))))
(catch 'selectrum-insert-action
(completing-read
(minibuffer-prompt) history nil t nil t)))))
(let* ((enable-recursive-minibuffers t)
(result
(minibuffer-with-setup-hook
(lambda ()
(setq-local selectrum-should-sort-p nil)
(setq-local selectrum-candidate-inserted-hook nil)
(setq-local selectrum-candidate-selected-hook nil)
(use-local-map
(make-composed-keymap nil (current-local-map)))
(define-key (current-local-map)
[remap selectrum-insert-current-candidate]
'selectrum--insert-history)
(let ((inhibit-read-only t))
(goto-char (or (search-backward ":" nil t)
(1- (minibuffer-prompt-end))))
(insert
(apply
#'propertize
" [history]"
(text-properties-at (point))))))
(catch 'selectrum-insert-action
(completing-read
(minibuffer-prompt) history nil t nil t)))))
(if (get-text-property 0 'selectum--insert result)
(progn
(delete-minibuffer-contents)
Expand Down Expand Up @@ -2172,7 +2173,8 @@ the prompt."
"Complete in-buffer text using a list of candidates.
Can be used as `completion-in-region-function'. For START, END,
COLLECTION, and PREDICATE, see `completion-in-region'."
(let* ((input (buffer-substring-no-properties start end))
(let* ((enable-recursive-minibuffers t)
(input (buffer-substring-no-properties start end))
(meta (completion-metadata input collection predicate))
(category (completion-metadata-get meta 'category))
(bound (pcase category
Expand Down

0 comments on commit 69342da

Please sign in to comment.