From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: Re: temporary set source blocks major-mode-hook to nil locally to speed up Org Mode Date: Thu, 18 Oct 2018 12:57:11 +0800 Message-ID: <871s8nua1k.fsf@gmail.com> References: <87r2gt55pq.fsf@gmail.com> <87d0sbexkq.fsf@nicolasgoaziou.fr> Reply-To: numbchild@gmail.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD0N9-0000dJ-Sa for emacs-orgmode@gnu.org; Thu, 18 Oct 2018 00:57:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD0N1-0002WQ-IB for emacs-orgmode@gnu.org; Thu, 18 Oct 2018 00:57:20 -0400 Received: from [61.175.244.13] (port=49004 helo=dark.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD0N1-0002Pd-2C for emacs-orgmode@gnu.org; Thu, 18 Oct 2018 00:57:15 -0400 In-reply-to: <87d0sbexkq.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: org-mode --=-=-= Content-Type: text/plain Nicolas Goaziou 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Set-all-lang-mode-hook-to-nil-to-speedup-source-bloc.patch Content-Description: a simple try >From cd43cd7c4c4e98d2b62af84a0729f82fb361c25f Mon Sep 17 00:00:00 2001 From: stardiviner 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 --=-=-= Content-Type: text/plain -- [ stardiviner ] don't need to convince with trends. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 --=-=-=--