Anonymous avatar Anonymous committed 908e191

igrep.el-2.83

Comments (0)

Files changed (3)

+1998-08-11  SL Baur  <steve@altair.xemacs.org>
+
+	* igrep.el-2.83.
+
 1998-01-24  SL Baur  <steve@altair.xemacs.org>
 
 	* Makefile (VERSION): Update to package standard 1.0.
 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-VERSION = 1.01
-AUTHOR_VERSION =
+VERSION = 1.02
+AUTHOR_VERSION = 2.83
 MAINTAINER = XEmacs Development Team <xemacs-beta@xemacs.org>
 PACKAGE = igrep
 PKG_TYPE = regular
 
 include ../../XEmacs.rules
 
-all:: $(ELCS) auto-autoloads.elc custom-load.elc
+all:: $(ELCS) auto-autoloads.elc
 
 srckit: srckit-std
 
-;;;; igrep.el --- An improved interface to `grep`.
+;;;; igrep.el --- An improved interface to `grep` and `find`.
+
+;;; SCCS @(#)igrep.el	2.83
 
 ;;; Description:
 ;;; 
-;;; Define the \[igrep] command, which is like \[grep] except that it
-;;; takes three required arguments (PROGRAM, EXPRESSION, and FILES) and
-;;; an optional argument (OPTIONS) instead of just one argument (COMMAND).
-;;; Also define the analogous \[egrep] and \[fgrep] commands for convenience.
+;;; The `igrep' command is like `grep' except that it takes three
+;;; required arguments (PROGRAM, EXPRESSION, and FILES) and an optional
+;;; argument (OPTIONS) instead of just one argument (COMMAND).  The
+;;; analogous `egrep' and `fgrep' commands are also defined for
+;;; convenience.
 ;;; 
-;;; Define the \[igrep-find] command, which is like \[igrep] except that
-;;; it uses `find` to recursively `grep` a directory.  Also define the
-;;; analogous \[egrep-find] and \[fgrep-find] commands for convenience.
+;;; The `igrep-find' command is like `igrep' except that it uses `find`
+;;; to recursively `grep` a directory.  The analogous `egrep-find' and
+;;; `fgrep-find' commands are also defined for convenience.
 ;;; 
-;;; \[igrep] and \[igrep-find] (and their analogues) provide defaults
-;;; for the EXPRESSION and FILES arguments when called interactively,
-;;; and there are global variables that control the syntax of the `grep`
-;;; and `find` shell commands that are executed.  A user option controls
-;;; whether the corresponding GNU (gzip) "zPROGRAM" script is used, to
-;;; `grep` compressed files.
+;;; When called interactively, `igrep' and `igrep-find' (and their
+;;; analogues) provide defaults for the EXPRESSION and FILES arguments
+;;; based on the current word and the visited file name (if the
+;;; `igrep-expression-default' and `igrep-files-default' options are
+;;; set, respectively).  Other options that control the user interface
+;;; are `igrep-read-options', `igrep-read-multiple-files',
+;;; `igrep-verbose-prompts', and `igrep-save-buffers'.
 ;;; 
-;;; \[agrep] and \[agrep-find] are also defined as convenient interfaces
-;;; to the approximate `grep` utility, which is distributed with the
-;;; `glimpse' indexing and query tool (available from
+;;; Besides the basic `igrep-program' and `igrep-find-program' global
+;;; variables, other variables control the syntax of the `grep` and
+;;; `find` shell commands that are executed: `igrep-options',
+;;; `igrep-expression-option', `igrep-find-prune-clause',
+;;; `igrep-find-file-clause', and `igrep-find-use-xargs'.
+;;; 
+;;; The `igrep-use-zgrep' user option controls whether the corresponding
+;;; GNU (gzip) "zPROGRAM" script is used, to `grep` compressed files.
+;;; Special minibuffer history lists are maintained for the EXPRESSION
+;;; and FILES arguments.
+;;; 
+;;; The `agrep' and `agrep-find' commands are interfaces to the
+;;; approximate `grep` utility, which is distributed with the `glimpse'
+;;; indexing and query tool (available from
 ;;; <URL:http://glimpse.cs.arizona.edu:1994/>).
 ;;; 
-;;; \[grep] itself is advised to provide the \[igrep] interface when
-;;; called interactively (when called programmatically, it still uses
-;;; the original argument list).  \[grep-find] is defined as an alias
-;;; for \[igrep-find].
+;;; `grep' itself can be advised to provide the `igrep' interface when
+;;; it is invoked interactively (so that when it's called
+;;; programmatically, it still uses the original argument list), via the
+;;; `igrep-insinuate' command.  `igrep-insinuate' also defines
+;;; `grep-find' as an alias for `igrep-find', `dired-do-grep' and
+;;; `dired-do-grep-find' as aliases for `dired-do-igrep' and
+;;; `dired-do-igrep-find', and `Buffer-menu-grep' as an alias for
+;;; `Buffer-menu-igrep'.
 ;;; 
-;;; When run interactively from Dired mode, the various \[igrep]
-;;; commands provide defaults for the EXPRESSION and FILES arguments
-;;; that are based on the visited directory (including any inserted
-;;; subdirectories) and the current file.  In addition, the
-;;; \[dired-do-igrep] and \[dired-do-igrep-find] commands are defined
-;;; that respect the `dired-do-*' command calling conventions: a prefix
-;;; argument is interpreted as the number of succeeding files to `grep`,
-;;; otherwise all the marked files are `grep`ed.  \[dired-do-grep] and
-;;; \[dired-do-grep-find] are defined as aliases for \[dired-do-igrep]
-;;; and \[dired-do-igrep-find].
+;;; When run interactively from Dired mode, the various `igrep' commands
+;;; provide defaults for the EXPRESSION and FILES arguments that are
+;;; based on the visited directory (including any inserted
+;;; subdirectories) and the current file.  The alternative
+;;; `dired-do-igrep' and `dired-do-igrep-find' commands respect the
+;;; `dired-do-*' command calling conventions: a prefix argument is
+;;; interpreted as the number of succeeding files to `grep`, otherwise
+;;; all the marked files are `grep`ed.
+;;; 
+;;; The `igrep-visited-files' command provides a simple way to `grep`
+;;; just those files that are being visited in buffers.  The
+;;; `Buffer-menu-igrep' command does the same thing, for buffers marked
+;;; for selection in Buffer Menu mode.
 
 ;;; Copyright:
 ;;; 
-;;; Copyright  1994,1995,1996,1997 Kevin Rodgers
+;;; Copyright ,A)(B 1994,1995,1996,1997,1998 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
 ;;; Information Handling Services, respectively) has disclaimed any
 ;;; copyright interest in igrep.el.
 ;;; 
-;;; Kevin Rodgers <kevinr@ihs.com>		Project Engineer
-;;; Information Handling Services		Electronic Systems Development
-;;; 15 Inverness Way East, M/S A201		
-;;; Englewood CO 80112 USA			(303)397-2807[voice]/-2779[fax]
+;;; Kevin Rodgers <kevinr@ihs.com>          Lead Software Engineer
+;;; Information Handling Services           Electronic Systems Development
+;;; 15 Inverness Way East, M/S A201         GO BUFFS!
+;;; Englewood CO 80112-5776 USA             1+ (303) 397-2807[voice]/-2244[fax]
 
 ;;; Installation:
 ;;; 
 ;;;    performance.  You can ignore any warnings about references to free
 ;;;    variables and "not known to be defined" functions.
 ;;; 2. Put these forms in default.el or ~/.emacs:
-;;;    (autoload (function igrep) "igrep"
+;;;    (autoload 'igrep "igrep"
 ;;;       "*Run `grep` PROGRAM to match EXPRESSION in FILES..." t)
-;;;    (autoload (function igrep-find) "igrep"
+;;;    (autoload 'igrep-find "igrep"
 ;;;       "*Run `grep` via `find`..." t)
-;;;    (autoload (function dired-do-igrep) "igrep"
+;;;    (autoload 'igrep-visited-files "igrep"
+;;;       "*Run `grep` ... on all visited files." t)
+;;;    (autoload 'dired-do-igrep "igrep"
 ;;;       "*Run `grep` on the marked (or next prefix ARG) files." t)
-;;;    (autoload (function dired-do-igrep-find) "igrep"
+;;;    (autoload 'dired-do-igrep-find "igrep"
 ;;;       "*Run `grep` via `find` on the marked (or next prefix ARG) directories." t)
+;;;    (autoload 'Buffer-menu-igrep "igrep"
+;;;      "*Run `grep` on the files visited in buffers marked with '>'." t)
+;;;    (autoload 'igrep-insinuate "igrep"
+;;;      "Define `grep' aliases for the corresponding `igrep' commands." t)
 ;;; 2. a. For completeness, you can add these forms as well:
