unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Glenn Morris <rgm@gnu.org>
To: rms@gnu.org
Cc: emacs-devel@gnu.org
Subject: Re: [ozymandias.dk@gmail.com: compile/grep: When directory tracking is used then next-error fails to go to the correct file when the basename was seen before.]
Date: Wed, 15 Aug 2007 21:58:15 -0400	[thread overview]
Message-ID: <xqbqd8b5qg.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <E1IJjAA-000348-Mf@fencepost.gnu.org> (Richard Stallman's message of "Sat, 11 Aug 2007 01:05:22 -0400")


> The problem occurs occurs when compiling or grepping. After running
> the compile command that gave the output seen below then running
> next-error four times only visits dir1/file.cpp. The third
> next-error should have opened dir2/file.cpp. The problem occurs
> because the same filename (basename) file.cpp is used in the two
> directories.
>
> make -w -C dir1; make -w -C dir2
> make: Entering directory `/Users/vagn/tmp/dir1'
> g++ -Wall file.cpp
> file.cpp: In function 'int main(int, char**)':
> file.cpp:5: warning: unused variable 'xx1'
> file.cpp:6: warning: unused variable 'xx2'
> make: Leaving directory `/Users/vagn/tmp/dir1'
> make: Entering directory `/Users/vagn/tmp/dir2'
> g++ -Wall file.cpp
> file.cpp: In function 'int main(int, char**)':
> file.cpp:5: warning: unused variable 'yy'
> file.cpp:6: warning: unused variable 'yy2'
> make: Leaving directory `/Users/vagn/tmp/dir2'


The fix below seems to work (very lightly tested), but please could
someone familiar with compile.el comment. As I see it, the problem is:

In compilation-get-file-structure `file' is (filename . spec-directory),
where filename is a relative file name.

When there is no entry for filename in compilation-locs, the second
puthash below creates a hash entry for just filename, ie "file.cpp".

On each subsequent call to this function, (gethash filename) is going
to return this value. It may not be appropriate if the file is in a
different directory, so if one has directory information one should
use it.


*** compile.el	13 Aug 2007 13:40:55 -0000	1.441
--- compile.el	16 Aug 2007 01:51:34 -0000
***************
*** 1972,1978 ****
  	;; Store it for the possibly unnormalized name
  	(puthash file
  		 ;; Retrieve or create file-structure for normalized name
! 		 (or (gethash (list filename) compilation-locs)
  		     (puthash (list filename)
  			      (list (list filename spec-directory) fmt)
  			      compilation-locs))
--- 1972,1981 ----
  	;; Store it for the possibly unnormalized name
  	(puthash file
  		 ;; Retrieve or create file-structure for normalized name
! 		 (or (gethash (if spec-directory
!                                   (cons filename spec-directory)
!                                 (list filename))
!                                 compilation-locs)
  		     (puthash (list filename)
  			      (list (list filename spec-directory) fmt)
  			      compilation-locs))

  reply	other threads:[~2007-08-16  1:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-11  5:05 [ozymandias.dk@gmail.com: compile/grep: When directory tracking is used then next-error fails to go to the correct file when the basename was seen before.] Richard Stallman
2007-08-16  1:58 ` Glenn Morris [this message]
2007-08-16  3:46   ` Stefan Monnier
2007-08-16  7:25     ` Glenn Morris
2007-08-17  0:31   ` Richard Stallman
2007-08-17  7:23     ` Glenn Morris
     [not found]       ` <E1IM8G7-0005St-1z@fencepost.gnu.org>
2007-08-17 20:41         ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2007-08-03 22:02 Richard Stallman

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=xqbqd8b5qg.fsf@fencepost.gnu.org \
    --to=rgm@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=rms@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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).