john_titor has been added to fg42 elisp's lib

This commit is contained in:
Sameer Rahmani 2019-01-14 17:21:36 +00:00
parent c1e58af798
commit 8241ef3cd8
5 changed files with 42 additions and 44 deletions

View File

@ -15,7 +15,7 @@
;; Extension -------------------------------------
(extension john_titor
:version "2.32"
:on-initialize extensions/john_titor-initialize
:on-initialize extensions/john-titor-initialize
:docs "lib/extensions/john_titor/readme.org")
(provide 'extensions/john_titor)

View File

@ -1,30 +0,0 @@
;;; john_title --- Enables RPC for john titor client
;;; Commentary:
;;; Code:
(defvar epc-connection nil
"The EPC connection to the john titor client.")
(defun john_titor/connect ()
"Connect to john titor via RPC."
(interactive)
(setq epc-connection
(epc:start-epc "node" '("../../..//john_titor/target/main.js"))))
(message "%S" (epc:call-sync epc-connection 'echo '(10)))
(defun john_titor/disconnect ()
"Disconnect from the john titor client."
(interactive)
(epc:stop-epc epc-connection))
;;;###autoload
(defun extensions/john_titor-initialize ()
"Initialize the john_titor extention."
(require 'epc)
(if (nilp epc-connection)
(john_titor/connect)))
(provide 'extensions/john_titor/init)
;;; init.el ends here

View File

@ -1 +0,0 @@
sameer.rahmani@MacBook-Pro-4.local.2114

View File

@ -1,28 +1,26 @@
;;; john_title --- Enables RPC for john titor client
;;; Commentary:
;;; Code:
(defvar epc-connection nil
"The EPC connection to the john titor client.")
(defun john_titor/connect ()
(defun john-titor-connect ()
"Connect to john titor via RPC."
(interactive)
(setq epc-connection
(epc:start-epc "node" '("~/.fg42/john_titor/target/main.js"))))
(john_titor/connect))
(defun john_titor/disconnect ()
(defun john-titor-disconnect ()
"Disconnect from the john titor client."
(interactive)
(epc:stop-epc epc-connection))
(john_titor/disconnect))
;;;###autoload
(defun extensions/john_titor-initialize ()
(defun extensions/john-titor-initialize ()
"Initialize the john_titor extention."
(require 'epc)
(require 'john_titor)
(when (nilp epc-connection)
(john-titor-connect)))
(if (nilp epc-connection)
(john_titor/connect)))
(provide 'extensions/john_titor/init)
;;; init.el ends here

31
lib/john_titor.el Normal file
View File

@ -0,0 +1,31 @@
;;; john_titor --- Enables RPC for john titor client
;;; Commentary:
;;; Code:
(require 'epc)
(defvar epc-connection nil
"The EPC connection to the john titor client.")
(defun john_titor/connect ()
"Connect to john titor via RPC."
(setq epc-connection
(epc:start-epc "node" '("../../../john_titor/target/main.js"))))
(defun john_titor/call-sync (command args)
"Call the given COMMAND with the given ARGS via john titor epc."
(epc:call-sync command args))
(defun john_titor/call (command args f)
"Call the COMMAND with the given ARGS in async fashion and call F as callback."
(deferred:$
(epc:call-deferred epc-connection command args)
(deferred:nextc it f)))
(defun john_titor/disconnect ()
"Disconnect from the john titor client."
(epc:stop-epc epc-connection))
(provide 'john_titor)
;;; john_titor.el ends here