mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-12 15:10:04 +00:00
Merge branch 'master' of orgmode.org:org-mode
This commit is contained in:
commit
68ea1baf46
159
lisp/org-list.el
159
lisp/org-list.el
|
@ -476,8 +476,8 @@ This checks `org-list-ending-method'."
|
||||||
"Is point in a line starting a hand-formatted item?"
|
"Is point in a line starting a hand-formatted item?"
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(and (not (eq (nth 2 (org-list-context)) 'invalid))
|
(and (looking-at (org-item-re))
|
||||||
(looking-at (org-item-re)))))
|
(not (eq (nth 2 (org-list-context)) 'invalid)))))
|
||||||
|
|
||||||
(defun org-at-item-bullet-p ()
|
(defun org-at-item-bullet-p ()
|
||||||
"Is point at the bullet of a plain list item?"
|
"Is point at the bullet of a plain list item?"
|
||||||
|
@ -514,89 +514,75 @@ Context will be a cell like (MIN MAX CONTEXT) where MIN and MAX
|
||||||
are boundaries and CONTEXT is a symbol among `drawer', `block',
|
are boundaries and CONTEXT is a symbol among `drawer', `block',
|
||||||
`invalid', `inlinetask' and nil.
|
`invalid', `inlinetask' and nil.
|
||||||
|
|
||||||
Contexts `block' and `invalid' refer to
|
Contexts `block' and `invalid' refer to `org-list-forbidden-blocks'."
|
||||||
`org-list-forbidden-blocks'."
|
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(save-excursion
|
(org-with-limited-levels
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(let* ((outline-regexp (org-get-limited-outline-regexp))
|
(let* ((case-fold-search t) (pos (point)) beg end
|
||||||
;; Can't use org-drawers-regexp as this function might be
|
;; Compute position of surrounding headings. This is the
|
||||||
;; called in buffers not in Org mode
|
;; default context.
|
||||||
(drawers-re (concat "^[ \t]*:\\("
|
(heading
|
||||||
(mapconcat 'regexp-quote org-drawers "\\|")
|
(save-excursion
|
||||||
"\\):[ \t]*$"))
|
(list (or (and (org-at-heading-p) (point-at-bol))
|
||||||
(case-fold-search t)
|
(outline-previous-heading)
|
||||||
;; Compute position of surrounding headings. This is the
|
(point-min))
|
||||||
;; default context.
|
(or (outline-next-heading) (point-max))
|
||||||
(heading
|
nil)))
|
||||||
(save-excursion
|
(prev-head (car heading))
|
||||||
(list
|
(next-head (nth 1 heading))
|
||||||
(or (and (org-at-heading-p) (point-at-bol))
|
;; Is point inside a drawer?
|
||||||
(outline-previous-heading)
|
(drawerp
|
||||||
(point-min))
|
(save-excursion
|
||||||
(or (outline-next-heading)
|
(let ((end-re "^[ \t]*:END:")
|
||||||
(point-max))
|
;; Can't use org-drawers-regexp as this function
|
||||||
nil)))
|
;; might be called in buffers not in Org mode
|
||||||
(prev-head (car heading))
|
(drawers-re (concat "^[ \t]*:\\("
|
||||||
(next-head (nth 1 heading))
|
(mapconcat 'regexp-quote org-drawers "\\|")
|
||||||
;; Is point inside a drawer?
|
"\\):[ \t]*$")))
|
||||||
(drawerp
|
(and (not (looking-at drawers-re))
|
||||||
(when (and (org-in-regexps-block-p
|
(not (looking-at end-re))
|
||||||
drawers-re "^[ \t]*:END:" prev-head)
|
(setq beg (and (re-search-backward drawers-re prev-head t)
|
||||||
(save-excursion
|
(1+ (point-at-eol))))
|
||||||
(beginning-of-line)
|
(setq end (or (and (re-search-forward end-re next-head t)
|
||||||
(and (not (looking-at drawers-re))
|
(1- (match-beginning 0)))
|
||||||
(not (looking-at "^[ \t]*:END:")))))
|
next-head))
|
||||||
(save-excursion
|
(>= end pos)
|
||||||
(list
|
(list beg end 'drawer)))))
|
||||||
(progn
|
;; Is point strictly in a block, and of which type?
|
||||||
(re-search-backward drawers-re prev-head t)
|
(blockp
|
||||||
(1+ (point-at-eol)))
|
(save-excursion
|
||||||
(if (re-search-forward "^[ \t]*:END:" next-head t)
|
(let ((block-re "^[ \t]*#\\+\\(begin\\|end\\)_") type)
|
||||||
(1- (point-at-bol))
|
(and (not (looking-at block-re))
|
||||||
next-head)
|
(setq beg (and (re-search-backward block-re prev-head t)
|
||||||
'drawer))))
|
(1+ (point-at-eol))))
|
||||||
;; Is point strictly in a block, and of which type?
|
(looking-at "^[ \t]*#\\+begin_\\(\\S-+\\)")
|
||||||
(blockp
|
(setq type (downcase (match-string 1)))
|
||||||
(save-excursion
|
(goto-char beg)
|
||||||
(when (and (org-in-regexps-block-p
|
(setq end (or (and (re-search-forward block-re next-head t)
|
||||||
"^[ \t]*#\\+begin_" "^[ \t]*#\\+end_" prev-head)
|
(1- (point-at-bol)))
|
||||||
(save-excursion
|
next-head))
|
||||||
(beginning-of-line)
|
(>= end pos)
|
||||||
(not (looking-at
|
(equal (downcase (match-string 1)) "end")
|
||||||
"^[ \t]*#\\+\\(begin\\|end\\)_"))))
|
(list beg end (if (member type org-list-forbidden-blocks)
|
||||||
(list
|
'invalid 'block))))))
|
||||||
(progn
|
;; Is point in an inlinetask?
|
||||||
(re-search-backward
|
(inlinetaskp
|
||||||
"^[ \t]*#\\+begin_\\(\\S-+\\)" prev-head t)
|
(when (featurep 'org-inlinetask)
|
||||||
(1+ (point-at-eol)))
|
(save-excursion
|
||||||
(save-match-data
|
(let* ((stars-re (org-inlinetask-outline-regexp))
|
||||||
(if (re-search-forward "^[ \t]*#\\+end_" next-head t)
|
(end-re (concat stars-re "END[ \t]*$")))
|
||||||
(1- (point-at-bol))
|
(and (not (looking-at "^\\*+"))
|
||||||
next-head))
|
(setq beg (and (re-search-backward stars-re prev-head t)
|
||||||
(if (member (downcase (match-string 1))
|
(1+ (point-at-eol))))
|
||||||
org-list-forbidden-blocks)
|
(not (looking-at end-re))
|
||||||
'invalid
|
(setq end (and (re-search-forward end-re next-head t)
|
||||||
'block)))))
|
(1- (match-beginning 0))))
|
||||||
;; Is point in an inlinetask?
|
(> (point) pos)
|
||||||
(inlinetaskp
|
(list beg end 'inlinetask))))))
|
||||||
(when (and (featurep 'org-inlinetask)
|
;; List actual candidates
|
||||||
(org-inlinetask-in-task-p)
|
(context-list (delq nil (list heading drawerp blockp inlinetaskp))))
|
||||||
(not (looking-at "^\\*+")))
|
;; Return the closest context around
|
||||||
(save-excursion
|
(assq (apply 'max (mapcar 'car context-list)) context-list)))))
|
||||||
(list
|
|
||||||
(progn (org-inlinetask-goto-beginning)
|
|
||||||
(1+ (point-at-eol)))
|
|
||||||
(progn
|
|
||||||
(org-inlinetask-goto-end)
|
|
||||||
(forward-line -1)
|
|
||||||
(1- (point-at-bol)))
|
|
||||||
'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.
|
||||||
|
@ -1197,8 +1183,7 @@ This function modifies STRUCT."
|
||||||
;; 4. Insert effectively item into buffer
|
;; 4. Insert effectively item into buffer
|
||||||
(goto-char item)
|
(goto-char item)
|
||||||
(org-indent-to-column ind)
|
(org-indent-to-column ind)
|
||||||
(insert body)
|
(insert body item-sep)
|
||||||
(insert item-sep)
|
|
||||||
;; 5. Add new item to STRUCT.
|
;; 5. Add new item to STRUCT.
|
||||||
(mapc (lambda (e)
|
(mapc (lambda (e)
|
||||||
(let ((p (car e))
|
(let ((p (car e))
|
||||||
|
@ -1238,7 +1223,7 @@ This function modifies STRUCT."
|
||||||
;; SIZE-OFFSET.
|
;; SIZE-OFFSET.
|
||||||
(t (setcar e (+ p size-offset))
|
(t (setcar e (+ p size-offset))
|
||||||
(setcar (nthcdr 6 e) (+ end size-offset))))))
|
(setcar (nthcdr 6 e) (+ end size-offset))))))
|
||||||
struct)
|
struct)
|
||||||
(push (list item ind bullet nil box nil (+ item item-size)) struct)
|
(push (list item ind bullet nil box nil (+ item item-size)) struct)
|
||||||
(setq struct (sort struct (lambda (e1 e2) (< (car e1) (car e2)))))
|
(setq struct (sort struct (lambda (e1 e2) (< (car e1) (car e2)))))
|
||||||
;; 6. If not BEFOREP, new item must appear after ITEM, so
|
;; 6. If not BEFOREP, new item must appear after ITEM, so
|
||||||
|
|
Loading…
Reference in a new issue