diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2010-07-18 11:04:15 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2010-09-01 19:05:47 +0200 |
commit | c3bbbc09261396cc23fb357dddb0b2352d31977c (patch) | |
tree | 55793f34d4a2ced6030b6f8b3645a317bbc58786 | |
parent | 905ad49e9a5d852fe660edad3ad3ee4bd437ddc4 (diff) | |
download | org-mode-c3bbbc09261396cc23fb357dddb0b2352d31977c.tar.gz |
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.
-rw-r--r-- | lisp/org-list.el | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lisp/org-list.el b/lisp/org-list.el index feffb65..b0eca8c 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -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 after the bullet. Cursor will be after this text once the -function end." +function ends." (goto-char pos) ;; Point in a special block: move before it prior to add a new item. (when (org-in-regexps-block-p @@ -355,16 +355,17 @@ function end." 0) ((eq insert-blank-p t) 1) ;; plain-list-item is 'auto. Count blank lines separating - ;; items in current list. + ;; neighbours items in list. (t - (save-excursion - (if (progn - (org-end-of-item-list) - (skip-chars-backward " \r\t\n") - (org-search-backward-unenclosed - "^[ \t]*$" (save-excursion (org-beginning-of-item-list)) t)) - (1+ (org-back-over-empty-lines)) - 0)))))) + (let ((next-p (org-get-next-item (point) (org-list-bottom-point)))) + (cond + ;; Is there a next item? + (next-p (goto-char next-p) + (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))))))) (insert-fun (lambda (text) ;; insert bullet above item in order to avoid bothering @@ -404,7 +405,7 @@ function end." (beginning-of-line) (while (looking-at "^[ \t]*$") (delete-region (point-at-bol) (1+ (point-at-eol))) - (backward-char)))))) + (beginning-of-line 0)))))) (funcall insert-fun after-text) t))))) ;;; Predicates |