Mercurial > emacs
annotate lisp/talk.el @ 83434:944e6b68a0de
Display "@" in mode-lines of Emacsclient frames.
* lisp/bindings.el (mode-line-client): New variable.
(help-echo): Add it to the default mode-line format.
* lisp/files.el (mode-line-client): Set it as risky.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-474
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Thu, 29 Dec 2005 21:11:27 +0000 |
parents | 76396de7f50a |
children | b98066f4aa10 |
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 |
64762
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64091
diff
changeset
|
3 ;; Copyright (C) 1995, 2002, 2003, 2004, 2005 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 |
64091 | 22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 ;; Boston, MA 02110-1301, 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) |
83167
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
52 (let ((type (frame-live-p (selected-frame))) |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83353
diff
changeset
|
53 (display (frame-terminal (selected-frame)))) |
83167
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
54 (cond |
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
55 ((eq type t) |
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
56 (talk-add-display (selected-frame))) |
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
57 ((eq type 'x) |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83353
diff
changeset
|
58 (talk-add-display (frame-terminal (selected-frame)))) |
83167
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
59 (t |
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
60 (error "Unknown frame type")))) |
82997
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
61 (talk-update-buffers)) |
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
62 |
83167
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
63 (defun talk-add-display (frame) |
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
64 (let* ((display (if (frame-live-p frame) |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83353
diff
changeset
|
65 (frame-terminal frame) |
83167
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
66 frame)) |
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
67 (elt (assoc display talk-display-alist)) |
83431
76396de7f50a
Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly.
Karoly Lorentey <lorentey@elte.hu>
parents:
83353
diff
changeset
|
68 (name (concat "*talk-" (terminal-name display) "*")) |
83167
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
69 buffer) |
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
70 (unless (frame-live-p frame) |
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
71 (setq frame (make-frame-on-display display (list (cons 'name name))))) |
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
72 (if (and elt (frame-live-p (nth 1 elt))) |
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
73 (setq frame (nth 1 elt))) |
12461
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
74 (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
|
75 (setq buffer (get-buffer-create name))) |
83167
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
76 (add-to-list 'delete-frame-functions 'talk-handle-delete-frame) |
12461
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
77 (setq talk-display-alist |
578abe49e2d3
(talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents:
11684
diff
changeset
|
78 (cons (list display frame buffer) (delq elt talk-display-alist))))) |
11684 | 79 |
83167
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
80 (defun talk-handle-delete-frame (frame) |
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
81 (dolist (d talk-display-alist) |
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
82 (when (eq (nth 1 d) frame) |
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
83 (setq talk-display-alist (delq d talk-display-alist)) |
69ebc75cb461
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82999
diff
changeset
|
84 (talk-update-buffers)))) |
82997
af2d6b850383
Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
85 |
11684 | 86 (defun talk-disconnect () |
87 "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
|
88 (interactive) |
11684 | 89 (let* ((mydisp (cdr (assq 'display (frame-parameters (selected-frame))))) |
90 (elt (assoc mydisp talk-display-alist))) | |
91 (delete-frame (nth 1 elt)) | |
92 (kill-buffer (nth 2 elt)) | |
93 (setq talk-display-alist (delq elt talk-display-alist)) | |
94 (talk-update-buffers))) | |
95 | |
96 (defun talk-update-buffers () | |
97 "Update all the talk frames so that each shows all the talk buffers." | |
98 (let ((tail talk-display-alist)) | |
99 (while tail | |
100 (let ((frame (nth 1 (car tail))) | |
101 (this-buffer (nth 2 (car tail))) | |
102 (buffers | |
103 (mapcar (function (lambda (elt) (nth 2 elt))) | |
104 talk-display-alist))) | |
105 ;; Put this display's own talk buffer | |
106 ;; at the front of the list. | |
107 (setq buffers (cons this-buffer (delq this-buffer buffers))) | |
108 (talk-split-up-frame frame buffers)) | |
109 (setq tail (cdr tail))))) | |
110 | |
111 (defun talk-split-up-frame (frame buffers) | |
112 "Split FRAME into equal-sized windows displaying the buffers in BUFFERS. | |
113 Select the first of these windows, displaying the first of the buffers." | |
114 (let ((lines-per-buffer (/ (frame-height frame) (length buffers))) | |
115 (old-frame (selected-frame))) | |
116 (unwind-protect | |
117 (progn | |
118 (select-frame frame) | |
119 (select-window (frame-first-window frame)) | |
120 (delete-other-windows) | |
121 (while (progn | |
122 (switch-to-buffer (car buffers)) | |
123 (setq buffers (cdr buffers))) | |
124 (split-window-vertically lines-per-buffer) | |
125 (other-window 1)) | |
126 (select-window (frame-first-window frame))) | |
127 (select-frame old-frame)))) | |
128 | |
18383 | 129 (provide 'talk) |
130 | |
52401 | 131 ;;; arch-tag: 7ab0ad88-1788-4886-a44c-ae685e6f8a1a |
11684 | 132 ;;; talk.el ends here |