emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] A file with 'org-mode rot'?


From: Nicolas Goaziou
Subject: Re: [O] A file with 'org-mode rot'?
Date: Sun, 13 Apr 2014 19:49:17 +0200

Karl Voit <address@hidden> writes:

> However, my (long) Org-mode files with the performance issues is not
> a situation I am satisfied. Last week I presented Org-mode at a
> Linuxdays-event here in Graz and I had to apologize for all the
> weird behavior. This was somewhat embarrassing :-(

Does this happen on stable branch?

> Sure. After a couple of minutes, I C-g and this is the output:
> http://paste.grml.org/1898/

Would the following patch improve the situation?


Regards,

-- 
Nicolas Goaziou
>From 3b772bab6d99298844d9d05f79a12e1a9fb87a3a Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <address@hidden>
Date: Sun, 13 Apr 2014 19:28:20 +0200
Subject: [PATCH] ob-exp: Improve speed

---
 lisp/ob-exp.el | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index 220a3c3..dc2bc94 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -153,20 +153,12 @@ may make them unreachable."
   (save-window-excursion
     (save-excursion
       (let ((case-fold-search t)
-           (org-babel-exp-reference-buffer reference-buffer)
-           (regexp (concat org-babel-inline-src-block-regexp "\\|"
-                           org-babel-lob-one-liner-regexp "\\|"
-                           "^[ \t]*#\\+BEGIN_SRC")))
+           (org-babel-exp-reference-buffer reference-buffer))
        (goto-char (point-min))
-       (while (re-search-forward regexp nil t)
+       (while (re-search-forward
+               "src_\\|^[ \t]*#\\+\\(call:\\|begin_src\\)\\|call_" nil t)
          (unless (save-match-data (org-in-commented-heading-p))
-           (let* ((element (save-excursion
-                             ;; If match is inline, point is at its
-                             ;; end.  Move backward so
-                             ;; `org-element-context' can get the
-                             ;; object, not the following one.
-                             (backward-char)
-                             (save-match-data (org-element-context))))
+           (let* ((element (save-match-data (org-element-context)))
                   (type (org-element-type element))
                   (begin (copy-marker (org-element-property :begin element)))
                   (end (copy-marker
@@ -176,6 +168,10 @@ may make them unreachable."
                           (point)))))
              (case type
                (inline-src-block
+                (goto-char begin)
+                (unless (bolp) (backward-char))
+                (looking-at org-babel-inline-src-block-regexp)
+                (goto-char (match-end 0))
                 (let* ((info (org-babel-parse-inline-src-block-match))
                        (params (nth 2 info)))
                   (setf (nth 1 info)
@@ -201,6 +197,11 @@ may make them unreachable."
                       (delete-region begin end)
                       (insert replacement)))))
                ((babel-call inline-babel-call)
+                (goto-char (or (org-element-property :post-affiliated element)
+                               begin))
+                (unless (bolp) (backward-char))
+                (looking-at org-babel-lob-one-liner-regexp)
+                (goto-char (match-end 0))
                 (let* ((lob-info (org-babel-lob-get-info))
                        (results
                         (org-babel-exp-do-export
-- 
1.9.2


reply via email to

[Prev in Thread] Current Thread [Next in Thread]