org-table: Make column delete consistent with row delete
* lisp/org-table.el (org-table-delete-column): Stay in the column at delete. Exceptionally allow column delete when point is at eol immediately to the right of a cell seperator. A hint by Eric S Fraga led to this commit. https://lists.gnu.org/archive/html/emacs-orgmode/2020-04/msg00283.html
This commit is contained in:
parent
22d2b0ac84
commit
bb9dfdafeb
|
@ -475,6 +475,11 @@ I.e. treat the whole file as if it was a subtree.
|
|||
Before, the new column was inserted to the right of the column at
|
||||
point position.
|
||||
|
||||
*** Table column deletion now consistent with row deletion
|
||||
|
||||
Point stays in the column at deletion, except when deleting the
|
||||
rightmost column.
|
||||
|
||||
* Version 9.2
|
||||
** Incompatible changes
|
||||
*** Removal of OrgStruct mode mode and radio lists
|
||||
|
|
|
@ -1427,6 +1427,7 @@ 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.
|
||||
(org-table-check-inside-data-field nil t)
|
||||
(let* ((col (org-table-current-column))
|
||||
(beg (org-table-begin))
|
||||
|
@ -1442,7 +1443,6 @@ Swap with anything in target cell."
|
|||
(and (looking-at "|[^|\n]+|")
|
||||
(replace-match "|")))
|
||||
(forward-line)))
|
||||
(org-table-goto-column (max 1 (1- col)))
|
||||
(org-table-align)
|
||||
;; Shift appropriately stored shrunk column numbers, then hide the
|
||||
;; columns again.
|
||||
|
|
|
@ -2340,6 +2340,44 @@ See also `test-org-table/copy-field'."
|
|||
(ignore-errors (org-table-previous-field))
|
||||
(char-after)))))
|
||||
|
||||
|
||||
;;; Deleting columns
|
||||
(ert-deftest test-org-table/delete-column ()
|
||||
"Test `org-table-delete-column'."
|
||||
;; Error when outside a table.
|
||||
(should-error
|
||||
(org-test-with-temp-text "Paragraph"
|
||||
(org-table-delete-column)))
|
||||
;; Delete first column.
|
||||
(should
|
||||
(equal "| a |\n"
|
||||
(org-test-with-temp-text
|
||||
"| <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 "|".
|
||||
(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)))))
|
||||
|
||||
|
||||
;;; Inserting rows, inserting columns
|
||||
|
||||
|
|
Loading…
Reference in New Issue