branch: externals/org commit 37edef8bbd8eb8c034ffde3684d4d8d6ec031110 Author: Ihor Radchenko <yanta...@gmail.com> Commit: Ihor Radchenko <yanta...@gmail.com>
org-mode: Initialise cache before initialising file-local regexps * lisp/org.el (org-mode): Initialise cache earlier, allowing the file-local settings to be taken from persistent cache when possible. Also, bind `org-mode-loading' while org-mode is loading. * lisp/ol.el (org-update-radio-target-regexp): Do not try to refresh cache when we are loading file for the first time. --- lisp/ol.el | 3 ++- lisp/org.el | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lisp/ol.el b/lisp/ol.el index 1d3631219f..b80f943b2b 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -2020,7 +2020,8 @@ Also refresh fontification if needed." (list old-regexp org-target-link-regexp) "\\|") after-re))))) - (when (featurep 'org-element) + (when (and (featurep 'org-element) + (not (bound-and-true-p org-mode-loading))) (org-with-point-at 1 (while (re-search-forward regexp nil t) (org-element-cache-refresh (match-beginning 1)))))) diff --git a/lisp/org.el b/lisp/org.el index a11a1e3d17..cc21291e33 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4820,6 +4820,8 @@ This is for getting out of special buffers like capture.") (defvar org-element-cache-persistent); Defined in org-element.el (defvar org-element-use-cache); Defined in org-element.el +(defvar org-mode-loading nil + "Non-nil during Org mode initialisation.") ;;;###autoload (define-derived-mode org-mode outline-mode "Org" "Outline-based notes management and organizer, alias @@ -4839,6 +4841,7 @@ can be exported as a structured ASCII or HTML file. The following commands are available: \\{org-mode-map}" + (setq-local org-mode-loading t) (org-load-modules-maybe) (org-install-agenda-files-menu) (when org-link-descriptive (add-to-invisibility-spec '(org-link))) @@ -4874,6 +4877,11 @@ The following commands are available: (add-hook 'before-change-functions 'org-before-change-function nil 'local) ;; Check for running clock before killing a buffer (add-hook 'kill-buffer-hook 'org-check-running-clock nil 'local) + ;; Initialize cache. + (org-element-cache-reset) + (when (and org-element-cache-persistent + org-element-use-cache) + (org-persist-read 'org-element--cache (current-buffer))) ;; Initialize macros templates. (org-macro-initialize-templates) ;; Initialize radio targets. @@ -4885,11 +4893,6 @@ The following commands are available: (org-setup-filling) ;; Comments. (org-setup-comments-handling) - ;; Initialize cache. - (org-element-cache-reset) - (when (and org-element-cache-persistent - org-element-use-cache) - (org-persist-read 'org-element--cache (current-buffer))) ;; Beginning/end of defun (setq-local beginning-of-defun-function 'org-backward-element) (setq-local end-of-defun-function @@ -4978,7 +4981,8 @@ The following commands are available: ;; Set face extension as requested. (org--set-faces-extend '(org-block-begin-line org-block-end-line) org-fontify-whole-block-delimiter-line) - (org--set-faces-extend org-level-faces org-fontify-whole-heading-line)) + (org--set-faces-extend org-level-faces org-fontify-whole-heading-line) + (setq-local org-mode-loading nil)) ;; Update `customize-package-emacs-version-alist' (add-to-list 'customize-package-emacs-version-alist