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

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

Re: grep excludes


From: B.V. Raghav
Subject: Re: grep excludes
Date: Thu, 07 Jul 2016 11:45:40 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

bvraghav@iitk.ac.in (B.V. Raghav) writes:

> (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 '

HTH

-- 
(B.V. Raghav)
Ph.D. Student,
Design Programme, IIT Kanpur



reply via email to

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