Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve yank pop #1523

Merged
merged 2 commits into from Apr 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions counsel.el
Expand Up @@ -3255,6 +3255,8 @@ All blank strings are deleted from `kill-ring' by default."
"Return list of kills for `counsel-yank-pop' to complete.
Returned elements satisfy `counsel-yank-pop-filter' and are
unique under `equal-including-properties'."
;; Refresh `kill-ring' in the presence of `interprogram-paste-function'
(current-kill 0)
;; Keep things consistent with the rest of Emacs
(dolist (sym '(kill-ring kill-ring-yank-pointer))
(set sym (cl-delete-duplicates
Expand All @@ -3266,8 +3268,11 @@ unique under `equal-including-properties'."
kill-ring))

(defun counsel-yank-pop-action (s)
"Like `yank-pop', but insert the kill corresponding to S."
"Like `yank-pop', but insert the kill corresponding to S.
Signal a `buffer-read-only' error if called from a read-only
buffer position."
(with-ivy-window
(barf-if-buffer-read-only)
(setq last-command 'yank)
(setq yank-window-start (window-start))
(yank-pop (counsel--yank-pop-position s))
Expand Down Expand Up @@ -3320,7 +3325,8 @@ can be controlled with `counsel-yank-pop-preselect-last', which
see. See also `counsel-yank-pop-filter' for how to filter
candidates.
Note: Duplicate elements of `kill-ring' are always deleted."
(interactive "*P")
;; Do not specify `*' to allow browsing `kill-ring' in read-only buffers
(interactive "P")
(let ((ivy-format-function #'counsel--yank-pop-format-function)
(ivy-height counsel-yank-pop-height)
(kills (counsel--yank-pop-kills)))
Expand Down