comparison lisp/packages/gnuserv.el @ 153:25f70ba0133c r20-3b3

Import from CVS: tag r20-3b3
author cvs
date Mon, 13 Aug 2007 09:38:25 +0200
parents 59463afc5666
children 5a88923fcbfe
comparison
equal deleted inserted replaced
152:4c132ee2d62b 153:25f70ba0133c
1 ;;; gnuserv.el --- Lisp interface code between Emacs and gnuserv 1 ;;; gnuserv.el --- Lisp interface code between Emacs and gnuserv
2 ;; Copyright (C) 1989-1997 Free Software Foundation, Inc. 2 ;; Copyright (C) 1989-1997 Free Software Foundation, Inc.
3 3
4 ;; Version: 3.2 4 ;; Version: 3.3
5 ;; Author: Andy Norman (ange@hplb.hpl.hp.com), originally based on server.el 5 ;; Author: Andy Norman (ange@hplb.hpl.hp.com), originally based on server.el
6 ;; Hrvoje Niksic <hniksic@srce.hr> 6 ;; Hrvoje Niksic <hniksic@srce.hr>
7 ;; Maintainer: Jan Vroonhof <vroonhof@math.ethz.ch>,
8 ;; Hrvoje Niksic <hniksic@srce.hr>
7 ;; Keywords: environment, processes, terminals 9 ;; Keywords: environment, processes, terminals
8 10
9 ;; This file is part of XEmacs. 11 ;; This file is part of XEmacs.
10 12
11 ;; XEmacs is free software; you can redistribute it and/or modify it 13 ;; XEmacs is free software; you can redistribute it and/or modify it
43 ;; terminal or X display in the usual way. If you are running under 45 ;; terminal or X display in the usual way. If you are running under
44 ;; X, a new X frame will be open for each gnuclient. If you are on a 46 ;; X, a new X frame will be open for each gnuclient. If you are on a
45 ;; TTY, this TTY will be attached as a new device to the running 47 ;; TTY, this TTY will be attached as a new device to the running
46 ;; XEmacs, and will be removed once you are done with the buffer. 48 ;; XEmacs, and will be removed once you are done with the buffer.
47 49
48 ;; To evaluate a Lisp form in a running Emacs, use the `gnudoit' 50 ;; To evaluate a Lisp form in a running Emacs, use the `-eval'
49 ;; utility. For example `gnudoit "(+ 2 3)"' will print `5', whereas 51 ;; argument of gnuclient. To simplify this, we provide the `gnudoit'
50 ;; `gnudoit "(gnus)"' will fire up your favorite newsreader. Like 52 ;; shell script. For example `gnudoit "(+ 2 3)"' will print `5',
51 ;; gnuclient, `gnudoit' requires the server to be started prior to 53 ;; whereas `gnudoit "(gnus)"' will fire up your favorite newsreader.
52 ;; using it. 54 ;; Like gnuclient, `gnudoit' requires the server to be started prior
55 ;; to using it.
53 56
54 ;; For more information you can refer to man pages of gnuclient, 57 ;; For more information you can refer to man pages of gnuclient,
55 ;; gnudoit and gnuserv, distributed with XEmacs. 58 ;; gnudoit and gnuserv, distributed with XEmacs.
56 59
57 ;; gnuserv.el was originally written by Andy Norman as an improvement 60 ;; gnuserv.el was originally written by Andy Norman as an improvement
75 78
76 79
77 ;;; Code: 80 ;;; Code:
78 81
79 (defconst gnuserv-rcs-version 82 (defconst gnuserv-rcs-version
80 "$Id: gnuserv.el,v 1.9 1997/05/23 01:36:30 steve Exp $") 83 "$Id: gnuserv.el,v 1.10 1997/05/29 23:50:05 steve Exp $")
81 84
82 (defgroup gnuserv nil 85 (defgroup gnuserv nil
83 "The gnuserv suite of programs to talk to Emacs from outside." 86 "The gnuserv suite of programs to talk to Emacs from outside."
84 :group 'environment 87 :group 'environment
85 :group 'processes 88 :group 'processes
315 ;; <text> - the actual contents of the request. 318 ;; <text> - the actual contents of the request.
316 (defun gnuserv-process-filter (proc string) 319 (defun gnuserv-process-filter (proc string)
317 "Process gnuserv client requests to execute Emacs commands." 320 "Process gnuserv client requests to execute Emacs commands."
318 (setq gnuserv-string (concat gnuserv-string string)) 321 (setq gnuserv-string (concat gnuserv-string string))
319 ;; C-d means end of request. 322 ;; C-d means end of request.
320 (when (string-match "\C-d$" gnuserv-string) 323 (when (string-match "\C-d\\'" gnuserv-string)
321 (cond ((string-match "^[0-9]+" gnuserv-string) ; client request id 324 (cond ((string-match "^[0-9]+" gnuserv-string) ; client request id
322 (let ((header (read-from-string gnuserv-string))) 325 (let ((header (read-from-string gnuserv-string)))
323 ;; Set the client we are talking to. 326 ;; Set the client we are talking to.
324 (setq gnuserv-current-client (car header)) 327 (setq gnuserv-current-client (car header))
325 ;; Evaluate the expression 328 ;; Evaluate the expression
625 (car (gnuclient-buffers client))) 628 (car (gnuclient-buffers client)))
626 ;; Else, try to find any client with at least one buffer, and 629 ;; Else, try to find any client with at least one buffer, and
627 ;; return its first buffer. 630 ;; return its first buffer.
628 ((setq client 631 ((setq client
629 (car (member-if-not 'null gnuserv-clients 632 (car (member-if-not 'null gnuserv-clients
630 :key 'gnuserv-buffers))) 633 :key 'gnuclient-buffers)))
631 (car (gnuclient-buffers client))) 634 (car (gnuclient-buffers client)))
632 ;; Oh, give up. 635 ;; Oh, give up.
633 (t nil)))) 636 (t nil))))
634 637
635 (defun gnuserv-buffer-done (buffer) 638 (defun gnuserv-buffer-done (buffer)
672 (set-process-sentinel gnuserv-process nil) 675 (set-process-sentinel gnuserv-process nil)
673 (gnuserv-prepare-shutdown) 676 (gnuserv-prepare-shutdown)
674 (condition-case () 677 (condition-case ()
675 (delete-process gnuserv-process) 678 (delete-process gnuserv-process)
676 (error nil)) 679 (error nil))
677 (setq gnuserv-process nil) 680 (setq gnuserv-process nil)))
678 (message "Killed server")))
679 681
680 ;; Actually start the process. Kills all the clients before-hand. 682 ;; Actually start the process. Kills all the clients before-hand.
681 (defun gnuserv-start-1 (&optional leave-dead) 683 (defun gnuserv-start-1 (&optional leave-dead)
682 ;; Shutdown the existing server, if any. 684 ;; Shutdown the existing server, if any.
683 (gnuserv-shutdown) 685 (gnuserv-shutdown)