0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 20:37:51 +00:00

org.el: Refactor ‘org-previous-line-empty-p’

* lisp/org.el (org--line-empty-p):
(org-next-line-empty-p): New functions.
(org-previous-line-empty-p): Remove `next' argument.  Call
`org--line-empty-p'.
This commit is contained in:
Aaron Ecay 2015-11-06 12:19:42 +00:00
parent a6768538d6
commit d29d9a029c

View file

@ -7666,15 +7666,27 @@ frame is not changed."
;;; Inserting headlines ;;; Inserting headlines
(defun org-previous-line-empty-p (&optional next) (defun org--line-empty-p (n)
"Is the previous line a blank line? "Is the Nth next line empty?
When NEXT is non-nil, check the next line instead."
Counts the current line as N = 1 and the previous line as N = 0;
see `beginning-of-line'."
(save-excursion (save-excursion
(and (not (bobp)) (and (not (bobp))
(or (beginning-of-line (if next 2 0)) t) (or (beginning-of-line n) t)
(save-match-data (save-match-data
(looking-at "[ \t]*$"))))) (looking-at "[ \t]*$")))))
(defun org-previous-line-empty-p ()
"Is the previous line a blank line?
When NEXT is non-nil, check the next line instead."
(org--line-empty-p 0))
(defun org-next-line-empty-p ()
"Is the previous line a blank line?
When NEXT is non-nil, check the next line instead."
(org--line-empty-p 2))
(defun org-insert-heading (&optional arg invisible-ok top-level) (defun org-insert-heading (&optional arg invisible-ok top-level)
"Insert a new heading or an item with the same depth at point. "Insert a new heading or an item with the same depth at point.
@ -7788,7 +7800,7 @@ heading, unconditionally."
(org-backward-heading-same-level (org-backward-heading-same-level
1 invisible-ok)) 1 invisible-ok))
(= (point) (match-beginning 0))) (= (point) (match-beginning 0)))
(not (org-previous-line-empty-p t))) (not (org-next-line-empty-p)))
(setq empty-line-p (or empty-line-p (setq empty-line-p (or empty-line-p
(org-previous-line-empty-p)))) (org-previous-line-empty-p))))
(match-string 0)) (match-string 0))