From a8568372ad8bba841af7f7d1fdf9b64d38426c3a Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 5 Mar 2014 16:39:29 +0100 Subject: [PATCH] org-element: Fix wrong cache behaviour * lisp/org-element.el (org-element--cache-before-change): Correctly preserve match data. --- lisp/org-element.el | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index 0faf1fddd..4cfb2091e 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -5461,23 +5461,23 @@ BEG and END are the beginning and end of the range of changed text. See `before-change-functions' for more information." (let ((inhibit-quit t)) ;; Make sure buffer positions in cache are correct until END. - (org-element--cache-sync (current-buffer) end) - (org-with-wide-buffer - (goto-char beg) - (beginning-of-line) - (let ((top (point)) - (bottom (save-excursion (goto-char end) (line-end-position))) - (sensitive-re - ;; A sensitive line is a headline or a block (or drawer, - ;; or latex-environment) boundary. Inserting one can - ;; modify buffer drastically both above and below that - ;; line, possibly making cache invalid. Therefore, we - ;; need to pay attention to changes happening to them. - (concat - "\\(" (org-with-limited-levels org-outline-regexp-bol) "\\)" "\\|" - org-element--cache-closing-line "\\|" - org-element--cache-opening-line))) - (save-match-data + (save-match-data + (org-element--cache-sync (current-buffer) end) + (org-with-wide-buffer + (goto-char beg) + (beginning-of-line) + (let ((top (point)) + (bottom (save-excursion (goto-char end) (line-end-position))) + (sensitive-re + ;; A sensitive line is a headline or a block (or drawer, + ;; or latex-environment) boundary. Inserting one can + ;; modify buffer drastically both above and below that + ;; line, possibly making cache invalid. Therefore, we + ;; need to pay attention to changes happening to them. + (concat + "\\(" (org-with-limited-levels org-outline-regexp-bol) "\\)" "\\|" + org-element--cache-closing-line "\\|" + org-element--cache-opening-line))) (setq org-element--cache-change-warning (cond ((not (re-search-forward sensitive-re bottom t)) nil) ((and (match-beginning 1) -- 2.11.4.GIT