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

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

[elpa] externals/valign 4af6efd 017/198: Support overlay image


From: Stefan Monnier
Subject: [elpa] externals/valign 4af6efd 017/198: Support overlay image
Date: Tue, 1 Dec 2020 18:19:07 -0500 (EST)

branch: externals/valign
commit 4af6efd757abe0a55728572b88fc31df640cd7d8
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Support overlay image
    
    * valign.el (valign--pixel-width-from-to): Also check for overlay.
---
 valign.el | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/valign.el b/valign.el
index d24a83a..4b769d0 100644
--- a/valign.el
+++ b/valign.el
@@ -97,12 +97,23 @@ calculate images pixel width."
       (while (< (point) to)
         (let ((display (plist-get (text-properties-at (point))
                                   'display)))
-          ;; This is an image, add image width.
-          (if (and (consp display) (eq (car display) 'image))
-              (progn (setq width (+ width (car (image-size display t))))
-                     (goto-char
-                      (next-single-property-change (point) 'display)))
-            ;; This is a normal character, add glyph width.
+          ;; 1) This is an overlay or text property image, add image
+          ;; width.
+          (if (and (setq ;; Overlay image?
+                    display (or (cl-loop for ov in (overlays-at (point) t)
+                                         if (overlay-get ov 'display)
+                                         return (overlay-get ov 'display)
+                                         finally return nil)
+                                ;; Text property image?
+                                (plist-get (text-properties-at (point))
+                                           'display)))
+                   (consp display)
+                   (eq (car display) 'image))
+              (progn
+                (setq width (+ width (car (image-size display t))))
+                (goto-char
+                 (next-single-property-change (point) 'display)))
+            ;; 2) This is a normal character, add glyph width.
             (setq width (+ width (valign--glyph-width-at-point)))
             (forward-char)))))
     width))



reply via email to

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