annotate lisp/talk.el @ 87697:e0467846347e

2008-01-10 Tassilo Horn <tassilo@member.fsf.org> * doc-view.el (doc-view-buffer-file-name): New variable. (doc-view-convert-current-doc, doc-view-search) (doc-view-current-cache-dir, doc-view-initiate-display) (doc-view-mode): Use it. (doc-view-bookmark-make-cell): Use variable buffer-file-name instead of function.
author Tassilo Horn <tassilo@member.fsf.org>
date Thu, 10 Jan 2008 15:08:10 +0000
parents 107ccd98fa12
children 606f2d163a64 1e3a407766b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
74442
b2e5081b9320 Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68651
diff changeset
3 ;; Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005,
79721
73661ddc7ac7 Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
4 ;; 2006, 2007, 2008 Free Software Foundation, Inc.
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12461
diff changeset
5
45078
829beb9a6a4b Follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 38414
diff changeset
6 ;; Maintainer: FSF
11684
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Keywords: comm, frames
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
78236
9355f9b7bbff Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 75347
diff changeset
13 ;; the Free Software Foundation; either version 3, or (at your option)
11684
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; any later version.
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12461
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
24 ;; Boston, MA 02110-1301, USA.
11684
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12461
diff changeset
28 ;; This is a multi-user talk package that runs in Emacs.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12461
diff changeset
29 ;; Use talk-connect to bring a new person into the conversation.
11684
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;;; Code:
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 (defvar talk-display-alist nil
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 "Alist of displays on which Emacs talk is now running.
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 Each element has the form (DISPLAY FRAME BUFFER).")
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;;;###autoload
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 (defun talk-connect (display)
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 "Connect to display DISPLAY for the Emacs talk group."
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 (interactive "sTalk to display: ")
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; Make sure we have an entry for the current display.
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 (let ((mydisp (cdr (assq 'display (frame-parameters (selected-frame))))))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 (talk-add-display mydisp))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; Make sure we have an entry for the specified display.
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 (talk-add-display display)
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; Add the new buffers to all talk frames.
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 (talk-update-buffers))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48
82997
af2d6b850383 Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents: 52401
diff changeset
49 ;;;###autoload
af2d6b850383 Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents: 52401
diff changeset
50 (defun talk ()
af2d6b850383 Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents: 52401
diff changeset
51 "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
52 (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
53 (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
54 (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
55 (cond
69ebc75cb461 Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents: 82999
diff changeset
56 ((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
57 (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
58 ((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
59 (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
60 (t
69ebc75cb461 Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents: 82999
diff changeset
61 (error "Unknown frame type"))))
82997
af2d6b850383 Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents: 52401
diff changeset
62 (talk-update-buffers))
af2d6b850383 Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents: 52401
diff changeset
63
83167
69ebc75cb461 Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents: 82999
diff changeset
64 (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
65 (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
66 (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
67 frame))
69ebc75cb461 Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents: 82999
diff changeset
68 (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
69 (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
70 buffer)
69ebc75cb461 Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents: 82999
diff changeset
71 (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
72 (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
73 (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
74 (setq frame (nth 1 elt)))
12461
578abe49e2d3 (talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents: 11684
diff changeset
75 (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
76 (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
77 (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
78 (setq talk-display-alist
578abe49e2d3 (talk-disconnect): Make it interactive.
Richard M. Stallman <rms@gnu.org>
parents: 11684
diff changeset
79 (cons (list display frame buffer) (delq elt talk-display-alist)))))
11684
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80
83167
69ebc75cb461 Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents: 82999
diff changeset
81 (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
82 (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
83 (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
84 (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
85 (talk-update-buffers))))
82997
af2d6b850383 Added multi-tty support for talk.el.
Karoly Lorentey <lorentey@elte.hu>
parents: 52401
diff changeset
86
11684
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (defun talk-disconnect ()
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 "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
89 (interactive)
11684
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (let* ((mydisp (cdr (assq 'display (frame-parameters (selected-frame)))))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (elt (assoc mydisp talk-display-alist)))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (delete-frame (nth 1 elt))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (kill-buffer (nth 2 elt))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (setq talk-display-alist (delq elt talk-display-alist))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (talk-update-buffers)))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (defun talk-update-buffers ()
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 "Update all the talk frames so that each shows all the talk buffers."
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (let ((tail talk-display-alist))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (while tail
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (let ((frame (nth 1 (car tail)))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (this-buffer (nth 2 (car tail)))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 (buffers
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (mapcar (function (lambda (elt) (nth 2 elt)))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 talk-display-alist)))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;; Put this display's own talk buffer
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ;; at the front of the list.
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (setq buffers (cons this-buffer (delq this-buffer buffers)))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (talk-split-up-frame frame buffers))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (setq tail (cdr tail)))))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 (defun talk-split-up-frame (frame buffers)
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 "Split FRAME into equal-sized windows displaying the buffers in BUFFERS.
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 Select the first of these windows, displaying the first of the buffers."
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (let ((lines-per-buffer (/ (frame-height frame) (length buffers)))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 (old-frame (selected-frame)))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 (unwind-protect
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (progn
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (select-frame frame)
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (select-window (frame-first-window frame))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (delete-other-windows)
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (while (progn
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (switch-to-buffer (car buffers))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (setq buffers (cdr buffers)))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (split-window-vertically lines-per-buffer)
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (other-window 1))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (select-window (frame-first-window frame)))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (select-frame old-frame))))
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
18383
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
130 (provide 'talk)
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
131
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 45078
diff changeset
132 ;;; arch-tag: 7ab0ad88-1788-4886-a44c-ae685e6f8a1a
11684
b59ad1e42981 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 ;;; talk.el ends here