master 4cfcf6ac67b: Merge from origin/emacs-31
Eli Zaretskii <[email protected]>
| Newsgroups | gmane.emacs.diffs |
|---|---|
| Message-ID | <[email protected]> |
branch: master commit 4cfcf6ac67b079cb1b12758595c40c5f1c1ffc8b Merge: 6505ac5c940 e78a0fc9f4d Author: Eli Zaretskii <[email protected]> Commit: Eli Zaretskii <[email protected]> Merge from origin/emacs-31 e78a0fc9f4d Resurrect effect of 2nd arg t in 'format-mode-line' --- doc/lispref/modes.texi | 2 +- src/xdisp.c | 7 ++++++- test/src/xdisp-tests.el | 13 +++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 5f0e9a0fade..a2cc2198108 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -2869,7 +2869,7 @@ The value string normally has text properties that correspond to the faces, keymaps, etc., that the mode line would have. Any character for which no @code{face} property is specified by @var{format} gets a default value determined by @var{face}. If @var{face} is @code{t}, that -stands for either @code{mode-line} if @var{window} is selected, +stands for either @code{mode-line-active} if @var{window} is selected, otherwise @code{mode-line-inactive}. If @var{face} is @code{nil} or omitted, that stands for the default face. If @var{face} is an integer, the value returned by this function will have no text properties. diff --git a/src/xdisp.c b/src/xdisp.c index 14d335fbcc1..444878a7d6d 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -29005,7 +29005,7 @@ By default, the format is evaluated for the currently selected window. Optional second arg FACE specifies the face property to put on all characters for which no face is specified. The value nil means the default face. The value t means whatever face the window's mode line -currently uses (either `mode-line' or `mode-line-inactive', +currently uses (either `mode-line-active' or `mode-line-inactive', depending on whether the window is the selected window or not). An integer value means the value string has no text properties. @@ -29056,6 +29056,11 @@ are the selected window and the WINDOW's buffer). */) : EQ (face, Qtool_bar) ? TOOL_BAR_FACE_ID : DEFAULT_FACE_ID; + if (EQ (face, Qt)) + face = EQ (window, selected_window) + ? Qmode_line_active + : Qmode_line_inactive; + old_buffer = current_buffer; /* Save things including mode_line_proptrans_alist, diff --git a/test/src/xdisp-tests.el b/test/src/xdisp-tests.el index 3b5ab902cc2..4369c00ca34 100644 --- a/test/src/xdisp-tests.el +++ b/test/src/xdisp-tests.el @@ -179,4 +179,17 @@ int main () { (buffer-string))) "foo\n"))) +(ert-deftest xdisp-test-format-mode-line () + ;; 'format-mode-line' returns an empty string with no properties in + ;; noninteractive sessions. + (skip-when noninteractive) + (with-temp-buffer + (insert (format-mode-line " " t)) + (should (equal (buffer-string) #(" " 0 1 (face mode-line-active))))) + (with-temp-buffer + (insert (format-mode-line + (propertize "x" 'face 'bold-italic) + 1200000000000000000000000000)) + (should (null (get-text-property 1 'face))))) + ;;; xdisp-tests.el ends here