How to make global option act local

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to make global option act local

Suresh Govindachar`
Hello,

Any suggestions on how to make a global option act local?
Here's an example of where the suggestion would be used:
Calenadar.vim has the line:

    setlocal nowrapscan

However, "wrapscan" is not a local option -- it is a global option.

Thanks,

--Suresh

Reply | Threaded
Open this post in threaded view
|

RE: How to make global option act local

Halim, Salman
I wrote a plugin that lets you specify options you want local to a
buffer and pushes/pops them when you leave/enter the buffer...  (I do it
by filetype, I think.)

There was another one a long time ago to Push and Pop options on
BufEnter/BufLeave before local options came into existence...

Salman.

> -----Original Message-----
> From: Suresh Govindachar [mailto:[hidden email]]
> Sent: Wednesday, August 17, 2005 10:12 AM
> To: [hidden email]
> Cc: Yasuhiro Matsumoto
> Subject: How to make global option act local
>
> Hello,
>
> Any suggestions on how to make a global option act local?
> Here's an example of where the suggestion would be used:
> Calenadar.vim has the line:
>
>     setlocal nowrapscan
>
> However, "wrapscan" is not a local option -- it is a global option.
>
> Thanks,
>
> --Suresh
>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to make global option act local

A.J.Mechelynck
----- Original Message -----
From: "Halim, Salman" <[hidden email]>
To: "Suresh Govindachar" <[hidden email]>; <[hidden email]>
Cc: "Yasuhiro Matsumoto" <[hidden email]>
Sent: Wednesday, August 17, 2005 4:14 PM
Subject: RE: How to make global option act local


>> -----Original Message-----
>> From: Suresh Govindachar [mailto:[hidden email]]
>> Sent: Wednesday, August 17, 2005 10:12 AM
>> To: [hidden email]
>> Cc: Yasuhiro Matsumoto
>> Subject: How to make global option act local
>>
>> Hello,
>>
>> Any suggestions on how to make a global option act local?
>> Here's an example of where the suggestion would be used:
>> Calenadar.vim has the line:
>>
>>     setlocal nowrapscan
>>
>> However, "wrapscan" is not a local option -- it is a global option.
>>
>> Thanks,
>>
>> --Suresh
>>
>>
>I wrote a plugin that lets you specify options you want local to a
> buffer and pushes/pops them when you leave/enter the buffer...  (I do it
> by filetype, I think.)
>
> There was another one a long time ago to Push and Pop options on
> BufEnter/BufLeave before local options came into existence...
>
> Salman.

Of course, the "ideal" solution would be if the options in question could be
made "global-local" (there is even a provision in the help saying more
options may become global-local in the future) but that, of course, requires
patching the source. _Some_ options like 'guifont' 'lines' 'columns' etc.
will of course always remain global-only.

Saving and restoring options to buffer-local variables sounds like a good
enough workaround to me. It's not hard to do:

    autocommand BufEnter * if exists("b:save_wrapscan") &&
exists("+wrapscan") | let &wrapscan = b:save_wrapscan | endif

    autocommand BufLeave * if exists("+wrapscan") | let b:save_wrapscan =
&wrapscan | endif

What the above doesn't do is save the file-by-file preferences across
sessions.