From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#63825: 29.0.90; The header line should be hidden when empty Date: Fri, 02 Jun 2023 14:36:16 +0300 Message-ID: <83mt1iayfj.fsf@gnu.org> References: <838rd3cg7u.fsf@gnu.org> <83353bc97b.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39856"; mail-complaints-to="usenet@ciao.gmane.io" Cc: sbaugh@janestreet.com, 63825@debbugs.gnu.org To: Eshel Yaron Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 02 13:36:22 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 1q534w-000ACC-6u for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Jun 2023 13:36:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q534e-0005YL-9E; Fri, 02 Jun 2023 07:36:04 -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 1q534c-0005Xq-Bh for bug-gnu-emacs@gnu.org; Fri, 02 Jun 2023 07:36: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 1q534c-0007Px-3D for bug-gnu-emacs@gnu.org; Fri, 02 Jun 2023 07:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q534b-00018r-QN for bug-gnu-emacs@gnu.org; Fri, 02 Jun 2023 07:36:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Jun 2023 11:36: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.16857057554376 (code B ref 63825); Fri, 02 Jun 2023 11:36:01 +0000 Original-Received: (at 63825) by debbugs.gnu.org; 2 Jun 2023 11:35:55 +0000 Original-Received: from localhost ([127.0.0.1]:39180 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q534S-00018S-LL for submit@debbugs.gnu.org; Fri, 02 Jun 2023 07:35:55 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:55678) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q534N-00018B-Ho for 63825@debbugs.gnu.org; Fri, 02 Jun 2023 07:35:51 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q534H-0007NM-LQ; Fri, 02 Jun 2023 07:35:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=sWlcmlghHymqw1SGfoP/DxxcWMGx+Hxn0FDTBJFbvv8=; b=Pdso5g2EBsrT bk4IkQtNobp4ww9vFFrukjCrgqybATX8tdzhWlfEgYF4bo8mJthzpK9R3GZRToT0mX85rS6RDsNtt LlDw+0rVXpxgY8RKjta3lDfMp9c5TzVVMvBTAR++I2oR5tgUkm7zwULhNtK+PyShcaCsxTzMar3pE iqkiKf9avNZdSG/ooPlcFMo0FchRw3Gn69WrJCFqPiyoDatVCcFv1tBpQzlHA6MAcNQVzJytdnFug +qYcsMKsvK/2BvjX4TAMiDeToZh9jQ9GMfhKGohzvOZjumOxNcAQ1A/ku20Nqxgd67K4zpoJI5H4k 3ntusdvfSYyTfW5sIiYLcQ==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q5344-0006Sk-7r; Fri, 02 Jun 2023 07:35:41 -0400 In-Reply-To: (message from Eshel Yaron on Fri, 02 Jun 2023 09:19:17 +0300) 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:262751 Archived-At: > From: Eshel Yaron > Cc: Eli Zaretskii , 63825@debbugs.gnu.org > Date: Fri, 02 Jun 2023 09:19:17 +0300 > > 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. Yes. > 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. Right. > 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): Thanks, this is an elegant solution. A few minor comments: > +/** > + * null_header_line_format: > + * > + * Return 1 when header line format F indicates that the header line > + * should not be displayed at all. We usually say "Return non-zero", not 1. > + * 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) The argument should be called fmt or somesuch. When I see 'f' in the C sources, I assume it's a pointe to 'struct frame'. > + if (NILP (f)) > + return 1; ^^^^^^^^^ This should say "return true;" instead, since the function is declared as returning a 'bool'. > + if (CONSP (f)) { This is not our style: we put the opening and closing braces on lines of their own; see the rest of the code around. > + car = XCAR (f); > + return (SYMBOLP (car) > + && ((EQ (car, QCeval) > + && NILP (Feval (XCAR (XCDR (f)), Qnil))) > + || NILP (find_symbol_value (car)))); find_symbol_value can return Qunbound, which is non-nil, but this function should treat it as if it were nil (see the documentation of mode-line-format). > + return 0; "return false;" > @@ -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))) This line is too long, and should be broken, probably before header_line_format. And finally, please accompany the change with a suitable commit log message, an entry in NEWS, and a change for the ELisp manual.