branch: externals/org commit 5aeeb4f739ec4092f96177ffa9896ede7bdbe0ec Author: Ihor Radchenko <yanta...@gmail.com> Commit: Ihor Radchenko <yanta...@gmail.com>
Use `org-element-at-point-no-context' in performance-critical places * lisp/org-compat.el (org-mode-flyspell-verify, org-indent-line, org-indent-region, org-indent-drawer, org-indent-block): Use `org-element-at-point-no-context' in place of `org-element-at-point' when we are doing changes. * lisp/org.el (org-collect-keywords): Use direct parsing in place of `org-elemnt-at-point' --- lisp/org-compat.el | 4 ++-- lisp/org.el | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 0950ff7..f77f779 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -1047,8 +1047,8 @@ ELEMENT is the element at point." (or (not (match-beginning 5)) (< (point) (match-beginning 5))) ;; Ignore checks in code, verbatim and others. - (org--flyspell-object-check-p (org-element-at-point))) - (let* ((element (org-element-at-point)) + (org--flyspell-object-check-p (org-element-at-point-no-context))) + (let* ((element (org-element-at-point-no-context)) (post-affiliated (org-element-property :post-affiliated element))) (cond ;; Ignore checks in all affiliated keywords but captions. diff --git a/lisp/org.el b/lisp/org.el index 7543277..6b2d6bf 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4537,7 +4537,7 @@ directory." (let ((case-fold-search t) (regexp (org-make-options-regexp keywords))) (while (and keywords (re-search-forward regexp nil t)) - (let ((element (org-element-at-point))) + (let ((element (org-with-point-at (match-beginning 0) (org-element-keyword-parser (line-end-position) (list (match-beginning 0)))))) (when (eq 'keyword (org-element-type element)) (let ((value (org-element-property :value element))) (pcase (org-element-property :key element) @@ -19271,7 +19271,7 @@ Also align node properties according to `org-property-format'." (skip-chars-backward "\n") (or (org-at-heading-p) (looking-back ":END:.*" (point-at-bol)))))) - (let* ((element (save-excursion (beginning-of-line) (org-element-at-point))) + (let* ((element (save-excursion (beginning-of-line) (org-element-at-point-no-context))) (type (org-element-type element))) (cond ((and (memq type '(plain-list item)) (= (line-beginning-position) @@ -19344,7 +19344,7 @@ assumed to be significant there." (end (copy-marker end))) (while (< (point) end) (if (or (looking-at-p " \r\t\n") (org-at-heading-p)) (forward-line) - (let* ((element (org-element-at-point)) + (let* ((element (org-element-at-point-no-context)) (type (org-element-type element)) (element-end (copy-marker (org-element-property :end element))) (ind (org--get-expected-indentation element nil))) @@ -19450,7 +19450,7 @@ assumed to be significant there." (beginning-of-line) (looking-at-p org-drawer-regexp)) (user-error "Not at a drawer")) - (let ((element (org-element-at-point))) + (let ((element (org-element-at-point-no-context))) (unless (memq (org-element-type element) '(drawer property-drawer)) (user-error "Not at a drawer")) (org-with-wide-buffer @@ -19466,7 +19466,7 @@ assumed to be significant there." (let ((case-fold-search t)) (looking-at-p "[ \t]*#\\+\\(begin\\|end\\)_"))) (user-error "Not at a block")) - (let ((element (org-element-at-point))) + (let ((element (org-element-at-point-no-context))) (unless (memq (org-element-type element) '(comment-block center-block dynamic-block example-block export-block quote-block special-block