emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] double quotes in tables
@ 2009-12-14 16:18 Francesco Pizzolante
  2009-12-18 17:03 ` Eric Schulte
  0 siblings, 1 reply; 2+ messages in thread
From: Francesco Pizzolante @ 2009-12-14 16:18 UTC (permalink / raw)
  To: mailing-list-org-mode

Hi,

Often, I find useful that babel could generate result tables without the
double quotes (") enclosing all the text values in the cells.

In order to do that, I added a 'noquotes` option to the :results header
argument.

Here's my patch. As I'm not an elisp expert, please tell me if there's a
better/safer way to do that or maybe that it already exists an option to do
that...

--8<---------------cut here---------------start------------->8---
diff --git a/contrib/babel/lisp/org-babel.el b/contrib/babel/lisp/org-babel.el
index 4c9bff5..13c8237 100644
--- a/contrib/babel/lisp/org-babel.el
+++ b/contrib/babel/lisp/org-babel.el
@@ -706,6 +706,9 @@ code ---- the results are extracted in the syntax of the source
           code of the language being evaluated and are added
           inside of a #+BEGIN_SRC block with the source-code
           language set appropriately."
+  (setq outputformat "%S")
+  (if (member "noquotes" result-params)
+      (setq outputformat "%s"))
   (if (stringp result)
       (progn
         (setq result (org-babel-clean-text-properties result))
@@ -739,7 +742,7 @@ code ---- the results are extracted in the syntax of the source
 			     (if (and (listp (car result))
                                       (listp (cdr (car result))))
 				 result (list result))
-			     '(:fmt (lambda (cell) (format "%S" cell)))) "\n"))
+			     '(:fmt (lambda (cell) (format outputformat cell)))) "\n"))
 	    (forward-line -1) (org-cycle))
 	   ((member "file" result-params)
 	    (insert result))
@@ -827,7 +830,8 @@ parameters when merging lists."
   (let ((results-exclusive-groups
 	 '(("file" "vector" "table" "scalar" "raw" "org" "html" "latex" "code" "pp")
 	   ("replace" "silent")
-	   ("output" "value")))
+	   ("output" "value")
+           ("noquotes")))
 	(exports-exclusive-groups
 	 '(("code" "results" "both" "none")))
 	params results exports tangle cache vars var ref)
--8<---------------cut here---------------end--------------->8---

Thanks,
Francesco


_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [babel] double quotes in tables
  2009-12-14 16:18 [babel] double quotes in tables Francesco Pizzolante
@ 2009-12-18 17:03 ` Eric Schulte
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Schulte @ 2009-12-18 17:03 UTC (permalink / raw)
  To: Francesco Pizzolante; +Cc: mailing-list-org-mode

Hi Francesco,

Thanks for bringing this up.  I'm thinking that a more aggressive
version of your patch should be applied here.  It seems that org-babel
should not change the values of tables which pass through it.  I'm
leaning towards applying the following lines of your patch

-			     '(:fmt (lambda (cell) (format "%S" cell)))) "\n"))
+			     '(:fmt (lambda (cell) (format outputformat cell)))) "\n"))

That change doesn't seem to break any of our unit tests.

Can anyone think of a reason not to make this change?

Thanks -- Eric

Francesco Pizzolante <fpz@missioncriticalit.com> writes:

> Hi,
>
> Often, I find useful that babel could generate result tables without the
> double quotes (") enclosing all the text values in the cells.
>
> In order to do that, I added a 'noquotes` option to the :results header
> argument.
>
> Here's my patch. As I'm not an elisp expert, please tell me if there's a
> better/safer way to do that or maybe that it already exists an option to do
> that...
>
> diff --git a/contrib/babel/lisp/org-babel.el b/contrib/babel/lisp/org-babel.el
> index 4c9bff5..13c8237 100644
> --- a/contrib/babel/lisp/org-babel.el
> +++ b/contrib/babel/lisp/org-babel.el
> @@ -706,6 +706,9 @@ code ---- the results are extracted in the syntax of the source
>            code of the language being evaluated and are added
>            inside of a #+BEGIN_SRC block with the source-code
>            language set appropriately."
> +  (setq outputformat "%S")
> +  (if (member "noquotes" result-params)
> +      (setq outputformat "%s"))
>    (if (stringp result)
>        (progn
>          (setq result (org-babel-clean-text-properties result))
> @@ -739,7 +742,7 @@ code ---- the results are extracted in the syntax of the source
>  			     (if (and (listp (car result))
>                                        (listp (cdr (car result))))
>  				 result (list result))
> -			     '(:fmt (lambda (cell) (format "%S" cell)))) "\n"))
> +			     '(:fmt (lambda (cell) (format outputformat cell)))) "\n"))
>  	    (forward-line -1) (org-cycle))
>  	   ((member "file" result-params)
>  	    (insert result))
> @@ -827,7 +830,8 @@ parameters when merging lists."
>    (let ((results-exclusive-groups
>  	 '(("file" "vector" "table" "scalar" "raw" "org" "html" "latex" "code" "pp")
>  	   ("replace" "silent")
> -	   ("output" "value")))
> +	   ("output" "value")
> +           ("noquotes")))
>  	(exports-exclusive-groups
>  	 '(("code" "results" "both" "none")))
>  	params results exports tangle cache vars var ref)
>
> Thanks,
> Francesco
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-12-18 17:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-14 16:18 [babel] double quotes in tables Francesco Pizzolante
2009-12-18 17:03 ` Eric Schulte

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).