aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2020-12-29 04:53:03 +0100
committerLars Ingebrigtsen2020-12-29 04:53:03 +0100
commita66f0d3bd3486b7253f482b7169b0de2d0d49c79 (patch)
tree4f47a60c67d153a81d5395fda625e0c3a214ea50
parent37049ee78c4576d340781179317e6cbaaf73b6c3 (diff)
downloademacs-a66f0d3bd3486b7253f482b7169b0de2d0d49c79.tar.gz
emacs-a66f0d3bd3486b7253f482b7169b0de2d0d49c79.zip
Introduce new variable mode-line-compact
* doc/lispref/modes.texi (Mode Line Basics): Document it (bug#34476). * src/xdisp.c (display_mode_line): Use it. (syms_of_xdisp): New variable mode-line-compact.
-rw-r--r--doc/lispref/modes.texi9
-rw-r--r--etc/NEWS6
-rw-r--r--src/xdisp.c49
3 files changed, 61 insertions, 3 deletions
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 675aeec8a5f..40edc90a6af 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -1930,6 +1930,15 @@ This function also forces an update of the menu bar and frame title.
1930color using the face @code{mode-line}. Other windows' mode lines appear 1930color using the face @code{mode-line}. Other windows' mode lines appear
1931in the face @code{mode-line-inactive} instead. @xref{Faces}. 1931in the face @code{mode-line-inactive} instead. @xref{Faces}.
1932 1932
1933@vindex mode-line-compact
1934 Some modes put a lot of data in the mode line, pushing elements at
1935the end of the mode line off to the right. Emacs can ``compress'' the
1936mode line if the @code{mode-line-compact} variable is non-@code{nil}
1937by turning stretches of spaces into a single space. If this variable
1938is @code{long}, this is only done when the mode line is wider than the
1939currently selected window. This variable can be buffer-local to only
1940compress mode-lines in certain buffers.
1941
1933@node Mode Line Data 1942@node Mode Line Data
1934@subsection The Data Structure of the Mode Line 1943@subsection The Data Structure of the Mode Line
1935@cindex mode line construct 1944@cindex mode line construct
diff --git a/etc/NEWS b/etc/NEWS
index 6348c1d8eef..a5247a9aea8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1615,6 +1615,12 @@ the column number format (when 'column-number-mode' is on), and
1615both modes are on). 1615both modes are on).
1616 1616
1617+++ 1617+++
1618*** New user option 'mode-line-compact'.
1619If non-nil, repeating spaces are compressed into a single space. If
1620'long', this is only done when the mode line is longer than the
1621current window width (in characters).
1622
1623+++
1618*** New command 'submit-emacs-patch'. 1624*** New command 'submit-emacs-patch'.
1619This works like 'report-emacs-bug', but is more geared towards sending 1625This works like 'report-emacs-bug', but is more geared towards sending
1620patches to the Emacs issue tracker. 1626patches to the Emacs issue tracker.
diff --git a/src/xdisp.c b/src/xdisp.c
index b5adee51055..6606e49e428 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -25451,14 +25451,49 @@ display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format)
25451 format_mode_line_unwind_data (NULL, NULL, 25451 format_mode_line_unwind_data (NULL, NULL,
25452 Qnil, false)); 25452 Qnil, false));
25453 25453
25454 mode_line_target = MODE_LINE_DISPLAY;
25455
25456 /* Temporarily make frame's keyboard the current kboard so that 25454 /* Temporarily make frame's keyboard the current kboard so that
25457 kboard-local variables in the mode_line_format will get the right 25455 kboard-local variables in the mode_line_format will get the right
25458 values. */ 25456 values. */
25459 push_kboard (FRAME_KBOARD (it.f)); 25457 push_kboard (FRAME_KBOARD (it.f));
25460 record_unwind_save_match_data (); 25458 record_unwind_save_match_data ();
25461 display_mode_element (&it, 0, 0, 0, format, Qnil, false); 25459
25460 if (NILP (Vmode_line_compact))
25461 {
25462 mode_line_target = MODE_LINE_DISPLAY;
25463 display_mode_element (&it, 0, 0, 0, format, Qnil, false);
25464 }
25465 else
25466 {
25467 Lisp_Object mode_string = Fformat_mode_line (format, Qnil, Qnil, Qnil);
25468 if (EQ (Vmode_line_compact, Qlong)
25469 && window_body_width (XWINDOW (selected_window), FALSE) >=
25470 SCHARS (mode_string))
25471 {
25472 display_string (SSDATA (mode_string), Qnil, Qnil, 0, 0, &it, 0, 0, 0,
25473 STRING_MULTIBYTE (mode_string));
25474 }
25475 else
25476 {
25477 char *string = xmalloc (SBYTES (mode_string) + 1),
25478 *ostring = SSDATA (mode_string);
25479 char *s = string, prev = 0;
25480
25481 /* Copy over the data from the mode line string, but ignore
25482 repeating spaces. This should be safe even for multibyte
25483 strings, since this is UTF-8. */
25484 for (int i = 0; i < SBYTES (mode_string); i++)
25485 {
25486 char c = ostring[i];
25487 if (!(c == ' ' && prev == ' '))
25488 prev = *s++ = c;
25489 }
25490 *s = 0;
25491
25492 display_string (string, Qnil, Qnil, 0, 0, &it, 0, 0, 0,
25493 STRING_MULTIBYTE (mode_string));
25494 xfree (string);
25495 }
25496 }
25462 pop_kboard (); 25497 pop_kboard ();
25463 25498
25464 unbind_to (count, Qnil); 25499 unbind_to (count, Qnil);
@@ -34805,6 +34840,14 @@ wide as that tab on the display. */);
34805The face used for trailing whitespace is `trailing-whitespace'. */); 34840The face used for trailing whitespace is `trailing-whitespace'. */);
34806 Vshow_trailing_whitespace = Qnil; 34841 Vshow_trailing_whitespace = Qnil;
34807 34842
34843 DEFVAR_LISP ("mode-line-compact", Vmode_line_compact,
34844 doc: /* Non-nil means that mode lines should be compact.
34845This means that repeating spaces will be replaced with a single space.
34846If this variable is `long', only mode lines that are wider than the
34847currently selected window are compressed. */);
34848 Vmode_line_compact = Qnil;
34849 DEFSYM (Qlong, "long");
34850
34808 DEFVAR_LISP ("nobreak-char-display", Vnobreak_char_display, 34851 DEFVAR_LISP ("nobreak-char-display", Vnobreak_char_display,
34809 doc: /* Control highlighting of non-ASCII space and hyphen chars. 34852 doc: /* Control highlighting of non-ASCII space and hyphen chars.
34810If the value is t, Emacs highlights non-ASCII chars which have the 34853If the value is t, Emacs highlights non-ASCII chars which have the