1 ;;; talk.el --- allow several users to talk to each other through Emacs
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
6 ;; Keywords: comm, frames
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; This is a multi-user talk package that runs in Emacs.
28 ;; Use talk-connect to bring a new person into the conversation.
32 (defvar talk-display-alist nil
33 "Alist of displays on which Emacs talk is now running.
34 Each element has the form (DISPLAY FRAME BUFFER).")
37 (defun talk-connect (display)
38 "Connect to display DISPLAY for the Emacs talk group."
39 (interactive "sTalk to display: ")
40 ;; Make sure we have an entry for the current display.
41 (let ((mydisp (cdr (assq 'display
(frame-parameters (selected-frame))))))
42 (talk-add-display mydisp
))
43 ;; Make sure we have an entry for the specified display.
44 (talk-add-display display
)
45 ;; Add the new buffers to all talk frames.
46 (talk-update-buffers))
48 (defun talk-add-display (display)
49 (let* ((elt (assoc display talk-display-alist
))
50 (name (concat "*talk-" display
"*"))
52 (if (not (and elt
(frame-live-p (setq frame
(nth 1 elt
)))))
53 (setq frame
(make-frame-on-display display
(list (cons 'name name
)))))
54 (if (not (and elt
(buffer-name (get-buffer (setq buffer
(nth 2 elt
))))))
55 (setq buffer
(get-buffer-create name
)))
56 (setq talk-display-alist
57 (cons (list display frame buffer
) (delq elt talk-display-alist
)))))
59 (defun talk-disconnect ()
60 "Disconnect this display from the Emacs talk group."
62 (let* ((mydisp (cdr (assq 'display
(frame-parameters (selected-frame)))))
63 (elt (assoc mydisp talk-display-alist
)))
64 (delete-frame (nth 1 elt
))
65 (kill-buffer (nth 2 elt
))
66 (setq talk-display-alist
(delq elt talk-display-alist
))
67 (talk-update-buffers)))
69 (defun talk-update-buffers ()
70 "Update all the talk frames so that each shows all the talk buffers."
71 (let ((tail talk-display-alist
))
73 (let ((frame (nth 1 (car tail
)))
74 (this-buffer (nth 2 (car tail
)))
76 (mapcar (function (lambda (elt) (nth 2 elt
)))
78 ;; Put this display's own talk buffer
79 ;; at the front of the list.
80 (setq buffers
(cons this-buffer
(delq this-buffer buffers
)))
81 (talk-split-up-frame frame buffers
))
82 (setq tail
(cdr tail
)))))
84 (defun talk-split-up-frame (frame buffers
)
85 "Split FRAME into equal-sized windows displaying the buffers in BUFFERS.
86 Select the first of these windows, displaying the first of the buffers."
87 (let ((lines-per-buffer (/ (frame-height frame
) (length buffers
)))
88 (old-frame (selected-frame)))
92 (select-window (frame-first-window frame
))
93 (delete-other-windows)
95 (switch-to-buffer (car buffers
))
96 (setq buffers
(cdr buffers
)))
97 (split-window-vertically lines-per-buffer
)
99 (select-window (frame-first-window frame
)))
100 (select-frame old-frame
))))
104 ;;; talk.el ends here