[comp.emacs] front-end-processor

sana@news3.t-asted.tis.co.jp (Kazuhiro Sanada) (07/12/90)

I'm a beginner of this newsgroup.

My name is Kazuhiro Sanada(call me Kaz).

I have one question.

"How can I use gnu-emacs as a front-end processor?"

I made a DB-search system. When input a key, then return some data
onto standard-output.
I successfully called this program from gnu-emacs environment by using
emacs-lisp. But what I really want to do is to make it always ready
under gnu-emacs.

If you need some more information about my working environment,
please post the request or write to me.

Kazuhiro Sanada
sana@news3.t-asted.tis.co.jp

sana@news3.t-asted.tis.co.jp (Kazuhiro Sanada) (07/19/90)

Dear Mr.Hahn and Mr.Gesley,

Thanks a lot for answering to me.

Yesterday I got the "GNU Emacs Lisp Manual", so I'm studying with it now.
If I could find the way to make a emacs-front-end-processing-environment,
I will post here again.

(To Mr.Hahn)
I'm going to explain the exact meaning of the last letter.

I already found the way to use GNU-emacs as a temporary front-end processor,
using some description of Emacs-Lisp. Following is an example.

(defun ej (arg)
	(interactive "sInput the word: ")
	(setq param (format "-D%s" arg))
	(call-process "/usr/sanada/srchdb" nil t nil param))

"interactive" function gets string from keyboard.
Using "setq" and "format" functions, I can create any string I like
as if using "sprintf" function of C-language.
"call-process" creates a synchronous process. It calls "/usr/sanada/srchdb"
and waits for it to finish. The second parameter is the input file
(in this case, no input file), the third output buffer name(in this case,
current buffer), the fourth redisplay buffer name.

You can write this lisp function on "~/.emacs" or any other file(if you
wrote the other file than "~/.emacs", you have to read that file using
"load-file" function, which can be called lisp function in "~/.emacs"
or M-x environment). When you need the function, you can easily call it
under the M-x environment. If there is "interactive" function, you should
input a string and set it into the "arg" variable.

I heard that "start-process" function can create a non-synchronic process.
I'm on the way to learn how to use this, so wait a few days(or weeks, months?)

Kazuhiro Sanada
sana@news3.t-asted.tis.co.jp

sana@news3.t-asted.tis.co.jp (Kazuhiro Sanada) (07/20/90)

I'm Kaz,

I found the way to load a executable module under emacs environment.
At first, you can see a sample emacs-lisp program.

(defun cat-start ()
  (interactive)
  (print (setq object-name
	 (start-process "sana-process" "foo-output" "cat" "-n"))))

(defun cat-test (arg)
  (interactive "sInput string: ")
  (setq newarg (format "%s\n" arg))
  (process-send-string "sana-process" newarg))

(defun cat-end ()
  (interactive)
  (process-send-eof "sana-process"))

(defun cat-kill ()
  (interactive)
  (kill-process "sana-process"))

(defun cat-processp ()
  (interactive)
  (print (processp object-name)))

This sample emacs-lisp program plays the following role;
prints the string which you entered from the minibuffer
with line numbers on the buffer "foo-output".

You can start "cat -n" program with "cat-start" function. Every 'defun'
needs "interactive" on the top of the definition in order to be called
from M-x minibuffer. The process name is "sana-process", while there
exists a object name. Please save the object name("start-process" return
value) into a proper variable.

 You can enter a string you like by calling "cat-test". This function
promotes your input from the keyboard on the minibuffer line. What you
input goes to standard-input because of "process-send-string" function.

 If you want to finish the process, you should call "cat-end" function.
It sends EOF to standard-input, the ending signal to "cat" command.
That function depends on "process-send-eof".

 There is a way to kill the process. The function name is "cat-kill".
In that function, "kill-process" kill the process.

 You can find "cat-processp" function, as the last function description.
It has to return t if the process is alive, and nil if dead, but another
value may be returned.

 Indeed it seems to us that there exist some problems, but you can easily
make use of that kind of requests.

Many thanks to those who helped me.

Kazuhiro Sanada
sana@news3.t-asted.tis.co.jp