1

In a library I use a prefix key defined like this:

(defcustom ensime-mode-key-prefix [?\C-c]
  "The prefix key for ensime-mode commands."
  :group 'ensime-mode
  :type 'sexp)

In my config file I've redefined it like the following:

(setq ensime-mode-key-prefix [?\C-c ?e])

Even though this has changed the prefix, all commands refuse to work with this error:

Symbol's function definition is void: ensime-mode-key-prefix

I've also tried to set it this way:

(customize-set-value 'ensime-mode-key-prefix [?\C-c ?e])

It also doesn't work, but with a different message - C-c e is undefined, which is strange cause in description it's set:

ensime-mode-key-prefix is a variable defined in `ensime-vars.el'.
Its value is [3 101]
Original value was [3]

I want to change the prefix to C-c e, tried to do that with std kbd, but that didn't help.

  • Sounds like an ensime bug. – Malabarba Nov 17 '14 at 18:10
  • Have you tried using Customize, or the equivalent (customize-set-value 'ensime-mode-key-prefix ...) in your init file? I've seen load order issues trying to change default prefix keys for other modes. – glucas Nov 17 '14 at 23:13
  • The error makes me wonder if this is connected with the ability to specify prefix keymaps in function slots (but without seeing the code it's impossible to tell). – phils Nov 18 '14 at 5:39
  • @phils I've add the link and made a little update – 4lex1v Nov 18 '14 at 5:49
  • Try customize-set-variable, not customize-set-value. The former uses the custom-set property, if any, for the option; the latter does not. grep for that variable in the source code, to see where it is handled. The defcustom apparently does not have a :set form, but there might be some code somewhere in the library that does handle setting the value. – Drew Apr 26 '15 at 3:29
2

The problem is that by changing the value of ensime-mode-key-prefix you are doing just that and nothing else. Somewhere after the definition of this option there is code which uses the value. If you haven't changed it then the default value is used, else the value you picked.

But if you change the value after the library has already been loaded, then that code won't be run again and just changing the variable value won't trigger a change in ensime-mode-map (or whatever keymap is relevant here). Such a trigger has to be implemented explicitly using defcustom's :set property. And even then this would only have an effect when changing the value through the Custom interface. The :set function won't be run if you use setq.

0

Try customize-set-variable, not customize-set-value. The former uses the custom-set property, if any, for the option; the latter does not. grep for that variable in the source code, to see where it is handled. The defcustom apparently does not have a :set form, but there might be some code somewhere in the library that does handle setting the value.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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