]> git.eshelyaron.com Git - emacs.git/commitdiff
(yank-pop-change-selection): New option.
authorRichard M. Stallman <rms@gnu.org>
Tue, 25 Dec 2007 20:19:13 +0000 (20:19 +0000)
committerRichard M. Stallman <rms@gnu.org>
Tue, 25 Dec 2007 20:19:13 +0000 (20:19 +0000)
(current-kill): Obey it.

etc/NEWS
lisp/ChangeLog
lisp/simple.el

index f23204c1cd5c75dd872902c7a65c71a0e346040a..56ddf7531ce4b129e64b5d1133705cdf0ca3922b 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -165,6 +165,10 @@ makes the new region into the primary selection (for interaction with
 other window applications).  If you enable this, you might want to bind
 `mouse-yank-primary' to Mouse-2.
 
+** If `yank-pop-change-selection' is t, rotating the kill ring
+also updates the selection or clipboard to the current yank,
+just as M-w would do so with the text it copies to the kill ring.
+
 ** Minibuffer changes:
 
 *** In C-x d, if you type M-n you get the visited file name of the
index 27a302d7d015bb403339260d2601a0543b963fec..0c80dccccf1306f9c9f80612bacc64bac423af9c 100644 (file)
@@ -2,6 +2,8 @@
 
        * simple.el (select-active-regions): New option.
        (set-mark): Obey it.
+       (yank-pop-change-selection): New option.
+       (current-kill): Obey it.
 
 2007-12-25  David Golden  <david.delaharpe.golden@gmail.com>  (tiny change)
 
index f4a5b51a68cd580aa3f759e81502af67fd43cd6a..3a17af8a3d3dedf69dc6a2fb824a6e217f0a04da 100644 (file)
@@ -2659,13 +2659,26 @@ If `interprogram-cut-function' is set, pass the resulting kill to it."
                  (equal yank-handler (get-text-property 0 'yank-handler cur)))
              yank-handler)))
 
+(defcustom yank-pop-change-selection nil
+  "If non-nil, rotating the kill ring changes the window system selection."
+  :type 'boolean
+  :group 'killing
+  :version "23.1")
+
 (defun current-kill (n &optional do-not-move)
   "Rotate the yanking point by N places, and then return that kill.
 If N is zero, `interprogram-paste-function' is set, and calling it returns a
 string or list of strings, then that string (or list) is added to the front
 of the kill ring and the string (or first string in the list) is returned as
-the latest kill.  If optional arg DO-NOT-MOVE is non-nil, then don't
-actually move the yanking point; just return the Nth kill forward."
+the latest kill.
+
+If N is not zero, and if `yank-pop-change-selection' is
+non-nil, use `interprogram-cut-function' to transfer the
+kill at the new yank point into the window system selection.
+
+If optional arg DO-NOT-MOVE is non-nil, then don't actually
+move the yanking point; just return the Nth kill forward."
+
   (let ((interprogram-paste (and (= n 0)
                                 interprogram-paste-function
                                 (funcall interprogram-paste-function))))
@@ -2684,8 +2697,12 @@ actually move the yanking point; just return the Nth kill forward."
             (nthcdr (mod (- n (length kill-ring-yank-pointer))
                          (length kill-ring))
                     kill-ring)))
-       (or do-not-move
-           (setq kill-ring-yank-pointer ARGth-kill-element))
+       (unless do-not-move
+         (setq kill-ring-yank-pointer ARGth-kill-element)
+         (when (and yank-pop-change-selection
+                    (> n 0)
+                    interprogram-cut-function)
+           (funcall interprogram-cut-function (car ARGth-kill-element))))
        (car ARGth-kill-element)))))