mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-22 11:18:32 +00:00
Better guessing of blank lines when inserting an item.
* org-list.el (org-list-insert-item-generic): When local search doesn't help, search the list globally for blank lines. Moreover, don't bother with new lists, and add 1 blank line.
This commit is contained in:
parent
ff6c147ac6
commit
2c3157e34e
|
@ -355,9 +355,17 @@ function ends."
|
|||
(let ((insert-blank-p
|
||||
(cdr (assq 'plain-list-item org-blank-before-new-entry))))
|
||||
(cond
|
||||
;; Trivial cases where there should be none.
|
||||
((or org-empty-line-terminates-plain-lists
|
||||
(not insert-blank-p)) 0)
|
||||
((eq insert-blank-p t) 1)
|
||||
;; When `org-blank-before-new-entry' says so, or item is
|
||||
;; alone in the whole list, it is 1.
|
||||
((or (eq insert-blank-p t)
|
||||
(save-excursion
|
||||
(goto-char (org-list-top-point))
|
||||
(end-of-line)
|
||||
(not (org-search-forward-unenclosed
|
||||
org-item-beginning-re (org-list-bottom-point) t)))) 1)
|
||||
;; plain-list-item is 'auto. Count blank lines separating
|
||||
;; neighbours items in list.
|
||||
(t (let ((next-p (org-get-next-item (point) (org-list-bottom-point))))
|
||||
|
@ -367,8 +375,13 @@ function ends."
|
|||
(org-back-over-empty-lines))
|
||||
;; Is there a previous item?
|
||||
((not (org-first-list-item-p)) (org-back-over-empty-lines))
|
||||
;; no luck: item is alone. Use default value.
|
||||
(t 1)))))))
|
||||
;; Local search failed: search globally.
|
||||
((and (goto-char (org-list-bottom-point))
|
||||
(beginning-of-line 0)
|
||||
(org-search-backward-unenclosed "^[ \t]*$" (org-list-top-point) t))
|
||||
(1+ (org-back-over-empty-lines)))
|
||||
;; No blank line found in the whole list.
|
||||
(t 0)))))))
|
||||
(insert-fun
|
||||
(lambda (text)
|
||||
;; insert bullet above item in order to avoid bothering
|
||||
|
|
Loading…
Reference in a new issue