* lisp/simple.el (yank-from-kill-ring-rotate): New defcustom (bug#48478).
(read-from-kill-ring, yank-from-kill-ring): Use it.
This commit is contained in:
parent
171dbe7048
commit
1f0f922ef2
2 changed files with 23 additions and 3 deletions
3
etc/NEWS
3
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'.
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue