[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/valign 99300eb 167/198: Add support for table.el tables
From: |
Stefan Monnier |
Subject: |
[elpa] externals/valign 99300eb 167/198: Add support for table.el tables |
Date: |
Tue, 1 Dec 2020 18:19:41 -0500 (EST) |
branch: externals/valign
commit 99300ebe55d1fdaa4c609c0ff46a453f32679714
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Add support for table.el tables
* valign.el (valign--at-table-p, valign--beginning-of-table,
valign--end-of-table, valign--align-separator-row, valign-table-1):
Change matching "|" to matching "| or +".
(valign--align-separator-row): Minor documentation change.
* valign.el (valign--align-separator-row): Handle "+--+--+" lines.
---
valign.el | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/valign.el b/valign.el
index 2ad1bf1..167c261 100644
--- a/valign.el
+++ b/valign.el
@@ -331,7 +331,7 @@ TYPE must be 'org. Start at point, stop at LIMIT."
(beginning-of-line)
(let ((face (plist-get (text-properties-at (point)) 'face)))
;; Don’t align tables in org blocks.
- (and (looking-at "[ \t]*|")
+ (and (looking-at "[ \t]*[|\\+]")
(not (and (consp face)
(or (equal face '(org-block))
(equal (plist-get face :inherit)
@@ -343,7 +343,7 @@ Assumes point is on a table."
(beginning-of-line)
(let ((p (point)))
(catch 'abort
- (while (looking-at "[ \t]*|")
+ (while (looking-at "[ \t]*[|\\+]")
(setq p (point))
(if (eq (point) (point-min))
(throw 'abort nil))
@@ -355,7 +355,7 @@ Assumes point is on a table."
"Go forward to the end of the table at point.
Assumes point is on a table."
(end-of-line)
- (while (looking-at "\n[ \t]*|")
+ (while (looking-at "\n[ \t]*[|\\+]")
(forward-line)
(end-of-line)))
@@ -429,8 +429,8 @@ STRING should have length 1."
(type (style (eql single-column)) column-width-list)
"Align the separator row (|---+---|) as “|---------|”.
Assumes the point is after the left bar (“|”). TYPE can be
-either 'org-mode or 'markdown, it doesn’t make any difference.
-STYLE is 'single-column. COLUMN-WIDTH-LIST is returned from
+either 'org-mode or 'markdown. STYLE is 'single-column.
+COLUMN-WIDTH-LIST is returned from
`valign--calculate-cell-width'."
(ignore type style)
(let* ((p (point))
@@ -441,7 +441,7 @@ STYLE is 'single-column. COLUMN-WIDTH-LIST is returned from
(* bar-width (1+ column-count)))))
;; Render the left bar.
(valign--maybe-render-bar (1- (point)))
- (when (search-forward "|" nil t)
+ (when (re-search-forward "[|\\+]" nil t)
(valign--put-overlay p (1- (point)) total-width
'face '(:strike-through t))
;; Render the right bar.
@@ -476,7 +476,8 @@ Assumes point is on the right bar or plus sign."
(type (style (eql multi-column)) column-width-list)
"Align the separator row in multi column style.
TYPE can be 'org-mode or 'markdown-mode, STYLE is 'multi-column.
-COLUMN-WIDTH-LIST is returned from `valign--calculate-cell-width'."
+COLUMN-WIDTH-LIST is returned from
+`valign--calculate-cell-width'."
(ignore type style)
(let ((bar-width (valign--glyph-width-of "|" (point)))
(space-width (valign--glyph-width-of " " (point)))
@@ -486,6 +487,12 @@ COLUMN-WIDTH-LIST is returned from
`valign--calculate-cell-width'."
(line-beginning-position) (point) t)))
;; Render the first left bar.
(valign--maybe-render-bar (1- (point)))
+ ;; Specially handle separator lines like “+--+--+”.
+ (when (looking-back "\\+" 1)
+ (valign--put-overlay (1- (point)) (point) 'display "|")
+ (setq pos (valign--pixel-width-from-to
+ (line-beginning-position) (point) t)))
+ ;; Add overlay in each column.
(while (re-search-forward "[+|]" (line-end-position) t)
;; Render the right bar.
(valign--maybe-render-bar (1- (point)))
@@ -575,7 +582,7 @@ If FORCE non-nil, force align."
;; Align each row.
(valign--do-row row-idx table-end
- (search-forward "|" (line-end-position))
+ (re-search-forward "[|\\+]" (line-end-position))
(if (valign--separator-p)
;; Separator row.
(valign--align-separator-row
- [elpa] externals/valign 973ddd6 138/198: * valign.el: Fix typo., (continued)
- [elpa] externals/valign 973ddd6 138/198: * valign.el: Fix typo., Stefan Monnier, 2020/12/01
- [elpa] externals/valign 6468741 168/198: Add better table.el table support, Stefan Monnier, 2020/12/01
- [elpa] externals/valign eea7454 173/198: * valign.el (cl-generic): Add require., Stefan Monnier, 2020/12/01
- [elpa] externals/valign 16e3313 174/198: * valign.el (Commentary): Update., Stefan Monnier, 2020/12/01
- [elpa] externals/valign 4005231 165/198: Fix inconsistency after enabling org-indent, Stefan Monnier, 2020/12/01
- [elpa] externals/valign 8c28c8c 151/198: * valign.el: Bump version to 2.3.0., Stefan Monnier, 2020/12/01
- [elpa] externals/valign e82e1f0 155/198: Re-align in jit-lock-functions, Stefan Monnier, 2020/12/01
- [elpa] externals/valign 2d7918b 195/198: Minor fixes, Stefan Monnier, 2020/12/01
- [elpa] externals/valign 831c2a7 176/198: * valign.el (valign--do-row): Fix infinite loop., Stefan Monnier, 2020/12/01
- [elpa] externals/valign 7315f4b 148/198: Add support for org-indent, Stefan Monnier, 2020/12/01
- [elpa] externals/valign 99300eb 167/198: Add support for table.el tables,
Stefan Monnier <=
- [elpa] externals/valign 7b581e0 072/198: Remove valign-werid-alignment error, Stefan Monnier, 2020/12/01
- [elpa] externals/valign f6d60d2 078/198: Merge two implementations for valign--align-separator-row, Stefan Monnier, 2020/12/01
- [elpa] externals/valign e9975b7 083/198: Use new text size calculation, Stefan Monnier, 2020/12/01
- [elpa] externals/valign e32d191 079/198: Valign-table refactor, Stefan Monnier, 2020/12/01
- [elpa] externals/valign 21a397a 092/198: Update README, Stefan Monnier, 2020/12/01
- [elpa] externals/valign 4ecc990 093/198: * valign.el (valign--table-face): Fix markdown-mode., Stefan Monnier, 2020/12/01
- [elpa] externals/valign c4ddfb3 095/198: Fix org-flag-region advice, Stefan Monnier, 2020/12/01
- [elpa] externals/valign 7529ddd 111/198: Revert "* valign.el (valign-table): Tuck in some long lines.", Stefan Monnier, 2020/12/01
- [elpa] externals/valign 97beef8 127/198: Remove valign-table-quiet, Stefan Monnier, 2020/12/01
- [elpa] externals/valign 1412fef 133/198: * valign.el (valign-table): Suppress search errors., Stefan Monnier, 2020/12/01