summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2015-02-25 14:41:13 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2015-02-25 14:41:13 +0100
commit1493151b3fa37496dda12ecbcfc94501ceeafd81 (patch)
treecc3a3f6e73669ee679d5b8a94f51aecf685383fb
parentc76f254e8be9801563599b39c08ced97ae966c0c (diff)
downloadorg-mode-1493151b3fa37496dda12ecbcfc94501ceeafd81.tar.gz
ob-core: Improper lists are returned in fixed-width areas
* lisp/ob-core.el (org-babel-insert-result): Improper lists are removeable. When a list cannot be turned into a table, return it in a fixed-width area so that it can be removed. Suggested-by: Charles C. Berry <ccberry@ucsd.edu> <http://permalink.gmane.org/gmane.emacs.orgmode/95430>
-rw-r--r--lisp/ob-core.el21
1 files changed, 13 insertions, 8 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index f2062ef..971cb64 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2055,7 +2055,7 @@ If the path of the link is a file path it is expanded using
(funcall echo-res result))))
(defun org-babel-insert-result
- (result &optional result-params info hash indent lang)
+ (result &optional result-params info hash indent lang)
"Insert RESULT into the current buffer.
By default RESULT is inserted after the end of the current source
@@ -2198,7 +2198,7 @@ INFO may provide the values of these header arguments (in the
(setq results-switches
(if results-switches (concat " " results-switches) ""))
(let ((wrap (lambda (start finish &optional no-escape no-newlines
- inline-start inline-finish)
+ inline-start inline-finish)
(when inlinep
(setq start inline-start)
(setq finish inline-finish)
@@ -2212,7 +2212,15 @@ INFO may provide the values of these header arguments (in the
(goto-char end)
(unless no-newlines (goto-char (point-at-eol)))
(setq end (point-marker))))
- (proper-list-p (lambda (it) (and (listp it) (null (cdr (last it)))))))
+ (tabulablep
+ (lambda (r)
+ ;; Non-nil when result R can be turned into
+ ;; a table.
+ (and (listp r)
+ (null (cdr (last r)))
+ (org-every
+ (lambda (e) (or (atom e) (null (cdr (last e)))))
+ result)))))
;; insert results based on type
(cond
;; Do nothing for an empty result.
@@ -2233,10 +2241,7 @@ INFO may provide the values of these header arguments (in the
"\n"))
;; Try hard to print RESULT as a table. Give up if
;; it contains an improper list.
- ((and (funcall proper-list-p result)
- (org-every (lambda (e)
- (or (atom e) (funcall proper-list-p e)))
- result))
+ ((funcall tabulablep result)
(goto-char beg)
(insert (concat (orgtbl-to-orgtbl
(if (org-every
@@ -2299,7 +2304,7 @@ INFO may provide the values of these header arguments (in the
"{{{results(" ")}}}"))
((and inlinep (member "file" result-params))
(funcall wrap nil nil nil nil "{{{results(" ")}}}"))
- ((and (not (funcall proper-list-p result))
+ ((and (not (funcall tabulablep result))
(not (member "file" result-params)))
(let ((org-babel-inline-result-wrap
;; Hard code {{{results(...)}}} on top of customization.