From: "Mattias Engdegård" <mattiase@acm.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 42904@debbugs.gnu.org, alan@idiocy.org
Subject: bug#42904: [PATCH] Non-Unicode frame title crashes Emacs on macOS
Date: Fri, 21 Aug 2020 16:53:34 +0200 [thread overview]
Message-ID: <D0AFDFAD-74B7-4FA9-BFC5-17D33D018A30@acm.org> (raw)
In-Reply-To: <83ft8gb05o.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 680 bytes --]
21 aug. 2020 kl. 15.26 skrev Eli Zaretskii <eliz@gnu.org>:
> That is true, but str_as_multibyte simply interprets any valid UTF-8
> sequence as a character, and any invalid sequence as a raw bytes. I
> thought this was precisely what you wanted for this use case, no?
Sorry, I read the comment for that function and got the impression that it would interpret raw bytes as Latin-1. Fortunately that wasn't true, and using it seems to be a clear improvement. Now a mixture of non-ASCII and raw bytes, like "a\377büc" results in the title "a��büc", which is one � too many but good enough.
What about the attached patch then? Only tested on macOS, admittedly.
[-- Attachment #2: 0001-Always-make-a-multibyte-string-for-the-frame-title-b.patch --]
[-- Type: application/octet-stream, Size: 2000 bytes --]
From dbe9ee59a179a3d42f337c60b5f426f6ff2913ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Fri, 21 Aug 2020 16:09:04 +0200
Subject: [PATCH] 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 ad03ac4605..9eeae43a52 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -12482,6 +12482,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 any raw bytes in the title are properly
+ multibyte-encoded. */
+ 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
@@ -12493,9 +12498,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);
+ }
}
}
--
2.21.1 (Apple Git-122.3)
next prev parent reply other threads:[~2020-08-21 14:53 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-17 14:11 bug#42904: [PATCH] Non-Unicode frame title crashes Emacs on macOS Mattias Engdegård
2020-08-17 14:54 ` Andrii Kolomoiets
2020-08-17 15:55 ` Mattias Engdegård
2020-08-17 15:55 ` Eli Zaretskii
2020-08-17 16:11 ` Mattias Engdegård
2020-08-17 17:05 ` Eli Zaretskii
2020-08-17 18:48 ` Mattias Engdegård
2020-08-17 19:56 ` Alan Third
2020-08-18 8:07 ` Mattias Engdegård
2020-08-18 8:43 ` Alan Third
2020-08-18 11:48 ` Mattias Engdegård
2020-08-18 12:22 ` Eli Zaretskii
2020-08-18 17:28 ` Alan Third
2020-08-20 9:27 ` Mattias Engdegård
2020-08-20 13:24 ` Eli Zaretskii
2020-08-20 18:46 ` Mattias Engdegård
2020-08-20 19:13 ` Eli Zaretskii
2020-08-21 9:39 ` Mattias Engdegård
2020-08-21 13:26 ` Eli Zaretskii
2020-08-21 14:53 ` Mattias Engdegård [this message]
2020-08-21 15:27 ` Eli Zaretskii
2020-08-21 15:50 ` Mattias Engdegård
2020-08-23 17:23 ` Mattias Engdegård
2020-08-20 13:24 ` Alan Third
2020-08-20 17:44 ` Mattias Engdegård
2020-08-18 12:24 ` Eli Zaretskii
2020-08-18 14:11 ` Mattias Engdegård
2020-08-18 14:40 ` Eli Zaretskii
2020-08-18 15:21 ` Mattias Engdegård
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D0AFDFAD-74B7-4FA9-BFC5-17D33D018A30@acm.org \
--to=mattiase@acm.org \
--cc=42904@debbugs.gnu.org \
--cc=alan@idiocy.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.