From 148ba2a3d1e226c257baef4af3815033aab71656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Madeleine=20Sydney=20=C5=9Alaga?= Date: Wed, 5 Nov 2025 05:13:54 -0700 Subject: [PATCH] feat(emacs): grep.el + rg --- .../home/users/msyds/emacs/lisp/syd/grep.el | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/modules/home/users/msyds/emacs/lisp/syd/grep.el b/modules/home/users/msyds/emacs/lisp/syd/grep.el index 08f0339..b1b4597 100644 --- a/modules/home/users/msyds/emacs/lisp/syd/grep.el +++ b/modules/home/users/msyds/emacs/lisp/syd/grep.el @@ -4,4 +4,35 @@ ;; me think it's about to kill my buffers. (setq grep-save-buffers nil) +;; rgrep-compatibility stolen from Faye }:P. +(when (executable-find "rg") + ;; Use rgrep-compatible flags for exclusion + (with-eval-after-load 'grep + (add-to-list + 'grep-expand-keywords + '("" . + (when-let* ((ignores (grep-find-ignored-files dir))) + (concat " --glob=" + (mapconcat + (lambda (ignore) + (shell-quote-argument (concat "!" ignore) + grep-quoting-style)) + ignores + " --glob="))))) + + ;; Hide ripgrep exclusion flags + (add-to-list + 'grep-mode-font-lock-keywords + '("^rg \\( *--glob.*--glob[^ ]+\\)" + (1 (if grep-find-abbreviate grep-find-abbreviate-properties + '(face nil abbreviated-command t))))) + + ;; Populate rg cmdline for grep-template and grep-find-template + (grep-apply-setting + 'grep-template + "rg --hidden -d 1 --no-heading -H -uu -g .") + (grep-apply-setting + 'grep-find-template + "rg --hidden --no-heading -H -uu "))) + (provide 'syd/grep)