0

I would like to prevent modes to add any custom keys to emacs.

For example this works for default key map:

(global-set-key (kbd "C-c") nil)

And this works for ensime:

(eval-after-load "ensime-mode"
  '(define-key ensime-mode-map (kbd "C-c") nil))

But same doesn't work for yas:

(eval-after-load "yas-minor-mode"
  '(define-key yas-minor-mode-map (kbd "C-c") nil))

So in the end it looks for me like this:

enter image description here

Is it possible to remove all keys from packages/modes?

  • 2
    Please clarify what you mean by "doesn't work for yas" (is the picture supposed to exhibit the problem with yas? I don't see what makes you think yas is the culprit there). Also I suspect that it might be much easier to fix your underlying problem in a different way, so you should probably explain a bit what you're really trying to achieve. – Stefan Dec 11 '18 at 17:11
  • @Stefan I mean I still have map available from github.com/joaotavora/yasnippet/blob/master/yasnippet.el#L654 when I press C-c. – droptheplot Dec 11 '18 at 17:21
4

The function yas-minor-mode is not defined in a file named yas-minor-mode.el but in the file named yasnippet.el so you need

(eval-after-load "yasnippet"
  '(define-key yas-minor-mode-map (kbd "C-c") nil))

You can also use

(eval-after-load 'yasnippet
  '(define-key yas-minor-mode-map (kbd "C-c") nil))

or

(add-hook 'yas-minor-mode-hook
          (lambda ()
            (define-key yas-minor-mode-map (kbd "C-c") nil)))
  • I thought first argument is a mode/package name, thanks! – droptheplot Dec 11 '18 at 19:11
  • 1
    It's a package name yes, but not a mode name. – Stefan Dec 11 '18 at 20:03

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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