Function: org-list-separating-blank-lines-number

org-list-separating-blank-lines-number is a byte-compiled function defined in org-list.el.gz.

Signature

(org-list-separating-blank-lines-number POS STRUCT PREVS)

Documentation

Return number of blank lines that should separate items in list.

POS is the position of point where org-list-insert-item was called.

STRUCT is the list structure. PREVS is the alist of previous items, as returned by org-list-prevs-alist.

Assume point is at item's beginning. If the item is alone, apply some heuristics to guess the result.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-list.el.gz
(defun org-list-separating-blank-lines-number (pos struct prevs)
  "Return number of blank lines that should separate items in list.

POS is the position of point where `org-list-insert-item' was called.

STRUCT is the list structure.  PREVS is the alist of previous
items, as returned by `org-list-prevs-alist'.

Assume point is at item's beginning.  If the item is alone, apply
some heuristics to guess the result."
  (save-excursion
    (let ((item (point))
	  (insert-blank-p
	   (cdr (assq 'plain-list-item org-blank-before-new-entry)))
	  usr-blank
	  (count-blanks
	   (lambda ()
	     ;; Count blank lines above beginning of line.
	     (save-excursion
               (count-lines (goto-char (line-beginning-position))
			    (progn (skip-chars-backward " \r\t\n")
				   (forward-line)
				   (point)))))))
      (cond
       ;; Trivial cases where there should be none.
       ((not insert-blank-p) 0)
       ;; When `org-blank-before-new-entry' says so, it is 1.
       ((eq insert-blank-p t) 1)
       ;; `plain-list-item' is 'auto.  Count blank lines separating
       ;; neighbors' items in list.
       (t (let ((next-p (org-list-get-next-item item struct prevs)))
	    (cond
	     ;; Is there a next item?
	     (next-p (goto-char next-p)
		     (funcall count-blanks))
	     ;; Is there a previous item?
	     ((org-list-get-prev-item item struct prevs)
	      (funcall count-blanks))
	     ;; User inserted blank lines, trust him.
	     ((and (> pos (org-list-get-item-end-before-blank item struct))
		   (> (save-excursion (goto-char pos)
				      (setq usr-blank (funcall count-blanks)))
		      0))
	      usr-blank)
	     ;; Are there blank lines inside the list so far?
	     ((save-excursion
		(goto-char (org-list-get-top-point struct))
		;; Do not use `org-list-search-forward' so blank lines
		;; in blocks can be counted in.
		(re-search-forward
		 "^[ \t]*$" (org-list-get-item-end-before-blank item struct) t))
	      1)
	     ;; Default choice: no blank line.
	     (t 0))))))))