diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2010-07-14 09:08:39 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2010-09-01 19:05:45 +0200 |
commit | 0c4770e66144d86792061dc4f35cf02d2084eff0 (patch) | |
tree | 17954b250b3f23951c01dbfe42bf0eca75acf63b | |
parent | 37733b77a47c517d97c8fe6ece07eee1279349a8 (diff) | |
download | org-mode-0c4770e66144d86792061dc4f35cf02d2084eff0.tar.gz |
Refactoring.
* org-list.el (org-insert-item): Simplify count of blank lines to insert.
-rw-r--r-- | lisp/org-list.el | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lisp/org-list.el b/lisp/org-list.el index f9b90a2..d8f5e81 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -631,25 +631,25 @@ block, or item is invisible." (timer-p (and description-p (string-match "^[-+*][ \t]+[0-9]+:[0-9]+:[0-9]+$" description-p))) ;; Guess number of blank lines used to separate items. - (blank-lines-nb (let* ((insert-blank-p - (cdr (assq 'plain-list-item org-blank-before-new-entry))) - (limit (save-excursion (org-end-of-item-list))) - (next-item-p (org-get-next-item (point) limit))) + (blank-lines-nb (let ((insert-blank-p + (cdr (assq 'plain-list-item org-blank-before-new-entry)))) (cond - ;; cases where there should be no blank line. - ((or (not insert-blank-p) - org-empty-line-terminates-plain-lists) 0) - ;; If there's a next item, count blank - ;; lines between current and next item. - (next-item-p (and (goto-char next-item-p) - (org-back-over-empty-lines))) - ;; if we're not on the first item, there - ;; is one above. Count blank lines between. - ((not (org-first-list-item-p)) (org-back-over-empty-lines)) - ;; Only one item list: can't guess. - ;; Follow `org-blank-before-new-entry' - ((eq insert-blank-p 'auto) 0) - (t 1)))) + ((or + org-empty-line-terminates-plain-lists + (not insert-blank-p)) + 0) + ((eq insert-blank-p t) 1) + ;; plain-list-item is 'auto. Count blank + ;; lines separating 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)))))) (insert-fun (lambda (&optional string-after-bullet) ;; insert bullet above item in order to avoid ;; bothering with possible blank lines ending |