1 ;; -*- mode: emacs-lisp; lexical-binding: t; -*-
2 ;;; parallel-remote.el ---
4 ;; Copyright (C) 2013 Grégoire Jadi
6 ;; Author: Grégoire Jadi <gregoire.jadi@gmail.com>
8 ;; This program is free software: you can redistribute it and/or
9 ;; modify it under the terms of the GNU General Public License as
10 ;; published by the Free Software Foundation, either version 3 of
11 ;; the License, or (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
25 (defvar parallel-service nil)
26 (defvar parallel-task-id nil)
27 (defvar parallel-client nil)
28 (defvar parallel--executed nil)
30 (defun parallel-send (data)
31 (process-send-string parallel-client
32 (format "%S " (cons parallel-task-id data))))
34 (defun parallel-remote--init ()
35 (setq parallel-client (make-network-process :name "emacs-parallel"
38 :service parallel-service
41 (set-process-filter parallel-client #'parallel-remote--filter)
43 (when noninteractive ; Batch Mode
44 ;; The evaluation is done in the `parallel--filter' but in Batch
45 ;; Mode, Emacs doesn't wait for the input, it stops as soon as
46 ;; `parallel--init' has been executed.
47 (while (null parallel--executed)
48 (sleep-for 10)))) ; arbitrary chosen
50 (defun parallel-remote--filter (_proc output)
52 (if (or noninteractive
57 (eval (read output))))
58 (setq parallel--executed t)
61 (provide 'parallel-remote)
63 ;;; parallel-remote.el ends here