GNU bug report logs - #14362
24.3; Make it possible to modify compilation-find-file

Previous Next

Package: emacs;

Reported by: Gareth Rees <gdr <at> garethrees.org>

Date: Tue, 7 May 2013 19:21:02 UTC

Severity: wishlist

Tags: notabug, wontfix

Found in version 24.3

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14362 in the body.
You can then email your comments to 14362 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#14362; Package emacs. (Tue, 07 May 2013 19:21:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Gareth Rees <gdr <at> garethrees.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 07 May 2013 19:21:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Gareth Rees <gdr <at> garethrees.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3; Make it possible to modify compilation-find-file
Date: Tue, 7 May 2013 20:19:04 +0100
BACKGROUND

I'm working on the Perforce/Emacs integration
<https://github.com/gareth-rees/p4.el>, 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. 
$ p4 grep -e FIXME '*.c <at> 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.")
 
+(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))))

-- 
Gareth Rees



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14362; Package emacs. (Tue, 07 May 2013 19:31:02 GMT) Full text and rfc822 format available.

Message #8 received at 14362 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Gareth Rees <gdr <at> garethrees.org>
Cc: 14362 <at> debbugs.gnu.org
Subject: Re: bug#14362: 24.3; Make it possible to modify compilation-find-file
Date: Tue, 07 May 2013 22:28:51 +0300
> From: Gareth Rees <gdr <at> garethrees.org>
> Date: Tue, 7 May 2013 20:19:04 +0100
> 
> 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.

Isn't that what file handlers are for?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14362; Package emacs. (Tue, 07 May 2013 19:40:01 GMT) Full text and rfc822 format available.

Message #11 received at 14362 <at> debbugs.gnu.org (full text, mbox):

From: Gareth Rees <gdr <at> garethrees.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 14362 <at> debbugs.gnu.org
Subject: Re: bug#14362: 24.3; Make it possible to modify compilation-find-file
Date: Tue, 7 May 2013 20:38:08 +0100
Eli Zaretskii wrote:
> Isn't that what file handlers are for?

Yes, it is. Thank you.

-- 
Gareth Rees




Added tag(s) notabug and wontfix. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 19 Jun 2013 17:31:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 14362 <at> debbugs.gnu.org and Gareth Rees <gdr <at> garethrees.org> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 19 Jun 2013 17:31:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 18 Jul 2013 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 58 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.