소스 검색

Fix list before first heading conversion to odd levels subtree

* lisp/org-list.el (org-list-to-subtree): if the list is before first
  heading and `org-odd-levels-only' is non-nil, the first item gets
  two stars instead of one.
* lisp/org.el (org-reduced-level): a level of 0 was reduced to 1 with
  `org-odd-levels-only' non-nil.
Nicolas Goaziou 14 년 전
부모
커밋
ddc2467387
2개의 변경된 파일11개의 추가작업 그리고 7개의 파일을 삭제
  1. 7 6
      lisp/org-list.el
  2. 4 1
      lisp/org.el

+ 7 - 6
lisp/org-list.el

@@ -2989,7 +2989,7 @@ with overruling parameters for `org-list-to-generic'."
 LIST is as returned by `org-list-parse-list'.  PARAMS is a property list
 with overruling parameters for `org-list-to-generic'."
   (let* ((rule (cdr (assq 'heading org-blank-before-new-entry)))
-	 (level (or (org-current-level) 0))
+	 (level (org-reduced-level (or (org-current-level) 0)))
 	 (blankp (or (eq rule t)
 		     (and (eq rule 'auto)
 			  (save-excursion
@@ -3000,11 +3000,12 @@ with overruling parameters for `org-list-to-generic'."
 	   ;; Return the string for the heading, depending on depth D
 	   ;; of current sub-list.
 	   (lambda (d)
-	     (concat
-	      (make-string (+ level
-			      (if org-odd-levels-only (* 2 (1+ d)) (1+ d)))
-			   ?*)
-	      " ")))))
+	     (let ((oddeven-level (+ level d 1)))
+	       (concat (make-string (if org-odd-levels-only
+					(1- (* 2 oddeven-level))
+				      oddeven-level)
+				    ?*)
+		       " "))))))
     (org-list-to-generic
      list
      (org-combine-plists

+ 4 - 1
lisp/org.el

@@ -7122,7 +7122,10 @@ first headline."
 (defun org-reduced-level (l)
   "Compute the effective level of a heading.
 This takes into account the setting of `org-odd-levels-only'."
-  (if org-odd-levels-only (1+ (floor (/ l 2))) l))
+  (cond
+   ((zerop l) 0)
+   (org-odd-levels-only (1+ (floor (/ l 2))))
+   (t l)))
 
 (defun org-level-increment ()
   "Return the number of stars that will be added or removed at a