From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Aaron Jensen Newsgroups: gmane.emacs.bugs Subject: bug#63988: 30.0.50; Recent header line format changes cause spin/seg fault with format-mode-line Date: Sat, 10 Jun 2023 13:51:03 -0400 Message-ID: References: <831qij24qm.fsf@gnu.org> <83wn0bzoeb.fsf@gnu.org> <83h6rfz01q.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29084"; mail-complaints-to="usenet@ciao.gmane.io" Cc: me@eshelyaron.com, Stefan Monnier , 63988@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 10 19:52:20 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 1q82l9-0007MA-R4 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 10 Jun 2023 19:52:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q82ku-0005sy-6I; Sat, 10 Jun 2023 13:52: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 1q82ks-0005sa-DR for bug-gnu-emacs@gnu.org; Sat, 10 Jun 2023 13:52: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 1q82ks-0004kO-4U for bug-gnu-emacs@gnu.org; Sat, 10 Jun 2023 13:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q82kr-00038G-Vy for bug-gnu-emacs@gnu.org; Sat, 10 Jun 2023 13:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Aaron Jensen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Jun 2023 17:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63988 X-GNU-PR-Package: emacs Original-Received: via spool by 63988-submit@debbugs.gnu.org id=B63988.168641948311980 (code B ref 63988); Sat, 10 Jun 2023 17:52:01 +0000 Original-Received: (at 63988) by debbugs.gnu.org; 10 Jun 2023 17:51:23 +0000 Original-Received: from localhost ([127.0.0.1]:36224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q82kE-000377-Dn for submit@debbugs.gnu.org; Sat, 10 Jun 2023 13:51:22 -0400 Original-Received: from mail-pj1-f50.google.com ([209.85.216.50]:50414) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q82kC-00036v-KC for 63988@debbugs.gnu.org; Sat, 10 Jun 2023 13:51:21 -0400 Original-Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-25665d2a8bdso1279820a91.0 for <63988@debbugs.gnu.org>; Sat, 10 Jun 2023 10:51:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686419475; x=1689011475; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=L9M9qtwIUyNXnH0cLyKUYLw1XKTR4RYiDFGFVMLBLDk=; b=B7hBu3ELnqeu5njubg/rfTvzAkbb29utBhkUpsraqPSyBNAfnHppvGP486ah7nezpb /tyuzzeoxHKhrCkiwLiYBH2YcNsfHHlY2G5NgWdnkxOAT1ZEW6nmpcuHUQem6fY3sv49 fyLaOTVlDNqYCwTb4s0kU1PjZoDy5UzwLrSWTGsToJTw+xq/9uCBvrNglHbhyB/BtDRm nyu8QHaX9Mf8VkyZj57tG1KDBqI7K2kfKDtaaIOTf13NfeR/NTj6ET5VufVnSs7yIX4f 4nzQbgLo39NNmH066sZqEznIrqt1ELf9K3w5L2Bzh+BVGpVcLkW5609ovAUFw9WPLyAp 49ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686419475; x=1689011475; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L9M9qtwIUyNXnH0cLyKUYLw1XKTR4RYiDFGFVMLBLDk=; b=ZnA61HnDW9ATC+GJ1cwoq8ydjiwz3cl9KRRQsn5SpoLDwp7d09XOjMsky709yvm3mR e/JRqmB7f/I6BAcLsqjf53mldfbwv3wttsf4LtiTQyOgX8yYtT0RWm2k8+ZA9XHO9Xd5 4kkrZnRjmnzyp8YLos+h3QhMOJ6zOisrqdMi+TlpAJtQ/3Y6HaRcGByXVg+AOxE1YzEk kgaOrCbErTsBH+Od1Zull2vIZcQipd4Rn360EykU2ti5wwAS1/M2HheabPtwUsriwe88 Fj0YQOBhcIvNt7Gs9odWgnal0VUq6Xbz67ZU6EpPVPd3o28hBoLFyhhvtXKT8TinAeDa aJNA== X-Gm-Message-State: AC+VfDzxpdJlIk3BXne5Wj69d+kKyNtsQZzZTVB0odp0A5brcg1o2m1L LQ13CZdTKR0ATf4G+JvpRP0vACWfQOISNwwRdXA= X-Google-Smtp-Source: ACHHUZ4H/8j2X6aYS4L/64pSPVrQT7S2KY1SnWWZuLvo4AzmZjjd/+c8QgF1dfOVp6KAjWTFaa04Q1/sb+Z3DTpch6Q= X-Received: by 2002:a17:90a:aa0e:b0:25b:8664:c1e with SMTP id k14-20020a17090aaa0e00b0025b86640c1emr3930644pjq.27.1686419474615; Sat, 10 Jun 2023 10:51:14 -0700 (PDT) In-Reply-To: <83h6rfz01q.fsf@gnu.org> 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:263232 Archived-At: On Sat, Jun 10, 2023 at 1:42=E2=80=AFPM Eli Zaretskii wrote: > > > From: Stefan Monnier > > Cc: aaronjensen@gmail.com, Eshel Yaron , > > 63988@debbugs.gnu.org > > Date: Sat, 10 Jun 2023 12:16:45 -0400 > > > > >> It causes infinite recursion, since format-mode-line also calls > > >> window_wants_header_line (indirectly). > > > > I wonder why `format-mode-line` calls `window_wants_header_line`. > > Is there a deep technical reason, or just an accident of how we > > currently implement the feature? > > format-mode-line calls init_iterator (because the formatting is done > by display code), and init_iterator calls window_wants_header_line > because it needs to know the general layout of the window up front. > > We could introduce some knobs to perhaps avoid this in the particular > case of format-mode-line, but the :eval form in header-line-format can > call any Lisp, not necessarily format-mode-line. And the Lisp code > called from :eval could easily call some primitive that uses the > display code, for example vertical-motion or window-text-pixel-size or > something else. Going over all those places and making sure > init_iterator will not call window_wants_header_line in those cases is > not my idea of fun, even if it is practical to discern between the > cases where it does and doesn't need that. > > > > However, I wonder whether we should rethink this minor feature. > > > Perhaps this minor convenience is not worth the complications? > > > > IIUC This is talking about commit > > 4f66cbbfe520ee31ef26676e09a926217d9736fe which extends the special > > treatment of a nil `header-line-format` to also hide the header line > > when its value is "equivalent" to nil. > > > > In the past I've wished for a non-nil mode-line that is not displayed > > because it's equivalent to nil, so I think the feature makes sense, but > > I agree it's not super important. Maybe if we want to make it work > > well, the better solution is to memoize the computation of > > (format-mode-line header-line-format) so that it's called at most once > > per redisplay? > > That is possible, and I thought about it as well, but it isn't easy. > Once again: the display code is many times called for purposes other > than display, and in at least some of those cases it does need to know > whether there is a header-line, because the layout and the metrics of > the text on display depend on that. So the question of when to record > the fact of header-line existence for a particular window -- that > question doesn't have an easy answer. It is easy to compute that at > the beginning of redisplay_window, but what about the following > scenario in some Lisp program: > > . do some calculation that affects header-line existence > . call window-text-pixel-size > > and its many variations? Are we going to sprinkle the code with calls > to a function that calculates the header-line and records the result > somewhere (perhaps in a window) before each call to init_iterator and > start_display, and if so, how to avoid potential recursion like the > one in this case? > > Or maybe we want to use the variable-watcher feature to do that > whenever header-line-format is modified? That is also far from being > fun, and could cause performance degradation, as some people, I hear, > use header-line to display the mode-line information. > > Bottom line: this sounds like a minor convenience feature that causes > major headaches to implement, because once you allow evaluation of > arbitrary Lisp, all bets are basically off. > > Let's admit it: the current Emacs display code was not designed to > support this, so it's a little wonder we face an uphill battle. And > maybe we should just admit defeat and say we cannot support it until > and unless the display engine is redesigned with this goal in mind. I'm personally fine with this. I also wonder if the initial use-case that led to this feature could be handled instead by controlling the header line format when whatever factor changes that would determine whether or not to display a header line. I know I have to do this with mode line now that my mode line is typically nil, but I use it sometimes to display things like number of matches. Aaron