emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* question about :results scalar
@ 2011-06-19 19:50 Robert McIntyre
  2011-06-19 23:08 ` Eric Schulte
  0 siblings, 1 reply; 4+ messages in thread
From: Robert McIntyre @ 2011-06-19 19:50 UTC (permalink / raw)
  To: emacs-orgmode

hi --- I'm working through the org manual and have run into a strange
problem with ":results scalar"

M-x org-version gives "Org-mode version 7.5 (release_7.5.288.gcec8.dirty)".

I've made a code block using #+begin_src emacs-lisp :results scalar,
with the source just being '(1 2 3), but I get back an org-table
instead of the expected : (1 2 3). what am I doing wrong?

a minimal example file can be found here:
 https://gist.github.com/1034648

I also get the same thing when trying the stable Org-mode version 7.5.

sincerely,
--Robert McIntyre

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

* Re: question about :results scalar
  2011-06-19 19:50 question about :results scalar Robert McIntyre
@ 2011-06-19 23:08 ` Eric Schulte
  2011-06-21 17:14   ` Robert McIntyre
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Schulte @ 2011-06-19 23:08 UTC (permalink / raw)
  To: Robert McIntyre; +Cc: emacs-orgmode

Hi Rob,

Thanks for pointing this out.  The emacs-lisp interaction is so simple
we apparently never implemented checks which are routine in other
languages.  I just pushed up a fix to the git repository so the
":results scalar" header argument combination should now be respected
for emacs-lisp.

Thanks -- Eric

Robert McIntyre <rlm@mit.edu> writes:

> hi --- I'm working through the org manual and have run into a strange
> problem with ":results scalar"
>
> M-x org-version gives "Org-mode version 7.5 (release_7.5.288.gcec8.dirty)".
>
> I've made a code block using #+begin_src emacs-lisp :results scalar,
> with the source just being '(1 2 3), but I get back an org-table
> instead of the expected : (1 2 3). what am I doing wrong?
>
> a minimal example file can be found here:
>  https://gist.github.com/1034648
>
> I also get the same thing when trying the stable Org-mode version 7.5.
>
> sincerely,
> --Robert McIntyre
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

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

* Re: question about :results scalar
  2011-06-19 23:08 ` Eric Schulte
@ 2011-06-21 17:14   ` Robert McIntyre
  2011-06-21 17:40     ` Eric Schulte
  0 siblings, 1 reply; 4+ messages in thread
From: Robert McIntyre @ 2011-06-21 17:14 UTC (permalink / raw)
  To: Eric Schulte, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2368 bytes --]

Excellent --- I'm glad that the interaction with emacs-lisp is straightened
out!

I've been continuing working with source blocks and the same problem seems
to be present with clojure interaction.

#+begin_src clojure :exports both :results scalar
(ns whatever)
(defn works? [] true)
#+end_src

#+results:
| function | whatever/works? |


The clojure repl would normally output the text

"#'whatever/works?"

but this is being converted into an org-mode table, ignoring the :results
scalar declaration.

futrhermore, the same test with emacs-lisp also fails as in this example


#+begin_src clojure :results scalar
'(1 2 3)
#+end_src

#+results:
| 1 | 2 | 3 |

-------------------------------------------------------------------------------------------------------


also, although :results scalar still works,  :results verbatim does not work
quite yet for emacs-lisp

#+begin_src emacs-lisp :results scalar
;;(debug t nil)
'(1 2 3)
#+end_src

#+results:
: (1 2 3)


#+begin_src emacs-lisp :results verbatim
;;(debug t nil)
'(1 2 3)
#+end_src

#+results:
| 1 | 2 | 3 |



M-x org-version returns:
Org-mode version 7.5 (release_7.5.414.g56de5.dirty)


Thank you so much for your prompt attention to my last comments!

sincerely,
--Robert McIntyre


On Sun, Jun 19, 2011 at 6:08 PM, Eric Schulte <schulte.eric@gmail.com>wrote:

