From: Eric Schulte <schulte.eric@gmail.com>
To: Bastien <bzg@altern.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH 03/10] Clean up various org-babel-*-maybe commands
Date: Sat, 20 Apr 2013 04:10:05 -0600 [thread overview]
Message-ID: <87ehe47pwy.fsf@gmail.com> (raw)
In-Reply-To: 87li8gs4kn.fsf@gmail.com
Aaron Ecay <aaronecay@gmail.com> writes:
> Hi Bastien,
>
> Thanks for your comments.
>
> 2013ko apirilak 3an, Bastien-ek idatzi zuen:
>
> [...]
>
>>> org-babel-get-src-block-info is a potentially expensive operation, which
>>> is why its ‘light’ argument exists. But in any case, it is overkill to
>>> query the whole info, if all that is needed is whether point is in a
>>> block or not. Factor the simplified common code out into a macro.
>>
>> The let-bound info variable is not only used to check if we are within
>> a src block, it is also passed as an argument to functions, see the ^^
>> marks below.
>
> All of these functions will re-calculate the info if it is not
> passed, using org-babel-get-src-block-info. So not passing it does no
> harm.
>
Could re-calculating the info cause referenced blocks to be executed
more than once?
If so then we should continue passing the info and *not* simply
re-calculate it later on.
Cheers,
>
>>
>>> ---
>>> lisp/ob-core.el | 31 +++++++++++++++++--------------
>>> 1 file changed, 17 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/lisp/ob-core.el b/lisp/ob-core.el
>>> index 723aa9d..283628e 100644
>>> --- a/lisp/ob-core.el
>>> +++ b/lisp/ob-core.el
>>> @@ -365,15 +365,22 @@ of potentially harmful code."
>>> (or (org-babel-execute-src-block-maybe)
>>> (org-babel-lob-execute-maybe)))
>>>
>>> +(defmacro org-babel-when-in-src-block (&rest body)
>>> + `(if (or (org-babel-where-is-src-block-head)
>>> + (org-babel-get-inline-src-block-matches))
>>> + (progn
>>> + ,@body
>>> + t)
>>> + nil))
>>
>> (Please always add a docstring of defuns and defmacros)
>
> I’ll resend the patch with a docstring and fixing the commit message
> problems you and Achim pointed out.
>
>
> [...]
>
>
>>> @@ -433,8 +436,8 @@ then run `org-babel-load-in-session'."
>>> Detect if this is context for a org-babel src-block and if so
>>> then run `org-babel-pop-to-session'."
>>> (interactive)
>>> - (let ((info (org-babel-get-src-block-info)))
>>> - (if info (progn (org-babel-pop-to-session current-prefix-arg info) t) nil)))
>> ^^^^
>>> + (org-babel-when-in-src-block
>>> + (org-babel-pop-to-session current-prefix-arg)))
>>
>> (Let's use the current name `org-babel-switch-to-session' instead of
>> the obsolete alias.)
>
> OK.
>
>>
>> Maybe we don't always need to pass the info as an argument, but at
>> least for this last example it is needed.
>
> o-b-switch-to-session does nothing with the info argument but pass it
> along to o-b-initiate-session, which will recalculate it if it is
> missing. So it takes 2 hops in contrast to the 1 in the other cases,
> but it still gets recalculated.
--
Eric Schulte
http://cs.unm.edu/~eschulte
next prev parent reply other threads:[~2013-04-20 23:17 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-01 5:42 [PATCH 00/10] babel cleanups Aaron Ecay
2013-04-01 5:42 ` [PATCH 01/10] Fix org-babel-R-initiate-session Aaron Ecay
2013-04-03 13:46 ` Eric Schulte
2013-04-01 5:42 ` [PATCH 02/10] Clean up org-babel-expand-body: functions for awk and picolisp Aaron Ecay
2013-04-03 13:56 ` Eric Schulte
2013-04-01 5:42 ` [PATCH 03/10] Clean up various org-babel-*-maybe commands Aaron Ecay
2013-04-02 19:31 ` Achim Gratz
2013-04-03 14:18 ` Bastien
2013-04-18 7:03 ` Aaron Ecay
2013-04-18 8:06 ` [PATCH 1/4] " Aaron Ecay
2013-04-18 10:28 ` Bastien
2013-04-20 10:10 ` Eric Schulte [this message]
2013-04-22 3:52 ` [PATCH 03/10] " Aaron Ecay
2013-04-01 5:42 ` [PATCH 04/10] Add 'light argument to some uses of org-babel-get-src-block-info Aaron Ecay
2013-04-03 14:09 ` Eric Schulte
2013-04-18 7:09 ` Aaron Ecay
2013-04-20 10:09 ` Eric Schulte
2013-04-22 3:51 ` Aaron Ecay
2013-04-01 5:42 ` [PATCH 05/10] Remove info arg from several org-babel functions Aaron Ecay
2013-04-03 13:58 ` Eric Schulte
2013-04-18 7:07 ` Aaron Ecay
2013-04-01 5:42 ` [PATCH 06/10] Use prefix arg in org-edit-special Aaron Ecay
2013-04-03 13:42 ` Eric Schulte
2013-04-03 17:02 ` Bastien
2013-04-01 5:42 ` [PATCH 07/10] Simplify org-babel-execute-src-block Aaron Ecay
2013-04-02 19:41 ` Achim Gratz
2013-04-03 13:54 ` Eric Schulte
2013-04-03 17:05 ` Achim Gratz
2013-04-03 17:20 ` Eric Schulte
2013-04-01 5:42 ` [PATCH 08/10] Fix testing/lisp/test-ob-emacs-lisp.el Aaron Ecay
2013-04-03 13:47 ` Eric Schulte
2013-04-01 5:42 ` [PATCH 09/10] Remove org-babel-check-confirm-evaluate macro Aaron Ecay
2013-04-02 19:53 ` Achim Gratz
2013-04-03 14:05 ` Eric Schulte
2013-04-01 5:42 ` [PATCH 10/10] Document how :var introduces code block dependencies Aaron Ecay
2013-04-03 14:04 ` Eric Schulte
2013-04-02 22:14 ` [PATCH 00/10] babel cleanups Eric Schulte
2013-04-03 14:13 ` Eric Schulte
2013-04-03 16:21 ` Bastien
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ehe47pwy.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=bzg@altern.org \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).