help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep excludes


From: Rusi
Subject: Re: grep excludes
Date: Thu, 7 Jul 2016 20:24:32 -0700 (PDT)
User-agent: G2/1.0

On Friday, July 8, 2016 at 8:41:23 AM UTC+5:30, Rusi wrote:
> On Friday, July 8, 2016 at 8:35:58 AM UTC+5:30, Rusi wrote:
> > On Thursday, July 7, 2016 at 11:46:02 AM UTC+5:30, B.V. Raghav wrote:
> > > 
> > > > (defun my-grep(pattern file-name)
> > > >   "My own version of grep command"
> > > >   (interactive "sPattern: \nFFind %s in file(s): ")
> > > >   (let ((cmd "grep -e"))
> > > >     ;;       ^^^^^^^^^ My Grep Command
> > > >     (grep (message "%s %s %s" cmd pattern file-name))))
> > > >
> > > > If I understand correctly, you requires the change of command as
> > > > mentioned here.
> > > >
> > > > HTH
> > > 
> > > On second thoughts, the following set should be helpful:
> > > 
> > > (defun my-grep-base(grep-cmd params)
> > >   (grep (format "%s %s %s" grep-cmd (car params) (cadr params))))
> > > 
> > > (defun my-grep-params(pattern file-name)
> > >   "My own version of grep command"
> > >   (interactive "sPattern: \nFFind %s in file(s): ")
> > >   (list pattern file-name))
> > > 
> > > (defun my-grep()
> > >   (interactive)
> > >   (my-grep-base "grep -e" (call-interactively #'my-grep-params)))
> > > 
> > > (defun my-lgrep()
> > >   (interactive)
> > >   (my-grep-base "lgrep -e" (call-interactively #'my-grep-params)))
> > > 
> > > (defun my-rgrep()
> > >   (interactive)
> > >   (my-grep-base "rgrep -e" (call-interactively #'my-grep-params)))
> > > 
> > > and you can define lgrep and rgrep in your .bashrc (or .bash_aliases) as 
> > > follows:
> > > 
> > > alias lgrep='grep -n '
> > > alias rgrep='grep -nR '
> > 
> > Thanks for trying Raghav but as of now it does:
> > --------------------------------
> > -*- mode: grep; default-directory: "~/vit-projects-common-wiki/" -*-
> > Grep started at Fri Jul  8 08:32:13
> > 
> > lgrep -e emacs ~/vit-projects-common-wiki/ /dev/null
> > /bin/bash: lgrep: command not found
> > 
> > Grep exited abnormally with code 127 at Fri Jul  8 08:32:13
> > ------------------------------
> 
> And when I change the lgrep defun to:
> 
> (defun my-lgrep()
>   (interactive)
>   (my-grep-base "grep -e" (call-interactively #'my-grep-params)))
> 
> in order to remove gratuitous dependency on a shell lgrep
> 
> I get:
> -*- mode: grep; default-directory: "~/vit-projects-common-wiki/" -*-
> Grep started at Fri Jul  8 08:40:04
> 
> grep -e emacs ~/.emacs.d/setups/grepsetup.el /dev/null
> 
> Grep finished with no matches found at Fri Jul  8 08:40:04

For now with:

grep-find-ignored-directories set to (".git" ".hg" "__pycache__")))

and

grep-find-ignored-files set to  (".#*" "*.o" "*.elc" "*.pyc")))

I get things like this:

-*- mode: grep; default-directory: "~/vit-projects-common-wiki/" -*-
Grep started at Fri Jul  8 08:48:12

grep  --exclude=.\#\* --exclude=\*.o --exclude=\*.elc --exclude=\*.pyc -i 
--color -nH -e emacs * .*
followed by the real grep output
without too many false positives

Sure one line of output would be better than 4 but its ok ... can live with it


reply via email to

[Prev in Thread] Current Thread [Next in Thread]