[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals-release/org f2833ff255 2/4: org-copy-visible: Fix handl
From: |
ELPA Syncer |
Subject: |
[elpa] externals-release/org f2833ff255 2/4: org-copy-visible: Fix handling of adjacent invisible text |
Date: |
Sun, 27 Feb 2022 23:57:40 -0500 (EST) |
branch: externals-release/org
commit f2833ff25508d49845a2bdb4c4e6d7b7ec062ce5
Author: Kyle Meyer <kyle@kyleam.com>
Commit: Kyle Meyer <kyle@kyleam.com>
org-copy-visible: Fix handling of adjacent invisible text
* lisp/org.el (org-copy-visible): Don't copy invisible text that
follows invisible text with a different property value.
If org-copy-visible sees that the left bound position has a non-nil
invisible property, it uses next-single-char-property-change to find
the new bound. However, next-single-char-property-change may just
find a bound that still has a _different_ non-nil invisible property.
Reported-by: "Максим Бабушкин" <maxbabushkin@gmail.com>
Link: https://debbugs.gnu.org/49967
---
lisp/org.el | 10 +++++-----
testing/lisp/test-org.el | 8 ++++++++
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 7ea8d65f3b..4fcc2cd900 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17522,11 +17522,11 @@ this numeric value."
(interactive "r")
(let ((result ""))
(while (/= beg end)
- (when (get-char-property beg 'invisible)
- (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)))
- (setq beg next)))
+ (if (get-char-property beg 'invisible)
+ (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)))
+ (setq beg next))))
(setq deactivate-mark t)
(kill-new result)
(message "Visible strings have been copied to the kill ring.")))
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 57daf4eeb1..6e6a1f8520 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -8223,6 +8223,14 @@ CLOSED: %s
(equal "abc"
(org-test-with-temp-text
#("aXbXc" 1 2 (invisible t) 3 4 (invisible t))
+ (let ((kill-ring nil))
+ (org-copy-visible (point-min) (point-max))
+ (current-kill 0 t)))))
+ ;; Handle adjacent invisible parts.
+ (should
+ (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)))))))