Browse Source

Fix inserting item with point before first char of item's body.

* lisp/org-list.el (org-insert-item-internal): fixes the problem when
  point was before the first char of the item's body.
Nicolas Goaziou 9 years ago
parent
commit
7cf8ab06de
1 changed files with 6 additions and 5 deletions
  1. 6 5
      lisp/org-list.el

+ 6 - 5
lisp/org-list.el

@@ -353,9 +353,9 @@ function end."
     (re-search-backward "^[ \t]*#\\+\\(begin\\|BEGIN\\)_" nil t)
     (end-of-line 0))
   (let* ((true-pos (point))
-	 (item-start (org-beginning-of-item))
-	 (bullet-init (and (looking-at (org-item-re))
-			   (match-string 0)))
+	 (bullet (and (org-beginning-of-item)
+		      (looking-at (org-item-re))
+		      (match-string 0)))
 	 (before-p (progn
 		     ;; Descriptive list: text starts after colons.
 		     (or (looking-at ".*::[ \t]+")
@@ -363,7 +363,7 @@ function end."
 			 (org-at-item-checkbox-p)
 			 ;; Otherwise, text starts after bullet.
 			 (org-at-item-p))
-		     (< true-pos (match-end 0))))
+		     (<= true-pos (match-end 0))))
 	 ;; Guess number of blank lines used to separate items.
 	 (blank-lines-nb
 	  (let ((insert-blank-p
@@ -390,9 +390,10 @@ function end."
 	    ;; insert bullet above item in order to avoid bothering
 	    ;; with possible blank lines ending last item.
 	    (org-beginning-of-item)
-	    (insert (concat bullet-init
+	    (insert (concat bullet
 			    (when checkbox "[ ] ")
 			    after-bullet))
+	    ;; Stay between after-bullet and before text.
 	    (save-excursion
 	      (insert (concat text (make-string (1+ blank-lines-nb) ?\n))))
 	    (unless before-p (org-move-item-down))