summaryrefslogtreecommitdiff
path: root/lisp/select.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/select.el')
-rw-r--r--lisp/select.el15
1 files changed, 14 insertions, 1 deletions
diff --git a/lisp/select.el b/lisp/select.el
index 1f5191e86c1..5abbf8f795d 100644
--- a/lisp/select.el
+++ b/lisp/select.el
@@ -289,7 +289,9 @@ two markers or an overlay. Otherwise, it is nil."
(defun xselect-convert-to-targets (_selection _type _value)
;; return a vector of atoms, but remove duplicates first.
- (let* ((all (cons 'TIMESTAMP (mapcar 'car selection-converter-alist)))
+ (let* ((all (cons 'TIMESTAMP
+ (cons 'MULTIPLE
+ (mapcar 'car selection-converter-alist))))
(rest all))
(while rest
(cond ((memq (car rest) (cdr rest))
@@ -365,6 +367,12 @@ This function returns the string \"emacs\"."
(defun xselect-convert-to-identity (_selection _type value) ; used internally
(vector value))
+;; Null target that tells clipboard managers we support SAVE_TARGETS
+;; (see freedesktop.org Clipboard Manager spec).
+(defun xselect-convert-to-save-targets (selection _type _value)
+ (when (eq selection 'CLIPBOARD)
+ 'NULL))
+
(setq selection-converter-alist
'((TEXT . xselect-convert-to-string)
(COMPOUND_TEXT . xselect-convert-to-string)
@@ -384,8 +392,13 @@ This function returns the string \"emacs\"."
(NAME . xselect-convert-to-name)
(ATOM . xselect-convert-to-atom)
(INTEGER . xselect-convert-to-integer)
+ (SAVE_TARGETS . xselect-convert-to-save-targets)
(_EMACS_INTERNAL . xselect-convert-to-identity)))
+(when (fboundp 'x-clipboard-manager-save)
+ (add-hook 'delete-frame-functions 'x-clipboard-manager-save)
+ (add-hook 'kill-emacs-hook 'x-clipboard-manager-save))
+
(provide 'select)
;;; select.el ends here