unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#72485: Support 'visual-wrap-prefix-mode' in SHR/EWW
@ 2024-08-06  3:47 Jim Porter
  2024-08-17  8:55 ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Jim Porter @ 2024-08-06  3:47 UTC (permalink / raw)
  To: 72485

[-- Attachment #1: Type: text/plain, Size: 1308 bytes --]

This patch is an extension of bug#71605, and the first place to 
explicitly use the new variable-pitch support for 
'visual-wrap-prefix-mode'. While implementing this, I found two small 
bugs in the new 'visual-wrap-prefix-mode' code:

1. When setting the min-width for the first line prefix, we should use 
'add-display-text-property' so as not to clobber other display properties.

2. My attempts to be "helpful" by special-casing wrap-prefixes of all 
spaces ended up just interfering with more complex cases (like SHR), so 
I removed it. The code is now simpler (one fewer condition) and just 
works more smoothly overall.

There's one limitation to this patch though: since SHR uses absolute 
pixel-widths for indenting internally, things can look mis-indented if 
you scale the text in the buffer. However, SHR has exactly the same 
issue when *not* using 'visual-wrap-prefix-mode', so it's really just a 
more-general bug in SHR. (It'd be nice to fix that, but I'd have to get 
a better understanding of how indentation and <table> elements interact.)

Attached is a test HTML page that shows off the indentation. You can see 
the results by running:

   emacs -Q --eval '(progn (setq shr-fill-text nil) (eww "test.html"))'

(And also compare to the default behavior where 'shr-fill-text' is non-nil.)

[-- Attachment #2: 0001-Improve-SHR-EWW-support-for-visual-wrap-prefix-mode.patch --]
[-- Type: text/plain, Size: 4945 bytes --]

From 5e1de09af5398bd0a60683ebf53bef3f87440a91 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sun, 4 Aug 2024 19:37:00 -0700
Subject: [PATCH] Improve SHR/EWW support for 'visual-wrap-prefix-mode'

* lisp/visual-wrap.el (visual-wrap--apply-to-line): Use
'add-display-text-property' so we don't clobber other display
properties.
(visual-wrap--content-prefix): Remove special-case for spaces-only
indent prefix; this was an attempt to be helpful for variable-pitch
fonts, but in practice just interferes with matters.  This case now
falls back to the one immediately following it (return the string of
spaces).)

* lisp/net/shr.el (shr-indent): Set 'shr-prefix-length' here to help
keep track of the prefixes of nestedly-indented elements.
* lisp/net/shr.el (shr-adaptive-fill-function): Use 'shr-prefix-length'
as set above to return a fill prefix.

* lisp/net/eww.el (eww-render): Enable 'visual-wrap-prefix-mode'
alongside of 'visual-line-mode'.
(eww-mode): Set 'adaptive-fill-function' to
'shr-adaptive-fill-function'.
---
 lisp/net/eww.el     |  5 ++++-
 lisp/net/shr.el     | 19 ++++++++++++++-----
 lisp/visual-wrap.el | 12 +++---------
 3 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index b2e1c5a72e5..b5d2f20781a 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -709,7 +709,8 @@ eww-render
 	      (and last-coding-system-used
 		   (set-buffer-file-coding-system last-coding-system-used))
               (unless shr-fill-text
-                (visual-line-mode))
+                (visual-line-mode)
+                (visual-wrap-prefix-mode))
 	      (run-hooks 'eww-after-render-hook)
               ;; Enable undo again so that undo works in text input
               ;; boxes.
@@ -1336,6 +1337,8 @@ eww-mode
   ;; desktop support
   (setq-local desktop-save-buffer #'eww-desktop-misc-data)
   (setq truncate-lines t)
+  ;; visual-wrap-prefix-mode support
+  (setq-local adaptive-fill-function #'shr-adaptive-fill-function)
   ;; thingatpt support
   (setq-local thing-at-point-provider-alist
               (cons '(url . eww--url-at-point)
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index d3c48b34428..a0f9cd252d2 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -938,6 +938,11 @@ shr-fill-line
         (when (looking-at " $")
 	  (delete-region (point) (line-end-position)))))))
 
+(defun shr-adaptive-fill-function ()
+  "Return a fill prefix for the paragraph at point."
+  (when-let ((prefix (get-text-property (point) 'shr-prefix-length)))
+    (buffer-substring (point) (+ (point) prefix))))
+
 (defun shr-parse-base (url)
   ;; Always chop off anchors.
   (when (string-match "#.*" url)
@@ -1041,11 +1046,15 @@ shr-ensure-paragraph
 
 (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 start (point)
+                           'display `(space :width (,shr-indentation))))
+      (put-text-property start (+ (point) prefix)
+                         'shr-prefix-length (+ prefix (- (point) start))))))
 
 (defun shr-fontize-dom (dom &rest types)
   (let ((start (point)))
diff --git a/lisp/visual-wrap.el b/lisp/visual-wrap.el
index cac3bc767b8..51c0213a037 100644
--- a/lisp/visual-wrap.el
+++ b/lisp/visual-wrap.el
@@ -121,9 +121,9 @@ visual-wrap--apply-to-line
                (next-line-prefix (visual-wrap--content-prefix
                                   first-line-prefix position)))
       (when (numberp next-line-prefix)
-        (put-text-property
-         position (+ position (length first-line-prefix)) 'display
-         `(min-width ((,next-line-prefix . width)))))
+        (add-display-text-property
+         position (+ position (length first-line-prefix)) 'min-width
+         `((,next-line-prefix . width))))
       (setq next-line-prefix (visual-wrap--adjust-prefix next-line-prefix))
       (put-text-property
        position (line-end-position) 'wrap-prefix
@@ -141,12 +141,6 @@ visual-wrap--content-prefix
   (cond
    ((string= prefix "")
     nil)
-   ((string-match (rx bos (+ blank) eos) prefix)
-    ;; If the first-line prefix is all spaces, return its width in
-    ;; characters.  This way, we can set the prefix for all lines to use
-    ;; the canonical-width of the font, which helps for variable-pitch
-    ;; fonts where space characters are usually quite narrow.
-    (string-width prefix))
    ((or (and adaptive-fill-first-line-regexp
              (string-match adaptive-fill-first-line-regexp prefix))
         (and comment-start-skip
-- 
2.25.1


[-- Attachment #3: test.html --]
[-- Type: text/html, Size: 2827 bytes --]

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* bug#72485: Support 'visual-wrap-prefix-mode' in SHR/EWW
  2024-08-06  3:47 bug#72485: Support 'visual-wrap-prefix-mode' in SHR/EWW Jim Porter
@ 2024-08-17  8:55 ` Eli Zaretskii
  2024-08-18  0:30   ` Jim Porter
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2024-08-17  8:55 UTC (permalink / raw)
  To: Jim Porter; +Cc: 72485

> Date: Mon, 5 Aug 2024 20:47:52 -0700
> From: Jim Porter <jporterbugs@gmail.com>
> 
> This patch is an extension of bug#71605, and the first place to 
> explicitly use the new variable-pitch support for 
> 'visual-wrap-prefix-mode'. While implementing this, I found two small 
> bugs in the new 'visual-wrap-prefix-mode' code:
> 
> 1. When setting the min-width for the first line prefix, we should use 
> 'add-display-text-property' so as not to clobber other display properties.
> 
> 2. My attempts to be "helpful" by special-casing wrap-prefixes of all 
> spaces ended up just interfering with more complex cases (like SHR), so 
> I removed it. The code is now simpler (one fewer condition) and just 
> works more smoothly overall.
> 
> There's one limitation to this patch though: since SHR uses absolute 
> pixel-widths for indenting internally, things can look mis-indented if 
> you scale the text in the buffer. However, SHR has exactly the same 
> issue when *not* using 'visual-wrap-prefix-mode', so it's really just a 
> more-general bug in SHR. (It'd be nice to fix that, but I'd have to get 
> a better understanding of how indentation and <table> elements interact.)

Thanks.  This lacks a NEWS entry, but other than that, feel fee to
install on master when ready.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#72485: Support 'visual-wrap-prefix-mode' in SHR/EWW
  2024-08-17  8:55 ` Eli Zaretskii
@ 2024-08-18  0:30   ` Jim Porter
  2024-08-18  4:49     ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Jim Porter @ 2024-08-18  0:30 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 72485

[-- Attachment #1: Type: text/plain, Size: 1045 bytes --]

On 8/17/2024 1:55 AM, Eli Zaretskii wrote:
>> Date: Mon, 5 Aug 2024 20:47:52 -0700
>> From: Jim Porter <jporterbugs@gmail.com>
>>
>> There's one limitation to this patch though: since SHR uses absolute
>> pixel-widths for indenting internally, things can look mis-indented if
>> you scale the text in the buffer. However, SHR has exactly the same
>> issue when *not* using 'visual-wrap-prefix-mode', so it's really just a
>> more-general bug in SHR. (It'd be nice to fix that, but I'd have to get
>> a better understanding of how indentation and <table> elements interact.)
> 
> Thanks.  This lacks a NEWS entry, but other than that, feel fee to
> install on master when ready.

Thanks for taking a look. I've added a NEWS entry (see attached). I also 
improved the implementation a bit, so the above-mentioned limitation is 
no longer a problem. Now, SHR/EWW will indent things properly even when 
using 'text-scale-adjust'.

(The additional changes aren't major, so I'll probably merge this in a 
day or two once I've had time to sleep on it.)

[-- Attachment #2: 0001-Improve-SHR-EWW-support-for-visual-wrap-prefix-mode.patch --]
[-- Type: text/plain, Size: 6862 bytes --]

From 8cef1852bfe4dbdf53b063faeacdb1e6a85d15c2 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sun, 4 Aug 2024 19:37:00 -0700
Subject: [PATCH] Improve SHR/EWW support for 'visual-wrap-prefix-mode'

* lisp/visual-wrap.el (visual-wrap--apply-to-line): Use
'add-display-text-property' so we don't clobber other display
properties.
(visual-wrap--content-prefix): Remove special-case for spaces-only
indent prefix; this was an attempt to be helpful for variable-pitch
fonts, but in practice just interferes with matters.  This case now
falls back to the one immediately following it (return the string of
spaces).  Use 'string-pixel-width' instead of 'string-width'.

* lisp/net/shr.el (shr-indent): Set 'shr-prefix-length' here to help
keep track of the prefixes of nestedly-indented elements.  Set the
specified space width in terms of the default width of the current face.
* lisp/net/shr.el (shr-adaptive-fill-function): Use 'shr-prefix-length'
as set above to return a fill prefix.

* lisp/net/eww.el (eww-render): Enable 'visual-wrap-prefix-mode'
alongside of 'visual-line-mode'.
(eww-mode): Set 'adaptive-fill-function' to
'shr-adaptive-fill-function'.

* etc/NEWS: Announce this change (bug#72485).
---
 etc/NEWS            |  8 ++++++++
 lisp/net/eww.el     |  5 ++++-
 lisp/net/shr.el     | 28 +++++++++++++++++++++++-----
 lisp/visual-wrap.el | 18 ++++++++----------
 4 files changed, 43 insertions(+), 16 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 8cd21f5fb74..5063e754730 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -144,6 +144,14 @@ Advanced" node in the EWW manual.
 By customizing 'shr-image-zoom-levels', you can change the list of zoom
 levels that SHR cycles through when calling 'shr-zoom-image'.
 
+** EWW
+
+---
+*** EWW now enables 'visual-wrap-prefix-mode' when 'shr-fill-text' is nil.
+This improves the display of multiline, indented text, such as block
+quotes or (un)ordered lists.  Now, the wrapped lines of indented text
+will line up visually with the first line.
+
 ** Go-ts mode
 
 +++
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index b2e1c5a72e5..b5d2f20781a 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -709,7 +709,8 @@ eww-render
 	      (and last-coding-system-used
 		   (set-buffer-file-coding-system last-coding-system-used))
               (unless shr-fill-text
-                (visual-line-mode))
+                (visual-line-mode)
+                (visual-wrap-prefix-mode))
 	      (run-hooks 'eww-after-render-hook)
               ;; Enable undo again so that undo works in text input
               ;; boxes.
@@ -1336,6 +1337,8 @@ eww-mode
   ;; desktop support
   (setq-local desktop-save-buffer #'eww-desktop-misc-data)
   (setq truncate-lines t)
+  ;; visual-wrap-prefix-mode support
+  (setq-local adaptive-fill-function #'shr-adaptive-fill-function)
   ;; thingatpt support
   (setq-local thing-at-point-provider-alist
               (cons '(url . eww--url-at-point)
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index d3c48b34428..b9ac9f0c8c0 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -938,6 +938,11 @@ shr-fill-line
         (when (looking-at " $")
 	  (delete-region (point) (line-end-position)))))))
 
+(defun shr-adaptive-fill-function ()
+  "Return a fill prefix for the paragraph at point."
+  (when-let ((prefix (get-text-property (point) 'shr-prefix-length)))
+    (buffer-substring (point) (+ (point) prefix))))
+
 (defun shr-parse-base (url)
   ;; Always chop off anchors.
   (when (string-match "#.*" url)
@@ -1041,11 +1046,24 @@ shr-ensure-paragraph
 
 (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))))))
 
 (defun shr-fontize-dom (dom &rest types)
   (let ((start (point)))
diff --git a/lisp/visual-wrap.el b/lisp/visual-wrap.el
index cac3bc767b8..56d58ef1d60 100644
--- a/lisp/visual-wrap.el
+++ b/lisp/visual-wrap.el
@@ -121,9 +121,9 @@ visual-wrap--apply-to-line
                (next-line-prefix (visual-wrap--content-prefix
                                   first-line-prefix position)))
       (when (numberp next-line-prefix)
-        (put-text-property
-         position (+ position (length first-line-prefix)) 'display
-         `(min-width ((,next-line-prefix . width)))))
+        (add-display-text-property
+         position (+ position (length first-line-prefix)) 'min-width
+         `((,next-line-prefix . width))))
       (setq next-line-prefix (visual-wrap--adjust-prefix next-line-prefix))
       (put-text-property
        position (line-end-position) 'wrap-prefix
@@ -141,12 +141,6 @@ visual-wrap--content-prefix
   (cond
    ((string= prefix "")
     nil)
-   ((string-match (rx bos (+ blank) eos) prefix)
-    ;; If the first-line prefix is all spaces, return its width in
-    ;; characters.  This way, we can set the prefix for all lines to use
-    ;; the canonical-width of the font, which helps for variable-pitch
-    ;; fonts where space characters are usually quite narrow.
-    (string-width prefix))
    ((or (and adaptive-fill-first-line-regexp
              (string-match adaptive-fill-first-line-regexp prefix))
         (and comment-start-skip
@@ -169,7 +163,11 @@ visual-wrap--content-prefix
         (max (string-width prefix)
              (ceiling (string-pixel-width prefix (current-buffer))
                       (aref info 7)))
-      (string-width prefix)))))
+      ;; We couldn't get the font, so we're in a terminal and
+      ;; `string-pixel-width' is really returning the number of columns.
+      ;; (This is different from `string-width', since that doesn't
+      ;; respect specified spaces.)
+      (string-pixel-width prefix)))))
 
 (defun visual-wrap-fill-context-prefix (beg end)
   "Compute visual wrap prefix from text between BEG and END.
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* bug#72485: Support 'visual-wrap-prefix-mode' in SHR/EWW
  2024-08-18  0:30   ` Jim Porter
@ 2024-08-18  4:49     ` Eli Zaretskii
  2024-08-18  6:13       ` Jim Porter
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2024-08-18  4:49 UTC (permalink / raw)
  To: Jim Porter; +Cc: 72485

> Date: Sat, 17 Aug 2024 17:30:10 -0700
> Cc: 72485@debbugs.gnu.org
> From: Jim Porter <jporterbugs@gmail.com>
> 
> +** EWW
> +
> +---
> +*** EWW now enables 'visual-wrap-prefix-mode' when 'shr-fill-text' is nil.
> +This improves the display of multiline, indented text, such as block
> +quotes or (un)ordered lists.  Now, the wrapped lines of indented text
> +will line up visually with the first line.

I'm not sure many users know about shr-fill-text, including that its
default is non-nil.  So I think this NEWS entry should say something
about that, otherwise this text might cause incorrect user
expectations.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#72485: Support 'visual-wrap-prefix-mode' in SHR/EWW
  2024-08-18  4:49     ` Eli Zaretskii
@ 2024-08-18  6:13       ` Jim Porter
  2024-08-18  9:20         ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Jim Porter @ 2024-08-18  6:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 72485

On 8/17/2024 9:49 PM, Eli Zaretskii wrote:
> I'm not sure many users know about shr-fill-text, including that its
> default is non-nil.  So I think this NEWS entry should say something
> about that, otherwise this text might cause incorrect user
> expectations.

How does this sound?

----------------------------------------

*** EWW now enables 'visual-wrap-prefix-mode' when 'shr-fill-text' is nil.
Previously, when 'shr-fill-text' was nil, EWW would use
'visual-line-mode' to wrap paragraphs instead of inserting newline
characters.  Now, EWW additionally enables 'visual-wrap-prefix-mode' in
this case.  This improves the display of multiline, indented text, such
as block quotes or (un)ordered lists.

----------------------------------------

I also notice that 'shr-fill-text' is new in Emacs 30, but doesn't have 
a NEWS entry in that release. Should I add a mention of it to the Emacs 
30 NEWS as well? (I don't see any harm in reiterating what 
'shr-fill-text' does in the Emacs 31 NEWS as well though.)





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#72485: Support 'visual-wrap-prefix-mode' in SHR/EWW
  2024-08-18  6:13       ` Jim Porter
@ 2024-08-18  9:20         ` Eli Zaretskii
  2024-08-18 16:58           ` Jim Porter
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2024-08-18  9:20 UTC (permalink / raw)
  To: Jim Porter; +Cc: 72485

> Date: Sat, 17 Aug 2024 23:13:00 -0700
> Cc: 72485@debbugs.gnu.org
> From: Jim Porter <jporterbugs@gmail.com>
> 
> On 8/17/2024 9:49 PM, Eli Zaretskii wrote:
> > I'm not sure many users know about shr-fill-text, including that its
> > default is non-nil.  So I think this NEWS entry should say something
> > about that, otherwise this text might cause incorrect user
> > expectations.
> 
> How does this sound?
> 
> ----------------------------------------
> 
> *** EWW now enables 'visual-wrap-prefix-mode' when 'shr-fill-text' is nil.
> Previously, when 'shr-fill-text' was nil, EWW would use
> 'visual-line-mode' to wrap paragraphs instead of inserting newline
> characters.  Now, EWW additionally enables 'visual-wrap-prefix-mode' in
> this case.  This improves the display of multiline, indented text, such
> as block quotes or (un)ordered lists.

It still doesn't say that shr-fill-text is non-nil by default.

> I also notice that 'shr-fill-text' is new in Emacs 30, but doesn't have 
> a NEWS entry in that release. Should I add a mention of it to the Emacs 
> 30 NEWS as well?

Yes, please do.

> (I don't see any harm in reiterating what 'shr-fill-text' does in
> the Emacs 31 NEWS as well though.)

I don't see a reason to reiterate that.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#72485: Support 'visual-wrap-prefix-mode' in SHR/EWW
  2024-08-18  9:20         ` Eli Zaretskii
@ 2024-08-18 16:58           ` Jim Porter
  2024-08-18 18:12             ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Jim Porter @ 2024-08-18 16:58 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 72485

On 8/18/2024 2:20 AM, Eli Zaretskii wrote:
> It still doesn't say that shr-fill-text is non-nil by default.
> 
>> I also notice that 'shr-fill-text' is new in Emacs 30, but doesn't have
>> a NEWS entry in that release. Should I add a mention of it to the Emacs
>> 30 NEWS as well?
> 
> Yes, please do.

How about this?

---------- For Emacs 30 ----------


*** New option 'shr-fill-text'.
When non-nil (the default), SHR will insert newlines in text to wrap it.
If customized to nil, SHR will leave the text as-is; in that case, EWW
will automatically enable 'visual-line-mode' to visually wrap the text
when displaying a page.


---------- For Emacs 31 ----------


*** EWW now enables 'visual-wrap-prefix-mode' when 'shr-fill-text' is nil.
When 'shr-fill-text' is customized to nil, EWW now enables
'visual-wrap-prefix-mode' when rendering in addition to
'visual-line-mode'.  This improves the display of multiline, indented
text, such as block quotes or (un)ordered lists.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#72485: Support 'visual-wrap-prefix-mode' in SHR/EWW
  2024-08-18 16:58           ` Jim Porter
@ 2024-08-18 18:12             ` Eli Zaretskii
  2024-08-18 18:28               ` Jim Porter
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2024-08-18 18:12 UTC (permalink / raw)
  To: Jim Porter; +Cc: 72485

> Date: Sun, 18 Aug 2024 09:58:07 -0700
> Cc: 72485@debbugs.gnu.org
> From: Jim Porter <jporterbugs@gmail.com>
> 
> *** New option 'shr-fill-text'.
> When non-nil (the default), SHR will insert newlines in text to wrap it.
> If customized to nil, SHR will leave the text as-is; in that case, EWW
> will automatically enable 'visual-line-mode' to visually wrap the text
> when displaying a page.

Inserting newlines is not the important part of this variable's
effect.  The important part is filling the text, and shr does that
with fixed-pitch and variable-pitch fonts alike.  The NEWS entry
should describe this important part.

> *** EWW now enables 'visual-wrap-prefix-mode' when 'shr-fill-text' is nil.
> When 'shr-fill-text' is customized to nil, EWW now enables
> 'visual-wrap-prefix-mode' when rendering in addition to
> 'visual-line-mode'.  This improves the display of multiline, indented
> text, such as block quotes or (un)ordered lists.

I evidently fail to explain myself, so let me just propose an entry
as I envisioned it:

 *** EWW now enables 'visual-wrap-prefix-mode' when 'shr-fill-text' is nil.
 By default, 'shr-fill-text' is t, and EWW fills the text according to
 the width of the window.  If you customize 'shr-fill-text' to nil,
 EWW will now automatically turn on 'visual-wrap-prefix-mode' in
 addition to 'visual-line-mode', so that long lines are wrapped at
 word boundaries near window edge and the continuation lines are
 indented using prefixes computed from surrounding context.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#72485: Support 'visual-wrap-prefix-mode' in SHR/EWW
  2024-08-18 18:12             ` Eli Zaretskii
@ 2024-08-18 18:28               ` Jim Porter
  2024-08-18 18:53                 ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Jim Porter @ 2024-08-18 18:28 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 72485

On 8/18/2024 11:12 AM, Eli Zaretskii wrote:
>   *** EWW now enables 'visual-wrap-prefix-mode' when 'shr-fill-text' is nil.
>   By default, 'shr-fill-text' is t, and EWW fills the text according to
>   the width of the window.  If you customize 'shr-fill-text' to nil,
>   EWW will now automatically turn on 'visual-wrap-prefix-mode' in
>   addition to 'visual-line-mode', so that long lines are wrapped at
>   word boundaries near window edge and the continuation lines are
>   indented using prefixes computed from surrounding context.

That seems good to me, so I'll just use that as-is for Emacs 31. How 
about this for the release branch?


*** New option 'shr-fill-text'.
When 'shr-fill-text' is non-nil (the default), SHR will fill the text
according to the width of the window.  If you customize it to nil, SHR
will leave the text as-is; in that case, EWW will automatically enable
'visual-line-mode' when displaying a page so that long lines are
visually wrapped at word boundaries.


(If you think this makes the Emacs 31 NEWS entry partially redundant, I 
can try to trim that one down to only discuss the new additions, but I 
don't mind either way.)





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#72485: Support 'visual-wrap-prefix-mode' in SHR/EWW
  2024-08-18 18:28               ` Jim Porter
@ 2024-08-18 18:53                 ` Eli Zaretskii
  2024-08-18 23:10                   ` Jim Porter
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2024-08-18 18:53 UTC (permalink / raw)
  To: Jim Porter; +Cc: 72485

> Date: Sun, 18 Aug 2024 11:28:40 -0700
> Cc: 72485@debbugs.gnu.org
> From: Jim Porter <jporterbugs@gmail.com>
> 
> On 8/18/2024 11:12 AM, Eli Zaretskii wrote:
> >   *** EWW now enables 'visual-wrap-prefix-mode' when 'shr-fill-text' is nil.
> >   By default, 'shr-fill-text' is t, and EWW fills the text according to
> >   the width of the window.  If you customize 'shr-fill-text' to nil,
> >   EWW will now automatically turn on 'visual-wrap-prefix-mode' in
> >   addition to 'visual-line-mode', so that long lines are wrapped at
> >   word boundaries near window edge and the continuation lines are
> >   indented using prefixes computed from surrounding context.
> 
> That seems good to me, so I'll just use that as-is for Emacs 31. How 
> about this for the release branch?
> 
> 
> *** New option 'shr-fill-text'.
> When 'shr-fill-text' is non-nil (the default), SHR will fill the text
> according to the width of the window.  If you customize it to nil, SHR
> will leave the text as-is; in that case, EWW will automatically enable
> 'visual-line-mode' when displaying a page so that long lines are
> visually wrapped at word boundaries.

LGTM, thanks.

> (If you think this makes the Emacs 31 NEWS entry partially redundant, I 
> can try to trim that one down to only discuss the new additions, but I 
> don't mind either way.)

I see no reason to trim it.





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#72485: Support 'visual-wrap-prefix-mode' in SHR/EWW
  2024-08-18 18:53                 ` Eli Zaretskii
@ 2024-08-18 23:10                   ` Jim Porter
  0 siblings, 0 replies; 11+ messages in thread
From: Jim Porter @ 2024-08-18 23:10 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 72485-done

On 8/18/2024 11:53 AM, Eli Zaretskii wrote:
> LGTM, thanks.
> 
>> (If you think this makes the Emacs 31 NEWS entry partially redundant, I
>> can try to trim that one down to only discuss the new additions, but I
>> don't mind either way.)
> 
> I see no reason to trim it.

Thanks. Merged the NEWS update to the release branch as b54e8b3741b, and 
the main patch to the master branch as a876c4d7a17. Closing this bug now.





^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-08-18 23:10 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-06  3:47 bug#72485: Support 'visual-wrap-prefix-mode' in SHR/EWW Jim Porter
2024-08-17  8:55 ` Eli Zaretskii
2024-08-18  0:30   ` Jim Porter
2024-08-18  4:49     ` Eli Zaretskii
2024-08-18  6:13       ` Jim Porter
2024-08-18  9:20         ` Eli Zaretskii
2024-08-18 16:58           ` Jim Porter
2024-08-18 18:12             ` Eli Zaretskii
2024-08-18 18:28               ` Jim Porter
2024-08-18 18:53                 ` Eli Zaretskii
2024-08-18 23:10                   ` Jim Porter

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).