Merge branch 'master' of orgmode.org:org-mode
This commit is contained in:
commit
511fb10eb1
133
lisp/org-list.el
133
lisp/org-list.el
|
@ -516,73 +516,74 @@ are boundaries and CONTEXT is a symbol among `drawer', `block',
|
||||||
|
|
||||||
Contexts `block' and `invalid' refer to `org-list-forbidden-blocks'."
|
Contexts `block' and `invalid' refer to `org-list-forbidden-blocks'."
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(org-with-limited-levels
|
(save-excursion
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(let* ((case-fold-search t) (pos (point)) beg end
|
(let* ((case-fold-search t) (pos (point)) beg end
|
||||||
;; Compute position of surrounding headings. This is the
|
;; Compute position of surrounding headings. This is the
|
||||||
;; default context.
|
;; default context.
|
||||||
(heading
|
(heading
|
||||||
(save-excursion
|
(org-with-limited-levels
|
||||||
(list (or (and (org-at-heading-p) (point-at-bol))
|
|
||||||
(outline-previous-heading)
|
|
||||||
(point-min))
|
|
||||||
(or (outline-next-heading) (point-max))
|
|
||||||
nil)))
|
|
||||||
(prev-head (car heading))
|
|
||||||
(next-head (nth 1 heading))
|
|
||||||
;; Is point inside a drawer?
|
|
||||||
(drawerp
|
|
||||||
(save-excursion
|
|
||||||
(let ((end-re "^[ \t]*:END:")
|
|
||||||
;; Can't use org-drawers-regexp as this function
|
|
||||||
;; might be called in buffers not in Org mode
|
|
||||||
(drawers-re (concat "^[ \t]*:\\("
|
|
||||||
(mapconcat 'regexp-quote org-drawers "\\|")
|
|
||||||
"\\):[ \t]*$")))
|
|
||||||
(and (not (looking-at drawers-re))
|
|
||||||
(not (looking-at end-re))
|
|
||||||
(setq beg (and (re-search-backward drawers-re prev-head t)
|
|
||||||
(1+ (point-at-eol))))
|
|
||||||
(setq end (or (and (re-search-forward end-re next-head t)
|
|
||||||
(1- (match-beginning 0)))
|
|
||||||
next-head))
|
|
||||||
(>= end pos)
|
|
||||||
(list beg end 'drawer)))))
|
|
||||||
;; Is point strictly in a block, and of which type?
|
|
||||||
(blockp
|
|
||||||
(save-excursion
|
|
||||||
(let ((block-re "^[ \t]*#\\+\\(begin\\|end\\)_") type)
|
|
||||||
(and (not (looking-at block-re))
|
|
||||||
(setq beg (and (re-search-backward block-re prev-head t)
|
|
||||||
(1+ (point-at-eol))))
|
|
||||||
(looking-at "^[ \t]*#\\+begin_\\(\\S-+\\)")
|
|
||||||
(setq type (downcase (match-string 1)))
|
|
||||||
(goto-char beg)
|
|
||||||
(setq end (or (and (re-search-forward block-re next-head t)
|
|
||||||
(1- (point-at-bol)))
|
|
||||||
next-head))
|
|
||||||
(>= end pos)
|
|
||||||
(equal (downcase (match-string 1)) "end")
|
|
||||||
(list beg end (if (member type org-list-forbidden-blocks)
|
|
||||||
'invalid 'block))))))
|
|
||||||
;; Is point in an inlinetask?
|
|
||||||
(inlinetaskp
|
|
||||||
(when (featurep 'org-inlinetask)
|
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let* ((stars-re (org-inlinetask-outline-regexp))
|
(list (or (and (org-at-heading-p) (point-at-bol))
|
||||||
(end-re (concat stars-re "END[ \t]*$")))
|
(outline-previous-heading)
|
||||||
(and (not (looking-at "^\\*+"))
|
(point-min))
|
||||||
(setq beg (and (re-search-backward stars-re prev-head t)
|
(or (outline-next-heading) (point-max))
|
||||||
(1+ (point-at-eol))))
|
nil))))
|
||||||
(not (looking-at end-re))
|
(prev-head (car heading))
|
||||||
(setq end (and (re-search-forward end-re next-head t)
|
(next-head (nth 1 heading))
|
||||||
(1- (match-beginning 0))))
|
;; Is point inside a drawer?
|
||||||
(> (point) pos)
|
(drawerp
|
||||||
(list beg end 'inlinetask))))))
|
(save-excursion
|
||||||
;; List actual candidates
|
(let ((end-re "^[ \t]*:END:")
|
||||||
(context-list (delq nil (list heading drawerp blockp inlinetaskp))))
|
;; Can't use org-drawers-regexp as this function
|
||||||
;; Return the closest context around
|
;; might be called in buffers not in Org mode
|
||||||
(assq (apply 'max (mapcar 'car context-list)) context-list)))))
|
(drawers-re (concat "^[ \t]*:\\("
|
||||||
|
(mapconcat 'regexp-quote org-drawers "\\|")
|
||||||
|
"\\):[ \t]*$")))
|
||||||
|
(and (not (looking-at drawers-re))
|
||||||
|
(not (looking-at end-re))
|
||||||
|
(setq beg (and (re-search-backward drawers-re prev-head t)
|
||||||
|
(1+ (point-at-eol))))
|
||||||
|
(setq end (or (and (re-search-forward end-re next-head t)
|
||||||
|
(1- (match-beginning 0)))
|
||||||
|
next-head))
|
||||||
|
(>= end pos)
|
||||||
|
(list beg end 'drawer)))))
|
||||||
|
;; Is point strictly in a block, and of which type?
|
||||||
|
(blockp
|
||||||
|
(save-excursion
|
||||||
|
(let ((block-re "^[ \t]*#\\+\\(begin\\|end\\)_") type)
|
||||||
|
(and (not (looking-at block-re))
|
||||||
|
(setq beg (and (re-search-backward block-re prev-head t)
|
||||||
|
(1+ (point-at-eol))))
|
||||||
|
(looking-at "^[ \t]*#\\+begin_\\(\\S-+\\)")
|
||||||
|
(setq type (downcase (match-string 1)))
|
||||||
|
(goto-char beg)
|
||||||
|
(setq end (or (and (re-search-forward block-re next-head t)
|
||||||
|
(1- (point-at-bol)))
|
||||||
|
next-head))
|
||||||
|
(>= end pos)
|
||||||
|
(equal (downcase (match-string 1)) "end")
|
||||||
|
(list beg end (if (member type org-list-forbidden-blocks)
|
||||||
|
'invalid 'block))))))
|
||||||
|
;; Is point in an inlinetask?
|
||||||
|
(inlinetaskp
|
||||||
|
(when (featurep 'org-inlinetask)
|
||||||
|
(save-excursion
|
||||||
|
(let* ((stars-re (org-inlinetask-outline-regexp))
|
||||||
|
(end-re (concat stars-re "END[ \t]*$")))
|
||||||
|
(and (not (looking-at "^\\*+"))
|
||||||
|
(setq beg (and (re-search-backward stars-re prev-head t)
|
||||||
|
(1+ (point-at-eol))))
|
||||||
|
(not (looking-at end-re))
|
||||||
|
(setq end (and (re-search-forward end-re next-head t)
|
||||||
|
(1- (match-beginning 0))))
|
||||||
|
(> (point) pos)
|
||||||
|
(list beg end 'inlinetask))))))
|
||||||
|
;; List actual candidates
|
||||||
|
(context-list (delq nil (list heading drawerp blockp inlinetaskp))))
|
||||||
|
;; Return the closest context around
|
||||||
|
(assq (apply 'max (mapcar 'car context-list)) context-list)))))
|
||||||
|
|
||||||
(defun org-list-struct ()
|
(defun org-list-struct ()
|
||||||
"Return structure of list at point.
|
"Return structure of list at point.
|
||||||
|
|
Loading…
Reference in New Issue