Function: ghostel-yank-pop

ghostel-yank-pop is an interactive and natively compiled function defined in ghostel.el.

Signature

(ghostel-yank-pop)

Documentation

Replace the just-yanked text with the next kill ring entry.

After ghostel-yank or ghostel-yank-pop, cycles through the kill ring by erasing the previous paste and inserting the next entry. Otherwise, browses kill-ring with read-from-kill-ring and pastes the selected entry into the terminal.

Key Bindings

ghostel-semi-char-mode-map M-y

Source Code

;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel-yank-pop ()
  "Replace the just-yanked text with the next kill ring entry.
After `ghostel-yank' or `ghostel-yank-pop', cycles through the
kill ring by erasing the previous paste and inserting the next entry.
Otherwise, browses `kill-ring' with `read-from-kill-ring' and
pastes the selected entry into the terminal."
  (interactive)
  (if (memq last-command '(ghostel-yank ghostel-yank-pop))
      (let* ((prev-text (current-kill ghostel--yank-index t))
             (prev-len (length prev-text)))
        (setq ghostel--yank-index (1+ ghostel--yank-index))
        (ghostel--on-user-input)
        ;; Erase previous paste: send backspaces
        (ghostel--write-pty ghostel--term
                            (make-string prev-len ?\x7f))
        ;; Paste the next entry
        (ghostel--paste-text (current-kill ghostel--yank-index t))
        (setq this-command 'ghostel-yank-pop))
    ;; No preceding yank: browse kill ring and paste selection
    (let ((text (read-from-kill-ring "Paste from kill ring: ")))
      (unless (string-empty-p text)
        (ghostel--on-user-input)
        (ghostel--paste-text text)))))