Initial Commit
[packages] / xemacs-packages / ilisp / ilisp-prc.el
1 ;;; -*- Mode: Emacs-Lisp -*-
2
3 ;;; ilisp-prc.el --
4 ;;; ILISP process handling.
5 ;;;
6 ;;; This file is part of ILISP.
7 ;;; Please refer to the file COPYING for copyrights and licensing
8 ;;; information.
9 ;;; Please refer to the file ACKNOWLEGDEMENTS for an (incomplete) list
10 ;;; of present and past contributors.
11 ;;;
12 ;;; $Id: ilisp-prc.el,v 1.3 2001-07-02 09:40:48 youngs Exp $
13
14
15 (defun ilisp-process ()
16   "Return the current ILISP process."
17   (get-buffer-process (ilisp-buffer)))
18
19
20 (defvar ilisp-buffer-function 'ilisp-recent-buffer
21   "A function of no arguments which returns the current ilisp buffer")
22
23
24 ;;;%Buffer and process selection
25 (defun ilisp-buffer ()
26   "Return the current ILISP buffer.
27 This is the buffer to whose process requests are sent."
28   (if (memq major-mode ilisp-modes)
29       (current-buffer)
30     (let ((buffer (funcall ilisp-buffer-function)))
31       (or buffer
32           (error "You must start an inferior LISP with run-ilisp.")))))
33
34
35 (defun ilisp-recent-buffer ()
36   "Return the most-recently selected ilisp buffer." 
37   (if ilisp-buffer 
38       (or (get-buffer ilisp-buffer)
39           (get-buffer
40            (setq ilisp-buffers
41                  (delete* (substring ilisp-buffer
42                                      1 
43                                      (1- (length ilisp-buffer)))
44                           ilisp-buffers 
45                           :test (function (lambda (s1 s2)
46                                             (string= s1 (car s2)))))
47                  ilisp-buffer
48                  (format "*%s*" (car (car ilisp-buffers))))))))
49
50
51 ;;;
52 (defun select-ilisp ()
53   "Select the current ILISP buffer."
54   (interactive)
55   (let ((new (completing-read
56               (if ilisp-buffer
57                   (format "Buffer [%s]: "
58                           (substring ilisp-buffer 1
59                                      (1- (length ilisp-buffer))))
60                   "Buffer: ")
61               ilisp-buffers nil t)))
62     (if (not (zerop (length new)))
63         (setq ilisp-buffer (format "*%s*" new)))))
64
65 ;;; end of file -- ilisp-prc.el --