saving unnamed buffer
I want to make saving of unnamed buffers possible as follows: When I do :w on a unnamed buffer, I want it to save to the file /tmp/N where N is number. I tried the simple code below, but it does not work. I am getting 'E32: No file name', same error as without this code. How do I fix it ? Thanks Yakov attempt to save unnamed buffer to file /tmp/N - au BufWritePre if(expand('%') == '') | exe filename .TempName() | endif function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun
Re: saving unnamed buffer
Yakov Lerner wrote: I want to make saving of unnamed buffers possible as follows: When I do :w on a unnamed buffer, I want it to save to the file /tmp/N where N is number. I tried the simple code below, but it does not work. I am getting 'E32: No file name', same error as without this code. How do I fix it ? Thanks Yakov attempt to save unnamed buffer to file /tmp/N - au BufWritePre if(expand('%') == '') | exe filename .TempName() | endif function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun Instead of :filename which AFAIK is not a Vim command, try using :file or :saveas instead. Best regards, Tony.
Re: saving unnamed buffer
On 8/21/06, A.J.Mechelynck [EMAIL PROTECTED] wrote: Yakov Lerner wrote: I want to make saving of unnamed buffers possible as follows: When I do :w on a unnamed buffer, I want it to save to the file /tmp/N where N is number. I tried the simple code below, but it does not work. I am getting 'E32: No file name', same error as without this code. How do I fix it ? Thanks Yakov attempt to save unnamed buffer to file /tmp/N - au BufWritePre if(expand('%') == '') | exe filename .TempName() | endif function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun Instead of :filename which AFAIK is not a Vim command, try using :file or :saveas instead. Nope, does not help. Yakov
Re: saving unnamed buffer
On 8/21/06, Yakov Lerner [EMAIL PROTECTED] wrote: On 8/21/06, A.J.Mechelynck [EMAIL PROTECTED] wrote: Yakov Lerner wrote: I want to make saving of unnamed buffers possible as follows: When I do :w on a unnamed buffer, I want it to save to the file /tmp/N where N is number. I tried the simple code below, but it does not work. I am getting 'E32: No file name', same error as without this code. How do I fix it ? Thanks Yakov attempt to save unnamed buffer to file /tmp/N - au BufWritePre if(expand('%') == '') | exe filename .TempName() | endif function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun Instead of :filename which AFAIK is not a Vim command, try using :file or :saveas instead. I fixed another bug, the '*' missing in the autocommand: au BufWritePre * if(expand('%') == '') | exe file .TempName() | endif au BufWritePre * if(expand('%') == '') | exe saveas .TempName() | endif , but still no luck. I'm still getting the E32: No file name error. Yakov
Re: saving unnamed buffer
Yakov Lerner wrote: On 8/21/06, Yakov Lerner [EMAIL PROTECTED] wrote: On 8/21/06, A.J.Mechelynck [EMAIL PROTECTED] wrote: Yakov Lerner wrote: I want to make saving of unnamed buffers possible as follows: When I do :w on a unnamed buffer, I want it to save to the file /tmp/N where N is number. I tried the simple code below, but it does not work. I am getting 'E32: No file name', same error as without this code. How do I fix it ? Thanks Yakov attempt to save unnamed buffer to file /tmp/N - au BufWritePre if(expand('%') == '') | exe filename .TempName() | endif function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun Instead of :filename which AFAIK is not a Vim command, try using :file or :saveas instead. I fixed another bug, the '*' missing in the autocommand: au BufWritePre * if(expand('%') == '') | exe file .TempName() | endif au BufWritePre * if(expand('%') == '') | exe saveas .TempName() | endif , but still no luck. I'm still getting the E32: No file name error. Yakov Well, what gets displayed when you replace exe by echo or echomsg? That's a well-known debugging trick. Best regards, Tony.
Re: saving unnamed buffer
Hi, A.J.Mechelynck wrote: Yakov Lerner wrote: I fixed another bug, the '*' missing in the autocommand: au BufWritePre * if(expand('%') == '') | exe file .TempName() | endif au BufWritePre * if(expand('%') == '') | exe saveas .TempName() | endif , but still no luck. I'm still getting the E32: No file name error. Well, what gets displayed when you replace exe by echo or echomsg? probably nothing; I guess the file name is checked before BufWritePre is executed. Regards, Jürgen -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us. (Calvin)
Re: saving unnamed buffer
On 8/21/06, Jürgen Krämer [EMAIL PROTECTED] wrote: Hi, A.J.Mechelynck wrote: Yakov Lerner wrote: I fixed another bug, the '*' missing in the autocommand: au BufWritePre * if(expand('%') == '') | exe file .TempName() | endif au BufWritePre * if(expand('%') == '') | exe saveas .TempName() | endif , but still no luck. I'm still getting the E32: No file name error. Well, what gets displayed when you replace exe by echo or echomsg? probably nothing; I guess the file name is checked before BufWritePre is executed. not good. Yakov
Re: saving unnamed buffer
On 8/21/06, A.J.Mechelynck [EMAIL PROTECTED] wrote: Yakov Lerner wrote: On 8/21/06, Yakov Lerner [EMAIL PROTECTED] wrote: On 8/21/06, A.J.Mechelynck [EMAIL PROTECTED] wrote: Yakov Lerner wrote: I want to make saving of unnamed buffers possible as follows: When I do :w on a unnamed buffer, I want it to save to the file /tmp/N where N is number. I tried the simple code below, but it does not work. I am getting 'E32: No file name', same error as without this code. How do I fix it ? Thanks Yakov attempt to save unnamed buffer to file /tmp/N - au BufWritePre if(expand('%') == '') | exe filename .TempName() | endif function! TempName() let x=1 while filereadable(/tmp/.x) let x = x + 1 endwhile return /tmp/.x endfun Instead of :filename which AFAIK is not a Vim command, try using :file or :saveas instead. I fixed another bug, the '*' missing in the autocommand: au BufWritePre * if(expand('%') == '') | exe file .TempName() | endif au BufWritePre * if(expand('%') == '') | exe saveas .TempName() | endif , but still no luck. I'm still getting the E32: No file name error. Yakov Well, what gets displayed when you replace exe by echo or echomsg? Nothing gets displayed. Jürgen must be right. Yakov
Re: saving unnamed buffer
On 2006-08-21, Yakov Lerner [EMAIL PROTECTED] wrote: On 8/21/06, Jürgen Krämer [EMAIL PROTECTED] wrote: Hi, A.J.Mechelynck wrote: Yakov Lerner wrote: I fixed another bug, the '*' missing in the autocommand: au BufWritePre * if(expand('%') == '') | exe file .TempName() | endif au BufWritePre * if(expand('%') == '') | exe saveas .TempName() | endif , but still no luck. I'm still getting the E32: No file name error. Well, what gets displayed when you replace exe by echo or echomsg? probably nothing; I guess the file name is checked before BufWritePre is executed. not good. How about trying the BufWriteCmd event instead? Maybe it doesn't check the buffer name. HTH, Gary -- Gary Johnson | Agilent Technologies [EMAIL PROTECTED] | Wireless Division | Spokane, Washington, USA