[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#7307: 24.0.50; Mode line had more than just dashes removed
From: |
Stephen Berman |
Subject: |
bug#7307: 24.0.50; Mode line had more than just dashes removed |
Date: |
Sat, 30 Oct 2010 15:27:32 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
On Sat, 30 Oct 2010 08:51:14 +0200 Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Stephen Berman <stephen.berman@gmx.net>
>> Date: Sat, 30 Oct 2010 01:05:32 +0200
>> Cc:
>>
>> The only problem is specifying the length of the
>> string: (window-width) as the maximum possible length fails here,
>> because the mode line is constructed before the window-system frame, and
>> has a value of just 10. So I just picked 200 as a plausible maximum.
>> Maybe there's a better way, but this seems to work ok.
>
> Would it help to use window-width as the maximum?
?? See above. Or did you mean something else? (Though I see that what
I wrote is a bit garbled: it should say "(window-width) has a value of
just 10".) Anyway, maybe it's less kludgy to introduce a mode line
%-construct for spaces. Here's a patch for that, which just adapts the
code for "%-". It seems to works (but so does my other lisp-only
patch). (Interestingly, lots_of_dashes, and hence lots_of_spaces, has a
length of 140, but that's enough at least for my screen.)
=== modified file 'doc/lispref/modes.texi'
--- doc/lispref/modes.texi 2010-08-22 19:30:26 +0000
+++ doc/lispref/modes.texi 2010-10-30 13:01:23 +0000
@@ -2029,6 +2029,9 @@
@item %-
Dashes sufficient to fill the remainder of the mode line.
+@item %_
+Spaces sufficient to fill the remainder of the mode line.
+
@item %%
The character @samp{%}---this is how to include a literal @samp{%} in a
string in which @code{%}-constructs are allowed.
=== modified file 'lisp/bindings.el'
--- lisp/bindings.el 2010-10-19 19:20:33 +0000
+++ lisp/bindings.el 2010-10-30 13:01:56 +0000
@@ -336,7 +336,8 @@
'mode-line-modes
`(which-func-mode ("" which-func-format ,spaces))
`(global-mode-string ("" global-mode-string ,spaces))
- `(:eval (unless (display-graphic-p)
+ `(:eval (if (display-graphic-p)
+ ,(propertize " %_" 'help-echo help-echo)
,(propertize "-%-" 'help-echo help-echo)))))
(standard-mode-line-modes
(list
=== modified file 'src/buffer.c'
--- src/buffer.c 2010-10-29 03:29:29 +0000
+++ src/buffer.c 2010-10-30 13:01:37 +0000
@@ -5571,6 +5571,7 @@
remote machine.
%[ -- print one [ for each recursive editing level. %] similar.
%% -- print %. %- -- print infinitely many dashes.
+ %_ -- print infinitely many spaces.
Decimal digits after the % specify field width to which to pad. */);
DEFVAR_LISP_NOPRO ("default-major-mode", &buffer_defaults.major_mode,
=== modified file 'src/xdisp.c'
--- src/xdisp.c 2010-10-23 21:19:02 +0000
+++ src/xdisp.c 2010-10-30 12:37:24 +0000
@@ -19269,6 +19269,8 @@
static char lots_of_dashes[] =
"--------------------------------------------------------------------------------------------------------------------------------------------";
+static char lots_of_spaces[] = "
";
+
static const char *
decode_mode_spec (struct window *w, register int c, int field_width,
int precision, Lisp_Object *string)
@@ -19355,6 +19357,26 @@
return lots_of_dashes;
}
+ case '_':
+ {
+ register int i;
+
+ /* Let lots_of_spaces be a string of infinite length. */
+ if (mode_line_target == MODE_LINE_NOPROP ||
+ mode_line_target == MODE_LINE_STRING)
+ return " ";
+ if (field_width <= 0
+ || field_width > sizeof (lots_of_spaces))
+ {
+ for (i = 0; i < FRAME_MESSAGE_BUF_SIZE (f) - 1; ++i)
+ decode_mode_spec_buf[i] = ' ';
+ decode_mode_spec_buf[i] = '\0';
+ return decode_mode_spec_buf;
+ }
+ else
+ return lots_of_dashes;
+ }
+
case 'b':
obj = b->name;
break;