[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org f0b7dfb3a0 2/2: org-table: Repair table before inse
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org f0b7dfb3a0 2/2: org-table: Repair table before inserting rows/columns |
Date: |
Thu, 6 Oct 2022 04:57:56 -0400 (EDT) |
branch: externals/org
commit f0b7dfb3a018891b2955986b0bdb5bf6fd5beb57
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>
org-table: Repair table before inserting rows/columns
* lisp/org-table.el (org-table-insert-column):
(org-table-insert-row): Repair the table as needed before inserting.
The internal insertion logic assumes that the table is valid. The
rapair checks are copied from `org-table-insert-hline'.
Reported-by: Mauro Aranda <maurooaranda@gmail.com>
Link: https://orgmode.org/list/87o8csah5t.fsf@localhost
---
lisp/org-table.el | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 50e2bcc136..5362b5f8f4 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -1355,6 +1355,9 @@ However, when FORCE is non-nil, create new columns if
necessary."
"Insert a new column into the table."
(interactive)
(unless (org-at-table-p) (user-error "Not at a table"))
+ (when (eobp) (save-excursion (insert "\n")))
+ (unless (string-match-p "|[ \t]*$" (org-current-line-string))
+ (org-table-align))
(org-table-find-dataline)
(let ((col (max 1 (org-table-current-column)))
(beg (org-table-begin))
@@ -1649,6 +1652,9 @@ Swap with anything in target cell."
With prefix ARG, insert below the current line."
(interactive "P")
(unless (org-at-table-p) (user-error "Not at a table"))
+ (when (eobp) (save-excursion (insert "\n")))
+ (unless (string-match-p "|[ \t]*$" (org-current-line-string))
+ (org-table-align))
(org-table-with-shrunk-columns
(let* ((line (buffer-substring (line-beginning-position)
(line-end-position)))
(new (org-table-clean-line line)))