summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-12-02 17:27:53 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-12-02 17:27:53 +0100
commitbdaf5dacf44c3816c4d1d4ecbd9d3fabff317c3d (patch)
tree8d111e023ca1b9ec692791f76b4167c444db9739
parent0ace32b045cb70c7889eece0cb351217b7fd652a (diff)
parentca43c1f262b6e88881b24023b517e5bb4a5b6804 (diff)
downloadorg-mode-bdaf5dacf44c3816c4d1d4ecbd9d3fabff317c3d.tar.gz
Merge branch 'maint'
-rw-r--r--lisp/org-table.el26
-rw-r--r--lisp/org.el10
-rw-r--r--testing/lisp/test-org.el12
3 files changed, 30 insertions, 18 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 0388f70..1f7a69e 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -1061,22 +1061,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)
diff --git a/lisp/org.el b/lisp/org.el
index a6c424d..045086b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20740,13 +20740,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'.
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index d5e7ba3..d5d1b4a 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -1185,6 +1185,18 @@
(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)))))
(ert-deftest test-org/meta-return ()