# HG changeset patch # User Sam Steingold # Date 1251384977 0 # Node ID 2ef67426b537e43ce2478cd79c1040d782fe71c9 # Parent 5890929d6c1dc40895cefd18eccc4843577cbb5e (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. diff -r 5890929d6c1d -r 2ef67426b537 lisp/ChangeLog --- a/lisp/ChangeLog Thu Aug 27 13:50:59 2009 +0000 +++ b/lisp/ChangeLog Thu Aug 27 14:56:17 2009 +0000 @@ -1,3 +1,9 @@ +2009-08-27 Sam Steingold + + * simple.el (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. + 2009-08-19 Julian Scheid (tiny change) * net/tramp.el (tramp-handle-process-file): Do not flush all diff -r 5890929d6c1d -r 2ef67426b537 lisp/simple.el --- a/lisp/simple.el Thu Aug 27 13:50:59 2009 +0000 +++ b/lisp/simple.el Thu Aug 27 14:56:17 2009 +0000 @@ -2805,6 +2805,12 @@ :group 'killing :version "23.2") +(defcustom kill-do-not-save-duplicates nil + "Do not add a new string to `kill-ring' when it is the same as the last one." + :type 'boolean + :group 'killing + :version "23.2") + (defun kill-new (string &optional replace yank-handler) "Make STRING the latest kill in the kill ring. Set `kill-ring-yank-pointer' to point to it. @@ -2832,6 +2838,9 @@ (if yank-handler (signal 'args-out-of-range (list string "yank-handler specified for empty string")))) + (when (and kill-do-not-save-duplicates + (equal string (car kill-ring))) + (setq replace t)) (if (fboundp 'menu-bar-update-yank-menu) (menu-bar-update-yank-menu string (and replace (car kill-ring)))) (when save-interprogram-paste-before-kill