Re: Vim71: breaking change not mentioned in the document.
[EMAIL PROTECTED] wrote: Hi, vimmers: The line 1230 of editing.txt said: To change to the directory of the current file: :cd %:h This works for Vim 7.0 and before, but not for Vim 7.1. In Vim 7.1 when the pwd is the same as the directory of current file, the command will fail with E500. The failure will break the execution of a mapping, if one have a mapping to do :cd %:h and then continue to do something else. To reproduce the error, just at anytime, run :cd %:h twice. (I've got Windows gvim7.1.1, cygwin console vim 7.1.1) So there's at least two issues IMHO: 1. the line 1230 of editing.txt should be changed to :cd %:p:h 2. somewhere in the document should mention: if we had used :cd %:h in our mappings or scripts, we should change them into %:p:h after upgraded to vim 7.1. Or did I missed anything? -- Sincerely, Pan, Shi Zhu. ext: 2606 I agree with point 1. As for point 2, the way I remember it, ":cd %:h" and ":lcd %:h" already failed on Vim 6.3 or maybe earlier, if the current filename (as displayed e.g. on the status line) had no explicit path before it. So apparently one of us either missed something or remembered something the wrong way. Note that ":cd" (without an argument) has different meanings on different OSes, thus reflecting the OS's idiosyncrasies: on Windows it is synonymous with ":pwd", on Linux with ":cd $HOME". Best regards, Tony. -- "Here's something to think about: How come you never see a headline like `Psychic Wins Lottery'?" -- Jay Leno
Re: Vim71: breaking change not mentioned in the document.
On 2007-05-17, [EMAIL PROTECTED] wrote: > Gary Johnson <[EMAIL PROTECTED]> 2007-05-17 00:35:42: > > On 2007-05-16, [EMAIL PROTECTED] wrote: > > > Gary Johnson <[EMAIL PROTECTED]> 2007-05-16 16:41:22: > > > > On 2007-05-16, [EMAIL PROTECTED] wrote: > > > > > Hi, vimmers: > > > > > > > > > > The line 1230 of editing.txt said: > > > > > > > > > > To change to the directory of the current file: > > > > > :cd %:h > > > > > > > I don't think disabling E500 would help. The text of E500 is, > > "E500: Evaluates to an empty string". That's warning you that there > > is no head component of the file name. If you disabled the error, > > and presumably allowed %:h to return an empty string, then your ":cd > > %:h" command would be executing just ":cd", which on a Unix system > > changes to the home directory--not what you want. > > > > Another way to fix your mapping would be to use > > > >:silent! cd %:h > > > > which allows the cd to fail silently. > > > > Regards, > > Gary > > > > -- > > You certainly are right, disabling E500 would not help. However: > > > The line 1230 of editing.txt said: > > > > To change to the directory of the current file: > > :cd %:h > > If I was tell that a script could change to the directory of the current > file, I would think that it will always change to the directory of the > current file, and it is absurd to see it will give an error when the pwd is > already the directory of the current file. > > I'm sure most average users will take it for granted if the document says > this. and they will not think the E500 is reasonable here. The document is > aprently misleading. I see what you mean. Not everyone would read "change to the directory of the current file" as literally as I did in my initial reply. While the manual is correct, it could be more clear here. > So, if :cd %:h must give E500 here, I think the document should change it > to :cd %:p:h Yes, that seems reasonable. Regards, Gary -- Gary Johnson | Agilent Technologies [EMAIL PROTECTED] | Mobile Broadband Division | Spokane, Washington, USA
Re: Vim71: breaking change not mentioned in the document.
Gary Johnson <[EMAIL PROTECTED]> 写于 2007-05-17 00:35:42: > On 2007-05-16, [EMAIL PROTECTED] wrote: > > Gary Johnson <[EMAIL PROTECTED]> 2007-05-16 16:41:22: > > > On 2007-05-16, [EMAIL PROTECTED] wrote: > > > > Hi, vimmers: > > > > > > > > The line 1230 of editing.txt said: > > > > > > > > To change to the directory of the current file: > > > > :cd %:h > > > > > I don't think disabling E500 would help. The text of E500 is, > "E500: Evaluates to an empty string". That's warning you that there > is no head component of the file name. If you disabled the error, > and presumably allowed %:h to return an empty string, then your ":cd > %:h" command would be executing just ":cd", which on a Unix system > changes to the home directory--not what you want. > > Another way to fix your mapping would be to use > >:silent! cd %:h > > which allows the cd to fail silently. > > Regards, > Gary > > -- You certainly are right, disabling E500 would not help. However: > The line 1230 of editing.txt said: > > To change to the directory of the current file: > :cd %:h If I was tell that a script could change to the directory of the current file, I would think that it will always change to the directory of the current file, and it is absurd to see it will give an error when the pwd is already the directory of the current file. I'm sure most average users will take it for granted if the document says this. and they will not think the E500 is reasonable here. The document is aprently misleading. So, if :cd %:h must give E500 here, I think the document should change it to :cd %:p:h -- Sincerely, Pan, Shi Zhu. ext: 2606
Re: Vim71: breaking change not mentioned in the document.
On 2007-05-16, [EMAIL PROTECTED] wrote: > Gary Johnson <[EMAIL PROTECTED]> 2007-05-16 16:41:22: > > On 2007-05-16, [EMAIL PROTECTED] wrote: > > > Hi, vimmers: > > > > > > The line 1230 of editing.txt said: > > > > > > To change to the directory of the current file: > > > :cd %:h > > > > > > This works for Vim 7.0 and before, but not for Vim 7.1. In Vim 7.1 when > the > > > pwd is the same as the directory of current file, the command will fail > > > with E500. The failure will break the execution of a mapping, if one > have a > > > mapping to do :cd %:h and then continue to do something else. > > > > > > To reproduce the error, just at anytime, run :cd %:h twice. (I've got > > > Windows gvim7.1.1, cygwin console vim 7.1.1) > > > > I would expect ":cd %:h" to give an error the second time it is > > executed. Just to be sure, I repeated your experiment on 7.1, 7.0 > > and 6.4 on Unix and 7.0 on Windows. I always got E500. Are you > > sure that it "works" for you for Vim 7.0? > > Positive, I've got a mapping which do :cd %:h then :grep, this mapping > works since Vim 6.3, 6.4 and 7.0, this is the mapping I used "Everyday" and > I cannot use Vim without it, then suddenly it breaks after I installed Vim > 7.1. Now I changed :cd %:h to :cd %:p:h and everything works. That's very strange. Your observations certainly don't match mine. I wonder what's going on. > Anyway, I think there should be an option to disable E500, or "catch and > throw". This is the Unix trend: if the caller feel necessary, a program > should fail silently in order not to break a script. I don't think disabling E500 would help. The text of E500 is, "E500: Evaluates to an empty string". That's warning you that there is no head component of the file name. If you disabled the error, and presumably allowed %:h to return an empty string, then your ":cd %:h" command would be executing just ":cd", which on a Unix system changes to the home directory--not what you want. Another way to fix your mapping would be to use :silent! cd %:h which allows the cd to fail silently. Regards, Gary -- Gary Johnson | Agilent Technologies [EMAIL PROTECTED] | Mobile Broadband Division | Spokane, Washington, USA
Re: Vim71: breaking change not mentioned in the document.
Gary Johnson <[EMAIL PROTECTED]> 写于 2007-05-16 16:41:22: > On 2007-05-16, [EMAIL PROTECTED] wrote: > > Hi, vimmers: > > > > The line 1230 of editing.txt said: > > > > To change to the directory of the current file: > > :cd %:h > > > > This works for Vim 7.0 and before, but not for Vim 7.1. In Vim 7.1 when the > > pwd is the same as the directory of current file, the command will fail > > with E500. The failure will break the execution of a mapping, if one have a > > mapping to do :cd %:h and then continue to do something else. > > > > To reproduce the error, just at anytime, run :cd %:h twice. (I've got > > Windows gvim7.1.1, cygwin console vim 7.1.1) > > I would expect ":cd %:h" to give an error the second time it is > executed. Just to be sure, I repeated your experiment on 7.1, 7.0 > and 6.4 on Unix and 7.0 on Windows. I always got E500. Are you > sure that it "works" for you for Vim 7.0? Positive, I've got a mapping which do :cd %:h then :grep, this mapping works since Vim 6.3, 6.4 and 7.0, this is the mapping I used "Everyday" and I cannot use Vim without it, then suddenly it breaks after I installed Vim 7.1. Now I changed :cd %:h to :cd %:p:h and everything works. Anyway, I think there should be an option to disable E500, or "catch and throw". This is the Unix trend: if the caller feel necessary, a program should fail silently in order not to break a script.
Re: Vim71: breaking change not mentioned in the document.
On 2007-05-16, [EMAIL PROTECTED] wrote: > Hi, vimmers: > > The line 1230 of editing.txt said: > > To change to the directory of the current file: > :cd %:h > > This works for Vim 7.0 and before, but not for Vim 7.1. In Vim 7.1 when the > pwd is the same as the directory of current file, the command will fail > with E500. The failure will break the execution of a mapping, if one have a > mapping to do :cd %:h and then continue to do something else. > > To reproduce the error, just at anytime, run :cd %:h twice. (I've got > Windows gvim7.1.1, cygwin console vim 7.1.1) I would expect ":cd %:h" to give an error the second time it is executed. Just to be sure, I repeated your experiment on 7.1, 7.0 and 6.4 on Unix and 7.0 on Windows. I always got E500. Are you sure that it "works" for you for Vim 7.0? > So there's at least two issues IMHO: > 1. the line 1230 of editing.txt should be changed to :cd %:p:h I disagree. If you want to _change_ directory to that of the current file, the command ":cd %:h" is correct. If the working directory is already that of the current file, such that executing ":cd %:h" would give E500, then there is no reason to change directory. > 2. somewhere in the document should mention: if we had used :cd %:h in our > mappings or scripts, we should change them into %:p:h after upgraded to vim > 7.1. I don't see that this behavior has changed. Regards, Gary -- Gary Johnson | Agilent Technologies [EMAIL PROTECTED] | Mobile Broadband Division | Spokane, Washington, USA
Vim71: breaking change not mentioned in the document.
Hi, vimmers: The line 1230 of editing.txt said: To change to the directory of the current file: :cd %:h This works for Vim 7.0 and before, but not for Vim 7.1. In Vim 7.1 when the pwd is the same as the directory of current file, the command will fail with E500. The failure will break the execution of a mapping, if one have a mapping to do :cd %:h and then continue to do something else. To reproduce the error, just at anytime, run :cd %:h twice. (I've got Windows gvim7.1.1, cygwin console vim 7.1.1) So there's at least two issues IMHO: 1. the line 1230 of editing.txt should be changed to :cd %:p:h 2. somewhere in the document should mention: if we had used :cd %:h in our mappings or scripts, we should change them into %:p:h after upgraded to vim 7.1. Or did I missed anything? -- Sincerely, Pan, Shi Zhu. ext: 2606