From 0e73297707eaf98aeb3fd0747ff8b408fc40ae58 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 27 Jul 2020 03:07:04 -0400 Subject: [PATCH] lang/org: fix edge case in +org--insert-item --- modules/lang/org/autoload/org.el | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/lang/org/autoload/org.el b/modules/lang/org/autoload/org.el index 65ced335c..a001f5dfe 100644 --- a/modules/lang/org/autoload/org.el +++ b/modules/lang/org/autoload/org.el @@ -34,10 +34,16 @@ ;; insert the new list item. (if (eq direction 'above) (org-beginning-of-item) - (org-end-of-item)) - (if (org-element-property :checkbox context) - (org-insert-todo-heading nil) - (org-insert-item))) + (org-end-of-item) + (backward-char)) + (org-insert-item (org-element-property :checkbox context)) + ;; Handle edge case where current item is empty and bottom of list is + ;; flush against a new heading. + (when (and (eq direction 'below) + (eq (org-element-property :contents-begin context) + (org-element-property :contents-end context))) + (org-end-of-item) + (org-end-of-line))) ;; Add a new table row ((or `table `table-row)