summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2011-01-24 23:37:35 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2011-02-18 12:45:12 +0100
commit0148fac717a978e49edd119d462637235d75f54f (patch)
treee79cf3636050465ab00018c48b58720cf3fcc3de
parent0bec47e9abad2d323a7ea389a3fda104bdf5b54f (diff)
downloadorg-mode-0148fac717a978e49edd119d462637235d75f54f.tar.gz
org-list: make org-at-item-p less permissive
* lisp/org-list.el (org-at-item-p): also verify context is valid. Otherwise it would recognize valid items where org-in-item-p wouldn't. (org-in-item-p, org-list-struct-apply-struct): use shorter version of org-at-item-p. (org-cycle-list-bullet): fix typo. (org-list-parse-list): avoid calling org-at-item-p two times by using an appropriate regexp * lisp/org.el (org-indent-line-function): use an appropriate regexp instead of calling org-at-item-p two times.
-rw-r--r--lisp/org-list.el20
-rw-r--r--lisp/org.el2
2 files changed, 14 insertions, 8 deletions
diff --git a/lisp/org-list.el b/lisp/org-list.el
index 7b953f9..c6e554d 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -408,6 +408,7 @@ This checks `org-list-ending-method'."
(lim-up (car context))
(inlinetask-re (and (featurep 'org-inlinetask)
(org-inlinetask-outline-regexp)))
+ (item-re (org-item-re))
;; Indentation isn't meaningful when point starts at an empty
;; line or an inline task.
(ind-ref (if (or (looking-at "^[ \t]*$")
@@ -416,7 +417,7 @@ This checks `org-list-ending-method'."
(org-get-indentation))))
(cond
((eq (nth 2 context) 'invalid) nil)
- ((org-at-item-p) (point))
+ ((looking-at item-re) (point))
(t
;; Detect if cursor in amidst `org-list-end-re'. First, count
;; number HL of hard lines it takes, then call `org-in-regexp'
@@ -440,7 +441,7 @@ This checks `org-list-ending-method'."
(let ((ind (org-get-indentation)))
(cond
;; This is exactly what we want.
- ((and (org-at-item-p)
+ ((and (looking-at item-re)
(or (< ind ind-ref)
(eq org-list-ending-method 'regexp)))
(throw 'exit (point)))
@@ -471,7 +472,10 @@ This checks `org-list-ending-method'."
(defun org-at-item-p ()
"Is point in a line starting a hand-formatted item?"
- (save-excursion (beginning-of-line) (looking-at (org-item-beginning-re))))
+ (save-excursion
+ (beginning-of-line)
+ (and (not (eq (nth 2 (org-list-context)) 'invalid))
+ (looking-at (org-item-re)))))
(defun org-at-item-bullet-p ()
"Is point at the bullet of a plain list item?"
@@ -1591,6 +1595,7 @@ have changed.
Initial position of cursor is restored after the changes."
(let* ((pos (copy-marker (point)))
+ (item-re (org-item-re))
(shift-body-ind
(function
;; Shift the indentation between END and BEG by DELTA.
@@ -1600,7 +1605,8 @@ Initial position of cursor is restored after the changes."
(skip-chars-backward " \r\t\n")
(beginning-of-line)
(while (or (> (point) beg)
- (and (= (point) beg) (not (org-at-item-p))))
+ (and (= (point) beg)
+ (not (looking-at item-re))))
(when (org-looking-at-p "^[ \t]*\\S-")
(let ((i (org-get-indentation)))
(org-indent-line-to (+ i delta))))
@@ -1958,7 +1964,7 @@ If WHICH is a valid string, use that as the new bullet. If WHICH
is an integer, 0 means `-', 1 means `+' etc. If WHICH is
`previous', cycle backwards."
(interactive "P")
- (unless (org-at-item-p) (error "This is not a list"))
+ (unless (org-at-item-p) (error "Not at an item"))
(save-excursion
(beginning-of-line)
(let* ((struct (org-list-struct))
@@ -2619,12 +2625,12 @@ Point is left at list end."
(mapcar parse-item e)))))
(parse-item
(function
- ;; Return a list containing conter of item, if any, text
+ ;; Return a list containing counter of item, if any, text
;; and any sublist inside it.
(lambda (e)
(let ((start (save-excursion
(goto-char e)
- (or (org-at-item-counter-p) (org-at-item-p))
+ (looking-at "[ \t]*\\S-+[ \t]+\\(\\[@[:[:alnum:]]+\\][ \t]*\\)?")
(match-end 0)))
;; Get counter number. For alphabetic counter, get
;; its position in the alphabet.
diff --git a/lisp/org.el b/lisp/org.el
index 06b74ab..64a5979 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18866,7 +18866,7 @@ If point is in an inline task, mark that task instead."
(org-get-indentation (match-string 0)))))
;; Lists
((ignore-errors (goto-char (org-in-item-p)))
- (or (org-at-item-description-p) (org-at-item-p))
+ (looking-at "[ \t]*\\(\\S-+\\)\\(.*[ \t]+::\\)?[ \t]+")
(setq bpos (match-beginning 1) tpos (match-end 0)
bcol (progn (goto-char bpos) (current-column))
tcol (progn (goto-char tpos) (current-column)))