0

How can I set a keybinding to something to C-c \? I tried with this but it does not work

(global-set-key (kbd "C-c \\") 'something)

Evaluating this gives me the error

Key sequence C-c \ starts with non-prefix key C-c.
  • Solved, this was caused by me having called the same command with (kbd "C-c \ ") (note the whitespace) before – Nisba Feb 24 '18 at 23:50
  • Right, the latter string is C-c followed by two spaces (one of which was needlessly escaped), which was then getting trimmed to just C-c for the binding, hence the "non-prefix key" result. – phils Feb 25 '18 at 1:14
  • 3
    If you think your question and answer might help others, please post your answer as an answer. (You can accept your own answer.) If you don't think it will help others then consider deleting the question. – Drew Feb 25 '18 at 1:40
  • 1
    @phils Actually it's C-c followed by one space, escaping whitespace produces no character ((elisp) Syntax for Strings (obviously, it gets trimmed regardless, as you said) – npostavs Feb 25 '18 at 13:08
1

I solved my problem: it was caused by me having called the same command with (kbd "C-c \ "), without escaping the backslash.

As pointed out in the comments, this string is actually C-c followed by a single space (the following "escaped space" produces no character), which was then getting trimmed to just C-c for the binding, hence the "non-prefix key" result.

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.