emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] add :session support for ob-js.el
@ 2018-03-12  9:02 stardiviner
  2018-03-13  8:43 ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: stardiviner @ 2018-03-12  9:02 UTC (permalink / raw)
  To: org-mode


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

I added org-mode babel ob-js.el header argument :session.

Following packages :session are supported:

- skewer-mode

- js-comint

- Indium


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

[-- Attachment #2: 0003-ob-js.el-add-session-support-with-js-comint.patch --]
[-- Type: text/x-patch, Size: 1410 bytes --]

From 2cdf05cf2fe3e0740997d9861c8ff8f81c163750 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Fri, 9 Mar 2018 00:10:54 +0800
Subject: [PATCH 3/3] * ob-js.el: add :session support with js-comint.

---
 lisp/ob-js.el | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-js.el b/lisp/ob-js.el
index d2fc5e29c..126685813 100644
--- a/lisp/ob-js.el
+++ b/lisp/ob-js.el
@@ -59,6 +59,7 @@
   :version "24.1"
   :type '(choice (const "node")
 		 (const "mozrepl")
+		 (const "js-comint")
 		 (const "skewer-mode"))
   :safe #'stringp)
 
@@ -159,7 +160,17 @@ specifying a variable of the same value."
 then create.  Return the initialized session."
   (unless (string= session "none")
     (cond
-     ((string= "*skewer-repl*" session)
+     ((and (string= "js-comint" org-babel-js-cmd) ; `js-comint'
+	   (string= "*Javascript REPL*" session))
+      (require 'js-comint)
+      (let ((session-buffer "*Javascript REPL*"))
+	(if (and (org-babel-comint-buffer-livep (get-buffer session-buffer))
+		 (comint-check-proc session-buffer))
+	    session-buffer
+	  (call-interactively 'run-js)
+	  (sit-for .5)
+	  session-buffer)))
+     ((string= "*skewer-repl*" session) ; `skewer-mode'
       (require 'skewer-repl)
       (let ((session-buffer (get-buffer "*skewer-repl*")))
 	(if (and (org-babel-comint-buffer-livep (get-buffer session-buffer))
-- 
2.16.2


[-- Attachment #3: 0002-ob-js.el-support-session-for-Indium-Node.js-REPL.patch --]
[-- Type: text/x-patch, Size: 2128 bytes --]

From 4eef9f4fc9534ac45b5d98ba8eab36f764cd7518 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Thu, 8 Mar 2018 23:15:16 +0800
Subject: [PATCH 2/3] * ob-js.el: support :session for Indium Node.js REPL.

---
 lisp/ob-js.el | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/lisp/ob-js.el b/lisp/ob-js.el
index e2a2a9cec..d2fc5e29c 100644
--- a/lisp/ob-js.el
+++ b/lisp/ob-js.el
@@ -70,21 +70,30 @@
   "Execute a block of Javascript code with org-babel.
 This function is called by `org-babel-execute-src-block'"
   (let* ((org-babel-js-cmd (or (cdr (assq :cmd params)) org-babel-js-cmd))
+	 (session (cdr (assq :session params)))
          (result-type (cdr (assq :result-type params)))
          (full-body (org-babel-expand-body:generic
 		     body params (org-babel-variable-assignments:js params)))
 	 (result (if (not (string= (cdr (assq :session params)) "none"))
 		     ;; session evaluation
-		     (let ((session (org-babel-prep-session:js
-				     (cdr (assq :session params)) params)))
-		       (nth 1
-			    (org-babel-comint-with-output
-				(session (format "%S" org-babel-js-eoe) t body)
-			      (mapc
-			       (lambda (line)
-				 (insert (org-babel-chomp line))
-				 (comint-send-input nil t))
-			       (list body (format "%S" org-babel-js-eoe))))))
+		     (cond
+		      ;; Indium Node
+		      ((string= "*JS REPL*" session)
+		       (require 'indium-repl)
+		       (unless (get-buffer session)
+			 (indium-run-node))
+		       (indium-eval full-body))
+		      (t
+		       (let ((session (org-babel-prep-session:js
+				       (cdr (assq :session params)) params)))
+			 (nth 1
+			      (org-babel-comint-with-output
+				  (session (format "%S" org-babel-js-eoe) t body)
+				(mapc	; FIXME: stack on this scope when `skewer-eval'
+				 (lambda (line)
+				   (insert (org-babel-chomp line))
+				   (comint-send-input nil t))
+				 (list body (format "%S" org-babel-js-eoe))))))))
 		   ;; external evaluation
 		   (let ((script-file (org-babel-temp-file "js-script-")))
 		     (with-temp-file script-file
-- 
2.16.2


[-- Attachment #4: 0001-ob-js.el-support-use-skewer-mode-as-session-support.patch --]
[-- Type: text/x-patch, Size: 1712 bytes --]

From 9c3a57107e4ed598ca24582fa330fe698829b61e Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Thu, 8 Mar 2018 17:15:58 +0800
Subject: [PATCH] * ob-js.el: support use skewer-mode as session support.

---
 lisp/ob-js.el | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-js.el b/lisp/ob-js.el
index 38c8c39ac..e2a2a9cec 100644
--- a/lisp/ob-js.el
+++ b/lisp/ob-js.el
@@ -27,6 +27,11 @@
 ;;
 ;; This certainly isn't optimally robust, but it seems to be working
 ;; for the basic use cases.
+;;
+;; `skewer-mode' session support:
+;; #+begin_src js :session *skewer-repl*
+;; console.log("chris");
+;; #+end_src
 
 ;;; Requirements:
 
@@ -52,7 +57,10 @@
   "Name of command used to evaluate js blocks."
   :group 'org-babel
   :version "24.1"
-  :type 'string)
+  :type '(choice (const "node")
+		 (const "mozrepl")
+		 (const "skewer-mode"))
+  :safe #'stringp)
 
 (defvar org-babel-js-function-wrapper
   "require('sys').print(require('sys').inspect(function(){\n%s\n}()));"
@@ -142,6 +150,18 @@ specifying a variable of the same value."
 then create.  Return the initialized session."
   (unless (string= session "none")
     (cond
+     ((string= "*skewer-repl*" session)
+      (require 'skewer-repl)
+      (let ((session-buffer (get-buffer "*skewer-repl*")))
+	(if (and (org-babel-comint-buffer-livep (get-buffer session-buffer))
+		 (comint-check-proc session-buffer))
+	    session-buffer
+	  ;; start skewer REPL.
+	  (sit-for .5)
+	  (httpd-start)
+	  (run-skewer)
+	  (sit-for .5)
+	  session-buffer)))
      ((string= "mozrepl" org-babel-js-cmd)
       (require 'moz)
       (let ((session-buffer (save-window-excursion
-- 
2.16.2


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

* Re: [PATCH] add :session support for ob-js.el
  2018-03-12  9:02 [PATCH] add :session support for ob-js.el stardiviner
@ 2018-03-13  8:43 ` Nicolas Goaziou
  2018-03-13 11:51   ` stardiviner
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2018-03-13  8:43 UTC (permalink / raw)
  To: stardiviner; +Cc: org-mode

Hello,

stardiviner <numbchild@gmail.com> writes:

> I added org-mode babel ob-js.el header argument :session.
>
> Following packages :session are supported:
>
> - skewer-mode
>
> - js-comint
>
> - Indium

I don't know any of these, but here come some comments about the code.

>  then create.  Return the initialized session."
>    (unless (string= session "none")
>      (cond

Nitpick: You can merge the `unless' into the `cond'.

> -     ((string= "*skewer-repl*" session)
> +     ((and (string= "js-comint" org-babel-js-cmd) ; `js-comint'
> +	   (string= "*Javascript REPL*" session))
> +      (require 'js-comint)
> +      (let ((session-buffer "*Javascript REPL*"))
> +	(if (and (org-babel-comint-buffer-livep (get-buffer session-buffer))
> +		 (comint-check-proc session-buffer))
> +	    session-buffer
> +	  (call-interactively 'run-js)

The `run-js' probably needs to be declared at the beginning of the file.

> +		     (cond
> +		      ;; Indium Node
> +		      ((string= "*JS REPL*" session)
> +		       (require 'indium-repl)
> +		       (unless (get-buffer session)
> +			 (indium-run-node))

The function above needs to be declared, too.

> +		       (indium-eval full-body))

So does this one.

> +		      (t
> +		       (let ((session (org-babel-prep-session:js
> +				       (cdr (assq :session params)) params)))
> +			 (nth 1
> +			      (org-babel-comint-with-output
> +				  (session (format "%S" org-babel-js-eoe) t body)
> +				(mapc	; FIXME: stack on this scope when `skewer-eval'

What does mean this FIXME?

> +				 (lambda (line)

Nitpick: `mapc' + `lambda' -> `dolist'

>      (cond
> +     ((string= "*skewer-repl*" session)
> +      (require 'skewer-repl)
> +      (let ((session-buffer (get-buffer "*skewer-repl*")))
> +	(if (and (org-babel-comint-buffer-livep (get-buffer session-buffer))
> +		 (comint-check-proc session-buffer))
> +	    session-buffer
> +	  ;; start skewer REPL.
> +	  (sit-for .5)

Why is this `sit-for' needed?

> +	  (httpd-start)
> +	  (run-skewer)

These functions need to be declared.

Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] add :session support for ob-js.el
  2018-03-13  8:43 ` Nicolas Goaziou
@ 2018-03-13 11:51   ` stardiviner
  2018-03-17 11:14     ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: stardiviner @ 2018-03-13 11:51 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: org-mode

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

updated my code. I followed your suggestions. But modify code one by one 
messed code up. So I merge all related commits into one commit. Sorry 
for this.



[-- Attachment #2: 0001-ob-js.el-support-session-for-many-JS-packages.patch --]
[-- Type: text/x-patch, Size: 9812 bytes --]

From 23ef274fd418c876be85871f8da34738ae15ffd5 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Thu, 8 Mar 2018 17:15:58 +0800
Subject: [PATCH] * ob-js.el: support :session for many JS packages.

- ob-js.el: support :session for js-comint.
- ob-js.el: support :session for Indium Node.js REPL.
- ob-js.el: (org-babel-js-initiate-session): merge the `unless' into the `cond'
---
 etc/ORG-NEWS  |   8 ++++
 lisp/ob-js.el | 141 ++++++++++++++++++++++++++++++++++++----------------------
 2 files changed, 97 insertions(+), 52 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 10687ba83..5cbc10b8b 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -107,6 +107,14 @@ document, use =shrink= value instead, or in addition to align:
 #+END_EXAMPLE
 
 ** New features
+*** Add support for ob-js :session with Indium
+You can specify :session for js src block with ~*JS REPL*~.
+*** Add support for ob-js :session with js-comint
+After you launched js-comint REPL. You can specify :session for js
+src block with ~*Javascript REPL*~.
+*** Add support for ob-js :session with skewer-mode
+After you launched skewer-mode REPL. You can specify :session for js
+src block with ~*skewer-repl*~.
 *** Add support for open src block in below window
 Set option ~org-src-window-setup~ to ~'split-window-below~.
 *** Add support for links to LaTeX equations in HTML export
diff --git a/lisp/ob-js.el b/lisp/ob-js.el
index 38c8c39ac..93c08c162 100644
--- a/lisp/ob-js.el
+++ b/lisp/ob-js.el
@@ -41,6 +41,9 @@
 (require 'ob)
 
 (declare-function run-mozilla "ext:moz" (arg))
+(declare-function run-js "js-comint" (cmd))
+(declare-function indium-run-node "indium-nodejs" (command))
+(declare-function indium-eval "indium-interaction" (string &optional callback))
 
 (defvar org-babel-default-header-args:js '()
   "Default header arguments for js code blocks.")
@@ -52,7 +55,11 @@
   "Name of command used to evaluate js blocks."
   :group 'org-babel
   :version "24.1"
-  :type 'string)
+  :type '(choice (const "node")
+		             (const "mozrepl")
+		             (const "js-comint")
+		             (const "skewer-mode"))
+  :safe #'stringp)
 
 (defvar org-babel-js-function-wrapper
   "require('sys').print(require('sys').inspect(function(){\n%s\n}()));"
@@ -62,32 +69,40 @@
   "Execute a block of Javascript code with org-babel.
 This function is called by `org-babel-execute-src-block'"
   (let* ((org-babel-js-cmd (or (cdr (assq :cmd params)) org-babel-js-cmd))
+	       (session (cdr (assq :session params)))
          (result-type (cdr (assq :result-type params)))
          (full-body (org-babel-expand-body:generic
-		     body params (org-babel-variable-assignments:js params)))
-	 (result (if (not (string= (cdr (assq :session params)) "none"))
-		     ;; session evaluation
-		     (let ((session (org-babel-prep-session:js
-				     (cdr (assq :session params)) params)))
-		       (nth 1
-			    (org-babel-comint-with-output
-				(session (format "%S" org-babel-js-eoe) t body)
-			      (mapc
-			       (lambda (line)
-				 (insert (org-babel-chomp line))
-				 (comint-send-input nil t))
-			       (list body (format "%S" org-babel-js-eoe))))))
-		   ;; external evaluation
-		   (let ((script-file (org-babel-temp-file "js-script-")))
-		     (with-temp-file script-file
-		       (insert
-			;; return the value or the output
-			(if (string= result-type "value")
-			    (format org-babel-js-function-wrapper full-body)
-			  full-body)))
-		     (org-babel-eval
-		      (format "%s %s" org-babel-js-cmd
-			      (org-babel-process-file-name script-file)) "")))))
+		                 body params (org-babel-variable-assignments:js params)))
+	       (result (if (not (string= (cdr (assq :session params)) "none"))
+		                 ;; session evaluation
+		                 (cond
+		                  ;; Indium Node
+		                  ((string= "*JS REPL*" session)
+		                   (require 'indium-repl)
+		                   (unless (get-buffer session)
+			                   (indium-run-node))
+		                   (indium-eval full-body))
+		                  (t
+		                   (let ((session (org-babel-prep-session:js
+				                               (cdr (assq :session params)) params)))
+			                   (nth 1
+			                        (org-babel-comint-with-output
+				                          (session (format "%S" org-babel-js-eoe) t body)
+				                        (dolist ((code (list body (format "%S" org-babel-js-eoe))))
+				                          (lambda (code)
+				                            (insert (org-babel-chomp code))
+				                            (comint-send-input nil t))))))))
+		               ;; external evaluation
+		               (let ((script-file (org-babel-temp-file "js-script-")))
+		                 (with-temp-file script-file
+		                   (insert
+			                  ;; return the value or the output
+			                  (if (string= result-type "value")
+			                      (format org-babel-js-function-wrapper full-body)
+			                    full-body)))
+		                 (org-babel-eval
+		                  (format "%s %s" org-babel-js-cmd
+			                        (org-babel-process-file-name script-file)) "")))))
     (org-babel-result-cond (cdr (assq :result-params params))
       result (org-babel-js-read result))))
 
@@ -97,16 +112,16 @@ If RESULTS look like a table, then convert them into an
 Emacs-lisp table, otherwise return the results as a string."
   (org-babel-read
    (if (and (stringp results)
-	    (string-prefix-p "[" results)
-	    (string-suffix-p "]" results))
+	          (string-prefix-p "[" results)
+	          (string-suffix-p "]" results))
        (org-babel-read
         (concat "'"
                 (replace-regexp-in-string
                  "\\[" "(" (replace-regexp-in-string
                             "\\]" ")" (replace-regexp-in-string
                                        ",[[:space:]]" " "
-				       (replace-regexp-in-string
-					"'" "\"" results))))))
+				                               (replace-regexp-in-string
+					                              "'" "\"" results))))))
      results)))
 
 (defun org-babel-js-var-to-js (var)
@@ -120,42 +135,64 @@ specifying a variable of the same value."
 (defun org-babel-prep-session:js (session params)
   "Prepare SESSION according to the header arguments specified in PARAMS."
   (let* ((session (org-babel-js-initiate-session session))
-	 (var-lines (org-babel-variable-assignments:js params)))
+	       (var-lines (org-babel-variable-assignments:js params)))
     (when session
       (org-babel-comint-in-buffer session
-	(sit-for .5) (goto-char (point-max))
-	(mapc (lambda (var)
-		(insert var) (comint-send-input nil t)
-		(org-babel-comint-wait-for-output session)
-		(sit-for .1) (goto-char (point-max))) var-lines)))
+	      (sit-for .5) (goto-char (point-max))
+	      (mapc (lambda (var)
+		            (insert var) (comint-send-input nil t)
+		            (org-babel-comint-wait-for-output session)
+		            (sit-for .1) (goto-char (point-max))) var-lines)))
     session))
 
 (defun org-babel-variable-assignments:js (params)
   "Return list of Javascript statements assigning the block's variables."
   (mapcar
    (lambda (pair) (format "var %s=%s;"
-			  (car pair) (org-babel-js-var-to-js (cdr pair))))
+			                (car pair) (org-babel-js-var-to-js (cdr pair))))
    (org-babel--get-vars params)))
 
 (defun org-babel-js-initiate-session (&optional session)
   "If there is not a current inferior-process-buffer in SESSION
 then create.  Return the initialized session."
-  (unless (string= session "none")
-    (cond
-     ((string= "mozrepl" org-babel-js-cmd)
-      (require 'moz)
-      (let ((session-buffer (save-window-excursion
-			      (run-mozilla nil)
-			      (rename-buffer session)
-			      (current-buffer))))
-	(if (org-babel-comint-buffer-livep session-buffer)
-	    (progn (sit-for .25) session-buffer)
-	  (sit-for .5)
-	  (org-babel-js-initiate-session session))))
-     ((string= "node" org-babel-js-cmd )
-      (error "Session evaluation with node.js is not supported"))
-     (t
-      (error "Sessions are only supported with mozrepl add \":cmd mozrepl\"")))))
+  (cond
+   ((string= session "none")
+    (error "Session evaluation is not supported"))
+   ((string= "*Javascript REPL*" session)
+    (require 'js-comint)
+    (let ((session-buffer "*Javascript REPL*"))
+      (if (and (org-babel-comint-buffer-livep (get-buffer session-buffer))
+	             (comint-check-proc session-buffer))
+	        session-buffer
+	      (call-interactively 'run-js)
+	      (sit-for .5)
+	      session-buffer)))
+   ((string= "*skewer-repl*" session) ; `skewer-mode'
+    (require 'skewer-repl)
+    (let ((session-buffer (get-buffer "*skewer-repl*")))
+      (if (and (org-babel-comint-buffer-livep (get-buffer session-buffer))
+	             (comint-check-proc session-buffer))
+	        session-buffer
+	      ;; start skewer REPL.
+	      (sit-for .5)
+	      (httpd-start)
+	      (run-skewer)
+	      (sit-for .5)
+	      session-buffer)))
+   ((string= "mozrepl" org-babel-js-cmd)
+    (require 'moz)
+    (let ((session-buffer (save-window-excursion
+			                      (run-mozilla nil)
+			                      (rename-buffer session)
+			                      (current-buffer))))
+      (if (org-babel-comint-buffer-livep session-buffer)
+	        (progn (sit-for .25) session-buffer)
+	      (sit-for .5)
+	      (org-babel-js-initiate-session session))))
+   ((string= "node" org-babel-js-cmd )
+    (error "Session evaluation with node.js is not supported"))
+   (t
+    (error "Sessions are only supported with mozrepl add \":cmd mozrepl\""))))
 
 (provide 'ob-js)
 
-- 
2.16.2


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

* Re: [PATCH] add :session support for ob-js.el
  2018-03-13 11:51   ` stardiviner
@ 2018-03-17 11:14     ` Nicolas Goaziou
  2018-03-17 17:51       ` About the assignment of FSF papers stardiviner
  2018-03-25  3:31       ` [PATCH] add :session support for ob-js.el stardiviner
  0 siblings, 2 replies; 11+ messages in thread
From: Nicolas Goaziou @ 2018-03-17 11:14 UTC (permalink / raw)
  To: stardiviner; +Cc: org-mode

Hello,

stardiviner <numbchild@gmail.com> writes:

> updated my code. I followed your suggestions. But modify code one by
> one messed code up. So I merge all related commits into one commit.
> Sorry for this.

Some comments follow.
> +	       (result (if (not (string= (cdr (assq :session params)) "none"))

You can integrate the test above in the `cond':

(cond
 ((string= "none" (cdr (assq :session params))) nil)
 ((string= "*JS REPL*" session) ...)
 ...)
> +	      (sit-for .5) (goto-char (point-max))

(sit-for .5)
(goto-char (point-max))

> +	      (mapc (lambda (var)
> +		            (insert var) (comint-send-input nil t)
> +		            (org-babel-comint-wait-for-output session)
> +		            (sit-for .1) (goto-char (point-max))) var-lines)))
>      session))

  (dolist (var ...)
   ...)

Also, what's your status wrt FSF papers? This cannot fit as
a TINYCHANGE.

Regard,

-- 
Nicolas Goaziou

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

* Re: About the assignment of FSF papers
  2018-03-17 11:14     ` Nicolas Goaziou
@ 2018-03-17 17:51       ` stardiviner
  2018-03-18 16:15         ` Nicolas Goaziou
  2018-03-25  3:31       ` [PATCH] add :session support for ob-js.el stardiviner
  1 sibling, 1 reply; 11+ messages in thread
From: stardiviner @ 2018-03-17 17:51 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: org-mode

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

I remember I tried this assignment before. But suspended at somewhere.

Here is the PDF paper where has my name. How to assign this paper?

BTW, this paper is old.

#+begin_src shell :dir "Data"
ls -l assignment.pdf
#+end_src

#+RESULTS[<2018-03-18 01:48:36> 3c6dfd290d7adb1dab0192c0cbf97104dc0668f1]:
: -rw-r--r-- 1 stardiviner users 307016 Apr 28  2016 assignment.pdf

Does it still work? If not I need to request a new one.

About assignment the paper, how can I assign on the PDF paper?

And no need to send real paper to US or somewhere, right? Only digital
paper need.






[-- Attachment #2.1: Type: text/html, Size: 2876 bytes --]

[-- Attachment #2.2: hckokjodmgmoopbp.png --]
[-- Type: image/png, Size: 243760 bytes --]

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

* Re: About the assignment of FSF papers
  2018-03-17 17:51       ` About the assignment of FSF papers stardiviner
@ 2018-03-18 16:15         ` Nicolas Goaziou
  2018-03-22 18:47           ` stardiviner
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2018-03-18 16:15 UTC (permalink / raw)
  To: stardiviner; +Cc: org-mode

Hello,

stardiviner <numbchild@gmail.com> writes:

> Here is the PDF paper where has my name. How to assign this paper?

Isn't it written on the file?

> BTW, this paper is old. 
>
> #+begin_src shell :dir "Data"
> ls -l assignment.pdf
> #+end_src
>
> #+RESULTS[<2018-03-18 01:48:36> 3c6dfd290d7adb1dab0192c0cbf97104dc0668f1]:
> : -rw-r--r-- 1 stardiviner users 307016 Apr 28 2016 assignment.pdf
>
> Does it still work? If not I need to request a new one.

The process hasn't changed for a while, so it should be fine.

> About assignment the paper, how can I assign on the PDF paper?

> And no need to send real paper to US or somewhere, right? Only digital
> paper need.

It depends on your country. Back in the days, I had to send it through
snail mail. You may want to ask to assign@gnu.org.

Regards,

-- 
Nicolas Goaziou

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

* Re: About the assignment of FSF papers
  2018-03-18 16:15         ` Nicolas Goaziou
@ 2018-03-22 18:47           ` stardiviner
  2018-03-24 19:02             ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: stardiviner @ 2018-03-22 18:47 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: org-mode


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

Hi, @Nicolas I finished my FSF paper assignment. Check out the attachment.

Finally can merge my patch now. So I can use it and delete the branch.


On 03/19/2018 12:15 AM, Nicolas Goaziou wrote:
> Hello,
>
> stardiviner <numbchild@gmail.com> writes:
>
>> Here is the PDF paper where has my name. How to assign this paper?
> Isn't it written on the file?
>
>> BTW, this paper is old.
>>
>> #+begin_src shell :dir "Data"
>> ls -l assignment.pdf
>> #+end_src
>>
>> #+RESULTS[<2018-03-18 01:48:36> 3c6dfd290d7adb1dab0192c0cbf97104dc0668f1]:
>> : -rw-r--r-- 1 stardiviner users 307016 Apr 28 2016 assignment.pdf
>>
>> Does it still work? If not I need to request a new one.
> The process hasn't changed for a while, so it should be fine.
>
>> About assignment the paper, how can I assign on the PDF paper?
>> And no need to send real paper to US or somewhere, right? Only digital
>> paper need.
> It depends on your country. Back in the days, I had to send it through
> snail mail. You may want to ask to assign@gnu.org.
>
> Regards,
>


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

[-- Attachment #2: Miles.1998363.EMACS.pdf --]
[-- Type: application/pdf, Size: 1615170 bytes --]

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

* Re: About the assignment of FSF papers
  2018-03-22 18:47           ` stardiviner
@ 2018-03-24 19:02             ` Nicolas Goaziou
  0 siblings, 0 replies; 11+ messages in thread
From: Nicolas Goaziou @ 2018-03-24 19:02 UTC (permalink / raw)
  To: stardiviner; +Cc: org-mode

Hello,

stardiviner <numbchild@gmail.com> writes:

> Hi, @Nicolas I finished my FSF paper assignment. Check out the
> attachment.

Great. I added you to the Hall of Fame.

> Finally can merge my patch now. So I can use it and delete the branch.

OK. It doesn't seem to apply on master. Could you include my latest
comments and send it again so I can apply it?

Thank you.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

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

* Re: [PATCH] add :session support for ob-js.el
  2018-03-17 11:14     ` Nicolas Goaziou
  2018-03-17 17:51       ` About the assignment of FSF papers stardiviner
@ 2018-03-25  3:31       ` stardiviner
  2018-03-25 21:09         ` Nicolas Goaziou
  1 sibling, 1 reply; 11+ messages in thread
From: stardiviner @ 2018-03-25  3:31 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: org-mode

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

I attached my new generated patches.


On 03/17/2018 07:14 PM, Nicolas Goaziou wrote:
> Some comments follow.
>> +	       (result (if (not (string= (cdr (assq :session params)) "none"))
> You can integrate the test above in the `cond':
>
> (cond
>   ((string= "none" (cdr (assq :session params))) nil)
>   ((string= "*JS REPL*" session) ...)
>   ...)
This is modified in new patch.
>> +	      (sit-for .5) (goto-char (point-max))
> (sit-for .5)
> (goto-char (point-max))
This is in original code, might because ob-js initialize REPL backend 
need some time so original author added `site-for`. After test, this 
seems does not matter. So remote the sit-for now.
>
>> +	      (mapc (lambda (var)
>> +		            (insert var) (comint-send-input nil t)
>> +		            (org-babel-comint-wait-for-output session)
>> +		            (sit-for .1) (goto-char (point-max))) var-lines)))
>>       session))
>    (dolist (var ...)
>     ...)
modified in new patch.

I don't know how to apply master branch new update on my local 
`ob-js-session` branch so to get ob-js related commits on top to 
generate new patches. (Do you have any idea on this?) The new patches 
are behind latest `master` branch. But should be compatible still. If 
generating patches based on latest `master` branch commit is must, I can 
do that.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-js.el-support-session-for-skewer-mode-REPL.patch --]
[-- Type: text/x-patch; name="0001-ob-js.el-support-session-for-skewer-mode-REPL.patch", Size: 5480 bytes --]

From 140ef4c23fb3e13a772ca01b92b14bccc47043fb Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Thu, 8 Mar 2018 17:15:58 +0800
Subject: [PATCH 1/4] * ob-js.el: support :session for skewer-mode REPL.

---
 etc/ORG-NEWS  |  4 +++
 lisp/ob-js.el | 81 ++++++++++++++++++++++++++++++++++++-----------------------
 2 files changed, 54 insertions(+), 31 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index bd9d2a8f7..11ecaa5d3 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -113,6 +113,10 @@ now sort according to the locale’s collation rules instead of by
 code-point.
 
 ** New features
+*** Add ~:session~ support of ob-js for skewer-mode
+#+begin_src js :session "*skewer-repl*"
+console.log("stardiviner")
+#+end_src
 *** Add support for links to LaTeX equations in HTML export
 Use MathJax links when enabled (by ~org-html-with-latex~), otherwise
 add a label to the rendered equation.
diff --git a/lisp/ob-js.el b/lisp/ob-js.el
index 38c8c39ac..920d104f8 100644
--- a/lisp/ob-js.el
+++ b/lisp/ob-js.el
@@ -41,6 +41,8 @@
 (require 'ob)
 
 (declare-function run-mozilla "ext:moz" (arg))
+(declare-function httpd-start "simple-httpd" ())
+(declare-function run-skewer "skewer-mode" ())
 
 (defvar org-babel-default-header-args:js '()
   "Default header arguments for js code blocks.")
@@ -52,7 +54,10 @@
   "Name of command used to evaluate js blocks."
   :group 'org-babel
   :version "24.1"
-  :type 'string)
+  :type '(choice (const "node")
+		 (const "mozrepl")
+		 (const "skewer-mode"))
+  :safe #'stringp)
 
 (defvar org-babel-js-function-wrapper
   "require('sys').print(require('sys').inspect(function(){\n%s\n}()));"
@@ -62,22 +67,13 @@
   "Execute a block of Javascript code with org-babel.
 This function is called by `org-babel-execute-src-block'"
   (let* ((org-babel-js-cmd (or (cdr (assq :cmd params)) org-babel-js-cmd))
+	 (session (cdr (assq :session params)))
          (result-type (cdr (assq :result-type params)))
          (full-body (org-babel-expand-body:generic
 		     body params (org-babel-variable-assignments:js params)))
-	 (result (if (not (string= (cdr (assq :session params)) "none"))
-		     ;; session evaluation
-		     (let ((session (org-babel-prep-session:js
-				     (cdr (assq :session params)) params)))
-		       (nth 1
-			    (org-babel-comint-with-output
-				(session (format "%S" org-babel-js-eoe) t body)
-			      (mapc
-			       (lambda (line)
-				 (insert (org-babel-chomp line))
-				 (comint-send-input nil t))
-			       (list body (format "%S" org-babel-js-eoe))))))
-		   ;; external evaluation
+	 (result (cond
+		  ;; no session specified, external evaluation
+		  ((string= session "none")
 		   (let ((script-file (org-babel-temp-file "js-script-")))
 		     (with-temp-file script-file
 		       (insert
@@ -87,7 +83,19 @@ This function is called by `org-babel-execute-src-block'"
 			  full-body)))
 		     (org-babel-eval
 		      (format "%s %s" org-babel-js-cmd
-			      (org-babel-process-file-name script-file)) "")))))
+			      (org-babel-process-file-name script-file)) "")))
+		  ;; session evaluation
+		  (t
+		   (let ((session (org-babel-prep-session:js
+				   (cdr (assq :session params)) params)))
+		     (nth 1
+			  (org-babel-comint-with-output
+			      (session (format "%S" org-babel-js-eoe) t body)
+			    (dolist (code (list body (format "%S" org-babel-js-eoe)))
+			      (lambda (code)
+				(insert (org-babel-chomp code))
+				(comint-send-input nil t)))))))
+		  )))
     (org-babel-result-cond (cdr (assq :result-params params))
       result (org-babel-js-read result))))
 
@@ -140,22 +148,33 @@ specifying a variable of the same value."
 (defun org-babel-js-initiate-session (&optional session)
   "If there is not a current inferior-process-buffer in SESSION
 then create.  Return the initialized session."
-  (unless (string= session "none")
-    (cond
-     ((string= "mozrepl" org-babel-js-cmd)
-      (require 'moz)
-      (let ((session-buffer (save-window-excursion
-			      (run-mozilla nil)
-			      (rename-buffer session)
-			      (current-buffer))))
-	(if (org-babel-comint-buffer-livep session-buffer)
-	    (progn (sit-for .25) session-buffer)
-	  (sit-for .5)
-	  (org-babel-js-initiate-session session))))
-     ((string= "node" org-babel-js-cmd )
-      (error "Session evaluation with node.js is not supported"))
-     (t
-      (error "Sessions are only supported with mozrepl add \":cmd mozrepl\"")))))
+  (cond
+   ((string= session "none")
+    (warn "Session evaluation of ob-js is not supported"))
+   ((string= "*skewer-repl*" session)
+    (require 'skewer-repl)
+    (let ((session-buffer (get-buffer "*skewer-repl*")))
+      (if (and (org-babel-comint-buffer-livep (get-buffer session-buffer))
+	       (comint-check-proc session-buffer))
+	  session-buffer
+	;; start skewer REPL.
+	(httpd-start)
+	(run-skewer)
+	session-buffer)))
+   ((string= "mozrepl" org-babel-js-cmd)
+    (require 'moz)
+    (let ((session-buffer (save-window-excursion
+			    (run-mozilla nil)
+			    (rename-buffer session)
+			    (current-buffer))))
+      (if (org-babel-comint-buffer-livep session-buffer)
+	  (progn (sit-for .25) session-buffer)
+	(sit-for .5)
+	(org-babel-js-initiate-session session))))
+   ((string= "node" org-babel-js-cmd )
+    (error "Session evaluation with node.js is not supported"))
+   (t
+    (error "Sessions are only supported with mozrepl add \":cmd mozrepl\""))))
 
 (provide 'ob-js)
 
-- 
2.16.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-ob-js.el-support-session-for-Indium-Node-REPL.patch --]
[-- Type: text/x-patch; name="0002-ob-js.el-support-session-for-Indium-Node-REPL.patch", Size: 2121 bytes --]

From e3d04ef080ef21d5741176ca7b02c25e35b8d414 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Sun, 18 Mar 2018 01:19:29 +0800
Subject: [PATCH 2/4] * ob-js.el: support :session for Indium Node REPL.

---
 etc/ORG-NEWS  |  4 ++++
 lisp/ob-js.el | 12 +++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 11ecaa5d3..0e0b6fa33 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -113,6 +113,10 @@ now sort according to the locale’s collation rules instead of by
 code-point.
 
 ** New features
+*** Add ~:session~ support of ob-js for Indium
+#+begin_src js :session "*JS REPL*"
+console.log("stardiviner")
+#+end_src
 *** Add ~:session~ support of ob-js for skewer-mode
 #+begin_src js :session "*skewer-repl*"
 console.log("stardiviner")
diff --git a/lisp/ob-js.el b/lisp/ob-js.el
index 920d104f8..06df20bf7 100644
--- a/lisp/ob-js.el
+++ b/lisp/ob-js.el
@@ -43,6 +43,8 @@
 (declare-function run-mozilla "ext:moz" (arg))
 (declare-function httpd-start "simple-httpd" ())
 (declare-function run-skewer "skewer-mode" ())
+(declare-function indium-run-node "indium-nodejs" (command))
+(declare-function indium-eval "indium-interaction" (string &optional callback))
 
 (defvar org-babel-default-header-args:js '()
   "Default header arguments for js code blocks.")
@@ -56,7 +58,8 @@
   :version "24.1"
   :type '(choice (const "node")
 		 (const "mozrepl")
-		 (const "skewer-mode"))
+		 (const "skewer-mode")
+		 (const "indium"))
   :safe #'stringp)
 
 (defvar org-babel-js-function-wrapper
@@ -84,6 +87,13 @@ This function is called by `org-babel-execute-src-block'"
 		     (org-babel-eval
 		      (format "%s %s" org-babel-js-cmd
 			      (org-babel-process-file-name script-file)) "")))
+		  ;; Indium Node REPL
+		  ;; separate case because Indium REPL is not inherited from comint-mode
+		  ((string= session "*JS REPL*")
+		   (require 'indium-repl)
+		   (unless (get-buffer session)
+		     (indium-run-node))
+		   (indium-eval full-body))
 		  ;; session evaluation
 		  (t
 		   (let ((session (org-babel-prep-session:js
-- 
2.16.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-ob-js.el-support-session-for-js-comint-REPL.patch --]
[-- Type: text/x-patch; name="0003-ob-js.el-support-session-for-js-comint-REPL.patch", Size: 1726 bytes --]

From a743e2252aa7030007d1f0f57f26640ffbbf14a1 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Sun, 18 Mar 2018 01:33:12 +0800
Subject: [PATCH 3/4] * ob-js.el: support :session for js-comint REPL.

---
 etc/ORG-NEWS  |  4 ++++
 lisp/ob-js.el | 12 +++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 0e0b6fa33..71895e6a0 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -113,6 +113,10 @@ now sort according to the locale’s collation rules instead of by
 code-point.
 
 ** New features
+*** Add ~:session~ support of ob-js for js-comint
+#+begin_src js :session "*Javascript REPL*"
+console.log("stardiviner")
+#+end_src
 *** Add ~:session~ support of ob-js for Indium
 #+begin_src js :session "*JS REPL*"
 console.log("stardiviner")
diff --git a/lisp/ob-js.el b/lisp/ob-js.el
index 06df20bf7..c829c4c74 100644
--- a/lisp/ob-js.el
+++ b/lisp/ob-js.el
@@ -59,7 +59,8 @@
   :type '(choice (const "node")
 		 (const "mozrepl")
 		 (const "skewer-mode")
-		 (const "indium"))
+		 (const "indium")
+		 (const "js-comint"))
   :safe #'stringp)
 
 (defvar org-babel-js-function-wrapper
@@ -171,6 +172,15 @@ then create.  Return the initialized session."
 	(httpd-start)
 	(run-skewer)
 	session-buffer)))
+   ((string= "*Javascript REPL*" session)
+    (require 'js-comint)
+    (let ((session-buffer "*Javascript REPL*"))
+      (if (and (org-babel-comint-buffer-livep (get-buffer session-buffer))
+	       (comint-check-proc session-buffer))
+	  session-buffer
+	(call-interactively 'run-js)
+	(sit-for .5)
+	session-buffer)))
    ((string= "mozrepl" org-babel-js-cmd)
     (require 'moz)
     (let ((session-buffer (save-window-excursion
-- 
2.16.2


[-- Attachment #5: 0004-ob-js.el-org-babel-prep-session-js-replace-mapc-with.patch --]
[-- Type: text/x-patch, Size: 1093 bytes --]

From 7fe493e915750b8337ad8ce830f595ab3648bc65 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Sun, 25 Mar 2018 11:26:37 +0800
Subject: [PATCH 4/4] * ob-js.el (org-babel-prep-session:js) replace mapc with
 dolist.

---
 lisp/ob-js.el | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lisp/ob-js.el b/lisp/ob-js.el
index c829c4c74..9c42687c0 100644
--- a/lisp/ob-js.el
+++ b/lisp/ob-js.el
@@ -142,11 +142,11 @@ specifying a variable of the same value."
 	 (var-lines (org-babel-variable-assignments:js params)))
     (when session
       (org-babel-comint-in-buffer session
-	(sit-for .5) (goto-char (point-max))
-	(mapc (lambda (var)
-		(insert var) (comint-send-input nil t)
-		(org-babel-comint-wait-for-output session)
-		(sit-for .1) (goto-char (point-max))) var-lines)))
+	(goto-char (point-max))
+	(dolist (var var-lines)
+	  (insert var) (comint-send-input nil t)
+	  (org-babel-comint-wait-for-output session)
+	  (sit-for .1) (goto-char (point-max)))))
     session))
 
 (defun org-babel-variable-assignments:js (params)
-- 
2.16.2


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

* Re: [PATCH] add :session support for ob-js.el
  2018-03-25  3:31       ` [PATCH] add :session support for ob-js.el stardiviner
@ 2018-03-25 21:09         ` Nicolas Goaziou
  2018-03-26  1:40           ` stardiviner
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2018-03-25 21:09 UTC (permalink / raw)
  To: stardiviner; +Cc: org-mode

Hello,

stardiviner <numbchild@gmail.com> writes:

> I attached my new generated patches.
>
>
> On 03/17/2018 07:14 PM, Nicolas Goaziou wrote:
>> Some comments follow.
>>> +	       (result (if (not (string= (cdr (assq :session params)) "none"))
>> You can integrate the test above in the `cond':
>>
>> (cond
>>   ((string= "none" (cdr (assq :session params))) nil)
>>   ((string= "*JS REPL*" session) ...)
>>   ...)
> This is modified in new patch.
>>> +	      (sit-for .5) (goto-char (point-max))
>> (sit-for .5)
>> (goto-char (point-max))
> This is in original code, might because ob-js initialize REPL backend
> need some time so original author added `site-for`. After test, this
> seems does not matter. So remote the sit-for now.
>>
>>> +	      (mapc (lambda (var)
>>> +		            (insert var) (comint-send-input nil t)
>>> +		            (org-babel-comint-wait-for-output session)
>>> +		            (sit-for .1) (goto-char (point-max))) var-lines)))
>>>       session))
>>    (dolist (var ...)
>>     ...)
> modified in new patch.
>
> I don't know how to apply master branch new update on my local
> `ob-js-session` branch so to get ob-js related commits on top to
> generate new patches. (Do you have any idea on this?) The new patches
> are behind latest `master` branch. But should be compatible still. If
> generating patches based on latest `master` branch commit is must,
> I can do that.

I applied you patch. However, I rewrote your commit messages: they need
to refer to modified variables and functions. I also fixed dangling
parenthesis, and fixed a typo in a move from `mapc' + `lambda' to
`dolist'.

Thank you.

Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] add :session support for ob-js.el
  2018-03-25 21:09         ` Nicolas Goaziou
@ 2018-03-26  1:40           ` stardiviner
  0 siblings, 0 replies; 11+ messages in thread
From: stardiviner @ 2018-03-26  1:40 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: org-mode

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

Thanks for your refactoring. I must be recklessof this. I will be 
careful next time.


On 03/26/2018 05:09 AM, Nicolas Goaziou wrote:
> Hello,
>
> stardiviner <numbchild@gmail.com> writes:
>
>> I attached my new generated patches.
>>
>>
>> On 03/17/2018 07:14 PM, Nicolas Goaziou wrote:
>>> Some comments follow.
>>>> +	       (result (if (not (string= (cdr (assq :session params)) "none"))
>>> You can integrate the test above in the `cond':
>>>
>>> (cond
>>>    ((string= "none" (cdr (assq :session params))) nil)
>>>    ((string= "*JS REPL*" session) ...)
>>>    ...)
>> This is modified in new patch.
>>>> +	      (sit-for .5) (goto-char (point-max))
>>> (sit-for .5)
>>> (goto-char (point-max))
>> This is in original code, might because ob-js initialize REPL backend
>> need some time so original author added `site-for`. After test, this
>> seems does not matter. So remote the sit-for now.
>>>> +	      (mapc (lambda (var)
>>>> +		            (insert var) (comint-send-input nil t)
>>>> +		            (org-babel-comint-wait-for-output session)
>>>> +		            (sit-for .1) (goto-char (point-max))) var-lines)))
>>>>        session))
>>>     (dolist (var ...)
>>>      ...)
>> modified in new patch.
>>
>> I don't know how to apply master branch new update on my local
>> `ob-js-session` branch so to get ob-js related commits on top to
>> generate new patches. (Do you have any idea on this?) The new patches
>> are behind latest `master` branch. But should be compatible still. If
>> generating patches based on latest `master` branch commit is must,
>> I can do that.
> I applied you patch. However, I rewrote your commit messages: they need
> to refer to modified variables and functions. I also fixed dangling
> parenthesis, and fixed a typo in a move from `mapc' + `lambda' to
> `dolist'.
>
> Thank you.
>
> Regards,
>


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

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

end of thread, other threads:[~2018-03-26  1:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-12  9:02 [PATCH] add :session support for ob-js.el stardiviner
2018-03-13  8:43 ` Nicolas Goaziou
2018-03-13 11:51   ` stardiviner
2018-03-17 11:14     ` Nicolas Goaziou
2018-03-17 17:51       ` About the assignment of FSF papers stardiviner
2018-03-18 16:15         ` Nicolas Goaziou
2018-03-22 18:47           ` stardiviner
2018-03-24 19:02             ` Nicolas Goaziou
2018-03-25  3:31       ` [PATCH] add :session support for ob-js.el stardiviner
2018-03-25 21:09         ` Nicolas Goaziou
2018-03-26  1:40           ` stardiviner

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