-
Notifications
You must be signed in to change notification settings - Fork 37
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
rg-mode shouldn't bind C-n and C-p #72
Comments
The
I don't think I will change the bindings. It's a bit of an unfortunate clash but It's commonly used keys in this mode and I don't want to break such use cases. Could possibly add an option for it for users that find it hard to rebind keys. |
Could you be more specific of their utility? I tried to be specific because I found them unusable in grouped mode. They moved me to the "header" line but then I couldn't do anything there because I didn't find bindings that did anything when point was on a header line, and I couldn't move off a header line because C-n and C-p were changed and behaved as if I hadn't moved to the header line in the first place. This is what I tried to describe. I can see their utility in ungrouped mode, but I think in this case they just behave the same as the "upstream" |
I don't think I can actually. As I wrote, the benefit is moving between files to immediately identify the file (name) with matches. There isn't really much more to it I am afraid but very useful I think. Compare that to moving backwards with
|
I'll be doing the following in my config:
I see the utility of getting to the filename if it's not visible (though maybe it could be displayed in the modeline), but it feels closer to moving by paragraphs so I'm trying |
FWIW, I also bind those (C-n, ...) to |
I just found this ticket after trying to unbind |
I think
rg-mode
should stop bindingC-n
andC-p
in the*rg*
buffer.The keymap is
rg-mode-map
which inherits fromgrep-mode-map
which inherits fromcompilation-minor-mode-map
which all seems reasonable.compilation-minor-mode-map
being a minor mode doesn't bind the most common keys. So it usesM-n
andM-p
for next and previous error andM-}
andM-{
for next and previous file.grep-mode-map
being a map for major mode binds easier keys for these things.n
andp
are next and previous error and}
and{
are next and previous file and of course the parent bindings still work.rg-mode-map
has similar needs, needing motion by error (aka match) and by file, as well as forward and back in search history which are bound toC-c>
andC-c<
which is fine. It uses the inherited bindings forn
andp
for next and previous error which seems reasonable. Those are the most obvious keys for motion and moving by error is the most obvious motion.But it also binds
C-n
andC-p
to file motion commandsrg-next-file
andrg-previous-file
. I tend to just use these keys for motion since they work everwhere else in emacs and having them skip over lines in*rg*
buffers is jarring. Also unlikecompilation-next-file
andcompilation-previous-file
they don't move you to the first or last match in a file, but to the filename line itself (ifrg-group-result
is non-nil which is its default value).As near as I can tell, when results are grouped, when point is on a file name line there don't seem to be useful key bindings.
RET
doesn't take you to the file,o
doesn't display it in another window, etc. So I don't think the next and previous file commands should put you on those lines.Also they don't seem to play well with the next and previous error commands. If I use
n
to move to say the 4th error of the 5th file and then useC-p
to move up to the 2nd file; if I then hitn
I move not to the first error of the 2nd file, but to the 5th error of the 5th file, as if I never hitC-p
at all. Navigating withcompilation-next-file
andcompilation-previous-file
seem to have the same issue (I notice they don't move a bullet in the left gutter), even if results aren't grouped by files, but since they always leave me on an error, I can hitRET
to move to that error and thenn
andp
work. Usingrg-next-file
I end up on a file and then can't move to it's first error becauseC-n
is bound torg-next-file
.So I don't understand what
rg-next-file
andrg-previous-file
are buying you overcompilation-next-file
andcompilation-previous-file
and regardless I don't think they should be bound toC-n
andC-p
.The text was updated successfully, but these errors were encountered: