Skip to content

Commit

Permalink
[#41] Don't break history search bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
raxod502 committed Apr 17, 2020
1 parent 6f6709a commit 97b59f1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog].

## Unreleased
### Enhancements
* It is now possible to use the standard Isearch bindings within the
minibuffer to search the current user input and the minibuffer
history. Note that this functionality is not compatible with
Selectrum. See [#41].

[#41]: https://github.com/raxod502/ctrlf/issues/41

## 1.0 (released 2020-03-31)
### Added
* Package `ctrlf`
Expand Down
24 changes: 18 additions & 6 deletions ctrlf.el
Original file line number Diff line number Diff line change
Expand Up @@ -971,18 +971,26 @@ different behavior, for which see `recenter-top-bottom'."
"Search forward for literal string.
If already in a search, go to next candidate, or if no input then
insert the previous search string. If in a non-literal search,
change back to literal search if prefix ARG is provided."
change back to literal search if prefix ARG is provided. If in
the minibuffer but not in a search already, run command
`isearch-forward' instead."
(interactive "P")
(ctrlf-forward 'literal (null arg)))
(if (and (window-minibuffer-p) (not ctrlf--active-p))
(isearch-forward)
(ctrlf-forward 'literal (null arg))))

;;;###autoload
(defun ctrlf-backward-literal (&optional arg)
"Search backward for literal string.
If already in a search, go to previous candidate, or if no input
then insert the previous search string. If in a non-literal
search, change back to literal search if prefix ARG is provided."
search, change back to literal search if prefix ARG is provided.
If in the minibuffer but not in a search already, run
`isearch-backward' instead."
(interactive "P")
(ctrlf-backward 'literal (null arg)))
(if (and (window-minibuffer-p) (not ctrlf--active-p))
(isearch-backward)
(ctrlf-backward 'literal (null arg))))

;;;###autoload
(defun ctrlf-forward-regexp ()
Expand All @@ -991,7 +999,9 @@ If already in a search, go to next candidate, or if no input then
insert the previous search string. If in a non-regexp search,
change back to regexp search."
(interactive)
(ctrlf-forward 'regexp))
(if (and (window-minibuffer-p) (not ctrlf--active-p))
(isearch-forward-regexp)
(ctrlf-forward 'regexp)))

;;;###autoload
(defun ctrlf-backward-regexp ()
Expand All @@ -1000,7 +1010,9 @@ If already in a search, go to previous candidate, or if no input
then insert the previous search string. If in a non-regexp
search, change back to regexp search."
(interactive)
(ctrlf-backward 'regexp))
(if (and (window-minibuffer-p) (not ctrlf--active-p))
(isearch-backward-regexp)
(ctrlf-backward 'regexp)))

(defun ctrlf-forward-fuzzy ()
"Fuzzy search forward for literal string.
Expand Down

0 comments on commit 97b59f1

Please sign in to comment.