mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 18:36:26 +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)))
|
||||
;; Items starting after modified item fall into two
|
||||
;; categories. If item was split, and current item was
|
||||
;; located after split point, it was moved to the new
|
||||
;; item. Practically speaking, this means that the part
|
||||
;; between body start of body and split point was removed.
|
||||
;; So we compute the offset and shit item's positions
|
||||
;; accordingly. In any other case, the item was simply
|
||||
;; shifted by ITEM-SIZE.
|
||||
((and split-line-p (not beforep) (>= p pos))
|
||||
;; located after split point, it was moved to the new item.
|
||||
;; This means that the part between body start of body and
|
||||
;; split point was removed. So we compute the offset and
|
||||
;; shift item's positions accordingly. In any other case,
|
||||
;; the item was simply shifted by ITEM-SIZE.
|
||||
((and split-line-p (not beforep) (>= p pos) (<= p item-end-no-blank))
|
||||
(let ((offset (- pos item ind (length bullet) (length after-bullet))))
|
||||
(setcar e (- p offset))
|
||||
(setcar (nthcdr 6 e) (- end offset))))
|
||||
|
|
|
@ -787,6 +787,12 @@ b. Item 2<point>"
|
|||
(let ((org-M-RET-may-split-line '((default . nil))))
|
||||
(org-insert-item))
|
||||
(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.
|
||||
(should
|
||||
(equal
|
||||
|
|
Loading…
Reference in a new issue