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 narrow and search with a consult grep command.

Use ripgrep (rg) if found, otherwise, plain grep.

With GREP-INCLUDES or RIPGREP-GLOBS file suffixes to include, 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 the start of headline text only (lines that start with hsys-consult-entry-regexp).

Search over PATH-LIST.

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-20261030.2317/hsys-consult.el
;;;###autoload
(defun hsys-consult-grep (grep-includes ripgrep-globs
                          &optional regexp max-matches
                                    path-list prompt)
  "Interactively narrow and search with a consult grep command.
Use ripgrep (rg) if found, otherwise, plain grep.

With GREP-INCLUDES or RIPGREP-GLOBS file suffixes to include, 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 the start of headline text only (lines that start with
`hsys-consult-entry-regexp').

Search over PATH-LIST.

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)))