From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.bugs Subject: bug#72771: 31.0.50; shr html renderer throwing "Specified window is not displaying the current buffer" Date: Sat, 24 Aug 2024 10:10:06 -0700 Message-ID: References: <875xrrr6x3.fsf@hw.ac.uk> <861q2fqt6r.fsf@gnu.org> <875xrrcgia.fsf@gmail.com> <3482d616-8a1c-d458-8da4-1b9d12ff32c5@gmail.com> <867cc6pi5b.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35646"; mail-complaints-to="usenet@ciao.gmane.io" Cc: R.Stewart@hw.ac.uk, 72771@debbugs.gnu.org, kevin.legouguec@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 24 19:12:35 2024 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 1shuJW-00098T-Ln for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 24 Aug 2024 19:12:34 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1shuJD-00021i-IQ; Sat, 24 Aug 2024 13:12:15 -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 1shuJB-00021E-Re for bug-gnu-emacs@gnu.org; Sat, 24 Aug 2024 13:12:13 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1shuJB-00075p-J6 for bug-gnu-emacs@gnu.org; Sat, 24 Aug 2024 13:12:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=In-Reply-To:From:References:MIME-Version:Date:To:Subject; bh=6J3Na5FFBt07tVXW/Ynxv+PkVFjdoRglBxVS5dVDz9s=; b=XvUKp/eNoe75FAMkrVqf1IU59htEEuZRmHjBHD4TwR8N3vdr9ueblVvuzcdSDRcOkHInqkMzpaHFtsgJmob3nR5BVUIiOjEc72yMKgZJ+Hp38px38crTrZmB4jUy5wTrOhCVXb4Y/FWV/kR3vwPXbErrK/CYPdxb6OV4mv9bCVV8z5+cVG7NTEbvXE62KPTJ6sYyzuzkc40060iS4iS+jIoIs2BN0DYUZwjFjIV8QDjkTHpkCpZFw3P+73I0UGvYeYBXDaah1wOQOFC3VVQ39NOCHymhUbsyNULPEiry5+wGgbxeZ+sWS0UxraTl1RVRUh3vYQugfcmNMz8vzD8VHw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1shuJy-0005KC-1X for bug-gnu-emacs@gnu.org; Sat, 24 Aug 2024 13:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 24 Aug 2024 17:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72771 X-GNU-PR-Package: emacs Original-Received: via spool by 72771-submit@debbugs.gnu.org id=B72771.172451952320386 (code B ref 72771); Sat, 24 Aug 2024 17:13:02 +0000 Original-Received: (at 72771) by debbugs.gnu.org; 24 Aug 2024 17:12:03 +0000 Original-Received: from localhost ([127.0.0.1]:41837 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1shuJ1-0005Ij-0n for submit@debbugs.gnu.org; Sat, 24 Aug 2024 13:12:03 -0400 Original-Received: from mail-pg1-f182.google.com ([209.85.215.182]:43034) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1shuIz-0005IC-7O for 72771@debbugs.gnu.org; Sat, 24 Aug 2024 13:12:02 -0400 Original-Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-7cd8afc9ff3so2812534a12.0 for <72771@debbugs.gnu.org>; Sat, 24 Aug 2024 10:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724519406; x=1725124206; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=6J3Na5FFBt07tVXW/Ynxv+PkVFjdoRglBxVS5dVDz9s=; b=AtpGuSRh5nnxPyLZIH/S59blv/KbzZ7bZg8YmN67N8uYMjK+5DtkpqCHFfPMTk4OAP kF85v35TvWS7sBaLLZdCDcGm4ic5YC/SI5ltPvEUUYUFJBrEA4ESEa43qg6yGg9CavIQ lVrTEsouYpTesnSaHQvJm8XldhM2yeb5KoGLwcx8GnTUmthnpNRJjBOiOrfKtYIynexI wAprM/DAD9UK+xAfqJ8EyifnDZyvIdv5Kw41VHhyO2PWozpBGMd9Q+yFY4vhSCpJxxMJ ZsDWEm5dJVh12+ev8VyRwDK/sorLJv8sDFitLJSXPsJY7rblmtRUQgg6PPC6CGKmNvwW gn6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724519406; x=1725124206; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6J3Na5FFBt07tVXW/Ynxv+PkVFjdoRglBxVS5dVDz9s=; b=fO5wNUX6QN32s8kkBpmjin+RMjn6jZY2pm9vtZD74YzEPWETfTmOH98NQqqAh+FMIr EBgeMCfNzEXgPUcIpJx4TBanYeg/yetLEZDtf6eqQ/96hRKSM+NENd+68k1uDTM+ASF8 YlCOJUhttXiEdjPhQubKnAD1AvEy9LI0jfyUcB4mRmMrOXl7pInE2Ux8yJDGFGmnqKo9 V6ws6DeC5bfd00DR+8YbY9o/sv+vW+6U9eTtCnUdDWlOTkpqmEBVay4sRasOQT70cpB/ tBOyNXLRTkE2OZAoRG+FOsGQKQlT8MQhG997l0Yy63q421VDdsUyq4DBCcymBtR7lQeT PKAQ== X-Forwarded-Encrypted: i=1; AJvYcCVRkyyBO99Xdg/f35pFO8aPWaNsomD3xULl3FMkHw4h4SInMULe0uHkRKtBGyrufrUASUwlow==@debbugs.gnu.org X-Gm-Message-State: AOJu0YyqURwq1ApSeIKgNRp1GT+WAkdU/0T7o9TJiO85GhQ9Bg/XXH6p 8G7sjnznKYcgAdFIfYkJquhtM4qV9WiAIMqUy5z6hVTO0mXw+my5 X-Google-Smtp-Source: AGHT+IHjJR1Qgvzpquv3ZmgvkBHrwfHGOxIR5dl5DozpJsLALv468qtm+C23ThVmlZ35N3m3fKckSg== X-Received: by 2002:a17:90b:3889:b0:2d3:acbd:307b with SMTP id 98e67ed59e1d1-2d60a9363b3mr15456048a91.10.1724519405773; Sat, 24 Aug 2024 10:10:05 -0700 (PDT) Original-Received: from [192.168.1.2] (syn-023-240-098-037.res.spectrum.com. [23.240.98.37]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2d5ebbb17d9sm8677467a91.43.2024.08.24.10.10.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 24 Aug 2024 10:10:05 -0700 (PDT) Content-Language: en-US In-Reply-To: <867cc6pi5b.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:290685 Archived-At: On 8/23/2024 11:08 PM, Eli Zaretskii wrote: >> Date: Fri, 23 Aug 2024 15:39:00 -0700 >> Cc: Rob Stewart , 72771@debbugs.gnu.org >> From: Jim Porter >> >> Here's a patch. I've tested this in a few configurations (in the current >> window, in a buffer that's not being displayed, in a terminal Emacs) and >> it all seems to work. >> >> One question, Eli: is there a better way than I'm using to get the font >> that would be used for a character in the buffer? When the buffer is >> being displayed in a window, '(font-at position window)' works, but that >> doesn't address this bug, where the buffer isn't displayed. (The font >> that we get back doesn't have to be 100% accurate; just a good guess >> should be fine for this case.) > > AFAIU, the code needs the width of the space character of a font used > to show some text, is that correct? Close, it needs the "average width", since the goal is to make a pixel specification like "(1.23 . width)". Based on my reading of 'calc_pixel_width_or_height' in xdisp.c, the average width is the value the display engine uses for the 'width' unit. > And the patch solves the problem of font-at by pretending that the > relevant text is displayed in the current window, is that correct? Yep. I figure there's a very good chance that the text in question (which is already in the current buffer) will soon be displayed in the current window, or failing that, a different window in the same frame. So it seemed like an ok guess to me. (Also, even if we guess wrong, things should usually look fine; it would only fail with certain pathological fonts, and even then it would just be a slight visual misalignment.) > Alternatives to the solution in the patch are: Thanks for the suggestions. (I reordered the list below when replying.) > . use the font obtained from (face-font 'default) (or the actual face > of the text, if you can get at it easily), like this: > > (aref (font-info (face-font 'default)) 10) I think the problem is getting the actual face, which works for simple cases via 'get-text-property', but not for more complex ones, e.g. when the 'face' property is a list; 'face-font' raises an error in that case. Effectively what I want would be a Lisp version of 'face_at_buffer_position', but that requires a window object anyway, so I'm back to the original problem... > . temporarily display the buffer in some window (if there is already > a window showing the buffer, use with-selected-window) That could work, though I think it ends up being just as much code complexity as my current patch, and it might perform worse with all the temporary window-switching... > . use buffer-text-pixel-size or string-pixel-width to measure the > width of a string of a single SPC character I think this wouldn't work since I want the average font width, not the width of SPC. In light of the above, I think what I have now might be the best way to do it for the time being, unless my comments above gave you another idea for an alternative. If not, do you have any objections to me merging this patch?