From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: "Charles C. Berry" <ccberry@ucsd.edu>
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: Fri, 16 Jan 2015 23:41:59 +0100 [thread overview]
Message-ID: <87lhl2s5zc.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <alpine.OSX.2.00.1501121608520.1829@charlessmacbook> (Charles C. Berry's message of "Mon, 12 Jan 2015 16:48:00 -0800")
"Charles C. Berry" <ccberry@ucsd.edu> writes:
> I've attached three patches and two files that show the behavior under
> the current master (12 Jan 2015,
> e0879b03d08bb4acc663084076370482f61e8698) and under the patched
> version.
Thank you. Some comments follow.
> With the patches, inline source block results can be removed by
> re-executing the source block if they are wrapped in
> a `{{{results(...)}}}' macro. The schema for the RESULT-PARAMS is as
> follows, but see the examples for caveats:
>
> | Param | Example output |
> |-----------------+-----------------------------------+
> | default/replace | {{{results(=42=)}}} |
> | list | \n: - 42\n\n |
> | raw | 42 |
> | drawer/wrap | {{{results(42)}}} |
> | org | {{{results(src_org{...})}}} |
> | html | {{{results(@@html:...@@)}}} |
> | latex | {{{results(@@latex:...@@)}}} |
> | code | {{{results(src_emacs-lisp{...})}}}|
> | table | \n| 42 |\n\n |
> |-----------------+-----------------------------------+
I don't think inline Babel blocks should be able to generate lists or
tables. Org cannot contain inline lists or tables. If you need a real
table or list, a regular Babel call will do.
I suggest to ignore :results table and :results list, or even return an
error, since this is bound to breaking the document structure.
> The `results' macro is hard coded to wrap `value' except when list,
> table, or raw is specified as a RESULT-PARAM or when (listp value).
> And obviously, :file
I thought :file produced {{{results([[file:...]]}}} ?
> * lisp/ob-core.el (org-babel-insert-result): Delete any `results'
> macro following current inline src block; insert current value in
> 'results' macro possibly wrapping RESULT in an export snippet or
> inline source block first. Protect commas and backslash commas in the
> RESULT with backslashes if the macro form is used.
I think the "protect commas and backslashes commas" should be factored
out of "ob-core.el" (and "org-element.el") and moved into
"org-macro.el".
> +By default RESULT is inserted after the end of the current source
> +block. The RESULT of an inline source block usually will be
> +wrapped inside a `results' macro and placed on the same line as
> +the inline source block. The macro is stripped upon
Two spaces.
> +export. Multiline and non-scalar RESULTS from inline source
> +blocks are fragile and should be avoided. With optional argument
Ditto.
> +RESULT-PARAMS controls insertion of results in the org-mode file.
Org mode file.
> + ;; escape commas, e.g. {{{results(a\,b)}}}
> + ((and inlinep
> + (not (member "raw" result-params)))
> + (goto-char beg)
> + (insert
> + ;; Escape commas and preceding backslash per
> + ;; (info "(org) Macro replacement").
> + (replace-regexp-in-string
> + "\\(\\\\*\\)\\(,\\)"
> + (lambda (str)
> + (let ((len (length (match-string 1 str))))
> + (concat (make-string (* 2 (/ len 2)) ?\\) "\\,")))
> + result nil t)))
See remark about factoring it out.
> +(defun org-babel-remove-inline-result ()
> + "Remove the result of the current inline-src-block if it is
> + wrapped in a `results' macro and trim extraneous leading whitespace."
Docstring's first sentence has to fit on a single line.
> + (let ((el (org-element-context)) post-blank)
(let* ((el (org-element-context))
(post-blank (org-element-property :post-blank el)))
...)
> + (when (eq (org-element-type el) 'inline-src-block)
> + (save-excursion
`org-with-wide-buffer' is better: results might be outside the narrowed
part of the buffer.
> + (setq post-blank (org-element-property :post-blank el))
See above.
> + (goto-char (org-element-property :end el))
> + (setq el (org-element-context))
(let ((el (org-element-context))))
> + (when (and (eq (org-element-type el) 'macro)
> + (equal (org-element-property :key el) "results"))
Nitpick: `equal' => `string='
Regards,
next prev parent reply other threads:[~2015-01-16 22:41 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 [this message]
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
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=87lhl2s5zc.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=aaronecay@gmail.com \
--cc=andreas.leha@med.uni-goettingen.de \
--cc=ccberry@ucsd.edu \
--cc=emacs-orgmode@gnu.org \
--cc=giepen.m@googlemail.com \
--cc=istazahn@gmail.com \
/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).