From 57362f741492253782e585901d82eedc0da23064 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 27 Feb 2022 23:31:49 -0500 Subject: [PATCH] org-copy-visible: Respect buffer-invisibility-spec * lisp/org.el (org-copy-visible): Decide whether text is invisible by calling invisible-p rather than checking whether the invisible property at point is non-nil. Text may have a non-nil invisible property but _not_ be hidden from the user (and thus should be copied by org-copy-visible). For example, the link itself is shown when org-link-descriptive is nil, but it still has an invisible property of `org-link'. --- lisp/org.el | 2 +- testing/lisp/test-org.el | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 4fcc2cd90..d656a5159 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -17522,7 +17522,7 @@ this numeric value." (interactive "r") (let ((result "")) (while (/= beg end) - (if (get-char-property beg 'invisible) + (if (invisible-p beg) (setq beg (next-single-char-property-change beg 'invisible nil end)) (let ((next (next-single-char-property-change beg 'invisible nil end))) (setq result (concat result (buffer-substring beg next))) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 6e6a1f852..d552474e2 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -8231,6 +8231,17 @@ CLOSED: %s (equal "ab" (org-test-with-temp-text #("aXXb" 1 2 (invisible t) 2 3 (invisible org-link)) + (let ((kill-ring nil)) + (org-copy-visible (point-min) (point-max)) + (current-kill 0 t))))) + ;; Copies text based on what's actually visible, as defined by + ;; `buffer-invisibility-spec'. + (should + (equal "aYb" + (org-test-with-temp-text + #("aXYb" + 1 2 (invisible t) + 2 3 (invisible org-test-copy-visible)) (let ((kill-ring nil)) (org-copy-visible (point-min) (point-max)) (current-kill 0 t)))))))