1

Windows 10, Emacs 26.1 dired+

I want in dired mode find files by names, content

  1. Approach#1 - use external tools. What tools you can suggest?
  2. Approach#2 - use only built-in Emacs function on external lib - What you can suggest?
  • If you don't know rgrep and lgrep you should certainly look them up. – mikado May 18 at 13:32
3

I think you're asking how to find files by matching both their file names and the file contents. Is that it?

If so, Icicles does this for you, in all of its file-finding commands.

The commands use multi-completion: The input you type can be two-part: (1) a pattern that matches the file name, (2) a pattern that matches the file content.

You can use only one of the two possible patterns if you like. For example, you will most often just type a file-name pattern. In that case, the behavior is like find-file (but a very enhanced find-file).

When you type input for the command, if you use C-M-j that separates the two patterns. The file-name pattern is first, then C-M-j, then the file-content pattern.

This is described in detail here: File-Name Input. The name-and-content-matching behavior is described here.

In Icicles during completion your input patterns can use regexp matching (which Icicles calls apropos completion).


You ask also about Dired.

In a Dired buffer, there are related content-matching commands you can use to visit the marked files and subdirectories whose content matches a regexp.

icicle-visit-marked-file-of-content, bound to C-S-f, aka C-F, icicle-visit-marked-file-of-content-recursive, bound to M-+ C-F.

The latter visits not only the files that are marked in the current directory, but also those marked in any marked subdirectories, and sub-subdirectories etc., recursively. (For these recursively descending searches you need Dired+.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.