From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?K=C3=A9vin_Le_Gouguec?= Newsgroups: gmane.emacs.devel Subject: Re: master a876c4d7a17: Improve SHR/EWW support for 'visual-wrap-prefix-mode' Date: Wed, 21 Aug 2024 19:50:34 +0200 Message-ID: <87o75lkbo5.fsf@gmail.com> References: <172402253530.16373.1641341718329436871@vcs2.savannah.gnu.org> <20240818230855.B0A94C2BC6D@vcs2.savannah.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="18175"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org, Jim Porter To: Eshel Yaron Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Aug 21 19:51:04 2024 Return-path: Envelope-to: ged-emacs-devel@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 1sgpU6-0004XW-Hi for ged-emacs-devel@m.gmane-mx.org; Wed, 21 Aug 2024 19:51:02 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sgpTo-0003CP-7y; Wed, 21 Aug 2024 13:50:44 -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 1sgpTm-00035U-1g for emacs-devel@gnu.org; Wed, 21 Aug 2024 13:50:42 -0400 Original-Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sgpTh-0000JS-Ub for emacs-devel@gnu.org; Wed, 21 Aug 2024 13:50:41 -0400 Original-Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3718ea278a8so186991f8f.3 for ; Wed, 21 Aug 2024 10:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724262636; x=1724867436; darn=gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fAKvSf41P3yxEPDHCHt+gWF29Uh7dW+nmRxWNGEg2FM=; b=EvPgxJFBl9HhPvvOVCXS74Aspdk6aTkRanuK3nxmc4aiFqD0eM5kjOUaqJHd+3cc6M /XEnuT4c2peoEoMoWh3TNqQvrB8kUwPcsKwFrvKbDdHyLgwlmhGvNJ5IcjGe1gb05flC JEASRwnj5aqtiPbgYNGZjD3CgtefLqCtSczBm/JMq7XTZCRCQFGvMvVCQy811OMAqqTB fV74neLgGe9Qn7cs9CW7LpYUBWx0DO/iuQ2Hu2gGPQs2NLGWRq76qlDSiDznF1NhM6wK mx1J0yx5/E11WKriXJZVzg+vRpTnKvl2QVkhIC7LIm+qUai7nu9ca07I+/jeFgohWoK0 7mEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724262636; x=1724867436; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=fAKvSf41P3yxEPDHCHt+gWF29Uh7dW+nmRxWNGEg2FM=; b=S48o58JbMQrSeZy5yo9WvtFrbxjTJORA92kYyynuij98lZTPsXyKzVpv7Tq8Lmnlx5 ba/KhdX4rVft3BnqeKqG4FOdi/iFwQraY50TD6lqA33Kba4ytd+HCPh6pym5deqR/NtU 17St4W2kbIWE2PcFUawdDa3H/3YY+aNqtA4soKV2TLYg+a4YnH7kZ+0jnMshjsseEXub 1EdnakAwY7mjkkijdgmOBM8K/RZ1IeEIFWoqugwpKMUrTwsObqWQyEfjJ0+DDDK6M5kU SEpEeRz7mxXXyBZY5Gz0QMWgQ3o63el4AH4BrlrTIt9bQ/LnKfZ6MhnvcKE/ofMAMjTf VEOg== X-Gm-Message-State: AOJu0YyzQpU2OS8Sn6EH+RN0mX+QJ++rvtbUvcBPcRkxIIoGHatrtvYR DLudDY2uGWjDlPtZHACgp8z0O6MV3zKs1ZbKWRZ9SAozdLwG8Zhwskm+xA== X-Google-Smtp-Source: AGHT+IFJu3DDAdDFYNJoS7bT4/Cu2zguWuooxKYJbxa6S07Ay2VksSE0zjBvNPRAJELCk7Yzb5a9AQ== X-Received: by 2002:a05:600c:1ca0:b0:427:f1a9:cb06 with SMTP id 5b1f17b1804b1-42abef82886mr13739315e9.0.1724262635851; Wed, 21 Aug 2024 10:50:35 -0700 (PDT) Original-Received: from amdahl30 ([2a01:e0a:253:fe0:2ef0:5dff:fed2:7b49]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42abf019dadsm33958005e9.48.2024.08.21.10.50.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 10:50:35 -0700 (PDT) In-Reply-To: (Eshel Yaron's message of "Wed, 21 Aug 2024 13:33:25 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=kevin.legouguec@gmail.com; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:323018 Archived-At: Eshel Yaron writes: > Hello Jim, > > Jim Porter writes: > >> branch: master >> commit a876c4d7a17df152e3e78800c76ddf158f632ee5 >> Author: Jim Porter >> Commit: Jim Porter >> >> Improve SHR/EWW support for 'visual-wrap-prefix-mode' >>=20=20=20=20=20 > [...] > > Thanks for this! > > It seems like this change breaks Elfeed though, namely: > >> (defun shr-indent () >> (when (> shr-indentation 0) >> - (if (not shr-use-fonts) >> - (insert-char ?\s shr-indentation) >> - (insert ?\s) >> - (put-text-property (1- (point)) (point) >> - 'display `(space :width (,shr-indentation)))))) >> + (let ((start (point)) >> + (prefix (or (get-text-property (point) 'shr-prefix-length) 0)= )) >> + (if (not shr-use-fonts) >> + (insert-char ?\s shr-indentation) >> + (insert ?\s) >> + (put-text-property >> + (1- (point)) (point) 'display >> + ;; Set the specified space width in terms of the default width >> + ;; of the current face, like (N . width). That way, the >> + ;; indentation is calculated correctly when using >> + ;; `text-scale-adjust'. >> + `(space :width (,(if-let ((font (font-at (1- (point)))) >> + (info (query-font font))) >> + (/ (float shr-indentation) (aref info 7)) >> + shr-indentation) >> + . width)))) >> + (put-text-property start (+ (point) prefix) >> + 'shr-prefix-length (+ prefix (- (point) start)= ))))) > > This call to font-at throws an error unless the current buffer happens > to be displayed in the selected window. This affects elfeed-show-entry, > for example. Thanks for raising this; FWIW I noticed a simliar issue with Gnus, where I add visual-wrap-prefix-mode to gnus-article-prepare-hook. Don't have a backtrace handy, but had convinced myself that the faulty font-at was this one in visual-wrap--content-prefix=E2=80=A6 (if-let ((font (font-at position)) (info (query-font font))) =E2=80=A6) =E2=80=A6 from 2024-08-04 "Add support for variable-pitch fonts in 'visual-wrap-prefix-mode'" (f70a6ea0ea8); and so meant to submit this=E2=80= =A6 diff --git a/lisp/visual-wrap.el b/lisp/visual-wrap.el index 902a9e41c5e..975ccab3adb 100644 --- a/lisp/visual-wrap.el +++ b/lisp/visual-wrap.el @@ -164,7 +164,8 @@ visual-wrap--content-prefix ;; width of the first-line prefix in canonical-width characters. ;; This is useful if the first-line prefix uses some very-wide ;; characters. - (if-let ((font (font-at position)) + (if-let ((window (get-buffer-window (current-buffer))) + (font (font-at position window)) (info (query-font font))) (max (string-width prefix) (ceiling (string-pixel-width prefix (current-buffer)) =E2=80=A6 but meant to research & test more before submitting.