[O] ob-clojure: possible to display results as soon as something is written to STDOUT?

2016-03-29 Thread Frederick Giasson

Hi everybody,

I was wondering if it was possible for Org-mode to write results in 
#+RESULTS as soon as something is written to STDOUT?


Here is my issue: I am writing Notebooks in Clojure using org-mode 
(clojure). I have some long-running procedures in the notebook that 
output the current status of the process (like, 1/4986000) to the 
REPL using printnl.


With now, I am using the header "clojure :session :results output.

I am getting the output, but *only once the function finished its 
processing*. What I would like to know if it is possible to have 
Org-mode to write things when they are written to STDOUT instead then 
just when it finished?


Note: I am not sure if this is something related to Org-mode, or 
ob-clojure or Cider.


Thanks,

Fred


[O] [PATCH] expose nrepl's timeout setting in ob-clojure.el

2016-03-29 Thread Frederick Giasson

Hi everybody,

I am starting to use org-mode to create literate applications in 
Clojure. So far so good, this is a terrific piece of software.


One thing why I wanted to use org-mode is to use it to create Clojure 
Notebooks. The problem I had is that I have many functions that can take 
some time (more than 10 seconds) to complete. This means that I was 
often receiving that error from nrepl:


===
nrepl-send-sync-request: Sync nREPL request timed out (op eval session 
57bdacff-b178-4952-8bf8-5e01ac9d745a code (def umbel 
(create-ontology-structure))

===

The problem is that there is no way to define the nrepl timeout from 
Org-mode. What I did is to expose that nrepl setting in ob-clojure.el. 
This is the ob-clojure.el.diff patch I am proposing here.


The name of the new setting is "org-babel-clojure-nrepl-timeout". If it 
is set to /nil/ then no timeout will occur, otherwise any integer will 
define a timeout value.


This variable can be set from the /.emacs/ global setting file.

It works fine from here, please modify as required.

Thanks,

Fred
diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index 89a09a9..46031e1 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -1,4 +1,4 @@
-;;; ob-clojure.el --- Babel Functions for Clojure-*- lexical-binding: t; 
-*-
+;;; ob-clojure.el --- org-babel functions for clojure evaluation
 
 ;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
 
@@ -55,6 +55,7 @@
 
 (defvar org-babel-default-header-args:clojure '())
 (defvar org-babel-header-args:clojure '((package . :any)))
+(defvar org-babel-clojure-nrepl-timeout 10)
 
 (defcustom org-babel-clojure-backend
   (cond ((featurep 'cider) 'cider)
@@ -67,7 +68,7 @@
 
 (defun org-babel-expand-body:clojure (body params)
   "Expand BODY according to PARAMS, return the expanded body."
-  (let* ((vars (org-babel--get-vars params))
+  (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
@@ -94,8 +95,9 @@
(let ((result-params (cdr (assoc :result-params params
 (setq result
   (nrepl-dict-get
-   (nrepl-sync-request:eval
-expanded (cider-current-connection) (cider-current-session))
+   (let ((nrepl-sync-request-timeout 
org-babel-clojure-nrepl-timeout))
+ (nrepl-sync-request:eval
+  expanded (cider-current-connection) (cider-current-session)))
(if (or (member "output" result-params)
(member "pp" result-params))
"out"

warning: LF will be replaced by CRLF in lisp/ob-clojure.el.
The file will have its original line endings in your working directory.


Re: [O] headers on special blocks

2016-03-29 Thread Eric S Fraga
On Monday, 28 Mar 2016 at 12:25, John Kitchin wrote:
> If anyone is interested, here is a way I am using headers on special blocks:
> http://kitchingroup.cheme.cmu.edu/blog/2016/03/28/Another-approach-to-embedded-molecular-data-in-org-mode/

Very nice.

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.92.1, Org release_8.3.4-668-g809a83



Re: [O] first #+LATEX_HEADER: in SETUPFILE not correctly exported and causes Missing \begin{document} error

2016-03-29 Thread Eric S Fraga
On Monday, 28 Mar 2016 at 10:54, Charles Millar wrote:

[...]

> As we agreed my first successful export was lucky, so I revised that
> file template from which I was exporting - the extra first page and
> the missing\begin{document} do not seem to be a problem now.
>
> However, the LATEX_HEADER: still is placed several spaces to the left,

So everything is fine other than the placement of the LaTeX header line?

In terms of the placement, I have no idea what causes this.  I don't
often look at the LaTeX the org exporter creates so cannot say whether
this is normal or not.  The extra whitespace should not affect LaTeX in
any case.
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.92.1, Org release_8.3.4-668-g809a83