소스 검색

Clocking: Make insertion of the CLOCK drawer safer

Daniel Clemente noticed that the clock drawer, when it is created for
the second clock entry, will swallow a plain list item after it,
because it thinks it might be a clock note.

This commit makes this function check for indentation.  If the plain
list item is indented less than the last clock line, it will be
assumed that it does not belong to the clocking line, and the drawer
will not swallow the item.
Carsten Dominik 16 년 전
부모
커밋
621bafc1b5
2개의 변경된 파일9개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 0
      lisp/ChangeLog
  2. 6 3
      lisp/org-clock.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2009-02-11  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-clock.el (org-clock-find-position): Do not swallow an item
+	less indented than the CLOCK line itself.
+
 	* org-exp.el (org-html-level-start): Add a CSS class to section
 	numbers.
 	(org-export-html-toplevel-hlevel): Better documentation of the

+ 6 - 3
lisp/org-clock.el

@@ -380,7 +380,7 @@ the clocking selection, associated with the letter `d'."
 	  (end (progn (outline-next-heading) (point)))
 	  (re (concat "^[ \t]*" org-clock-string))
 	  (cnt 0)
-	  first last)
+	  first last ind-last)
       (goto-char beg)
       (when (eobp) (newline) (setq end (max (point) end)))
       (when (re-search-forward "^[ \t]*:CLOCK:" end t)
@@ -397,11 +397,14 @@ the clocking selection, associated with the letter `d'."
 		 (>= (1+ cnt) org-clock-into-drawer))
 	;; Wrap current entries into a new drawer
 	(goto-char last)
+	(setq ind-last (org-get-indentation))
 	(beginning-of-line 2)
-	(if (org-at-item-p) (org-end-of-item))
+	(if (and (>= (org-get-indentation) ind-last)
+		 (org-at-item-p))
+	    (org-end-of-item))
 	(insert ":END:\n")
 	(beginning-of-line 0)
-	(org-indent-line-function)
+	(org-indent-line-to ind-last)
 	(goto-char first)
 	(insert ":CLOCK:\n")
 	(beginning-of-line 0)