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

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

[elpa] externals/valign f0c030e 018/198: * valign.el (valign--pixel-widt


From: Stefan Monnier
Subject: [elpa] externals/valign f0c030e 018/198: * valign.el (valign--pixel-width-from-to): Support invisible text.
Date: Tue, 1 Dec 2020 18:19:08 -0500 (EST)

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

    * valign.el (valign--pixel-width-from-to): Support invisible text.
---
 valign.el | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/valign.el b/valign.el
index 4b769d0..d7320f4 100644
--- a/valign.el
+++ b/valign.el
@@ -99,23 +99,27 @@ calculate images pixel width."
                                   'display)))
           ;; 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)))))
+          (cond ((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) Invisible text.
+                ((plist-get (text-properties-at (point)) 'invisible)
+                 (goto-char
+                  (next-single-property-change (point) 'invisible)))
+                ;; 3) This is a normal character, add glyph width.
+                (t (setq width (+ width (valign--glyph-width-at-point)))
+                   (goto-char (1+ (point))))))))
     width))
 
 (defun valign--skip-space-backward ()



reply via email to

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