org-fold: Honor :extend face property in folded headings/blocks/drawers

* 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
This commit is contained in:
Ihor Radchenko 2024-01-22 15:37:24 +01:00
parent dd4fd02995
commit 2ade16bbc2
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 20 additions and 0 deletions

View File

@ -13,6 +13,14 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
* Version 9.7 (not released yet)
** Important announcements and breaking changes
*** Folded lines can now extend their face beyond ellipsis
Previously, ~:extend t~ face attribute did not make folded headlines,
blocks, and drawers extend their face beyond end of line.
Now, the ellipsis and trailing newline use the same face as the last
character before the fold.
*** ~org-agenda-search-headline-for-time~ now ignores all the timestamp in headings
Previously, ~org-agenda-search-headline-for-time~ made Org agenda

View File

@ -1033,6 +1033,18 @@ If SPEC-OR-ALIAS is omitted and FLAG is nil, unfold everything in the region."
(when spec (org-fold-core--check-spec spec))
(with-silent-modifications
(org-with-wide-buffer
;; Arrange face property of newlines after all the folds
;; between FROM and TO to match the first character before the
;; fold; not the last as per Emacs defaults. This makes
;; :extend faces span past the ellipsis.
;; See bug#65896.
(if flag ; folding
(when (equal ?\n (char-after to))
(put-text-property to (1+ to) 'face (get-text-property from 'face)))
;; unfolding
(dolist (region (org-fold-core-get-regions :from from :to to :specs spec))
(when (equal ?\n (char-after (cadr region)))
(font-lock-flush (cadr region) (1+ (cadr region))))))
(when (eq org-fold-core-style 'overlays)
(if org-fold-core--keep-overlays
(mapc