emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: address@hidden: compile/grep: When directory tracking is used then n


From: Glenn Morris
Subject: Re: address@hidden: 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
User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)

> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]