emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Charles C. Berry" <ccberry@ucsd.edu>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: Aaron Ecay <aaronecay@gmail.com>,
	Andreas Leha <andreas.leha@med.uni-goettingen.de>,
	emacs-orgmode@gnu.org, Ista Zahn <istazahn@gmail.com>,
	mcg <giepen.m@googlemail.com>
Subject: Re: New patches WAS Re: [PATCH] inline src block results can be removed
Date: Thu, 29 Jan 2015 12:31:44 -0800	[thread overview]
Message-ID: <alpine.OSX.2.00.1501291212370.2664@charles-berrys-macbook.local> (raw)
In-Reply-To: <87a91a76sm.fsf@selenimh.mobile.lan>



The changes have been pushed to master just now.

To recap, inline src blocks and babel calls will now wrap their output in 
a `results' macro following the src block or call, replacing any previous 
such macro.

`:results raw' prevents the wrapping from taking place.

If the RESULT is a list or table or has more than one line (after 
stripping  trailing newline) an error is thrown. Likewise `:results list' 
and `:results table' throw an error.

`:results latex' (or html) will wrap the RESULT in a latex (html) export 
snippet. `:wrap blah' will produce a 'blah' snippet.

All of this should be utterly transparent on export, but there is one 
change I call to your attention:

This block:

 	src_emacs-lisp[:results code]{`(+ 1 2)}

yields this result:

 	{{{results(src_emacs-lisp[]{(+ 1 2)})}}}

which will export as

 	`(+ 1 2)'

under the 'ascii backend. Formerly, the `(+ 1 2)' would be evaluated by 
babel. If that behavior is truly needed, it can be restored. But in our 
discussions till now nobody has raised the issue, so I guessed the change 
would cause no headaches.

Best,

Chuck

On Thu, 22 Jan 2015, Nicolas Goaziou wrote:

> "Charles C. Berry" <ccberry@ucsd.edu> writes:
>
>> I attach 3 patches and a file of usage examples.
>
> Thanks.
>
>> +    (let* ((el (org-element-context))
>> +	   (beg (org-element-property :begin el))
>> +	   (type (org-element-type el)))
>> +      (when (eq type 'inline-babel-call)
>> +	(goto-char beg)))
>
> Nitpick: this looks like a lot of bindings for a dubious readability
> improvement. What about:
>
>  (let ((datum (org-element-context)))
>    (when (eq (org-element-type datum) 'inline-babel-call)
>      (goto-char (org-element-property :begin datum))))
>
>> +	     (bad-inline-p
>> +	      (when inlinep
>> +		(or
>> +		 (and (member "table" result-params) "`:results table'")
>> +		 (and (listp result) "list result")
>> +		 (and (string-match-p "\n." result) "multiline result")
>
> `string-match-p' => `org-string-match-p'
>
>>  		(cond
>>  		 ;; do nothing for an empty result
>>  		 ((null result))
>> +		 ;; illegal inline result or params
>
> Capital and final dot.
>
>> +		  (when inlinep
>> +		    (goto-char inlinep)
>> +		    (setq result) (org-macro-escape-arguments result))
>
>  (setq result (org-macro-escape-arguments result))
>
>> +		 (bad-inline-p) ;; do nothing
>
> Single semicolon for end-of-line comments, and capital+final dot.
>
>> +(defun org-babel-remove-inline-result ()
>> +  "Remove the result of the current inline-src-block or babel call.
>> +The result must be wrapped in a `results' macro to be
>> +  removed. Extraneous leading whitespace is trimmed."
>> +  (let* ((el (org-element-context))
>> +	 (post-blank (org-element-property :post-blank el)))
>> +    (when (memq (org-element-type el) '(inline-src-block inline-babel-call))
>> +      (org-with-wide-buffer
>> +        (goto-char (org-element-property :end el))
>> +        (let  ((el (org-element-context)))
>
>               ^^^
>           spurious space
>
> This looks good. I think you can push them into master once the minor
> issues above are fixed and if all tests pass.
>
>
> Regards,
>
> -- 
> Nicolas Goaziou
>

Charles C. Berry                 Dept of Family Medicine & Public Health
cberry at ucsd edu               UC San Diego / La Jolla, CA 92093-0901
http://famprevmed.ucsd.edu/faculty/cberry/

  parent reply	other threads:[~2015-01-29 20:31 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-12  0:49 [PATCH] inline src block results can be removed Charles C. Berry
2014-11-12  1:10 ` Andreas Leha
2014-11-12  6:58   ` Charles C. Berry
2014-11-12 19:34 ` Aaron Ecay
2014-11-12 23:47   ` Charles C. Berry
2014-11-13 17:48     ` Nicolas Goaziou
2014-11-13 19:06       ` Andreas Leha
2014-11-14 17:43       ` Charles C. Berry
2014-11-14 20:39         ` Nicolas Goaziou
2014-11-14 23:04           ` Aaron Ecay
2014-11-16  0:10             ` Nicolas Goaziou
2014-11-15 20:22           ` Charles C. Berry
2014-11-16 23:23             ` Nicolas Goaziou
2014-11-24  9:48               ` Daniele Pizzolli
2014-11-24 10:18                 ` Andreas Leha
2015-01-13  0:48               ` New patches WAS " Charles C. Berry
2015-01-16 22:41                 ` Nicolas Goaziou
2015-01-19  3:22                   ` Charles C. Berry
2015-01-19 17:53                     ` Nicolas Goaziou
2015-01-19 19:31                       ` Charles C. Berry
2015-01-20 23:30                         ` Nicolas Goaziou
2015-01-22  3:07                           ` Charles C. Berry
2015-01-22 23:08                             ` Nicolas Goaziou
2015-01-24 22:47                               ` Charles C. Berry
2015-01-25  1:14                                 ` Aaron Ecay
2015-01-25  5:01                                   ` Charles C. Berry
2015-01-29 20:31                               ` Charles C. Berry [this message]
2015-01-17  3:22                 ` Aaron Ecay
2015-01-17 22:20                   ` Nicolas Goaziou
2015-01-18 19:13                     ` Aaron Ecay
2015-01-18 22:34                       ` Nicolas Goaziou
2015-01-18 22:55                         ` Aaron Ecay

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=alpine.OSX.2.00.1501291212370.2664@charles-berrys-macbook.local \
    --to=ccberry@ucsd.edu \
    --cc=aaronecay@gmail.com \
    --cc=andreas.leha@med.uni-goettingen.de \
    --cc=emacs-orgmode@gnu.org \
    --cc=giepen.m@googlemail.com \
    --cc=istazahn@gmail.com \
    --cc=mail@nicolasgoaziou.fr \
    /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).