diff options
author | Karl Heuer <[email protected]> | 1994-09-15 21:30:21 +0000 |
---|---|---|
committer | Karl Heuer <[email protected]> | 1994-09-15 21:30:21 +0000 |
commit | f914dc91cbd28111a52a42e46b97563a94208e5b (patch) | |
tree | acd5074421b222dc9edb1f2b5f7a7517c6fe7fa5 | |
parent | f2495b93d43488d819f57bd291296f7c4a8b596b (diff) |
(kill-new): New optional argument means replace most recent kill.
(kill-append): Use that new interface.
-rw-r--r-- | lisp/simple.el | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 6bcfd42d46..e05c1e7af8 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -992,13 +992,18 @@ ring directly.") (defvar kill-ring-yank-pointer nil "The tail of the kill ring whose car is the last thing yanked.") -(defun kill-new (string) +(defun kill-new (string &optional replace) "Make STRING the latest kill in the kill ring. Set the kill-ring-yank pointer to point to it. -If `interprogram-cut-function' is non-nil, apply it to STRING." - (setq kill-ring (cons string kill-ring)) - (if (> (length kill-ring) kill-ring-max) - (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil)) +If `interprogram-cut-function' is non-nil, apply it to STRING. +Optional second argument REPLACE non-nil means that STRING will replace +the front of the kill ring, rather than being added to the list." + (menu-bar-update-yank-menu string (and replace (car kill-ring))) + (if replace + (setcar kill-ring string) + (setq kill-ring (cons string kill-ring)) + (if (> (length kill-ring) kill-ring-max) + (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil))) (setq kill-ring-yank-pointer kill-ring) (if interprogram-cut-function (funcall interprogram-cut-function string t))) @@ -1008,12 +1013,9 @@ If `interprogram-cut-function' is non-nil, apply it to STRING." If BEFORE-P is non-nil, prepend STRING to the kill. If `interprogram-cut-function' is set, pass the resulting kill to it." - (setcar kill-ring - (if before-p - (concat string (car kill-ring)) - (concat (car kill-ring) string))) - (if interprogram-cut-function - (funcall interprogram-cut-function (car kill-ring)))) + (kill-new (if before-p + (concat string (car kill-ring)) + (concat (car kill-ring) string)) t)) (defun current-kill (n &optional do-not-move) "Rotate the yanking point by N places, and then return that kill. |