ergoemacs / ergoemacs-mode

ergoemacs-mode
ergoemacs.github.io/
GNU General Public License v3.0
293 stars 35 forks source link

Can't unbind a key in ergoemacs #526

Closed ceridwen closed 1 month ago

ceridwen commented 1 month ago

I want to get rid of the print interface bound to C-p.

I've tried:

(global-set-key (kbd "C-p") nil)
(define-key ergoemacs-user-keymap (kbd "C-p") nil)
(ergoemacs-define-key ergoemacs-user-keymap (kbd "C-p") nil)

None of these unbind the key, the print interface still comes up.

I accompanied the global-set-key with (setq ergoemacs-ignore-prev-global 1). (ergoemacs-ignore-prev-global) by itself in my .emacs causes an error, so I tried the next logical thing.

This used to work, and I'm not exactly sure when it broke. Maybe with the major rewrite? Is there a working way to unbind keys altogether?

mattfidler commented 1 month ago

You can do the folowing:

 (define-key ergoemacs-user-keymap (kbd "C-p") 'undefined)
mattfidler commented 1 month ago

I have added this to the readme.

The major rewrite was to remove many of the specific changes that made the defining to a global map be intercepted and "do the right thing". It turned out to be fragile and brittle, so I changed back to using more of regular emacs keymaps.

Therefore binding a key as nil will ignore whatever was bound in the current map and find the next key in the list of maps that are queried.

In emacs defining a key as nil will skip the currently bound map and go to the next map. If you are trying to override the behavior you simply skip to the final function that emacs calls. In this case it will look up the key in ergoemacs-override-keymap

mattfidler commented 1 month ago

If you want to use emacs keys instead of unbinding the key, you can also use:

 (define-key ergoemacs-override-keymap (kbd "C-p") nil)
mattfidler commented 1 month ago

Hopefully, this answers your questions.