From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Charles C. Berry" Subject: Re: New patches WAS Re: [PATCH] inline src block results can be removed Date: Thu, 29 Jan 2015 12:31:44 -0800 Message-ID: References: <87egt81acy.fsf@gmail.com> <8761ejq9ek.fsf@nicolasgoaziou.fr> <87sihltt3v.fsf@selenimh.mobile.lan> <87zjbqrapy.fsf@nicolasgoaziou.fr> <87lhl2s5zc.fsf@nicolasgoaziou.fr> <87oapuac7g.fsf@nicolasgoaziou.fr> <87egqpxc6o.fsf@nicolasgoaziou.fr> <87a91a76sm.fsf@selenimh.mobile.lan> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGvkm-0002XK-Ux for emacs-orgmode@gnu.org; Thu, 29 Jan 2015 15:31:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGvki-00009q-UJ for emacs-orgmode@gnu.org; Thu, 29 Jan 2015 15:31:52 -0500 Received: from iport-acv6-out.ucsd.edu ([132.239.0.13]:39557) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGvki-00009U-A0 for emacs-orgmode@gnu.org; Thu, 29 Jan 2015 15:31:48 -0500 In-Reply-To: <87a91a76sm.fsf@selenimh.mobile.lan> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Goaziou Cc: Aaron Ecay , Andreas Leha , emacs-orgmode@gnu.org, Ista Zahn , mcg 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" 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/