emacs-diffs
[Top][All Lists]
Advanced

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

master a539488: Always make a multibyte string for the frame title (bug#


From: Mattias Engdegård
Subject: master a539488: Always make a multibyte string for the frame title (bug#42904)
Date: Sun, 23 Aug 2020 13:18:32 -0400 (EDT)

branch: master
commit a5394884627db6f6091c4b85b635af81c20f0f31
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Always make a multibyte string for the frame title (bug#42904)
    
    * src/xdisp.c (gui_consider_frame_title): Multibyte-encode any raw
    bytes in the title, and then pass a multibyte string to the back-end
    for use as a frame title.  This cuts down a little on the rubbish
    shown when raw bytes sneak in by mistake (as part of the buffer name,
    for instance).
---
 src/xdisp.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index 34644df..e2ebbbd 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -12565,6 +12565,11 @@ gui_consider_frame_title (Lisp_Object frame)
       display_mode_element (&it, 0, -1, -1, fmt, Qnil, false);
       len = MODE_LINE_NOPROP_LEN (title_start);
       title = mode_line_noprop_buf + title_start;
+      /* Make sure that any raw bytes in the title are properly
+         represented by their multibyte sequences.  */
+      ptrdiff_t nchars = 0;
+      len = str_as_multibyte (title, mode_line_noprop_buf_end - title,
+                              len, &nchars);
       unbind_to (count, Qnil);
 
       /* Set the title only if it's changed.  This avoids consing in
@@ -12576,9 +12581,10 @@ gui_consider_frame_title (Lisp_Object frame)
            || SBYTES (f->name) != len
            || memcmp (title, SDATA (f->name), len) != 0)
           && FRAME_TERMINAL (f)->implicit_set_name_hook)
-       FRAME_TERMINAL (f)->implicit_set_name_hook (f,
-                                                    make_string (title, len),
-                                                    Qnil);
+        {
+          Lisp_Object title_string = make_multibyte_string (title, nchars, 
len);
+          FRAME_TERMINAL (f)->implicit_set_name_hook (f, title_string, Qnil);
+        }
     }
 }
 



reply via email to

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