grep can be used to find strings in files. But I'm not interested in backup files (those whose name ends with a
How should I ignore those files when using the
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
rgrep as convenient interfaces for
grep. These commands may invoke
grep on the command line with
grep options systematically (see also the GNU Emacs Reference Manual). More specifically, the user option
grep-find-ignored-files (discovered after searching in the source code and in the integrated documentation) may be set to ignore some files.
M-x customize-variable Customize variable: grep-find-ignored-files
However, the variable
grep-find-ignored-files already contains the value
*~ in my default setting so
rgrep ignore backup files.
In my GNU environment, the variable allows to add several
--exclude= options on the command line to
grep when a user invokes
Note: The user may modify the settings globally by customizing the group
You could put your backup files somewhere else. When you do a grep emacs will ask for the root directory for the search, defaulting to the current directory. You could specify a directory for the backup files that is outside the places you usually search. You can do this by setting backup-directory-alist.
(setq backup-directory-alist `(("." . "~/.saves")))
Full details are here: How do I control how Emacs makes backup files?