Malabarba / names

A Namespace implementation for Emacs-Lisp
250 stars 19 forks source link

Loading or compiling names.el fails if you have redefined C-x #7

Closed davidshepherd7 closed 9 years ago

davidshepherd7 commented 9 years ago

I've had some issues with aggressive-indent which I think is due to edebug. However since this problem is only likely to occur for non-developers when they use names I figured I should report the problem and my workaround here.

The problem is that if you have redefined C-x then loading names.el will fail with the error message

Key sequence C-x X starts with non-prefix key C-x

To reproduce it you can run:

(global-set-key (kbd "C-\\") ctl-x-map)
(global-set-key (kbd "C-x") 'kill-line)
(load-file "names/names.el")

in a fresh emacs -Q.

The issue appears to be that edebug trys to bind C-x X, which obviously it can't do if C-x is not a prefix key (and packages are not supposed to mess with the C-x keymap right?).

The workaround is to (require 'edebug) before doing any key binding.

I'll leave it up to you to decide if this is really a bug in edebug, or just a quirk of the implementation. Either way I hope this information is useful for other users.

davidshepherd7 commented 9 years ago

Actually the workaround doesn't entirely solve the issue, edebug still stomps my keybindings. A better way is to set

(setq edebug-inhibit-emacs-lisp-mode-bindings 't)

before anything that requires names (or edebug) this seems to disable all the keybinding changes, including some weird key translation stuff that edebug does.

Malabarba commented 9 years ago

Ok, thanks for reporting that. I'll have to look into how to patch it.

Edebug maps key in two different places:

(unless edebug-inhibit-emacs-lisp-mode-bindings (define-key emacs-lisp-mode-map "\C-x\C-a\C-s" 'edebug-step-mode) (define-key emacs-lisp-mode-map "\C-x\C-a\C-n" 'edebug-next-mode) (define-key emacs-lisp-mode-map "\C-x\C-a\C-c" 'edebug-go-mode) (define-key emacs-lisp-mode-map "\C-x\C-a\C-l" 'edebug-where))

(defvar global-edebug-prefix "^XX" "Prefix key for global edebug commands, available from any buffer.")

(global-set-key global-edebug-prefix global-edebug-map)

For now, I can offer you the following workaround:

  1. Set edebug-inhibit-emacs-lisp-mode-bindings to t (which you've figured out already).
  2. Set global-edebug-prefix to a valid prefix.
Malabarba commented 9 years ago

Ok, I think I've fixed this bug. It should be on the latest Melpa and GNU Elpa versions. Let me know how it goes.

davidshepherd7 commented 9 years ago

Great, thanks! I'll give it a try when I get the chance.