previous kills, offering completion and minibuffer-history navigation
through previous kills recorded in the kill ring. A similar feature
in Isearch can be invoked if you bind 'C-s M-y' to the command
-'isearch-yank-pop'.
+'isearch-yank-pop'. When the user option 'yank-from-kill-ring-rotate'
+is nil the kill ring is not rotated after 'yank-from-kill-ring'.
---
** New user options 'copy-region-blink-delay' and 'delete-pair-blink-delay'.
;; `current-kill' updates `kill-ring' with a possible interprogram-paste
(current-kill 0)
(let* ((history-add-new-input nil)
+ (history-pos (when yank-from-kill-ring-rotate
+ (- (length kill-ring)
+ (length kill-ring-yank-pointer))))
(ellipsis (if (char-displayable-p ?…) "…" "..."))
;; Remove keymaps from text properties of copied string,
;; because typing RET in the minibuffer might call
'(metadata (display-sort-function . identity))
(complete-with-action action completions string pred)))
nil nil nil
- 'read-from-kill-ring-history))))
+ (if history-pos
+ (cons 'read-from-kill-ring-history history-pos)
+ 'read-from-kill-ring-history)))))
+
+(defcustom yank-from-kill-ring-rotate t
+ "Whether using `yank-from-kill-ring' should rotate `kill-ring-yank-pointer'.
+If non-nil, the kill ring is rotated after selecting previously killed text."
+ :type 'boolean
+ :group 'killing
+ :version "28.1")
(defun yank-from-kill-ring (string &optional arg)
"Select a stretch of previously killed text and insert (\"paste\") it.
When called from Lisp, insert STRING like `insert-for-yank' does."
(interactive (list (read-from-kill-ring "Yank from kill-ring: ")
current-prefix-arg))
+ (setq yank-window-start (window-start))
(push-mark)
(insert-for-yank string)
+ (when yank-from-kill-ring-rotate
+ (let ((pos (seq-position kill-ring string)))
+ (setq kill-ring-yank-pointer
+ (or (and pos (nthcdr (1+ pos) kill-ring))
+ kill-ring))))
(if (consp arg)
- ;; Swap point and mark like in `yank'.
+ ;; Swap point and mark like in `yank' and `yank-pop'.
(goto-char (prog1 (mark t)
(set-marker (mark-marker) (point) (current-buffer))))))
+
\f
;; Some kill commands.