FUEL: remote connections.
parent
db63d9d324
commit
f34f7298ee
|
@ -2,9 +2,10 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
|
||||||
USING: accessors arrays assocs compiler.units definitions fuel.eval
|
USING: accessors arrays assocs compiler.units definitions fuel.eval
|
||||||
fuel.help help.markup help.topics io.pathnames kernel math math.order
|
fuel.help help.markup help.topics io io.encodings.utf8 io.pathnames
|
||||||
memoize namespaces parser sequences sets sorting tools.crossref
|
io.servers.connection kernel listener math math.order memoize
|
||||||
tools.scaffold tools.vocabs vocabs vocabs.loader vocabs.parser words ;
|
namespaces parser sequences sets sorting tools.crossref tools.scaffold
|
||||||
|
tools.vocabs vocabs vocabs.loader vocabs.parser words ;
|
||||||
|
|
||||||
IN: fuel
|
IN: fuel
|
||||||
|
|
||||||
|
@ -174,3 +175,19 @@ PRIVATE>
|
||||||
|
|
||||||
: fuel-scaffold-get-root ( name -- ) find-vocab-root fuel-eval-set-result ;
|
: fuel-scaffold-get-root ( name -- ) find-vocab-root fuel-eval-set-result ;
|
||||||
|
|
||||||
|
! Remote connection
|
||||||
|
|
||||||
|
: fuel-start-remote-listener ( port/f -- )
|
||||||
|
"Starting server. Connect with 'M-x connect-to-factor' in Emacs"
|
||||||
|
write nl flush number? [ 9000 ] unless*
|
||||||
|
<threaded-server>
|
||||||
|
"tty-server" >>name
|
||||||
|
utf8 >>encoding
|
||||||
|
swap local-server >>insecure
|
||||||
|
[ listener ] >>handler
|
||||||
|
f >>timeout
|
||||||
|
start-server ;
|
||||||
|
|
||||||
|
: fuel-start-remote-listener* ( -- ) f fuel-start-remote-listener ;
|
||||||
|
|
||||||
|
MAIN: fuel-start-remote-listener*
|
||||||
|
|
|
@ -53,6 +53,20 @@ beast.
|
||||||
factor image (overwriting the current one) with all the needed
|
factor image (overwriting the current one) with all the needed
|
||||||
vocabs.
|
vocabs.
|
||||||
|
|
||||||
|
*** Connecting to a running Factor
|
||||||
|
|
||||||
|
'run-factor' starts a new factor listener process managed by Emacs.
|
||||||
|
If you prefer to start Factor externally, you can also connect
|
||||||
|
remotely from Emacs. Here's how to proceed:
|
||||||
|
|
||||||
|
- In the factor listener, run FUEL:
|
||||||
|
"fuel" run
|
||||||
|
This will start a server listener in port 9000.
|
||||||
|
- Switch to Emacs and issue the command 'M-x connect-to-factor'.
|
||||||
|
|
||||||
|
That's it; you should be up and running. See the help for
|
||||||
|
'connect-to-factor' for how to use a different port.
|
||||||
|
|
||||||
*** Vocabulary creation
|
*** Vocabulary creation
|
||||||
|
|
||||||
FUEL offers a basic interface with Factor's scaffolding utilities.
|
FUEL offers a basic interface with Factor's scaffolding utilities.
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
(autoload 'switch-to-factor "fuel-listener.el"
|
(autoload 'switch-to-factor "fuel-listener.el"
|
||||||
"Start a Factor listener, or switch to a running one." t)
|
"Start a Factor listener, or switch to a running one." t)
|
||||||
|
|
||||||
|
(autoload 'connect-to-factor "fuel-listener.el"
|
||||||
|
"Connect to an external Factor listener." t)
|
||||||
|
|
||||||
(autoload 'fuel-autodoc-mode "fuel-help.el"
|
(autoload 'fuel-autodoc-mode "fuel-help.el"
|
||||||
"Minor mode showing in the minibuffer a synopsis of Factor word at point."
|
"Minor mode showing in the minibuffer a synopsis of Factor word at point."
|
||||||
t)
|
t)
|
||||||
|
|
|
@ -87,6 +87,17 @@ buffer."
|
||||||
(fuel-listener--wait-for-prompt 10000)
|
(fuel-listener--wait-for-prompt 10000)
|
||||||
(fuel-con--setup-connection (current-buffer))))
|
(fuel-con--setup-connection (current-buffer))))
|
||||||
|
|
||||||
|
(defun fuel-listener--connect-process (port)
|
||||||
|
(message "Connecting to remote listener ...")
|
||||||
|
(pop-to-buffer (fuel-listener--buffer))
|
||||||
|
(let ((process (get-buffer-process (current-buffer))))
|
||||||
|
(when (or (not process)
|
||||||
|
(y-or-n-p "Kill current listener? "))
|
||||||
|
(make-comint-in-buffer "fuel listener" (current-buffer)
|
||||||
|
(cons "localhost" port))
|
||||||
|
(fuel-listener--wait-for-prompt 10000)
|
||||||
|
(fuel-con--setup-connection (current-buffer)))))
|
||||||
|
|
||||||
(defun fuel-listener--process (&optional start)
|
(defun fuel-listener--process (&optional start)
|
||||||
(or (and (buffer-live-p (fuel-listener--buffer))
|
(or (and (buffer-live-p (fuel-listener--buffer))
|
||||||
(get-buffer-process (fuel-listener--buffer)))
|
(get-buffer-process (fuel-listener--buffer)))
|
||||||
|
@ -123,6 +134,17 @@ buffer."
|
||||||
(pop-to-buffer buf)
|
(pop-to-buffer buf)
|
||||||
(switch-to-buffer buf))))
|
(switch-to-buffer buf))))
|
||||||
|
|
||||||
|
(defun connect-to-factor (&optional arg)
|
||||||
|
"Connects to a remote listener running in the same host.
|
||||||
|
Without prefix argument, the default port, 9000, is used.
|
||||||
|
Otherwise, you'll be prompted for it. To make this work, in the
|
||||||
|
remote listener you need to issue the words
|
||||||
|
'fuel-start-remote-listener*' or 'port
|
||||||
|
fuel-start-remote-listener', from the fuel vocabulary."
|
||||||
|
(interactive "P")
|
||||||
|
(let ((port (if (not arg) 9000 (read-number "Port: "))))
|
||||||
|
(fuel-listener--connect-process port)))
|
||||||
|
|
||||||
(defun fuel-listener-nuke ()
|
(defun fuel-listener-nuke ()
|
||||||
"Try this command if the listener becomes unresponsive."
|
"Try this command if the listener becomes unresponsive."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
|
Loading…
Reference in New Issue