summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2011-03-09 20:30:18 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2011-03-09 20:30:18 +0100
commitf8ca5d85baa749b69f7b044079f8110825ec0f64 (patch)
treec8639889276cc6b4136af59f921c3f361a2dd1cb
parent6ff4c9f42f39d2a85f5bf38e2f621988af9b0435 (diff)
downloadorg-mode-f8ca5d85baa749b69f7b044079f8110825ec0f64.tar.gz
org-list: small refactoring
* lisp/org-list.el (org-list-in-valid-block-p): new function. (org-at-item-p,org-list-search-generic): use new function.
-rw-r--r--lisp/org-list.el20
1 files changed, 15 insertions, 5 deletions
diff --git a/lisp/org-list.el b/lisp/org-list.el
index 430c9ff..a092e2b 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -400,6 +400,17 @@ group 4: description tag")
(goto-char (match-end 0)))
(looking-at regexp))))
+(defun org-list-in-valid-block-p ()
+ "Non-nil if point is in a valid block.
+Invalid blocks are referring to `org-list-forbidden-blocks'."
+ (save-match-data
+ (let ((case-fold-search t))
+ (not (org-in-regexps-block-p
+ (concat "^[ \t]*#\\+begin_\\("
+ (mapconcat 'regexp-quote org-list-forbidden-blocks "\\|")
+ "\\)")
+ '(concat "^[ \t]*#\\+end_" (match-string 1)))))))
+
(defun org-in-item-p ()
"Return item beginning position when in a plain list, nil otherwise.
This checks `org-list-ending-method'."
@@ -476,8 +487,7 @@ This checks `org-list-ending-method'."
"Is point in a line starting a hand-formatted item?"
(save-excursion
(beginning-of-line)
- (and (looking-at (org-item-re))
- (not (eq (nth 2 (org-list-context)) 'invalid)))))
+ (and (looking-at (org-item-re)) (org-list-in-valid-block-p))))
(defun org-at-item-bullet-p ()
"Is point at the bullet of a plain list item?"
@@ -1037,9 +1047,9 @@ in `re-search-forward'."
(unless (funcall search re bound noerr)
(throw 'exit (and (goto-char (if (memq noerr '(t nil)) origin bound))
nil)))
- ;; 2. Match in an `invalid' context: continue searching. Else,
- ;; return point.
- (unless (eq (org-list-context) 'invalid) (throw 'exit (point)))))))
+ ;; 2. Match in valid context: return point. Else, continue
+ ;; searching.
+ (when (org-list-in-valid-block-p) (throw 'exit (point)))))))
(defun org-list-search-backward (regexp &optional bound noerror)
"Like `re-search-backward' but stop only where lists are recognized.