Make TextExpander work with GUI Emacs

Oct 30, '09 07:30:03AM

Contributed by: JWiegley

If you use the emacs-app port from MacPorts to run a GUI version of emacs (called Emacs from here on), there's a problem with the app: TextExpander won't expand abbreviations in Emacs buffers, since it wants to transmit the expanded text using a Command-V event -- which is paste in OS X apps, but scroll-down in Emacs.

But if you happen to have a keyboard remapping utility, such as QuicKeys, there is a way to get these two to play together:

  1. Add the following to your .emacs file:
    (setq ns-alternate-modifier 'alt)
    (define-key global-map [(alt ?v)] 'scroll-down)
    (define-key global-map [(meta ?v)] 'yank)
  2. Restart emacs.
  3. In QuicKeys, or some other key remapping utility, remap Command-V for emacs to generate the keystroke Option-V instead.
The result of this little hack is that when the user types Command-V, the system sends Option-V, which does what Command-V used to do. And when TextExpander sends Command-V, it causes 'yank' to be invoked, which pastes in the expanded text.

Comments (0)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20091013214429696