]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix UTF-8 tty input when first frame is an X frame. Steps towards multiple tty local...
authorKaroly Lorentey <lorentey@elte.hu>
Tue, 3 May 2005 01:49:33 +0000 (01:49 +0000)
committerKaroly Lorentey <lorentey@elte.hu>
Tue, 3 May 2005 01:49:33 +0000 (01:49 +0000)
* lisp/international/mule-cmds.el (set-locale-environment): Ignore
  window-system; always set the keyboard coding system.

* src/termhooks.h (DISPLAY_TERMINAL_CODING, DISPLAY_KEYBOARD_CODING): New macros.

* src/coding.c (Fset_terminal_coding_system_internal, Fterminal_coding_system)
  (Fset_keyboard_coding_system_internal, Fkeyboard_coding_system): Add DISPLAY
  parameter.

* src/term.c (get_display): Add THROW parameter.
  (get_tty_display, Fdisplay_name, Fdisplay_tty_type, Fdisplay_controlling_tty_p)
  (Fdelete_display, Fdisplay_live_p): Update callers.
* src/xfns.c (check_x_display_info): Ditto.
* src/frame.c (Fmake_terminal_frame, Fframe_display): Ditto.

* src/dispextern.h (get_display): Update prototype.

* lisp/international/mule.el (set-terminal-coding-system)
  (set-keyboard-coding-system): Add DISPLAY parameter.

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

README.multi-tty
lisp/international/mule-cmds.el
lisp/international/mule.el
lisp/term/lk201.el
src/coding.c
src/dispextern.h
src/frame.c
src/term.c
src/termhooks.h
src/xfns.c

index e7602bda7cb6f8a50142974264e5336c6ae6b564..c5230c0ca54f75ec42b73e694cd1ab660fa8b3bd 100644 (file)
@@ -383,18 +383,19 @@ THINGS TO DO
    Update: selecting a region with the mouse enables single_kboard
    under X.  This is very confusing.
 
-   Update: After discussions with Richard, this will be resolved by
-   having locked displays warn the user to wait, and introducing a
-   complex protocol to remotely bail out of single-kboard mode by
-   pressing C-g.
+   Update: After discussions with Richard Stallman, this will be
+   resolved by having locked displays warn the user to wait, and
+   introducing a complex protocol to remotely bail out of
+   single-kboard mode by pressing C-g.
 
    Update: Warning the user is not trivial to implement, as Emacs has
-   only one echo area.  Ideally the warning should not be displayed on
-   the display that is locking the others.  Perhaps the high
-   probability of user confusion caused by single_kboard mode deserves
-   a special case in the display code.  Alternatively, it might be
-   good enough to signal single_kboard mode by changing the modelines
-   or some other frame-local display element on the locked out displays.
+   only one echo area, shared by all frames.  Ideally the warning
+   should not be displayed on the display that is locking the others.
+   Perhaps the high probability of user confusion caused by
+   single_kboard mode deserves a special case in the display code.
+   Alternatively, it might be good enough to signal single_kboard mode
+   by changing the modelines or some other frame-local display element
+   on the locked out displays.
 
 ** normal-erase-is-backspace-mode in simple.el needs to be updated for
    multi-tty (rep. by Dan Waber).
@@ -405,6 +406,22 @@ THINGS TO DO
 ** rif->flush_display_optional (NULL) calls should be replaced by a
    new global function.
 
