Function: hui-select-rgrep
hui-select-rgrep is an autoloaded, interactive and byte-compiled
function defined in hui-select.el.
Signature
(hui-select-rgrep PATTERN &optional PREFX-ARG)
Documentation
Recursively grep with symbol at point or PATTERN.
Grep over all non-backup and non-autosave files in the current directory tree. If in an Emacs Lisp mode buffer and no optional PREFX-ARG is given, limit search to only .el and .el.gz files.
Key Bindings
Aliases
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hui-select.el
;;; ************************************************************************
;;; Public functions
;;; ************************************************************************
;;
;; Commands
;;
;;;###autoload
(defun hui-select-rgrep (pattern &optional prefx-arg)
"Recursively grep with symbol at point or PATTERN.
Grep over all non-backup and non-autosave files in the current
directory tree. If in an Emacs Lisp mode buffer and no optional
PREFX-ARG is given, limit search to only .el and .el.gz files."
(interactive (list (if (and (not current-prefix-arg) (equal (buffer-name) "*Locate*"))
(read-string "Grep files listed here for: ")
(let* ((delim-func (hui-select-at-delimited-thing-p))
(region (when delim-func (funcall delim-func (point))))
(default (if region
(buffer-substring-no-properties
(car region) (cdr region))
(symbol-at-point))))
(when (and default (symbolp default))
(setq default (symbol-name default)))
(read-string (format "Rgrep below current dir for%s: "
(if default
(format " (default %s)" default)
""))
nil nil default)))
current-prefix-arg))
(let* ((delim (cond ((not (string-match-p "\'" pattern)) ?\')
((not (string-match-p "\"" pattern)) ?\")
((not (string-match-p "=" pattern)) ?=)
(t ?@)))
(grep-cmd
(if (and (not current-prefix-arg) (equal (buffer-name) "*Locate*"))
(format "%s -e \%c%s\%c %s" hui-select-rgrep-command delim pattern delim (hypb:locate-pathnames))
(format "%s %s %s -e \%c%s\%c ."
hui-select-rgrep-command
(when (and (memq major-mode '(emacs-lisp-mode lisp-interaction-mode))
(not prefx-arg))
(if (string-match-p "\\`rg " hui-select-rgrep-command)
"-g '*.el' -g '*.el.gz'"
"--include=\"*.el\" --include=\"*.el.gz\""))
(cond ((string-match-p "\\`rg " hui-select-rgrep-command)
;; Note: rg ignores the dir, .git, automatically
"-g '!*/CVS/*' -g '!*~' -g '!#*' -g '!*/TAGS'")
((string-match-p "--exclude-dir" (shell-command-to-string
"grep --help | fgrep -- exclude-dir"))
"--exclude-dir=\".git\" --exclude-dir=\"CVS/*\" --exclude=\"*~\" --exclude=\"#*\" --exclude=\"TAGS\"")
(t
"--exclude=\"*~\" --exclude=\"#*\" --exclude=\"TAGS\""))
delim pattern delim))))
(setq this-command `(grep ,grep-cmd))
(push this-command command-history)
(grep grep-cmd)))