@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
** 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.
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")
(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)