mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-25 12:02:52 +00:00
Blank lines number is guessed locally when inserting item.
* org-list.el (org-insert-item-internal): guessing of blank lines number is made by looking at neighbours items, if any.
This commit is contained in:
parent
905ad49e9a
commit
c3bbbc0926
|
@ -322,7 +322,7 @@ new item will be created before the current one.
|
||||||
|
|
||||||
Insert a checkbox if CHECKBOX is non-nil, and string AFTER-BULLET
|
Insert a checkbox if CHECKBOX is non-nil, and string AFTER-BULLET
|
||||||
after the bullet. Cursor will be after this text once the
|
after the bullet. Cursor will be after this text once the
|
||||||
function end."
|
function ends."
|
||||||
(goto-char pos)
|
(goto-char pos)
|
||||||
;; Point in a special block: move before it prior to add a new item.
|
;; Point in a special block: move before it prior to add a new item.
|
||||||
(when (org-in-regexps-block-p
|
(when (org-in-regexps-block-p
|
||||||
|
@ -355,16 +355,17 @@ function end."
|
||||||
0)
|
0)
|
||||||
((eq insert-blank-p t) 1)
|
((eq insert-blank-p t) 1)
|
||||||
;; plain-list-item is 'auto. Count blank lines separating
|
;; plain-list-item is 'auto. Count blank lines separating
|
||||||
;; items in current list.
|
;; neighbours items in list.
|
||||||
(t
|
(t
|
||||||
(save-excursion
|
(let ((next-p (org-get-next-item (point) (org-list-bottom-point))))
|
||||||
(if (progn
|
(cond
|
||||||
(org-end-of-item-list)
|
;; Is there a next item?
|
||||||
(skip-chars-backward " \r\t\n")
|
(next-p (goto-char next-p)
|
||||||
(org-search-backward-unenclosed
|
(org-back-over-empty-lines))
|
||||||
"^[ \t]*$" (save-excursion (org-beginning-of-item-list)) t))
|
;; Is there a previous item?
|
||||||
(1+ (org-back-over-empty-lines))
|
((not (org-first-list-item-p)) (org-back-over-empty-lines))
|
||||||
0))))))
|
;; no luck: item is alone. Use default value.
|
||||||
|
(t 1)))))))
|
||||||
(insert-fun
|
(insert-fun
|
||||||
(lambda (text)
|
(lambda (text)
|
||||||
;; insert bullet above item in order to avoid bothering
|
;; insert bullet above item in order to avoid bothering
|
||||||
|
@ -404,7 +405,7 @@ function end."
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(while (looking-at "^[ \t]*$")
|
(while (looking-at "^[ \t]*$")
|
||||||
(delete-region (point-at-bol) (1+ (point-at-eol)))
|
(delete-region (point-at-bol) (1+ (point-at-eol)))
|
||||||
(backward-char))))))
|
(beginning-of-line 0))))))
|
||||||
(funcall insert-fun after-text) t)))))
|
(funcall insert-fun after-text) t)))))
|
||||||
|
|
||||||
;;; Predicates
|
;;; Predicates
|
||||||
|
|
Loading…
Reference in a new issue