Mercurial > emacs
annotate lisp/talk.el @ 83143:9fb10038ca55
Merged in changes from CVS trunk.
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-353
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-354
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-355
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-356
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-183
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Mon, 31 May 2004 13:48:26 +0000 |
parents | 6a6fb680d450 |
children | 69ebc75cb461 |
rev | line source |
---|---|
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
18383
diff
changeset
|
1 ;;; talk.el --- allow several users to talk to each other through Emacs |
11684 | 2 |
3 ;; Copyright (C) 1995 Free Software Foundation, Inc. | |
14169 | 4 |
45078 | 5 ;; Maintainer: FSF |
11684 | 6 ;; Keywords: comm, frames |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
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) | |
13 ;; any later version. | |
14 | |
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. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
14169 | 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. | |
11684 | 24 |
25 ;;; Commentary: | |
26 | |
14169 | 27 ;; This is a multi-user talk package that runs in Emacs. |
28 ;; Use talk-connect to bring a new person into the conversation. | |
11684 | 29 |
30 ;;; Code: | |
31 | |
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).") | |
35 | |
36 ;;;###autoload | |
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)) | |
47 | |
82997
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
48 ;;;###autoload |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
49 (defun talk () |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
50 "Connect to the Emacs talk group from the current X display or tty frame." |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
51 (interactive) |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
52 (let ((type (frame-live-p (selected-frame)))) |
82999
6a6fb680d450
Fixed typo in talk.el (again).
Karoly Lorentey <lorentey@elte.hu>
parents:
82998
diff
changeset
|
53 (if (eq type t) |
6a6fb680d450
Fixed typo in talk.el (again).
Karoly Lorentey <lorentey@elte.hu>
parents:
82998
diff
changeset
|
54 ;; Termcap frame |
6a6fb680d450
Fixed typo in talk.el (again).
Karoly Lorentey <lorentey@elte.hu>
parents:
82998
diff
changeset
|
55 (talk-add-tty-frame (selected-frame)) |
6a6fb680d450
Fixed typo in talk.el (again).
Karoly Lorentey <lorentey@elte.hu>
parents:
82998
diff
changeset
|
56 (if (eq type 'x) |
6a6fb680d450
Fixed typo in talk.el (again).
Karoly Lorentey <lorentey@elte.hu>
parents:
82998
diff
changeset
|
57 ;; X frame |
6a6fb680d450
Fixed typo in talk.el (again).
Karoly Lorentey <lorentey@elte.hu>
parents:
82998
diff
changeset
|
58 (talk-add-display (frame-parameter (selected-frame) 'display)) |
6a6fb680d450
Fixed typo in talk.el (again).
Karoly Lorentey <lorentey@elte.hu>
parents:
82998
diff
changeset
|
59 (error "Could not determine frame type")))) |
82997
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
60 (talk-update-buffers)) |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
61 |
11684 | 62 (defun talk-add-display (display) |
12461
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
63 (let* ((elt (assoc display talk-display-alist)) |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
64 (name (concat "*talk-" display "*")) |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
65 buffer frame) |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
66 (if (not (and elt (frame-live-p (setq frame (nth 1 elt))))) |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
67 (setq frame (make-frame-on-display display (list (cons 'name name))))) |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
68 (if (not (and elt (buffer-name (get-buffer (setq buffer (nth 2 elt)))))) |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
69 (setq buffer (get-buffer-create name))) |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
70 (setq talk-display-alist |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
71 (cons (list display frame buffer) (delq elt talk-display-alist))))) |
11684 | 72 |
82997
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
73 (defun talk-add-tty-frame (frame) |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
74 (let* ((elt (assoc (frame-tty-name frame) talk-display-alist)) |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
75 (name (concat "*talk-" (frame-tty-name frame) "*")) |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
76 buffer) |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
77 (if (not (and elt (buffer-name (get-buffer (setq buffer (nth 2 elt)))))) |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
78 (setq buffer (get-buffer-create name))) |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
79 (add-to-list 'delete-tty-after-functions 'talk-handle-delete-tty) |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
80 (setq talk-display-alist |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
81 (cons (list (frame-tty-name frame) frame buffer) (delq elt talk-display-alist))))) |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
82 |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
83 (defun talk-handle-delete-tty (tty) |
82998
24fb0f3a63a1
Fixed typo in talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
82997
diff
changeset
|
84 (let ((elt (assoc tty talk-display-alist))) |
82997
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
85 (setq talk-display-alist (delq elt talk-display-alist)) |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
86 (talk-update-buffers))) |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
87 |
11684 | 88 (defun talk-disconnect () |
89 "Disconnect this display from the Emacs talk group." | |
12461
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
90 (interactive) |
11684 | 91 (let* ((mydisp (cdr (assq 'display (frame-parameters (selected-frame))))) |
92 (elt (assoc mydisp talk-display-alist))) | |
93 (delete-frame (nth 1 elt)) | |
94 (kill-buffer (nth 2 elt)) | |
95 (setq talk-display-alist (delq elt talk-display-alist)) | |
96 (talk-update-buffers))) | |
97 | |
98 (defun talk-update-buffers () | |
99 "Update all the talk frames so that each shows all the talk buffers." | |
100 (let ((tail talk-display-alist)) | |
101 (while tail | |
102 (let ((frame (nth 1 (car tail))) | |
103 (this-buffer (nth 2 (car tail))) | |
104 (buffers | |
105 (mapcar (function (lambda (elt) (nth 2 elt))) | |
106 talk-display-alist))) | |
107 ;; Put this display's own talk buffer | |
108 ;; at the front of the list. | |
109 (setq buffers (cons this-buffer (delq this-buffer buffers))) | |
110 (talk-split-up-frame frame buffers)) | |
111 (setq tail (cdr tail))))) | |
112 | |
113 (defun talk-split-up-frame (frame buffers) | |
114 "Split FRAME into equal-sized windows displaying the buffers in BUFFERS. | |
115 Select the first of these windows, displaying the first of the buffers." | |
116 (let ((lines-per-buffer (/ (frame-height frame) (length buffers))) | |
117 (old-frame (selected-frame))) | |
118 (unwind-protect | |
119 (progn | |
120 (select-frame frame) | |
121 (select-window (frame-first-window frame)) | |
122 (delete-other-windows) | |
123 (while (progn | |
124 (switch-to-buffer (car buffers)) | |
125 (setq buffers (cdr buffers))) | |
126 (split-window-vertically lines-per-buffer) | |
127 (other-window 1)) | |
128 (select-window (frame-first-window frame))) | |
129 (select-frame old-frame)))) | |
130 | |
18383 | 131 (provide 'talk) |
132 | |
52401 | 133 ;;; arch-tag: 7ab0ad88-1788-4886-a44c-ae685e6f8a1a |
11684 | 134 ;;; talk.el ends here |