Loading ...
Sorry, an error occurred while loading the content.

Re: Evaluate expression does not work in MacVim

Expand Messages
  • björn
    2008/5/20 Nico Weber : Hi all, tell application Finder to launch in nearly call cocoa text fields, you can enter an apple
    Message 1 of 4 , May 20 9:49 AM
      2008/5/20 Nico Weber <nicolasweber@...>:
      > Hi all,
      > tell application "Finder" to launch
      > in nearly call cocoa text fields, you can enter an apple script
      > expression such as '80+2' or even 'tell application "Finder" to
      > activate", highlight it, and hit ⇧⌘8. The result of the applescript
      > expression will replace the highlighted text ('80+2' will become '82',
      > 'tell application…' will activate the finder and then complain that
      > no result was returned that the text could be replaced with). Try it
      > in TextEdit, for example.
      > This does not work with MacVim. I guess there's not much that can be
      > done about that, but I thought I'd report it anyways, especially since
      > other cocoa text field tricks like ⌘⌃D (look up highlighted work in
      > dictionary) work with MacVim.

      I've attached a first stab at a patch below.

      The reason why this didn't already work was because I hadn't
      implemented the code that receives data from a system service. The
      patch below takes care of this but it is flawed in that it assumes Vim
      is in Visual mode when the input is added to Vim. I have to think
      about how to implement this so that it takes the text from the
      pasteboard and replaces the current selection with this text, or
      inserts it if there is no selection (and it must work both in Visual
      and in Select mode). We might have to add a new message to the
      backend which does this (e.g. "ReplaceTextMsgId").


      diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m
      index c3b055e..b5a28a7 100644
      --- a/src/MacVim/MMWindowController.m
      +++ b/src/MacVim/MMWindowController.m
      @@ -734,6 +734,20 @@
      return [self askBackendForStarRegister:pboard];

      +- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard
      + // Replace the current selection with the text on the pasteboard.
      + NSArray *types = [pboard types];
      + if ([types containsObject:NSStringPboardType]) {
      + NSString *input = [NSString stringWithFormat:@"s%@",
      + [pboard stringForType:NSStringPboardType]];
      + [vimController addVimInput:input];
      + return YES;
      + }
      + return NO;
      @end // MMWindowController

      You received this message from the "vim_mac" maillist.
      For more information, visit http://www.vim.org/maillist.php
    Your message has been successfully submitted and would be delivered to recipients shortly.