I love emacs. I love having my clipboard history. I've used Jumpcut for a long time and recently purchased the powerpack for Alfred and tried its clipboard manager.

I have the same problem with both of these clipboard managers. When I try to paste into Emacs, the clipboard manager sends a virtual +V to Emacs. Emacs interprets this as M-v -- scroll-down.

I've been using Emacs too long and on too many platforms to change my keybindings. Emacs is very customizable. Since clipboard managers are used by geeky power users, the developers of clipboard managers are even geekier and know about solving geeky problems.

So, there must be a way to get these things to work together.

Is there a way to configure emacs to accept the paste natively (w/o changing my keybdindings)?

Is there a way for Jumpcut, Alfred, or another clipboard manager to send something that Emacs will interpret (e.g. C-y) just for Emacs?


I don't use Mac, on Windows I solved it by rebindig C-v which I luckily don't use otherwise. But here's an idea:

I guess there are tools for Mac which allows you to bind any key to call an application and check which window is active (something like Autohotkey). Choose some hotkey which you will use to to invoke the clipboard manager (you can also use its current hotkey if your keyboard macro program can handle it). Attach a macro to the hotkey which checks which window is active and if it is emacs then it sends a message first to emacs via emacsclient to rebind M-v as "yank and then restore the original binding of M-v" and then invokes the clipboard manager. This way when the clipboard manager pastes into emacs then emacs will interpret M-v as yank and then it restores the original binding of M-v to scrolling.

  • Wow... macro-processor sending message to emacs for dynamic key rebinding. Serious emacs/geeky chops to you. Have an upvote. I'll have to explore my options in OS X before I accept this though. – Doug Harris Dec 2 '11 at 15:41
  • you don't use C-v??? how do you page down? – rbp May 31 '13 at 12:17

The source for Jumpcut (which I have never used) is available, so you can change fakeCommandV in AppController.m to detect when it's pasting in Emacs. I have tested the following very lightly. I also had to make a few unrelated but minor changes to get it to compile on my computer (10.6).

    /*" +fakeCommandV synthesizes keyboard events for Cmd-v Paste
    shortcut. "*/
    // Code from a Mark Mason post to Cocoadev-l
    // What are the flaws in this approach?
    //  We don't know whether we can really accept the paste
    //  We have no way of judging whether it's gone through
    //  Simulating keypresses could have oddball consequences (for instance, if something else was trapping control v)
    //  Not all apps may take Command-V as a paste command (xemacs, for instance?)
    // Some sort of AE-based (or System Events-based, or service-based) paste would be preferable in many circumstances.
    // On the other hand, this doesn't require scripting support, should work for Carbon, etc.
    // Ideally, in the future, we will be able to tell from what environment JC was passed the trigger
    // and have different behavior from each.
    NSString* app = [[[NSWorkspace sharedWorkspace] activeApplication]
    NSLog(@"Current application: %@",app);
    if ( [app isEqual:@"Emacs"] ) {
        NSNumber *keyCode = [srTransformer reverseTransformedValue:@"Y"];
        CGKeyCode yCode = (CGKeyCode)[keyCode intValue];
        CGPostKeyboardEvent( (CGCharCode)0, (CGKeyCode)59, true ); // Control down
        CGPostKeyboardEvent( (CGCharCode)'y', yCode, true ); // Y down
        CGPostKeyboardEvent( (CGCharCode)'y', yCode, false ); //  Y up
        CGPostKeyboardEvent( (CGCharCode)0, (CGKeyCode)59, false ); // Control up

    } else {
        NSNumber *keyCode = [srTransformer reverseTransformedValue:@"V"];
        CGKeyCode veeCode = (CGKeyCode)[keyCode intValue];
        CGPostKeyboardEvent( (CGCharCode)0, (CGKeyCode)55, true ); // Command down
        CGPostKeyboardEvent( (CGCharCode)'v', veeCode, true ); // V down
        CGPostKeyboardEvent( (CGCharCode)'v', veeCode, false ); //  V up
        CGPostKeyboardEvent( (CGCharCode)0, (CGKeyCode)55, false ); // Command up

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.