* [PATCH] Bugfix for heading levels when toggling from list
@ 2011-06-09 7:07 Michael Brand
2011-06-09 7:54 ` Nicolas Goaziou
0 siblings, 1 reply; 4+ messages in thread
From: Michael Brand @ 2011-06-09 7:07 UTC (permalink / raw)
To: Nicolas Goaziou, Org Mode
[-- Attachment #1: Type: text/plain, Size: 392 bytes --]
Hi Nicolas, hi all
The help provided from this thread about the function outline-level
and "Match Data"
http://thread.gmane.org/gmane.emacs.orgmode/42611
allowed me to make the attached patch. It resolves two or so buglets,
the one I found first was introduced by
http://orgmode.org/w/?p=org-mode.git;a=commitdiff;h=ddc24673877da5f7d82375fb10b8cc238e2ff6a7
according to git bisect.
Michael
[-- Attachment #2: 0001-Bugfix-for-heading-levels-when-toggling-from-list.patch --]
[-- Type: application/octet-stream, Size: 2743 bytes --]
From ffcbe6207484ec08fc1bdd2b911459326cb338b5 Mon Sep 17 00:00:00 2001
From: Michael Brand <michael.ch.brand@gmail.com>
Date: Thu, 9 Jun 2011 08:59:09 +0200
Subject: [PATCH] Bugfix for heading levels when toggling from list
* org.el (org-toggle-heading): More comments and fix number of stars
when toggling from list items.
---
lisp/org.el | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index bb00573..f9745c1 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17963,12 +17963,20 @@ stars to add."
(looking-at outline-regexp) (replace-match ""))
(forward-line)))
;; Case 2. Started at an item: change items into headlines.
+ ;; One star will be added by `org-list-to-subtree'.
((org-at-item-p)
- (let ((stars (make-string
- (if nstars
- (prefix-numeric-value current-prefix-arg)
- (or (org-current-level) 0))
- ?*)))
+ (let* ((stars (make-string
+ (if nstars
+ ;; subtract the star that will be added again by
+ ;; `org-list-to-subtree'
+ (1- (prefix-numeric-value current-prefix-arg))
+ (or (org-current-level) 0))
+ ?*))
+ (add-stars
+ (cond (nstars "") ; stars from prefix only
+ ((equal stars "") "") ; before first heading
+ (org-odd-levels-only "*") ; inside heading, odd
+ (t "")))) ; inside heading, oddeven
(while (< (point) end)
(when (org-at-item-p)
;; Pay attention to cases when region ends before list.
@@ -17979,9 +17987,8 @@ stars to add."
(insert
(org-list-to-subtree
(org-list-parse-list t)
- '(:istart (concat stars (funcall get-stars depth))
- :icount (concat stars
- (funcall get-stars depth))))))))
+ '(:istart (concat stars add-stars (funcall get-stars depth))
+ :icount (concat stars add-stars (funcall get-stars depth))))))))
(forward-line))))
;; Case 3. Started at normal text: make every line an heading,
;; skipping headlines and items.
@@ -17990,10 +17997,11 @@ stars to add."
(prefix-numeric-value current-prefix-arg)
(or (org-current-level) 0))
?*))
- (add-stars (cond (nstars "")
- ((equal stars "") "*")
- (org-odd-levels-only "**")
- (t "*")))
+ (add-stars
+ (cond (nstars "") ; stars from prefix only
+ ((equal stars "") "*") ; before first heading
+ (org-odd-levels-only "**") ; inside heading, odd
+ (t "*"))) ; inside heading, oddeven
(rpl (concat stars add-stars " ")))
(while (< (point) end)
(when (and (not (org-on-heading-p)) (not (org-at-item-p))
--
1.7.4.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Bugfix for heading levels when toggling from list
2011-06-09 7:07 [PATCH] Bugfix for heading levels when toggling from list Michael Brand
@ 2011-06-09 7:54 ` Nicolas Goaziou
2011-06-09 11:13 ` Michael Brand
0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2011-06-09 7:54 UTC (permalink / raw)
To: Michael Brand; +Cc: Org Mode
Hello,
Michael Brand <michael.ch.brand@gmail.com> writes:
> The help provided from this thread about the function outline-level
> and "Match Data"
> http://thread.gmane.org/gmane.emacs.orgmode/42611
> allowed me to make the attached patch. It resolves two or so buglets,
> the one I found first was introduced by
> http://orgmode.org/w/?p=org-mode.git;a=commitdiff;h=ddc24673877da5f7d82375fb10b8cc238e2ff6a7
> according to git bisect.
I would happily apply your patch, but could you explain, before, what
bugs are solved by it ? Thank you.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Bugfix for heading levels when toggling from list
2011-06-09 7:54 ` Nicolas Goaziou
@ 2011-06-09 11:13 ` Michael Brand
2011-06-10 5:25 ` Nicolas Goaziou
0 siblings, 1 reply; 4+ messages in thread
From: Michael Brand @ 2011-06-09 11:13 UTC (permalink / raw)
To: Michael Brand, Org Mode
On Thu, Jun 9, 2011 at 09:54, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> I would happily apply your patch, but could you explain, before, what
> bugs are solved by it ? Thank you.
BTW, your bugfix commit mentioned by me was not buggy at all, it just
unleashed (before I wrongly wrote "introduced") this buglet hidden
before: "C-c *" on an item inside heading and only with "odd":
#+begin_src org
,#+STARTUP: odd
,* section
, - item
#+end_src
expected: 3 stars, buglet: 2 stars
The second buglet, found in the source code while resolving the first:
"M-1 C-c *" on an item before first heading:
#+begin_src org
,- item
#+end_src
expected: 1 star, buglet: 2 stars
According to my understanding of the source code of org-toggle-heading
I expect no other buglet with "C-c *" on items or body text. At least
I found no buglet left when testing my changes with the necessary
combinations to cover all 4 cases within each of both "cond" and both
"if nstar" in the source code region I changed:
- no region / region with body text lines or one item nested in one item
- item(s) / body text line(s)
- before first heading / inside heading
- "C-c *" / "M-1 C-c *" / "M-2 C-c *"
- #+STARTUP: oddeven / odd
Quite a rigorous testing :-)
Michael
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Bugfix for heading levels when toggling from list
2011-06-09 11:13 ` Michael Brand
@ 2011-06-10 5:25 ` Nicolas Goaziou
0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2011-06-10 5:25 UTC (permalink / raw)
To: Michael Brand; +Cc: Org Mode
Michael Brand <michael.ch.brand@gmail.com> writes:
> #+begin_src org
> ,#+STARTUP: odd
> ,* section
> , - item
> #+end_src
>
> expected: 3 stars, buglet: 2 stars
> #+begin_src org
> ,- item
> #+end_src
>
> expected: 1 star, buglet: 2 stars
This is clearer now. Thanks for the examples and the patch. I have now
applied it.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-06-10 5:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-09 7:07 [PATCH] Bugfix for heading levels when toggling from list Michael Brand
2011-06-09 7:54 ` Nicolas Goaziou
2011-06-09 11:13 ` Michael Brand
2011-06-10 5:25 ` Nicolas Goaziou
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.