X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/c07bb40b73856e3c40daf1dc6007ea13e3870912..56b3f3fe705e27cf2e15200f9ca8e8bbee5603e4:/lisp/talk.el diff --git a/lisp/talk.el b/lisp/talk.el index cb4043ee1a..a578675c26 100644 --- a/lisp/talk.el +++ b/lisp/talk.el @@ -1,7 +1,7 @@ ;;; talk.el --- allow several users to talk to each other through Emacs ;; Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005, -;; 2006, 2007 Free Software Foundation, Inc. +;; 2006, 2007, 2008 Free Software Foundation, Inc. ;; Maintainer: FSF ;; Keywords: comm, frames @@ -10,7 +10,7 @@ ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) +;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, @@ -46,17 +46,44 @@ Each element has the form (DISPLAY FRAME BUFFER).") ;; Add the new buffers to all talk frames. (talk-update-buffers)) -(defun talk-add-display (display) - (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))))) +;;;###autoload +(defun talk () + "Connect to the Emacs talk group from the current X display or tty frame." + (interactive) + (let ((type (frame-live-p (selected-frame))) + (display (frame-terminal (selected-frame)))) + (cond + ((eq type t) + (talk-add-display (selected-frame))) + ((eq type 'x) + (talk-add-display (frame-terminal (selected-frame)))) + (t + (error "Unknown frame type")))) + (talk-update-buffers)) + +(defun talk-add-display (frame) + (let* ((display (if (frame-live-p frame) + (frame-terminal frame) + frame)) + (elt (assoc display talk-display-alist)) + (name (concat "*talk-" (terminal-name display) "*")) + buffer) + (unless (frame-live-p frame) + (setq frame (make-frame-on-display display (list (cons 'name name))))) + (if (and elt (frame-live-p (nth 1 elt))) + (setq frame (nth 1 elt))) (if (not (and elt (buffer-name (get-buffer (setq buffer (nth 2 elt)))))) (setq buffer (get-buffer-create name))) + (add-to-list 'delete-frame-functions 'talk-handle-delete-frame) (setq talk-display-alist (cons (list display frame buffer) (delq elt talk-display-alist))))) +(defun talk-handle-delete-frame (frame) + (dolist (d talk-display-alist) + (when (eq (nth 1 d) frame) + (setq talk-display-alist (delq d talk-display-alist)) + (talk-update-buffers)))) + (defun talk-disconnect () "Disconnect this display from the Emacs talk group." (interactive)