unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Diff Mode: Can I apply a difference to a buffer of my choosing?
@ 2006-01-29 15:02 Alan Mackenzie
  2006-02-04 22:35 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Mackenzie @ 2006-01-29 15:02 UTC (permalink / raw)


Emacs 21.3.

I have a file, cc-defs.el.diff, which I created with a "cvs diff"
operation on the Emacs CVS at savannah, like this:

    # cvs diff -c -r1.36 -r 1.37 cc-defs.el > cc-defs.el.diff

.  I have loaded cc-defs.el.diff into a buffer in Diff Mode.  I want to
apply one of its diffs to a buffer (coincidentally also called
cc-defs.el).  However, when I try C-c C-a (`diff-apply-hunk'), Emacs
loads a different version of cc-defs.el, and applies the patch to that.

Is there any convenient way of associating cc-defs.el.diff with the
buffer I want to change?  Neither C-h m nor the Emacs manual seems to
suggest a way.

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Diff Mode: Can I apply a difference to a buffer of my choosing?
  2006-01-29 15:02 Diff Mode: Can I apply a difference to a buffer of my choosing? Alan Mackenzie
@ 2006-02-04 22:35 ` Stefan Monnier
  2006-02-10 11:11   ` Alan Mackenzie
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2006-02-04 22:35 UTC (permalink / raw)


> .  I have loaded cc-defs.el.diff into a buffer in Diff Mode.  I want to
> apply one of its diffs to a buffer (coincidentally also called
> cc-defs.el).  However, when I try C-c C-a (`diff-apply-hunk'), Emacs
> loads a different version of cc-defs.el, and applies the patch to that.

diff-mode basically looks at the diff's header (or "Index:" line) to find
the file name to which the patch should be applied, then does find-file on
that file to get the buffer.

So you can try to get what you want, by doing a M-x cd in the diff's buffer
before C-s C-a (presumaing the diff's header uses relative path names).

> Is there any convenient way of associating cc-defs.el.diff with the
> buffer I want to change?

In Emacs-CVS, I've added a command diff-tell-file-name to do just that (tho
it still doesn't allow you to bind to a buffer, only to a filename).

In previous versions, you can do is M-x cd RET /some/where/else since if
diff-mode can't find the file on its own, it then asks you to enter the
destination file name interactively.


        Stefan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Diff Mode: Can I apply a difference to a buffer of my choosing?
  2006-02-04 22:35 ` Stefan Monnier
@ 2006-02-10 11:11   ` Alan Mackenzie
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Mackenzie @ 2006-02-10 11:11 UTC (permalink / raw)


Stefan Monnier <monnier@iro.umontreal.ca> wrote on Sat, 04 Feb 2006
17:35:55 -0500:
>> .  I have loaded cc-defs.el.diff into a buffer in Diff Mode.  I want
>> to apply one of its diffs to a buffer (coincidentally also called
>> cc-defs.el).  However, when I try C-c C-a (`diff-apply-hunk'), Emacs
>> loads a different version of cc-defs.el, and applies the patch to
>> that.

> diff-mode basically looks at the diff's header (or "Index:" line) to
> find the file name to which the patch should be applied, then does
> find-file on that file to get the buffer.

> So you can try to get what you want, by doing a M-x cd in the diff's
> buffer before C-c C-a (presumaing the diff's header uses relative path
> names).

YES, YES, YES!!!  Brilliant!  Fantastic!  That works!

Thanks!

>> Is there any convenient way of associating cc-defs.el.diff with the
>> buffer I want to change?

> In Emacs-CVS, I've added a command diff-tell-file-name to do just that
> (tho it still doesn't allow you to bind to a buffer, only to a
> filename).

OK.  Binding to a buffer would be nice to have, but binding to a file
will be good enough nearly all the time.

> In previous versions, what you can do is M-x cd RET /some/where/else
> since if diff-mode can't find the file on its own, it then asks you to
> enter the destination file name interactively.

Again, thanks!

>         Stefan

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-02-10 11:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-29 15:02 Diff Mode: Can I apply a difference to a buffer of my choosing? Alan Mackenzie
2006-02-04 22:35 ` Stefan Monnier
2006-02-10 11:11   ` Alan Mackenzie

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).