2021-03-24 08:05:06 +00:00
|
|
|
;;; talk.el --- allow several users to talk to each other through Emacs -*- lexical-binding: t -*-
|
1995-05-04 17:24:40 +00:00
|
|
|
|
2024-01-02 01:47:10 +00:00
|
|
|
;; Copyright (C) 1995, 2001-2024 Free Software Foundation, Inc.
|
1996-01-14 07:34:30 +00:00
|
|
|
|
2019-05-25 20:43:06 +00:00
|
|
|
;; Maintainer: emacs-devel@gnu.org
|
1995-05-04 17:24:40 +00:00
|
|
|
;; Keywords: comm, frames
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1995-05-04 17:24:40 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
1995-05-04 17:24:40 +00:00
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1995-05-04 17:24:40 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
;; This is a multi-user talk package that runs in Emacs.
|
2021-03-24 08:05:06 +00:00
|
|
|
;; Use `talk-connect' to bring a new person into the conversation.
|
1995-05-04 17:24:40 +00:00
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(defvar talk-display-alist nil
|
|
|
|
"Alist of displays on which Emacs talk is now running.
|
|
|
|
Each element has the form (DISPLAY FRAME BUFFER).")
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun talk-connect (display)
|
|
|
|
"Connect to display DISPLAY for the Emacs talk group."
|
|
|
|
(interactive "sTalk to display: ")
|
|
|
|
;; Make sure we have an entry for the current display.
|
|
|
|
(let ((mydisp (cdr (assq 'display (frame-parameters (selected-frame))))))
|
|
|
|
(talk-add-display mydisp))
|
|
|
|
;; Make sure we have an entry for the specified display.
|
|
|
|
(talk-add-display display)
|
|
|
|
;; Add the new buffers to all talk frames.
|
|
|
|
(talk-update-buffers))
|
|
|
|
|
2004-01-03 09:08:15 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun talk ()
|
|
|
|
"Connect to the Emacs talk group from the current X display or tty frame."
|
|
|
|
(interactive)
|
2011-04-19 13:44:55 +00:00
|
|
|
(let ((type (frame-live-p (selected-frame))))
|
2008-05-13 20:50:32 +00:00
|
|
|
(if (or (eq type t) (eq type 'x))
|
2011-04-19 13:44:55 +00:00
|
|
|
(talk-add-display
|
2013-08-05 10:35:55 +00:00
|
|
|
(terminal-name (frame-terminal)))
|
2008-05-13 20:50:32 +00:00
|
|
|
(error "Unknown frame type")))
|
2004-01-03 09:08:15 +00:00
|
|
|
(talk-update-buffers))
|
|
|
|
|
2008-05-13 20:50:32 +00:00
|
|
|
(defun talk-add-display (display)
|
|
|
|
(let* ((elt (assoc display talk-display-alist))
|
|
|
|
(name (concat "*talk-" display "*"))
|
|
|
|
frame buffer)
|
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
* lisp/frame.el (make-frame-on-display): Update doc.
(make-frame): Handle display-id parameter. Update doc.
(frames-on-display-list): Update for display ids.
(framep-on-display): Ditto.
(suspend-frame): Use display-name, not frame-tty-name.
(selected-display): New function.
* lisp/server.el (server-delete-client): Use delete-display, not delete-tty.
(server-tty-live-p, server-handle-delete-tty): Removed.
(server-handle-delete-frame): Delete tty clients, if needed.
(server-process-filter): Set the display parameter, and use it when appropriate.
(server-handle-suspend-tty): Use the display parameter.
(server-start, server-unload-hook): Removed obsolete delete-tty hook.
* lisp/talk.el (talk): Always use talk-add-display.
(talk-add-tty-frame, talk-handle-delete-tty): Removed.
(talk-handle-delete-frame): New function.
(talk-add-display): Open a new frame only if parameter was not a frame.
* src/dispextern.h (get_display, Fdisplay_tty_type): New prototypes.
(Fframe_tty_type): Removed.
* src/dispnew.c (init_display): Use Fdisplay_tty_type, not Fframe_tty_type.
* src/frame.c (Qdisplay_id, Qdisplay_live_p): New symbols.
(make_terminal_frame): Get display as a parameter.
(Fmake_terminal_frame): Get/create display here; pass it to
make_terminal_frame.
(Fframe_display): New function.
(Fdelete_frame): Stop if the hook deleted the frame.
(syms_of_frame): Register new stuff.
* src/frame.h (Qdisplay_id, Qdisplay_live_p, make_terminal_frame):
Updated prototypes.
* src/keyboard.c (interrupt_signal): Updated comment.
* src/term.c (Vdelete_tty_after_functions): Removed variable.
(Qframe_tty_name, Qframe_tty_type): Removed.
(next_display_id): New var.
(tty_ring_bell): Don't do anything on suspended frames.
(Ftty_display_color_p, Ftty_display_color_cells): Doc update.
(get_display): New function.
(get_tty_display): Use it.
(get_named_tty_display): Ignore suspended displays.
(Fframe_tty_name): Renamed to Fdisplay_name. Handle all kinds of
displays.
(Fframe_tty_type): Renamed to Fdisplay_tty_type.
(init_initial_display): Set display name.
(term_init): Allow more displays on the same device. Set display name.
(Fdelete_tty): Removed.
(delete_tty): Don't run hooks.
(create_display): Set display id.
(delete_display): Free display name.
(Fdelete_display, Fdisplay_live_p, Fdisplay_list): New functions.
(Fsuspend_tty): Call hook with display id. Doc update.
(Fresume_tty): Refuse to resume when there is already an active display
on the same device. Call hook with display id. Doc update.
(syms_of_term): Reflect above changes.
* src/termhooks.h (struct display): Added `id' and `name' members.
(DISPLAY_ACTIVE_P): New macro.
* src/xfns.c (check_x_display_info): Handle display ids.
(Fx_create_frame): Try to get display from `display-id' parameter.
* src/xterm.c (x_term_init): Set display name.
(x_delete_display): Handle the case when `font_table' is NULL.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-207
2004-07-04 04:48:55 +00:00
|
|
|
(if (and elt (frame-live-p (nth 1 elt)))
|
2008-05-13 20:50:32 +00:00
|
|
|
(setq frame (nth 1 elt))
|
|
|
|
(setq frame (make-frame-on-display display (list (cons 'name name)))))
|
2004-01-03 09:08:15 +00:00
|
|
|
(if (not (and elt (buffer-name (get-buffer (setq buffer (nth 2 elt))))))
|
|
|
|
(setq buffer (get-buffer-create name)))
|
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
* lisp/frame.el (make-frame-on-display): Update doc.
(make-frame): Handle display-id parameter. Update doc.
(frames-on-display-list): Update for display ids.
(framep-on-display): Ditto.
(suspend-frame): Use display-name, not frame-tty-name.
(selected-display): New function.
* lisp/server.el (server-delete-client): Use delete-display, not delete-tty.
(server-tty-live-p, server-handle-delete-tty): Removed.
(server-handle-delete-frame): Delete tty clients, if needed.
(server-process-filter): Set the display parameter, and use it when appropriate.
(server-handle-suspend-tty): Use the display parameter.
(server-start, server-unload-hook): Removed obsolete delete-tty hook.
* lisp/talk.el (talk): Always use talk-add-display.
(talk-add-tty-frame, talk-handle-delete-tty): Removed.
(talk-handle-delete-frame): New function.
(talk-add-display): Open a new frame only if parameter was not a frame.
* src/dispextern.h (get_display, Fdisplay_tty_type): New prototypes.
(Fframe_tty_type): Removed.
* src/dispnew.c (init_display): Use Fdisplay_tty_type, not Fframe_tty_type.
* src/frame.c (Qdisplay_id, Qdisplay_live_p): New symbols.
(make_terminal_frame): Get display as a parameter.
(Fmake_terminal_frame): Get/create display here; pass it to
make_terminal_frame.
(Fframe_display): New function.
(Fdelete_frame): Stop if the hook deleted the frame.
(syms_of_frame): Register new stuff.
* src/frame.h (Qdisplay_id, Qdisplay_live_p, make_terminal_frame):
Updated prototypes.
* src/keyboard.c (interrupt_signal): Updated comment.
* src/term.c (Vdelete_tty_after_functions): Removed variable.
(Qframe_tty_name, Qframe_tty_type): Removed.
(next_display_id): New var.
(tty_ring_bell): Don't do anything on suspended frames.
(Ftty_display_color_p, Ftty_display_color_cells): Doc update.
(get_display): New function.
(get_tty_display): Use it.
(get_named_tty_display): Ignore suspended displays.
(Fframe_tty_name): Renamed to Fdisplay_name. Handle all kinds of
displays.
(Fframe_tty_type): Renamed to Fdisplay_tty_type.
(init_initial_display): Set display name.
(term_init): Allow more displays on the same device. Set display name.
(Fdelete_tty): Removed.
(delete_tty): Don't run hooks.
(create_display): Set display id.
(delete_display): Free display name.
(Fdelete_display, Fdisplay_live_p, Fdisplay_list): New functions.
(Fsuspend_tty): Call hook with display id. Doc update.
(Fresume_tty): Refuse to resume when there is already an active display
on the same device. Call hook with display id. Doc update.
(syms_of_term): Reflect above changes.
* src/termhooks.h (struct display): Added `id' and `name' members.
(DISPLAY_ACTIVE_P): New macro.
* src/xfns.c (check_x_display_info): Handle display ids.
(Fx_create_frame): Try to get display from `display-id' parameter.
* src/xterm.c (x_term_init): Set display name.
(x_delete_display): Handle the case when `font_table' is NULL.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-207
2004-07-04 04:48:55 +00:00
|
|
|
(add-to-list 'delete-frame-functions 'talk-handle-delete-frame)
|
2004-01-03 09:08:15 +00:00
|
|
|
(setq talk-display-alist
|
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
* lisp/frame.el (make-frame-on-display): Update doc.
(make-frame): Handle display-id parameter. Update doc.
(frames-on-display-list): Update for display ids.
(framep-on-display): Ditto.
(suspend-frame): Use display-name, not frame-tty-name.
(selected-display): New function.
* lisp/server.el (server-delete-client): Use delete-display, not delete-tty.
(server-tty-live-p, server-handle-delete-tty): Removed.
(server-handle-delete-frame): Delete tty clients, if needed.
(server-process-filter): Set the display parameter, and use it when appropriate.
(server-handle-suspend-tty): Use the display parameter.
(server-start, server-unload-hook): Removed obsolete delete-tty hook.
* lisp/talk.el (talk): Always use talk-add-display.
(talk-add-tty-frame, talk-handle-delete-tty): Removed.
(talk-handle-delete-frame): New function.
(talk-add-display): Open a new frame only if parameter was not a frame.
* src/dispextern.h (get_display, Fdisplay_tty_type): New prototypes.
(Fframe_tty_type): Removed.
* src/dispnew.c (init_display): Use Fdisplay_tty_type, not Fframe_tty_type.
* src/frame.c (Qdisplay_id, Qdisplay_live_p): New symbols.
(make_terminal_frame): Get display as a parameter.
(Fmake_terminal_frame): Get/create display here; pass it to
make_terminal_frame.
(Fframe_display): New function.
(Fdelete_frame): Stop if the hook deleted the frame.
(syms_of_frame): Register new stuff.
* src/frame.h (Qdisplay_id, Qdisplay_live_p, make_terminal_frame):
Updated prototypes.
* src/keyboard.c (interrupt_signal): Updated comment.
* src/term.c (Vdelete_tty_after_functions): Removed variable.
(Qframe_tty_name, Qframe_tty_type): Removed.
(next_display_id): New var.
(tty_ring_bell): Don't do anything on suspended frames.
(Ftty_display_color_p, Ftty_display_color_cells): Doc update.
(get_display): New function.
(get_tty_display): Use it.
(get_named_tty_display): Ignore suspended displays.
(Fframe_tty_name): Renamed to Fdisplay_name. Handle all kinds of
displays.
(Fframe_tty_type): Renamed to Fdisplay_tty_type.
(init_initial_display): Set display name.
(term_init): Allow more displays on the same device. Set display name.
(Fdelete_tty): Removed.
(delete_tty): Don't run hooks.
(create_display): Set display id.
(delete_display): Free display name.
(Fdelete_display, Fdisplay_live_p, Fdisplay_list): New functions.
(Fsuspend_tty): Call hook with display id. Doc update.
(Fresume_tty): Refuse to resume when there is already an active display
on the same device. Call hook with display id. Doc update.
(syms_of_term): Reflect above changes.
* src/termhooks.h (struct display): Added `id' and `name' members.
(DISPLAY_ACTIVE_P): New macro.
* src/xfns.c (check_x_display_info): Handle display ids.
(Fx_create_frame): Try to get display from `display-id' parameter.
* src/xterm.c (x_term_init): Set display name.
(x_delete_display): Handle the case when `font_table' is NULL.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-207
2004-07-04 04:48:55 +00:00
|
|
|
(cons (list display frame buffer) (delq elt talk-display-alist)))))
|
2004-01-03 09:08:15 +00:00
|
|
|
|
Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes.
* lisp/frame.el (make-frame-on-display): Update doc.
(make-frame): Handle display-id parameter. Update doc.
(frames-on-display-list): Update for display ids.
(framep-on-display): Ditto.
(suspend-frame): Use display-name, not frame-tty-name.
(selected-display): New function.
* lisp/server.el (server-delete-client): Use delete-display, not delete-tty.
(server-tty-live-p, server-handle-delete-tty): Removed.
(server-handle-delete-frame): Delete tty clients, if needed.
(server-process-filter): Set the display parameter, and use it when appropriate.
(server-handle-suspend-tty): Use the display parameter.
(server-start, server-unload-hook): Removed obsolete delete-tty hook.
* lisp/talk.el (talk): Always use talk-add-display.
(talk-add-tty-frame, talk-handle-delete-tty): Removed.
(talk-handle-delete-frame): New function.
(talk-add-display): Open a new frame only if parameter was not a frame.
* src/dispextern.h (get_display, Fdisplay_tty_type): New prototypes.
(Fframe_tty_type): Removed.
* src/dispnew.c (init_display): Use Fdisplay_tty_type, not Fframe_tty_type.
* src/frame.c (Qdisplay_id, Qdisplay_live_p): New symbols.
(make_terminal_frame): Get display as a parameter.
(Fmake_terminal_frame): Get/create display here; pass it to
make_terminal_frame.
(Fframe_display): New function.
(Fdelete_frame): Stop if the hook deleted the frame.
(syms_of_frame): Register new stuff.
* src/frame.h (Qdisplay_id, Qdisplay_live_p, make_terminal_frame):
Updated prototypes.
* src/keyboard.c (interrupt_signal): Updated comment.
* src/term.c (Vdelete_tty_after_functions): Removed variable.
(Qframe_tty_name, Qframe_tty_type): Removed.
(next_display_id): New var.
(tty_ring_bell): Don't do anything on suspended frames.
(Ftty_display_color_p, Ftty_display_color_cells): Doc update.
(get_display): New function.
(get_tty_display): Use it.
(get_named_tty_display): Ignore suspended displays.
(Fframe_tty_name): Renamed to Fdisplay_name. Handle all kinds of
displays.
(Fframe_tty_type): Renamed to Fdisplay_tty_type.
(init_initial_display): Set display name.
(term_init): Allow more displays on the same device. Set display name.
(Fdelete_tty): Removed.
(delete_tty): Don't run hooks.
(create_display): Set display id.
(delete_display): Free display name.
(Fdelete_display, Fdisplay_live_p, Fdisplay_list): New functions.
(Fsuspend_tty): Call hook with display id. Doc update.
(Fresume_tty): Refuse to resume when there is already an active display
on the same device. Call hook with display id. Doc update.
(syms_of_term): Reflect above changes.
* src/termhooks.h (struct display): Added `id' and `name' members.
(DISPLAY_ACTIVE_P): New macro.
* src/xfns.c (check_x_display_info): Handle display ids.
(Fx_create_frame): Try to get display from `display-id' parameter.
* src/xterm.c (x_term_init): Set display name.
(x_delete_display): Handle the case when `font_table' is NULL.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-207
2004-07-04 04:48:55 +00:00
|
|
|
(defun talk-handle-delete-frame (frame)
|
|
|
|
(dolist (d talk-display-alist)
|
|
|
|
(when (eq (nth 1 d) frame)
|
|
|
|
(setq talk-display-alist (delq d talk-display-alist))
|
|
|
|
(talk-update-buffers))))
|
2004-01-03 09:08:15 +00:00
|
|
|
|
1995-05-04 17:24:40 +00:00
|
|
|
(defun talk-disconnect ()
|
|
|
|
"Disconnect this display from the Emacs talk group."
|
1995-07-01 19:40:13 +00:00
|
|
|
(interactive)
|
1995-05-04 17:24:40 +00:00
|
|
|
(let* ((mydisp (cdr (assq 'display (frame-parameters (selected-frame)))))
|
|
|
|
(elt (assoc mydisp talk-display-alist)))
|
|
|
|
(delete-frame (nth 1 elt))
|
|
|
|
(kill-buffer (nth 2 elt))
|
|
|
|
(setq talk-display-alist (delq elt talk-display-alist))
|
|
|
|
(talk-update-buffers)))
|
|
|
|
|
|
|
|
(defun talk-update-buffers ()
|
|
|
|
"Update all the talk frames so that each shows all the talk buffers."
|
|
|
|
(let ((tail talk-display-alist))
|
|
|
|
(while tail
|
|
|
|
(let ((frame (nth 1 (car tail)))
|
|
|
|
(this-buffer (nth 2 (car tail)))
|
|
|
|
(buffers
|
2020-09-30 14:18:50 +00:00
|
|
|
(mapcar (lambda (elt) (nth 2 elt))
|
1995-05-04 17:24:40 +00:00
|
|
|
talk-display-alist)))
|
|
|
|
;; Put this display's own talk buffer
|
|
|
|
;; at the front of the list.
|
|
|
|
(setq buffers (cons this-buffer (delq this-buffer buffers)))
|
|
|
|
(talk-split-up-frame frame buffers))
|
|
|
|
(setq tail (cdr tail)))))
|
|
|
|
|
|
|
|
(defun talk-split-up-frame (frame buffers)
|
|
|
|
"Split FRAME into equal-sized windows displaying the buffers in BUFFERS.
|
|
|
|
Select the first of these windows, displaying the first of the buffers."
|
|
|
|
(let ((lines-per-buffer (/ (frame-height frame) (length buffers)))
|
|
|
|
(old-frame (selected-frame)))
|
|
|
|
(unwind-protect
|
|
|
|
(progn
|
|
|
|
(select-frame frame)
|
|
|
|
(select-window (frame-first-window frame))
|
|
|
|
(delete-other-windows)
|
|
|
|
(while (progn
|
|
|
|
(switch-to-buffer (car buffers))
|
|
|
|
(setq buffers (cdr buffers)))
|
2011-10-30 01:56:03 +00:00
|
|
|
(split-window-below lines-per-buffer)
|
1995-05-04 17:24:40 +00:00
|
|
|
(other-window 1))
|
|
|
|
(select-window (frame-first-window frame)))
|
|
|
|
(select-frame old-frame))))
|
|
|
|
|
1997-06-22 18:57:55 +00:00
|
|
|
(provide 'talk)
|
|
|
|
|
1995-05-04 17:24:40 +00:00
|
|
|
;;; talk.el ends here
|