Subject: bug#11777: 24.1.50; Format strings for filenames in compilation-error-regexp-alist don't work

From: Magnus Henoch <[email-masked]>
Date: Mon, 25 Jun 2012 12:01:46 +0100

Add a new regexp for compilation-mode:

(add-to-list
 'compilation-error-regexp-alist-alist
 (cons
  'erlang-eunit
  (list
   "^ *\\([^.:( \t\n]+\\):\\([0-9]+\\):.*\\.\\.\\."
   ;; file
   (list 1 "%s.erl" "src/%s.erl" "test/%s.erl")
   ;; line
   2
   ;; column
   nil
   ;; type
   0
   )))
(add-to-list 'compilation-error-regexp-alist 'erlang-eunit)

Create a new file, /tmp/foo.txt, and enter the following line:

  foo:954: all_test_...ok

Switch foo.txt into compilation-mode with M-x compilation-mode.

Create the file /tmp/src/foo.erl.

In foo.txt, hit RET on the now highlighted line.

Expected result: switch to the foo.erl buffer.
Actual result: prompt for file to open, default being "foo".

This patch seems to fix the problem:

diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 61dc371..d9dd1c0 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -2344,10 +2344,12 @@ This is the value of `next-error-function' in
Compilation buffers."
                  ;;            (setq timestamp compilation-buffer-modtime)))
                  )
       (with-current-buffer
-          (compilation-find-file
+          (apply
+	   'compilation-find-file
            marker
            (caar (compilation--loc->file-struct loc))
-           (cadr (car (compilation--loc->file-struct loc))))
+	   (cadr (car (compilation--loc->file-struct loc)))
+	   (compilation--file-struct->formats (compilation--loc->file-struct loc)))
         (let ((screen-columns
                ;; Obey the compilation-error-screen-columns of the target
                ;; buffer if its major mode set it buffer-locally.

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
/Applications/Emacs.app/Contents/Resources/etc/DEBUG.

In GNU Emacs 24.1.50.1 (x86_64-apple-darwin10.8.0, NS apple-appkit-1038.36)
 of 2012-05-17 on poki-sona.local
Windowing system distributor `Apple', version 10.3.1038
Configured using:
 `configure '--with-ns' '--without-rsvg''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  value of $XMODIFIERS: nil
  locale-coding-system: nil
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  diff-auto-refine-mode: t
  jabber-activity-mode: t
  shell-dirtrack-mode: t
  ido-everywhere: t
  show-paren-mode: t
  display-time-mode: t
  server-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
c o m p i l a t <return> C-x k <return> C-x b u t i
p <return> M-x c o m p i l e <return> <return> C-x
o <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <return> C-g C-g q C-x k <return>
C-x b e s h e <return> g i t SPC <backspace> <backspace>
<backspace> <backspace> s t a s h SPC p o p <return>
C-x b <return> M-x e v a l - b u f <return> C-x b C-g
q C-x o M-x <up> <up> <return> <return> <down> <down>
C-x o C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n <return>
C-g q C-x b c a p <backspace> <backspace> <backspace>
d o t e m <return> <down> <down> <down> <down> <down>
<down> <down> <down> <down> C-c ' <up> C-e C-x C-e
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> C-x
C-e C-n C-e C-x C-e C-c ' <up> <up> <up> C-x o C-x
k * c o m <return> M-x c o m p l <backspace> i l e
<return> <return> SPC C-x o <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <return>
C-g q C-x b c o m p i l e <return> C-x v = <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> C-c C-c y e s <return> C-M-x C-x b <return>
C-x k <return> C-x b u t i p <return> M-x c o m p i
l e <return> <return> C-x o C-n C-n C-n C-n C-n C-n
C-n C-n C-n C-n C-n C-n <return> C-x o C-n C-n C-n
<return> C-x b C-s <return> M-x r e c <backspace> p
- e m - b u g <return>

Recent messages:
Entering debugger...
Back to top level.
Finding changes in /Users/magnus/src/emacs/lisp/progmodes/compile.el...done
Previous buffer text saved to kill ring
Hunk already applied
compilation-next-error-function
(No files need saving)
Mark set
Compilation finished
Mark set

Load-path shadows:
~/src/emacs-jabber/compat/hex-util hides
/Applications/Emacs.app/Contents/Resources/lisp/hex-util

Features:
(shadow sort mail-extr emacsbug message rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums whitespace diff bookmark cl-specs
edebug jka-compr nxml-uchnm rng-xsd xsd-regexp rng-cmpct rng-nxml
rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt rng-util
rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph
nxml-enc xmltok vc-annotate conf-mode tramp-cache tramp tramp-compat
tramp-loaddefs man log-edit smerge-mode browse-url erlang-flymake
flymake find-dired grep cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs debug tabify image-file
face-remap imenu erlang etags compile em-unix em-term term disp-table
ehelp electric em-script em-prompt em-ls em-hist em-pred em-glob em-dirs
em-cmpl em-basic esh-opt em-banner em-alias esh-var esh-io esh-cmd
esh-ext esh-proc esh-arg eldoc esh-groups eshell esh-module esh-mode
esh-util add-log log-view pcvs-util multi-isearch make-mode diff-mode
vc-bzr vc-sccs vc-svn vc-cvs vc-rcs vc-dir vc ediff-merg ediff-diff
ediff-wind ediff-help ediff-util ediff-mult ediff-init ediff
vc-dispatcher dired sasl-digest hmac-md5 hex-util goto-addr thingatpt
jabber-keepalive jabber-ping jabber-bookmarks jabber-private
network-stream auth-source eieio password-cache jabber jabber-libnotify
dbus jabber-awesome jabber-osd jabber-wmii jabber-xmessage
jabber-festival jabber-sawfish jabber-ratpoison jabber-tmux
jabber-screen jabber-socks5 jabber-ft-server jabber-si-server
jabber-ft-client jabber-ft-common jabber-si-client jabber-si-common
jabber-feature-neg jabber-truncate jabber-time jabber-autoaway
jabber-vcard-avatars jabber-chatstates jabber-events jabber-vcard
jabber-avatar mailcap jabber-activity jabber-watch jabber-modeline
jabber-ahc-presence jabber-ahc jabber-version jabber-ourversion
jabber-muc-nick-completion hippie-exp jabber-browse jabber-search
jabber-register jabber-roster jabber-presence jabber-muc
jabber-muc-nick-coloring assoc hexrgb jabber-newdisco jabber-widget
jabber-disco jabber-chat jabber-history jabber-chatbuffer jabber-alert
jabber-iq jabber-core jabber-sasl sasl sasl-anonymous sasl-login
sasl-plain fsm jabber-logon jabber-conn srv dns starttls tls gnutls
jabber-xml xml jabber-menu ielm pp help-mode view org-beamer org-clock
vc-git org-wl org-w3m org-vm org-rmail org-mhe org-mew org-irc
org-jsinfo org-infojs org-html org-exp ob-exp org-exp-blocks find-func
org-agenda org-info org-gnus org-docview org-bibtex bibtex org-bbdb
jabber-console sgml-mode ewoc jabber-util jabber-keymap ob-sh shell ido
gnus gnus-ems nnheader gnus-util mail-utils mm-util mail-prsvr wid-edit
cus-start cus-load jabber-autoloads erlang-start tempo derived paren
uniquify time org-capture org-mks org byte-opt warnings bytecomp
byte-compile cconv macroexp advice help-fns advice-preload ob-emacs-lisp
ob-ref ob-lob ob-table org-footnote org-pcomplete pcomplete org-list
org-faces org-entities noutline outline easy-mmode format-spec diary-lib
diary-loaddefs cal-menu easymenu calendar cal-loaddefs cl server edmacro
kmacro ob-tangle org-src ob-comint comint ansi-color ring ob-keys
org-compat ob org-macs ob-eval time-date tooltip ediff-hook vc-hooks
lisp-float-type mwheel ns-win tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment lisp-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces
cus-face files text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote
make-network-process dbusbind ns multi-tty emacs)