From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#63825: 29.0.90; The header line should be hidden when empty Date: Fri, 02 Jun 2023 09:19:17 +0300 Message-ID: References: <838rd3cg7u.fsf@gnu.org> <83353bc97b.fsf@gnu.org> Reply-To: Eshel Yaron Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3590"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , 63825@debbugs.gnu.org To: Spencer Baugh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 02 08:20:18 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q4y94-0000le-Bo for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Jun 2023 08:20:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4y8p-00034m-L6; Fri, 02 Jun 2023 02:20:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4y8o-00034R-Lg for bug-gnu-emacs@gnu.org; Fri, 02 Jun 2023 02:20:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q4y8o-0002IQ-AF for bug-gnu-emacs@gnu.org; Fri, 02 Jun 2023 02:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q4y8n-0006rU-O6 for bug-gnu-emacs@gnu.org; Fri, 02 Jun 2023 02:20:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Jun 2023 06:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63825 X-GNU-PR-Package: emacs Original-Received: via spool by 63825-submit@debbugs.gnu.org id=B63825.168568676526324 (code B ref 63825); Fri, 02 Jun 2023 06:20:01 +0000 Original-Received: (at 63825) by debbugs.gnu.org; 2 Jun 2023 06:19:25 +0000 Original-Received: from localhost ([127.0.0.1]:38970 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q4y8C-0006qV-Ne for submit@debbugs.gnu.org; Fri, 02 Jun 2023 02:19:25 -0400 Original-Received: from mail.eshelyaron.com ([107.175.124.16]:49080 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q4y89-0006qL-DS for 63825@debbugs.gnu.org; Fri, 02 Jun 2023 02:19:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1685686760; bh=p+tAuiIe7SJZpH+Ng+GpubpcrLxWizzELZAUcfDkKbg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=NKzZSM9U+691AnuL6DX132F/0phzPKmicxVQWmwdH7Aw1ZMZRe0nDubmvez8LIuG3 EYKb8gtsNpP/mm2jekUoAbvN01U1ZqaCMQfwyg+4PQIeZMu7/dK0O7dnCsrTCxW2t/ ekXcnqhwGrJsJLy7qXXSfsXxXOJkrgz7SIyGz4GJNZcOQJ2jnhYHduVj+eC1+X1L7o 1eHiXtLNpLkYpSDDHs8jTxmE00w4xBFS22GhP9hoW4EfRvllSoAnofMQ5U1jQJcDj/ qQHPpuW/xuWyTJfMGgbOPUe98Xgp2sxCkk5qig9ZQzJ1xaQjojcURVSL5cpYetWh/g k4yK89PqSYZcw== In-Reply-To: (Spencer Baugh's message of "Thu, 01 Jun 2023 16:22:14 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:262733 Archived-At: Spencer Baugh writes: > Eli Zaretskii writes: >> 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? This might be a bit too coarse IMO, because it would make it a lot harder to create an empty header line. Namely, setting `header-line-format` to an empty string would no longer create an empty header line. I'm far from fluent in Emacs's internals, but AFAIU from skimming src/xdisp.c there's another issue which is that Emacs checks whether a window should have a header line in many circumstances, as it affects the window's effective dimensions. So formatting the entire header line each time Emacs just wants to know whether there is or isn't a header line might not be ideal in terms of efficiency. The way I read Eli's above message, it boils down to extending the C function `window_wants_mode_line` with a couple of special cases. Something like the following (mildly tested): diff --git a/src/window.c b/src/window.c index f4e09f49eae..10bccc6df65 100644 --- a/src/window.c +++ b/src/window.c @@ -5471,6 +5471,36 @@ window_wants_mode_line (struct window *w) } +/** + * null_header_line_format: + * + * Return 1 when header line format F indicates that the header line + * should not be displayed at all. + * + * This is when F is nil, or F is a cons cell and either its car is a + * symbol whose value as a variable is nil, or its car is the symbol + * ':eval' and its cddr evaluates to nil. + */ +static bool +null_header_line_format (Lisp_Object f) +{ + Lisp_Object car; + + if (NILP (f)) + return 1; + + if (CONSP (f)) { + car = XCAR (f); + return (SYMBOLP (car) + && ((EQ (car, QCeval) + && NILP (Feval (XCAR (XCDR (f)), Qnil))) + || NILP (find_symbol_value (car)))); + } + + return 0; +} + + /** * window_wants_header_line: * @@ -5495,8 +5525,8 @@ window_wants_header_line (struct window *w) && !MINI_WINDOW_P (w) && !WINDOW_PSEUDO_P (w) && !EQ (window_header_line_format, Qnone) - && (!NILP (window_header_line_format) - || !NILP (BVAR (XBUFFER (WINDOW_BUFFER (w)), header_line_format))) + && (!null_header_line_format (window_header_line_format) + || !null_header_line_format (BVAR (XBUFFER (WINDOW_BUFFER (w)), header_line_format))) && (WINDOW_PIXEL_HEIGHT (w) > (window_wants_mode_line (w) ? 2 * WINDOW_FRAME_LINE_HEIGHT (w)