(replace_buffer_in_all_windows):
[bpt/emacs.git] / lisp / talk.el
index a4d3d1c..a159b93 100644 (file)
@@ -1,6 +1,7 @@
 ;;; talk.el --- Allow several users to talk to each other through Emacs.
 
 ;; Copyright (C) 1995 Free Software Foundation, Inc.
+
 ;; Keywords: comm, frames
 
 ;; This file is part of GNU Emacs.
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
-;;; This is a multi-user talk package that runs in Emacs.
-;;; Use talk-connect to bring a new person into the conversation.
+;; This is a multi-user talk package that runs in Emacs.
+;; Use talk-connect to bring a new person into the conversation.
 
 ;;; Code:
 
@@ -43,17 +45,19 @@ Each element has the form (DISPLAY FRAME BUFFER).")
   (talk-update-buffers))
 
 (defun talk-add-display (display)
-  (or (assoc display talk-display-alist)
-      (let* ((name (concat "*talk-" display "*"))
-            (buffer (get-buffer-create name))
-            (frame (make-frame-on-display display
-                                          (list (cons 'name name)))))
-       (setq talk-display-alist
-             (cons (list display frame buffer)
-                   talk-display-alist)))))
+  (let* ((elt (assoc display talk-display-alist))
+        (name (concat "*talk-" display "*"))
+        buffer frame)
+    (if (not (and elt (frame-live-p (setq frame (nth 1 elt)))))
+       (setq frame (make-frame-on-display display (list (cons 'name name)))))
+    (if (not (and elt (buffer-name (get-buffer (setq buffer (nth 2 elt))))))
+       (setq buffer (get-buffer-create name)))
+    (setq talk-display-alist
+         (cons (list display frame buffer) (delq elt talk-display-alist)))))
 
 (defun talk-disconnect ()
   "Disconnect this display from the Emacs talk group."
+  (interactive)
   (let* ((mydisp (cdr (assq 'display (frame-parameters (selected-frame)))))
         (elt (assoc mydisp talk-display-alist)))
     (delete-frame (nth 1 elt))
@@ -94,4 +98,6 @@ Select the first of these windows, displaying the first of the buffers."
          (select-window (frame-first-window frame)))
       (select-frame old-frame))))
 
+(provide 'talk)
+
 ;;; talk.el ends here