From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Jonas Bernoulli Newsgroups: gmane.emacs.bugs Subject: bug#38181: Actual height of mode-line not taken into account Date: Sat, 16 Nov 2019 16:27:12 +0100 Message-ID: <878sofon8v.fsf@bernoul.li> References: <87eeyd3ul0.fsf@bernoul.li> <83d0dt2qt6.fsf@gnu.org> <83r2290w24.fsf@gnu.org> <83pnhs6wwp.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="231854"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: mu4e 1.1.0; emacs 27.0.50 Cc: 38181@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Nov 16 16:28:34 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iW001-000yBQ-Ml for geb-bug-gnu-emacs@m.gmane.org; Sat, 16 Nov 2019 16:28:33 +0100 Original-Received: from localhost ([::1]:48638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iW000-0000HS-DU for geb-bug-gnu-emacs@m.gmane.org; Sat, 16 Nov 2019 10:28:32 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52711) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVzzZ-0000FF-Af for bug-gnu-emacs@gnu.org; Sat, 16 Nov 2019 10:28:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVzzY-0007XH-89 for bug-gnu-emacs@gnu.org; Sat, 16 Nov 2019 10:28:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58994) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iVzzY-0007X6-56 for bug-gnu-emacs@gnu.org; Sat, 16 Nov 2019 10:28:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iVzzW-0005yw-HS for bug-gnu-emacs@gnu.org; Sat, 16 Nov 2019 10:28:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jonas Bernoulli Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 16 Nov 2019 15:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38181 X-GNU-PR-Package: emacs Original-Received: via spool by 38181-submit@debbugs.gnu.org id=B38181.157391804022945 (code B ref 38181); Sat, 16 Nov 2019 15:28:02 +0000 Original-Received: (at 38181) by debbugs.gnu.org; 16 Nov 2019 15:27:20 +0000 Original-Received: from localhost ([127.0.0.1]:39582 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iVzyn-0005xz-Dd for submit@debbugs.gnu.org; Sat, 16 Nov 2019 10:27:17 -0500 Original-Received: from mail.hostpark.net ([212.243.197.30]:60168) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iVzyk-0005xo-Qo for 38181@debbugs.gnu.org; Sat, 16 Nov 2019 10:27:15 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 5BE9916640; Sat, 16 Nov 2019 16:27:13 +0100 (CET) X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Original-Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail1.hostpark.net [127.0.0.1]) (amavisd-new, port 10124) with ESMTP id aT2etsM1HJr3; Sat, 16 Nov 2019 16:27:12 +0100 (CET) Original-Received: from customer (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPSA id D0F40165CB; Sat, 16 Nov 2019 16:27:12 +0100 (CET) In-reply-to: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:171726 Archived-At: >> Could fit-window-to-buffer invoke >> 'redisplay' internally, perhaps? > > It could but it's called way too often to warrant such behavior by > default. But we could give it a separate optional argument so users > can avoid the advice. I think Jonas could easily write and a test a > patch along this idea. Again, the mode-line-prettifiers are not the ones who create new buffers and then call fit-buffer-to-window. It's arbitrary other packages that do that. An optional argument therefore would not help because when one of the prettifier modes is active, then each and every third-party caller of fit-buffer-to-window would have to pass that optional argument. This is the advice I currently use: (defvar-local moody--size-hacked-p nil) (defun moody-redisplay (&optional _force &rest _ignored) (unless moody--size-hacked-p (setq moody--size-hacked-p t) (redisplay t))) (advice-add 'fit-window-to-buffer :before #'moody-redisplay) Of course fit-buffer-to-window itself could be changed to do that and it could also be taught to only do so iff the user opted in to doing it. ---- Creating and displaying a new buffer and creating and resizing a new window surely *already* causes a "redisplay" without the programmer having to explicitly call `redisplay'. So if we explicitly tell fit-window-to-buffer to redisplay, then that means that we are redisplaying twice, right? I am under the impression (but this is just wild speculation) that redisplay only performs some of the necessary size calculations before doing the actual redisplaying. But some other calculations (including those concerning the mode-lien) are done only after the actual redisplaying has already happened. That is too late for this redisplay round but causes the values to be in place for all subsequent redisplays. So the fix could be to do the mode-line based calculations earlier?