Commit 407062c2 authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen
Browse files

Allow save-interprogram-paste-before-kill to be a number

* doc/emacs/killing.texi (Clipboard): Document it.
* lisp/simple.el (save-interprogram-paste-before-kill): Extend
range (bug#41168).
(kill-new): Implement it (bug#41168).
parent dc471fee
Pipeline #11071 failed with stages
in 182 minutes and 36 seconds
......@@ -522,11 +522,14 @@ clipboard.
@vindex save-interprogram-paste-before-kill
When an Emacs kill command puts text in the clipboard, the existing
clipboard contents are normally lost. Optionally, you can change
@code{save-interprogram-paste-before-kill} to @code{t}. Then Emacs
will first save the clipboard to its kill ring, preventing you from
losing the old clipboard data---at the risk of high memory consumption
if that data turns out to be large.
clipboard contents are normally lost. Optionally, Emacs can save the
existing clipboard contents to the kill ring, preventing you from
losing the old clipboard data. If
@code{save-interprogram-paste-before-kill} changed to a number, then
this data is copied over if it's smaller (in characters) than this
number. If this variable is any other non-@code{nil} value, it's
always copied over---at the risk of high memory consumption if that
data turns out to be large.
Yank commands, such as @kbd{C-y} (@code{yank}), also use the
clipboard. If another application ``owns'' the clipboard---i.e., if
......
......@@ -2087,6 +2087,11 @@ Shift while typing 'C-a', i.e. 'C-S-a', will now highlight the text.
** Miscellaneous
+++
*** 'save-interprogram-paste-before-kill' can now be a number.
In that case, it's interpreted as a limit to how long the clipboard
data can be before saving to the kill ring.
---
*** New variable 'hl-line-overlay-priority'.
This can be used to change the priority of the hl-line overlays.
......
......@@ -5041,8 +5041,14 @@ ring directly.")
A non-nil value ensures that Emacs kill operations do not
irrevocably overwrite existing clipboard text by saving it to the
`kill-ring' prior to the kill. Such text can subsequently be
retrieved via \\[yank] \\[yank-pop]."
:type 'boolean
retrieved via \\[yank] \\[yank-pop].
This variable can be either a number (in which case the clipboard
data is only saved if it's shorter (in characters) than that
number. Any other non-nil value will save the clipboard data
unconditionally."
:type '(choice (const :tag "Always" t)
number)
:group 'killing
:version "23.2")
......@@ -5079,13 +5085,18 @@ argument should still be a \"useful\" string for such uses."
(let ((interprogram-paste (and interprogram-paste-function
(funcall interprogram-paste-function))))
(when interprogram-paste
(dolist (s (if (listp interprogram-paste)
;; Use `reverse' to avoid modifying external data.
(reverse interprogram-paste)
(list interprogram-paste)))
(unless (and kill-do-not-save-duplicates
(equal-including-properties s (car kill-ring)))
(push s kill-ring))))))
(setq interprogram-paste
(if (listp interprogram-paste)
;; Use `reverse' to avoid modifying external data.
(reverse interprogram-paste)
(list interprogram-paste)))
(when (or (not (numberp save-interprogram-paste-before-kill))
(< (seq-reduce #'+ (mapcar #'length interprogram-paste) 0)
save-interprogram-paste-before-kill))
(dolist (s interprogram-paste)
(unless (and kill-do-not-save-duplicates
(equal-including-properties s (car kill-ring)))
(push s kill-ring)))))))
(unless (and kill-do-not-save-duplicates
(equal-including-properties string (car kill-ring)))
(if (and replace kill-ring)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment