bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#23824: 25.0.95; Prevent compare one buffer with itself


From: Eli Zaretskii
Subject: bug#23824: 25.0.95; Prevent compare one buffer with itself
Date: Thu, 23 Jun 2016 18:27:04 +0300

> Cc: 23824@debbugs.gnu.org
> From: Tino Calancha <f92capac@gmail.com>
> Date: Thu, 23 Jun 2016 09:58:02 +0900
> 
> > I think we need first to establish what exactly is the semantic of
> > this situation.  You are comparing a buffer with the file that the
> > buffer visits.  The doc string of this function tries to say something
> > about this situation:
> >
> >    If the current buffer is visiting the file being compared against, it
> >    also will have its differences highlighted.  Otherwise, the file is
> >    read in temporarily but the buffer is deleted.
> >
> > but I must confess that this is incomprehensible for me.  So I think
> > we should first establish what that means, or what the code is trying
> > to do.
>   I understand what the doc means:  if the current buffer (buf-a) is 
> visiting file-b,
> then this func will perform a diff between buf-a and file-b.

But then what is that "also" word doing in the doc string?

> * So, if  buf-a is modified, the command highlight you the differences 
> with file-b, so
>    let you decide if you want to save buf-a (overwritting file-b) or 
> not.  It sounds useful.
> * Current implementation doesn't match the doc string: even if buf-a is 
> visiting file-b and
>    modified, the func compare buf-a with buf-a, so that you never get 
> nothing highlight
>    in this case.

I think there's more here than meets the eye.  Did you ask yourself
why the user is asked twice whether to save the same buffer to the
same file in your scenario?  Why does it do that?  What does it have
in mind?

> >> +                         (with-current-buffer buf-new
> >> +                           (insert-file-contents-literally file-b)
> > ??? Why insert-file-contents-literally?  That definitely sounds wrong.
> >
> > Thanks.
> 
> We can use: (insert-file-contents file-b)
> it doesn't matter.

Oh, it matters a lot.  insert-file-contents-literally will bypass any
decoding and leave the CR-LF EOLs untranslated, something that you
don't want to affect the comparison.





reply via email to

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