Mercurial > emacs
annotate lisp/talk.el @ 81870:d51d516c783f
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 14 Jul 2007 18:34:22 +0000 |
parents | e3694f1cb928 |
children | 9355f9b7bbff b8d9a391daf3 95d0cdf160ea |
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 |
74442 | 3 ;; Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005, |
75347 | 4 ;; 2006, 2007 Free Software Foundation, Inc. |
14169 | 5 |
45078 | 6 ;; Maintainer: FSF |
11684 | 7 ;; Keywords: comm, frames |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
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) | |
14 ;; any later version. | |
15 | |
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. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64091 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
11684 | 25 |
26 ;;; Commentary: | |
27 | |
14169 | 28 ;; This is a multi-user talk package that runs in Emacs. |
29 ;; Use talk-connect to bring a new person into the conversation. | |
11684 | 30 |
31 ;;; Code: | |
32 | |
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).") | |
36 | |
37 ;;;###autoload | |
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)) | |
48 | |
49 (defun talk-add-display (display) | |
12461
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
50 (let* ((elt (assoc display talk-display-alist)) |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
51 (name (concat "*talk-" display "*")) |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
52 buffer frame) |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
53 (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
|
54 (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
|
55 (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
|
56 (setq buffer (get-buffer-create name))) |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
57 (setq talk-display-alist |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
58 (cons (list display frame buffer) (delq elt talk-display-alist))))) |
11684 | 59 |
60 (defun talk-disconnect () | |
61 "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
|
62 (interactive) |
11684 | 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))) | |
69 | |
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)) | |
73 (while tail | |
74 (let ((frame (nth 1 (car tail))) | |
75 (this-buffer (nth 2 (car tail))) | |
76 (buffers | |
77 (mapcar (function (lambda (elt) (nth 2 elt))) | |
78 talk-display-alist))) | |
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))))) | |
84 | |
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))) | |
90 (unwind-protect | |
91 (progn | |
92 (select-frame frame) | |
93 (select-window (frame-first-window frame)) | |
94 (delete-other-windows) | |
95 (while (progn | |
96 (switch-to-buffer (car buffers)) | |
97 (setq buffers (cdr buffers))) | |
98 (split-window-vertically lines-per-buffer) | |
99 (other-window 1)) | |
100 (select-window (frame-first-window frame))) | |
101 (select-frame old-frame)))) | |
102 | |
18383 | 103 (provide 'talk) |
104 | |
52401 | 105 ;;; arch-tag: 7ab0ad88-1788-4886-a44c-ae685e6f8a1a |
11684 | 106 ;;; talk.el ends here |