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

Fwd: Launching an already open file

Expand Messages
  • Gabi Huiber
    Meant to send this here. Sorry, Gabi ... From: Gabi Huiber Date: Thu, Aug 4, 2011 at 5:30 PM Subject: Re: Launching an already open file
    Message 1 of 1 , Aug 4, 2011
    • 0 Attachment
      Meant to send this here. Sorry,

      Gabi

      ---------- Forwarded message ----------
      From: Gabi Huiber <ghuiber@...>
      Date: Thu, Aug 4, 2011 at 5:30 PM
      Subject: Re: Launching an already open file
      To: Ben Schmidt <mail_ben_schmidt@...>


      Thanks for the <CR> pointer. it was driving me nuts that I kept having
      to hit CR after fn+F7+CR.  Then I saw in :map that a bunch of key
      bindings are defined with <CR> and some even with <CR><CR>,
      experimented with both, and decided on the latter.

      I'm making some progress. StataMP will respond to this:

      function RunIt()
       wa
       !rm -Rf ~/Library/Saved*/com.stata*
       !osascript -e 'tell app "StataMP" to open "%:p"'
      endfunction

      :map <F7> :<C-U>call RunIt()<CR><CR>
      :imap <F7> <Esc>:<C-U>call RunIt()<CR><CR>

      But it will not actually do the do-file (that is, execute it
      verbosely). Instead, it opens it for editing in its own editor. Still,
      I get no error messages, no hangs, and RunIt() can be launched as many
      times as needed. It won't open another instance of Stata, which is
      good. Now I only need to figure out the Apple event that will
      interpret "tell app to open" as "make app execute it" instead of "make
      app edit it" when app=StataMP.

      Thank you,

      Gabi

      On Wed, Aug 3, 2011 at 9:05 PM, Ben Schmidt
      <mail_ben_schmidt@...> wrote:
      >> " STATA DO-FILE SCRIPT
      >>
      >> function RunIt()
      >>   wa
      >>   !open -a StataMP --args do "%:p"
      >> endfunction
      >>
      >> :map <F7> :<C-U>call RunIt()
      >> :imap <F7> <Esc>:<C-U>call RunIt()
      >
      > I don't really think this is the answer to your problem, but you
      > probably want <CR> at the end of your mappings.
      >
      > :map <F7> :<C-U>call RunIt()<CR>
      > :imap <F7> <Esc>:<C-U>call RunIt()<CR>
      >
      >> Unfortunately, this doesn't work all that well. Either RunIt() or
      >> RunDoLines() will work as expected only once. All subsequent calls to
      >> either
      >> function will be ignored.
      >
      > Does StataMP quit after running once or remain open? If it remains open,
      > perhaps that is the problem, as it can't be given arguments if it isn't
      > being launched. You may need to find another way to communicate with it
      > if it is already open, e.g. AppleScript:
      >
      > !osascript -e 'tell app "StataMP" to open "%:p"'
      >
      > That will probably launch the app if it isn't already running, too.
      >
      > Ben.
      >
      >
      >
      >

      --
      You received this message from the "vim_mac" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    Your message has been successfully submitted and would be delivered to recipients shortly.