+** Support multiple character locales.  
+
+       (1) A version of `set-locale-environment' needs to be written
+           for setting up display-local settings on ttys.  I think
+           calling set-display-table-and-terminal-coding-system and
+           set-keyboard-coding-system would be enough.  The language
+           environment itself should remain a global setting.
+
+       (2) Have a look at Vlocale_coding_system.  Seems like it would
+           be a tedious job to localize it, although most references
+           use it for interfacing with libc and are therefore OK with
+           the global definition.
+
+            Exceptions found so far: x-select-text and
+            x-cut-buffer-or-selection-value.
+
 ** Have a look at fatal_error_hook.
 
 ** Have a look at set_frame_matrix_frame.
@@ -429,7 +446,8 @@ THINGS TO DO
 
 ** The terminal customization files in term/*.el tend to change global
    parameters, which may confuse Emacs with multiple displays.  Change
-   them to tweak only frame-local settings, if possible.
+   them to tweak only frame-local settings, if possible.  (They tend
+   to call define-key to set function key sequences a lot.)
 
 ** Dan Nicolaescu suggests that -nw should be added as an alias for -t
    in emacsclient.  Good idea.  (Alas, implementing this is not
@@ -449,9 +467,6 @@ THINGS TO DO
    terminals in xterm and konsole.  The screen does flicker a bit,
    but it's so quick it isn't noticable.
 
-** Clean up the frame-local variable system.  I think it's ugly and
-   error-prone.  But maybe I just haven't yet fully understood it.
-
 ** Move baud_rate to struct display.
 
 ** Implement support for starting an interactive Emacs session without
@@ -963,7 +978,7 @@ DIARY OF CHANGES
 
    (Fixed.  Emacs now uses the locale settings as seen by the
    emacsclient process for server tty frames.)
-
+   (Update: Not really; Vlocale_coding_system is still global.)
 
 -- Make `struct display' accessible to Lisp programs.  Accessor functions:
 
@@ -1022,5 +1037,9 @@ DIARY OF CHANGES
 
    (Done.  This is the new default.  No complaints so far.)
 
+-- Clean up the frame-local variable system.  I think it's ugly and
+   error-prone.  But maybe I just haven't yet fully understood it.
+
+   (Nothing to do.  It doesn't seem ugly any more.  It's rather clever.)
 
 ;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d
