On 2017-12-15, Bram Moolenaar wrote:
> Many plugins set options to a different value.  To be able to restore
> the original value very often the old value needs to be saved.
> 
> Not only is this a bit of a hassle, especially for local options, it is
> also incomplete, since the location where the option was originally set
> can't be restored.
> 
> I have been thinking of adding two functions to make this work better:
> 
> option_save({list})                                   *option_save()*
>               Saves the options named in {list}.  The returned value can be
>               passed to option_restore().  Example: >
>                       let s:saved_options = option_save([
>                           \ 'ignorecase',
>                           \ 'iskeyword',
>                           \ ])
>                        au <buffer> BufLeave *
>                           \ call option_restore(s:saved_options)
> <             The advantage over using `:let` is that global and local
>               values are handled and the script ID is restored, so that
>               `:verbose set` will show where the option was originally set,
>               not where it was restored.
> 
> 
> option_restore({list})                                        
> *option_restore()*
>               Restore options previously saved by option_save().
>               When buffer-local options have been saved, this function must
>               be called when the same buffer is the current buffer.
>               When window-local options have been saved, this function must
>               be called when the same window is the current window.
>               When in the wrong buffer and/or window an error is given and
>               the local options won't be restored.
> 
> Does that sound useful?

Almost.

I surveyed my plugins for places where I save and restore options
and in almost all cases the function opens a new buffer, sometimes
as the result of a :grep command.

So, this would not be useful to me unless option_save() also
remembered the buffer/window it was in when executed and
option_restore() just restored to that buffer/window, even if it
wasn't the current buffer/window.

Regards,
Gary

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui