summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2011-07-17 22:53:46 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2011-07-17 22:54:21 +0200
commit054230b13828b2712865833498fc2ec6b42a85a1 (patch)
treecd9660eb7d0f39bbea09edca7dec3777a938ca3c
parent46a5bde601980c47eccd06d87b82dbae85b20704 (diff)
downloadorg-mode-054230b13828b2712865833498fc2ec6b42a85a1.tar.gz
org-list: never add useless blank lines when inserting an item
* lisp/org-list.el (org-list-insert-item): when insertion point is in some white line after the end of the list, remove all unnecessary white lines there before proceeding. Also refactor a snippet of code.
-rw-r--r--lisp/org-list.el15
1 files changed, 10 insertions, 5 deletions
diff --git a/lisp/org-list.el b/lisp/org-list.el
index aca2c5c..82eb0dd 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -1245,15 +1245,20 @@ This function modifies STRUCT."
(and (not beforep) split-line-p
(progn
(goto-char pos)
+ ;; If POS is greater than ITEM-END, then point is
+ ;; in some white lines after the end of the list.
+ ;; Those must be removed, or they will be left,
+ ;; stacking up after the list.
+ (when (< item-end pos)
+ (delete-region (1- item-end) (point-at-eol)))
(skip-chars-backward " \r\t\n")
(setq pos (point))
(delete-and-extract-region pos item-end-no-blank))))
(body (concat bullet (when box (concat box " ")) after-bullet
- (or (and text-cut
- (if (string-match "\\`[ \t]+" text-cut)
- (replace-match "" t t text-cut)
- text-cut))
- "")))
+ (and text-cut
+ (if (string-match "\\`[ \t]+" text-cut)
+ (replace-match "" t t text-cut)
+ text-cut))))
(item-sep (make-string (1+ blank-nb) ?\n))
(item-size (+ ind-size (length body) (length item-sep)))
(size-offset (- item-size (length text-cut))))