From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.devel 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 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1187229286 7738 80.91.229.12 (16 Aug 2007 01:54:46 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 16 Aug 2007 01:54:46 +0000 (UTC) Cc: emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 16 03:54:44 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1ILUZO-0002Vb-MY for ged-emacs-devel@m.gmane.org; Thu, 16 Aug 2007 03:54:42 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ILUZO-0005tb-CS for ged-emacs-devel@m.gmane.org; Wed, 15 Aug 2007 21:54:42 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ILUZL-0005sQ-9v for emacs-devel@gnu.org; Wed, 15 Aug 2007 21:54:39 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ILUZK-0005rK-Ls for emacs-devel@gnu.org; Wed, 15 Aug 2007 21:54:38 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ILUZK-0005rF-Hb for emacs-devel@gnu.org; Wed, 15 Aug 2007 21:54:38 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ILUZK-0003sR-2M for emacs-devel@gnu.org; Wed, 15 Aug 2007 21:54:38 -0400 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.60) (envelope-from ) id 1ILUcp-0004AO-HE; Wed, 15 Aug 2007 21:58:15 -0400 X-Spook: domestic disruption warfare DES Clinton S Key NORAD mania X-Ran: uB;0f\![s|f<)[oIU0D1Fmur=,.>ok]G!%uQ$bibG,7kCgk5e3Nx%K3u|0KV%?.v X-Hue: black X-Attribution: GM In-Reply-To: (Richard Stallman's message of "Sat, 11 Aug 2007 01:05:22 -0400") User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) X-Detected-Kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:76606 Archived-At: > 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))