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" <ccbe...@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/