Skip to content

Conversation

@pierre-rouleau
Copy link
Contributor

@pierre-rouleau pierre-rouleau commented Jan 20, 2025

Add the deadgrep-extra-searched-directories user-option.

  • That's an association list:
    • key := directory context : a string identifying a directory tree used as a context
    • value :=
      • a boolean identifying whether the directory context should be search (true by default)
      • a list of other directory trees to search when the user performs a search inside the directory or sub-directory of the corresponding directory context.

By default deadgrep-extra-searched-directories is nil, and deadgrep continues to behave as before.

If deadgrep-extra-searched-directories holds something and inside there's a key that is equal to the default-directory, then the ripgrep command line is set to search the directory/ies identified in the list associated with the alist element value.

If the default-directory does not match any identified directory context (or is one of the sub-directory of an identified directory context), deadgrep uses "." as before and ends up behaving as before.

This provides the ability to set up a list of directory contexts to pre-define the directories that are effectively searched by deadgrep. The real advantage is that this list can contain a set of non-overlapping directories to search (and the original directory if that's needed), something like /etc and /usr for example.

It works with Tramp syntax as well, as long as the user reads the description in the customization buffer when entering the paths of the extra directories.

This is one way of addressing #162

@Wilfred I think what is inside the commits of this PR is complete. I have been using it and all works fine.
The code added in inside deadgrep--arguments which deals with possible entries in deadgrep-extra-searched-directories user-option`.

Add the deadgrep-extra-searched-directories user-option.
- That's an association list:
  - key   := directory context : a string identifying a directory context
  - value := list of directories to search when the directory context is
             selected in the Directory field.

By default this is nil, and deadgrep continues to behave as before.

If deadgrep-extra-searched-directories holds something and inside there's a
key that is equal to the default-directory, then the ripgrep command line
is set to search the directory/ies identified in the list associated with the
alist elment value.

If no key match the default-directory, deadgrep uses "." as before and ends up
behaving as before.

This provides the ability to set up a list of directory contexts to pre-define
the directories that are effectively searched by deadgrep.  The real
advantage is that this list can contain a set of non-overlapping directories
to search (and the original directory if that's needed), something like /etc
and /usr for example.

It works with Tramp syntax as well, as long as the user reads the description
in the customization buffer when entering the paths of the extra directories.
Ensures that dir name comparison is done on fully expanded directories,
allowing ~ in the names placed in the customized list.
- The check for directory context treats the Context Directory as a directory
  tree; searching inside any of it's sub-directory will include the context.
- The context directory is now include in the search by default.  However the
  user can explicitly excluded it via customization.
- Improved the description of the `deadgrep-extra-searched-directories'
  user-option.  Also added tags to provide information in the customize buffer
  during data entry.
The use of context-based extra directories was always added in the last
instance of the code instead of being included only when the extra context
directory matched the current directory as the intent was.
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.

1 participant