org-table: Insert column at point
* lisp/org-table.el (org-table-insert-column): Adjust the function to insert the column at point (and not to the right.) Org-manual, ORG-NEWS and testing are changed accordingly.
This commit is contained in:
parent
4f9e07cbb4
commit
22d2b0ac84
|
@ -1429,7 +1429,8 @@ you, configure the option ~org-table-auto-blank-field~.
|
|||
|
||||
#+kindex: M-S-RIGHT
|
||||
#+findex: org-table-insert-column
|
||||
Insert a new column to the right of point position.
|
||||
Insert a new column at point position. Move the recent column and
|
||||
all cells to the right of this column to the right.
|
||||
|
||||
- {{{kbd(M-UP)}}} (~org-table-move-row-up~) ::
|
||||
|
||||
|
|
|
@ -470,6 +470,11 @@ I.e. treat the whole file as if it was a subtree.
|
|||
|
||||
*** Respect narrowing when agenda command is restricted to buffer
|
||||
|
||||
*** ~org-table-insert-column~ inserts the column at point position
|
||||
|
||||
Before, the new column was inserted to the right of the column at
|
||||
point position.
|
||||
|
||||
* Version 9.2
|
||||
** Incompatible changes
|
||||
*** Removal of OrgStruct mode mode and radio lists
|
||||
|
|
|
@ -1290,25 +1290,21 @@ However, when FORCE is non-nil, create new columns if necessary."
|
|||
(while (< (point) end)
|
||||
(unless (org-at-table-hline-p)
|
||||
(org-table-goto-column col t)
|
||||
(unless (search-forward "|" (line-end-position) t 2)
|
||||
;; Add missing vertical bar at the end of the row.
|
||||
(end-of-line)
|
||||
(insert "|"))
|
||||
(insert " |"))
|
||||
(insert "|"))
|
||||
(forward-line)))
|
||||
(org-table-goto-column (1+ col))
|
||||
(org-table-goto-column col)
|
||||
(org-table-align)
|
||||
;; Shift appropriately stored shrunk column numbers, then hide the
|
||||
;; columns again.
|
||||
(org-table--shrink-columns (mapcar (lambda (c) (if (<= c col) c (1+ c)))
|
||||
(org-table--shrink-columns (mapcar (lambda (c) (if (< c col) c (1+ c)))
|
||||
shrunk-columns)
|
||||
beg end)
|
||||
(set-marker end nil)
|
||||
;; Fix TBLFM formulas, if desirable.
|
||||
(when (or (not org-table-fix-formulas-confirm)
|
||||
(funcall org-table-fix-formulas-confirm "Fix formulas? "))
|
||||
(org-table-fix-formulas "$" nil col 1)
|
||||
(org-table-fix-formulas "$LR" nil col 1))))
|
||||
(org-table-fix-formulas "$" nil (1- col) 1)
|
||||
(org-table-fix-formulas "$LR" nil (1- col) 1))))
|
||||
|
||||
(defun org-table-find-dataline ()
|
||||
"Find a data line in the current table, which is needed for column commands.
|
||||
|
|
|
@ -2351,45 +2351,45 @@ See also `test-org-table/copy-field'."
|
|||
(org-table-insert-column)))
|
||||
;; Insert new column after current one.
|
||||
(should
|
||||
(equal "| a | |\n"
|
||||
(equal "| | a |\n"
|
||||
(org-test-with-temp-text "| a |"
|
||||
(org-table-insert-column)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(equal "| a | | b |\n"
|
||||
(equal "| | a | b |\n"
|
||||
(org-test-with-temp-text "| <point>a | b |"
|
||||
(org-table-insert-column)
|
||||
(buffer-string))))
|
||||
;; Move point into the newly created column.
|
||||
(should
|
||||
(equal " |"
|
||||
(equal " | a |"
|
||||
(org-test-with-temp-text "| <point>a |"
|
||||
(org-table-insert-column)
|
||||
(buffer-substring-no-properties (point) (line-end-position)))))
|
||||
(should
|
||||
(equal " | b |"
|
||||
(equal " | a | b |"
|
||||
(org-test-with-temp-text "| <point>a | b |"
|
||||
(org-table-insert-column)
|
||||
(buffer-substring-no-properties (point) (line-end-position)))))
|
||||
;; Handle missing vertical bar in the last column.
|
||||
(should
|
||||
(equal "| a | |\n"
|
||||
(equal "| | a |\n"
|
||||
(org-test-with-temp-text "| a"
|
||||
(org-table-insert-column)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(equal " |"
|
||||
(equal " | a |"
|
||||
(org-test-with-temp-text "| <point>a"
|
||||
(org-table-insert-column)
|
||||
(buffer-substring-no-properties (point) (line-end-position)))))
|
||||
;; Handle column insertion when point is before first column.
|
||||
(should
|
||||
(equal " | a | |\n"
|
||||
(equal " | | a |\n"
|
||||
(org-test-with-temp-text " | a |"
|
||||
(org-table-insert-column)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(equal " | a | | b |\n"
|
||||
(equal " | | a | b |\n"
|
||||
(org-test-with-temp-text " | a | b |"
|
||||
(org-table-insert-column)
|
||||
(buffer-string)))))
|
||||
|
@ -2397,8 +2397,8 @@ See also `test-org-table/copy-field'."
|
|||
(ert-deftest test-org-table/insert-column-with-formula ()
|
||||
"Test `org-table-insert-column' with a formula in place."
|
||||
(should
|
||||
(equal "| 1 | | 1 | 2 |
|
||||
#+TBLFM: $4=$1+$3"
|
||||
(equal "| | 1 | 1 | 2 |
|
||||
#+TBLFM: $4=$2+$3"
|
||||
(org-test-with-temp-text
|
||||
"| 1<point> | 1 | 2 |
|
||||
#+TBLFM: $3=$1+$2"
|
||||
|
|
Loading…
Reference in New Issue