comparison lisp/simple.el @ 104624:eee8a7124ad0

(save-interprogram-paste-before-kill): New user option. (kill-new): When `save-interprogram-paste-before-kill' is non-nil, save the interprogram-paste into kill-ring before overriding it with the Emacs kill.
author Sam Steingold <sds@gnu.org>
date Wed, 26 Aug 2009 20:55:39 +0000
parents 2e9b68642e06
children 2ef67426b537
comparison
equal deleted inserted replaced
104623:f369eb846e57 104624:eee8a7124ad0
2792 :group 'killing) 2792 :group 'killing)
2793 2793
2794 (defvar kill-ring-yank-pointer nil 2794 (defvar kill-ring-yank-pointer nil
2795 "The tail of the kill ring whose car is the last thing yanked.") 2795 "The tail of the kill ring whose car is the last thing yanked.")
2796 2796
2797 (defcustom save-interprogram-paste-before-kill nil
2798 "Save the paste strings into `kill-ring' before replacing it with emacs strings.
2799 When one selects something in another program to paste it into Emacs,
2800 but kills something in Emacs before actually pasting it,
2801 this selection is gone unless this variable is non-nil,
2802 in which case the other program's selection is saved in the `kill-ring'
2803 before the Emacs kill and one can still paste it using \\[yank] \\[yank-pop]."
2804 :type 'boolean
2805 :group 'killing
2806 :version "23.2")
2807
2797 (defun kill-new (string &optional replace yank-handler) 2808 (defun kill-new (string &optional replace yank-handler)
2798 "Make STRING the latest kill in the kill ring. 2809 "Make STRING the latest kill in the kill ring.
2799 Set `kill-ring-yank-pointer' to point to it. 2810 Set `kill-ring-yank-pointer' to point to it.
2800 If `interprogram-cut-function' is non-nil, apply it to STRING. 2811 If `interprogram-cut-function' is non-nil, apply it to STRING.
2801 Optional second argument REPLACE non-nil means that STRING will replace 2812 Optional second argument REPLACE non-nil means that STRING will replace
2803 2814
2804 Optional third arguments YANK-HANDLER controls how the STRING is later 2815 Optional third arguments YANK-HANDLER controls how the STRING is later
2805 inserted into a buffer; see `insert-for-yank' for details. 2816 inserted into a buffer; see `insert-for-yank' for details.
2806 When a yank handler is specified, STRING must be non-empty (the yank 2817 When a yank handler is specified, STRING must be non-empty (the yank
2807 handler, if non-nil, is stored as a `yank-handler' text property on STRING). 2818 handler, if non-nil, is stored as a `yank-handler' text property on STRING).
2819
2820 When `save-interprogram-paste-before-kill' and `interprogram-paste-function'
2821 are non-nil, saves the interprogram paste string(s) into `kill-ring' before
2822 STRING.
2808 2823
2809 When the yank handler has a non-nil PARAM element, the original STRING 2824 When the yank handler has a non-nil PARAM element, the original STRING
2810 argument is not used by `insert-for-yank'. However, since Lisp code 2825 argument is not used by `insert-for-yank'. However, since Lisp code
2811 may access and use elements from the kill ring directly, the STRING 2826 may access and use elements from the kill ring directly, the STRING
2812 argument should still be a \"useful\" string for such uses." 2827 argument should still be a \"useful\" string for such uses."
2817 (if yank-handler 2832 (if yank-handler
2818 (signal 'args-out-of-range 2833 (signal 'args-out-of-range
2819 (list string "yank-handler specified for empty string")))) 2834 (list string "yank-handler specified for empty string"))))
2820 (if (fboundp 'menu-bar-update-yank-menu) 2835 (if (fboundp 'menu-bar-update-yank-menu)
2821 (menu-bar-update-yank-menu string (and replace (car kill-ring)))) 2836 (menu-bar-update-yank-menu string (and replace (car kill-ring))))
2837 (when save-interprogram-paste-before-kill
2838 (let ((interprogram-paste (and interprogram-paste-function
2839 (funcall interprogram-paste-function))))
2840 (when interprogram-paste
2841 (if (listp interprogram-paste)
2842 (dolist (s (nreverse interprogram-paste))
2843 (push s kill-ring))
2844 (push interprogram-paste kill-ring)))))
2822 (if (and replace kill-ring) 2845 (if (and replace kill-ring)
2823 (setcar kill-ring string) 2846 (setcar kill-ring string)
2824 (push string kill-ring) 2847 (push string kill-ring)
2825 (if (> (length kill-ring) kill-ring-max) 2848 (if (> (length kill-ring) kill-ring-max)
2826 (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil))) 2849 (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil)))