[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 1f0f922: * lisp/simple.el (yank-from-kill-ring-rotate): New defcu
From: |
Juri Linkov |
Subject: |
master 1f0f922: * lisp/simple.el (yank-from-kill-ring-rotate): New defcustom (bug#48478). |
Date: |
Wed, 19 May 2021 12:30:54 -0400 (EDT) |
branch: master
commit 1f0f922ef279e29bc91642f4e8ff2b552064d07f
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
* lisp/simple.el (yank-from-kill-ring-rotate): New defcustom (bug#48478).
(read-from-kill-ring, yank-from-kill-ring): Use it.
---
etc/NEWS | 3 ++-
lisp/simple.el | 23 +++++++++++++++++++++--
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 8bbb972..32d7c4f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -340,7 +340,8 @@ When invoked like that, it prompts in the minibuffer for
one of the
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'.
diff --git a/lisp/simple.el b/lisp/simple.el
index 2d9b7dd..8697eed 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -5683,6 +5683,9 @@ PROMPT is a string to prompt with."
;; `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
@@ -5730,7 +5733,16 @@ PROMPT is a string to prompt with."
'(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.
@@ -5755,12 +5767,19 @@ beginning of the inserted text and mark at the end,
like `yank' does.
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))))))
+
;; Some kill commands.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 1f0f922: * lisp/simple.el (yank-from-kill-ring-rotate): New defcustom (bug#48478).,
Juri Linkov <=