unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Glenn Morris <rgm@gnu.org>
Cc: Nikolaj Schumacher <n_schumacher@web.de>, bug-gnu-emacs@gnu.org
Subject: Re: diff-find-file-name and /dev/null
Date: Mon, 27 Aug 2007 00:51:29 -0400	[thread overview]
Message-ID: <jwvabsdk2h6.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <kq1wdswf8k.fsf@fencepost.gnu.org> (Glenn Morris's message of "Fri\, 24 Aug 2007 21\:54\:35 -0400")

>> 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))
>          ;; <foo>.rej patches implicitly apply to <foo>
> --- 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))
>          ;; <foo>.rej patches implicitly apply to <foo>

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

  reply	other threads:[~2007-08-27  4:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-17 22:53 diff-find-file-name and /dev/null Nikolaj Schumacher
2007-08-17 23:33 ` Michaël Cadilhac
2007-08-19 21:06   ` Nikolaj Schumacher
2007-08-25  1:54     ` Glenn Morris
2007-08-27  4:51       ` Stefan Monnier [this message]
2007-08-27  7:10         ` Glenn Morris

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=jwvabsdk2h6.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=bug-gnu-emacs@gnu.org \
    --cc=n_schumacher@web.de \
    --cc=rgm@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).