0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-08-23 07:18:40 +00:00

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.
This commit is contained in:
Nicolas Goaziou 2010-07-17 10:05:05 +02:00
parent deb6b0c504
commit 7cf8ab06de

View file

@ -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))