Re: [O] Clojure Code Block Results not Tabularized
Hi Greg, Soapy Smith writes: > Is there a way to get the > complete code blocks exported in an entire org file using a global > option? I think you want :export both -- see tangle export options in the manual. > Python code blocks are used for comparison. There were some > differences. Please report further bugs -- thanks! -- Bastien
Re: [O] Clojure Code Block Results not Tabularized
Here are the files from testing of Clojure code blocks with the latest master: https://github.com/Greg-R/org-babel-clojure-tests?source=cc The PDF file is the result of a LaTeX export. The code blocks were forced to appear as they do in the org file by wrapping them in begin_example/end_example. Is there a way to get the complete code blocks exported in an entire org file using a global option? Python code blocks are used for comparison. There were some differences. The coercion to tables (where appropriate) is working well. Regards, Greg On Thu, 2014-01-30 at 12:11 +0100, Bastien wrote: > Hi Greg, > > Soapy Smith writes: > > > The problem is that the results inserted into the org document should be > > tabularized. > > This should now be fixed in master -- thanks for further testing, > and thanks to Eric for giving the solution. >
Re: [O] Clojure Code Block Results not Tabularized
Great news! I will update my system to the master. I will create an org file with permutations of the :results option and export to LaTeX and HTML. Perhaps even compare to Python behavior. I will attempt to push the test files to github later today. I need the git practice! Regards, Greg On Thu, 2014-01-30 at 12:11 +0100, Bastien wrote: > Hi Greg, > > Soapy Smith writes: > > > The problem is that the results inserted into the org document should be > > tabularized. > > This should now be fixed in master -- thanks for further testing, > and thanks to Eric for giving the solution. >
Re: [O] Clojure Code Block Results not Tabularized
Hi Greg, Soapy Smith writes: > The problem is that the results inserted into the org document should be > tabularized. This should now be fixed in master -- thanks for further testing, and thanks to Eric for giving the solution. -- Bastien
Re: [O] Clojure Code Block Results not Tabularized
It is better. To really stress it, I tried a two-row table: #+begin_src clojure :results table [[:ny :nj :ct] [ 7 9 4]] #+end_src #+RESULTS: | :ny | :nj | :ct | | 7 | 9 | 4 | On Wed, Jan 29, 2014 at 10:28 AM, Bastien wrote: > Eric Schulte writes: > > > Try evaluating the following and see how it works. > > It works fine for me: > > , > | #+BEGIN_SRC clojure :results table > | (map #(* %1 3) '(1 2 3)) > | #+END_SRC > | > | #+RESULTS: > | | 3 | 6 | 9 | > ` > > > This simply copies > > the results handling from the slime backend to the cider backend (which > > currently does not appear to have any results handling). While you're > > at it the nrepl results handling looks broken to me as well. > > Yep. > > Greg, please test Eric's function above for all your use cases and let > us know if it covers them all -- then I'll fix this and the nrepl case > too. > > Thanks Eric! > > -- > Bastien > >
Re: [O] Clojure Code Block Results not Tabularized
Eric Schulte writes: > Try evaluating the following and see how it works. It works fine for me: , | #+BEGIN_SRC clojure :results table | (map #(* %1 3) '(1 2 3)) | #+END_SRC | | #+RESULTS: | | 3 | 6 | 9 | ` > This simply copies > the results handling from the slime backend to the cider backend (which > currently does not appear to have any results handling). While you're > at it the nrepl results handling looks broken to me as well. Yep. Greg, please test Eric's function above for all your use cases and let us know if it covers them all -- then I'll fix this and the nrepl case too. Thanks Eric! -- Bastien
Re: [O] Clojure Code Block Results not Tabularized
Soapy Smith writes: > Yes, I agree the Clojure behavior is not quite correct. But all the > functionality is there if both the old and new are combined. I think > only a rearrangement of existing code is required. > Try evaluating the following and see how it works. This simply copies the results handling from the slime backend to the cider backend (which currently does not appear to have any results handling). While you're at it the nrepl results handling looks broken to me as well. Maybe Bastien (who I believe wrote or committed this code) can help. (defun org-babel-execute:clojure (body params) "Execute a block of Clojure code with Babel." (let ((expanded (org-babel-expand-body:clojure body params))) (case org-babel-clojure-backend (cider (require 'cider) (let ((result (or (nth 1 (nrepl-send-string-sync expanded (cider-current-ns) (nrepl-current-tooling-session))) (error "nREPL not connected! Use M-x cider-jack-in RET" (org-babel-result-cond (cdr (assoc :result-params params)) result (condition-case nil (org-babel-script-escape result) (error result) (nrepl (require 'nrepl) (if (nrepl-current-connection-buffer) (let* ((result (nrepl-eval expanded)) (s (plist-get result :stdout)) (r (plist-get result :value))) (if s (concat s "\n" r) r)) (error "nREPL not connected! Use M-x nrepl-jack-in RET"))) (slime (require 'slime) (with-temp-buffer (insert expanded) ((lambda (result) (let ((result-params (cdr (assoc :result-params params (org-babel-result-cond result-params result (condition-case nil (org-babel-script-escape result) (error result) (slime-eval `(swank:eval-and-grab-output ,(buffer-substring-no-properties (point-min) (point-max))) (cdr (assoc :package params) I don't have clojure installed locally and can't test. Best, > > I like the idea of comparing to the behavior of Python code blocks. > I've got a Coursera class coming up which will use Python, so I need to > get it set it up here. > > Thank you for the assistance! > Greg > > On Wed, 2014-01-29 at 13:58 +0100, Christian Moe wrote: >> Soapy Smith writes: >> >> > Christian, could you try :results table with Python and reply back with >> > the #+RESULTS:? >> >> Same as the default, i.e. a table, as expected. >> #+RESULTS: >> | 1 | 2 | 3 | >> >> The Babel/Clojure behavior you report does seem buggy. >> >> I'm afraid I can't be of further help, but hopefully others will pick up >> on this. >> >> Yours, >> Christian > > > -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D
Re: [O] Clojure Code Block Results not Tabularized
Yes, I agree the Clojure behavior is not quite correct. But all the functionality is there if both the old and new are combined. I think only a rearrangement of existing code is required. I like the idea of comparing to the behavior of Python code blocks. I've got a Coursera class coming up which will use Python, so I need to get it set it up here. Thank you for the assistance! Greg On Wed, 2014-01-29 at 13:58 +0100, Christian Moe wrote: > Soapy Smith writes: > > > Christian, could you try :results table with Python and reply back with > > the #+RESULTS:? > > Same as the default, i.e. a table, as expected. > #+RESULTS: > | 1 | 2 | 3 | > > The Babel/Clojure behavior you report does seem buggy. > > I'm afraid I can't be of further help, but hopefully others will pick up > on this. > > Yours, > Christian
Re: [O] Clojure Code Block Results not Tabularized
Soapy Smith writes: > Christian, could you try :results table with Python and reply back with > the #+RESULTS:? Same as the default, i.e. a table, as expected. #+RESULTS: | 1 | 2 | 3 | The Babel/Clojure behavior you report does seem buggy. I'm afraid I can't be of further help, but hopefully others will pick up on this. Yours, Christian
Re: [O] Clojure Code Block Results not Tabularized
Hi Christian, I think that is a very good point! >From the manual, the explanation of what is returned as a result using :results raw "raw The results are interpreted as raw Org mode code and are inserted directly into the buffer. If the results look like a table they will be aligned as such by Org mode. E.g., :results value raw." So, it doesn't say it will result in a table, but it will be aligned like a table! Whatever the case, the behavior of Clojure should be consistent with the other languages. Looking into the "old" set further, I find the :results header argument makes no difference: :results value :results value raw :results table (no header argument) All result in the same org table. So it looks like the old version was not behaving properly either. However, it was able to coerce the Clojure vector into an org table successfully. With the new system (version 8 org and CIDER), there are in fact 3 different results blocks: (no header argument) #+RESULTS: : [1 2 3 4] :results value raw #+RESULTS: [1 2 3 4] :results value #+RESULTS: : [1 2 3 4] :results table #+RESULTS: | [1 2 3 4] | Christian, could you try :results table with Python and reply back with the #+RESULTS:? Regards, Greg On Wed, 2014-01-29 at 08:57 +0100, Christian Moe wrote: > Hi, > > I don't use Clojure so I may get this wrong, but: isn't this what you > would expect with `:results raw'? > > Cf. these Python examples: > > #+begin_src python :results raw > a = (1, 2, 3) > return a > #+end_src > > #+RESULTS: > (1, 2, 3) > > #+begin_src python > a = (1, 2, 3) > return a > #+end_src > > #+RESULTS: > | 1 | 2 | 3 | > > Yours, > Christian
Re: [O] Clojure Code Block Results not Tabularized
Soapy Smith writes: > The problem is that the results inserted into the org document should be > tabularized. This is not happening using the latest version of org. > Here is the simplest possible example: > > #+begin_src clojure :results value raw > [1 2 3 4] > #+end_src > > #+RESULTS: > [1 2 3 4] Hi, I don't use Clojure so I may get this wrong, but: isn't this what you would expect with `:results raw'? Cf. these Python examples: #+begin_src python :results raw a = (1, 2, 3) return a #+end_src #+RESULTS: (1, 2, 3) #+begin_src python a = (1, 2, 3) return a #+end_src #+RESULTS: | 1 | 2 | 3 | Yours, Christian
[O] Clojure Code Block Results not Tabularized
Hello to the list, my first message here. This is in regards to code blocks in the Clojure language. The problem is that the results inserted into the org document should be tabularized. This is not happening using the latest version of org. Here is the simplest possible example: #+begin_src clojure :results value raw [1 2 3 4] #+end_src #+RESULTS: [1 2 3 4] The result block is not tabularized. In an older system, the result block is properly changed to an org table: #+RESULTS: | 1 | 2 | 3 | 4 | Here is a comparison of the systems, old and new, which produced the above results: PlatformOld New emacs 24.3.1 24.3.1 Leiningen 2.3.4 2.3.4 Java1.7._51 1.6.0_27 (both are OpenJDK 64 bit server VM) org 7.9 8.2.4 Old REPL: nrepl 0.1.8-preview New REPL: cider 0.6.0alpha The only thing strange I discovered about my new system is that it is using an older version of Java than the old system. Regards, Greg