1

I would like to use the classic emacs yank-pop instead of counsel mode's counsel-yank-pop which is linked to M-y. I've tried unbinding and rebinding it, but it does not seem to work.

I setup counsel using the following code:

(use-package counsel
  :bind (("C-x C-f" . counsel-find-file)
         ("C-c s"   . counsel-recentf)
         ("C-c C-s" . counsel-locate)
         ("C-c S"   . counsel-ack)
         :map minibuffer-local-map
         ("C-r" . counsel-minibuffer-history))
  :custom
  (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
  :config
  (counsel-mode 1))

At this point, if I describe-variable counsel-mode-map, I can see that the binding M-y counsel-yank-pop exists. Also, if I run helpful-key I can see the same. However, I am unable to change the binding to yank-pop. I've tried:

(global-unset-key (kbd "M-y"))
(local-unset-key (kbd "M-y"))
(unbind-key "M-y" counsel-mode-map)

However, as soon as I try to rebind to yank-pop the binding goes back to counsel-yank-pop:

(global-set-key (kbd "M-y") 'yank-pop)

What am I doing wrong?

1 Answer 1

1

Looks like the answer might be to remove enable counsel-mode in use-package and set the keybinding globally.

(global-set-key (kbd "M-y") 'yank-pop)

(use-package counsel
  :bind (("C-x C-f" . counsel-find-file)
         ("C-c s"   . counsel-recentf)
         ("C-c C-s" . counsel-locate)
         ("C-c S"   . counsel-ack)
         :map minibuffer-local-map
         ("C-r" . counsel-minibuffer-history))
  :custom
  (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only))
2
  • FYI - You can accept your answer, if you like.
    – Drew
    Jul 25, 2023 at 14:47
  • Not yet :/ 23 more hours to go.
    – oneself
    Jul 26, 2023 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.