Re: Calling Cream_file_open() from command-line
Cream is a free, easy-to-use configuration of the Vim text editor
Brought to you by:
digitect
From: Steve H. <dig...@mi...> - 2006-05-03 03:40:55
|
On Tue, 2006-05-02 at 08:34 -0300, BG - Ben Armstrong wrote: > On Mon, 2006-05-01 at 20:11 -0400, Steve Hall wrote: > > > > How about this: > > > > cream --remote-send "<C-o>:call > > Cream_file_open(\"/path/file\")<CR>" > > Tried it. Didn't work for me. Even when you had a GVIM server running? What was the error? Is this from bash or something else? > The actual command that works for me > now is: > > cream --remote-silent "+call Cream_file_open(\"/path/file\")" - > > By specifying "-", I no longer need the <C-U> hack, which apparently > broke in vim7. Is this trying to dump stdin via Ex mode? My <C-o> and <CR> assume a call from insert mode, what did your trailing <C-u> do? > By specifying --remote-silent, I suppress the warning when the > server doesn't exist yet. I get a buffer named "-" and a buffer named "file\")"! Can't seem to figure out a way around, I wonder if this is a shell limitation? > I cannot use --remote-send because it will make no attempt to create > the server if it doesn't yet exist: > > E247: no registered server named "GVIM": Send failed. Right, I forgot. It's too late for me, dunno how to solve this. > > I think this syntax is a little smoother, although the file must > > exist to work. So, if we change the second test in > > Cream_file_open() to: > > > > if filereadable(myfile) == 0 > > let n = confirm( > > \ "File \"" . myfile . "\"\n" . > > \ "does not exist, create it?\n" . > > \ "\n", "&Ok\n&Cancel", 1, "Info") > > if n != 1 > > return > > endif > > endif > > Good idea. But this doesn't quite work. I get: > > Warning! > > File is not writable (read-only, permissions, etc.). Open anyway? > > I think you now need to move the writable check into the "else" of > the readable check, since if the file isn't readable and we don't > create it, there is no file to edit, and if we do create it, then > surely it is writable (or else the touch would have failed). At > least, that's what works for me. Actually, the writable check is a different block just below the code above, it didn't change. There are three in file_open(): 1. Verify not directory 2. Verify exists, prompt to create if not (above) 3. Verify not read-only You're now seeing the third, not sure why unless it is already opened by another server? > > What do you do if you're trying to open multiple files? It might > > be good for somebody to modify the cream shell script to pass > > multiple arguments this way, although it might be a little > > complicated parsing wildcards and passing in each name. > > At present I'm not concerned about the multiple file open case, > although I agree some people might want this. > > Before solving the multiple file open in a general way, I'm more > concerned about allowing these scenarios: > > 1. open a single file read-only > 2. pass two files to be diffed, opening both read-only > 3. pass two files to be diffed, opening the first read-only (the > original) and the second read-write (the working copy) Arguments and wrappers and global variables, oh my! With too little sleep, I can't even get my head around this to imagine. -- Steve Hall [ digitect mindspring com ] :: Cream... something good to put in your Vim! :: http://cream.sourceforge.net |