Update frames-on-display-list to accept terminal id numbers.
authorKaroly Lorentey <lorentey@elte.hu>
Mon, 7 Nov 2005 14:17:18 +0000 (14:17 +0000)
committerKaroly Lorentey <lorentey@elte.hu>
Mon, 7 Nov 2005 14:17:18 +0000 (14:17 +0000)
* lisp/frame.el (frames-on-display-list): Use terminal-id to get the
  display id.
  (terminal-id): Also accept X display strings and tty device names.

git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-436

README.multi-tty
lisp/frame.el

index 2bba1b9..ab43fc7 100644 (file)
@@ -424,9 +424,6 @@ THINGS TO DO
    instead of delete-frame-functions),
    after-delete-terminal-functions, after-create-terminal-functions.
 
-** If the first key pressed on a new tty terminal is a function key,
-   it is not recognized correctly.  May be related to the bug below.
-
 ** Fix set-input-mode for multi-tty.  It's a truly horrible interface;
    what if we'd blow it up into several separate functions (with a
    compatibility definition)?
@@ -472,20 +469,6 @@ THINGS TO DO
     frame-display                       terminal-of-frame
     delete-display                     delete-terminal
 
-** The semantics of terminal-local variables are confusing; it is not
-   clear what binding is in effect in any given time.  See if
-   current_kboard (or at least the terminal-local bindings exported to
-   Lisp) might be changed to be tied to the selected frame instead.
-   Currently, `function-key-map' and `key-translation-map' may be
-   accessed reliably only using the hackish
-   `(set-)terminal-local-value' functions.
-
-   Perhaps there should be a difference between `last-command' &co.
-   and these more conventional configuration variables.
-   (E.g. `symbol-value' would use current_kboard to access
-   `last-command', but SELECTED_FRAME()->display->kboard to get the
-   value of `function-key-map'.
-
 ** The single-keyboard mode of MULTI_KBOARD is extremely confusing
    sometimes; Emacs does not respond to stimuli from other keyboards.
    At least a beep or a message would be important, if the single-mode
@@ -1261,5 +1244,27 @@ DIARY OF CHANGES
 
    (Done in patch-431.)
 
+-- The semantics of terminal-local variables are confusing; it is not
+   clear what binding is in effect in any given time.  See if
+   current_kboard (or at least the terminal-local bindings exported to
+   Lisp) might be changed to be tied to the selected frame instead.
+   Currently, `function-key-map' and `key-translation-map' may be
+   accessed reliably only using the hackish
+   `(set-)terminal-local-value' functions.
+
+   Perhaps there should be a difference between `last-command' &co.
+   and these more conventional configuration variables.
+   (E.g. `symbol-value' would use current_kboard to access
+   `last-command', but SELECTED_FRAME()->display->kboard to get the
+   value of `function-key-map'.
+
+   (Fixed in patch-434.)
+
+-- If the first key pressed on a new tty terminal is a function key,
+   it is not recognized correctly.  May be related to the bug below.
+
+   (Seems to have been fixed as a side effect of patch-434.  "The bug
+   below" was the set-input-mode madness.)
+
 ;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d
 
index 8342d8e..fb49442 100644 (file)
@@ -696,17 +696,18 @@ setup is for focus to follow the pointer."
    (function (lambda (frame)
               (eq frame (window-frame (minibuffer-window frame)))))))
 
-(defun frames-on-display-list (&optional display)
-  "Return a list of all frames on DISPLAY.
+(defun frames-on-display-list (&optional terminal)
+  "Return a list of all frames on TERMINAL.
 
-DISPLAY should be a display identifier (an integer), but it may
-also be a name of a display, a string of the form HOST:SERVER.SCREEN.
+TERMINAL should be a terminal identifier (an integer), a frame,
+or a name of an X display (a string of the form
+HOST:SERVER.SCREEN).
 
-If DISPLAY is omitted or nil, it defaults to the selected frame's display."
-  (let* ((display (or display (frame-display)))
+If TERMINAL is omitted or nil, it defaults to the selected
+frame's terminal device."
+  (let* ((terminal (terminal-id terminal))
         (func #'(lambda (frame)
-                  (or (eq (frame-display frame) display)
-                      (equal (frame-parameter frame 'display) display)))))
+                  (eq (frame-display frame) terminal))))
     (filtered-frame-list func)))
 
 (defun framep-on-display (&optional display)
@@ -1430,13 +1431,23 @@ Use Custom to set this variable to get the display updated."
 (defun terminal-id (terminal)
   "Return the numerical id of terminal TERMINAL.
 
-TERMINAL can be a terminal id, a frame, or nil (meaning the
-selected frame's terminal)."
+TERMINAL can be a terminal id (an integer), a frame, or
+nil (meaning the selected frame's terminal).  Alternatively,
+TERMINAL may be the name of an X display
+device (HOST.SERVER.SCREEN) or a tty device file."
   (cond
    ((integerp terminal)
-    terminal)
+    (if (display-live-p terminal)
+       terminal
+      (signal 'wrong-type-argument (list 'display-live-p terminal))))
    ((or (null terminal) (framep terminal))
     (frame-display terminal))
+   ((stringp terminal)
+    (let ((f (car (filtered-frame-list (lambda (frame)
+                                        (or (equal (frame-parameter frame 'display) terminal)
+                                            (equal (frame-parameter frame 'tty) terminal)))))))
+      (or f (error "Display %s does not exist" terminal))
+      (frame-display f)))
    (t
     (error "Invalid argument %s in `terminal-id'" terminal))))