From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: [PATCH] Fix Subtle Heading Creation Bugs Date: Wed, 22 Oct 2008 08:02:56 +0200 Message-ID: <6FE33468-00B0-4CEE-87AC-65F12E8BC847@uva.nl> References: Mime-Version: 1.0 (Apple Message framework v929.2) Content-Type: multipart/mixed; boundary="===============0766421402==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KsWoB-0000qU-NG for emacs-orgmode@gnu.org; Wed, 22 Oct 2008 02:03:03 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KsWo9-0000qI-6U for emacs-orgmode@gnu.org; Wed, 22 Oct 2008 02:03:02 -0400 Received: from [199.232.76.173] (port=58403 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KsWo9-0000qF-2p for emacs-orgmode@gnu.org; Wed, 22 Oct 2008 02:03:01 -0400 Received: from ug-out-1314.google.com ([66.249.92.168]:52362) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KsWo8-0002au-5l for emacs-orgmode@gnu.org; Wed, 22 Oct 2008 02:03:00 -0400 Received: by ug-out-1314.google.com with SMTP id z36so1354009uge.17 for ; Tue, 21 Oct 2008 23:02:59 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Peter Jones Cc: emacs-orgmode@gnu.org --===============0766421402== Content-Type: multipart/alternative; boundary=Apple-Mail-1--612442631 --Apple-Mail-1--612442631 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Hi Peter, I have applied your full patch, thanks. Please verify the push, I did have a little technical problem when applying, so please make sure it worked correctly. Thanks. - Carsten On Oct 18, 2008, at 2:10 AM, Peter Jones wrote: > > Since commit 238d0d1 (Improve consistency for inserting new headlines) > a few minor inconsistencies were introduced to heading creation with > the control key, A.K.A. org-insert-heading-respect-content. This > patch resolves those subtle "bugs". > > This patch changes org-insert-heading-respect-content so that it: > > - Creates a new heading even if point is in a plain list > (force-heading is set to true, behavior before 238d0d1) > - If the previous heading was closed, keep it closed > (keeps the previous heading in the state it was before C-RET) > > It also includes changes for org-insert-todo-heading and the OrgMode > manual. > > Thanks Carsten for making the changes in 238d0d1 for me. With the > attached patch, heading creation is now perfect (for me at least ;). > > From 200826587af4bd40995d1d45381006ed0639f7e9 Mon Sep 17 00:00:00 2001 > From: Peter Jones > Date: Fri, 17 Oct 2008 17:26:11 -0600 > Subject: [PATCH] Fix Subtle Heading Creation Bugs > > Since commit 238d0d1 (Improve consistency for inserting new headlines) > a few minor inconsistencies were introduced to heading creation with > the control key, A.K.A. org-insert-heading-respect-content. This > patch resolves those subtle "bugs". > > This patch changes org-insert-heading-respect-content so that it: > > - Creates a new heading even if point is in a plain list > (force-heading is set to true, behavior before 238d0d1) > - If the previous heading was closed, keep it closed > (keeps the previous heading in the state it was before C-RET) > --- > lisp/org.el | 11 +++++++++-- > 1 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/lisp/org.el b/lisp/org.el > index 9c08ba4..541cf3a 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -4607,7 +4607,7 @@ but create the new hedline after the current > line." > (match-string 0)) > (error "*")))) > (blank (cdr (assq 'heading org-blank-before-new-entry))) > - pos) > + pos should-hide-previous-heading) > (cond > ((and (org-on-heading-p) (bolp) > (or (bobp) > @@ -4622,6 +4622,9 @@ but create the new hedline after the current > line." > nil) > (t > ;; in the middle of the line > + (save-excursion > + (end-of-line) > + (setq should-hide-previous-heading (org-invisible-p))) > (org-show-entry) > (let ((split > (org-get-alist-option org-M-RET-may-split-line 'headline)) > @@ -4652,6 +4655,10 @@ but create the new hedline after the current > line." > (setq pos (point)) > (end-of-line 1) > (unless (= (point) pos) (just-one-space) (backward-delete-char 1)) > + (when (and org-insert-heading-respect-content should-hide- > previous-heading) > + (save-excursion > + (outline-previous-visible-heading 1) > + (hide-entry))) > (run-hooks 'org-insert-heading-hook))))) > > (defun org-get-heading (&optional no-tags) > @@ -4675,7 +4682,7 @@ but create the new hedline after the current > line." > (defun org-insert-heading-respect-content () > (interactive) > (let ((org-insert-heading-respect-content t)) > - (call-interactively 'org-insert-heading))) > + (org-insert-heading t))) > > (defun org-insert-todo-heading-respect-content () > (interactive) > -- > 1.6.0 > > > From e7de89ce7a1bd3ab2259159fdb65b052d74370a0 Mon Sep 17 00:00:00 2001 > From: Peter Jones > Date: Fri, 17 Oct 2008 17:57:47 -0600 > Subject: [PATCH] Update documentation WRT C-RET > > --- > doc/org.texi | 5 +++-- > 1 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/doc/org.texi b/doc/org.texi > index 31996e0..b76fcaf 100644 > --- a/doc/org.texi > +++ b/doc/org.texi > @@ -897,8 +897,9 @@ of a headline), then a headline like the current > one will be inserted > after the end of the subtree. > @kindex C-@key{RET} > @item C-@key{RET} > -Just like @kbd{M-@key{RET}}, but if the heading is inserted after > the current, > -insert it actually after the entire subtree. > +Just like @kbd{M-@key{RET}}, except when adding a new heading below > the > +current heading, the new heading is placed after the body instead > of before > +it. This command works from anywhere in the entry. > @kindex M-S-@key{RET} > @item M-S-@key{RET} > Insert new TODO entry with same level as current heading. > -- > 1.6.0 > > > From 4f7aed562ae93759fb1638378029aeef3cc70e79 Mon Sep 17 00:00:00 2001 > From: Peter Jones > Date: Fri, 17 Oct 2008 18:03:38 -0600 > Subject: [PATCH] Also fix org-insert-todo-heading > > --- > lisp/org.el | 10 +++++----- > 1 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/lisp/org.el b/lisp/org.el > index 541cf3a..5e4d6a5 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -4684,18 +4684,18 @@ but create the new hedline after the current > line." > (let ((org-insert-heading-respect-content t)) > (org-insert-heading t))) > > -(defun org-insert-todo-heading-respect-content () > - (interactive) > +(defun org-insert-todo-heading-respect-content (force-state) > + (interactive "P") > (let ((org-insert-heading-respect-content t)) > - (call-interactively 'org-insert-todo-heading))) > + (org-insert-todo-heading force-state t))) > > -(defun org-insert-todo-heading (arg) > +(defun org-insert-todo-heading (arg &optional force-heading) > "Insert a new heading with the same level and TODO state as > current heading. > If the heading has no TODO state, or if the state is DONE, use the > first > state (TODO by default). Also with prefix arg, force first state." > (interactive "P") > (when (not (org-insert-item 'checkbox)) > - (org-insert-heading) > + (org-insert-heading force-heading) > (save-excursion > (org-back-to-heading) > (outline-previous-heading) > -- > 1.6.0 > > > -- > Peter Jones, http://pmade.com > pmade inc. Louisville, CO US > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode --Apple-Mail-1--612442631 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Peter,

I = have applied your full patch, thanks.

Please = verify the push, I did have a little technical problem when applying, so = please make sure it worked = correctly.

Thanks.

- = Carsten
On Oct 18, 2008, at 2:10 AM, Peter Jones = wrote:


Since commit 238d0d1 (Improve consistency for = inserting new headlines)
a few minor inconsistencies were introduced = to heading creation with
the control key, A.K.A. = org-insert-heading-respect-content.  This
patch resolves those = subtle "bugs".

This patch changes = org-insert-heading-respect-content so that it:

- Creates a new = heading even if point is in a plain list
  (force-heading = is set to true, behavior before 238d0d1)
- If the previous heading = was closed, keep it closed
  (keeps the previous heading = in the state it was before C-RET)

It also includes changes for = org-insert-todo-heading and the OrgMode
manual.

Thanks Carsten = for making the changes in 238d0d1 for me.  With the
attached = patch, heading creation is now perfect (for me at least ;).

=46rom = 200826587af4bd40995d1d45381006ed0639f7e9 Mon Sep 17 00:00:00 = 2001
From: Peter Jones <pjones@pmade.com>
Date: Fri, 17 = Oct 2008 17:26:11 -0600
Subject: [PATCH] Fix Subtle Heading Creation = Bugs

Since commit 238d0d1 (Improve consistency for inserting new = headlines)
a few minor inconsistencies were introduced to heading = creation with
the control key, A.K.A. = org-insert-heading-respect-content.  This
patch resolves those = subtle "bugs".

This patch changes = org-insert-heading-respect-content so that it:

- Creates a new = heading even if point is in a plain list
  (force-heading = is set to true, behavior before 238d0d1)
- If the previous heading = was closed, keep it closed
  (keeps the previous heading = in the state it was before C-RET)
---
lisp/org.el | =   11 +++++++++--
1 files changed, 9 insertions(+), 2 = deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index = 9c08ba4..541cf3a 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ = -4607,7 +4607,7 @@ but create the new hedline after the current = line."
= = =   (match-string 0))
=       (error "*"))))
=     (blank (cdr (assq 'heading = org-blank-before-new-entry)))
- =     pos)
+     pos = should-hide-previous-heading)
(cond
((and = (org-on-heading-p) (bolp)
=       (or (bobp)
@@ -4622,6 +4622,9 @@ = but create the new hedline after the current line."
=  nil)
= (t
=  ;; in the middle of the line
+ =          (save-excursion
+= =            (end-of-= line)
+ =            (setq = should-hide-previous-heading (org-invisible-p)))
=  (org-show-entry)
 (let ((split
= (org-get-alist-option org-M-RET-may-split-line 'headline))
@@ -4652,6 = +4655,10 @@ but create the new hedline after the current line."
= = (setq pos (point))
(end-of-line 1)
(unless = (=3D (point) pos) (just-one-space) (backward-delete-char 1))
+ =        (when (and = org-insert-heading-respect-content should-hide-previous-heading)
+ =            (save-ex= cursion
+ =             &n= bsp;(outline-previous-visible-heading 1)
+ =             &n= bsp;(hide-entry)))
(run-hooks = 'org-insert-heading-hook)))))

(defun org-get-heading = (&optional no-tags)
@@ -4675,7 +4682,7 @@ but create the new = hedline after the current line."
(defun = org-insert-heading-respect-content ()
  (interactive)
=   (let ((org-insert-heading-respect-content t))
- =    (call-interactively 'org-insert-heading)))
+ =    (org-insert-heading t)))

(defun = org-insert-todo-heading-respect-content ()
=   (interactive)
--
1.6.0


=46rom = e7de89ce7a1bd3ab2259159fdb65b052d74370a0 Mon Sep 17 00:00:00 = 2001
From: Peter Jones <pjones@pmade.com>
Date: Fri, 17 = Oct 2008 17:57:47 -0600
Subject: [PATCH] Update documentation WRT = C-RET

---
doc/org.texi |    5 +++--
1 = files changed, 3 insertions(+), 2 deletions(-)

diff --git = a/doc/org.texi b/doc/org.texi
index 31996e0..b76fcaf 100644
--- = a/doc/org.texi
+++ b/doc/org.texi
@@ -897,8 +897,9 @@ of a = headline), then a headline like the current one will be inserted
= after the end of the subtree.
@kindex C-@key{RET}
@item = C-@key{RET}
-Just like @kbd{M-@key{RET}}, but if the heading is = inserted after the current,
-insert it actually after the entire = subtree.
+Just like @kbd{M-@key{RET}}, except when adding a new = heading below the
+current heading, the new heading is placed after = the body instead of before
+it.  This command works from = anywhere in the entry.
@kindex M-S-@key{RET}
@item = M-S-@key{RET}
Insert new TODO entry with same level as current = heading.
--
1.6.0


=46rom = 4f7aed562ae93759fb1638378029aeef3cc70e79 Mon Sep 17 00:00:00 = 2001
From: Peter Jones <pjones@pmade.com>
Date: Fri, 17 = Oct 2008 18:03:38 -0600
Subject: [PATCH] Also fix = org-insert-todo-heading

---
lisp/org.el |   10 = +++++-----
1 files changed, 5 insertions(+), 5 = deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index = 541cf3a..5e4d6a5 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ = -4684,18 +4684,18 @@ but create the new hedline after the current = line."
  (let ((org-insert-heading-respect-content t))
=     (org-insert-heading t)))

-(defun = org-insert-todo-heading-respect-content ()
- =  (interactive)
+(defun org-insert-todo-heading-respect-content = (force-state)
+  (interactive "P")
  (let = ((org-insert-heading-respect-content t))
- =    (call-interactively 'org-insert-todo-heading)))
+ =    (org-insert-todo-heading force-state = t)))

-(defun org-insert-todo-heading (arg)
+(defun = org-insert-todo-heading (arg &optional force-heading)
=   "Insert a new heading with the same level and TODO state as = current heading.
If the heading has no TODO state, or if the state = is DONE, use the first
state (TODO by default).  Also with = prefix arg, force first state."
  (interactive "P")
=   (when (not (org-insert-item 'checkbox))
- =    (org-insert-heading)
+ =    (org-insert-heading force-heading)
=     (save-excursion
=       (org-back-to-heading)
=       (outline-previous-heading)
-- =
1.6.0


--
Peter Jones, http://pmade.com
pmade inc. =  Louisville, CO = US
_______________________________________________
Emacs-orgmode = mailing list
Remember: use `Reply All' to send replies to the = list.
Emacs-orgmode@gnu.org
http://= lists.gnu.org/mailman/listinfo/emacs-orgmode

= --Apple-Mail-1--612442631-- --===============0766421402== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============0766421402==--