1 ;;; talk.el --- allow several users to talk to each other through Emacs
3 ;; Copyright (C) 1995, 2002, 2003, 2004, 2005,
4 ;; 2006 Free Software Foundation, Inc.
7 ;; Keywords: comm, frames
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
28 ;; This is a multi-user talk package that runs in Emacs.
29 ;; Use talk-connect to bring a new person into the conversation.
33 (defvar talk-display-alist nil
34 "Alist of displays on which Emacs talk is now running.
35 Each element has the form (DISPLAY FRAME BUFFER).")
38 (defun talk-connect (display)
39 "Connect to display DISPLAY for the Emacs talk group."
40 (interactive "sTalk to display: ")
41 ;; Make sure we have an entry for the current display.
42 (let ((mydisp (cdr (assq 'display
(frame-parameters (selected-frame))))))
43 (talk-add-display mydisp
))
44 ;; Make sure we have an entry for the specified display.
45 (talk-add-display display
)
46 ;; Add the new buffers to all talk frames.
47 (talk-update-buffers))
49 (defun talk-add-display (display)
50 (let* ((elt (assoc display talk-display-alist
))
51 (name (concat "*talk-" display
"*"))
53 (if (not (and elt
(frame-live-p (setq frame
(nth 1 elt
)))))
54 (setq frame
(make-frame-on-display display
(list (cons 'name name
)))))
55 (if (not (and elt
(buffer-name (get-buffer (setq buffer
(nth 2 elt
))))))
56 (setq buffer
(get-buffer-create name
)))
57 (setq talk-display-alist
58 (cons (list display frame buffer
) (delq elt talk-display-alist
)))))
60 (defun talk-disconnect ()
61 "Disconnect this display from the Emacs talk group."
63 (let* ((mydisp (cdr (assq 'display
(frame-parameters (selected-frame)))))
64 (elt (assoc mydisp talk-display-alist
)))
65 (delete-frame (nth 1 elt
))
66 (kill-buffer (nth 2 elt
))
67 (setq talk-display-alist
(delq elt talk-display-alist
))
68 (talk-update-buffers)))
70 (defun talk-update-buffers ()
71 "Update all the talk frames so that each shows all the talk buffers."
72 (let ((tail talk-display-alist
))
74 (let ((frame (nth 1 (car tail
)))
75 (this-buffer (nth 2 (car tail
)))
77 (mapcar (function (lambda (elt) (nth 2 elt
)))
79 ;; Put this display's own talk buffer
80 ;; at the front of the list.
81 (setq buffers
(cons this-buffer
(delq this-buffer buffers
)))
82 (talk-split-up-frame frame buffers
))
83 (setq tail
(cdr tail
)))))
85 (defun talk-split-up-frame (frame buffers
)
86 "Split FRAME into equal-sized windows displaying the buffers in BUFFERS.
87 Select the first of these windows, displaying the first of the buffers."
88 (let ((lines-per-buffer (/ (frame-height frame
) (length buffers
)))
89 (old-frame (selected-frame)))
93 (select-window (frame-first-window frame
))
94 (delete-other-windows)
96 (switch-to-buffer (car buffers
))
97 (setq buffers
(cdr buffers
)))
98 (split-window-vertically lines-per-buffer
)
100 (select-window (frame-first-window frame
)))
101 (select-frame old-frame
))))
105 ;;; arch-tag: 7ab0ad88-1788-4886-a44c-ae685e6f8a1a
106 ;;; talk.el ends here