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

Make ctrlf go to the end of matches. #73

Merged
merged 6 commits into from
Jan 18, 2021
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog].

## Unreleased
### Features
* New user option `ctrlf-go-to-end-of-match`, if non-nil, puts point
at the end of a match when exiting a search, rather than the
beginning ([#66], [#73])

### Enhancements
* Compatibility with evil-mode's jump list and search history features
was included in [#59]. This integration happens automatically and
requires no user input/customisation.

[#59]: https://github.com/raxod502/ctrlf/issues/59
[#66]: https://github.com/raxod502/ctrlf/issues/66
[#73]: https://github.com/raxod502/ctrlf/pull/73

## 1.2 (released 2020-10-20)
### Features
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ and `ctrlf-previous-match`. These functions are the same as
features of inserting the previous search, changing to a literal
search, or starting a new search when not already in a search session.

You can customize the behavior:

* If `ctrlf-go-to-end-of-match` is nil, then the cursor will move to
the beginning of the match instead of the end.

### Search styles

CTRLF implements support for literal and regexp using an extensible
Expand Down
9 changes: 8 additions & 1 deletion ctrlf.el
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ return nil."
Otherwise, the match count is only shown in the minibuffer."
:type 'boolean)

(defcustom ctrlf-go-to-end-of-match t
irigone marked this conversation as resolved.
Show resolved Hide resolved
"Non-nil means to go to the end of the match after the search is finished.
Otherwise, it goes to the beginning of the match."
:type 'boolean)

(defcustom ctrlf-style-alist
'((literal . (:prompt "literal"
:translator regexp-quote
Expand Down Expand Up @@ -699,7 +704,9 @@ later (this should be used at the end of the search)."
(if (and (not skip-search)
(ctrlf--search input :bound 'wraparound))
(progn
(goto-char (match-beginning 0))
(goto-char (if ctrlf-go-to-end-of-match
(match-end 0)
(match-beginning 0)))
(setq ctrlf--match-bounds
(cons (match-beginning 0)
(match-end 0))))
Expand Down