[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 2df7b98de31 2/3: * lisp/net/shr.el (shr-dom-max-natural-width): R
From: |
Mattias Engdegård |
Subject: |
master 2df7b98de31 2/3: * lisp/net/shr.el (shr-dom-max-natural-width): Rewrite muddled code. |
Date: |
Wed, 31 May 2023 11:17:00 -0400 (EDT) |
branch: master
commit 2df7b98de317a7f89d1ec342d79a93dd789c70bc
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
* lisp/net/shr.el (shr-dom-max-natural-width): Rewrite muddled code.
---
lisp/net/shr.el | 30 +++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 86987807153..9b19a1b3980 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -2530,7 +2530,7 @@ flags that control whether to collect or render objects."
(setq natural-width
(or (dom-attr dom 'shr-td-cache-natural)
(let ((natural (max (shr-pixel-buffer-width)
- (shr-dom-max-natural-width dom 0))))
+ (shr-dom-max-natural-width dom))))
(dom-set-attribute dom 'shr-td-cache-natural natural)
natural))))
(if (and natural-width
@@ -2559,22 +2559,18 @@ flags that control whether to collect or render
objects."
(cdr (assq 'color shr-stylesheet))
(cdr (assq 'background-color shr-stylesheet))))))
-(defun shr-dom-max-natural-width (dom max)
- (if (eq (dom-tag dom) 'table)
- (max max (or
- (cl-loop
- for line in (dom-attr dom 'shr-suggested-widths)
- maximize (+
- shr-table-separator-length
- (cl-loop for elem in line
- summing
- (+ (cdr elem)
- (* 2 shr-table-separator-length)))))
- 0))
- (dolist (child (dom-children dom))
- (unless (stringp child)
- (setq max (max (shr-dom-max-natural-width child max)))))
- max))
+(defun shr-dom-max-natural-width (dom)
+ (or (if (eq (dom-tag dom) 'table)
+ (cl-loop for line in (dom-attr dom 'shr-suggested-widths)
+ maximize (+ shr-table-separator-length
+ (cl-loop for elem in line
+ summing
+ (+ (cdr elem)
+ (* 2 shr-table-separator-length)))))
+ (cl-loop for child in (dom-children dom)
+ unless (stringp child)
+ maximize (shr-dom-max-natural-width child)))
+ 0))
(defun shr-buffer-width ()
(goto-char (point-min))