Function: eshell-poor-mans-grep
eshell-poor-mans-grep is a byte-compiled function defined in
em-unix.el.gz.
Signature
(eshell-poor-mans-grep ARGS)
Documentation
A poor version of grep that opens every file and uses occur.
This eats up memory, since it leaves the buffers open (to speed future searches), and it's very slow. But, if your system has no grep available...
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/em-unix.el.gz
(defun eshell-poor-mans-grep (args)
"A poor version of grep that opens every file and uses `occur'.
This eats up memory, since it leaves the buffers open (to speed future
searches), and it's very slow. But, if your system has no grep
available..."
(save-selected-window
(let ((default-dir default-directory))
(with-current-buffer (get-buffer-create "*grep*")
(let ((inhibit-read-only t)
(default-directory default-dir))
(erase-buffer)
(occur-mode)
(let ((files (eshell-stringify-list
(flatten-tree (cdr args))))
(inhibit-redisplay t)
string)
(when (car args)
(if (get-buffer "*Occur*")
(kill-buffer (get-buffer "*Occur*")))
(setq string nil)
(while files
(with-current-buffer (find-file-noselect (car files))
(save-excursion
(ignore-errors
(occur (car args))))
(if (get-buffer "*Occur*")
(with-current-buffer (get-buffer "*Occur*")
(setq string (buffer-string))
(kill-buffer (current-buffer)))))
(if string (insert string))
(setq string nil
files (cdr files)))))
(local-set-key [mouse-2] 'eshell-occur-mode-mouse-goto)
(local-set-key [(control ?c) (control ?c)]
'eshell-occur-mode-goto-occurrence)
(local-set-key [(control ?m)]
'eshell-occur-mode-goto-occurrence)
(local-set-key [return] 'eshell-occur-mode-goto-occurrence)
(pop-to-buffer (current-buffer) t)
(goto-char (point-min))
(resize-temp-buffer-window))))))