-;;;    (autoload (function grep) "igrep"
+;;;    (autoload 'grep "igrep"
 ;;;       "*Run `grep` PROGRAM to match EXPRESSION in FILES..." t)
-;;;    (autoload (function egrep) "igrep"
+;;;    (autoload 'egrep "igrep"
 ;;;       "*Run `egrep`..." t)
-;;;    (autoload (function fgrep) "igrep"
+;;;    (autoload 'fgrep "igrep"
 ;;;       "*Run `fgrep`..." t)
-;;;    (autoload (function agrep) "igrep"
+;;;    (autoload 'agrep "igrep"
 ;;;       "*Run `agrep`..." t)
-;;;    (autoload (function grep-find) "igrep"
+;;;    (autoload 'grep-find "igrep"
 ;;;       "*Run `grep` via `find`..." t)
-;;;    (autoload (function egrep-find) "igrep"
+;;;    (autoload 'egrep-find "igrep"
 ;;;       "*Run `egrep` via `find`..." t)
-;;;    (autoload (function fgrep-find) "igrep"
+;;;    (autoload 'fgrep-find "igrep"
 ;;;       "*Run `fgrep` via `find`..." t)
-;;;    (autoload (function agrep-find) "igrep"
+;;;    (autoload 'agrep-find "igrep"
 ;;;       "*Run `agrep` via `find`..." t)
-;;;    (autoload (function dired-do-grep) "igrep"
-;;;       "*Run `grep` on the marked (or next prefix ARG) files." t)
-;;;    (autoload (function dired-do-grep-find) "igrep"
-;;;       "*Run `grep` via `find` on the marked (or next prefix ARG) directories." t)
 ;;; 3. If you are running Windows 95/NT, you should install findutils
-;;;    and grep from release 17.1 (or higher) of the Cygnus cygwin32
+;;;    and grep from release 17.1 (or higher) of the Cygnus GNU-Win32
 ;;;    distribution.  See <URL:http://www.cygnus.com/misc/gnu-win32/>.
 
 ;;; Usage:
 ;;; 
-;;; M-x igrep			M-x igrep-find
-;;; M-x  grep			M-x  grep-find
-;;; M-x egrep			M-x egrep-find
-;;; M-x fgrep			M-x fgrep-find
-;;; M-x agrep			M-x agrep-find
-;;; M-x dired-do-igrep		M-x dired-do-igrep-find
-;;; M-x  dired-do-grep		M-x  dired-do-grep-find
-;;; (Each of the 10 igrep commands accepts 1, 2, or 3 `C-u' prefix arguments.
-;;; The 2 Dired commands interpret a prefix argument like the regular `dired-do'
-;;; commands.)
-;;; C-x ` (M-x next-error)	C-c C-c (M-x compile-goto-error) [in *igrep*]
+;;; These igrep commands accept 1, 2, or 3 `C-u' prefix arguments:
+;;; 	M-x igrep		M-x igrep-find
+;;; 	M-x  grep		M-x  grep-find	[after `M-x igrep-insinuate']
+;;; 	M-x egrep		M-x egrep-find
+;;; 	M-x fgrep		M-x fgrep-find
+;;; 	M-x agrep		M-x agrep-find
+;;; 
+;;; These igrep commands accept a single `C-u' prefix argument:
+;;; 	M-x igrep-visited-files
+;;; 	M-x Buffer-menu-igrep	[in the *Buffer List* buffer]
+;;; 
+;;; These igrep commands interpret a prefix argument like the Emacs
+;;; `dired-do-*' commands:
+;;; 	M-x dired-do-igrep	M-x dired-do-igrep-find
+;;; 	M-x  dired-do-grep	M-x  dired-do-grep-find	[after `M-x
+;;; 							 igrep-insinuate']
+;;; 
+;;; These Emacs commands can be used after any igrep command:
+;;; 	C-x ` (M-x next-error)
+;;; 	C-c C-c (M-x compile-goto-error)	[in the *igrep* buffer]
 
 ;;; Customization examples:
 ;;; 
 ;;; or define new igrep commands (this works for zegrep and zfgrep as well):
 ;;; 	(igrep-define zgrep)		; M-x zgrep
 ;;; 	(igrep-find-define zgrep)	; M-x zgrep-find
+;;; To search "*.[ch]" files by default in C mode:
+;;; 	(put 'igrep-files-default 'c-mode
+;;; 	     (lambda () "*.[ch]"))
+;;; To disable the default search expression and/or files pattern,
+;;; except for specific modes:
+;;; 	(setq igrep-expression-default 'ignore)
+;;; 	(setq igrep-files-default 'ignore)
 ;;; To avoid exceeding some shells' limit on command argument length
-;;; (this only works when grep'ing files in the current directory):
+;;; (this only searches files in the current directory):
 ;;; 	(setq igrep-find t
-;;; 	      igrep-find-prune-option "\\! -name .")
+;;; 	      igrep-find-prune-clause "\\! -name .")
 
 ;;; To do:
 ;;; 
-;;; 1. Delete the *-program variables (except for igrep-program) and
-;;;    replace igrep-options with a table that maps igrep-program to the
-;;;    appropriate options.
+;;; 1. Replace igrep-options with a table that maps igrep-program
+;;;    to the appropriate options.
 ;;; 2. Generalize support for the -prune find clause (e.g. -fstype nfs).
 ;;; 3. Provide support for `glimpse`.
 ;;; 4. Add a menu interface.
+;;; 5. Port to Emacs 20.
 
 ;;; LCD Archive Entry:
 ;;; 
 ;;; igrep|Kevin Rodgers|kevinr@ihs.com|
-;;; An improved interface to grep/egrep/fgrep; plus recursive `find` versions.|
-;;; 97/02/10|2.56|~/misc/igrep.el.Z|
+;;; An improved interface to `grep` and `find`.|
+;;; 98/08/06|2.83|~/misc/igrep.el.Z|
 
 
 ;;; Package interface:
 
 (provide 'igrep)
 
-(require 'backquote)			; igrep-with-default-in-history
-(require 'compile)			; compile-internal and grep-regexp-
-					; alist
+(require 'compile)			; compile-internal, grep-regexp-alist
 
 (eval-when-compile
-  (require 'dired))
+  (require 'dired)			; dired-directory,
+					; dired-get-filename,
+					; dired-current-directory,
+					; dired-get-marked-files,
+					; dired-mark-get-files
+  (or (featurep 'ange-ftp)
+      (featurep 'efs)
+      (condition-case nil
+	  (load-library "ange-ftp")	; ange-ftp-ftp-name
+	(error nil))
+      (condition-case nil
+	  (load-library "efs")		; efs-ftp-path
+	(error nil)))
+  )
 
-(defconst igrep-version "2.56"
+(defconst igrep-version "2.83"
   "Version of igrep.el")
 
 
 ;;; User options:
 
-(defgroup igrep nil
-  "An improved interface to `grep'."
-  :group 'processes)
-
-(defcustom igrep-options nil
-  "*The options passed by \\[igrep] to `igrep-program', or nil.
+(defvar igrep-options nil
+  "*The options passed by `\\[igrep]' to `igrep-program', or nil.
 
 `-n' will automatically be passed to `igrep-program', to generate the
-output expected by \\[next-error] and \\[compile-goto-error].
+output expected by `\\[next-error]' and `\\[compile-goto-error]'.
 `-e' will automatically be passed to `igrep-program', if it supports
-that option."
-  :type '(repeat (string :tag "Option"))
-  :group 'igrep)
+that option.")
+(put 'igrep-options 'variable-interactive
+     "xOptions (\"-xyz\" or nil): ")
 
-(defcustom igrep-read-options nil
+(defvar igrep-read-options nil
   "*If non-nil, `\\[igrep]' always prompts for options;
-otherwise, it only prompts when 1 or 3 `C-u's are given as a prefix arg."
-  :type 'boolean
-  :group 'igrep)
+otherwise, it only prompts when 1 or 3 `C-u's are given as a prefix arg.")
+(put 'igrep-read-options 'variable-interactive
+     "XAlways prompt for options? (t or nil): ")
 
-(defcustom igrep-read-multiple-files nil
+(defvar igrep-read-multiple-files nil
   "*If non-nil, `\\[igrep]' always prompts for multiple-files;
-otherwise, it only prompts when 2 or 3 `C-u's are given as a prefix arg."
-  :type 'boolean
-  :group 'igrep)
+otherwise, it only prompts when 2 or 3 `C-u's are given as a prefix arg.")
+(put 'igrep-read-multiple-files 'variable-interactive
+     "XAlways prompt for multiple files? (t or nil): ")
 
-(defcustom igrep-verbose-prompts t
-  "*If t, \\[igrep] prompts for arguments verbosely;
-if not t but non-nil, \\[igrep] prompts for arguments semi-verbosely;
-if nil, \\[igrep] prompts for arguments tersely."
-  :type 'boolean
-  :group 'igrep)
+(defvar igrep-expression-default 'current-word
+  "*If non-nil, a function that returns a default EXPRESSION for `\\[igrep]'.
+The function is called with no arguments and should return a string (or nil).
 
-(defcustom igrep-save-buffers 'query
-  "*If t, \\[igrep] first saves each modified file buffer;
-if not t but non-nil, \\[igrep] offers to save each modified file buffer."
-  :type '(choice (const :tag "Save" t)
-		 (const :tag "Dont Save" nil)
-		 (const :tag "Query" query))
-  :group 'igrep)
+A different function can be specified for any particular mode by specifying
+a value for that `major-mode' property; for example:
+	(put 'igrep-expression-default 'dired-mode
+	     'igrep-dired-file-current-word)")
+(put 'igrep-expression-default 'variable-interactive
+     "SProvide a default expression? (function or nil): ")
+(put 'igrep-expression-default 'dired-mode
+     'igrep-dired-file-current-word)
+
+(defvar igrep-files-default 'igrep-buffer-file-name-pattern
+  "*If non-nil, a function that returns the default FILES for `\\[igrep]'.
+The function is called with no arguments and should return a string (or nil).
+
+A different function can be specified for any particular mode by specifying
+a value for that `major-mode' property; for example:
+	(put 'igrep-files-default 'dired-mode
+	     'igrep-dired-directory-file-pattern)")
+(put 'igrep-files-default 'variable-interactive
+     "SProvide a default file pattern? (function or nil): ")
+(put 'igrep-files-default 'dired-mode
+     'igrep-dired-directory-file-pattern)
+
+(defvar igrep-verbose-prompts t
+  "*If t, `\\[igrep]' prompts for arguments verbosely;
+if not t but non-nil, `\\[igrep]' prompts for arguments semi-verbosely;
+if nil, `\\[igrep]' prompts for arguments tersely.")
+(put 'igrep-verbose-prompts 'variable-interactive
+     "XPrompt verbosely? (t, 'semi, or nil): ")
+
+(defvar igrep-save-buffers 'query
+  "*If t, `\\[igrep]' first saves each modified file buffer;
+if not t but non-nil, `\\[igrep]' offers to save each modified file buffer.")
+(put 'igrep-save-buffers 'variable-interactive
+     "XSave modified buffers? (t, 'query, or nil): ")
+
+
+;;; User variables:
+
+(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
+the \"-n\" option.
+If nil, `\\[igrep]' prompts for the program to run.")
+
+(defvar igrep-expression-option
+  (if (equal (call-process igrep-program nil nil nil
+			   "-e" "foo" grep-null-device)
+	     1)
+      "-e")
+  "If non-nil, the option used to specify the EXPRESSION argument to `\\[igrep]',
+to protect an initial `-' from option processing.")
 
 (defvar igrep-program-table		; referenced by igrep-use-zgrep
   (let ((exec-directories exec-path)
 	(program-obarray (make-vector 11 0)))
     (while exec-directories
       (if (and (car exec-directories)
-	       (file-directory-p (car exec-directories)))
+	       (file-directory-p (car exec-directories))
+	       (file-readable-p (car exec-directories)))
 	  (let ((grep-programs
 		 (directory-files (car exec-directories)
 				  nil "grep\\(\\.exe\\)?\\'")))
 (defvar igrep-use-zgrep
   (if (intern-soft "zgrep" igrep-program-table)
       'files)
-  "If t, \\[igrep] searches files using the GNU (gzip) `zPROGRAM` script;
-If not t but non-nil, \\[igrep] searches compressed FILES using `zPROGRAM`;
-if nil, \\[igrep] searches files with `PROGRAM`.")
-
-
-;;; User variables:
-
-(defvar igrep-program "grep"
-  "The default shell program run by \\[igrep] and \\[igrep-find].
-It must take a `grep` expression argument and one or more file names.
-If nil, \\[igrep] prompts for the program to run.")
-
-(defvar igrep-expression-quote-char
-  (if (memq system-type '(ms-dos windows-95 windows-nt emx))
-      ?\"
-    ?')
-  "The character used to delimit the EXPRESSION argument to \\[igrep],
-to protect it from shell filename expansion.")
-
-(defvar igrep-expression-option
-  (if (or (eq system-type 'berkeley-unix)
-	  (save-match-data
-	    (string-match "-sco" system-configuration)))
-      "-e")
-  "If non-nil, the option used to specify the EXPRESSION argument to \\[igrep],
-to protect an initial `-' from option processing.")
-
-(defvar igrep-parenthesis-escape-char
-  (if (memq system-type '(ms-dos windows-95 windows-nt emx))
-      nil
-    ?\\)
-  "If non-nil, the character used by \\[igrep] to escape parentheses,
-to protect them from shell interpretation.")
+  "If t, `\\[igrep]' searches files using the GNU (gzip) `zPROGRAM` script;
+If not t but non-nil, `\\[igrep]' searches compressed FILES using `zPROGRAM`;
+if nil, `\\[igrep]' searches files with `PROGRAM`.")
 
 (defvar igrep-find nil
-  "If non-nil, \\[igrep] searches directories using `find`.
-See \\[igrep-find].")
+  "If non-nil, `\\[igrep]' searches directories using `find`.
+See `igrep-find'.")
 
-(defvar igrep-find-prune-options
-  (if (not (save-match-data
-	     (string-match "-sco" system-configuration)))
-      "-name SCCS -o -name RCS")
+(defvar igrep-find-program "find"
+  "The program run by `\\[igrep-find]'.")
+
+(defvar igrep-find-prune-clause
+  (if (equal (call-process igrep-find-program nil nil nil
+			   grep-null-device "-prune")
+	     0)
+      (format "%s -name SCCS -o -name RCS %s"
+	      (shell-quote-argument "(")
+	      (shell-quote-argument ")")))
   "The `find` clause used to prune directories, or nil;
-see \\[igrep-find].")
+see `igrep-find'.")
 
-(defvar igrep-find-file-options "-type f -o -type l"
+(defvar igrep-find-file-clause "-type f"
+  ;; (format "%s -type f -o -type l %s" ...)
   "The `find` clause used to filter files passed to `grep`, or nil;
-see \\[igrep-find].")
+see `igrep-find'.")
 
 (defvar igrep-find-use-xargs
-  (if (equal (call-process "find" nil nil nil
-			   (if (boundp 'grep-null-device)
-			       grep-null-device
-			     "/dev/null")
-			   "-print0")
+  (if (equal (call-process igrep-find-program nil nil nil
+			   grep-null-device "-print0")
 	     0)
       'gnu)
-  "If `gnu', \\[igrep-find] executes
+  "If `gnu', `\\[igrep-find]' executes
 	`find ... -print0 | xargs -0 -e grep ...`;
-if not `gnu' but non-nil, \\[igrep-find] executes
+if not `gnu' but non-nil, `\\[igrep-find]' executes
 	`find ... -print | xargs -e grep ...`;
-if nil, \\[igrep-find] executes
+if nil, `\\[igrep-find]' executes
 	`find ... -exec grep ...`.")
 
-(defvar igrep-program-default nil
+(defvar igrep-program-default "grep"
   "The default `grep` program, passed by `igrep-read-program'
 to `completing-read' when `igrep-program' is nil.")
 
 (defvar igrep-expression-history '()
-  "The minibuffer history list for \\[igrep]'s EXPRESSION argument.")
+  "The minibuffer history list for `\\[igrep]'s EXPRESSION argument.")
 
 (defvar igrep-files-history '()
-  "The minibuffer history list for \\[igrep]'s FILES argument.")
+  "The minibuffer history list for `\\[igrep]'s FILES argument.")
 
 
 ;;; Commands:
 
-;; This used to be evaluated at top level.  We consider it evil, so it
-;; goes into a user-callable function.    --hniksic
 ;;;###autoload
-(defun igrep-insinuate ()
-  "Replace the `grep' functions with `igrep'."
-  (defadvice grep (around igrep-interface first (&rest grep-args) activate)
-    "If called interactively, use the \\[igrep] interface instead,
-where GREP-ARGS is (PROGRAM EXPRESSION FILES OPTIONS);
-if called programmatically, GREP-ARGS is still (COMMAND)."
-    (interactive (igrep-read-args))
-    (if (interactive-p)
-	(apply (function igrep) grep-args)
-      ad-do-it))
-  (defalias 'grep-find 'igrep-find)
-  (defalias 'dired-do-grep 'dired-do-igrep)
-  (defalias 'dired-do-grep-find 'dired-do-igrep-find))
-
-
-(defvar mswindows-quote-process-args)	; XEmacs
+(defun igrep-insinuate (&optional override)
+  "Define `grep' aliases for the corresponding `igrep' commands.
+With a prefix arg, override the current `grep` command definitions."
+  (interactive "P")
+  (if override
+      (defalias 'grep-find 'igrep-find)
+    (defadvice grep (around igrep-interactive first (&rest command-args)
+			    activate)
+      "If called interactively, use the `\\[igrep]' interface instead,
+where COMMAND-ARGS is (PROGRAM EXPRESSION FILES [OPTIONS]);
+if called programmatically, COMMAND-ARGS is still (COMMAND)."
+      (interactive (igrep-read-args))
+      (if (interactive-p)
+	  (apply 'igrep command-args)
+	ad-do-it)))
+  (if (or (not (fboundp 'grep-find))
+	  override)
+      (defalias 'grep-find 'igrep-find))
+  (if (or (not (fboundp 'dired-do-grep))
+	  override)
+      (defalias 'dired-do-grep 'dired-do-igrep))
+  (if (or (not (fboundp 'dired-do-grep-find))
+	  override)
+      (defalias 'dired-do-grep-find 'dired-do-igrep-find))
+  (if (or (not (fboundp 'Buffer-menu-grep))
+	  override)
+      (defalias 'Buffer-menu-grep 'Buffer-menu-igrep)))
 
 ;;;###autoload
 (defun igrep (program expression files &optional options)
   "*Run `grep` PROGRAM to match EXPRESSION in FILES.
-The output is displayed in the *igrep* buffer, which \\[next-error] and
-\\[compile-goto-error] parse to find each line of matched text.
+The output is displayed in the *igrep* buffer, which `\\[next-error]' and
+`\\[compile-goto-error]' parse to find each line of matched text.
 
 PROGRAM may be nil, in which case it defaults to `igrep-program'.
 
-EXPRESSION is automatically delimited by `igrep-expression-quote-char'.
+EXPRESSION is automatically quoted by `shell-quote-argument'.
 
 FILES is either a file name pattern (expanded by the shell named by
 `shell-file-name') or a list of file name patterns.
 Optional OPTIONS is also passed to PROGRAM; it defaults to `igrep-options'.
 
 If a prefix argument \
-\(\\[universal-argument]\) \
+\(`\\[universal-argument]') \
 is given when called interactively,
 or if `igrep-read-options' is set, OPTIONS is read from the minibuffer.
 
 If two prefix arguments \
-\(\\[universal-argument] \\[universal-argument]\) \
+\(`\\[universal-argument] \\[universal-argument]') \
 are given when called interactively,
 or if `igrep-read-multiple-files' is set, FILES is read from the minibuffer
 multiple times.
 
 If three prefix arguments \
-\(\\[universal-argument] \\[universal-argument] \\[universal-argument]\) \
+\(`\\[universal-argument] \\[universal-argument] \\[universal-argument]') \
 are given when called interactively,
 or if `igrep-read-options' and `igrep-read-multiple-files' are set,
 OPTIONS is read and FILES is read multiple times.
 
 If `igrep-find' is non-nil, the directory or directories
 containing FILES is recursively searched for files whose name matches
-the file name component of FILES \(and whose contents match
-EXPRESSION\)."
+the file name component of FILES (and whose contents match EXPRESSION)."
   (interactive
    (igrep-read-args))
   (if (null program)
       (setq options igrep-options))
   (if (not (listp files))		; (stringp files)
       (setq files (list files)))
-  (if (string-match "^[rj]?sh$" (file-name-nondirectory shell-file-name))
+  (if (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)))
-  (let* ((mswindows-quote-process-args nil)	; work around NT Emacs hack
-	 (use-zgrep (cond ((eq igrep-use-zgrep t))
+  (let* ((use-zgrep (cond ((eq igrep-use-zgrep t))
 			  (igrep-use-zgrep
 			   (let ((files files)
 				 (compressed-p nil))
 			       (setq files (cdr files)))
 			     compressed-p))
 			  (t nil)))
-	 (command (format "%s -n %s %s %c%s%c %s %s"
+	 (command (format "%s -n %s %s %s %s %s"
 			  (if (and use-zgrep
 				   (save-match-data
 				     (not (string-match "\\`z" program))))
 				      (string-match "\\`-" expression))
 				    (setq expression (concat "\\" expression)))
 				""))
-			  igrep-expression-quote-char
-			  expression
-			  igrep-expression-quote-char
+			  (shell-quote-argument expression)
 			  (if igrep-find
 			      (if igrep-find-use-xargs
 				  ""
-				"\"{}\"")
-			    (mapconcat (function identity) files " "))
-			  (if (boundp 'grep-null-device)
-			      grep-null-device
-			    "/dev/null"))))
+				(shell-quote-argument "{}"))
+			    (mapconcat 'identity files " "))
+			  grep-null-device)))
     (if igrep-find
 	(setq command
 	      (igrep-format-find-command command files)))
     (cond ((eq igrep-save-buffers t) (save-some-buffers t))
 	  (igrep-save-buffers (save-some-buffers)))
-    (compile-internal command
-		      (format "No more %c%s%c matches"
-			      igrep-expression-quote-char
-			      program
-			      igrep-expression-quote-char)
+    (compile-internal command (format "No more %s matches" program)
 		      "igrep" nil grep-regexp-alist)))
 
 ;; Analogue commands:
 
-;;;###autoload
 (defmacro igrep-define (analogue-command &rest igrep-bindings)
   "Define ANALOGUE-COMMAND as an `igrep' analogue command.
 Optional (VARIABLE VALUE) arguments specify temporary bindings for the command."
 ;;;  (interactive "SCommand: ") ; C-u => read bindings?
   (let ((analogue-program (symbol-name analogue-command)))
-    (` (defun (, analogue-command) (&rest igrep-args)
-	 (, (format "*Run `%s` via \\[igrep].
-All arguments \(including prefix arguments, when called interactively\)
+    `(defun ,analogue-command (&rest igrep-args)
+       ,(format "*Run `%s` via `\\[igrep]'.
+All arguments (including prefix arguments, when called interactively)
 are handled by `igrep'."
-		    analogue-program))
-	 (interactive
-	  (let ((igrep-program (if igrep-program (, analogue-program)))
-		(igrep-program-default (, analogue-program)))
-	    (igrep-read-args)))
-	 (let ( (,@ igrep-bindings))
-	   (apply (function igrep)
-		  (cond ((interactive-p) (car igrep-args))
-			((car igrep-args))
-			(t (, analogue-program)))
-		  (cdr igrep-args)))))))
+		analogue-program)
+       (interactive
+	(let ((igrep-program (if igrep-program ,analogue-program))
+	      (igrep-program-default ,analogue-program))
+	  (igrep-read-args)))
+       (let (,@ igrep-bindings)
+	 (apply 'igrep
+		(cond ((interactive-p) (car igrep-args))
+		      ((car igrep-args))
+		      (t ,analogue-program))
+		(cdr igrep-args))))))
 
 (igrep-define egrep)
 (igrep-define fgrep)
 
 ;;;###autoload
 (defun igrep-find (&rest igrep-args)
-  "*Run `grep` via `find`; see \\[igrep] and `igrep-find'.
-All arguments \(including prefix arguments, when called interactively\)
+  "*Run `grep` via `find`; see `igrep' and `igrep-find'.
+All arguments (including prefix arguments, when called interactively)
 are handled by `igrep'."
   (interactive
    (let ((igrep-find t))
      (igrep-read-args)))
   (let ((igrep-find t))
-    (apply (function igrep) igrep-args)))
+    (apply 'igrep igrep-args)))
 
 ;; Analogue recursive (`find`) commands:
 
-;;;###autoload
 (defmacro igrep-find-define (analogue-command &rest igrep-bindings)
   "Define ANALOGUE-COMMAND-find as an `igrep' analogue `find` command.
 Optional (VARIABLE VALUE) arguments specify temporary bindings for the command."
   (let ((analogue-program (symbol-name analogue-command)))
     (setq analogue-command
 	  (intern (format "%s-find" analogue-command)))
-    (` (defun (, analogue-command) (&rest igrep-args)
-	 (, (format "*Run `%s` via \\[igrep-find].
-All arguments \(including prefix arguments, when called interactively\)
+    `(defun ,analogue-command (&rest igrep-args)
+       ,(format "*Run `%s` via `\\[igrep-find]'.
+All arguments (including prefix arguments, when called interactively)
 are handled by `igrep'."
-		    analogue-program))
-	 (interactive
-	  (let ((igrep-program (if igrep-program (, analogue-program)))
-		(igrep-program-default (, analogue-program))
-		(igrep-find t))
-	    (igrep-read-args)))
-	 (let ( (,@ igrep-bindings))
-	   (apply (function igrep-find)
-		  (cond ((interactive-p) (car igrep-args))
-			((car igrep-args))
-			(t (, analogue-program)))
-		  (cdr igrep-args)))))))
+		analogue-program)
+       (interactive
+	(let ((igrep-program (if igrep-program ,analogue-program))
+	      (igrep-program-default ,analogue-program)
+	      (igrep-find t))
+	  (igrep-read-args)))
+       (let (,@ igrep-bindings)
+	 (apply 'igrep-find
+		(cond ((interactive-p) (car igrep-args))
+		      ((car igrep-args))
+		      (t ,analogue-program))
+		(cdr igrep-args))))))
 
 (igrep-find-define egrep)
 (igrep-find-define fgrep)
   (igrep-use-zgrep nil)
   (igrep-expression-option "-e"))
 
+;;;###autoload
+(defun igrep-visited-files (program expression &optional options)
+  "*Run `grep` PROGRAM to match EXPRESSION (with optional OPTIONS) \
+on all visited files.
+See `\\[igrep]'."
+  (interactive
+   (let ((igrep-args (igrep-read-args 'no-files)))
+     ;; Delete FILES:
+     (setcdr (nthcdr 1 igrep-args) (nthcdr 3 igrep-args))
+     igrep-args))
+  (igrep program expression
+	 (let ((directory-abbrev-alist
+		(cons (cons (expand-file-name default-directory)
+			    "./")	; or even ""
+		      directory-abbrev-alist)))
+	   (mapcar 'abbreviate-file-name
+		   (apply 'nconc
+			  (mapcar (lambda (buffer)
+				    (let ((file (buffer-file-name buffer)))
+				      (if (and file
+					       (cond ((featurep 'ange-ftp)
+						      (not (ange-ftp-ftp-name file)))
+						     ((featurep 'efs)
+						      (not (efs-ftp-path file)))
+						     (t t))
+					       ;; (file-exists-p file)
+					       )
+					  (list file))))
+				  (buffer-list)))))
+	 options))
+
 
 ;; Dired commands:
 
 ;;;###autoload
 (defun dired-do-igrep (program expression &optional options arg)
-  "*Run `grep` PROGRAM to match EXPRESSION (with optional OPTIONS)
-on the marked (or next prefix ARG) 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)))
 		  t arg)
 	 options))
 
-;;;###autoload
+
 
 ;; Dired recursive (`find`) commands:
 
 ;;;###autoload
 (defun dired-do-igrep-find (program expression &optional options arg)
-  "*Run `grep` PROGRAM to match EXPRESSION (with optional OPTIONS)
-on the marked (or next prefix ARG) directories."
+  "*Run `grep` on the marked (or next prefix ARG) directories.
+See `\\[igrep]'."
   (interactive
    (let* ((current-prefix-arg nil)
 	  (igrep-find t)
     (dired-do-igrep program expression options arg)))
 
 
+
+;; Buffer menu commands:
+
+;;;###autoload
+(defun Buffer-menu-igrep (program expression &optional options)
+  "*Run `grep` on the files visited in buffers marked with '>'.
+See `\\[igrep]'."
+  (interactive
+   (let ((igrep-args (igrep-read-args 'no-files)))
+     ;; Delete FILES:
+     (setcdr (nthcdr 1 igrep-args) (nthcdr 3 igrep-args))
+     igrep-args))
+  ;; See Buffer-menu-select:
+  (let ((marked-files '())
+	marked-buffer
+	file)
+    (goto-char (point-min))
+    (while (search-forward "\n>" nil t)
+      (setq marked-buffer (Buffer-menu-buffer t)
+	    file (buffer-file-name marked-buffer))
+      (if (and file
+	       ;; local:
+	       (cond ((featurep 'ange-ftp)
+		      (not (ange-ftp-ftp-name file)))
+		     ((featurep 'efs)
+		      (not (efs-ftp-path file)))
+		     (t t)))
+	  (setq marked-files (cons file marked-files)))
+;;;    (let ((buffer-read-only nil))
+;;;      (delete-char -1)
+;;;      (insert ?\ ))
+      )
+    (setq marked-files (nreverse marked-files))
+    (igrep program expression
+	   (let ((directory-abbrev-alist
+		  (cons (cons (expand-file-name default-directory)
+			      "./")	; or even ""
+			directory-abbrev-alist)))
+	     (mapcar 'abbreviate-file-name marked-files))
+	   options)))
+
+
+;;; User functions:
+
+(defun igrep-dired-file-current-word ()
+  "Return the current word in the file on this line, if it is visible;
+else, return the file name on this line, if there is one;
+otherwise, return the current word."
+  (let* ((dired-file
+	  (dired-get-filename t t))
+	 (dired-file-buffer
+	  (if dired-file
+	      (get-file-buffer (expand-file-name dired-file))))
+	 (dired-file-buffer-window
+	  (if dired-file-buffer
+	      (get-buffer-window dired-file-buffer))))
+    (cond (dired-file-buffer-window (save-excursion
+				      (set-buffer dired-file-buffer)
+				      (current-word)))
+	  (dired-file)
+	  (t (current-word)))))
+
+(defun igrep-buffer-file-name-pattern ()
+  "Return a shell file name pattern based on `buffer-file-name', or \"*\"."
+  ;; (Based on other-possibly-interesting-files in ~/as-is/unix.el, by
+  ;; Wolfgang Rupprecht <wolfgang@mgm.mit.edu>.)
+  (if buffer-file-name
+      (let ((file-name (file-name-nondirectory buffer-file-name)))
+	(concat "*"
+		(save-match-data
+		  (if (string-match "\\.[^.]+\\(\\.g?[zZ]\\)?\\'"
+				    file-name)
+		      (substring file-name (match-beginning 0)
+				 (match-end 0))))))
+    "*"))
+
+(defun igrep-dired-directory-file-pattern ()
+"Return a shell file name pattern based on `dired-directory', or \"*\"."
+  (cond ((stringp dired-directory)
+	 (if (file-directory-p dired-directory)
+	     "*"
+	   (file-name-nondirectory dired-directory))) ; wildcard
+	((consp dired-directory)	; (DIR FILE ...)
+	 (mapconcat 'identity (cdr dired-directory) " "))))
+
+
 ;;; Utilities:
 
 (defsubst igrep-file-directory (name)
       (setq files (cdr files)))
     (format (cond ((eq igrep-find-use-xargs 'gnu)
 		   ;; | \\\n
-		   "find %s %s %s %s -print0 | xargs -0 -e %s")
+		   "%s %s %s %s %s -print0 | xargs -0 -e %s")
 		  (igrep-find-use-xargs
 		   ;; | \\\n
-		   "find %s %s %s %s -print | xargs -e %s")
-;;;		  ((memq system-type '(ms-dos windows-95 windows-nt emx))
-;;;		   "find %s %s %s %s -exec %s ;")
+		   "%s %s %s %s %s -print | xargs -e %s")
 		  (t
-		   "find %s %s %s %s -exec %s \\;"))
-	    (mapconcat (function identity) (nreverse directories)
+		   "%s %s %s %s %s -exec %s %s"))
+	    igrep-find-program
+	    (mapconcat 'identity (nreverse directories)
 		       " ")
-	    (if igrep-find-prune-options
-		(format "-type d %c( %s %c) -prune -o"
-			(or igrep-parenthesis-escape-char ? )
-			igrep-find-prune-options
-			(or igrep-parenthesis-escape-char ? ))
+	    (if igrep-find-prune-clause
+		(format "-type d %s -prune -o" igrep-find-prune-clause)
 	      "")
-	    (if igrep-find-file-options
-		(format "%c( %s %c)"
-			(or igrep-parenthesis-escape-char ? )
-			igrep-find-file-options
-			(or igrep-parenthesis-escape-char ? ))
-	      "")
+	    (or igrep-find-file-clause "")
 	    (if (listp patterns)
 		(if (cdr patterns)	; (> (length patterns) 1)
-		    (format "%c( %s %c)"
-			    (or igrep-parenthesis-escape-char " ")
-			    (mapconcat (function (lambda (pat)
-						   (format "-name \"%s\"" pat)))
+		    (format "%s %s %s"
+			    (shell-quote-argument "(")
+			    (mapconcat (lambda (pat)
+					 (format "-name \"%s\"" pat))
 				       (nreverse patterns)
 				       " -o ")
-			    (or igrep-parenthesis-escape-char " "))
+			    (shell-quote-argument ")"))
 		  (format "-name \"%s\"" (car patterns)))
 	      "")
-	    command)))
+	    command
+	    (shell-quote-argument ";")
+	    )))
+
+(defmacro igrep-default-arg (variable)
+  ;; Return the default arg based on VARIABLE.
+  `(if ,variable
+       (cond ((get (quote ,variable) major-mode)
+	      (funcall (get (quote ,variable) major-mode)))
+	     (t (funcall ,variable)))))
+
+(defsubst igrep-prefix (prefix string &rest strings)
+  ;; If PREFIX is non-nil or any STRINGS are specified, concatenate them
+  ;; before and after STRING; otherwise, return the STRING.
+  (if (or prefix strings)
+      (apply 'concat prefix string strings)
+    string))
 
 (defun igrep-read-args (&optional no-files)
   ;; Read and return a list: (PROGRAM EXPRESSION FILES OPTIONS).
   ;; If NO-FILES is non-nil, then FILES is not read and nil is returned
   ;; in its place.
-  (let* ((program (igrep-read-program (if igrep-verbose-prompts
-					  (if igrep-find
-					      "[find] "))))
-	 (prompt-prefix (if igrep-verbose-prompts
-			    (apply (function concat)
-				   (if igrep-find
-				       "[find] ")
-				   (if (eq igrep-verbose-prompts t)
-				       (list program " ")))))
-	 (options (igrep-read-options prompt-prefix)))
-    (if (eq igrep-verbose-prompts t)
-	(setq prompt-prefix
-	      (concat prompt-prefix options " ")))
+  (let* ((pre-prefix (if (and igrep-find (eq igrep-verbose-prompts t))
+			 "[find] "))
+	 (program
+	  (igrep-read-program pre-prefix))
+	 (prefix (if (and program (eq igrep-verbose-prompts t))
+		     (igrep-prefix pre-prefix program " ")
+		   pre-prefix))
+	 (options
+	  (igrep-read-options prefix))
+	 (post-prefix (if (and options (eq igrep-verbose-prompts t))
+			    (igrep-prefix prefix options " ")
+			  prefix)))
     (list program
-	  (igrep-read-expression prompt-prefix)
+	  (igrep-read-expression post-prefix)
 	  (if (not no-files)
-	      (igrep-read-files prompt-prefix))
+	      (igrep-read-files post-prefix))
 	  options)))
 
-(defsubst igrep-prefix (prefix string)
-  ;; If PREFIX is non-nil, concatenate it and STRING; otherwise, return STRING.
-  (if prefix
-      (concat prefix string)
-    string))
-
 (defun igrep-read-program (&optional prompt-prefix)
   ;; If igrep-program is nil, read and return a program name from the
   ;; minibuffer; otherwise, return igrep-program.
   (or igrep-program
       (let ((prompt "Program: "))
 	(completing-read (igrep-prefix prompt-prefix prompt) igrep-program-table
-			 nil t (or igrep-program-default "grep")))))
+			 nil t igrep-program-default))))
 
 (defun igrep-read-options (&optional prompt-prefix)
   ;; If current-prefix-arg is '(4) or '(64), read and return an options
 (defun igrep-read-expression (&optional prompt-prefix)
   ;; Read and return a `grep` expression string from the minibuffer.
   ;; Optional PROMPT-PREFIX is prepended to the "Expression: " prompt.
-  (let ((default-expression (igrep-default-expression)))
+  (let ((default-expression (igrep-default-arg igrep-expression-default)))
     (if (string= default-expression "")
-	(read-from-minibuffer (igrep-prefix prompt-prefix "Expression: ")
-			      nil nil nil 'igrep-expression-history)
-      (let ((expression
-	     (igrep-read-string-with-default-in-history
-	      (igrep-prefix prompt-prefix (format "Expression (default %s): "
-						  default-expression))
-	      default-expression
-	      'igrep-expression-history)))
-	(if (string= expression "")
-	    default-expression
-	  expression)))))
+	(setq default-expression nil))
+    (read-from-minibuffer (igrep-prefix prompt-prefix "Expression: ")
+			  default-expression nil nil
+			  'igrep-expression-history)))
 
-(defun igrep-default-expression ()
-  (if (eq major-mode 'dired-mode)
-      (let ((dired-file (dired-get-filename nil t)))
-	(save-excursion
-	  (set-buffer (or (and dired-file (get-file-buffer dired-file))
-			  (other-buffer (current-buffer) t)))
-	  (current-word)))
-    (current-word)))
-
-(defsubst igrep-default-key ()
-  ;; Return the key bound to `exit-minibuffer', preferably "\r".
-  (if (eq (lookup-key minibuffer-local-completion-map "\r")
-	  (function exit-minibuffer))
-      "\r"
-    (where-is-internal (function exit-minibuffer)
-		       minibuffer-local-completion-map
-		       t)))
+(defsubst igrep-default-key (command &optional keymap key)
+  ;; Return the key bound to COMMAND in KEYMAP, preferably KEY.
+  (if (null keymap)
+      (setq keymap (current-global-map)))
+  (if (and key
+	   (eq (lookup-key keymap key) command))
+      key
+    (where-is-internal command keymap t)))
 
 (defun igrep-read-files (&optional prompt-prefix)
   ;; Read and return a file name pattern from the minibuffer.  If
   ;; prepended to the "File(s): " prompt.
   (let* ((dired-subdirectory (if (eq major-mode 'dired-mode)
 				 (dired-current-directory t)))
-	 (default-files (concat dired-subdirectory
-				(igrep-default-file-pattern)))
-	 (prompt (format "File(s) (default %s): " default-files))
+	 (default-files (if dired-subdirectory
+			    (concat dired-subdirectory
+				    (igrep-default-arg igrep-files-default))
+			  (igrep-default-arg igrep-files-default)))
 	 (insert-default-directory nil)	; use relative path names
-	 (file (igrep-read-file-name-with-default-in-history
-		(igrep-prefix prompt-prefix prompt)
-		default-files
-		nil
+	 (file (igrep-read-file-name
+		(igrep-prefix prompt-prefix "File(s): ")
+		nil default-files nil default-files
 		'igrep-files-history)))
     (if (or igrep-read-multiple-files
 	    (and (consp current-prefix-arg)
 		 (memq (prefix-numeric-value current-prefix-arg)
 		       '(16 64))))
-	(let ((files (list file)))
-	  (setq prompt
-		(igrep-prefix prompt-prefix
-			      (if igrep-verbose-prompts
-				  (format "File(s): [Type `%s' when done] "
-					  (key-description (igrep-default-key)))
-				"File(s): ")))
+	(let ((files (list file))
+	      (prompt
+	       (igrep-prefix prompt-prefix
+			     (if igrep-verbose-prompts
+				 (format "File(s): [Type `%s' when done] "
+					 (key-description
+					  (igrep-default-key 'exit-minibuffer
+							     minibuffer-local-completion-map
+							     "\r")))
+			       "File(s): "))))
 	  (while (not (string= (setq file
 				     (igrep-read-file-name prompt
 							   nil "" nil nil
 	  (nreverse files))
       file)))
 
-(defmacro igrep-with-default-in-history (default history &rest body)
-  ;; Temporarily append DEFAULT to HISTORY, and execute BODY forms.
-  (` (progn
-       ;; Append default to history:
-       (set history
-	    (cons (, default)
-		  (if (boundp (, history))
-		      (symbol-value (, history))
-		    '())))
-       (unwind-protect			; Make sure the history is restored.
-	   ;; Execute body:
-	   (progn (,@ body))
-	 ;; Delete default from history (undo the append above):
-	 (setcdr (symbol-value (, history))
-		 (nthcdr 2 (symbol-value (, history))))))))
-
-(defun igrep-read-string-with-default-in-history (prompt default history)
-  ;; Read a string from the minibuffer, prompting with string PROMPT.
-  ;; DEFAULT can be inserted into the minibuffer with `previous-
-  ;; history-element'; HISTORY is a symbol whose value (if bound) is a
-  ;; list of previous results, most recent first.
-  (let ((string (igrep-with-default-in-history default history
-		  (read-from-minibuffer prompt nil nil nil history))))
-    ;; Replace empty string in history with default:
-    (if (string= string "")
-	(setcar (symbol-value history) default))
-    string))
-
-(defun igrep-read-file-name-with-default-in-history
-  (prompt &optional default initial history)
-  ;; Read a file name from the minibuffer, prompting with string PROMPT.
-  ;; DEFAULT can be inserted into the minibuffer with `previous-
-  ;; history-element'; HISTORY is a symbol whose value (if any) is a
-  ;; list of previous results, most recent first.
-  (igrep-with-default-in-history default history
-    (igrep-read-file-name prompt nil default nil initial history)))
-
 (defun igrep-read-file-name (prompt
   &optional directory default existing initial history)
   ;; Just like read-file-name, but with optional HISTORY.
 	     (file-directory-p file-name))
 	(expand-file-name "*" file-name)
       file-name)))
-
-(defun igrep-default-file-pattern ()
-  ;; Return a shell file name pattern that matches files with the same
-  ;; extension as the file being visited in the current buffer.
-  ;; (Based on other-possibly-interesting-files in ~/as-is/unix.el, by
-  ;; Wolfgang Rupprecht <wolfgang@mgm.mit.edu>.)
-  (if (eq major-mode 'dired-mode)
-      (cond ((stringp dired-directory)
-	     (if (file-directory-p dired-directory)
-		 "*"
-	       (file-name-nondirectory dired-directory))) ; wildcard
-	    ((consp dired-directory)	; (DIR FILE ...)
-	     (mapconcat 'identity (cdr dired-directory) " ")))
-    (if buffer-file-name
-	(let ((file-name (file-name-nondirectory buffer-file-name)))
-	  (concat "*"
-		  (save-match-data
-		    (if (string-match "\\.[^.]+\\(\\.g?[zZ]\\)?$" file-name)
-			(substring file-name
-				   (match-beginning 0) (match-end 0))))))
-      "*")))
 
 ;;; Local Variables:
-;;; eval: (put 'igrep-with-default-in-history 'lisp-indent-hook 2)
 ;;; eval: (put 'igrep-define 'lisp-indent-hook 1)
 ;;; eval: (put 'igrep-find-define 'lisp-indent-hook 1)
 ;;; End:
 
 ;;;; igrep.el ends here
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.