feat(emacs): grep.el + rg
This commit is contained in:
@@ -4,4 +4,35 @@
|
|||||||
;; me think it's about to kill my buffers.
|
;; me think it's about to kill my buffers.
|
||||||
(setq grep-save-buffers nil)
|
(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
|
||||||
|
'("<X>" .
|
||||||
|
(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 <X> --hidden -d 1 --no-heading -H -uu -g <F> <R> .")
|
||||||
|
(grep-apply-setting
|
||||||
|
'grep-find-template
|
||||||
|
"rg <X> --hidden --no-heading -H -uu <R> <D>")))
|
||||||
|
|
||||||
(provide 'syd/grep)
|
(provide 'syd/grep)
|
||||||
|
|||||||
Reference in New Issue
Block a user