emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Brand <michael.ch.brand@gmail.com>
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: Emacs Org mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: org-insert-heading rewritten from scratch
Date: Mon, 9 Sep 2013 18:42:20 +0200	[thread overview]
Message-ID: <CALn3zohJ49bJz7CZHyQaS+C31F5Lraq+OSg+wRy1s9knCnNrPg@mail.gmail.com> (raw)
In-Reply-To: <6570EFE0-1DCA-44D1-AAD9-BE51A278EE58@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1063 bytes --]

Hi Carsten

On Thu, Aug 8, 2013 at 8:43 AM, Carsten Dominik
<carsten.dominik@gmail.com> wrote:
> I have rewritten org-insert-heading, because it had become an unmaintainable beast.
> Please follow up in this thread if you find problems with the new implementation.
> Very likely there will be bugs, but now I am at least confident they can be fixed.

On the way of rewiring my muscle memory from C-RET to M-RET for some
cases, I stumbled across this:

#+DRAWERS: MyStructuredDrawer
:MyStructuredDrawer:
- a
:END:

To insert a new item I once changed to use C-RET also on items. How is
one supposed to do this now within a drawer? M-RET just inserts an
empty line. I would like to suggest the attached patches with an ERT.
They change (fix?) org-meta-return to insert a new item in this case.

About the following different issue I don't care as much and only
wanted to report: C-RET before any headline when within a drawer, or
generally before any headline(?), could bark instead of changing to a
headline leading to invalid Org syntax within a drawer.

Michael

[-- Attachment #2: 0001-Add-ERTs-for-org-meta-return.patch.txt --]
[-- Type: text/plain, Size: 1621 bytes --]

From 6bc4c15c4a76a98c841e8a200c75f5a0737ffece Mon Sep 17 00:00:00 2001
From: Michael Brand <michael.ch.brand@gmail.com>
Date: Mon, 9 Sep 2013 18:38:58 +0200
Subject: [PATCH 1/2] Add ERTs for org-meta-return

* testing/lisp/test-org-list.el (test-org-list/insert-item): Adapt
docstring.
* (test-org-list/meta-return): New `ert-deftest' to test
`org-meta-return'.
---
 testing/lisp/test-org-list.el | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/testing/lisp/test-org-list.el b/testing/lisp/test-org-list.el
index ac81d4d..ea19606 100644
--- a/testing/lisp/test-org-list.el
+++ b/testing/lisp/test-org-list.el
@@ -627,7 +627,7 @@
     (should (org-invisible-p2))))
 
 (ert-deftest test-org-list/insert-item ()
-  "Test item insertion."
+  "Test item insertion with `org-insert-item'."
   ;; Blank lines specifications.
   ;;
   ;; Non-nil `org-blank-before-new-entry': insert a blank line, unless
@@ -713,6 +713,22 @@
        (forward-line -1)
        (looking-at "$")))))
 
+(ert-deftest test-org-list/meta-return ()
+  "Test item insertion with `org-meta-return'."
+  (should
+   (org-test-with-temp-text "- a"
+     (org-meta-return)
+     (beginning-of-line)
+     (looking-at "- $")))
+  ;; TODO Insert an item also in a drawer.
+  (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 "$")))))
+
 (ert-deftest test-org-list/repair ()
   "Test `org-list-repair' specifications."
   ;; Repair indentation.
-- 
1.7.12.4 (Apple Git-37)


[-- Attachment #3: 0002-org-meta-return-Insert-an-item-also-in-a-drawer.patch.txt --]
[-- Type: text/plain, Size: 1846 bytes --]

From 9896499fb7f497a13857b5b86f33cfbf1b918029 Mon Sep 17 00:00:00 2001
From: Michael Brand <michael.ch.brand@gmail.com>
Date: Mon, 9 Sep 2013 18:40:07 +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-list.el (test-org-list/meta-return): On an
item in a drawer expect an item to be inserted.
---
 lisp/org.el                   | 3 ++-
 testing/lisp/test-org-list.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-list.el b/testing/lisp/test-org-list.el
index ea19606..f3ced15 100644
--- a/testing/lisp/test-org-list.el
+++ b/testing/lisp/test-org-list.el
@@ -720,14 +720,14 @@
      (org-meta-return)
      (beginning-of-line)
      (looking-at "- $")))
-  ;; TODO Insert an item also in a drawer.
+  ;; Insert an item also in a drawer.
   (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 "- $")))))
 
 (ert-deftest test-org-list/repair ()
   "Test `org-list-repair' specifications."
-- 
1.7.12.4 (Apple Git-37)


  parent reply	other threads:[~2013-09-09 16:42 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-08  6:43 org-insert-heading rewritten from scratch Carsten Dominik
2013-08-08  7:41 ` Eric Abrahamsen
2013-08-31 14:00   ` Carsten Dominik
2013-08-31 14:34     ` Nicolas Goaziou
2013-09-01  6:13       ` Carsten Dominik
2013-09-01  8:19         ` Nicolas Goaziou
2013-09-01 12:04           ` Carsten Dominik
2013-09-01 12:25             ` Nicolas Goaziou
2013-09-03 13:16             ` Nicolas Goaziou
2013-09-03 13:25               ` Carsten Dominik
2013-09-03 13:33                 ` Carsten Dominik
2013-09-03 13:38                 ` Nicolas Goaziou
2013-09-03 13:47                   ` Carsten Dominik
2013-09-03 13:58                     ` Nicolas Goaziou
2013-09-03 14:04                       ` Carsten Dominik
2013-09-03 14:12                         ` Nicolas Goaziou
2013-09-07 10:50                         ` Nicolas Goaziou
2013-09-07 12:01                           ` Nicolas Goaziou
2013-09-01  2:38     ` Eric Abrahamsen
2013-09-01  3:11     ` Samuel Wales
2013-09-01  3:13       ` Samuel Wales
2013-09-09 16:42 ` Michael Brand [this message]
2013-09-09 19:10   ` Nicolas Goaziou
2013-09-09 20:37     ` Michael Brand
2013-09-12 20:20       ` Carsten Dominik
2013-09-12 20:52         ` Michael Brand
2013-09-12 20:58           ` Carsten Dominik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALn3zohJ49bJz7CZHyQaS+C31F5Lraq+OSg+wRy1s9knCnNrPg@mail.gmail.com \
    --to=michael.ch.brand@gmail.com \
    --cc=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).