emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] expose nrepl's timeout setting in ob-clojure.el
@ 2016-03-29 17:38 Frederick Giasson
  2016-04-06  9:43 ` Nicolas Goaziou
  0 siblings, 1 reply; 13+ messages in thread
From: Frederick Giasson @ 2016-03-29 17:38 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1082 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 1527 bytes --]

[-- Attachment #2: ob-clojure.el.diff --]
[-- Type: text/plain, Size: 1634 bytes --]

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.

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

end of thread, other threads:[~2016-04-27 12:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-29 17:38 [PATCH] expose nrepl's timeout setting in ob-clojure.el Frederick Giasson
2016-04-06  9:43 ` Nicolas Goaziou
2016-04-06 14:48   ` Frederick Giasson
2016-04-10  8:20     ` Nicolas Goaziou
2016-04-11 14:03       ` Frederick Giasson
2016-04-12 20:18         ` Nicolas Goaziou
2016-04-13 20:15           ` Frederick Giasson
2016-04-06 16:27   ` [PATCH] new :async feature for org-babel-clojure Frederick Giasson
2016-04-20 12:17     ` Frederick Giasson
2016-04-20 21:59       ` Nicolas Goaziou
2016-04-21 12:34         ` Frederick Giasson
2016-04-26 19:21           ` Nicolas Goaziou
2016-04-27 12:00             ` Frederick Giasson

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