branch: elpa/htmlize
commit 83f2745769d58f14438e1f46c92d06f44e56b3b4
Author: Hrvoje Niksic <[email protected]>
Commit: Hrvoje Niksic <[email protected]>
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")))