Function: hsys-consult-grep

hsys-consult-grep is an autoloaded and byte-compiled function defined in hsys-consult.el.

Signature

(hsys-consult-grep GREP-INCLUDES RIPGREP-GLOBS &optional REGEXP MAX-MATCHES PATH-LIST PROMPT)

Documentation

Interactively search PATH-LIST with a consult package grep command.

With GREP-INCLUDES or RIPGREP-GLOBS file suffixes to include, search for optional REGEXP up to MAX-MATCHES in PATH-LIST.

Use ripgrep (rg) if found, otherwise, plain grep. Initialize search with optional REGEXP and interactively prompt for changes. Limit matches per file to the absolute value of MAX-MATCHES, if given and not 0. If
0, match to headlines only (lines that start with a '^[*#]+[ ]+' regexp).

With optional PROMPT string, use this as the first part of the grep prompt; omit any trailing colon and space in the prompt.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hsys-consult.el
;;;###autoload
(defun hsys-consult-grep (grep-includes ripgrep-globs &optional regexp max-matches
					path-list prompt)
  "Interactively search PATH-LIST with a consult package grep command.

With GREP-INCLUDES or RIPGREP-GLOBS file suffixes to include, search
for optional REGEXP up to MAX-MATCHES in PATH-LIST.

Use ripgrep (rg) if found, otherwise, plain grep.  Initialize search with
optional REGEXP and interactively prompt for changes.  Limit matches
per file to the absolute value of MAX-MATCHES, if given and not 0.  If
0, match to headlines only (lines that start with a '^[*#]+[ \t]+' regexp).

With optional PROMPT string, use this as the first part of the grep prompt;
omit any trailing colon and space in the prompt."
  (hsys-consult-require-version)
  (let* ((consult-grep-args
	  (if (listp consult-grep-args)
	      (append consult-grep-args (list grep-includes))
	    (concat consult-grep-args " " grep-includes)))
	 (consult-ripgrep-args
	  (if (listp consult-ripgrep-args)
	      (append consult-ripgrep-args (list ripgrep-globs))
            (concat consult-ripgrep-args " " ripgrep-globs)))
	 (paths (if find-file-wildcards
		    ;; Use only the directory of paths with wildcards
		    ;; since the grep command filters to desired file
		    ;; types much more efficiently.
		    (mapcar (lambda (path)
			      (if (string-match "[\\/]?\\([^*?\\/]*[*?][^\\/]+\\'\\)" path)
				  (substring path 0 (match-beginning 1))
				path))
			    path-list)
		  path-list)))
    (hsys-consult--grep-paths paths regexp max-matches prompt)))