unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to edit/modify patches using emacs?
@ 2005-05-08 11:23 Andreas R.
  2005-05-08 11:43 ` Peter Dyballa
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Andreas R. @ 2005-05-08 11:23 UTC (permalink / raw)


When I open a patch (created by simple diff) emacs says it's read-only.

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

* Re: How to edit/modify patches using emacs?
  2005-05-08 11:23 How to edit/modify patches using emacs? Andreas R.
@ 2005-05-08 11:43 ` Peter Dyballa
  2005-05-08 12:09 ` Miles Bader
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Peter Dyballa @ 2005-05-08 11:43 UTC (permalink / raw)



Am 08.05.2005 um 13:23 schrieb Andreas R.:

> When I open a patch (created by simple diff) emacs says it's read-only.
>

Shouldn't they be read-only from nature? If you want to edit them, you 
can press e in that buffer. If that does not help, check the 
permissions of that patch file! Are you its owner? Are you allowed to 
create a backup copy of the file in its directory?

What about copying it to /tmp? This copy should be yours then and you 
should be allowed to do with it whatever idea you develop ...

--
Mit friedvollen Grüßen

   Pete

Behold the warranty ... the bold print giveth and the fine print taketh 
away.

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

* Re: How to edit/modify patches using emacs?
  2005-05-08 11:23 How to edit/modify patches using emacs? Andreas R.
  2005-05-08 11:43 ` Peter Dyballa
@ 2005-05-08 12:09 ` Miles Bader
  2005-05-08 12:19 ` Reiner Steib
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Miles Bader @ 2005-05-08 12:09 UTC (permalink / raw)


"Andreas R." <newsgroupsREMOVE@freenet.de> writes:
> When I open a patch (created by simple diff) emacs says it's read-only.

`toggle-read-only' (normally bound to C-x C-q I think).

-Miles
-- 
.Numeric stability is probably not all that important when you're guessing.

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

* Re: How to edit/modify patches using emacs?
  2005-05-08 11:23 How to edit/modify patches using emacs? Andreas R.
  2005-05-08 11:43 ` Peter Dyballa
  2005-05-08 12:09 ` Miles Bader
@ 2005-05-08 12:19 ` Reiner Steib
  2005-05-08 13:42 ` Pascal Bourguignon
  2005-05-09 19:52 ` Andreas R.
  4 siblings, 0 replies; 14+ messages in thread
From: Reiner Steib @ 2005-05-08 12:19 UTC (permalink / raw)


On Sun, May 08 2005, Andreas R. wrote:

> When I open a patch (created by simple diff) emacs says it's read-only.

Apropos is your friend: `C-h a read-only RET'

,----[ `C-h k C-x C-q' ]
| C-x C-q runs the command vc-toggle-read-only
|    which is an interactive compiled Lisp function in `vc-hooks'.
| (vc-toggle-read-only &optional VERBOSE)
`----

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

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

* Re: How to edit/modify patches using emacs?
  2005-05-08 11:23 How to edit/modify patches using emacs? Andreas R.
                   ` (2 preceding siblings ...)
  2005-05-08 12:19 ` Reiner Steib
@ 2005-05-08 13:42 ` Pascal Bourguignon
  2005-05-08 14:45   ` Miles Bader
  2005-05-09 19:52 ` Andreas R.
  4 siblings, 1 reply; 14+ messages in thread
From: Pascal Bourguignon @ 2005-05-08 13:42 UTC (permalink / raw)


"Andreas R." <newsgroupsREMOVE@freenet.de> writes:

> When I open a patch (created by simple diff) emacs says it's read-only.

You can force edit it (see the other answers), but I think the best
way to "edit" a patch, is to duplicate the source directory, apply the
patch on one copy, edit this copy of the source files, then invoke
diff  to create a new patch.

cp -r src src-orig
cd src
patch -p1 < ../modifs.patch
emacs *
cd ..
diff -Naur src-orig src > newmodifs.patch


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
You never feed me.
Perhaps I'll sleep on your face.
That will sure show you.

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

* Re: How to edit/modify patches using emacs?
  2005-05-08 13:42 ` Pascal Bourguignon
