forked from mirrors/org-mode
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'.
This commit is contained in:
parent
f2833ff255
commit
57362f7414
|
@ -17522,7 +17522,7 @@ this numeric value."
|
||||||
(interactive "r")
|
(interactive "r")
|
||||||
(let ((result ""))
|
(let ((result ""))
|
||||||
(while (/= beg end)
|
(while (/= beg end)
|
||||||
(if (get-char-property beg 'invisible)
|
(if (invisible-p beg)
|
||||||
(setq beg (next-single-char-property-change beg 'invisible nil end))
|
(setq beg (next-single-char-property-change beg 'invisible nil end))
|
||||||
(let ((next (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 result (concat result (buffer-substring beg next)))
|
||||||
|
|
|
@ -8231,6 +8231,17 @@ CLOSED: %s
|
||||||
(equal "ab"
|
(equal "ab"
|
||||||
(org-test-with-temp-text
|
(org-test-with-temp-text
|
||||||
#("aXXb" 1 2 (invisible t) 2 3 (invisible org-link))
|
#("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))
|
(let ((kill-ring nil))
|
||||||
(org-copy-visible (point-min) (point-max))
|
(org-copy-visible (point-min) (point-max))
|
||||||
(current-kill 0 t)))))))
|
(current-kill 0 t)))))))
|
||||||
|
|
Loading…
Reference in New Issue