Function: org-cycle-show-empty-lines
org-cycle-show-empty-lines is a byte-compiled function defined in
org-cycle.el.gz.
Signature
(org-cycle-show-empty-lines STATE)
Documentation
Show empty lines above all visible headlines.
The region to be covered depends on STATE when called through
org-cycle-hook. Lisp program can use t for STATE to get the
entire buffer covered. Note that an empty line is only shown if there
are at least org-cycle-separator-lines empty lines before the headline.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-cycle.el.gz
(defun org-cycle-show-empty-lines (state)
"Show empty lines above all visible headlines.
The region to be covered depends on STATE when called through
`org-cycle-hook'. Lisp program can use t for STATE to get the
entire buffer covered. Note that an empty line is only shown if there
are at least `org-cycle-separator-lines' empty lines before the headline."
(when (/= org-cycle-separator-lines 0)
(save-excursion
(let* ((n (abs org-cycle-separator-lines))
(re (cond
((= n 1) "\\(\n[ \t]*\n\\*+\\) ")
((= n 2) "^[ \t]*\\(\n[ \t]*\n\\*+\\) ")
(t (let ((ns (number-to-string (- n 2))))
(concat "^\\(?:[ \t]*\n\\)\\{" ns "," ns "\\}"
"[ \t]*\\(\n[ \t]*\n\\*+\\) ")))))
beg end)
(cond
((memq state '(overview contents t))
(setq beg (point-min) end (point-max)))
((memq state '(children folded))
(setq beg (point)
end (progn (org-end-of-subtree t t)
(line-beginning-position 2)))))
(when beg
(goto-char beg)
(while (re-search-forward re end t)
(unless (org-invisible-p (match-end 1))
(let ((e (match-end 1))
(b (if (>= org-cycle-separator-lines 0)
(match-beginning 1)
(save-excursion
(goto-char (match-beginning 0))
(skip-chars-backward " \t\n")
(line-end-position)))))
(org-fold-region b e nil 'outline))))))))
;; Never hide empty lines at the end of the file.
(save-excursion
(goto-char (point-max))
(outline-previous-heading)
(outline-end-of-heading)
(when (and (looking-at "[ \t\n]+")
(= (match-end 0) (point-max)))
(org-fold-region (point) (match-end 0) nil 'outline))))