index a91c12bcaf20d27baec1381c388d112744ac1778..8af768f91ccf3e87a35c63604aa1b03386aed98e 100644 (file)
@@ -2470,11 +2470,14 @@ See also `locale-charset-language-names', `locale-language-names',
          ;; Set the `keyboard-coding-system' if appropriate (tty
          ;; only).  At least X and MS Windows can generate
          ;; multilingual input.
-         (unless window-system
-           (let ((kcs (or coding-system
-                          (car (get-language-info language-name
-                                                  'coding-system)))))
-             (if kcs (set-keyboard-coding-system kcs))))
+         ;; XXX This was disabled unless `window-system', but that
+         ;; leads to buggy behaviour when a tty frame is opened
+         ;; later.  Setting the keyboard coding system has no adverse
+         ;; effect on X, so let's do it anyway. -- Lorentey
+         (let ((kcs (or coding-system
+                        (car (get-language-info language-name
+                                                'coding-system)))))
+           (if kcs (set-keyboard-coding-system kcs)))
 
          (setq locale-coding-system
                (car (get-language-info language-name 'coding-priority))))
index 49635652bb23b18300dd5253a7b71eefeb538341..d86ce458bf4226d822dd6a5cf4576f5d8c29e191 100644 (file)
@@ -1199,13 +1199,17 @@ see) to CODING-SYSTEM."
 This is normally set according to the selected language environment.
 See also the command `set-terminal-coding-system'.")
 
-(defun set-terminal-coding-system (coding-system)
-  "Set coding system of your terminal to CODING-SYSTEM.
-All text output to the terminal will be encoded
+(defun set-terminal-coding-system (coding-system &optional display)
+  "Set coding system of terminal output to CODING-SYSTEM.
+All text output to DISPLAY will be encoded
 with the specified coding system.
+
 For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems].
 The default is determined by the selected language environment
-or by the previous use of this command."
+or by the previous use of this command.
+
+DISPLAY may be a display id, a frame, or nil for the selected frame's display.
+The setting has no effect on graphical displays."
   (interactive
    (list (let ((default (if (and (not (terminal-coding-system))
                                 default-terminal-coding-system)
@@ -1219,7 +1223,7 @@ or by the previous use of this command."
       (setq coding-system default-terminal-coding-system))
   (if coding-system
       (setq default-terminal-coding-system coding-system))
-  (set-terminal-coding-system-internal coding-system)
+  (set-terminal-coding-system-internal coding-system display)
   (redraw-frame (selected-frame)))
 
 (defvar default-keyboard-coding-system nil
@@ -1227,14 +1231,18 @@ or by the previous use of this command."
 This is normally set according to the selected language environment.
 See also the command `set-keyboard-coding-system'.")
 
-(defun set-keyboard-coding-system (coding-system)
-  "Set coding system for keyboard input to CODING-SYSTEM.
+(defun set-keyboard-coding-system (coding-system &optional display)
+  "Set coding system for keyboard input on DISPLAY to CODING-SYSTEM.
 In addition, this command enables Encoded-kbd minor mode.
 \(If CODING-SYSTEM is nil, Encoded-kbd mode is turned off -- see
 `encoded-kbd-mode'.)
+
 For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems].
 The default is determined by the selected language environment
-or by the previous use of this command."
+or by the previous use of this command.
+
+DISPLAY may be a display id, a frame, or nil for the selected frame's display.
+The setting has no effect on graphical displays."
   (interactive
    (list (let ((default (if (and (not (keyboard-coding-system))
                                 default-keyboard-coding-system)
@@ -1248,7 +1256,7 @@ or by the previous use of this command."
       (setq coding-system default-keyboard-coding-system))
   (if coding-system
       (setq default-keyboard-coding-system coding-system))
-  (set-keyboard-coding-system-internal coding-system)
+  (set-keyboard-coding-system-internal coding-system display)
   (setq keyboard-coding-system coding-system)
   (encoded-kbd-mode (if coding-system 1 0)))
 
index 1f8d9ca77a34b5ecbcd78b59242257791763804f..b207e13b0a5af9d7ddbe93db60973bb13eecb333 100644 (file)
@@ -1,6 +1,8 @@
 ;; -*- no-byte-compile: t -*-
 ;; Define function key sequences for DEC terminals.
 
+;; XXX We need to find a way to have these define-keys be display-local. -- Lorentey
+
 ;; Termcap or terminfo should set these.
 ;; (define-key function-key-map "\e[A" [up])
 ;; (define-key function-key-map "\e[B" [down])
index b914574bbcab489486a0e785912be00bd0f3a0c1..f7da394def1d0eec95c18df7f3a92a89e3014856 100644 (file)
@@ -7305,12 +7305,13 @@ Return the corresponding character code in Big5.  */)
 }
 \f
 DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_internal,
-       Sset_terminal_coding_system_internal, 1, 1, 0,
+       Sset_terminal_coding_system_internal, 1, 2, 0,
        doc: /* Internal use only.  */)
-     (coding_system)
+     (coding_system, display)
      Lisp_Object coding_system;
+     Lisp_Object display;
 {
-  struct coding_system *terminal_coding = FRAME_TERMINAL_CODING (SELECTED_FRAME ());
+  struct coding_system *terminal_coding = DISPLAY_TERMINAL_CODING (get_display (display, 1));
   CHECK_SYMBOL (coding_system);
   setup_coding_system (Fcheck_coding_system (coding_system), terminal_coding);
   /* We had better not send unsafe characters to terminal.  */
@@ -7343,33 +7344,39 @@ DEFUN ("set-safe-terminal-coding-system-internal", Fset_safe_terminal_coding_sys
 }
 
 DEFUN ("terminal-coding-system", Fterminal_coding_system,
-       Sterminal_coding_system, 0, 0, 0,
-       doc: /* Return coding system specified for terminal output.  */)
-     ()
+       Sterminal_coding_system, 0, 1, 0,
+       doc: /* Return coding system specified for terminal output on the given display.
+DISPLAY may be a display id, a frame, or nil for the selected frame's display.  */)
+     (display)
+     Lisp_Object display;
 {
-  return FRAME_TERMINAL_CODING (SELECTED_FRAME ())->symbol;
+  return DISPLAY_TERMINAL_CODING (get_display (display, 1))->symbol;
 }
 
 DEFUN ("set-keyboard-coding-system-internal", Fset_keyboard_coding_system_internal,
-       Sset_keyboard_coding_system_internal, 1, 1, 0,
+       Sset_keyboard_coding_system_internal, 1, 2, 0,
        doc: /* Internal use only.  */)
-     (coding_system)
+     (coding_system, display)
      Lisp_Object coding_system;
+     Lisp_Object display;
 {
+  struct display *d = get_display (display, 1);
   CHECK_SYMBOL (coding_system);
+
   setup_coding_system (Fcheck_coding_system (coding_system),
-                       FRAME_KEYBOARD_CODING (SELECTED_FRAME ()));
+                       DISPLAY_KEYBOARD_CODING (d));
   /* Character composition should be disabled.  */
-  FRAME_KEYBOARD_CODING (SELECTED_FRAME ())->composing = COMPOSITION_DISABLED;
+  DISPLAY_KEYBOARD_CODING (d)->composing = COMPOSITION_DISABLED;
   return Qnil;
 }
 
 DEFUN ("keyboard-coding-system", Fkeyboard_coding_system,
-       Skeyboard_coding_system, 0, 0, 0,
+       Skeyboard_coding_system, 0, 1, 0,
        doc: /* Return coding system specified for decoding keyboard input.  */)
-     ()
+     (display)
+     Lisp_Object display;
 {
-  return FRAME_KEYBOARD_CODING (SELECTED_FRAME ())->symbol;
+  return DISPLAY_KEYBOARD_CODING (get_display (display, 1))->symbol;
 }
 
 \f
index abcda4fc731f57be085f1a2929cf1e7432118016..df6bbd00eec6e70110718af4b6805286686ab514 100644 (file)
@@ -2925,7 +2925,7 @@ extern int per_line_cost P_ ((char *));
 extern void calculate_costs P_ ((struct frame *));
 extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object));
 extern void tty_setup_colors P_ ((struct tty_display_info *, int));
-extern struct display *get_display P_ ((Lisp_Object display));
+extern struct display *get_display P_ ((Lisp_Object display, int));
 extern struct display *get_named_tty_display P_ ((char *));
 EXFUN (Fdisplay_tty_type, 1);
 extern struct display *init_initial_display P_ ((void));
index d0d4b3491e48e2b42e33a2601d6487b051b39c67..f86cb0d43dac9b6f7a96405440e3124475e2d6f2 100644 (file)
@@ -698,9 +698,7 @@ affects all frames on the same terminal device.  */)
       {
         display_device = XCDR (display_device);
         CHECK_NUMBER (display_device);
-        d = get_display (XINT (display_device));
-        if (!d)
-          wrong_type_argument (Qdisplay_live_p, display_device);
+        d = get_display (XINT (display_device), 1);
       }
   }
   
@@ -1073,7 +1071,7 @@ The display device is represented by its integer identifier.  */)
 
   CHECK_LIVE_FRAME (frame);
 
-  d = get_display (frame);
+  d = get_display (frame, 0);
 
   if (!d)
     return Qnil;
index bc30e3fb0d8ac347e9d26d3a6fa6f81b4acfb2ae..9c733a46abba4b2082f34e159aa250059979966a 100644 (file)
@@ -2105,17 +2105,17 @@ set_tty_color_mode (f, val)
 
 /* Return the display object specified by DISPLAY.  DISPLAY may be a
    display id, a frame, or nil for the display device of the current
-   frame. */
+   frame.  If THROW is zero, return NULL for failure, otherwise throw
+   an error.  */
 
 struct display *
-get_display (Lisp_Object display)
+get_display (Lisp_Object display, int throw)
 {
+  Lisp_Object result = NULL;
+
   if (NILP (display))
     display = selected_frame;
 
-  if (! INTEGERP (display) && ! FRAMEP (display))
-    return NULL;
-
   if (INTEGERP (display))
     {
       struct display *d;
@@ -2123,15 +2123,21 @@ get_display (Lisp_Object display)
       for (d = display_list; d; d = d->next_display)
         {
           if (d->id == XINT (display))
-            return d;
+            {
+              result = d;
+              break;
+            }
         }
-      return NULL;
     }
   else if (FRAMEP (display))
     {
-      return FRAME_DISPLAY (XFRAME (display));
+      result = FRAME_DISPLAY (XFRAME (display));
     }
-  return NULL;
+
+  if (result == NULL && throw)
+    wrong_type_argument (Qdisplay_live_p, display);
+
+  return result;
 }
 
 /* Return the tty display object specified by DISPLAY. */
@@ -2139,7 +2145,7 @@ get_display (Lisp_Object display)
 static struct display *
 get_tty_display (Lisp_Object display)
 {
-  struct display *d = get_display (display);
+  struct display *d = get_display (display, 0);
   
   if (d && d->type == output_initial)
     d = NULL;
@@ -2194,10 +2200,7 @@ frame's display). */)
   (display)
      Lisp_Object display;
 {
-  struct display *d = get_display (display);
-
-  if (!d)
-    wrong_type_argument (Qdisplay_live_p, display);
+  struct display *d = get_display (display, 1);
 
   if (d->name)
     return build_string (d->name);
@@ -2210,10 +2213,8 @@ DEFUN ("display-tty-type", Fdisplay_tty_type, Sdisplay_tty_type, 0, 1, 0,
   (display)
      Lisp_Object display;
 {
-  struct display *d = get_display (display);
+  struct display *d = get_display (display, 1);
 
-  if (!d)
-    wrong_type_argument (Qdisplay_live_p, display);
   if (d->type != output_termcap)
     error ("Display %d is not a termcap display", d->id);
            
@@ -2228,10 +2229,7 @@ DEFUN ("display-controlling-tty-p", Fdisplay_controlling_tty_p, Sdisplay_control
   (display)
      Lisp_Object display;
 {
-  struct display *d = get_display (display);
-
-  if (!d)
-    wrong_type_argument (Qdisplay_live_p, display);
+  struct display *d = get_display (display, 1);
 
   if (d->type != output_termcap || d->display_info.tty->name)
     return Qnil;
@@ -3157,7 +3155,7 @@ but if the second argument FORCE is non-nil, you may do so. */)
 {
   struct display *d, *p;
 
-  d = get_display (display);
+  d = get_display (display, 0);
 
   if (!d)
     return Qnil;
@@ -3193,7 +3191,7 @@ Displays are represented by their integer identifiers. */)
   if (!INTEGERP (object))
     return Qnil;
 
-  d = get_display (object);
+  d = get_display (object, 0);
 
   if (!d)
     return Qnil;
index d424ad75e4ae16e5343c87b67b580e74640fab43..788b57e9d1e97ad71de41d5c538e7bf02245304d 100644 (file)
@@ -550,6 +550,9 @@ extern struct display *display_list;
 #define FRAME_TERMINAL_CODING(f) ((f)->display->terminal_coding)
 #define FRAME_KEYBOARD_CODING(f) ((f)->display->keyboard_coding)
 
+#define DISPLAY_TERMINAL_CODING(d) ((d)->terminal_coding)
+#define DISPLAY_KEYBOARD_CODING(d) ((d)->keyboard_coding)
+
 #define FRAME_RIF(f) ((f)->display->rif)
 
 #define FRAME_DISPLAY(f) ((f)->display)
index 6a9ec8a6b47ca19acb3a8207db12013241323bac..666acfec773e996636eeea558fc13a5c007384fd 100644 (file)
@@ -263,10 +263,8 @@ check_x_display_info (frame)
     }
   else if (INTEGERP (frame))
     {
-      struct display *d = get_display (XINT (frame));
+      struct display *d = get_display (XINT (frame), 1);
 
-      if (!d)
-        wrong_type_argument (Qdisplay_live_p, frame);
       if (d->type != output_x_window)
         error ("Display %d is not an X display", XINT (frame));