The code constantly prints server-process: nil
instead of the server process name:
-*- lexical-binding: t; -*-
(let* ((port 1234)
(server-process 'something))
(setq server-process
(make-network-process
:server t
:name "libbasecampel-oauth-http-server"
:service port
:buffer (generate-new-buffer "*libbasecampel-oauth-http-server*")
:filter (lambda (_process _data)
(message "server-process: %s" server-process)))))
Can someone please explain why I can't access the server process from the filter lambda? Also, I would like to know how to do it, my goal being to kill the server when data arrives.
In case you wonder, the _process
argument to the filter function is the client process, not the server one.
(lambda
and a comma before theserver-process
in the message statement. In terms of thelet*
, you are only bindingport
andserver-process
and you are not using either of them in subsequent let-bound statements -- as such, it would appear that justlet
is sufficient and do not needlet*
. In addition, you may be interested in tryinglexical-let
instead oflet
-- in that case, you may not need the backtick/comma.(message "%S" (process-filter server-process))
to the end of that outermostlet*
form, I see the expected(closure ((server-process . #<process libbasecampel-oauth-http-server>) (port . 1234) t) (_process _data) (message "server-process: %s" server-process))
. Do you see the same?