* lisp/org-fold-core.el (org-fold-core--specs): Add new folding spec -
:font-lock. When non-nil, enable re-fontification of the folds.
(org-fold-core-region): Only trigger re-fontification when the folding
spec has :font-lock property.
* lisp/org-fold.el (org-fold-initialize): Only enable re-fontification
of folded outlines, drawers, and blocks.
* lisp/org-fold-core.el (org-fold-core-region): Do not just update
folds before/after. Refresh newlines created by splicing a fold by
unfolding in the middle of an existing fold. Then, fold list between
from/to will not cover the folds right before from and right after to.
Reported-by: StrawberryTea <look@strawberrytea.xyz>
Link: https://orgmode.org/list/878r2xfk60.fsf@strawberrytea.xyz
* lisp/org-fold-core.el (org-fold-core-region): Make sure that we
refresh fontification of newlines after folds when unfolding is
requested across multiple non-intersecting folds.
Reported-by: StrawberryTea <look@strawberrytea.xyz>
Link: https://orgmode.org/list/87y1b0m0ij.fsf@strawberrytea.xyz
* lisp/org-fold-core.el (org-fold-core--update-buffer-folds): New
function updating buffer folds in copied text for current buffer.
(org-fold-core-decouple-indirect-buffer-folds): Use the new function.
* lisp/org-element.el (org-element--generate-copy-script): Synchronize
folds.
* lisp/org-fold-core.el (org-fold-core-get-folding-spec): When SPEC is
nil, do not rely upon 'invisible property value to determine the fold.
Examine unique property set by `org-fold-region' instead.
* lisp/org.el (org-activate-folds): New fontification function to
arrange faces at newlines after folds to be the same as face before
the fold.
(org-set-font-lock-defaults): Add the new fontification function.
* lisp/org-fold-core.el (org-fold-core-region): Refresh fontification
of newlines after folds when folding/unfolding.
Reported-by: StrawberryTea <look@strawberrytea.xyz>
Link: https://orgmode.org/list/87plwoqrfv.fsf@strawberrytea.xyz
* lisp/org-fold-core.el (org-fold-core-style): Set default value to
'overlays in newer Emacs versions. Newer Emacs does not have
performance issues with overlays and using text-properties there is
not beneficial due to numerous issues with most of Emacs code and
third-party packages that assume overlay-based folding.
* lisp/org-fold-core.el (org-fold-core-region): When folding, when the
fold ends at a newline, copy 'face property from the beginning of the
fold, so that the trailing newline after ellipsis does not appear
with different face. This fixes :extend t in headlines, blocks, and
drawers not being honored when the headlines are folded.
* etc/ORG-NEWS (Folded lines can now extend their face beyond
ellipsis): Announce the change.
Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=65896
* lisp/org-fold-core.el (org-fold-core--fix-folded-region): Delay
revealing fragile regions to until the current command is executed.
(org-fold-core--region-delayed): New function to postpone folding to
the time when `post-command-hook' is executed.
(org-fold-core--region-delayed-list): New internal variable holding
delayed fold requests.
(org-fold-core--process-delayed): New function to be used to process
the delayed folds and cleanup `post-command-hook'.
*
testing/lisp/test-org-fold.el (test-org-fold/org-fold-reveal-broken-structure):
Update tests to account for the delayed unfolding.
Reported-by: Sebastian Miele <iota@whxvd.name>
Link: https://orgmode.org/list/875y04yq9s.fsf@localhost
* 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 (org-fold-core-get-folding-spec-from-alias):
Do not put ":alias" as an actual alias. The code did not account that
`assq' returns the whole cons cell, not just value of the alist item.
* lisp/org-fold-core.el (org-fold-core-next-folding-state-change):
Avoid repetitive searches all to way to LIMIT. Instead, limit the
next searches by the limit computer by previous.
* lisp/org-fold-core.el (org-fold-core--isearch-setup): Use
add-function, respecting the value of `isearch-filter-predicate'.
(org-fold-core--isearch-filter-predicate-overlays): Remove.
Link: https://yhetil.org/emacs-devel/87o7lxpip9.fsf@web.de
* lisp/org-fold-core.el (org-fold-core--with-isearch-active): New
macro, signaling `org-fold-core-region' to store newly created folds
in `org-fold-core--isearch-overlays'.
(org-fold-core-region): Respect the new macro. Respect fold priority
for overlays.
(org-fold-core--isearch-setup): Do not run
`org-fold-core--clear-isearch-overlays' twice.
(org-fold-core--isearch-show): Fix when point is not on the match.
(org-fold-core--isearch-show-temporary): Rewrite, limiting to overlays
only and simplifying the code.
(org-fold-core--create-isearch-overlays): Extend link folds to full
link.
(org-fold-core--clear-isearch-overlay): Do not expect to be called in `isearch-mode-end-hook'.
* lisp/org-fold.el (org-fold--isearch-reveal): Respect argument.
* lisp/org-fold-core.el (org-fold-core-get-folding-spec): Only
consider folding using a single (currently selected) folding style.
Multiple fold styles may be present during isearch - we do not want to
mix them.
* lisp/org-fold-core.el (org-fold-core--isearch-show): Make use of the
passed argument. Do not just rely on `point' being at the isearch
match.
This partially fixes edge case with point being moved to the end of
the folded region during isearch.
* lisp/org-fold-core.el (org-fold-core-cycle-over-indirect-buffers):
Clear folds from killed indirect buffers once only. Avoid calling
`remove-text-properties' when there is nothing to remove.
* lisp/org-fold-core.el (org-fold-core--fix-folded-region): Ignore
deletions more aggressively, avoiding the calls to
`org-fold-core-cycle-over-indirect-buffers'.
* lisp/org-fold-core.el (org-fold-core--keep-overlays): New internal
macro, signaling `org-fold-core-region' to keep overlays in place and
store new overlays for later use in isearch.
(org-fold-core-region): Never remove overlays and store newly created
ones in `org-fold-core--isearch-overlays' when
`org-fold-core--keep-overlays' is non-nil. Remove resolved FIXME.
(org-fold-core--isearch-setup): Advice `isearch-clean-overlays' as
more reliable way to clear all the temporary overlays created for
isearch. `query-replace' and EVIL packages use
`isearch-filter-predicate' separately as thus `isearch-mode-end-hook'
is not sufficient to ensure that isearch overlays are converted back
to text properties.
(org-fold-core--isearch-show-temporary): Do not alter match data, as
isearch expects the match data to stay unchanged. Arrange the
overlays to be kept for isearch consumption (otherwise, isearch will
signal an error; see
https://list.orgmode.org/orgmode/87pmc4smdg.fsf@fastmail.fm/).
(org-fold-core--create-isearch-overlays): Call `org-fold-core-region'
with let-bound `org-fold-core-style' instead of repeating the code
from `org-fold-core-region'.
Reported-by: Michael Dauer <mick.dauer@gmail.com>
Link:
https://list.orgmode.org/orgmode/CAP7OBx+L11ck3Ni6rv94HGU3otdj6C4rG-rMDzkwR1LTj=BWiw@mail.gmail.com/
Link+: https://list.orgmode.org/orgmode/87pmc4smdg.fsf@fastmail.fm/
Link+: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60399
Link+: https://yhetil.org/emacs-devel/87fs7c10cq.fsf@web.de/
* lisp/org-fold-core.el (org-fold-core-next-visibility-change): Take
into account that `previous-single-char-property-change' move the
point to the first position where the property is still unchanged.
* lisp/org-cycle.el (org-cycle-set-visibility-according-to-property):
Ignore invisibility when skipping subtree.
Reported-by: Philipp Kiefer <phil.kiefer@gmail.com>
Link: https://orgmode.org/list/96becf12-9a5a-2fc2-0105-a41528be1f66@gmail.com
* 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 <mdl@imapmail.org>
Link: https://orgmode.org/list/87zgb6tk6h.fsf@localhost
* lisp/org-fold-core.el (org-fold-core-save-visibility): Calculate
folds on runtime, not during macro expansion.
* testing/lisp/test-org.el (test-org/org-ctrl-c-ctrl-c): Add test
ensuring that outline visibility is preserved upon refreshing Org
setup.
Reported-by: Matt Lundin <mdl@imapmail.org>
Link: https://orgmode.org/list/87wn70tlcn.fsf@fastmail.fm
* lisp/org-fold-core.el (org-fold-core-cycle-over-indirect-buffers):
Fix logic detecting foreign `org-fold-core--indirect-buffers'.
`current-buffer' is not always at `car'. Before this change, capture
buffers could be missed when cycling over indirect buffers causing
subtle bugs.
Reported-by: Alexandros Prekates <aprekates@posteo.net>
Link: https://orgmode.org/list/20221128122841.2246aa08@enous
* lisp/org-fold-core.el (org-fold-core--property-symbol-get-create):
(org-fold-core-decouple-indirect-buffer-folds): Do not try to decouple
folding state in indirect buffers when 'ignore-indirect is requested
in `org-fold-core--optimise-for-huge-buffers'.
* lisp/org-fold-core.el: Remove the code overriding
`font-lock-default-fontify-region'. Emacs itself is skipping
fontification of invisible text and doing it more efficiently. The
org-fold fontification overrides are redundant, except when some
poorly written third-party code is forcing fontification inside folded
regions. However, Org does not need to entertain poorly written third
party code, especially when the required supporting code is reducing
font-lock performance and is complicating the maintenance.
(org-fold-core--specs):
(org-fold-core-add-folding-spec): Remove `:font-lock-skip' spec.
(org-fold-core-initialize):
(org-fold-core--fontifying):
(org-fold-core-region):
(org-fold-core--force-fontification):
(org-fold-core-fontify-region): Remove custom fontification.
* lisp/org-fold.el (org-fold-initialize): Remove `:font-lock-skip'
spec.
* lisp/org-macs.el (org-fold-core--force-fontification):
(org-with-forced-fontification):
(org-buffer-substring-fontified):
(org-looking-at-fontified): Remove org-fold's font-lock logic.
* lisp/org-fold-core.el (org-fold-core-get-regions): New function to
retrieve the list of folded regions in buffer.
(org-fold-core-regions): New function to set folding state in buffer
according to the list returned by `org-fold-core-get-regions'.
(org-fold-core-save-visibility): New macro, equivalent to
`org-fold-save-outline-visibility'.