emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/htmlize 83f2745 035/134: Simplify loop, noticing that over


From: ELPA Syncer
Subject: [nongnu] elpa/htmlize 83f2745 035/134: Simplify loop, noticing that overlay-faces is invariant throughout the loop.
Date: Sat, 7 Aug 2021 09:17:01 -0400 (EDT)

branch: elpa/htmlize
commit 83f2745769d58f14438e1f46c92d06f44e56b3b4
Author: Hrvoje Niksic <hniksic@gmail.com>
Commit: Hrvoje Niksic <hniksic@gmail.com>

    Simplify loop, noticing that overlay-faces is invariant throughout the loop.
---
 htmlize.el | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/htmlize.el b/htmlize.el
index 589c41a..f3a13f6 100644
--- a/htmlize.el
+++ b/htmlize.el
@@ -314,24 +314,19 @@ output.")
   (defun htmlize-overlay-faces-at (pos)
     (delq nil (mapcar (lambda (o) (overlay-get o 'face)) (overlays-at pos))))
   (defun htmlize-next-face-change (pos &optional limit)
-    ;; It is insufficient to call (htmlize-next-change pos 'face
-    ;; limit) because it skips over entire overlays that specify the
-    ;; `face' property, although the overlay contains smaller text
-    ;; property runs that also specify `face'.  The Emacs display
-    ;; engine merges faces from all sources, and so must we.
+    ;; (htmlize-next-change pos 'face limit) would skip over entire
+    ;; overlays that specify the `face' property, even when they
+    ;; contain smaller text properties that also specify `face'.
+    ;; Emacs display engine merges those faces, and so must we.
     (or limit
         (setq limit (point-max)))
     (let ((next-prop (next-single-property-change pos 'face nil limit))
-          (overlay-faces (htmlize-overlay-faces-at pos))
-          next-pos next-overlay-faces)
-      (loop
-       do (setq next-pos (next-overlay-change pos))
-       until (>= next-pos next-prop)
-       do (setq next-overlay-faces (htmlize-overlay-faces-at next-pos))
-       while (equal overlay-faces next-overlay-faces)
-       do (setq pos next-pos
-                overlay-faces next-overlay-faces))
-      (min next-pos next-prop))))
+          (overlay-faces (htmlize-overlay-faces-at pos)))
+      (while (progn
+               (setq pos (next-overlay-change pos))
+               (and (< pos next-prop)
+                    (equal overlay-faces (htmlize-overlay-faces-at pos)))))
+      (min pos next-prop))))
  (t
   (error "htmlize requires next-single-property-change or \
 next-single-char-property-change")))



reply via email to

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