org-element: Small refactoring
* lisp/org-element.el (org-element-at-point): Refactor code. Fixing
structure in cached plain lists is no longer required since
4423d750a4
.
This commit is contained in:
parent
fde42c5303
commit
4dbbbe5b01
|
@ -5284,29 +5284,20 @@ first row."
|
||||||
(while t
|
(while t
|
||||||
(unless element
|
(unless element
|
||||||
(setq element
|
(setq element
|
||||||
(let* ((pos (if (and (memq special-flag '(item table-row))
|
(let ((pos (if (and (memq special-flag '(item table-row))
|
||||||
(memq type '(plain-list table)))
|
(memq type '(plain-list table)))
|
||||||
;; First item (resp. row) in
|
;; First item (resp. row) in plain
|
||||||
;; plain list (resp. table) gets
|
;; list (resp. table) gets
|
||||||
;; a special key in cache.
|
;; a special key in cache.
|
||||||
(1+ (point))
|
(1+ (point))
|
||||||
(point)))
|
(point))))
|
||||||
(cached (org-element-cache-get pos 'element)))
|
(or (org-element-cache-get pos 'element)
|
||||||
(cond
|
(let ((element (org-element--current-element
|
||||||
((not cached)
|
end 'element special-flag struct)))
|
||||||
(let ((element (org-element--current-element
|
(when (derived-mode-p 'org-mode)
|
||||||
end 'element special-flag struct)))
|
(org-element-cache-put pos (cons element nil)))
|
||||||
(when (derived-mode-p 'org-mode)
|
(org-element-put-property element
|
||||||
(org-element-cache-put pos (cons element nil)))
|
:parent parent))))))
|
||||||
(org-element-put-property element :parent parent)))
|
|
||||||
;; When changes happened in the middle of
|
|
||||||
;; a list, its structure ends up being
|
|
||||||
;; invalid. Therefore, we make sure to use
|
|
||||||
;; a valid one.
|
|
||||||
((and struct (memq (org-element-type cached)
|
|
||||||
'(item plain-list)))
|
|
||||||
(org-element-put-property cached :structure struct))
|
|
||||||
(t cached)))))
|
|
||||||
(setq type (org-element-type element))
|
(setq type (org-element-type element))
|
||||||
(cond
|
(cond
|
||||||
;; 1. Skip any element ending before point. Also skip
|
;; 1. Skip any element ending before point. Also skip
|
||||||
|
@ -5317,8 +5308,8 @@ first row."
|
||||||
(and (= elem-end origin) (/= elem-end end)))
|
(and (= elem-end origin) (/= elem-end end)))
|
||||||
(goto-char elem-end)))
|
(goto-char elem-end)))
|
||||||
(setq element nil))
|
(setq element nil))
|
||||||
;; 2. An element containing point is always the element at
|
;; 2. An element containing point is always the element
|
||||||
;; point.
|
;; at point.
|
||||||
((not (memq type org-element-greater-elements))
|
((not (memq type org-element-greater-elements))
|
||||||
(throw 'exit element))
|
(throw 'exit element))
|
||||||
;; 3. At any other greater element type, if point is
|
;; 3. At any other greater element type, if point is
|
||||||
|
|
Loading…
Reference in New Issue