Prechádzať zdrojové kódy

org-element-cache: Do not carry over warning after sync

* lisp/org-element.el (org-element--cache-sync): Set
`org-element--cache-warning' to nil at the end of synchronisation.
We do not need to consider that next request might be merged with
existing request in such scenario.
(org-element--cache-before-change): Add comment explaining the use of `org-element--cache-warning'.
Ihor Radchenko 3 rokov pred
rodič
commit
325b06bde4
1 zmenil súbory, kde vykonal 12 pridanie a 0 odobranie
  1. 12 0
      lisp/org-element.el

+ 12 - 0
lisp/org-element.el

@@ -5932,6 +5932,7 @@ The buffer is: %s\n Current command: %S\n Chars modified: %S\n Buffer modified:
 	  ;; Otherwise, reset keys.
 	  (if org-element--cache-sync-requests
 	      (org-element--cache-set-timer buffer)
+            (setq org-element--cache-change-warning nil)
             (setq org-element--cache-sync-keys-value (1+ org-element--cache-sync-keys-value))))))))
 
 (defun org-element--cache-process-request
@@ -6533,6 +6534,17 @@ The function returns the new value of `org-element--cache-change-warning'."
                            end
                          (line-end-position)))))
          (prog1
+             ;; Use the worst change warning to not miss important edits.
+             ;; This function is called before edit and after edit by
+             ;; `org-element--cache-after-change'.  Before the edit, we still
+             ;; want to use the old value if it comes from previous
+             ;; not yet processed edit (they may be merged by
+             ;; `org-element--cache-submit-request').  After the edit, we want to
+             ;; look if there was a sensitive removed during edit.
+             ;; FIXME: This is not the most efficient way and we now
+             ;; have to delete more elemetns than needed in some
+             ;; cases.  A better approach may be storing the warning
+             ;; in the modification request itself.
              (let ((org-element--cache-change-warning-before org-element--cache-change-warning)
                    (org-element--cache-change-warning-after))
                (setq org-element--cache-change-warning-after