emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-babel-expand-src-block behavior
@ 2017-08-12  4:40 Ken Mankoff
  2017-08-12 10:52 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Ken Mankoff @ 2017-08-12  4:40 UTC (permalink / raw)
  To: Org Mode

Hi,

I've just learned about =org-babel-expand-src-block= (from [1]) which seems like an improvement over =org-edit-special=, because variables are expanded.

But I notice two issues with it, and I'm wondering if these are intentional or bugs, or if there are work-arounds.

First, the buffer is read-only (which someone else claims is a bug [2]), and second, if I make changes and then exit the expanded block (via C-') without saving, the changes are lost. If I enter =org-edit-special= and exit w/o saving, the changes are propagated back to the buffer.

Cheers,

  -k.

Org version:
Org mode version 9.0.9 (9.0.9-68-g492420-elpaplus @ /Users/mankoff/.emacs.d/elpa/org-plus-contrib-20170807/)


[1] https://emacs.stackexchange.com/questions/34821/pass-variable-from-src-block-to-org-edit-src-code

[2] https://emacs.stackexchange.com/questions/29368/org-babel-noweb-expansion-when-sending-c-c-buffer-to-python-shell

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

* Re: org-babel-expand-src-block behavior
  2017-08-12  4:40 org-babel-expand-src-block behavior Ken Mankoff
@ 2017-08-12 10:52 ` Nicolas Goaziou
  2017-08-12 18:11   ` Ken Mankoff
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2017-08-12 10:52 UTC (permalink / raw)
  To: Ken Mankoff; +Cc: Org Mode

Hello,

Ken Mankoff <mankoff@gmail.com> writes:

> Hi,
>
> I've just learned about =org-babel-expand-src-block= (from [1]) which seems like an improvement over =org-edit-special=, because variables are expanded.
>
> But I notice two issues with it, and I'm wondering if these are intentional or bugs, or if there are work-arounds.
>
> First, the buffer is read-only

It is a feature. It doesn't correspond to the contents of the block. It
is used to check what is really evaluated.

> (which someone else claims is a bug [2]),

IIUC, the bug is about

    "However if the block contains a noweb reference then the code is
    not expanded when sent to the shell and causes syntax error"

and not about the read-onlyness of the buffer.

FWIW, I cannot reproduce the bug above.

> and second, if I make changes and then exit the expanded block
> (via C-') without saving, the changes are lost. If I enter
> =org-edit-special= and exit w/o saving, the changes are propagated
> back to the buffer.

I don't understand. "C-c '" is `org-edit-special'. "C-'" is
`org-cycle-agenda-files'.

If you use "C-c '", make changes to the remote editing buffer and exit
with "C-c '", changes are propagated to the source buffer. Remote
editing is just a convenient way to edit another part of the same
buffer.

Regards,

-- 
Nicolas Goaziou

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

* Re: org-babel-expand-src-block behavior
  2017-08-12 10:52 ` Nicolas Goaziou
@ 2017-08-12 18:11   ` Ken Mankoff
  2017-08-14 14:25     ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Ken Mankoff @ 2017-08-12 18:11 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode

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

On Sat, Aug 12, 2017 at 12:52 PM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:
>
> Ken Mankoff <mankoff@gmail.com> writes:
>
> > and second, if I make changes and then exit the expanded block
> > (via C-') without saving, the changes are lost. If I enter
> > =org-edit-special= and exit w/o saving, the changes are propagated
> > back to the buffer.
>
> I don't understand. "C-c '" is `org-edit-special'. "C-'" is
> `org-cycle-agenda-files'.
>

Typo. I meant C-c '.


> If you use "C-c '", make changes to the remote editing buffer and exit
> with "C-c '", changes are propagated to the source buffer. Remote
> editing is just a convenient way to edit another part of the same
> buffer.
>

OK. I think I have a slightly different workflow, or desired workflow. I
often *run* code in the org-edit-special buffer. I find it is useful to
debug and evaluate there as I develop it, have the Python or other REPL
(using session) also available, etc. Then when the development matures,
save changes to the source buffer and evaluate it from there in the future.

This works, but not if I'm debugging something with a variable. I got
excited when I discovered org-babel-expand-src-block because now I can more
easily debug code with input variables. But apparently this is not the
purpose of that function, since a) the buffer is read-only and b) if
read-only mode is changed, the changes are not always sent back to the
primary buffer.

Is there a way to get variables into org-edit-special? Maybe by pre-pending
C-u to C-c '?  How do others debug code with input variables? Would others
like this enough to make it a feature request?

Thanks,

  -k.

[-- Attachment #2: Type: text/html, Size: 2516 bytes --]

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

* Re: org-babel-expand-src-block behavior
  2017-08-12 18:11   ` Ken Mankoff
@ 2017-08-14 14:25     ` Nicolas Goaziou
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2017-08-14 14:25 UTC (permalink / raw)
  To: Ken Mankoff; +Cc: Org Mode

Hello,

Ken Mankoff <mankoff@gmail.com> writes:

> Is there a way to get variables into org-edit-special? Maybe by pre-pending
> C-u to C-c '?

The problem is not getting the variables into the remote editing buffer.
As you noticed, we would only need to remove the read-only status from
`org-babel-expand-src-block' output. The difficulty is writing back to
the source buffer. You need to mark somehow the original contents of the
src block and be able to retrieve it upon exiting the buffer.

Also, the remote editing buffer is not really suited for debugging.
Since it is not associated to a file, some compilers refuse to run the
code in there (e.g., asymptote blocks).

> How do others debug code with input variables?

I expand everything, copy it and write it into a temporary file. I do
the debugging in the temp file. When I'm satisfied, I copy the contents
of the file back into the remote editing buffer. Nothing fancy.


Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2017-08-14 14:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-12  4:40 org-babel-expand-src-block behavior Ken Mankoff
2017-08-12 10:52 ` Nicolas Goaziou
2017-08-12 18:11   ` Ken Mankoff
2017-08-14 14:25     ` Nicolas Goaziou

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