Skip to content

Conversation

@iquiw
Copy link
Contributor

@iquiw iquiw commented Mar 2, 2025

Summary

Hi, this PR provides transient interface for deadgrep.
This makes it easy to add new options to deadgrep through the transient API.
I'd like to hear your opinion whether it can be included in deadgrep.

Ref. #125

image

For example, we can add --search-zip options like the following. Ref. #110

(transient-append-suffix 'deadgrep-transient-menu '(1) ["Input Options" ("-z" "Search Zip" "--search-zip")])

image

Changes

  • Introduce new file and command deadgrep-transient-menu, which invokes transient menu for deadgrep.
  • Bind t to deadgrep-transient-menu in deadgrep-mode-map.
  • Add new internal variables deadgrep--arguments-function and deadgrep--write-heading-function,
    which are default to deadgrep--arguments and deadgrep--write-heading respectively and overridden in deadgrep-transient.

TODO

This PR is a draft due to the following reasons.

  • No document. README.md is not updated yet.
  • This currently provides 2 transient suffixes, "Search in project root" and "Search in current directory",
    but I am considering if it is better to add transient infix to set the search directory instead.
  • The transient interface is corresponding to ripgrep options, while deadgrep options have some shorthand.
    So deadgrep-transient options cannot be translated to deadgrep options in some cases.
    For example, it is possible that "--word-regexp" is on and "--fixed-strings" is off in deadgrep-transient, while there is no corresponding option in deadgrep.
    We might add some optional text in deadgrep heading for them.

Correspondence between some of deadgrep options and ripgrep options.

variable value deadgrep UI ripgrep options
deadgrep--search-type string string --fixed-strings
words words --fixed-strings --word-regexp
regexp regexp
deadgrep--skip-if-hidden t yes
nil no --hidden
deadgrep--skip-if-vcs-ignore t yes --glob=!/.git
nil no --no-ignore-vcs

iquiw added 2 commits March 2, 2025 21:54
* Introduce new command `deadgrep-transient`, which invokes transient menu
  for deadgrep.
* In deadgrep-mode, bind "t" key to `deadgrep-transient`.
* Remove suffixes, "Search in project root", "Search in current directory".
* Add suffixes, "Restart search with new term", "New search".
@iquiw
Copy link
Contributor Author

iquiw commented Mar 5, 2025

  • This currently provides 2 transient suffixes, "Search in project root" and "Search in current directory",
    but I am considering if it is better to add transient infix to set the search directory instead.

Implemented the above change.

iquiw added 7 commits March 8, 2025 16:17
It sets deadgrep options according to transient arguments and writes
heading.
When `deadgrep-transient-menu` is called, the values are initialized as
follows.

1. If it is called from deadgrep results buffer, initialized with options
   in the previous search.
2. If there is saved value of `deadgrep-transient-prefix`, initialized with
   the saved value.
3. Otherwise, initialized with default value.
@arminfriedl
Copy link

Just as an additional data point: I'd be looking forward to this being integrated too. Already started writing my own transient when I stumbled across this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants