Commits

Anonymous committed e999851

Updated to igrep 2.87

Comments (0)

Files changed (1)

+;;; -*-unibyte: t;-*-
+
 ;;;; igrep.el --- An improved interface to `grep` and `find`.
 
-;;; SCCS @(#)igrep.el	2.83
+;;; SCCS @(#)igrep.el	2.87
 
 ;;; Description:
 ;;; 
 
 ;;; Copyright:
 ;;; 
-;;; Copyright ,A)(B 1994,1995,1996,1997,1998 Kevin Rodgers
+;;; Copyright Š 1994,1995,1996,1997,1998,2000 Kevin Rodgers
 ;;; 
 ;;; This program is free software; you can redistribute it and/or modify
 ;;; it under the terms of the GNU General Public License as published by
 ;;; To avoid exceeding some shells' limit on command argument length
 ;;; (this only searches files in the current directory):
 ;;; 	(setq igrep-find t
-;;; 	      igrep-find-prune-clause "\\! -name .")
+;;; 	      igrep-find-prune-clause "-type d \\! -name .")
 
 ;;; To do:
 ;;; 
 ;;; 4. Add a menu interface.
 ;;; 5. Port to Emacs 20.
 
-;;; LCD Archive Entry:
-;;; 
-;;; igrep|Kevin Rodgers|kevinr@ihs.com|
-;;; An improved interface to `grep` and `find`.|
-;;; 98/08/06|2.83|~/misc/igrep.el.Z|
+;;; Emacs Lisp Archive Entry:
+;;; Filename: igrep.el
+;;; Author: Kevin Rodgers <kevinr@ihs.com>
+;;; Version: 2.87
+;;; Description: An improved interface to `grep` and `find`.
+;;; Keywords: search
+;;; Last-Updated: 00/07/20
 
 
 ;;; Package interface:
 
 (provide 'igrep)
 
-(require 'compile)			; compile-internal, grep-regexp-alist
+(require 'compile)			; compile-internal, grep-regexp-alist,
+					; grep-null-device
 
 (eval-when-compile
   (require 'dired)			; dired-directory,
 	(error nil)))
   )
 
-(defconst igrep-version "2.83"
+(defconst igrep-version "2.87"
   "Version of igrep.el")
 
 
 
 ;;; User variables:
 
+(defvar igrep-null-device
+  (cond ((boundp 'grep-null-device) grep-null-device) ; Emacs 19
+	((boundp 'null-device) null-device))) ; Emacs 20
+
 (defvar igrep-program "grep"
   "The default program run by `\\[igrep]' and `\\[igrep-find]'.
 It must accept a `grep` expression argument and one or more file names, plus
 
 (defvar igrep-expression-option
   (if (equal (call-process igrep-program nil nil nil
-			   "-e" "foo" grep-null-device)
+			   "-e" "foo" igrep-null-device)
 	     1)
       "-e")
   "If non-nil, the option used to specify the EXPRESSION argument to `\\[igrep]',
 
 (defvar igrep-find-prune-clause
   (if (equal (call-process igrep-find-program nil nil nil
-			   grep-null-device "-prune")
+			   igrep-null-device "-prune")
 	     0)
-      (format "%s -name SCCS -o -name RCS %s"
+      (format "-type d %s -name RCS -o -name CVS -o -name SCCS %s"
 	      (shell-quote-argument "(")
 	      (shell-quote-argument ")")))
   "The `find` clause used to prune directories, or nil;
 see `igrep-find'.")
 
-(defvar igrep-find-file-clause "-type f"
-  ;; (format "%s -type f -o -type l %s" ...)
+(defvar igrep-find-file-clause
+  (format "-type f %s -name %s %s -name %s %s -name %s" ; -type l
+	  (shell-quote-argument "!")
+	  (shell-quote-argument "*~")	; Emacs backup
+	  (shell-quote-argument "!")
+	  (shell-quote-argument "*,v")	; RCS file
+	  (shell-quote-argument "!")
+	  (shell-quote-argument "s.*"))	; SCCS file
   "The `find` clause used to filter files passed to `grep`, or nil;
 see `igrep-find'.")
 
 (defvar igrep-find-use-xargs
   (if (equal (call-process igrep-find-program nil nil nil
-			   grep-null-device "-print0")
+			   igrep-null-device "-print0")
 	     0)
       'gnu)
   "If `gnu', `\\[igrep-find]' executes
   "The default `grep` program, passed by `igrep-read-program'
 to `completing-read' when `igrep-program' is nil.")
 
+
+;;; Internal variables:
+
 (defvar igrep-expression-history '()
   "The minibuffer history list for `\\[igrep]'s EXPRESSION argument.")
 
       (setq options igrep-options))
   (if (not (listp files))		; (stringp files)
       (setq files (list files)))
-  (if (save-match-data
-	(string-match "\\`[rj]?sh\\(\\.exe\\)?\\'"
-		      (file-name-nondirectory shell-file-name)))
+  (if (and (member ?~ (mapcar 'string-to-char files))
+	   (save-match-data
+	     (string-match "\\`[rj]?sh\\(\\.exe\\)?\\'"
+			   (file-name-nondirectory shell-file-name))))
       ;; (restricted, job-control, or standard) Bourne shell doesn't expand ~:
       (setq files
 	    (mapcar 'expand-file-name files)))
 				  ""
 				(shell-quote-argument "{}"))
 			    (mapconcat 'identity files " "))
-			  grep-null-device)))
+			  igrep-null-device)))
     (if igrep-find
 	(setq command
 	      (igrep-format-find-command command files)))
   "*Run `grep` on the marked (or next prefix ARG) files.
 See `\\[igrep]'."
   (interactive
-   (let* ((current-prefix-arg nil)
-	  (igrep-args (igrep-read-args t)))
+   (let ((igrep-args
+	  (let ((current-prefix-arg nil))
+	    (igrep-read-args t))))
      ;; Delete FILES:
      (setcdr (nthcdr 1 igrep-args) (nthcdr 3 igrep-args))
      ;; Append ARG:
   "*Run `grep` on the marked (or next prefix ARG) directories.
 See `\\[igrep]'."
   (interactive
-   (let* ((current-prefix-arg nil)
-	  (igrep-find t)
-	  (igrep-args (igrep-read-args t)))
+   (let ((igrep-args
+	  (let ((current-prefix-arg nil)
+		(igrep-find t))
+	    (igrep-read-args t))))
      ;; Delete FILES:
      (setcdr (nthcdr 1 igrep-args) (nthcdr 3 igrep-args))
      ;; Append ARG:
 	    (mapconcat 'identity (nreverse directories)
 		       " ")
 	    (if igrep-find-prune-clause
-		(format "-type d %s -prune -o" igrep-find-prune-clause)
+		(format "%s -prune -o" igrep-find-prune-clause)
 	      "")
 	    (or igrep-find-file-clause "")
 	    (if (listp patterns)