Mercurial > emacs
annotate lisp/talk.el @ 13508:b64345cf1ee9
(HACK_EDITRES): Don't define if NO_EDITRES is defined.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 11 Nov 1995 07:13:56 +0000 |
parents | 578abe49e2d3 |
children | 83f275dcd93a |
rev | line source |
---|---|
11684 | 1 ;;; talk.el --- Allow several users to talk to each other through Emacs. |
2 | |
3 ;; Copyright (C) 1995 Free Software Foundation, Inc. | |
4 ;; Keywords: comm, frames | |
5 | |
6 ;; This file is part of GNU Emacs. | |
7 | |
8 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
9 ;; it under the terms of the GNU General Public License as published by | |
10 ;; the Free Software Foundation; either version 2, or (at your option) | |
11 ;; any later version. | |
12 | |
13 ;; GNU Emacs is distributed in the hope that it will be useful, | |
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 ;; GNU General Public License for more details. | |
17 | |
18 ;; You should have received a copy of the GNU General Public License | |
19 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
20 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
21 | |
22 ;;; Commentary: | |
23 | |
24 ;;; This is a multi-user talk package that runs in Emacs. | |
25 ;;; Use talk-connect to bring a new person into the conversation. | |
26 | |
27 ;;; Code: | |
28 | |
29 (defvar talk-display-alist nil | |
30 "Alist of displays on which Emacs talk is now running. | |
31 Each element has the form (DISPLAY FRAME BUFFER).") | |
32 | |
33 ;;;###autoload | |
34 (defun talk-connect (display) | |
35 "Connect to display DISPLAY for the Emacs talk group." | |
36 (interactive "sTalk to display: ") | |
37 ;; Make sure we have an entry for the current display. | |
38 (let ((mydisp (cdr (assq 'display (frame-parameters (selected-frame)))))) | |
39 (talk-add-display mydisp)) | |
40 ;; Make sure we have an entry for the specified display. | |
41 (talk-add-display display) | |
42 ;; Add the new buffers to all talk frames. | |
43 (talk-update-buffers)) | |
44 | |
45 (defun talk-add-display (display) | |
12461
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
46 (let* ((elt (assoc display talk-display-alist)) |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
47 (name (concat "*talk-" display "*")) |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
48 buffer frame) |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
49 (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
|
50 (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
|
51 (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
|
52 (setq buffer (get-buffer-create name))) |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
53 (setq talk-display-alist |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
54 (cons (list display frame buffer) (delq elt talk-display-alist))))) |
11684 | 55 |
56 (defun talk-disconnect () | |
57 "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
|
58 (interactive) |
11684 | 59 (let* ((mydisp (cdr (assq 'display (frame-parameters (selected-frame))))) |
60 (elt (assoc mydisp talk-display-alist))) | |
61 (delete-frame (nth 1 elt)) | |
62 (kill-buffer (nth 2 elt)) | |
63 (setq talk-display-alist (delq elt talk-display-alist)) | |
64 (talk-update-buffers))) | |
65 | |
66 (defun talk-update-buffers () | |
67 "Update all the talk frames so that each shows all the talk buffers." | |
68 (let ((tail talk-display-alist)) | |
69 (while tail | |
70 (let ((frame (nth 1 (car tail))) | |
71 (this-buffer (nth 2 (car tail))) | |
72 (buffers | |
73 (mapcar (function (lambda (elt) (nth 2 elt))) | |
74 talk-display-alist))) | |
75 ;; Put this display's own talk buffer | |
76 ;; at the front of the list. | |
77 (setq buffers (cons this-buffer (delq this-buffer buffers))) | |
78 (talk-split-up-frame frame buffers)) | |
79 (setq tail (cdr tail))))) | |
80 | |
81 (defun talk-split-up-frame (frame buffers) | |
82 "Split FRAME into equal-sized windows displaying the buffers in BUFFERS. | |
83 Select the first of these windows, displaying the first of the buffers." | |
84 (let ((lines-per-buffer (/ (frame-height frame) (length buffers))) | |
85 (old-frame (selected-frame))) | |
86 (unwind-protect | |
87 (progn | |
88 (select-frame frame) | |
89 (select-window (frame-first-window frame)) | |
90 (delete-other-windows) | |
91 (while (progn | |
92 (switch-to-buffer (car buffers)) | |
93 (setq buffers (cdr buffers))) | |
94 (split-window-vertically lines-per-buffer) | |
95 (other-window 1)) | |
96 (select-window (frame-first-window frame))) | |
97 (select-frame old-frame)))) | |
98 | |
99 ;;; talk.el ends here |