From 60185c2fa667fdd8a3900936130895b8a783c127 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 24 Aug 2020 02:46:15 +0200 Subject: [PATCH] Improve frame-title-format and icon-title-format * src/xdisp.c (decode_mode_spec): Support new '%B'-construct. (syms_of_xdisp): Change 'Vframe_title_format' and 'Vicon_title_format' to use the new '%B'-construct. Replace 'invocation-name' with the text "GNU Emacs". (Bug#41147) * doc/lispref/modes.texi (%-Constructs): Document new '%B'-construct. * etc/NEWS: Announce the above changes. --- doc/lispref/modes.texi | 6 ++++++ etc/NEWS | 14 ++++++++++++++ src/xdisp.c | 12 +++++++++--- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 33a07c9fb4..92c660617d 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -2245,6 +2245,12 @@ %-Constructs The current buffer name, obtained with the @code{buffer-name} function. @xref{Buffer Names}. +@item %B +The visited file name obtained with the @code{buffer-file-name} +function, but shortened using @code{abbreviate-file-name}. If the +current buffer is not visiting a file, use the current buffer name +obtained with the @code{buffer-name} function instead. + @item %c The current column number of point, counting from zero starting at the left margin of the window. diff --git a/etc/NEWS b/etc/NEWS index ad63955f7b..9bbcc7896c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -121,6 +121,15 @@ the mouse cursor is on the scroll bars, fringes, margins, header line, and mode line. ('mwheel-mode' is enabled by default on most graphical displays.) +--- +** The default 'frame-title-format' has been changed. +It now includes the file or buffer name even when there is only a +single frame, but no longer contains 'invocation-name'. To get the +old behavior back, add the following to your Init file: + + (setq frame-title-format '(multiple-frames "%b" + ("" invocation-name "@" system-name))) + * Editing Changes in Emacs 28.1 @@ -1091,6 +1100,11 @@ It was used to allow loading Lisp libraries compiled by XEmacs, a modified version of Emacs which is no longer actively maintained. This is no longer supported, and setting this variable has no effect. ++++ +** The Mode Line Format has a new '%B'-construct. +The new construct adds the abbreviated file name or name of the +current buffer. See the Emacs Lisp Reference Manual for more details. + +++ ** The macro 'with-displayed-buffer-window' is now obsolete. Use macro 'with-current-buffer-window' with action alist entry 'body-function'. diff --git a/src/xdisp.c b/src/xdisp.c index dd73758043..4920260406 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -26424,6 +26424,13 @@ decode_mode_spec (struct window *w, register int c, int field_width, obj = BVAR (b, name); break; + case 'B': + if (!NILP (BVAR (b, filename))) + obj = call1 (intern ("abbreviate-file-name"), BVAR (b, filename)); + else + obj = BVAR (b, name); + break; + case 'c': case 'C': /* %c, %C, and %l are ignored in `frame-title-format'. @@ -34830,13 +34837,12 @@ syms_of_xdisp (void) Oracle Developer Studio 12.6. */ Lisp_Object icon_title_name_format = pure_list (empty_unibyte_string, - intern_c_string ("invocation-name"), - build_pure_c_string ("@"), + build_pure_c_string ("%B - GNU Emacs at "), intern_c_string ("system-name")); Vicon_title_format = Vframe_title_format = pure_list (intern_c_string ("multiple-frames"), - build_pure_c_string ("%b"), + build_pure_c_string ("%B"), icon_title_name_format); DEFVAR_LISP ("message-log-max", Vmessage_log_max, -- 2.28.0