From d29d9a029cd1feef6db247c89500e29346befd7f Mon Sep 17 00:00:00 2001 From: Aaron Ecay Date: Fri, 6 Nov 2015 12:19:42 +0000 Subject: [PATCH] =?utf8?q?org.el:=20Refactor=20=E2=80=98org-previous-line-?= =?utf8?q?empty-p=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * 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'. --- lisp/org.el | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 5d8880a20..a70fe01fd 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -7666,15 +7666,27 @@ frame is not changed." ;;; Inserting headlines -(defun org-previous-line-empty-p (&optional next) - "Is the previous line a blank line? -When NEXT is non-nil, check the next line instead." +(defun org--line-empty-p (n) + "Is the Nth next line empty? + +Counts the current line as N = 1 and the previous line as N = 0; +see `beginning-of-line'." (save-excursion (and (not (bobp)) - (or (beginning-of-line (if next 2 0)) t) + (or (beginning-of-line n) t) (save-match-data (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) "Insert a new heading or an item with the same depth at point. @@ -7788,7 +7800,7 @@ heading, unconditionally." (org-backward-heading-same-level 1 invisible-ok)) (= (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 (org-previous-line-empty-p)))) (match-string 0)) -- 2.11.4.GIT