瀏覽代碼

Merge branch 'maint'

Nicolas Goaziou 7 年之前
父節點
當前提交
bdaf5dacf4
共有 3 個文件被更改,包括 30 次插入18 次删除
  1. 11 15
      lisp/org-table.el
  2. 7 3
      lisp/org.el
  3. 12 0
      testing/lisp/test-org.el

+ 11 - 15
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)

+ 7 - 3
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'.

+ 12 - 0
testing/lisp/test-org.el

@@ -1184,6 +1184,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)))))