branch: externals/valign
commit f0c030ee3b3c5c363351f82f50162c550d0b6341
Author: Yuan Fu <[email protected]>
Commit: Yuan Fu <[email protected]>
* 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 ()