Whenever I'm using M-x rgrep
to search inside my project arborescence, the interactive prompts suggest the following default arguments for the function:
Search for (default: <current word>)
(OK, always what I want)
Search for <current word> in files (default: *.<extension of the current file>)
(mostly OK, not always what I want but I can live with that)
Base directory: <current directory>
(not OK, I never want it to use the current directory)
I like the first proposed argument, but I'd like to change the second one, and especially the third one, to use other defaults (such as "parent directory" instead of "current directory").
How can I modify rgrep
so that (1) either it remains interactive, but proposes different default values, or (2) it becomes non-interactive, but uses the word currently under the cursor as first argument?
interactive
spec can do anything you like, and it can copy some of its code from the originalinteractive
spec, or otherwise be inspired from it. @Francesco's answer shows you examples of this.interactive
such as the EmacsWiki RecursiveGrep page, but I had failed to find one that showed how to change the default arguments while still allowing the user to modify them. His example is indeed what I wanted.