emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master a876c4d7a17: Improve SHR/EWW support for 'visual-wrap-prefix-


From: Jim Porter
Subject: Re: master a876c4d7a17: Improve SHR/EWW support for 'visual-wrap-prefix-mode'
Date: Wed, 21 Aug 2024 12:01:50 -0700

On 8/21/2024 10:50 AM, Kévin Le Gouguec wrote:
Eshel Yaron <me@eshelyaron.com> writes:

Hello Jim,

Jim Porter <jporterbugs@gmail.com> writes:

branch: master
commit a876c4d7a17df152e3e78800c76ddf158f632ee5
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Jim Porter <jporterbugs@gmail.com>

     Improve SHR/EWW support for 'visual-wrap-prefix-mode'
[...]

Thanks for this!

It seems like this change breaks Elfeed though, namely:
[snip]
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 noticing this. It'd be good to make the "get the average width of the font" bit work properly in all cases.

That said, this is *also* a bug in Elfeed. SHR just works a lot better if the buffer is displayed in a window before rendering the HTML out. See <https://github.com/skeeto/elfeed/pull/521>.

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))

Assuming this is working for you, I think this patch makes sense and you can feel free to merge it.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]