5

I've become accustomed to using C-x p for switching to the previous window.

And, I recently had to start including a company-wide startup.el file that defines the prefix C-x p-. I don't use any of the C-x p- shortcuts.

Is there a way that I can undefine the C-x p- prefix after it's been defined?

Kennet Belenky
  • 211
  • 1
  • 4
  • 2
    Find out what keymap it is defined in, and then `(define-key THAT-MAP "\C-xp" nil)`. – Drew Nov 18 '14 at 20:30
  • http://emacs.stackexchange.com/questions/2150/the-c-x-c-j-binding-for-dired-jump-stopped-working/2155#2155 looks like it might be what you're looking for, but I'm not entirely sure. If it is, we can mark your question as a duplicate which helps consolidate answers and improves search results. – Tikhon Jelvis Nov 18 '14 at 20:41
  • 1
    What is the exact `define-prefix-command` call being used to define this prefix key? It would be helpful if you could give an example of what the prefix-key is and how it is being defined. The description [here](http://www.gnu.org/software/emacs/manual/html_node/elisp/Prefix-Keys.html) shows the prefix key being bound to a keymap. So, you would simply need to unset that keybinding. – Pradhan Nov 18 '14 at 20:56
  • For example, with the default emacs configuration, `(key-binding (kbd "C-x"))` will say something like `(keymap Control-X-prefix)`. To make `C-x` the prefix for your own set of bindings, you would simply rebind the key `C-x` to your keymap. – Pradhan Nov 18 '14 at 20:59

3 Answers3

6

I found a solution:

(global-unset-key (kbd "C-x p-"))

I can't find documentation of this anywhere, so I"m not sure if it works by coincidence or by design. However, the reproducible effect is that it disables the keymap and allows me to redefine "C-x p".

programking
  • 7,064
  • 9
  • 41
  • 62
Kennet Belenky
  • 211
  • 1
  • 4
2

From gnu.org:

M-x local-unset-key <RET> key

Make key undefined locally (in the major mode now in effect).

So you can use

(local-unset-key (kbd "C-x p-"))
nicael
  • 1,598
  • 2
  • 13
  • 20
0

Following only work in emacs 25.3.1:

(local-unset-key (kbd "C-x p"))
Drew
  • 75,699
  • 9
  • 109
  • 225
zw963
  • 151
  • 3