From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Gareth Rees Newsgroups: gmane.emacs.bugs Subject: bug#14362: 24.3; Make it possible to modify compilation-find-file Date: Tue, 7 May 2013 20:19:04 +0100 Message-ID: <1D196226-AB6A-49B4-A156-83EDFE9C6905@garethrees.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1367954410 11036 80.91.229.3 (7 May 2013 19:20:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 7 May 2013 19:20:10 +0000 (UTC) To: 14362@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 07 21:20:11 2013 Return-path: Envelope-to: geb-bug-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 1UZnQn-0007o9-GB for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 May 2013 21:20:09 +0200 Original-Received: from localhost ([::1]:55321 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZnQm-0003fn-V6 for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 May 2013 15:20:08 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZnQg-0003co-CW for bug-gnu-emacs@gnu.org; Tue, 07 May 2013 15:20:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UZnQc-0001jb-T2 for bug-gnu-emacs@gnu.org; Tue, 07 May 2013 15:20:02 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57272) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZnQc-0001jX-Oc for bug-gnu-emacs@gnu.org; Tue, 07 May 2013 15:19:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UZnRe-0006G0-MY for bug-gnu-emacs@gnu.org; Tue, 07 May 2013 15:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Gareth Rees Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 May 2013 19:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 14362 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.136795443423994 (code B ref -1); Tue, 07 May 2013 19:21:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 May 2013 19:20:34 +0000 Original-Received: from localhost ([127.0.0.1]:33148 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UZnRB-0006Ex-GW for submit@debbugs.gnu.org; Tue, 07 May 2013 15:20:34 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:60554) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UZnR8-0006Eo-Fd for submit@debbugs.gnu.org; Tue, 07 May 2013 15:20:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UZnQ3-0001ae-BW for submit@debbugs.gnu.org; Tue, 07 May 2013 15:19:26 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:36551) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZnQ3-0001aa-80 for submit@debbugs.gnu.org; Tue, 07 May 2013 15:19:23 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:43638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZnPz-0003Wk-6G for bug-gnu-emacs@gnu.org; Tue, 07 May 2013 15:19:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UZnPv-0001Yl-Ow for bug-gnu-emacs@gnu.org; Tue, 07 May 2013 15:19:19 -0400 Original-Received: from raven.ravenbrook.com ([94.229.129.33]:12556) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZnPv-0001XV-Gw for bug-gnu-emacs@gnu.org; Tue, 07 May 2013 15:19:15 -0400 Original-Received: from [192.168.0.2] (cpc22-cmbg15-2-0-cust180.5-4.cable.virginmedia.com [86.27.176.181]) (authenticated bits=0) by raven.ravenbrook.com (8.14.7/8.14.5) with ESMTP id r47JJ47N095795 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Tue, 7 May 2013 20:19:04 +0100 (BST) (envelope-from gdr@garethrees.org) X-Mailer: Apple Mail (2.1503) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (raven.ravenbrook.com [94.229.129.33]); Tue, 07 May 2013 20:19:04 +0100 (BST) X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:74051 Archived-At: BACKGROUND I'm working on the Perforce/Emacs integration , and I recently added support for the "p4 grep" command. This command is just like "grep" except that it searches current or past revisions of files stored on the Perforce server. Typical output from the command looks like this: # find occurrences of FIXME in *.c as of 1st January 2013.=20 $ p4 grep -e FIXME '*.c@2013/01/01' //info.ravenbrook.com/project/mps/master/code/eventcnv.c#17: /* = FIXME: This attempted to print the event stats on a row that //info.ravenbrook.com/project/mps/master/code/mps.c#14:#include "span.c" = /* generic stack probe FIXME: Is this correct? */ The filename on the left of each hit is expressed in Perforce server format: thus the first hit is for revision number 17 of eventcnv.c. An Emacs interface to this command is easy to implement, using the grep function and setting compilation-error-regexp-alist accordingly. Except for one problem. If the user runs the p4 grep command via my interface, and then clicks on one of the hits, I want Emacs to jump to the corresponding line in that revision of the file. But the filename is given in Perforce server syntax, and compilation-next-error-function does not know how to visit that file. There seems to be no way to customize the behaviour of compilation-find-file. SUGGESTION The simplest way to support my use case would be to add a new variable compilation-find-file-function. If this is non-NIL, then call it instead of compilation-find-file. Suggested patch against 24.3 below. WORKAROUND I've set next-error-function to this function, which overrides compilation-find-file during the call to compilation-next-error-function. (defun p4-grep-next-error-function (n &optional reset) "Advance to the next error message and visit the file where the error = was. This is the value of `next-error-function' in P4 Grep buffers." (interactive "p") (let ((cff (symbol-function 'compilation-find-file))) (unwind-protect (progn (fset 'compilation-find-file 'p4-grep-find-file) (compilation-next-error-function n reset)) (fset 'compilation-find-file cff)))) PATCH --- compile.el-24.3 2013-05-07 20:07:58.000000000 +0100 +++ compile.el 2013-05-07 20:15:17.000000000 +0100 @@ -83,6 +83,15 @@ that value, otherwise it uses the value in the *compilation* buffer. This enables a major-mode to specify its own value.") =20 +(defvar compilation-find-file-function nil + "Function to call to visit a file found by `next-error' and +similar commands. It takes three arguments: MARKER FILENAME +DIRECTORY, where FILENAME is the name of the file to visit, MARKER +is the location in the compilation output where the file was +mentioned, and DIRECTORY is the \"current\" directory. If +DIRECTORY is relative, it is combined with `default-directory'. +If DIRECTORY is nil, that means use `default-directory'.") + (defvar compilation-parse-errors-filename-function nil "Function to call to post-process filenames while parsing error = messages. It takes one arg FILENAME which is the name of a file as found @@ -1972,6 +1981,7 @@ compilation-first-column compilation-mode-font-lock-keywords compilation-page-delimiter + compilation-find-file-function compilation-parse-errors-filename-function compilation-process-setup-function compilation-scroll-output @@ -2370,7 +2380,7 @@ ;; (setq timestamp = compilation-buffer-modtime))) ) (with-current-buffer - (compilation-find-file + (funcall (or compilation-find-file-function = 'compilation-find-file) marker (caar (compilation--loc->file-struct loc)) (cadr (car (compilation--loc->file-struct loc)))) --=20 Gareth Rees=