From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sam Halliday Newsgroups: gmane.emacs.help Subject: Re: move point to first error, without opening target buffer Date: Thu, 24 Dec 2015 16:11:09 -0800 (PST) Message-ID: References: <4bd36afe-1422-4300-bbc2-fc516d780bd9@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1451002519 26286 80.91.229.3 (25 Dec 2015 00:15:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 25 Dec 2015 00:15:19 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 25 01:15:19 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aCG2R-0001Sp-9d for geh-help-gnu-emacs@m.gmane.org; Fri, 25 Dec 2015 01:15:19 +0100 Original-Received: from localhost ([::1]:33818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aCG2Q-00089O-7D for geh-help-gnu-emacs@m.gmane.org; Thu, 24 Dec 2015 19:15:18 -0500 X-Received: by 10.31.169.141 with SMTP id s135mr33209351vke.11.1451002270950; Thu, 24 Dec 2015 16:11:10 -0800 (PST) X-Received: by 10.50.30.201 with SMTP id u9mr656422igh.4.1451002270902; Thu, 24 Dec 2015 16:11:10 -0800 (PST) Original-Path: usenet.stanford.edu!6no688809qgy.0!news-out.google.com!l1ni1412igd.0!nntp.google.com!mv3no20796436igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2.101.49.251; posting-account=kRukCAoAAAANs-vsVh9dFwo5kp5pwnPz Original-NNTP-Posting-Host: 2.101.49.251 User-Agent: G2/1.0 Injection-Date: Fri, 25 Dec 2015 00:11:10 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:216182 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:108472 Archived-At: 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, > >=20 > > I am using a package called `ag' as a faster replacement for grep (silv= ersearcher), installing the emacs package like so: > >=20 > > (use-package ag > > :commands ag > > :config > > (add-hook 'ag-search-finished-hook 'next-error-no-select)) > >=20 > > for all intents and purposes, this could be any subprocess that uses th= e `compile' support and search results are shown as "errors". > >=20 > > 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 t= hat I don't have to manually `C-x o' and then `C-s' to the hits (sometimes = the preamble can be quite long). > >=20 > > 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 fi= rst 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? > >=20 > > 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. >=20 >=20 > Thanks to Sasha on #emacs for pointing me at compilation-next-error, used= like this in the hook, it works a treat! >=20 > (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-l= ast-buffer))))