commit d8d2d9164d1781ad7a958d4e9b888d7b708a5842
parent 20e8bf0866b62a7987163f650776a93cd2a34478
Author: Vincent Demeester <vincent@sbr.pm>
Date: Wed, 8 Apr 2020 18:51:33 +0200
config-search.el: re-enable grep, wgrep and rg
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Diffstat:
1 file changed, 48 insertions(+), 30 deletions(-)
diff --git a/tools/emacs/config/config-search.el b/tools/emacs/config/config-search.el
@@ -1,13 +1,6 @@
;;; -*- lexical-binding: t; -*-
-;; Ignore directories during grep
-(with-eval-after-load 'grep
- '(progn
- (add-to-list 'grep-find-ignored-directories "auto")
- (add-to-list 'grep-find-ignored-directories "elpa")))
-
-;; Truncate lines during grep
-(add-hook 'grep-mode-hook #'toggle-truncate-lines)
+;; UseISearch
(use-package isearch
:disabled
:config
@@ -52,23 +45,42 @@ confines of word boundaries (e.g. multiple words)."
:map isearch-mode-map
("DEL" . contrib/isearchp-remove-failed-part-or-last-char)
("<C-return>" . contrib/isearch-done-opposite-end)))
+;; -UseISearch
-(use-package anzu
- :disabled
- :ensure t
- :delight
+;; UseGrep
+(use-package grep
+ :commands (find-grep grep find-grep-dired find-name-dired)
+ :bind (("M-s n" . find-name-dired)
+ ("M-s F" . find-grep)
+ ("M-s G" . grep)
+ ("M-s d" . find-grep-dired))
+ :hook ((hook-mode . toggle-truncate-lines))
+ :config
+ (add-to-list 'grep-find-ignored-directories "auto")
+ (add-to-list 'grep-find-ignored-directories "elpa"))
+;; -UseGrep
+
+;; UseWgrep
+(use-package wgrep
+ :commands (wgrep-change-to-wgrep-mode)
+ :defer 2
:custom
- (anzu-search-threshold 100)
- (anzu-replace-threshold nil)
- (anzu-deactivate-region nil)
- (anzu-replace-to-string-separator "")
+ (wgrep-auto-save-buffer t)
+ (wgrep-change-readonly-file t))
+;; -UseWgrep
+
+;; UseRG
+(use-package rg
+ :if *rg*
+ :commands (rg rg-project rg-dwim)
+ :bind (("M-s r r" . rg)
+ ("M-s r p" . rg-project)
+ ("M-s r s" . rg-dwiw))
+ :hook (after-init . rg-enable-default-binding)
:config
- (global-anzu-mode 1)
- :bind (([remap isearch-query-replace] . anzu-isearch-query-replace)
- ([remap isearch-query-replace-regexp] . anzu-isearch-query-replace-regexp))
- ([remap query-replace] . anzu-query-replace)
- ([remap query-replace-regexp] . anzu-query-replace-regexp)
- ("M-s %" . anzu-query-replace-at-cursor))
+ (with-eval-after-load 'projectile
+ (defalias 'projectile-ripgrep #'rg-project)))
+;; -UseRG
(use-package swiper
:disabled
@@ -84,15 +96,21 @@ confines of word boundaries (e.g. multiple words)."
("M-y" . yank)
("C-." . swiper-avy)))
-(use-package wgrep
+(use-package anzu
:disabled
- :defer 2
+ :ensure t
+ :delight
:custom
- (wgrep-auto-save-buffer t)
- (wgrep-change-readonly-file t))
-
-(use-package rg
- :disabled
- :hook (after-init . rg-enable-default-binding))
+ (anzu-search-threshold 100)
+ (anzu-replace-threshold nil)
+ (anzu-deactivate-region nil)
+ (anzu-replace-to-string-separator "")
+ :config
+ (global-anzu-mode 1)
+ :bind (([remap isearch-query-replace] . anzu-isearch-query-replace)
+ ([remap isearch-query-replace-regexp] . anzu-isearch-query-replace-regexp))
+ ([remap query-replace] . anzu-query-replace)
+ ([remap query-replace-regexp] . anzu-query-replace-regexp)
+ ("M-s %" . anzu-query-replace-at-cursor))
(provide 'setup-search)