branch: elpa/el-job
commit 7cb72107fc5a9be1e448c5e81e2012b9bfd25b69
Author: Martin Edström <meedstro...@gmail.com>
Commit: Martin Edström <meedstro...@gmail.com>

    .
---
 el-job-child.el | 18 ++++++++++--------
 el-job.el       | 31 ++++++++++++++++++++-----------
 2 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/el-job-child.el b/el-job-child.el
index 47d68f9ff7..83d0871f7e 100644
--- a/el-job-child.el
+++ b/el-job-child.el
@@ -35,20 +35,22 @@ and each element must be a proper list or nil."
     (when alist2 (error "Lists differed in length"))
     (nreverse merged)))
 
-(defun el-job-child--work (func items)
+(defun el-job-child--work (func &optional items)
   "Run FUNC on one of ITEMS at a time.
 FUNC comes from :funcall argument of `org-node-job-launch'.
 
 Benchmark how long FUNC took to handle each item, and add that
 information to the final return value."
   (let (item start output meta results)
-    (while items
-      (setq item (pop items))
-      (setq start (time-convert nil t))
-      (setq output (funcall func item))
-      (push (time-since start) meta)
-      ;; May affect the durations erratically, so do this step after.
-      (setq results (el-job-child--zip output results)))
+    (if items
+        (while items
+          (setq item (pop items))
+          (setq start (time-convert nil t))
+          (setq output (funcall func item))
+          (push (time-since start) meta)
+          ;; May affect the durations erratically, so do this step after.
+          (setq results (el-job-child--zip output results)))
+      (funcall func))
     ;; Ensure durations are in same order that ITEMS came in, letting us
     ;; associate which with which just by index.
     (setq meta (nreverse meta))
diff --git a/el-job.el b/el-job.el
index b1a6087bdc..aacaacabb7 100644
--- a/el-job.el
+++ b/el-job.el
@@ -41,6 +41,12 @@
 (require 'el-job-child)
 (declare-function eshell-wait-for-processes "esh-proc")
 
+;; FIXME: "vfork argument list too long", when :inject-vars massive.
+;;        Probably need to refactor to use `process-send-string'.
+;;        Wonder if PTY works better than pipe in this regard?
+
+;; TODO: Want a method to keep children alive and skip spin-up.
+
 ;;; Subroutines:
 
 (defvar el-job--feature-mem nil)
@@ -321,7 +327,7 @@ subprocess.
 
 Due to the absence of `load-path', be careful writing `require'
 statements into that Emacs Lisp file.  You can pass `load-path' via
-INJECT-VARS, but consider that less requires means faster spin-up.
+INJECT-VARS, but consider that fewer dependencies means faster spin-up.
 
 
 INPUTS is a list that will be split by up to the number
@@ -408,14 +414,15 @@ evaluated many times."
                       (current-buffer))))
              print-length
              print-level
+             (print-circle t)
+             (print-symbols-bare t)
              (inject-vars-alist
-              (cons (cons 'current-time-list current-time-list)
-                    ;; TODO: Reuse allocated memory instead of building a new
-                    ;; list since the values could possibly be huge.
-                    (cl-loop
-                     for var in inject-vars
-                     if (symbolp var) collect (cons var (symbol-value var))
-                     else collect var)))
+              ;; TODO: Reuse allocated memory instead of building a new
+              ;; list since the values could possibly be huge.
+              (cl-loop
+               for var in inject-vars
+               if (symbolp var) collect (cons var (symbol-value var))
+               else collect var))
              (inject-vars-expr (prin1-to-string
                                 `(dolist (var ',inject-vars-alist)
                                    (set (car var) (cdr var)))))
@@ -450,9 +457,11 @@ evaluated many times."
                   (if eval-once (list "--eval" eval-once))
                   (list
                    "--load" (el-job--find-lib 'el-job-child)
-                   "--eval" (format "(el-job-child--work #'%S '%s)"
-                                    funcall
-                                    (prin1-to-string items))))
+                   "--eval" (if items
+                                (format "(el-job-child--work #'%S)" funcall)
+                              (format "(el-job-child--work #'%S '%s)"
+                                      funcall
+                                      (prin1-to-string items)))))
                  :sentinel
                  (lambda (proc event)
                    (pcase event

Reply via email to