diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 8f0a5acf70..aba4d59371 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -484,9 +484,13 @@ grep-mode-font-lock-keywords This gets tacked on the end of the generated expressions.") ;;;###autoload -(defvar grep-program (purecopy "grep") +(defcustom grep-program (purecopy "grep") "The default grep program for `grep-command' and `grep-find-command'. -This variable's value takes effect when `grep-compute-defaults' is called.") +This variable's value takes effect when `grep-compute-defaults' is called." + :type `(choice + (const :tag "Use Grep" "grep") + (string :tag "User defined")) + :version "28.1") ;;;###autoload (defvar find-program (purecopy "find") diff --git a/lisp/cedet/semantic/symref/grep.el b/lisp/cedet/semantic/symref/grep.el index 180d779a78..e13c21bc07 100644 --- a/lisp/cedet/semantic/symref/grep.el +++ b/lisp/cedet/semantic/symref/grep.el @@ -150,15 +150,17 @@ semantic-symref-perform-search "-l ") ((eq (oref tool searchtype) 'regexp) "-nE ") - (t "-n "))) + (t (if (equal grep-program "rg") "" "-n ")))) (greppat (cond ((eq (oref tool searchtype) 'regexp) (oref tool searchfor)) (t ;; Can't use the word boundaries: Grep ;; doesn't always agree with the language ;; syntax on those. - (format "\\(^\\|\\W\\)%s\\(\\W\\|$\\)" - (oref tool searchfor))))) + (if (equal grep-program "rg") + (oref tool searchfor) + (format "\\(^\\|\\W\\)%s\\(\\W\\|$\\)" + (oref tool searchfor)))))) ;; Misc (b (get-buffer-create "*Semantic SymRef*")) (ans nil)