emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Apply patch from org document
@ 2016-07-24  0:00 Óscar Fuentes
  2016-07-24  2:12 ` Charles C. Berry
  0 siblings, 1 reply; 3+ messages in thread
From: Óscar Fuentes @ 2016-07-24  0:00 UTC (permalink / raw)
  To: emacs-orgmode

Is there a method for applying a patch/diff embedded in a code block?

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

* Re: Apply patch from org document
  2016-07-24  0:00 Apply patch from org document Óscar Fuentes
@ 2016-07-24  2:12 ` Charles C. Berry
  2016-07-24 13:26   ` Óscar Fuentes
  0 siblings, 1 reply; 3+ messages in thread
From: Charles C. Berry @ 2016-07-24  2:12 UTC (permalink / raw)
  To: Óscar Fuentes; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 768 bytes --]

On Sun, 24 Jul 2016, Óscar Fuentes wrote:

> Is there a method for applying a patch/diff embedded in a code block?
>

If by `embedded' you mean that the body of a src block is a patch such as 
provided by `git format-patch', you could use the language `diff'. 
`org-edit-src-code' (typing C-c ') with point in the block will open a 
buffer with the body as its contents in Diff mode. You can use the Diff 
menu to do various things like apply the patch. When you are done another 
C-c ' will close the buffer.

With some effort, you can follow ob-template.el[1] as a guide to crafting 
ob-diff.el (say) to allow execution of src blocks, if you think you need 
to go that far.

HTH,

Chuck

[1]  http://orgmode.org/w/worg.git/blob/HEAD:/org-contrib/babel/ob-template.el

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

* Re: Apply patch from org document
  2016-07-24  2:12 ` Charles C. Berry
@ 2016-07-24 13:26   ` Óscar Fuentes
  0 siblings, 0 replies; 3+ messages in thread
From: Óscar Fuentes @ 2016-07-24 13:26 UTC (permalink / raw)
  To: emacs-orgmode

"Charles C. Berry" <ccberry@ucsd.edu> writes:

> On Sun, 24 Jul 2016, Óscar Fuentes wrote:
>
>> Is there a method for applying a patch/diff embedded in a code block?
>>
>
> If by `embedded' you mean that the body of a src block is a patch such
> as provided by `git format-patch', you could use the language `diff'.
> `org-edit-src-code' (typing C-c ') with point in the block will open a
> buffer with the body as its contents in Diff mode. You can use the
> Diff menu to do various things like apply the patch. When you are done
> another C-c ' will close the buffer.

Interesting. For some reason the patch can't be applied with a single
command (diff-ediff-patch is unable to figure out the target files, but
Apply Hunk works fine; that's an issue to be discussed on the emacs ml,
though.) Anyway this is more convenient than extracting the patch and
applying it from a shell.

> With some effort, you can follow ob-template.el[1] as a guide to
> crafting ob-diff.el (say) to allow execution of src blocks, if you
> think you need to go that far.

Precisely, I was expecting to see a Babel module for diffs but writing
one for this task is overkill. A function that extracts the current
block, creates a patch and runs `patch' on it will do too and seems like
an easy one to write. Will go down that route if the issue with
diff-ediff-patch can't be fixed.

Thank you Chuck.

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

end of thread, other threads:[~2016-07-24 13:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-24  0:00 Apply patch from org document Óscar Fuentes
2016-07-24  2:12 ` Charles C. Berry
2016-07-24 13:26   ` Óscar Fuentes

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).