summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2014-08-28 11:07:24 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2014-08-28 11:07:24 +0200
commit2e5b3dede103bba0071144ec7b7fc250471c1463 (patch)
tree6782ace8c6a11d5f5a41393e214cdd6d2d201e86
parent42271d8c4357172e2a1d0f5eda132f789c1b56bb (diff)
downloadorg-mode-2e5b3dede103bba0071144ec7b7fc250471c1463.tar.gz
org-element: Interpret headlines according to `org-odd-levels-only'
* lisp/org-element.el (org-element-headline-interpreter): Take into consideration `org-odd-levels-only' value. Small refactoring. * testing/lisp/test-org-element.el (test-org-element/headline-interpreter): Add test.
-rw-r--r--lisp/org-element.el60
-rw-r--r--testing/lisp/test-org-element.el7
2 files changed, 37 insertions, 30 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 7a42138..76c93ce 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -870,38 +870,40 @@ CONTENTS is the contents of the element."
(org-element-property :tags headline))
(org-element-property :tags headline))))
(and tag-list
- (format ":%s:" (mapconcat 'identity tag-list ":")))))
+ (format ":%s:" (mapconcat #'identity tag-list ":")))))
(commentedp (org-element-property :commentedp headline))
(quotedp (org-element-property :quotedp headline))
(pre-blank (or (org-element-property :pre-blank headline) 0))
- (heading (concat (make-string (org-reduced-level level) ?*)
- (and todo (concat " " todo))
- (and quotedp (concat " " org-quote-string))
- (and commentedp (concat " " org-comment-string))
- (and priority
- (format " [#%s]" (char-to-string priority)))
- (cond ((and org-footnote-section
- (org-element-property
- :footnote-section-p headline))
- (concat " " org-footnote-section))
- (title (concat " " title))))))
- (concat heading
- ;; Align tags.
- (when tags
- (cond
- ((zerop org-tags-column) (format " %s" tags))
- ((< org-tags-column 0)
- (concat
- (make-string
- (max (- (+ org-tags-column (length heading) (length tags))) 1)
- ? )
- tags))
- (t
- (concat
- (make-string (max (- org-tags-column (length heading)) 1) ? )
- tags))))
- (make-string (1+ pre-blank) 10)
- contents)))
+ (heading
+ (concat (make-string (if org-odd-levels-only (1- (* level 2)) level)
+ ?*)
+ (and todo (concat " " todo))
+ (and quotedp (concat " " org-quote-string))
+ (and commentedp (concat " " org-comment-string))
+ (and priority (format " [#%s]" (char-to-string priority)))
+ " "
+ (if (and org-footnote-section
+ (org-element-property :footnote-section-p headline))
+ org-footnote-section
+ title))))
+ (concat
+ heading
+ ;; Align tags.
+ (when tags
+ (cond
+ ((zerop org-tags-column) (format " %s" tags))
+ ((< org-tags-column 0)
+ (concat
+ (make-string
+ (max (- (+ org-tags-column (length heading) (length tags))) 1)
+ ?\s)
+ tags))
+ (t
+ (concat
+ (make-string (max (- org-tags-column (length heading)) 1) ?\s)
+ tags))))
+ (make-string (1+ pre-blank) ?\n)
+ contents)))
;;;; Inlinetask
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index b188950..12cd2bd 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -2209,7 +2209,12 @@ Outside list"
(should
(equal (org-test-parse-and-interpret
"* Headline\n\n\nText after two blank lines.")
- "* Headline\n\n\nText after two blank lines.\n")))
+ "* Headline\n\n\nText after two blank lines.\n"))
+ ;; 8. Preserve `org-odd-levels-only' state.
+ (should
+ (equal "* H\n*** H2\n"
+ (let ((org-odd-levels-only t))
+ (org-test-parse-and-interpret "* H\n*** H2")))))
(ert-deftest test-org-element/inlinetask-interpreter ()
"Test inlinetask interpretation."