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 3 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 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
11 changes: 9 additions & 2 deletions 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)))
irigone marked this conversation as resolved.
Show resolved Hide resolved
(setq ctrlf--match-bounds
(cons (match-beginning 0)
(match-end 0))))
Expand Down Expand Up @@ -855,7 +862,7 @@ For some reason this gets trashed when exiting the minibuffer, so
we restore it to keep the scroll position consistent.

I have literally no idea why this is needed.")

"this is a test"
irigone marked this conversation as resolved.
Show resolved Hide resolved
(defun ctrlf--finalize ()
"Perform cleanup that has to happen after the minibuffer is exited.
And self-destruct this hook."
Expand Down