summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2014-06-23 12:28:11 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2014-06-23 12:28:11 +0200
commit69773248c505e6041bee9c039debe8f482d11d1a (patch)
tree79f46edb05c076d1689246ae005273d78ed87baf
parentdef0361b7b9fa517d71c5cafa147765bcc51efc5 (diff)
downloadorg-mode-69773248c505e6041bee9c039debe8f482d11d1a.tar.gz
org-element: Fix cache
* lisp/org-element.el (org-element--cache-after-change): Preserve match data. Thanks to Matt Lundin for reporting it. http://permalink.gmane.org/gmane.emacs.orgmode/87871
-rw-r--r--lisp/org-element.el71
1 files changed, 35 insertions, 36 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index abf5f62..c140b38 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -5449,47 +5449,46 @@ text. See `before-change-functions' for more information."
BEG and END are the beginning and end of the range of changed
text, and the length in bytes of the pre-change text replaced by
that range. See `after-change-functions' for more information."
- (let ((inhibit-quit t))
- (when (org-element--cache-active-p)
- (org-with-wide-buffer
- (goto-char beg)
- (beginning-of-line)
+ (when (org-element--cache-active-p)
+ (org-with-wide-buffer
+ (goto-char beg)
+ (beginning-of-line)
+ (save-match-data
(let ((top (point))
(bottom (save-excursion (goto-char end) (line-end-position))))
(org-with-limited-levels
- (save-match-data
- ;; Determine if modified area needs to be extended,
- ;; according to both previous and current state. We make
- ;; a special case for headline editing: if a headline is
- ;; modified but not removed, do not extend.
- (when (let ((previous-state org-element--cache-change-warning)
- (sensitive-re
- (concat "\\(" org-outline-regexp-bol "\\)" "\\|"
- org-element--cache-closing-line "\\|"
- org-element--cache-opening-line))
- (case-fold-search t))
- (cond ((eq previous-state t))
- ((not (re-search-forward sensitive-re bottom t))
- (eq previous-state 'headline))
- ((match-beginning 1)
- (or (not (eq previous-state 'headline))
- (and (progn (goto-char bottom)
- (re-search-backward
- sensitive-re (match-end 1) t))
- (not (match-beginning 1)))))
- (t)))
- ;; Effectively extend modified area.
- (setq top (progn (goto-char top)
- (when (outline-previous-heading) (forward-line))
- (point)))
- (setq bottom (progn (goto-char bottom)
- (if (outline-next-heading) (1- (point))
- (point)))))))
+ ;; Determine if modified area needs to be extended,
+ ;; according to both previous and current state. We make
+ ;; a special case for headline editing: if a headline is
+ ;; modified but not removed, do not extend.
+ (when (let ((previous-state org-element--cache-change-warning)
+ (sensitive-re
+ (concat "\\(" org-outline-regexp-bol "\\)" "\\|"
+ org-element--cache-closing-line "\\|"
+ org-element--cache-opening-line))
+ (case-fold-search t))
+ (cond ((eq previous-state t))
+ ((not (re-search-forward sensitive-re bottom t))
+ (eq previous-state 'headline))
+ ((match-beginning 1)
+ (or (not (eq previous-state 'headline))
+ (and (progn (goto-char bottom)
+ (re-search-backward
+ sensitive-re (match-end 1) t))
+ (not (match-beginning 1)))))
+ (t)))
+ ;; Effectively extend modified area.
+ (setq top (progn (goto-char top)
+ (when (outline-previous-heading) (forward-line))
+ (point)))
+ (setq bottom (progn (goto-char bottom)
+ (if (outline-next-heading) (1- (point))
+ (point))))))
;; Store synchronization request.
(let ((offset (- end beg pre)))
- (org-element--cache-submit-request top (- bottom offset) offset))))
- ;; Activate a timer to process the request during idle time.
- (org-element--cache-set-timer (current-buffer)))))
+ (org-element--cache-submit-request top (- bottom offset) offset)))))
+ ;; Activate a timer to process the request during idle time.
+ (org-element--cache-set-timer (current-buffer))))
(defun org-element--cache-for-removal (beg end offset)
"Return first element to remove from cache.