emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: line-number-mode at EOB


From: Stephen Berman
Subject: Re: line-number-mode at EOB
Date: Tue, 18 Jul 2017 18:33:08 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

On Tue, 18 Jul 2017 17:55:41 +0300 Eli Zaretskii <address@hidden> wrote:

>> From: Stephen Berman <address@hidden>
>> Cc: address@hidden
>> Date: Tue, 18 Jul 2017 00:20:10 +0200
>> 
>> > By that reasoning, line-number-mode (the %l construct) should be changed
>> > so as not to display a number when point is at EOB.  Perhaps it should
>> > display "EOB" or "END" instead.
>> 
>> I attempted to implement this change in the mode line display (see
>> attached patch) and the result, while admittedly only "minor aesthetic
>> sugar", seems to me not too bad: it makes line-number-mode consistent
>> not only with vertically displayed line numbers but also with
>> `count-words-region' (and hence with `count-lines').  What do others
>> think?
>
> Hmm... I don't understand why you needed to change the format spec to
> %l, and also why the change in mode_line_update_needed.  Isn't it
> enough to just produce "EOB" instead of a number?

If just mode-line-position in bindings.el is changed, that fails to
update the mode line frequently enough: if you go to point-max in
*scratch*, so the mode line displays "EOB", then continually typing C-b
or C-p doesn't change the "EOB".  Conversely, if just decode_mode_spec
is changed to output "EOB" at point-max, the current code in
mode-line-position will make the mode line display "LEOB" when
column-number-mode is disabled.  Finally, even with both of the other
changes, without the change in mode_line_update_needed, if the character
immediately before EOB is not a newline (and column-number-mode is not
enabled), then if point is at EOB, continually typing C-b will keep
displaying "EOB" until the line number changes, and if point in on the
last line but before EOB, typing C-f to move to EOB will not change the
display to "EOB".

>>  static bool
>>  mode_line_update_needed (struct window *w)
>>  {
>> -  return (w->column_number_displayed != -1
>> -      && !(PT == w->last_point && !window_outdated (w))
>> -      && (w->column_number_displayed != current_column ()));
>> +  return ((w->column_number_displayed != -1
>> +       && !(PT == w->last_point && !window_outdated (w))
>> +       && (w->column_number_displayed != current_column ()))
>> +      || (line_number_displayed
>> +          && ((ZV == w->last_point && PT != ZV)
>> +              || (ZV != w->last_point && PT == ZV))));
>
> The last 2 lines can be written more succinctly as
>
>               && ((ZV == w->last_point) != (PT == ZV))

Thanks!  (I felt sure there was a shorter equivalent expression, but it
was late when I posted and I couldn't get my head around it.)

Steve Berman



reply via email to

[Prev in Thread] Current Thread [Next in Thread]