Hi Nicolas On Mon, Sep 9, 2013 at 9:10 PM, Nicolas Goaziou <n.goaz...@gmail.com> wrote: > FWIW, I think the test belongs to test-org.el, not to test-org-list.el.
Ok, I assume, then better also with more tests than only for list items. See the attached patches that replace the previous ones. Michael
From 66f6d15234bda97fc2e197efd2f9cb7c6439fef1 Mon Sep 17 00:00:00 2001 From: Michael Brand <michael.ch.br...@gmail.com> Date: Mon, 9 Sep 2013 22:32:36 +0200 Subject: [PATCH 1/2] Add ERTs for org-meta-return * testing/lisp/test-org.el (test-org/meta-return): New `ert-deftest' to test `org-meta-return'. --- testing/lisp/test-org.el | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 8a1e9f1..4944c24 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -365,6 +365,51 @@ +;;; Editing + +;;;; Insert elements + +(ert-deftest test-org/meta-return () + "Test M-RET (`org-meta-return')." + ;; In a table field insert a row above. + (should + (org-test-with-temp-text "| a |" + (forward-char) + (org-meta-return) + (forward-line -1) + (looking-at "| |$"))) + ;; In a paragraph change current line into a header. + (should + (org-test-with-temp-text "a" + (org-meta-return) + (beginning-of-line) + (looking-at "\* a$"))) + ;; In an item insert an item, in this case above. + (should + (org-test-with-temp-text "- a" + (org-meta-return) + (beginning-of-line) + (looking-at "- $"))) + ;; In a drawer and paragraph insert an empty line, in this case above. + (should + (let ((org-drawers '("MYDRAWER"))) + (org-test-with-temp-text ":MYDRAWER:\na\n:END:" + (forward-line) + (org-meta-return) + (forward-line -1) + (looking-at "$")))) + ;; TODO In a drawer and item insert an item, in this case above. + (should + (let ((org-drawers '("MYDRAWER"))) + (org-test-with-temp-text ":MYDRAWER:\n- a\n:END:" + (forward-line) + (org-meta-return) + (forward-line -1) + (looking-at "$"))))) + + + + ;;; Links ;;;; Fuzzy Links -- 1.7.12.4 (Apple Git-37)
From fddcaaed03630e7acc26ed701937b2ca17184fe5 Mon Sep 17 00:00:00 2001 From: Michael Brand <michael.ch.br...@gmail.com> Date: Mon, 9 Sep 2013 22:33:47 +0200 Subject: [PATCH 2/2] org-meta-return: Insert an item also in a drawer * lisp/org.el (org-meta-return): Exclude item from cond for drawer. * testing/lisp/test-org.el (test-org/meta-return): In a drawer and item insert an item. --- lisp/org.el | 3 ++- testing/lisp/test-org.el | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 59a22a2..edc8725 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -20698,7 +20698,8 @@ See the individual commands for more information." (org-check-before-invisible-edit 'insert) (cond ((run-hook-with-args-until-success 'org-metareturn-hook)) - ((or (org-at-drawer-p) (org-in-drawer-p) (org-at-property-p)) + ((and (or (org-at-drawer-p) (org-in-drawer-p) (org-at-property-p)) + (not (org-in-item-p))) (newline-and-indent)) ((org-at-table-p) (call-interactively 'org-table-wrap-region)) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 4944c24..3538242 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -398,14 +398,14 @@ (org-meta-return) (forward-line -1) (looking-at "$")))) - ;; TODO In a drawer and item insert an item, in this case above. + ;; In a drawer and item insert an item, in this case above. (should (let ((org-drawers '("MYDRAWER"))) (org-test-with-temp-text ":MYDRAWER:\n- a\n:END:" (forward-line) (org-meta-return) - (forward-line -1) - (looking-at "$"))))) + (beginning-of-line) + (looking-at "- $"))))) -- 1.7.12.4 (Apple Git-37)