diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-04-18 18:33:07 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-04-18 18:33:07 +0200 |
commit | 756ddff9e3ff8dbcb4644f4e7c0afb252f5ab20f (patch) | |
tree | 1c9065bb22d55cbf72f63a429047c7399dfcedb0 | |
parent | c7063b05f7b254428f20a2f9ae3999f7294c5ba8 (diff) | |
download | org-mode-756ddff9e3ff8dbcb4644f4e7c0afb252f5ab20f.tar.gz |
table: Small fix to column deletion
* lisp/org-table.el (org-table-delete-column): Do not assume row ends
right after the last vertical line. Do not use `looking-back'.
* testing/lisp/test-org-table.el (test-org-table/delete-column): Add
test.
-rw-r--r-- | lisp/org-table.el | 3 | ||||
-rw-r--r-- | testing/lisp/test-org-table.el | 38 |
2 files changed, 24 insertions, 17 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el index f22e6ec..8d6c15b 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -1427,7 +1427,8 @@ Swap with anything in target cell." (interactive) (unless (org-at-table-p) (user-error "Not at a table")) (org-table-find-dataline) - (and (eolp) (looking-back "|" 1) (backward-char)) ; Snap into last column. + (when (save-excursion (skip-chars-forward " \t") (eolp)) + (search-backward "|")) ;snap into last column (org-table-check-inside-data-field nil t) (let* ((col (org-table-current-column)) (beg (org-table-begin)) diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index a89ee44..64a1b4b 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -2352,31 +2352,37 @@ See also `test-org-table/copy-field'." (should (equal "| a |\n" (org-test-with-temp-text - "| <point> | a |\n" - (org-table-delete-column) - (buffer-string)))) + "| <point> | a |\n" + (org-table-delete-column) + (buffer-string)))) ;; Delete column and check location of point. (should (= 2 (org-test-with-temp-text - "| a | <point>b | c |" - (org-table-delete-column) - (org-table-current-column)))) - ;; Delete column when at end of line and immediately after a "|". + "| a | <point>b | c |" + (org-table-delete-column) + (org-table-current-column)))) + ;; Delete column when at end of line and after a "|". (should (equal "| a |\n" - (org-test-with-temp-text - "| a | b |<point>\n" - (org-table-delete-column) - (buffer-string)))) + (org-test-with-temp-text + "| a | b |<point>\n" + (org-table-delete-column) + (buffer-string)))) + (should + (equal "| a |\n" + (org-test-with-temp-text + "| a | b | <point>\n" + (org-table-delete-column) + (buffer-string)))) ;; Delete two columns starting with the last column. (should (equal "| a |\n" - (org-test-with-temp-text - "| a | b | c<point> |" - (org-table-delete-column) - (org-table-delete-column) - (buffer-string))))) + (org-test-with-temp-text + "| a | b | c<point> |" + (org-table-delete-column) + (org-table-delete-column) + (buffer-string))))) ;;; Inserting rows, inserting columns |