Added better grepping utilities, per file or for the configuration file
Better than (counsel-rg-or-swiper), provides a buffer of results that I can deal with as I want.
This commit is contained in:
@@ -1439,6 +1439,8 @@ thing faster and within Emacs lisp. ~rgrep~ is useful though.
|
|||||||
(reusable-frames . t))
|
(reusable-frames . t))
|
||||||
:general
|
:general
|
||||||
(search-leader
|
(search-leader
|
||||||
|
"g" #'grep-this-file
|
||||||
|
"c" #'grep-config-file
|
||||||
"d" #'rgrep)
|
"d" #'rgrep)
|
||||||
(nmmap
|
(nmmap
|
||||||
:keymaps 'grep-mode-map
|
:keymaps 'grep-mode-map
|
||||||
@@ -1453,7 +1455,25 @@ thing faster and within Emacs lisp. ~rgrep~ is useful though.
|
|||||||
"ZQ" #'wgrep-abort-changes)
|
"ZQ" #'wgrep-abort-changes)
|
||||||
:config
|
:config
|
||||||
;; Without this wgrep doesn't work properly
|
;; Without this wgrep doesn't work properly
|
||||||
(evil-set-initial-state 'grep-mode 'normal))
|
(evil-set-initial-state 'grep-mode 'normal)
|
||||||
|
|
||||||
|
(defun grep-file (query filename)
|
||||||
|
(grep (format "grep --color=auto -nIiHZEe \"%s\" -- %s"
|
||||||
|
query filename)))
|
||||||
|
|
||||||
|
(defun grep-this-file ()
|
||||||
|
(interactive)
|
||||||
|
(let ((query (read-string "Search for: ")))
|
||||||
|
(if (buffer-file-name (current-buffer))
|
||||||
|
(grep-file query (buffer-file-name (current-buffer)))
|
||||||
|
(let ((temp-file (make-temp-file "temp-grep")))
|
||||||
|
(write-region (point-min) (point-max) temp-file)
|
||||||
|
(grep-file query temp-file)))))
|
||||||
|
|
||||||
|
(defun grep-config-file ()
|
||||||
|
(interactive)
|
||||||
|
(let ((query (read-string "Search for: " "^[*]+ .*")))
|
||||||
|
(grep-file query (concat user-emacs-directory "config.org")))))
|
||||||
#+end_src
|
#+end_src
|
||||||
*** rg
|
*** rg
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
|
|||||||
Reference in New Issue
Block a user