Skip to content

Commit

Permalink
Make ctrlf go to the end of matches. (#73)
Browse files Browse the repository at this point in the history
* Add option to go to the end of the line and make it the default.

* For passing the circleci check

* Change (or (and... to (if... for easier readability

Co-authored-by: Radon Rosborough <radon.neon@gmail.com>

* Remove comment

* Fix indentation

Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
  • Loading branch information
irigone and raxod502 authored Jan 18, 2021
1 parent febd5a3 commit 928f98d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
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
"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

0 comments on commit 928f98d

Please sign in to comment.