Skip to content

Commit f0b7dfb

Browse files
committed
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
1 parent 2247083 commit f0b7dfb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lisp/org-table.el

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,9 @@ However, when FORCE is non-nil, create new columns if necessary."
13551355
"Insert a new column into the table."
13561356
(interactive)
13571357
(unless (org-at-table-p) (user-error "Not at a table"))
1358+
(when (eobp) (save-excursion (insert "\n")))
1359+
(unless (string-match-p "|[ \t]*$" (org-current-line-string))
1360+
(org-table-align))
13581361
(org-table-find-dataline)
13591362
(let ((col (max 1 (org-table-current-column)))
13601363
(beg (org-table-begin))
@@ -1649,6 +1652,9 @@ Swap with anything in target cell."
16491652
With prefix ARG, insert below the current line."
16501653
(interactive "P")
16511654
(unless (org-at-table-p) (user-error "Not at a table"))
1655+
(when (eobp) (save-excursion (insert "\n")))
1656+
(unless (string-match-p "|[ \t]*$" (org-current-line-string))
1657+
(org-table-align))
16521658
(org-table-with-shrunk-columns
16531659
(let* ((line (buffer-substring (line-beginning-position) (line-end-position)))
16541660
(new (org-table-clean-line line)))

0 commit comments

Comments
 (0)