Closed casch-at closed 9 years ago
OK, so the default behaviour of n
and p
in the results buffer is to simply move point to the next search result.
If I've understood correctly, you're proposing n
to move point in the search buffer and to open the relevant result.
I think this is the same as next-error-follow-minor-mode
, which you can enable with C-c C-f
in a results buffer. If you want this behaviour on by default, try this:
(add-hook 'ag-mode-hook #'next-error-follow-minor-mode)
Does that meet your needs?
(If so, we should probably clarify this in the docs.)
@Wilfred Looks like next-error-follow-minor-mode
enables only the follow mode that syncs the ag results with the corresponding locations in files.
As @cslux updated, those bindings will have to be added to the ag-mode-map
, just as grep.el
does:
(defvar grep-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map compilation-minor-mode-map)
(define-key map " " 'scroll-up-command)
(define-key map [?\S-\ ] 'scroll-down-command)
(define-key map "\^?" 'scroll-down-command)
(define-key map "\C-c\C-f" 'next-error-follow-minor-mode)
(define-key map "\r" 'compile-goto-error) ;; ?
(define-key map "n" 'next-error-no-select)
(define-key map "p" 'previous-error-no-select)
Thanks for the pointer @cslux, I have remapped those bindings in ag-mode-map in my config.
@Wilfred yes that meet my needs, didn't know that.
Thank you! Chris
Hey,
first off all, thank you for this extension for _the_silversearcher.
It would be great if the key
n
andp
in the ag search buffer are bound tonext-error-no-select
andprevious-error-no-select
by default, as it is in grep search buffer.In grep search buffer you can move right to the location with
n
andp
(no leaving of the buffer) whereas in ag search buffer you would have to pressC-c C-c
orEnter
to jump to the location and than you would have to go back. Of course as the parent mode iscompiliation-mode
you could also pressC-x `` to jump to next "error" or
M-g pto jump to the previous "error". But I think if you use
grepor
ag` you usually want to investigate the hits quickly with less key strokes.Just my opinion, let me know what you think.
regards, Christian
UPDATE:
For now I have added this to my emacs init file.
Would be nice if this would be the default bindings.