From df4a5d86d8e483f8780e0af1274c4529a4cd967c Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Mon, 16 Jan 2023 12:21:57 +0300 Subject: [PATCH] org-fold: Fix isearch when `org-fold-core-style' is 'overlays * lisp/org-fold-core.el (org-fold-core--isearch-show): Make sure that the actual isearch match is revealed. This relies on undocumented behavior of isearch that point is at the match when 'isearch-open-invisible is called. (org-fold-core-region): Disable 'isearch-open-invisible-temporary features when `org-fold-core-style' is 'overlays. This is to work around the undocumented requirement of isearch to _not_ delete the overlay passed to 'isearch-open-invisible-temporary function. Since `org-fold-show-set-visibility' may destroy overlays arbitrarily, we cannot currently support isearch `org-fold-show-context-detail' in full. Reported-by: Matt Lundin Link: https://orgmode.org/list/87zgb6tk6h.fsf@localhost --- lisp/org-fold-core.el | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lisp/org-fold-core.el b/lisp/org-fold-core.el index 0855e6f39..027ff9215 100644 --- a/lisp/org-fold-core.el +++ b/lisp/org-fold-core.el @@ -1003,7 +1003,13 @@ If SPEC-OR-ALIAS is omitted and FLAG is nil, unfold everything in the region." (overlay-put o (org-fold-core--property-symbol-get-create spec) spec) (overlay-put o 'invisible spec) (overlay-put o 'isearch-open-invisible #'org-fold-core--isearch-show) - (overlay-put o 'isearch-open-invisible-temporary #'org-fold-core--isearch-show-temporary)) + ;; FIXME: Disabling to work around Emacs bug#60399 + ;; and https://orgmode.org/list/87zgb6tk6h.fsf@localhost. + ;; The proper fix will require making sure that + ;; `org-fold-core-isearch-open-function' does not + ;; delete the overlays used by isearch. + ;; (overlay-put o 'isearch-open-invisible-temporary #'org-fold-core--isearch-show-temporary) + ) (put-text-property from to (org-fold-core--property-symbol-get-create spec) spec) (put-text-property from to 'isearch-open-invisible #'org-fold-core--isearch-show) (put-text-property from to 'isearch-open-invisible-temporary #'org-fold-core--isearch-show-temporary) @@ -1131,16 +1137,9 @@ This function is intended to be used as `isearch-filter-predicate'." "Clear `org-fold-core--isearch-local-regions'." (clrhash org-fold-core--isearch-local-regions)) -(defun org-fold-core--isearch-show (region) - "Reveal text in REGION found by isearch. -REGION can also be an overlay in current buffer." - (when (overlayp region) - (setq region (cons (overlay-start region) - (overlay-end region)))) - (org-with-point-at (car region) - (while (< (point) (cdr region)) - (funcall org-fold-core-isearch-open-function (car region)) - (goto-char (org-fold-core-next-visibility-change (point) (cdr region) 'ignore-hidden))))) +(defun org-fold-core--isearch-show (_) + "Reveal text at point found by isearch." + (funcall org-fold-core-isearch-open-function (point))) (defun org-fold-core--isearch-show-temporary (region hide-p) "Temporarily reveal text in REGION.