mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 18:36:26 +00:00
org-list: Fix last commit
* lisp/org-list.el (org-list-insert-item): This is a followup to
1ae1f8f2df
. It fixes an error when
insertion happens after the last item in the list.
* testing/lisp/test-org-list.el (test-org-list/insert-item): Add test.
This commit is contained in:
parent
6f1b837492
commit
8eef99306a
|
@ -1240,15 +1240,15 @@ This function modifies STRUCT."
|
|||
;; (SPLIT-LINE-P).
|
||||
(item
|
||||
(catch :exit
|
||||
;; Do not initialize I as top item as we don't know if the
|
||||
;; list is correctly structured.
|
||||
(let ((i nil))
|
||||
(pcase-dolist (`(,start ,_ ,_ ,_ ,_ ,_ ,end) struct)
|
||||
(cond
|
||||
((> start pos) (throw :exit i))
|
||||
((< end pos) nil) ;skip sub-lists before point
|
||||
(t (setq i start))))
|
||||
(or i (org-list-get-top-point struct)))))
|
||||
;; If no suitable item is found, insert a sibling of the
|
||||
;; last item in buffer.
|
||||
(or i (caar (reverse struct))))))
|
||||
(item-end (org-list-get-item-end item struct))
|
||||
(item-end-no-blank (org-list-get-item-end-before-blank item struct))
|
||||
(beforep
|
||||
|
|
|
@ -749,6 +749,18 @@ b. Item 2<point>"
|
|||
(org-test-with-temp-text "- <point>item"
|
||||
(org-insert-item)
|
||||
(buffer-string))))
|
||||
;; When called at the very end of the list, insert new item as
|
||||
;; a sibling of the very last one.
|
||||
(should
|
||||
(equal "- A\n\n - B\n\n - "
|
||||
(org-test-with-temp-text "- A\n\n - B\n\n<point>"
|
||||
(org-insert-item)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(equal "- A\n\n - B\n\n - "
|
||||
(org-test-with-temp-text "- A\n\n - B\n\n <point>"
|
||||
(org-insert-item)
|
||||
(buffer-string))))
|
||||
;; When called on tag in a descriptive list, insert new item before
|
||||
;; current one too.
|
||||
(should
|
||||
|
|
Loading…
Reference in a new issue