Questions tagged [grep]
The grep tag has no usage guidance.
81
questions
0
votes
1
answer
21
views
How to use the Emacs Lisp implementations of several UNIX commands in emacs (outside of eshell)
I am curious, is it possiblie to use the Emacs Lisp implementations of UNIX commands out side of eshell?
For example, can I point grep (or consult-grep) to eshell/grep (instead of the external program)...
1
vote
1
answer
36
views
How to change key binding in grep mode?
The Enter key (RET) is originally bound to the "compile-goto-error" function in grep mode.
But I want to bind it to my function.
The problem is that the keymap has changed, but the function ...
0
votes
2
answers
91
views
How to use grep in windows emacs
I have Emacs installed in my Windows PC, but I'm not able to use grep in that. I got an error saying that it cannot find the path to grep executable.
I found the same question in Stack-overflow, but ...
0
votes
2
answers
63
views
Using a grep like function in lisp
I have a file, and I want to search if a given file has a string.
I want to call that function from an elisp function.
AFAIK, all the grep family of functions open a new buffer.
I only need to know if ...
1
vote
1
answer
55
views
How to grep/sed through a column - the eLisp way?
I want the table formula to basically go through every data line of column $2 between the 1st and 4th hline, looking for a field width flag - in this example <14>* - and as soon as it finds it, ...
0
votes
0
answers
26
views
Temporary change to grep-find-command à la (let ((grep-find-command ...)) ...)
I'm trying to define a function that runs grep-find using a temporary value for grep-find-command. The following almost works:
;; "fe" is the "iron searcher" that I use internally....
0
votes
1
answer
132
views
use `ripgrep` for everything that `grep` would be used for on Windows
Given that grep is not available on windows, I'm trying to use ripgrep as a drop-in replacement so that I can use things like project-find-regexp.
I don't need any extra functionality, just that ...
1
vote
1
answer
89
views
How to ignore some directories with find-grep-dired?
When I search with find-grep-dired it also searches /Library/ directory and finds hundreds of cached links. Is there a way to ignore /Library/ directory?
I found this :
M-x customize-option
<return&...
1
vote
1
answer
55
views
How to create separate buffers from the ouput of grep?
Is there any way to create separate buffers for each file grep locates when running something like
grep 'blabla' *.c
0
votes
2
answers
682
views
consult-man, consult-grep, etc. don't match anything
Emacs 29.0.60 running on Windows 10 with Msys2 and Git for Windows.
I'm trying out the consult package, particularly functions such as consult-grep and consult-man, and I'm finding that I apparently ...
0
votes
1
answer
116
views
using grep on a specific file
I've read, for instance here, that one could just run M-x grep to interface with the underlying shell and just run a simple grep command. I suspect something is wrong in the setup because this simple ...
2
votes
1
answer
137
views
Search whole ebook in nov
nov.el does not provide an easy function to search the whole of the ebook content. Every search performed on buffer only applies to the "document" or chapter of the book on display at that ...
0
votes
1
answer
39
views
"-o" like options for `elgrep`?
Sometimes I just want the matched result by regexp instead of the whole line, this seems possible via the -o option in grep
I discovered elgrep in emacs recently, which is fantastic! Any chance we can ...
0
votes
3
answers
194
views
Why can't counsel-rg index an expression previously found?
I am using trying to use a command called counsel-rg. This is the associated describe-command:
counsel-rg is an autoloaded interactive compiled Lisp function in
‘counsel.el’.
(counsel-rg &...
0
votes
1
answer
37
views
Weird behavior of `search-forward-regexp` influenced by buffer mode change
Action 1: evaluate the lisp expression: (search-forward-regexp "\\s'")
in a buffer in lisp-interaction-mode containing the text:
The pandemic market was cooling, but homes in north Seattle ...
2
votes
1
answer
314
views
Case insensitive search with M-x find-grep-dired
I’m trying to do a case insensitive search with M-x find-grep-dired. When I enter M-x find-grep-dired and hit ENTER and enter the directory name I get the prompt find-grep (grep regexp):. I understand ...
0
votes
1
answer
239
views
How to exclude certain files from helm-do-grep-1
Suppose, we have the following files: ~/1.js, ~/1.min.js, ~/bad-dir/2.js.
All of them have the following contents:
function hello () {}
I am using helm-do-grep-1 to grep through these files and want ...
1
vote
2
answers
388
views
grep contents of a set of files from find
I want to grep contents of all CMakeLists.txt files in a project (nested within a directory) so I can jump from each instance, like I would when running emacs grep function. In the examples below I'm ...
3
votes
2
answers
2k
views
Filter text of buffer in a grep-like way
I want to filter the text of an emacs buffer, a bit like you can filter text with grep.
Sounds simple, but I tried googling it and I only get results from people who want to search in a buffer or to ...
0
votes
1
answer
261
views
How do I make `helm` save search results in a grep buffer?
I do helm-find-files (C-x c C-x C-f>), Tab, "Grep current directory with AG" (M-g a), enter pattern, Tab, "Save results in grep buffer" (F3). Now, how do I make M-g M-n/M-g M-p ...
4
votes
0
answers
712
views
How to exclude certain directories/files from `consult-git-grep` search?
I want to exlude certain files such as .gitignore in consult-git-grep search.
consult-git-grep works find with following defualt setup:
(setq consult-git-grep-args "git --no-pager grep -F -n --...
1
vote
0
answers
324
views
How to exclude certain directories/files from counsel-git-grep search?
Would it be possible to exclude certain directories/files from counsel-git-grep search, such as .gitignore?
Here I don't want to see matches in .gitignore file:
I have tried adding ':(exclude)....
0
votes
1
answer
852
views
How to filter search results by path pattern?
I'm using Projectile with ripgrep.
I can search project lines by some pattern, as an example:
test 42 will match strings like this so, test is not 42 at all
I would like to be able to add additional ...
0
votes
1
answer
152
views
How can I get projectile-grep et al to choose the project before searching?
Projectile-grep, projectile-ag et al always execute the search in the current file's project.
What I want to do is to select the project from a completion list and get projectile to search that ...
0
votes
1
answer
136
views
Run grep (like this)
I use the standard grep command a lot. When I execute it, the minibuffer is populated with the following the text, allowing me to complete the command:
Run grep (like this): grep --color -nH --null -e ...
1
vote
1
answer
218
views
Is there a way to narrow down grep results?
When I search with grep, I get the results like:
-- mode: grep; default-directory: "~/code/" -- Grep started at Wed Feb 24 12:40:28
find . -type d ...
that is followed by multiple lines ...
0
votes
2
answers
216
views
Position the cursor at a specific point in a custom Emacs grep command
I have created this custom grep command in Emacs to search for contacts:
'(grep-command
"grep --color -nH --null grep -ie '^name' -A 1 ~/diary/*.org")
I would like to be able to ...
0
votes
0
answers
119
views
How to use helm to search a buffer?
I would like to use the helm machinery to search "live" a buffer's lines.
Is this possible? If not how would I go about figuring out how to implement this?
0
votes
0
answers
64
views
How can we save all the grep searches (using `M-x grep`) into history?
How can we save and retrieve all the grep searches that we do using M-x grep command into history ?
2
votes
1
answer
183
views
How to control the way windows are opened by "next-error" and "previous-error"?
The context
In the gif shown below, I demostrate that the way next-error show the current error in a new window depends on the size of the font.
When using the font Fira Code 20, a single window is ...
1
vote
2
answers
635
views
Efficiently calling multiple variants of the grep command
The context
I commonly execute the following variants of the grep command
grep --color -RHIn '' (search in the current working directory)
grep --color -RHIn --include='*.org' '' ~/repos/dotfiles/...
2
votes
3
answers
98
views
emacs grep eliminate suspects
Typically, at the beginning of a coding/maintenance task, I usually start with a carefully worded grep, such as
M-x grep
git --no-pager grep -n -e 'collect' -- ':!*spec*' ':!*.yml'<enter>
and ...
4
votes
2
answers
325
views
How to keep grep results in eshell buffer
When entering the grep command in an eshell in spacemacs, a separate window and buffer are created to list the grep output results. However, I would prefer for the output to be listed in the eshell ...
0
votes
1
answer
50
views
List all empty checkboxes in files
Is there any easy way, including installing a package, to list all waiting checkboxes in all the files in the directory?
So far I do the following for the checkboxes in a file:
M-x occur - \[ \]
...
0
votes
1
answer
251
views
Emacs wsl grep fails on special characters
I'm using GNU Emacs 26.3 on a Windows 10 system (Virtualbox guest on Mac).
The following grep command inside emacs fails:
grep -i -n -d skip -e temp_ *
with this error:
grep -i -n -d skip -e temp_ ...
1
vote
0
answers
121
views
Abort output in currently executing command in shell mode
Sometimes in shell I end up executing a command which results in too much output.
For example, consider a wrong grep on a huge text file which results in 10,000 matches. The grep command completes ...
1
vote
1
answer
343
views
Automatic "push-mark" when navigating with xref, find-grep, etc?
There seem to be a lot of situations, where a command changes the cursor location (point), but no mark is pushed, making navigating back by popping the mark with C-u SPC impossible.
For isolated use-...
2
votes
0
answers
78
views
Helm Grep within a first results set / multi line search
I would like to use helm to search for two terms which may well be on different lines.
Is there a way to grep for the first term then further grep within the resulting fileset the second term?
eg
...
5
votes
0
answers
329
views
Sort ripgrep results based on proximity to current buffer
I use counsel-projectile-rg to search within the project I work on. But there is my sub-project inside this big repo that most of my development is in.
Is there a way to sort ripgrep results based on ...
0
votes
2
answers
863
views
How can I do a regex search recursively from a directory?
Basically I want a command that can do the following:
find /path/dir -type f -print0 | xargs -0 grep -l "foo"
Is there an emacs command to do this? If not, then is there a convenient keybinding that ...
3
votes
1
answer
1k
views
How to use `next-error` and `previous-error` without the compilation buffer visible
I want to be able to use grep to find matching lines and to be able to jump through them using next-error and previous-error however I don't feel the need to have the match list on screen and it takes ...
2
votes
1
answer
200
views
eshell grep thinks options are patterns on windows
I'm using Emacs on windows, and was trying to run grep from within eshell (M-x eshell). The default shell through M-x is cmd.exe, but eshell has linux utilities so I'm trying to use eshell.
Now, ...
1
vote
1
answer
72
views
Does grepping via helm support searching for multiple words in any order like other helm completions?
When searching multiple terms with Helm separated with spaces then Helm returns the results which mach the terms in any order. This is good.
Sometimes I try grep via helm. E.g. I use helm-recentf to ...
4
votes
4
answers
2k
views
Grep pipe support and how to filter grep results
I try to filter the output of M-x grep with grep --color=always -nH -e "text_to_find" ~/path/to/files/*.org | grep -v "text_to_ignore" but it doesn't seem to be working. The 'to be ignored' part is ...
0
votes
0
answers
133
views
Search in recent files
I use helm-recentf to receive the list of recent files.
I would like to have an opportunity to search over the list of recently viewed files.
Can I do it with grep or helm-swoop? Is there any other ...
0
votes
1
answer
201
views
Cannot jump to file or location link in grep-mode or compile-mode
I have recently installed emacs on a new system (Manjaro arch-linux), using my usual configuration (available here, if relevant).
However, the jump function never works on this new system: whenever ...
1
vote
0
answers
119
views
How to make `helm-projectile-grep` do a recursive search?
I use helm with projectile and treemacs, how do I make helm-projectile-grep command to search in all project folders recursively starting at the project root. According to this page helm-projectile ...
3
votes
3
answers
794
views
How to ignore backup files (~) when running grep?
M-x 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 grep command?
2
votes
1
answer
1k
views
Grep exited abnormally with code 2
Windows 10, Emacs 26.1
M-x shell
grep
here result:
grep
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
Nice.
Now I want to find files in temp folder:
rgrep
...
3
votes
2
answers
450
views
Unable to visit file from grep results
I recently updated to emacs 26.1. Since then, grep results are not highlighted and does not contain links to files. 'n' or 'p' gives "Moved past last grep hit" or "Moved back before first grep hit".
...