3
votes

I'm on Mac OS 10.12.3 (Sierra), using Gnu Emacs 25.1 (9.0). I've been an Emacs user for a long time, but (unfortunately) not a Lisp programmer. I have a .emacs file I've carried around for a long time that sets up customizations that I've scraped from here and there.

Having just set up on a new system, switching from Aquamacs to Gnu Emacs, I have one remaining thing I'm trying to set up, namely getting the "forward-word" and "backward-word" commands to map to Ctrl-<right> and Ctrl-<left>, respectively.

I've tried:

(global-set-key (kbd "C-<right>") 'forward-word)

and

(global-set-key (quote [C-right]) (quote forward-word))

and neither works. The "meta" key has been mapped to the Apple command key, which I think is why this doesn't work:

(global-set-key "\M-[1;5C"    'forward-word)

Can anyone please help? If you want to flame me for not knowing Lisp first, that's fine.

2

2 Answers

2
votes
  • Ask Emacs how to describe the key sequence
  • Use what it tells you with kbd

C-h k followed by Ctrl-<right> tells me <C-right> and therefore I would use (kbd "<C-right>")

2
votes

Your Mac or Iterm may absorb your input combinations especially when they have system keys. On Mac, open settings -> keyboard -> Shortcuts and ensure you don't have overrides in that list. If you run console version of Emacs, check your Iterm settings too.