From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Brand Subject: Re: Opening an Org file slowed down Date: Sun, 24 Nov 2013 14:49:50 +0100 Message-ID: References: <87r4a7tmo2.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vka4Q-0003CU-De for emacs-orgmode@gnu.org; Sun, 24 Nov 2013 08:49:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vka4P-00061K-Cq for emacs-orgmode@gnu.org; Sun, 24 Nov 2013 08:49:54 -0500 Received: from mail-la0-x22e.google.com ([2a00:1450:4010:c03::22e]:42516) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vka4P-00061C-5W for emacs-orgmode@gnu.org; Sun, 24 Nov 2013 08:49:53 -0500 Received: by mail-la0-f46.google.com with SMTP id eh20so2176962lab.33 for ; Sun, 24 Nov 2013 05:49:51 -0800 (PST) In-Reply-To: <87r4a7tmo2.fsf@gmail.com> 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Goaziou Cc: Org Mode Hi Nicolas On Sat, Nov 23, 2013 at 11:52 AM, Nicolas Goaziou wrote: > I pushed a fix that should halve the time, I see this effect, thank you. > but it will still be slow. > > `org-element-at-point' is linear by the number of elements before point > in the current section. Therefore, parsing /all/ elements in a section > will be quadratic by the number of elements in the section. To avoid the quadratic scaling in my use case of "fileconversion" I think fileconversion should be improved to insert the leading stars _before_ Org mode has finished turning on. In the past org-mode-hook was simply used but it seems to have become the wrong choice for my purpose. First, I have an understanding question: I tried to find where org-mode-hook is called within the function org-mode but could not see something similar to the expected "(run-hooks 'org-mode-hook)". So I added 'backtrace to the org-mode-hook but don't understand it either: (backtrace) backtrace() run-hooks(change-major-mode-after-body-hook text-mode-hook outline-mode-hook org-mode-hook) apply(run-hooks (change-major-mode-after-body-hook text-mode-hook outline-mode-hook org-mode-hook)) run-mode-hooks(org-mode-hook) org-mode() [...] I see the expected "run-mode-hooks(org-mode-hook)" in this backtrace but where is the corresponding form in the function org-mode? Second, I guess it is not necessary to implement something like org-mode-early-hook but I could not find yet an existing hook. Which hook would you recommend for inserting the leading stars? Michael