1

I'm writing a major mode. In that mode I put:

(define-key oef-mode-map (kbd "C-c C-c") 'oef-edit-in-browser) ;  

With Aquamacs (on my mac) the shortcut is working as expected. But with emacs (on linux) I get: C-c C-c- and the minibuffer is waiting for a key.

If I try C-hk C-c C-c I get same thing : C-c C-c-

After bisecting my init file, as Drew suggested, I found that the problem was the line :

(add-hook 'sgml-mode-hook 'emmet-mode) ;; Auto-start on any markup modes  

If I disable emmet-mode C-c C-c is working fine with my mode... but I don't want to disable Emmet-mode because I like it very much.

Solved

I put that in my init file :

;;; EMMET-MODE
(defvar emmet-mode-keymap
  (let
      ((map (make-sparse-keymap)))
    (define-key map (kbd "C-j") 'emmet-expand-line)
    (define-key map (kbd "<C-return>") 'emmet-expand-line)
    (define-key map (kbd "<C-M-right>") 'emmet-next-edit-point)
    (define-key map (kbd "<C-M-left>") 'emmet-prev-edit-point)
    (define-key map (kbd "C-c w") 'emmet-wrap-with-markup)
    map)
  "Keymap for emmet minor mode.")

(require 'emmet-mode)
(add-hook 'sgml-mode-hook 'emmet-mode) ;; Auto-start on any markup modes
(add-hook 'html-mode-hook 'emmet-mode)
(add-hook 'css-mode-hook  'emmet-mode)
(add-hook 'web-mode-hook  'emmet-mode)

UPDATE

The solution that gave Tyler is working fine. So I put that in my init file:

(require 'emmet-mode)
(eval-after-load "emmet-mode"
  '(define-key emmet-mode-keymap (kbd "C-c C-c") 'oef-edit-in-browser))
(eval-after-load "emmet-mode"
  '(define-key emmet-mode-keymap (kbd "C-c w") 'emmet-wrap-with-markup))
(add-hook 'sgml-mode-hook 'emmet-mode) ;; Auto-start on any markup modes
;; `emmet-mode' will automatically start with oef-mode
(add-hook 'html-mode-hook 'emmet-mode)
(add-hook 'css-mode-hook  'emmet-mode)
(add-hook 'web-mode-hook  'emmet-mode)
  • Start Emacs using emacs -Q (no init file). Do you see the same problem? If not, bisect your init file to find the culprit. – Drew Oct 17 '18 at 19:45
  • For the future, if you are in a similar situation (i.e. you are trying to describe a key, but you see that Emacs expects more keys (i.e. it shows - after the keys you already typed), you can type ? (viz, in your case that would be C-c C-c ?) and that will show you possible other keys defined for this prefix. Once you know what function is bound to the key, it is usually trivial to locate the library which defined it, and make sure it doesn't do it / defines it differently. – wvxvw Oct 18 '18 at 11:15
  • If @Tyler's answer works for you, please consider accepting it. – Drew Dec 27 '18 at 3:32
2

When the minibuffer shows C-c C-c-, that indicates Emacs is still waiting for a complete key sequence. The same thing happens when you enter C-x - you'll see C-x- in the minibuffer, as Emacs waits for the rest of the command.

The reason Emacs thinks you haven't sent it a complete key sequences is most likely because you've bound C-c C-c to a prefix command. Check the source of your major mode for any code that binds C-c C-c to something, there's probably something fishy there.

If you install which-key, you can turn on which-key-mode, then when you enter C-c C-c and wait a second, it will show you the name of the prefix map that you've accidentally assigned to C-c C-c at the bottom of the minibuffer.

UPDATE

Knowing that the problem comes from emmet-mode, I found the following line in the source for that:

(define-key map (kbd "C-c C-c w") 'emmet-wrap-with-markup)

This is implicitly defining C-c C-c as an unamed prefix map in emmet-mode-keymap. Which means whenever that keymap is active, it's going to block whatever you've previously bound to C-c C-c.

To fix this, you could ask the emmet-mode maintainer to use C-c C-w instead. But they may have their reasons to do what they've done. You can over-ride it by redefining C-c C-c in emmet-mode-map after you load emmet-mode. Something like this:

(eval-after-load "emmet-mode"
   '(define-key emmet-mode-keymap (kbd "C-c C-c") 'oef-edit-in-browser))

You may want to add a new binding for emmet-wrap-with-markup. And this change will apply to emmet-mode whenever you use it, not just when you're using it with oef-mode. If that's not what you want you'll need to further tweak how and when you rebind the key.

  • The culprit is in emmet-mode.el (define-key map (kbd "C-c C-c w") 'emmet-wrap-with-markup) – Raoul HATTERER Oct 17 '18 at 21:17
  • I put your code in my init file but it's not working. emmet-mode-map doesn't exist. I found another way to solve my problem. Thank you for your help. – Raoul HATTERER Oct 17 '18 at 22:36
  • In Aquamacs I have emmet-mode version 20161113 here emmet-wrap-with-markup is bound to C-c w. In emacs I have emmet-mode version 20180613 bound to C-c C-c w. – Raoul HATTERER Oct 17 '18 at 22:54
  • Sorry, the code should have referred to emmet-mode-keymap, not emmet-mode-map. I have corrected it. – Tyler Oct 24 '18 at 17:51

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.