[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: move point to first error, without opening target buffer
From: |
Sam Halliday |
Subject: |
Re: move point to first error, without opening target buffer |
Date: |
Thu, 24 Dec 2015 15:32:25 -0800 (PST) |
User-agent: |
G2/1.0 |
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))