comparison lisp/simple.el @ 104645:2ef67426b537

(kill-do-not-save-duplicates): New user option. (kill-new): When it is non-nil, and the new string is the same as the latest kill, set replace to t to avoid duplicates in kill-ring.
author Sam Steingold <sds@gnu.org>
date Thu, 27 Aug 2009 14:56:17 +0000
parents eee8a7124ad0
children 50fdf250e26b
comparison
equal deleted inserted replaced
104644:5890929d6c1d 104645:2ef67426b537
2803 before the Emacs kill and one can still paste it using \\[yank] \\[yank-pop]." 2803 before the Emacs kill and one can still paste it using \\[yank] \\[yank-pop]."
2804 :type 'boolean 2804 :type 'boolean
2805 :group 'killing 2805 :group 'killing
2806 :version "23.2") 2806 :version "23.2")
2807 2807
2808 (defcustom kill-do-not-save-duplicates nil
2809 "Do not add a new string to `kill-ring' when it is the same as the last one."
2810 :type 'boolean
2811 :group 'killing
2812 :version "23.2")
2813
2808 (defun kill-new (string &optional replace yank-handler) 2814 (defun kill-new (string &optional replace yank-handler)
2809 "Make STRING the latest kill in the kill ring. 2815 "Make STRING the latest kill in the kill ring.
2810 Set `kill-ring-yank-pointer' to point to it. 2816 Set `kill-ring-yank-pointer' to point to it.
2811 If `interprogram-cut-function' is non-nil, apply it to STRING. 2817 If `interprogram-cut-function' is non-nil, apply it to STRING.
2812 Optional second argument REPLACE non-nil means that STRING will replace 2818 Optional second argument REPLACE non-nil means that STRING will replace
2830 (put-text-property 0 (length string) 2836 (put-text-property 0 (length string)
2831 'yank-handler yank-handler string)) 2837 'yank-handler yank-handler string))
2832 (if yank-handler 2838 (if yank-handler
2833 (signal 'args-out-of-range 2839 (signal 'args-out-of-range
2834 (list string "yank-handler specified for empty string")))) 2840 (list string "yank-handler specified for empty string"))))
2841 (when (and kill-do-not-save-duplicates
2842 (equal string (car kill-ring)))
2843 (setq replace t))
2835 (if (fboundp 'menu-bar-update-yank-menu) 2844 (if (fboundp 'menu-bar-update-yank-menu)
2836 (menu-bar-update-yank-menu string (and replace (car kill-ring)))) 2845 (menu-bar-update-yank-menu string (and replace (car kill-ring))))
2837 (when save-interprogram-paste-before-kill 2846 (when save-interprogram-paste-before-kill
2838 (let ((interprogram-paste (and interprogram-paste-function 2847 (let ((interprogram-paste (and interprogram-paste-function
2839 (funcall interprogram-paste-function)))) 2848 (funcall interprogram-paste-function))))