On 3 November 2010 09:10, E. Wing <[email protected]> wrote:
> I have a small in-app feature where I can open my application's Lua
> scripts with the default text editor registered in the system. I also
> like to open the Lua scripts to a specific line number if I detect an
> error. With MacVim, I invoke it with command line switches: -g +
> (line_number)
>
> This works great if the file is not already open. If the file is open,
> Vim prompts me there is a .swp file and allows me pick an action. But
> in this case, what I would prefer is that Vim just silently bring the
> already existing open window to the front (ideally with the correct
> tab selected if tabs are in use). Gold star if I can also get this
> already open window to move to the requested line number.
>
> Is there any way to achieve this? Perhaps there is some special
> command line argument I can use to suppress prompts and already does
> what I want? Or if not, is there an AppleScript way to control this?
> (Incidentally, I'm working on a Lua/Cocoa bridge which has Scripting
> Bridge support so in theory, I may be able to write a Lua script to
> control this for me.)

There is an AppleScript way (this is how Xcode does it): send an odoc
event to open a file with a "keyAEPosition" descriptor the data of
which should be the following struct

struct
{
    int16_t unused1;      // 0 (not used)
    int16_t lineNum;      // line to select (< 0 to specify range)
    int32_t startRange;   // start of selection range (if line < 0)
    int32_t endRange;     // end of selection range (if line < 0)
    int32_t unused2;      // 0 (not used)
    int32_t theDate;      // modification date/time
};

See, the -[MMAppController extractArgumentsFromOdocEvent:] for more
details on how MacVim parses this.

Alternatively, you may be able to use the mvim:// URL handler, see ":h mvim://".

Finally, if you have a specific MacVim window that you wish to open a
file in then you should use the --servername and --remote family of
arguments to the "mvim" script, e.g.

mvim --servername VIM --remote-silent filename

Björn

-- 
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

Reply via email to