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.
This commit is contained in:
Ihor Radchenko 2024-01-09 16:32:56 +01:00
parent 0773f4980c
commit c9e5270bf1
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
3 changed files with 24 additions and 3 deletions

View File

@ -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))

View File

@ -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

View File

@ -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: