From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: Re: diff-find-file-name and /dev/null Date: Mon, 27 Aug 2007 00:51:29 -0400 Message-ID: References: <878x89ag8z.fsf@lrde.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1188190303 23605 80.91.229.12 (27 Aug 2007 04:51:43 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 27 Aug 2007 04:51:43 +0000 (UTC) Cc: Nikolaj Schumacher , bug-gnu-emacs@gnu.org To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 27 06:51:41 2007 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IPWZd-0007Kl-NR for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Aug 2007 06:51:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IPWZd-00088A-1u for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Aug 2007 00:51:37 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IPWZb-000885-Bi for bug-gnu-emacs@gnu.org; Mon, 27 Aug 2007 00:51:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IPWZa-00087t-Ue for bug-gnu-emacs@gnu.org; Mon, 27 Aug 2007 00:51:35 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IPWZa-00087q-PN for bug-gnu-emacs@gnu.org; Mon, 27 Aug 2007 00:51:34 -0400 Original-Received: from tomts10.bellnexxia.net ([209.226.175.54] helo=tomts10-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IPWZX-0005xX-I1; Mon, 27 Aug 2007 00:51:31 -0400 Original-Received: from pastel.home ([70.55.146.55]) by tomts10-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20070827045130.ITBJ9197.tomts10-srv.bellnexxia.net@pastel.home>; Mon, 27 Aug 2007 00:51:30 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 9FE7F7F7A; Mon, 27 Aug 2007 00:51:29 -0400 (EDT) In-Reply-To: (Glenn Morris's message of "Fri\, 24 Aug 2007 21\:54\:35 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) X-Detected-Kernel: Solaris 8 (1) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:16452 Archived-At: >> Since there's nothing to view or edit in /dev/null. > How about this patch then: > diff -c -c -w -r1.99.2.3 diff-mode.el > *** diff-mode.el 6 Aug 2007 20:08:07 -0000 1.99.2.3 > --- diff-mode.el 25 Aug 2007 01:41:53 -0000 > *************** > *** 646,652 **** > ((or (null files) > (setq file (do* ((files files (cdr files)) > (file (car files) (car files))) > ! ((or (null file) (file-exists-p file)) > file)))) > file)) > ;; .rej patches implicitly apply to > --- 646,652 ---- > ((or (null files) > (setq file (do* ((files files (cdr files)) > (file (car files) (car files))) > ! ((or (null file) (file-regular-p file)) > file)))) > file)) > ;; .rej patches implicitly apply to Looks very good. This will also rule out directories. Please install. >> I admit the actual fault could be the fact that it looks for first >> one at all (or at least _before_ chopping off prefixes of the second >> one), even when diff-jump-to-old-file is nil. /dev/null is just the >> only cause of such behavior. > Yes, I don't see why diff-find-file-name does that, and I don't think > /dev/null is the only cause. Eg repeating the above example, but with > regular files: > diff -u /tmp/file1 foo/file2 > foo/file.diff > diff-goto-source will open file1 rather than file2. > Stefan, is there a reason why diff-find-file-name can return the old > file, even when OLD is nil? Why doesn't it just consider > (car (diff-hunk-file-names old))? diff-find-file-name tries pretty hard to find *A* file, so I think it's OK for it to sometimes return an old file even when OLD is nil. But maybe the order in which file names are tried could be improved. > If it should consider both old and new in each case, should it not try > dropping the directory entries from the new/old file first, before > going on to check the old/new one in the same way only it it does not > find a match? Sounds right. The current ordering is somewhat arbitrary. Fell free to change it as you suggest, but for any such change, please add a comment explaining the situation for which the change makes sense. Stefan