# support functions to run pf inside emacs # interaction is through standard output, we can communcate with emacs # by sending a "emacs: (expr ...)\n" string # see libpf/emacs/*.el provide emacs # send a command to emacs : >emacs "emacs:" p write ; "(thing -- )\txt will generate expression (list), which will be formatted." doc # command completion: need to pass symbols as strings : emacs-words words ' >string map ; # help : emacs-help dup "\t" concat swap >symbol try find try docstring recover 2drop "not documented" endtry recover 2drop "not found" endtry + 1 pack (message) swap concat >emacs ; : emacs-.S { ds .ds } with-output-to-string ` message 2 pack >emacs ; # redefine this one, so we can load script that run interactively : interactive "OK" p cr ; # for extra confidence : ping "I'm still here." p cr ; # write an atom to the log buffer : emacs-log stdout-stream write-atom ; # so we can send empty lists : nil () ; # see modules.pf for the normal interactive mode using # PF supports 2 main synchronous bidirectional I/O protocols, ATOM and # LINE, where for each received datum a similar datum is # returned. ATOM is a lisp like interface, while LINE is there to # support almost all other text protocols. since emacs is lisp, it can # take advantage of the read/write interface. # the emacs interface is organized like this: # - run PF as a daemon # - connect to a console socket (which uses LINE mode) # - open an atom listener for IPC # console stuff load-console variable emacs-command # output handlers : quoted-receiver read emacs-command ! { emacs-command @ 2 pack serialize } is console-quote ; # emacs will start PF in daemon mode, then connect to it using socat. "PF daemon running." p cr # this task is done finish