> Hi Rob,
>
> Thanks for pointing this out.  The emacs-lisp interaction is so simple
> we apparently never implemented checks which are routine in other
> languages.  I just pushed up a fix to the git repository so the
> ":results scalar" header argument combination should now be respected
> for emacs-lisp.
>
> Thanks -- Eric
>
> Robert McIntyre <rlm@mit.edu> writes:
>
> > hi --- I'm working through the org manual and have run into a strange
> > problem with ":results scalar"
> >
> > M-x org-version gives "Org-mode version 7.5
> (release_7.5.288.gcec8.dirty)".
> >
> > I've made a code block using #+begin_src emacs-lisp :results scalar,
> > with the source just being '(1 2 3), but I get back an org-table
> > instead of the expected : (1 2 3). what am I doing wrong?
> >
> > a minimal example file can be found here:
> >  https://gist.github.com/1034648
> >
> > I also get the same thing when trying the stable Org-mode version 7.5.
> >
> > sincerely,
> > --Robert McIntyre
> >
>
> --
> Eric Schulte
> http://cs.unm.edu/~eschulte/
>

[-- Attachment #2: Type: text/html, Size: 3262 bytes --]

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

* Re: question about :results scalar
  2011-06-21 17:14   ` Robert McIntyre
@ 2011-06-21 17:40     ` Eric Schulte
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Schulte @ 2011-06-21 17:40 UTC (permalink / raw)
  To: Robert McIntyre; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 290 bytes --]

Hi Robert,

I've added "verbatim" to the Emacs-lisp support.  The attached patch
should fix the Clojure behavior as well, however since I no longer have
a working clojure install on my system, would you mind confirming it's
behavior before I push it to the git repository?

Thanks -- Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-clojure-respect-the-results-scalar-header-argumen.patch --]
[-- Type: text/x-diff, Size: 3393 bytes --]

From 3d8136837979a6cd8e7a3b74be2d5652b81d1e16 Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
Date: Tue, 21 Jun 2011 10:35:58 -0700
Subject: [PATCH] ob-clojure: respect the ":results scalar" header argument

* lisp/ob-clojure.el (org-babel-expand-body:clojure): Move pretty
  printing out of body expansion.
  (org-babel-execute:clojure): Now holds pretty printing logic, and
  respects the ":results scalar" header argument
---
 lisp/ob-clojure.el |   63 ++++++++++++++++++++++++++++------------------------
 1 files changed, 34 insertions(+), 29 deletions(-)

diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index cc6c2de..35e3bd7 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -49,39 +49,44 @@
 
 (defun org-babel-expand-body:clojure (body params)
   "Expand BODY according to PARAMS, return the expanded body."
-  (let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
-	 (result-params (cdr (assoc :result-params params)))
-	 (print-level nil) (print-length nil)
-	 (body (org-babel-trim
-		(if (> (length vars) 0)
-		    (concat "(let ["
-			    (mapconcat
-			     (lambda (var)
-			       (format "%S (quote %S)" (car var) (cdr var)))
-			     vars "\n      ")
-			    "]\n" body ")")
-		  body))))
-    (if (or (member "code" result-params)
-	    (member "pp" result-params))
-	(format
-	 (concat
-	  "(let [org-mode-print-catcher (java.io.StringWriter.)] "
-	  "(clojure.pprint/with-pprint-dispatch clojure.pprint/%s-dispatch "
-	  "(clojure.pprint/pprint (do %s) org-mode-print-catcher) "
-	  "(str org-mode-print-catcher)))")
-	 (if (member "code" result-params) "code" "simple") body)
-      body)))
+  (let ((vars (mapcar #'cdr (org-babel-get-header params :var)))
+	(print-level nil) (print-length nil))
+    (org-babel-trim
+     (if (> (length vars) 0)
+	 (concat "(let ["
+		 (mapconcat
+		  (lambda (var)
+		    (format "%S (quote %S)" (car var) (cdr var)))
+		  vars "\n      ")
+		 "]\n" body ")")
+       body))))
 
 (defun org-babel-execute:clojure (body params)
   "Execute a block of Clojure code with Babel."
   (require 'slime) (require 'swank-clojure)
-  (with-temp-buffer
-    (insert (org-babel-expand-body:clojure body params))
-    ((lambda (result) (condition-case nil (read result) (error result)))
-     (slime-eval
-      `(swank:interactive-eval-region
-	,(buffer-substring-no-properties (point-min) (point-max)))
-      (cdr (assoc :package params))))))
+  (let ((result-params (cdr (assoc :result-params params)))
+	(body (org-babel-expand-body:clojure body params)))
+    (with-temp-buffer
+      (insert
+       (if (or (member "code" result-params)
+	       (member "pp" result-params))
+	   (format
+	    (concat
+	     "(let [org-mode-print-catcher (java.io.StringWriter.)] "
+	     "(clojure.pprint/with-pprint-dispatch clojure.pprint/%s-dispatch "
+	     "(clojure.pprint/pprint (do %s) org-mode-print-catcher) "
+	     "(str org-mode-print-catcher)))")
+	    (if (member "code" result-params) "code" "simple") body)
+	 body))
+      ((lambda (result)
+	 (if (or (member "scalar" result-params)
+		 (member "verbatim" result-params))
+	     result
+	   (condition-case nil (read result) (error result))))
+       (slime-eval
+	`(swank:interactive-eval-region
+	  ,(buffer-substring-no-properties (point-min) (point-max)))
+	(cdr (assoc :package params)))))))
 
 (provide 'ob-clojure)
 
-- 
1.7.4.1


[-- Attachment #3: Type: text/plain, Size: 2601 bytes --]



Robert McIntyre <rlm@mit.edu> writes:

> Excellent --- I'm glad that the interaction with emacs-lisp is straightened
> out!
>
> I've been continuing working with source blocks and the same problem seems
> to be present with clojure interaction.
>
> #+begin_src clojure :exports both :results scalar
> (ns whatever)
> (defn works? [] true)
> #+end_src
>
> #+results:
> | function | whatever/works? |
>
>
> The clojure repl would normally output the text
>
> "#'whatever/works?"
>
> but this is being converted into an org-mode table, ignoring the :results
> scalar declaration.
>
> futrhermore, the same test with emacs-lisp also fails as in this example
>
>
> #+begin_src clojure :results scalar
> '(1 2 3)
> #+end_src
>
> #+results:
> | 1 | 2 | 3 |
>
> -------------------------------------------------------------------------------------------------------
>
>
> also, although :results scalar still works,  :results verbatim does not work
> quite yet for emacs-lisp
>
> #+begin_src emacs-lisp :results scalar
> ;;(debug t nil)
> '(1 2 3)
> #+end_src
>
> #+results:
> : (1 2 3)
>
>
> #+begin_src emacs-lisp :results verbatim
> ;;(debug t nil)
> '(1 2 3)
> #+end_src
>
> #+results:
> | 1 | 2 | 3 |
>
>
>
> M-x org-version returns:
> Org-mode version 7.5 (release_7.5.414.g56de5.dirty)
>
>
> Thank you so much for your prompt attention to my last comments!
>
> sincerely,
> --Robert McIntyre
>
>
> On Sun, Jun 19, 2011 at 6:08 PM, Eric Schulte <schulte.eric@gmail.com>wrote:
>
>> Hi Rob,
>>
>> Thanks for pointing this out.  The emacs-lisp interaction is so simple
>> we apparently never implemented checks which are routine in other
>> languages.  I just pushed up a fix to the git repository so the
>> ":results scalar" header argument combination should now be respected
>> for emacs-lisp.
>>
>> Thanks -- Eric
>>
>> Robert McIntyre <rlm@mit.edu> writes:
>>
>> > hi --- I'm working through the org manual and have run into a strange
>> > problem with ":results scalar"
>> >
>> > M-x org-version gives "Org-mode version 7.5
>> (release_7.5.288.gcec8.dirty)".
>> >
>> > I've made a code block using #+begin_src emacs-lisp :results scalar,
>> > with the source just being '(1 2 3), but I get back an org-table
>> > instead of the expected : (1 2 3). what am I doing wrong?
>> >
>> > a minimal example file can be found here:
>> >  https://gist.github.com/1034648
>> >
>> > I also get the same thing when trying the stable Org-mode version 7.5.
>> >
>> > sincerely,
>> > --Robert McIntyre
>> >
>>
>> --
>> Eric Schulte
>> http://cs.unm.edu/~eschulte/
>>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

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

end of thread, other threads:[~2011-06-21 18:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-19 19:50 question about :results scalar Robert McIntyre
2011-06-19 23:08 ` Eric Schulte
2011-06-21 17:14   ` Robert McIntyre
2011-06-21 17:40     ` 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).