emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/org a98ae424d2: org-element-cache: Give user more contr


From: ELPA Syncer
Subject: [elpa] externals/org a98ae424d2: org-element-cache: Give user more control over silent modificatoin checks
Date: Thu, 6 Jan 2022 07:57:46 -0500 (EST)

branch: externals/org
commit a98ae424d2d4b5f11eeb1e2ef5699855d18887e5
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>

    org-element-cache: Give user more control over silent modificatoin checks
    
    * lisp/org-element.el (org-element--cache-silent-modification-check):
    New variable allowing the user to suppress modification checks completely.
    * lisp/org-element.el (org-element--cache-sync): Support
    `org-element--cache-silent-modification-check'.
    
    The existing heuristics for built-in non-modifying commands that
    change `buffer-chars-modified-tick' is not sufficient.  At least
    `capitalize-word' changes the tick regardless whether the buffer was
    actually modified or not.  Yet, `capitalize-word' does not call
    `after-change-functions' if the buffer is not really modified.
    
    Reported in 
https://list.orgmode.org/2022-01-06T12-13-17@devnull.Karl-Voit.at/T/#mb3771758f81b31721ba2f420878a4d16081dc483
---
 lisp/org-element.el | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index 71f53f1ae8..e61c292d51 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -5321,6 +5321,17 @@ can change `buffer-chars-modified-tick' internally even 
though no
 visible changes in buffer are being made.  Some of such expected cases
 are covered by heuristics, but not all.")
 
+(defvar org-element--cache-silent-modification-check t
+  "Detect changes in buffer made inside `with-silent-modifications'.
+
+Note that some internal Emacs functions may also trigger a warning and
+cache reset.  The warning can be suppressed by setting
+`org-element--cache-diagnostics-modifications' to nil, but the cache
+will still be refreshed to be safe.
+
+WARNING: Setting this variable to nil may cause cache corruption is some
+third-party packages make undetected changes in buffers.")
+
 (defvar org-element--cache-diagnostics-level 2
   "Detail level of the diagnostics.")
 
@@ -5859,7 +5870,8 @@ actually submitted."
       ;; Check if the buffer have been changed outside visibility of
       ;; `org-element--cache-before-change' and 
`org-element--cache-after-change'.
       (if (and (/= org-element--cache-change-tic
-                  (buffer-chars-modified-tick))
+                   (buffer-chars-modified-tick))
+               org-element--cache-silent-modification-check
                ;; FIXME: Below is a heuristics noticed by observation.
                ;; quail.el with non-latin input does silent
                ;; modifications in buffer increasing the tick counter
@@ -5878,7 +5890,8 @@ actually submitted."
                            ;; A number of Emacs internal operations in
                            ;; Emacs 26 and 27 alter
                            ;; `buffer-chars-modified-tick' (see
-                           ;; 
https://list.orgmode.org/87ee7jdv70.fsf@localhost/T/#t).
+                           ;; 
https://list.orgmode.org/87ee7jdv70.fsf@localhost/T/#t
+                           ;; 
https://list.orgmode.org/2022-01-06T12-13-17@devnull.Karl-Voit.at/T/#mb3771758f81b31721ba2f420878a4d16081dc483).
                            ;; We have no way to distinguish them from
                            ;; dangerious silent edits.  So, we can
                            ;; only reset the cache, but do not show



reply via email to

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