@ 2005-05-08 14:45   ` Miles Bader
  2005-05-08 21:54     ` Micha Feigin
       [not found]     ` <mailman.4139.1115590433.2819.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 14+ messages in thread
From: Miles Bader @ 2005-05-08 14:45 UTC (permalink / raw)


Pascal Bourguignon <pjb@informatimago.com> writes:
> You can force edit it (see the other answers), but I think the best
> way to "edit" a patch, is to duplicate the source directory, apply the
> patch on one copy, edit this copy of the source files, then invoke
> diff  to create a new patch.

Note that editing a patch with emacs `diff-mode' active is actually
fairly painless, because diff-mode takes care of keeping details like
the line counts updated, offers convenient functions like hunk-
splitting, makes it super easy to test your changes, etc.  I regularly
edit patches directly because of diff-mode.

[A common reason to edit a patch is because it _won't_ apply otherwise:
you basically look at the patch to see why doesn't match the source,
edit the patch to test your guess, and if it then applies cleanly,
you've got a nice record in the edited patch.]

-Miles
-- 
"Suppose we've chosen the wrong god. Every time we go to church we're
just making him madder and madder." -- Homer Simpson

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

* Re: How to edit/modify patches using emacs?
  2005-05-08 14:45   ` Miles Bader
@ 2005-05-08 21:54     ` Micha Feigin
       [not found]     ` <mailman.4139.1115590433.2819.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 14+ messages in thread
From: Micha Feigin @ 2005-05-08 21:54 UTC (permalink / raw)


On Sun, 08 May 2005 23:45:34 +0900
Miles Bader <miles@gnu.org> wrote:

> Pascal Bourguignon <pjb@informatimago.com> writes:
> > You can force edit it (see the other answers), but I think the best
> > way to "edit" a patch, is to duplicate the source directory, apply the
> > patch on one copy, edit this copy of the source files, then invoke
> > diff  to create a new patch.
> 
> Note that editing a patch with emacs `diff-mode' active is actually
> fairly painless, because diff-mode takes care of keeping details like
> the line counts updated, offers convenient functions like hunk-
> splitting, makes it super easy to test your changes, etc.  I regularly
> edit patches directly because of diff-mode.
> 
> [A common reason to edit a patch is because it _won't_ apply otherwise:
> you basically look at the patch to see why doesn't match the source,
> edit the patch to test your guess, and if it then applies cleanly,
> you've got a nice record in the edited patch.]

In such cases I just prefer to apply the patch and fix the rejects, gives you a
better overall view.

Editing patches for is useful when I know what I want to fix for sending out a
patch and I don't feel like applying it, changing the source and re-diffing
(especially useful with large source, such as modifying patches for the X or
kernel source trees)

> 
> -Miles
> -- 
> "Suppose we've chosen the wrong god. Every time we go to church we're
> just making him madder and madder." -- Homer Simpson
> 
> 
> _______________________________________________
> Help-gnu-emacs mailing list
> Help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
>  
>  +++++++++++++++++++++++++++++++++++++++++++
>  This Mail Was Scanned By Mail-seCure System
>  at the Tel-Aviv University CC.
> 

 
 +++++++++++++++++++++++++++++++++++++++++++
 This Mail Was Scanned By Mail-seCure System
 at the Tel-Aviv University CC.

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

* Re: How to edit/modify patches using emacs?
       [not found]     ` <mailman.4139.1115590433.2819.help-gnu-emacs@gnu.org>
@ 2005-05-08 23:38       ` Miles Bader
  0 siblings, 0 replies; 14+ messages in thread
From: Miles Bader @ 2005-05-08 23:38 UTC (permalink / raw)


Micha Feigin <michf@post.tau.ac.il> writes:
>> [A common reason to edit a patch is because it _won't_ apply otherwise:
>> you basically look at the patch to see why doesn't match the source,
>> edit the patch to test your guess, and if it then applies cleanly,
>> you've got a nice record in the edited patch.]
>
> In such cases I just prefer to apply the patch and fix the rejects, gives you a
> better overall view.

But that's the whole point -- certain hunks won't apply until you either
fix them to apply or fix the source so it can be "applied to"; I prefer
the former because it's generally easier to maintain a record of what
changed.

-Miles
-- 
`Life is a boundless sea of bitterness'

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

* Re: How to edit/modify patches using emacs?
  2005-05-08 11:23 How to edit/modify patches using emacs? Andreas R.
                   ` (3 preceding siblings ...)
  2005-05-08 13:42 ` Pascal Bourguignon
@ 2005-05-09 19:52 ` Andreas R.
  2005-05-09 20:48   ` Stefan Monnier
  4 siblings, 1 reply; 14+ messages in thread
From: Andreas R. @ 2005-05-09 19:52 UTC (permalink / raw)


Peter Dyballa wrote:
> Shouldn't they be read-only from nature? If you want to edit them, you
> can press e in that buffer. If that does not help, check the
> permissions of that patch file! Are you its owner? Are you allowed to
> create a backup copy of the file in its directory?
No that's not the problem. If I open a file like <file>.patch or <file>.diff
emacs opens it read-only (OK, I can rename the file, e.g. just to <file>,
then the problem no longer persists).

Miles Bader wrote:
>> When I open a patch (created by simple diff) emacs says it's read-only.
> 
> `toggle-read-only' (normally bound to C-x C-q I think).

Thanks, C-x C-q or M-x toggle-read-only work.

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

* Re: How to edit/modify patches using emacs?
  2005-05-09 19:52 ` Andreas R.
@ 2005-05-09 20:48   ` Stefan Monnier
  2005-05-09 22:38     ` Miles Bader
                       ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Stefan Monnier @ 2005-05-09 20:48 UTC (permalink / raw)


> No that's not the problem. If I open a file like <file>.patch or <file>.diff
> emacs opens it read-only (OK, I can rename the file, e.g. just to <file>,
> then the problem no longer persists).

Yes, it was a stupid idea of mine.  See diff-default-read-only, which in
Emacs-CVS has been set to nil.  Sorry 'bout it,


        Stefan

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

* Re: How to edit/modify patches using emacs?
  2005-05-09 20:48   ` Stefan Monnier
@ 2005-05-09 22:38     ` Miles Bader
       [not found]     ` <mailman.4311.1115678467.2819.help-gnu-emacs@gnu.org>
  2005-05-10 19:39     ` Alan Mackenzie
  2 siblings, 0 replies; 14+ messages in thread
From: Miles Bader @ 2005-05-09 22:38 UTC (permalink / raw)


Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> No that's not the problem. If I open a file like <file>.patch or <file>.diff
>> emacs opens it read-only (OK, I can rename the file, e.g. just to <file>,
>> then the problem no longer persists).
>
> Yes, it was a stupid idea of mine.  See diff-default-read-only, which in
> Emacs-CVS has been set to nil.  Sorry 'bout it,

I thought it was a rather good idea actually, though maybe the current
default is better because it confuses users less.

I use diff-mode a lot, but the _vast_ majority of diff files I visit are
only examined or applied from emacs, not edited; indeed almost always
the first thing I do when I visit one is toggle-read-only to prevent
inadvertent modification and enable the move convenient command
bindings.

So, anyway I guess now I know I can set `diff-default-read-only' to t...

-Miles
-- 
"Nah, there's no bigger atheist than me.  Well, I take that back.
I'm a cancer screening away from going agnostic and a biopsy away
from full-fledged Christian."  [Adam Carolla]

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

* Re: How to edit/modify patches using emacs?
       [not found]     ` <mailman.4311.1115678467.2819.help-gnu-emacs@gnu.org>
@ 2005-05-09 22:53       ` Stefan Monnier
  2005-05-09 23:41         ` Miles Bader
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2005-05-09 22:53 UTC (permalink / raw)


> I use diff-mode a lot, but the _vast_ majority of diff files I visit are
> only examined or applied from emacs, not edited; indeed almost always
> the first thing I do when I visit one is toggle-read-only to prevent
> inadvertent modification and enable the move convenient command
> bindings.

That's also how I felt originally, but over time I came to appreciate the
advantage of behaving in a more normal way and I think they outweigh the
benefits of defaulting to read-only.
Most of the diffs I look at are in *vc-diff* rather than in files anyway.

> So, anyway I guess now I know I can set `diff-default-read-only' to t...

I'm sure you knew you could do
(add-hook 'diff-mode-hook (lambda () (toggle-read-only 1)).
Other interesting things to put there are:
diff-delete-empty-files and diff-make-unified which I find most useful for
.rej files (especially in combination with Arch).  I still need to add
a mode where hunk-application removes the hunk from the buffer, so as to make
diff-delete-empty-files even more meaningful for Arch's .rej files.


        Stefan

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

* Re: How to edit/modify patches using emacs?
  2005-05-09 22:53       ` Stefan Monnier
@ 2005-05-09 23:41         ` Miles Bader
  0 siblings, 0 replies; 14+ messages in thread
From: Miles Bader @ 2005-05-09 23:41 UTC (permalink / raw)


Stefan Monnier <monnier@iro.umontreal.ca> writes:
> I'm sure you knew you could do
> (add-hook 'diff-mode-hook (lambda () (toggle-read-only 1)).

It seems that the burden of hitting "M-%" (my toggle-read-only) was just
not enough to trigger the "annoyed enough do something" reflex.

Now that I think about it, I generally _am_ more reluctant to add
something to my .emacs than I am to customize a variable, not really
because it's harder, or more convenient (though it is slightly), but
because I dislike my .emacs file growing large and cluttered with lots
of miscellaneous tweaks -- I tend to lose track of stuff among all the
noise.  I think I'd rather be able to use a `by name' interface like
customize for the small random changes, and put only "significant stuff"
in my .emacs file (some small custom modes, non-trivial hooks, etc.).

-Miles
-- 
x
y
Z!

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

* Re: How to edit/modify patches using emacs?
  2005-05-09 20:48   ` Stefan Monnier
  2005-05-09 22:38     ` Miles Bader
       [not found]     ` <mailman.4311.1115678467.2819.help-gnu-emacs@gnu.org>
@ 2005-05-10 19:39     ` Alan Mackenzie
  2 siblings, 0 replies; 14+ messages in thread
From: Alan Mackenzie @ 2005-05-10 19:39 UTC (permalink / raw)


Stefan Monnier <monnier@iro.umontreal.ca> wrote on Mon, 09 May 2005
16:48:34 -0400:
>> No that's not the problem. If I open a file like <file>.patch or
>> <file>.diff emacs opens it read-only (OK, I can rename the file, e.g.
>> just to <file>, then the problem no longer persists).

> Yes, it was a stupid idea of mine.  See diff-default-read-only, which in
> Emacs-CVS has been set to nil.  Sorry 'bout it,

Not half as stupid as _not_ writing diff-mode would have been.  ;-)

It's got to be one of my all-time favourite modes.  Doing a recursive
diff on two versions of a source tree (~2270 source files in each :-(),
then bringing the output up in diff-mode IMPRESSES onlookers.

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] 14+ messages in thread

end of thread, other threads:[~2005-05-10 19:39 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-08 11:23 How to edit/modify patches using emacs? Andreas R.
2005-05-08 11:43 ` Peter Dyballa
2005-05-08 12:09 ` Miles Bader
2005-05-08 12:19 ` Reiner Steib
2005-05-08 13:42 ` Pascal Bourguignon
2005-05-08 14:45   ` Miles Bader
2005-05-08 21:54     ` Micha Feigin
     [not found]     ` <mailman.4139.1115590433.2819.help-gnu-emacs@gnu.org>
2005-05-08 23:38       ` Miles Bader
2005-05-09 19:52 ` Andreas R.
2005-05-09 20:48   ` Stefan Monnier
2005-05-09 22:38     ` Miles Bader
     [not found]     ` <mailman.4311.1115678467.2819.help-gnu-emacs@gnu.org>
2005-05-09 22:53       ` Stefan Monnier
2005-05-09 23:41         ` Miles Bader
2005-05-10 19:39     ` 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).