I occasionally find myself using Nautilus instead of dired to search for files and would like to change that. When looking for a file, I often don't know the capitalization of its name which is why I like case-insensitive searches. Additionally, I almost always search for something in the middle of the file's name.

I think I can likely (i.e. p > .4) figure out myself how to write a function which always gives the same directory to find-name-dired and adds stars to both ends of its argument (so I can search for any substring).

However, I do not know how tell find-name-dired to tell find to ignore case. Basically I want find-name-dired to pass -iname to find instead of -name.

My question isn't necessarily about making find-name-dired do that. If there is a better way to achieve my goal, please tell me about it. It doesn't need to involve find-name-dired.


To answer your question about find-name-dired, according to its manual page (C-h f find-name-dired):

The default command run (after changing into DIR) is

find . -name 'PATTERN' -ls

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

If you go to find-name-arg manual page, you get:

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

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.

So you can use M-x customize-variable RET find-name-arg to set your desired value, or you can add this to your init file:

(require 'find-dired)
(setq find-name-arg "-iname")

I solved the problem by defining this function + shortcut:

(defun find-in-current-location ()
  (find-dired dired-directory (concat "-iname \"*" (read-from-minibuffer "Search for: ") "*\"")))
(global-set-key (kbd "C-c f") 'find-in-current-location)

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.