blob: 319919a87431f0c6d8d24bfcb95f94d586e97928 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
(defun grep-visit-buffer-other-window (&optional event noselect)
"Visit grep result in another window."
(interactive)
(let ((current-window (selected-window)))
(compile-goto-error event)
(when noselect
(select-window current-window))))
(defun grep-visit-buffer-other-window-noselect (&optional event)
"Visit grep result in another window, but don't select it."
(interactive)
(grep-visit-buffer-other-window event t))
(defun grep-mode-buffer-local-variables ()
;; wrap lines
(setq-local truncate-lines nil))
(use-package grep
:demand t ;; this cannot lazy load as bindings are inside a mode map
:hook (grep-mode . grep-mode-buffer-local-variables)
:bind (:map grep-mode-map
;; make C-o and o behave as in dired
("o" . grep-visit-buffer-other-window)
("C-o" . grep-visit-buffer-other-window-noselect)
;; n and p changes line as in ag-mode
("n" . compilation-next-error)
("p" . compilation-previous-error)))
(provide 'init-grep)
|