Skip to content

Commit

Permalink
org-copy-visible: Prevent Emacs storing primary-selection in kill-ring
Browse files Browse the repository at this point in the history
* lisp/org.el (org-copy-visible): Make sure that the visible text is
the first entry in `kill-ring' upon exiting `org-copy-visible'.  This
was previously not the case when `select-enable-primary' is non-nil.

The fix only works in Emacs 29 after
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=0ab572d5c991dee4818d364a65e004d20f1f45a1
See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57147

Fixes https://orgmode.org/list/25331.25617.528381.574211@gargle.gargle.HOWL
  • Loading branch information
yantar92 committed Aug 13, 2022
1 parent 6ad65f3 commit edf4642
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lisp/org.el
Original file line number Diff line number Diff line change
Expand Up @@ -16972,7 +16972,10 @@ this numeric value."
(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)
;; Prevent Emacs from adding full selected text to `kill-ring'
;; when `select-enable-primary' is non-nil. This special value of
;; `deactivate-mark' only works since Emacs 29.
(setq deactivate-mark 'dont-save)
(kill-new result)
(message "Visible strings have been copied to the kill ring.")))

Expand Down

0 comments on commit edf4642

Please sign in to comment.