Add functions to increment/decrement context #161
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thanks for this great package, I use it daily!
I wanted to be able to increase/decrease the before/after context via keybindings rather than clicking through the buttons in the header of a deadgrep buffer. I didn't see a way to do this with the functions
deadgrep
currently exposes, so I wrote my own. I figure others might find this useful, so this PR includes that code.(Please let me know if I've missed something and this functionality already exists).
New Functions
deadgrep--update-context
does most of the work. It takes a string (which-context
, which can be either "before" or "after") and an integer (value
). The function updates the context denoted bywhich-context
by addingvalue
to the appropriate field indeadgrep--context
, after ensuring that doing so won't result in a negative value.A family of interactive functions named
deadgrep-<increment/decrement>-<before/after>-context
are implemented to usedeadgrep--update-context
to increment/decrement the before/after context by 1 line. These are intended to be bound to keys.Keybindings
I've not added any keybindings to the
deadgrep-mode-map
, but in my configuration I use the following hydra:I'm happy to add default keybindings if that is desired and suggestions are welcome for such keybinds.
Note: This is my first non-trivial elisp contribution to an emacs package, so please let me know if there's anything here that needs to be changed, I'm happy to do it.