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

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

[elpa] externals/org c9e5270bf1 1/2: lisp/org.el (org-self-insert-comman


From: ELPA Syncer
Subject: [elpa] externals/org c9e5270bf1 1/2: lisp/org.el (org-self-insert-command): Do not skip fragility checks
Date: Tue, 9 Jan 2024 12:58:22 -0500 (EST)

branch: externals/org
commit c9e5270bf10c600b4c8d6e634e484c9f42bb28be
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    lisp/org.el (org-self-insert-command): Do not skip fragility checks
    
    * lisp/org-fold-core.el (org-fold-core--suppress-folding-fix):
    (org-fold-core-suppress-folding-fix): New macro suppressing re-folding
    checks.
    (org-fold-core--fix-folded-region): Skip re-folding checks when
    `org-fold-core--suppress-folding-fix' is non-nil.
    * lisp/org.el (org-self-insert-command): Use
    `org-fold-core-suppress-folding-fix' to bypass re-folding checks, but
    not fragility checks.
    *
    testing/lisp/test-org-fold.el 
(test-org-fold/org-fold-reveal-broken-structure):
    New test.
---
 lisp/org-fold-core.el         | 10 +++++++++-
 lisp/org.el                   |  6 ++++--
 testing/lisp/test-org-fold.el | 11 +++++++++++
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/lisp/org-fold-core.el b/lisp/org-fold-core.el
index 4ff4a2fc05..3f5bd2121b 100644
--- a/lisp/org-fold-core.el
+++ b/lisp/org-fold-core.el
@@ -1289,6 +1289,8 @@ instead of text properties.  The created overlays will be 
stored in
   "Non-nil: skip processing modifications in 
`org-fold-core--fix-folded-region'.")
 (defvar org-fold-core--ignore-fragility-checks nil
   "Non-nil: skip fragility checks in `org-fold-core--fix-folded-region'.")
+(defvar org-fold-core--suppress-folding-fix nil
+  "Non-nil: skip folding fix in `org-fold-core--fix-folded-region'.")
 
 (defmacro org-fold-core-ignore-modifications (&rest body)
   "Run BODY ignoring buffer modifications in 
`org-fold-core--fix-folded-region'."
@@ -1297,6 +1299,12 @@ instead of text properties.  The created overlays will 
be stored in
      (unwind-protect (progn ,@body)
        (setq org-fold-core--last-buffer-chars-modified-tick 
(buffer-chars-modified-tick)))))
 
+(defmacro org-fold-core-suppress-folding-fix (&rest body)
+  "Run BODY skipping re-folding checks in `org-fold-core--fix-folded-region'."
+  (declare (debug (form body)) (indent 0))
+  `(let ((org-fold-core--suppress-folding-fix t))
+     (progn ,@body)))
+
 (defmacro org-fold-core-ignore-fragility-checks (&rest body)
   "Run BODY skipping :fragility checks in `org-fold-core--fix-folded-region'."
   (declare (debug (form body)) (indent 0))
@@ -1330,7 +1338,7 @@ property, unfold the region if the :fragile function 
returns non-nil."
       ;; buffer.  Work around Emacs bug#46982.
       ;; Re-hide text inserted in the middle/front/back of a folded
       ;; region.
-      (unless (equal from to) ; Ignore deletions.
+      (unless (or org-fold-core--suppress-folding-fix (equal from to)) ; 
Ignore deletions.
         (when (eq org-fold-core-style 'text-properties)
           (org-fold-core-cycle-over-indirect-buffers
            (dolist (spec (org-fold-core-folding-spec-list))
diff --git a/lisp/org.el b/lisp/org.el
index 57379c26af..cf9abafac9 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16768,7 +16768,8 @@ overwritten, and the table is not marked as requiring 
realignment."
        t)
      (looking-at "[^|\n]*  |"))
     ;; There is room for insertion without re-aligning the table.
-    (org-fold-core-ignore-modifications
+    ;; Interactively, point should never be inside invisible regions
+    (org-fold-core-suppress-folding-fix
       (self-insert-command N))
     (org-table-with-shrunk-field
      (save-excursion
@@ -16779,7 +16780,8 @@ overwritten, and the table is not marked as requiring 
realignment."
        (delete-region (- (point) 2) (1- (point))))))
    (t
     (setq org-table-may-need-update t)
-    (org-fold-core-ignore-modifications
+    ;; Interactively, point should never be inside invisible regions
+    (org-fold-core-suppress-folding-fix
       (self-insert-command N)
       (org-fix-tags-on-the-fly))
     (when org-self-insert-cluster-for-undo
diff --git a/testing/lisp/test-org-fold.el b/testing/lisp/test-org-fold.el
index 955ebc4170..22f17977f1 100644
--- a/testing/lisp/test-org-fold.el
+++ b/testing/lisp/test-org-fold.el
@@ -471,6 +471,17 @@ Text here"
       (org-delete-char 1)
       (re-search-forward "Text")
       (should-not (org-invisible-p)))
+    (org-test-with-temp-text
+        "<point>* Heading 1
+Text here"
+      (org-overview)
+      (re-search-forward "Text")
+      (should (org-invisible-p))
+      (goto-char 1)
+      (let ((last-command-event ?a))
+        (org-self-insert-command 1))
+      (re-search-forward "Text")
+      (should-not (org-invisible-p)))
     (org-test-with-temp-text
         "* Heading 1
 <point>:PROPERTIES:



reply via email to

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