Monday, November 28, 2011

Re: Synchronizing or merging undo across platforms

On 28/11/11 06:31, Christian Brabandt wrote:
> Hi Bram!
>
> On So, 27 Nov 2011, Bram Moolenaar wrote:
>
>>
>> Christian Brabandt wrote:
>>
>>> On Wed, November 16, 2011 9:38 pm, Paul wrote:
>>>> On Nov 16, 1:42 am, "Christian Brabandt"<cbli...@256bit.org> wrote:
>>>>
>>>>> Well, first check that
>>>>> :echo undofile(@%) points to the same undofile across each platform.
>>>>
>>>> Aha, thanks. That helped me determine that my Vim silently ignores me
>>>> when I try to set relative directories for undodir.
>>>>
>>>> :set undodir=. works fine, but no undo file is created when I :set
>>>> undodir=./undodir
>>>>
>>>> This seems to be a different behavior than that of backupdir, even
>>>> though :help undodir says "See |'backupdir'| for details of the
>>>> format." Is this expected/documented/fixable?
>>>
>>> Hm, setting 'undodir' to a relative directory works for me. I can't
>>> reproduce this. However there is a bug when using rundo with those
>>> files.
>>>
>>> When using a separate 'undodir' directory to store the undofiles, Vim
>>> uses the complete path of the file as filename, replacing the path
>>> separators ('/') by '%'. So far this works as documented by :h
>>> 'undodir'.
>>>
>>> Now when using :rundo with a filename, that contains the complete path
>>> and using '%' as directory separators, those '%' will be replaced by
>>> the current file name (as documented by :h filename-modifiers) and
>>> surprise surprise Vim won't be able to read the undofile.
>>>
>>> So this is just plain wrong in this case. So here is a patch, that
>>> fixes that. This applies only to :rundo and I am not sure, whether
>>> this should also apply to :wundo (I tend not to apply it there) but
>>> this should be kept in mind.
>>>
>>> Bram, please check and apply.
>>
>> In most places where you can use a file name % is expanded. And it's
>> also useful, especially in the form "%:h" to get the directory.
>
> I don't understand. Using '%' as path separators contradicts the usage
> your pointing out. How am I supposed to :rundo an undofile, that
> contains the '%'-separator?

The path separator is % in 'undodir' but / in the operand of :rundo (see
the examples under ":help :rundo").

>
> #v+
> ~$ mkdir -p /tmp/undo
> ~$ vim -u NONE -U NONE -N -i NONE -c ':set undodir=/tmp/undo|set
> undofile|exe "wundo" undofile(@%)|q' ~/.vimrc
> ~$ vim -u NONE -U NONE -N -i NONE -c ':set undodir=/tmp/undo|set
> undofile|exe "verbose rundo" undofile(@%)' ~/.vimrc
> "~/.vimrc" 438L, 13769C
> Reading undo file: /tmp/undo/.vimrchome.vimrcchrisbra.vimrc.vim.vimrcvimrc
> Fehler beim Ausführen von "command line":
> E822: Cannot open undo file for reading: /tmp/undo/.vimrchome.vimrcchrisbra.vim
> rc.vim.vimrcvimrc
> #v-
>
> regards,
> Christian
>


Best regards,
Tony.
--
Burn's Hog Weighing Method:
(1) Get a perfectly symmetrical plank and balance it across a
sawhorse.
(2) Put the hog on one end of the plank.
(3) Pile rocks on the other end until the plank is again
perfectly balanced.
(4) Carefully guess the weight of the rocks.
-- Robert Burns

--
You received this message from the "vim_use" 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

No comments:

Post a Comment