GNU bug report logs - #63825
29.0.90; The header line should be hidden when empty

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> janestreet.com>

Date: Thu, 1 Jun 2023 13:38:01 UTC

Severity: normal

Found in version 29.0.90

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: 63825 <at> debbugs.gnu.org, me <at> eshelyaron.com
Subject: bug#63825: 29.0.90; The header line should be hidden when empty
Date: Fri, 02 Jun 2023 09:23:19 +0300
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Cc: Eshel Yaron <me <at> eshelyaron.com>,  63825 <at> debbugs.gnu.org
> Date: Thu, 01 Jun 2023 16:22:14 -0400
> 
> >> So this shows an empty header line:
> >> 
> >> --8<---------------cut here---------------start------------->8---
> >> (setq-default header-line-format '(:eval nil))
> >> --8<---------------cut here---------------end--------------->8---
> >> 
> >> (In Emacs master with -Q.)
> >
> > It shouldn't be hard to make this special case behave as you want.
> > Specifically, if the header-line-format is just a single cons cell,
> > and the car of that cons cell is either :eval or a symbol, and the
> > result of evaluation those yields nil, don't display the header line.
> > (I don't really like the idea of not displaying the mode line under
> > the same conditions.)
> >
> > Patches welcome.
> 
> Ok, the easy way to achieve that is to run format-mode-line on the
> header-line-format and if it evaluates to "", don't display the header
> line.  That also ignores the cases where header-line-format is multiple
> cons cells, all of which evaluate to nil, and other such scenarios.  Is
> that an acceptable approach to you?

No, using format-mode-line for displaying the mode line is not a good
idea, for several subtle reason which I won't go into.  If you want to
understand the reasons, look at the code of format-mode-line and how
it affects what display_mode_element does.  In particular, there's no
way to distinguish between the special value of header-line-format we
are discussing and the value that really yields an empty string: the
latter we don't want to change.

Why can't you simply copy some of the code from display_mode_element
that handles the :eval and the cons cell with a symbol cases into
display_mode_line, before it calls display_mode_element, and have the
function return zero in case the result is nil?  Then the callers of
display_mode_line should treat the zero value as an indication that
the mode line was not displayed/produced, and act accordingly.

Alternatively, you could do something special in display_mode_element
when these two forms evaluate to nil and DEPTH is 1, and add some
logic in display_mode_line to handle that.




This bug report was last modified 1 year and 346 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.