I use Aquamacs. C-; is bound to toggle-mac-option-modifier. When I use C-h k C-;, I get

^; runs the command toggle-mac-option-modifier, which is an interactive Lisp function in `emulate-mac-keyboard-mode.el'.

I want to remove this keybinding so I can use elsewhere. I have tried

(global-unset-key (kbd "C-;"))
(define-key toggle-mac-option-modifier [C-\;] nil)
(define-key emulate-mac-keyboard-mode [C-\;] nil)
(define-key emulate-mac-keyboard-mode [?\C-\;] nil)
(define-key emulate-mac-keyboard-mode [C-\;] nil)
(define-key emulate-mac-keyboard-mode [control-\;] nil)
(define-key emulate-mac-keyboard-mode-map [control-\;] nil)
(define-key emulate-mac-keyboard-mode [control \;] nil)
(define-key emulate-mac-keyboard-mode (kbd "C-;") nil)
(define-key toggle-mac-keyboard-modifier (kbd "C-;") nil)
(define-key toggle-mac-option-modifier "C-;" nil)

I keep getting the error that the

symbol's value as variable is void

After much searching I found somewhere that maybe the value of the variable had not been initialised, so I tried those after

(require 'emulate-mac-keyboard-mode)

with the same result. I also tried

(eval-after-load 'emulate-mac-keyboard-mode
     (define-key emulate-mac-keyboard-mode [C-\;] nil)))

How can I unset this key?

  • +1 for showing your work. ;) Clarifying question: does "I want to remove this keybinding so I can use elsewhere" mean you want to bind toggle-mac-option-modifier to a different key, or you want to use C-; for a different command? If the former, it's not a problem to have the same command bound to multiple keys -- no need to unbind. If the latter, you can just set the binding to a new command without unbinding it first.
    – Dan
    Sep 18 '15 at 12:47
  • In the 30 minutes I spent trying to figure this out, I was thinking of you, @Dan. Every time I try to do something simple in Emacs, I waste hours. Emacs for me is a means to an end, I don't always have the time it requires and often I just learn to live with things the way they are :(
    – Vivi
    Sep 18 '15 at 23:18
  • I wanted to bind commenting in and out everywhere to C-; . That seems quite hard though as it seems like the name of the function is different in every mode. In latex it is comment-or-uncomment-region, bound to C-c ; , in lisp it is paredit-comment-dwim bound to M-; , in matlab it is matlab-comment-region bound to C-c ; . When I try to use (global-set-key (kbd "C-;") comment-dwim) it says that "symbol's value as a variable is void: comment-dwim. I think I will live with the keybindings as they are.
    – Vivi
    Sep 18 '15 at 23:22
  • I think I see the problem: try #'comment-dwim instead.
    – Dan
    Sep 18 '15 at 23:23
  • @Dan That said, I still don't like C-; bound to toggle-mac-keyboard-modifier. I often press it by mistake and I want to remove that keybinding. How can I do that (ie, what I asked in the question)?
    – Vivi
    Sep 18 '15 at 23:23

I've switched to the railwaycat/homebrew-emacsmacport so I can't test this easily but I used to do this on Aquamacs:

(define-key osx-key-mode-map (kbd "C-;") nil) ; was toggle-mac-option-modifier
  • Oh, my king! Thank you, that solved the problem :)
    – Vivi
    Sep 19 '15 at 1:17

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.