1

I employed find within the current directory to find files containing "emacs"

$ find . -type f -iname "*emacs*" | nl | tail -3
    34  ./sources/tech/20190916 The Emacs Series Exploring ts.el.md
    35  ./sources/tech/20200311 What you need to know about variables in Emacs.md
    36  ./sources/tech/20191009 The Emacs Series ht.el- The Hash Table Library for Emacs.md

Get a result of 36 files,

When come to Emacs "find-name-dired", but find only one file

2637215      8 -rw-rw-r--   1 me   me       7708 Dec 19 20:48 sources/tech/20191218\ Emacs\ for\ Vim\ users-\ Getting\ started\ with\ the\ Spacemacs\ text\ editor.md

What's the problem?

3

tl;dr

Do you get the expected behavior under emacs -Q? It's possible you've disabled case-insensitivity.

Long answer

Without knowing your arguments to find-name-dired (you should add them to your question) it's hard to say. If you included the double quotes, Emacs will escape them and find will look for files that include them. Based on your output that doesn't seem to be the case. It's possible you've run into a case-sensitivity issue and you triggered on the "emacs" in "Spacemacs", not the "emacs" in "...Emacs for Vim...".

(The following is based on Emacs 26.2)

By default (ie under emacs -Q) find-name-dired is case insensitive, but that's configurable. From the documentation of find-name-dired (via Ctrl-H f find-name-dired RET):

find-name-dired is an interactive autoloaded Lisp function in
‘find-dired.el’.

(find-name-dired DIR PATTERN)

Search DIR recursively for files matching the globbing pattern PATTERN,
and run Dired on those files.
PATTERN is a shell wildcard (not an Emacs regexp) and need not be quoted.
The default command run (after changing into DIR) is

    find . -name 'PATTERN' -ls

See ‘find-name-arg’ to customize the arguments.

If we follow the docs to find-name-arg, we find:

find-name-arg is a variable defined in ‘find-dired.el’.
Its value is "-iname"

Documentation:
Argument used to specify file name pattern.
If ‘read-file-name-completion-ignore-case’ is non-nil, -iname is used so that
find also ignores case.  Otherwise, -name is used.

You can customize this variable.

This variable was introduced, or its default value was changed, in
version 22.2 of Emacs.

And again to read-file-name-completion-ignore-case:

read-file-name-completion-ignore-case is a variable defined in ‘minibuffer.el’.
Its value is t

Documentation:
Non-nil means when reading a file name completion ignores case.

You can customize this variable.

This variable was introduced, or its default value was changed, in
version 22.1 of Emacs.

So, if your find-name-arg is not "-iname" and/or your read-file-name-completion-ignore-case is nil, find-name-dired will be case sensitive. Check your init files (and custom.el), to find when these variables have been changed. Also, you can use find-dired to set the arguments to find yourself.

1
  • 1
    The default value of read-file-name-completion-ignore-case depends on the operating system, it's t when the default file system is not case sensitive (ms-dos, windows-nt, darwin, cygwin) (deleted and reposted comment, the original one had spelling errors)
    – matteol
    Mar 20 '20 at 9:44

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.