all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* move point to first error, without opening target buffer
@ 2015-12-24 23:15 Sam Halliday
  2015-12-24 23:32 ` Sam Halliday
  0 siblings, 1 reply; 3+ messages in thread
From: Sam Halliday @ 2015-12-24 23:15 UTC (permalink / raw)
  To: help-gnu-emacs

Dear Emacs users,

I am using a package called `ag' as a faster replacement for grep (silversearcher), installing the emacs package like so:

    (use-package ag
      :commands ag
      :config
      (add-hook 'ag-search-finished-hook 'next-error-no-select))

for all intents and purposes, this could be any subprocess that uses the `compile' support and search results are shown as "errors".

Ag has a hook (see above) which runs when the search is complete. What I'm trying to do is to make the point jump to the first search result, so that I don't have to manually `C-x o' and then `C-s' to the hits (sometimes the preamble can be quite long).

What I have above is nearly there, but it opens the first search result in a buffer and I don't want that. I just want the point to move to the first hit so I can manually select which ones I care about. Reading through `simple.el' I'm pretty confused about how I can achieve that, could somebody please help?

In addition, it would be far better if the hook was run when the first search result (or "error") was detected. There doesn't appear to be a hook point for this, but maybe I'm wrong.

Best regards,
Sam


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: move point to first error, without opening target buffer
  2015-12-24 23:15 move point to first error, without opening target buffer Sam Halliday
@ 2015-12-24 23:32 ` Sam Halliday
  2015-12-25  0:11   ` Sam Halliday
  0 siblings, 1 reply; 3+ messages in thread
From: Sam Halliday @ 2015-12-24 23:32 UTC (permalink / raw)
  To: help-gnu-emacs

On Thursday, 24 December 2015 23:15:33 UTC, Sam Halliday  wrote:
> Dear Emacs users,
> 
> I am using a package called `ag' as a faster replacement for grep (silversearcher), installing the emacs package like so:
> 
>     (use-package ag
>       :commands ag
>       :config
>       (add-hook 'ag-search-finished-hook 'next-error-no-select))
> 
> for all intents and purposes, this could be any subprocess that uses the `compile' support and search results are shown as "errors".
> 
> Ag has a hook (see above) which runs when the search is complete. What I'm trying to do is to make the point jump to the first search result, so that I don't have to manually `C-x o' and then `C-s' to the hits (sometimes the preamble can be quite long).
> 
> What I have above is nearly there, but it opens the first search result in a buffer and I don't want that. I just want the point to move to the first hit so I can manually select which ones I care about. Reading through `simple.el' I'm pretty confused about how I can achieve that, could somebody please help?
> 
> In addition, it would be far better if the hook was run when the first search result (or "error") was detected. There doesn't appear to be a hook point for this, but maybe I'm wrong.


Thanks to Sasha on #emacs for pointing me at compilation-next-error, used like this in the hook, it works a treat!

  (defun next-match-jump ()
    "Jump the point and user's focus to first match in a `compile'."
    (pop-to-buffer next-error-last-buffer)
    (compilation-next-error 1))


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: move point to first error, without opening target buffer
  2015-12-24 23:32 ` Sam Halliday
@ 2015-12-25  0:11   ` Sam Halliday
  0 siblings, 0 replies; 3+ messages in thread
From: Sam Halliday @ 2015-12-25  0:11 UTC (permalink / raw)
  To: help-gnu-emacs

On Thursday, 24 December 2015 23:32:27 UTC, Sam Halliday  wrote:
> On Thursday, 24 December 2015 23:15:33 UTC, Sam Halliday  wrote:
> > Dear Emacs users,
> > 
> > I am using a package called `ag' as a faster replacement for grep (silversearcher), installing the emacs package like so:
> > 
> >     (use-package ag
> >       :commands ag
> >       :config
> >       (add-hook 'ag-search-finished-hook 'next-error-no-select))
> > 
> > for all intents and purposes, this could be any subprocess that uses the `compile' support and search results are shown as "errors".
> > 
> > Ag has a hook (see above) which runs when the search is complete. What I'm trying to do is to make the point jump to the first search result, so that I don't have to manually `C-x o' and then `C-s' to the hits (sometimes the preamble can be quite long).
> > 
> > What I have above is nearly there, but it opens the first search result in a buffer and I don't want that. I just want the point to move to the first hit so I can manually select which ones I care about. Reading through `simple.el' I'm pretty confused about how I can achieve that, could somebody please help?
> > 
> > In addition, it would be far better if the hook was run when the first search result (or "error") was detected. There doesn't appear to be a hook point for this, but maybe I'm wrong.
> 
> 
> Thanks to Sasha on #emacs for pointing me at compilation-next-error, used like this in the hook, it works a treat!
> 
>   (defun next-match-jump ()
>     "Jump the point and user's focus to first match in a `compile'."
>     (pop-to-buffer next-error-last-buffer)
>     (compilation-next-error 1))

actually, much better is this

(setq compilation-scroll-output 'first-error)

(use-package ag
  :commands ag
  :init
  (setq ag-reuse-window 't)
  :config
  (add-hook 'ag-search-finished-hook (lambda () (pop-to-buffer next-error-last-buffer))))


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-25  0:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-24 23:15 move point to first error, without opening target buffer Sam Halliday
2015-12-24 23:32 ` Sam Halliday
2015-12-25  0:11   ` Sam Halliday

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.