unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefankangas@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: angelo.g0@libero.it, emacs-devel@gnu.org
Subject: Re: About the new frame title
Date: Thu, 24 Sep 2020 01:57:38 -0700	[thread overview]
Message-ID: <CADwFkmkb258qjxpjVbXrRQ0-h=o+uaOkFip0zf+nfGvbyqpH6A@mail.gmail.com> (raw)
In-Reply-To: <83imc93k5d.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 781 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>>    dpyinfo->name_list_element = Fcons (display_name, Qnil);
>>    if (STRINGP (Vsystem_name))
>>      {
>> -      dpyinfo->w32_id_name = xmalloc (SCHARS (Vinvocation_name)
>> -                                      + SCHARS (Vsystem_name) + 2);
>> -      sprintf (dpyinfo->w32_id_name, "%s@%s",
>> -               SDATA (Vinvocation_name), SDATA (Vsystem_name));
>> +      dpyinfo->w32_id_name = xmalloc (14 + SCHARS (Vsystem_name));
>> +      sprintf (dpyinfo->w32_id_name, "GNU Emacs at %s", SDATA (Vsystem_name));
>
> Please don't use hard-coded constants, like 14 above, in such cases.
> Instead, use sizeof to compute the correct size at compile time from
> the string used as format specifier.

Thanks.  Does the attached look better?

[-- Attachment #2: 0001-Make-initial-frame-match-frame-title-format.patch --]
[-- Type: text/x-diff, Size: 2954 bytes --]

From 46214fcd6db55b2c71836d2d3054fabe2860c9a1 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Sat, 19 Sep 2020 14:13:52 +0200
Subject: [PATCH] Make initial frame match frame-title-format

* src/xterm.c (x_term_init):
* src/w32term.c (w32_initialize_display_info): Sync initial frame
title with new value of Vframe_title_format.
Problem reported by Angelo Graziosi <angelo.g0@libero.it>.
---
 src/w32term.c | 14 +++++++++-----
 src/xterm.c   | 25 +++++++++++++++----------
 2 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/src/w32term.c b/src/w32term.c
index 2669f29b56..206b5ecb82 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -7165,15 +7165,19 @@ w32_initialize_display_info (Lisp_Object display_name)
   memset (dpyinfo, 0, sizeof (*dpyinfo));
 
   dpyinfo->name_list_element = Fcons (display_name, Qnil);
+  const char *title;
   if (STRINGP (Vsystem_name))
     {
-      dpyinfo->w32_id_name = xmalloc (SCHARS (Vinvocation_name)
-                                      + SCHARS (Vsystem_name) + 2);
-      sprintf (dpyinfo->w32_id_name, "%s@%s",
-               SDATA (Vinvocation_name), SDATA (Vsystem_name));
+      title = "GNU Emacs at ";
+      dpyinfo->w32_id_name = xmalloc (sizeof (title) + SCHARS (Vsystem_name));
+      sprintf (dpyinfo->w32_id_name, "%s%s", title, SDATA (Vsystem_name));
     }
   else
-    dpyinfo->w32_id_name = xlispstrdup (Vinvocation_name);
+    {
+      title = "GNU Emacs";
+      dpyinfo->w32_id_name = xmalloc (sizeof (title));
+      sprintf (dpyinfo->w32_id_name, "%s", title);
+    }
 
   /* Default Console mode values - overridden when running in GUI mode
      with values obtained from system metrics.  */
diff --git a/src/xterm.c b/src/xterm.c
index 2e0407aff4..626f066bca 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -12927,19 +12927,24 @@ #define NUM_ARGV 10
 #endif
 
   Lisp_Object system_name = Fsystem_name ();
-
-  ptrdiff_t nbytes = SBYTES (Vinvocation_name) + 1;
-  if (STRINGP (system_name)
-      && INT_ADD_WRAPV (nbytes, SBYTES (system_name) + 1, &nbytes))
-    memory_full (SIZE_MAX);
-  dpyinfo->x_id = ++x_display_id;
-  dpyinfo->x_id_name = xmalloc (nbytes);
-  char *nametail = lispstpcpy (dpyinfo->x_id_name, Vinvocation_name);
+  const char *title;
   if (STRINGP (system_name))
     {
-      *nametail++ = '@';
-      lispstpcpy (nametail, system_name);
+      title = "GNU Emacs at ";
+      ptrdiff_t nbytes = sizeof (title);
+      if (INT_ADD_WRAPV (nbytes, SBYTES (system_name), &nbytes))
+	memory_full (SIZE_MAX);
+      dpyinfo->x_id_name = xmalloc (nbytes);
+      sprintf(dpyinfo->x_id_name, "%s%s", title, SDATA (system_name));
     }
+  else
+    {
+      title = "GNU Emacs";
+      dpyinfo->x_id_name = xmalloc (sizeof (title));
+      sprintf (dpyinfo->x_id_name, "%s", title);
+    }
+
+  dpyinfo->x_id = ++x_display_id;
 
   /* Figure out which modifier bits mean what.  */
   x_find_modifier_meanings (dpyinfo);
-- 
2.28.0


  reply	other threads:[~2020-09-24  8:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-14  8:27 About the new frame title Angelo Graziosi
2020-09-14 15:17 ` Eli Zaretskii
2020-09-14 15:52   ` Angelo Graziosi
2020-09-19 13:21     ` Stefan Kangas
2020-09-19 14:39       ` Eli Zaretskii
2020-09-24  8:57         ` Stefan Kangas [this message]
2020-09-24 14:46           ` Eli Zaretskii
2020-09-25 12:38             ` Angelo Graziosi
2020-09-25 12:41               ` Eli Zaretskii
2020-09-25 13:31                 ` Angelo Graziosi
2020-09-25 13:42                   ` Eli Zaretskii
2020-11-13 23:10             ` Stefan Kangas
2020-11-13 23:51               ` Andrea Corallo via Emacs development discussions.
2020-11-14  7:26               ` Eli Zaretskii
2020-11-14 14:47                 ` Stefan Kangas
2020-11-14 15:10                   ` Eli Zaretskii
2020-11-15  1:44                     ` Stefan Kangas
2020-09-19 21:22       ` Angelo Graziosi
2020-09-24  8:37         ` Stefan Kangas

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkmkb258qjxpjVbXrRQ0-h=o+uaOkFip0zf+nfGvbyqpH6A@mail.gmail.com' \
    --to=stefankangas@gmail.com \
    --cc=angelo.g0@libero.it \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).