summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ecay <aaronecay@gmail.com>2015-11-06 12:19:42 +0000
committerAaron Ecay <aaronecay@gmail.com>2015-11-06 12:50:41 +0000
commitd29d9a029cd1feef6db247c89500e29346befd7f (patch)
tree3770f8df4fc9148dac25ba49ec9faae4a46372c2
parenta6768538d645d45a8420d36bacc5ed879b001816 (diff)
downloadorg-mode-d29d9a029cd1feef6db247c89500e29346befd7f.tar.gz
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'.
-rwxr-xr-xlisp/org.el22
1 files changed, 17 insertions, 5 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 5d8880a..a70fe01 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))