mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 19:07:52 +00:00
org-list: Another fix to item insertion
* lisp/org-list.el (org-list-insert-item): Fix typos. Add a check to determine if an item really belongs to the part being split. * testing/lisp/test-org-list.el (test-org-list/insert-item): Add test.
This commit is contained in:
parent
8eef99306a
commit
8b988ee3a5
|
@ -1325,13 +1325,12 @@ This function modifies STRUCT."
|
||||||
(setcar (nthcdr 6 e) (+ end size-offset)))
|
(setcar (nthcdr 6 e) (+ end size-offset)))
|
||||||
;; Items starting after modified item fall into two
|
;; Items starting after modified item fall into two
|
||||||
;; categories. If item was split, and current item was
|
;; categories. If item was split, and current item was
|
||||||
;; located after split point, it was moved to the new
|
;; located after split point, it was moved to the new item.
|
||||||
;; item. Practically speaking, this means that the part
|
;; This means that the part between body start of body and
|
||||||
;; between body start of body and split point was removed.
|
;; split point was removed. So we compute the offset and
|
||||||
;; So we compute the offset and shit item's positions
|
;; shift item's positions accordingly. In any other case,
|
||||||
;; accordingly. In any other case, the item was simply
|
;; the item was simply shifted by ITEM-SIZE.
|
||||||
;; shifted by ITEM-SIZE.
|
((and split-line-p (not beforep) (>= p pos) (<= p item-end-no-blank))
|
||||||
((and split-line-p (not beforep) (>= p pos))
|
|
||||||
(let ((offset (- pos item ind (length bullet) (length after-bullet))))
|
(let ((offset (- pos item ind (length bullet) (length after-bullet))))
|
||||||
(setcar e (- p offset))
|
(setcar e (- p offset))
|
||||||
(setcar (nthcdr 6 e) (- end offset))))
|
(setcar (nthcdr 6 e) (- end offset))))
|
||||||
|
|
|
@ -787,6 +787,12 @@ b. Item 2<point>"
|
||||||
(let ((org-M-RET-may-split-line '((default . nil))))
|
(let ((org-M-RET-may-split-line '((default . nil))))
|
||||||
(org-insert-item))
|
(org-insert-item))
|
||||||
(buffer-string))))
|
(buffer-string))))
|
||||||
|
;; Re-order automatically.
|
||||||
|
(should
|
||||||
|
(equal "1. A\n\n2. \n\n3. \n\n4. B"
|
||||||
|
(org-test-with-temp-text "1. A<point>\n\n2. \n\n3. B"
|
||||||
|
(org-insert-item)
|
||||||
|
(buffer-string))))
|
||||||
;; Preserve list visibility when inserting an item.
|
;; Preserve list visibility when inserting an item.
|
||||||
(should
|
(should
|
||||||
(equal
|
(equal
|
||||||
|
|
Loading…
Reference in a new issue