2012/9/12 Allan Odgaard <mailinglist@textmate.org>
On Sep 11, 2012, at 10:24 AM, Yvon Thoraval <yvon.thoraval@gmail.com> wrote:

> Here it is : […] Save failed! File exists - (bin/menu.zsh, bin/menu.zsh~)
> […]
> Also, i should mention i had a file "bin/menu.zsh~" BEFORE using rmate, then, removing it before a second rmate gave :
> […]
> Then, rmate is working except another file with the suffix "~" exists too.

I’m a little unclear as to whether or not you solved your problem.

It might be that File::rename does not unlink destination first. Given that you are using rvm and the script is in ruby, I would assume you can test the relevant code on your version of ruby to see why it has a problem.


OK, I've found a solution working even if I want to edit a file of given path where path~ does exist.

I've just changed the way the hard linked file is name, instead of "#{path}~" i name it npath with, as a starting point i let :
npath="#{path}~"

and if npath allready exist i change it to :
npath="#{npath}~"
              ^_________ notice the "n" here

then I changed the lines 97/104 to :
    npath="#{path}~"
    if File.exist? path
      while File.exist? npath
        npath="#{npath}~"
      end
      puts "Creating hard link from #{path} to #{npath}." if $settings.verbose
      File.link(path, npath)
    end


and here, suppose i do have both files "~/bin/menu.zsh" and "~/bin/menu.zsh~" where I want to remote edit "~/bin/menu.zsh", internally (of rmate-test) the npath would be in this case "~/bin/menu.zsh~~" (with two ~) which doesn't exist.

that makes the rmate-test working :
yt@D620 /home/yt $ rmate-test -v bin/menu.zsh
yt@D620 /home/yt $ Connect: ‘220 imyt.local RMATE TextMate (Darwin 11.4.0)’
Saving bin/menu.zsh
Creating hard link from bin/menu.zsh to bin/menu.zsh~~.
Closed bin/menu.zsh
Done

yt@D620 

see attached rmate-test, the modified rmate.

 


--
Yvon