bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: read-key-sequence displays umlauts incorrectly (fwd)


From: Kenichi Handa
Subject: Re: read-key-sequence displays umlauts incorrectly (fwd)
Date: Thu, 14 Dec 2000 19:49:50 +0900 (JST)

> ---------- Forwarded message ----------
> Date: Wed, 13 Dec 2000 02:29:48 +0100 (MET)
> From: Ulrich Neumerkel <ulrich@a0.complang.tuwien.ac.at>
> To: bug-gnu-emacs@gnu.org
> Subject: read-key-sequence displays umlauts incorrectly
[...]
> The following commands should behave identically, but the second does
> not seem to handle multibytes correctly.  In place of "rôle" one sees
> "r\201ôle" instead. This happens only if you byte-compile (with no
> matter what options) and load f2.  Be it interactively via the menu or
> in batch mode.  If you just C-x C-e the defun or do compile-defun
> (which is defined in bytecomp) the text is correctly rendered by f2...

> (defun f1 ()
>   (interactive)
>   (message "%s" "f1: The rôle of accents")
>   (read-key-sequence nil))

> (defun f2 ()
>   (interactive)
>   (read-key-sequence "f2: The rôle of accents"))

Thank you for the bug report.  It seems that you run Emacs
with --unibyte.   Otherwise, I can't reproduce this bug.

Anyway, the reason why it fails in unibyte mode is that
byte-compiler produces multibyte prompt string in the above
case, whereas read_key_sequence can't send the information of
the multibyteness of prompt string to message2_nolog.

I've just installed the attached change.  I tried to store a
string in echobuf always in multibyte form and ask
message2_nolog to do the right thing for unibyte and
multibyte mode.

But, as this is the first time for me to read this part of
codes, I'm not that confident.  Could someone please
doubl-check the new code?

---
Ken'ichi HANDA
handa@etl.go.jp

2000-12-14  Kenichi Handa  <handa@etl.go.jp>

        * keyboard.c (echo_prompt): Argument type changed to Lisp_Object.
        Always store string in multibyte representation in echobuf.
        (echo_char): Always store string in multibyte representation in
        echobuf.
        (echo_now): Call message2_nolog with the arg MULTIBYTE 1.
        (read_key_sequence): Adjusted for the change of echo_prompt.

Index: keyboard.c
===================================================================
RCS file: /cvs/emacs/src/keyboard.c,v
retrieving revision 1.590
retrieving revision 1.591
diff -c -c -r1.590 -r1.591
*** keyboard.c  2000/12/13 14:25:49     1.590
--- keyboard.c  2000/12/14 10:44:56     1.591
***************
*** 690,703 ****
  
  void
  echo_prompt (str)
!      char *str;
  {
!   int len = strlen (str);
  
    if (len > ECHOBUFSIZE - 4)
!     len = ECHOBUFSIZE - 4;
!   bcopy (str, current_kboard->echobuf, len);
!   current_kboard->echoptr = current_kboard->echobuf + len;
    *current_kboard->echoptr = '\0';
  
    current_kboard->echo_after_prompt = len;
--- 690,724 ----
  
  void
  echo_prompt (str)
!      Lisp_Object str;
  {
!   int len = STRING_BYTES (XSTRING (str));
!   int multibyte_p = STRING_MULTIBYTE (str);
  
    if (len > ECHOBUFSIZE - 4)
!     {
!       if (multibyte_p)
!       {
!         unsigned char *p = XSTRING (str)->data, *lastp;
!         unsigned char *pend = p + ECHOBUFSIZE - 4;
! 
!         while (p < pend)
!           {
!             int this_len;
! 
!             lastp = p;
!             PARSE_MULTIBYTE_SEQ (p, pend - p, this_len);
!             p += this_len;
!           }
!         len = lastp - XSTRING (str)->data;
!       }
!       else
!       len = ECHOBUFSIZE - 4;
!     }
! 
!   current_kboard->echoptr
!     += copy_text (XSTRING (str)->data, current_kboard->echobuf, len,
!                 STRING_MULTIBYTE (str), 1);
    *current_kboard->echoptr = '\0';
  
    current_kboard->echo_after_prompt = len;
***************
*** 727,737 ****
  
        if (INTEGERP (c))
        {
          if (ptr - current_kboard->echobuf
              > ECHOBUFSIZE - KEY_DESCRIPTION_SIZE)
            return;
  
!         ptr = push_key_description (XINT (c), ptr);
        }
        else if (SYMBOLP (c))
        {
--- 748,767 ----
  
        if (INTEGERP (c))
        {
+         int ch = XINT (c);
+ 
          if (ptr - current_kboard->echobuf
              > ECHOBUFSIZE - KEY_DESCRIPTION_SIZE)
            return;
  
!         if (ASCII_BYTE_P (ch))
!           ptr = push_key_description (ch, ptr);
!         else
!           {
!             if (SINGLE_BYTE_CHAR_P (ch))
!               ch = unibyte_char_to_multibyte (ch);          
!             ptr += CHAR_STRING (ch, ptr);
!           }
        }
        else if (SYMBOLP (c))
        {
***************
*** 739,746 ****
          if ((ptr - current_kboard->echobuf) + STRING_BYTES (name) + 4
              > ECHOBUFSIZE)
            return;
!         bcopy (name->data, ptr, STRING_BYTES (name));
!         ptr += STRING_BYTES (name);
        }
  
        if (current_kboard->echoptr == current_kboard->echobuf
--- 769,776 ----
          if ((ptr - current_kboard->echobuf) + STRING_BYTES (name) + 4
              > ECHOBUFSIZE)
            return;
!         ptr += copy_text (name->data, ptr, STRING_BYTES (name),
!                           name->size_byte >= 0, 1);
        }
  
        if (current_kboard->echoptr == current_kboard->echobuf
***************
*** 806,812 ****
  
    echoing = 1;
    message2_nolog (current_kboard->echobuf, strlen (current_kboard->echobuf),
!                 ! NILP (current_buffer->enable_multibyte_characters));
    echoing = 0;
  
    /* Record in what buffer we echoed, and from which kboard.  */
--- 836,842 ----
  
    echoing = 1;
    message2_nolog (current_kboard->echobuf, strlen (current_kboard->echobuf),
!                 1);
    echoing = 0;
  
    /* Record in what buffer we echoed, and from which kboard.  */
***************
*** 7839,7845 ****
    if (INTERACTIVE)
      {
        if (!NILP (prompt))
!       echo_prompt (XSTRING (prompt)->data);
        else if (cursor_in_echo_area
               && (FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes))
               && NILP (Fzerop (Vecho_keystrokes)))
--- 7869,7875 ----
    if (INTERACTIVE)
      {
        if (!NILP (prompt))
!       echo_prompt (prompt);
        else if (cursor_in_echo_area
               && (FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes))
               && NILP (Fzerop (Vecho_keystrokes)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]