Epsilon User's Manual and Reference > Commands by Topic > Moving Around > Searching >
Searching Multiple FilesEpsilon provides a convenient grep command that lets you search a set of files. The command prompts you for a search string (all of the search options described above apply) and for a file pattern. By default, the grep interprets the search string as a regular expression (see Regular Expressions). To toggle regular expression mode, press Ctrl-t at any time while typing the search string. The command then scans the indicated files, puts a list of matching lines in the grep buffer, then displays the grep buffer in the current window. Each line indicates the file it came from.
With a numeric argument, this command searches
through buffers instead of files. Instead of prompting for a file
name pattern, Epsilon prompts for a buffer name pattern, and only
operates on those buffers whose names match that pattern. Buffer name
patterns use a simplified file name pattern syntax:
When grep prompts for a file pattern, it shows you the last file pattern you searched inside square brackets. You can press <Enter> to conveniently search through the same files again. (See the grep-default-directory variable to control how Epsilon interprets this default pattern when the current directory has changed.)
By default file patterns you type are interpreted relative to the current buffer's file; see grep-prompt-with-buffer-directory to change this. To repeat a file pattern from before, press Alt-<Up> or Ctrl-Alt-p. (See Command History for details.) You can use extended file patterns to search in multiple directories; see Extended file patterns.
Epsilon skips over any file with an extension listed in grep-ignore-file-extensions; by default some binary file types are excluded. It skips files bigger than 2 GB, the default setting of the grep-ignore-file-max-size variable. It also skips over files matched by the grep-ignore-file-pattern or grep-ignore-file-basename variables (the latter matched against just the base name of the file, not its path, the former matched against the entire file name). The grep-ignore-file-types variable makes grep skip over files that refer to devices, named pipes, or other sorts of special files. You can set the use-grep-ignore-file-variables variable to zero temporarily to have Epsilon ignore all these variables and search every matching file, or use the select-and-grep command, which lets you define custom rule sets for grep. By default, there's a rule set that searches all files, ignoring all the restriction rules in this paragraph.
In a grep buffer, you can move around by using the normal movement commands. Most alphabetic keys run special grep commands. The "N" and "P" keys move to the next and previous matches. The Alt-n and Alt-p keys move to the next and previous files. Alt-] and Alt-[ move to the next and previous searches.
You can easily go from the grep buffer to the corresponding locations in the original files. To do this, simply position point on the copy of the line, then press <Space>, <Enter>, or "E". The file appears in the current window, with point positioned at the beginning of the matching line. Typing "1" brings up the file in a window that occupies the entire screen. Typing "2" splits the window horizontally, then brings up the file in the lower window. Typing "5" splits the window vertically, then brings up the file. Typing the letter 'O' shows the file in the next window on the screen, without splitting windows any further. Typing "Z" runs the zoom-window command, then brings up the file.
When Epsilon wants to search a particular file as a result of a grep command, it first scans the buffers to see if one of them contains the given file. If so, it uses that buffer. If the file doesn't appear in any buffer, Epsilon reads the file into a temporary buffer, does the search, then discards the buffer.
If you want Epsilon to always keep the files around in such cases, set the variable grep-keeps-files to a nonzero value. In that case, grep will simply use the find-file command to get any file it needs to search.
By default, each invocation of grep appends its results to the grep buffer. If you set the variable grep-empties-buffer to a nonzero value, grep will clear the grep buffer at the start of each invocation. Also see the grep-show-absolute-path variable to control the format of file names in the grep buffer, and the wrap-grep variable to control whether grepping sets the current window to wrap long lines.
You can move from match to match without returning to the grep buffer. The Ctrl-x Ctrl-n command moves directly to the next match. It does the same thing as switching to the grep buffer, moving down one line, then pressing <Space> to select that match. Similarly, Ctrl-x Ctrl-p backs up to the previous match.
Actually, Ctrl-x Ctrl-n runs the next-position command. After a grep command, this command simply calls next-match, which moves to the next match as described above. If you run a compiler in a subprocess, however, next-position calls next-error instead, to move to the next compiler error message. If you use the grep command again, or press <Space> in the grep buffer to select a match, or run next-match explicitly, then next-position will again call next-match to move to the next match.
Similarly, Ctrl-x Ctrl-p actually runs previous-position, which calls either previous-error or previous-match, depending upon whether you last ran a compiler or searched across files.