forked from mirrors/org-mode
Fix RET past the last column of a table
* lisp/org.el (org-return): Split the table before first column or after last one. * lisp/org-table.el (org-table-next-row): Remove code handling split. * testing/lisp/test-org.el (test-org/return): Add test.
This commit is contained in:
parent
f53d1e2005
commit
ca43c1f262
|
@ -1087,22 +1087,18 @@ Before doing so, re-align the table if necessary."
|
|||
(interactive)
|
||||
(org-table-maybe-eval-formula)
|
||||
(org-table-maybe-recalculate-line)
|
||||
(if (or (looking-at "[ \t]*$")
|
||||
(save-excursion (skip-chars-backward " \t") (bolp)))
|
||||
(newline)
|
||||
(if (and org-table-automatic-realign
|
||||
org-table-may-need-update)
|
||||
(org-table-align))
|
||||
(let ((col (org-table-current-column)))
|
||||
(beginning-of-line 2)
|
||||
(if (or (not (org-at-table-p))
|
||||
(if (and org-table-automatic-realign
|
||||
org-table-may-need-update)
|
||||
(org-table-align))
|
||||
(let ((col (org-table-current-column)))
|
||||
(beginning-of-line 2)
|
||||
(when (or (not (org-at-table-p))
|
||||
(org-at-table-hline-p))
|
||||
(progn
|
||||
(beginning-of-line 0)
|
||||
(org-table-insert-row 'below)))
|
||||
(org-table-goto-column col)
|
||||
(skip-chars-backward "^|\n\r")
|
||||
(if (looking-at " ") (forward-char 1)))))
|
||||
(beginning-of-line 0)
|
||||
(org-table-insert-row 'below))
|
||||
(org-table-goto-column col)
|
||||
(skip-chars-backward "^|\n\r")
|
||||
(when (looking-at " ") (forward-char))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-table-copy-down (n)
|
||||
|
|
10
lisp/org.el
10
lisp/org.el
|
@ -21042,13 +21042,17 @@ object (e.g., within a comment). In these case, you need to use
|
|||
(let ((context (if org-return-follows-link (org-element-context)
|
||||
(org-element-at-point))))
|
||||
(cond
|
||||
;; In a table, call `org-table-next-row'.
|
||||
;; In a table, call `org-table-next-row'. However, before first
|
||||
;; column or after last one, split the table.
|
||||
((or (and (eq (org-element-type context) 'table)
|
||||
(>= (point) (org-element-property :contents-begin context))
|
||||
(< (point) (org-element-property :contents-end context)))
|
||||
(org-element-lineage context '(table-row table-cell) t))
|
||||
(org-table-justify-field-maybe)
|
||||
(call-interactively #'org-table-next-row))
|
||||
(if (or (looking-at-p "[ \t]*$")
|
||||
(save-excursion (skip-chars-backward " \t") (bolp)))
|
||||
(insert "\n")
|
||||
(org-table-justify-field-maybe)
|
||||
(call-interactively #'org-table-next-row)))
|
||||
;; On a link or a timestamp, call `org-open-at-point' if
|
||||
;; `org-return-follows-link' allows it. Tolerate fuzzy
|
||||
;; locations, e.g., in a comment, as `org-open-at-point'.
|
||||
|
|
|
@ -1178,6 +1178,18 @@
|
|||
(should
|
||||
(equal "* h\n"
|
||||
(org-test-with-temp-text "*<point> h"
|
||||
(org-return)
|
||||
(buffer-string))))
|
||||
;; Before first column or after last one in a table, split the
|
||||
;; table.
|
||||
(should
|
||||
(equal "| a |\n\n| b |"
|
||||
(org-test-with-temp-text "| a |\n<point>| b |"
|
||||
(org-return)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(equal "| a |\n\n| b |"
|
||||
(org-test-with-temp-text "| a |<point>\n| b |"
|
||||
(org-return)
|
||||
(buffer-string)))))
|
||||
|
||||
|
|
Loading…
Reference in a new issue