From: Michael Brand <michael.ch.brand@gmail.com>
To: Nicolas Goaziou <n.goaziou@gmail.com>, Org Mode <emacs-orgmode@gnu.org>
Subject: [PATCH] Bugfix for heading levels when toggling from list
Date: Thu, 9 Jun 2011 09:07:19 +0200 [thread overview]
Message-ID: <BANLkTi=Ud9bfRgmjVAsiz9sBa_=9JqcGgQ@mail.gmail.com> (raw)
[-- 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
next reply other threads:[~2011-06-09 7:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-09 7:07 Michael Brand [this message]
2011-06-09 7:54 ` [PATCH] Bugfix for heading levels when toggling from list Nicolas Goaziou
2011-06-09 11:13 ` Michael Brand
2011-06-10 5:25 ` Nicolas Goaziou
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='BANLkTi=Ud9bfRgmjVAsiz9sBa_=9JqcGgQ@mail.gmail.com' \
--to=michael.ch.brand@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=n.goaziou@gmail.com \
/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 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.