unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Spencer Baugh <sbaugh@janestreet.com>
Cc: 63825@debbugs.gnu.org, me@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	[thread overview]
Message-ID: <83wn0mbcx4.fsf@gnu.org> (raw)
In-Reply-To: <ierv8g7ylu1.fsf@janestreet.com> (message from Spencer Baugh on Thu, 01 Jun 2023 16:22:14 -0400)

> From: Spencer Baugh <sbaugh@janestreet.com>
> Cc: Eshel Yaron <me@eshelyaron.com>,  63825@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.





      parent reply	other threads:[~2023-06-02  6:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01 13:37 bug#63825: 29.0.90; The header line should be hidden when empty Spencer Baugh
2023-06-01 16:14 ` Eli Zaretskii
2023-06-01 16:45   ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-01 17:37     ` Spencer Baugh
2023-06-01 18:46     ` Eli Zaretskii
2023-06-01 20:22       ` Spencer Baugh
2023-06-02  6:19         ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-02 11:36           ` Eli Zaretskii
2023-06-02 18:53             ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-03  5:44               ` Eli Zaretskii
2023-06-03  7:28                 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-04  7:03                   ` Eli Zaretskii
2023-06-04 16:45                     ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-06 12:18                       ` Eli Zaretskii
2023-06-06 12:28                         ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-02  6:23         ` Eli Zaretskii [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83wn0mbcx4.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=63825@debbugs.gnu.org \
    --cc=me@eshelyaron.com \
    --cc=sbaugh@janestreet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).