Nicolas Goaziou <[email protected]> writes:
> Some major modes may use major mode hooks to finish setting up their
> fontification process, who knows.
>
> In any case, it could be worth trying it. Do you want to provide a patch
> for that?
>
> Regards,
I dived into the source code of two functions which are related to
defcustom variable ~org-src-fontify-natively~.
Here is my try:
#+begin_src diff
modified lisp/org-src.el
@@ -585,7 +585,14 @@ as `org-src-fontify-natively' is non-nil."
(erase-buffer)
;; Add string and a final space to ensure property change.
(insert string " "))
- (unless (eq major-mode lang-mode) (funcall lang-mode))
+ (unless (eq major-mode lang-mode)
+ (message "%s enabled in source block" lang-mode)
+ ;; (make-local-variable (intern (format "%s-hook" lang-mode)))
+ ;; (set (intern (format "%s-hook" lang-mode)) nil)
+ (message "%s is %s"
+ (intern (format "%s-hook" lang-mode))
+ (symbol-value (intern (format "%s-hook" lang-mode))))
+ (funcall lang-mode))
(org-font-lock-ensure)
(let ((pos (point-min)) next)
(while (setq next (next-property-change pos))
#+end_src
But it seems does not work as I expected.
Can't find out which real function is invoked when fontify every source blocks.
>From cd43cd7c4c4e98d2b62af84a0729f82fb361c25f Mon Sep 17 00:00:00 2001
From: stardiviner <[email protected]>
Date: Thu, 18 Oct 2018 12:55:30 +0800
Subject: [PATCH] Set all lang-mode-hook to nil to speedup source blocks
fontify.
---
lisp/org-src.el | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 9c462b7e7..271ca82b9 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -585,7 +585,14 @@ as `org-src-fontify-natively' is non-nil."
(erase-buffer)
;; Add string and a final space to ensure property change.
(insert string " "))
- (unless (eq major-mode lang-mode) (funcall lang-mode))
+ (unless (eq major-mode lang-mode)
+ (message "%s enabled in source block" lang-mode)
+ ;; (make-local-variable (intern (format "%s-hook" lang-mode)))
+ ;; (set (intern (format "%s-hook" lang-mode)) nil)
+ (message "%s is %s"
+ (intern (format "%s-hook" lang-mode))
+ (symbol-value (intern (format "%s-hook" lang-mode))))
+ (funcall lang-mode))
(org-font-lock-ensure)
(let ((pos (point-min)) next)
(while (setq next (next-property-change pos))
--
2.19.1
--
[ stardiviner ] don't need to convince with trends.
Blog: https://stardiviner.github.io/
IRC(freenode): stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3