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

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

[elpa] externals/valign 24ad00d 074/198: * valign.el (valign--cell-width


From: Stefan Monnier
Subject: [elpa] externals/valign 24ad00d 074/198: * valign.el (valign--cell-width): Includes extra spaces in cell width.
Date: Tue, 1 Dec 2020 18:19:20 -0500 (EST)

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

    * valign.el (valign--cell-width): Includes extra spaces in cell width.
---
 valign.el | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/valign.el b/valign.el
index 49ac578..12d3135 100644
--- a/valign.el
+++ b/valign.el
@@ -91,16 +91,25 @@ TYPE must be 'markdown-mode.  Simply return HINT."
   "Return the pixel width of the cell at point.
 Assumes point is after the left bar (“|”).
 Return nil if not in a cell."
-  (let (start)
+  ;; We assumes:
+  ;; 1. Point is after the left bar (“|”).
+  ;; 2. Cell is delimited by either “|” or “+”.
+  ;; 3. There is at least one space on either side of the content,
+  ;;    unless the cell is empty.
+  ;; IOW: CELL      := <DELIM>(<EMPTY>|<NON-EMPTY>)<DELIM>
+  ;;      EMPTY     := <SPACE>+
+  ;;      NON-EMPTY := <SPACE>+<NON-SPACE>+<SPACE>+
+  ;;      DELIM     := | or +
+  (let ((start (point)))
     (save-excursion
       (valign--skip-space-forward)
-      (setq start (point))
-      (if (not (search-forward "|" nil t))
-          (signal 'valign-bad-cell nil)
-        ;; We are at the right “|”
-        (backward-char)
-        (valign--skip-space-backward)
-        (valign--pixel-width-from-to start (point))))))
+      (if (looking-at-p "[|+]")
+          0
+        (if (not (search-forward "|" nil t))
+            (signal 'valign-bad-cell nil)
+          ;; We are at the right “|”
+          (backward-char 2)
+          (valign--pixel-width-from-to (1+ start) (point)))))))
 
 ;; (defun valign--font-at (p)
 ;;   (find-font



reply via email to

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