From: Sam Halliday <sam.halliday@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: move point to first error, without opening target buffer
Date: Thu, 24 Dec 2015 16:11:09 -0800 (PST) [thread overview]
Message-ID: <a7dfb2cb-fa29-468b-821b-ebf9f9e1ed89@googlegroups.com> (raw)
In-Reply-To: <a95999db-4d9c-44e5-8cb1-89c630713771@googlegroups.com>
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))))
prev parent reply other threads:[~2015-12-25 0:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a7dfb2cb-fa29-468b-821b-ebf9f9e1ed89@googlegroups.com \
--to=sam.halliday@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).