Making ":unset [varname]" = ":set no[varname]"

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

Making ":unset [varname]" = ":set no[varname]"

Stephen R Laniel
I'd like to write a (presumably small) vim patch so that

:unset [varname]

does the same thing as

:set no[varname]

assuming [varname] is a valid vim variable. But I've been looking
through the source, and I'm not clear on where I'd include the patch.
Can someone give a first-time vim developer a kick in the right
direction?

Thanks,
Steve

--
Stephen R. Laniel
[hidden email]
+(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Making ":unset [varname]" = ":set no[varname]"

Gautam Iyer
On Mon, Jun 27, 2005 at 04:02:34PM -0400, Stephen R Laniel wrote:

> I'd like to write a (presumably small) vim patch so that
>
> :unset [varname]
>
> does the same thing as
>
> :set no[varname]
>
> assuming [varname] is a valid vim variable. But I've been looking
> through the source, and I'm not clear on where I'd include the patch.
> Can someone give a first-time vim developer a kick in the right
> direction?

Why do you need to patch vim for this? You can easily write a vim script
to do the same. Something like (untested)

    :command -nargs=1 Unset exec 'set no'.<q-args>

should do the trick. Only disadvantage is that you will have to call
your command :Unset instead of :unset. If you decide you *really* can't
live with that, try

    :cab unset Unset

in addition to the above. (Ofcourse using an abbreviation for unset has
it's disadvantages ...)

:)

GI

--
If your wife wants to learn to drive, don't stand in her way.
Reply | Threaded
Open this post in threaded view
|

Re: Making ":unset [varname]" = ":set no[varname]"

A.J.Mechelynck
GI wrote:

> On Mon, Jun 27, 2005 at 04:02:34PM -0400, Stephen R Laniel wrote:
>
>
>>I'd like to write a (presumably small) vim patch so that
>>
>>:unset [varname]
>>
>>does the same thing as
>>
>>:set no[varname]
>>
>>assuming [varname] is a valid vim variable. But I've been looking
>>through the source, and I'm not clear on where I'd include the patch.
>>Can someone give a first-time vim developer a kick in the right
>>direction?
>
>
> Why do you need to patch vim for this? You can easily write a vim script
> to do the same. Something like (untested)
>
>     :command -nargs=1 Unset exec 'set no'.<q-args>
>
> should do the trick. Only disadvantage is that you will have to call
> your command :Unset instead of :unset. If you decide you *really* can't
> live with that, try
>
>     :cab unset Unset
>
> in addition to the above. (Ofcourse using an abbreviation for unset has
> it's disadvantages ...)
>
> :)
>
> GI
>

You may want to make your :Unset command somewhat more sophisticated,
for instance:

if 'option' is not a functioning option
        :Unset option
                Error: ...

if 'option' is boolean
        :Unset option
        --> set nooption

if 'option' is a String
        :Unset option
        --> set option=

if 'option' is a Number
        :Unset option
        --> set option=0

I don't know how to test the type of an option though...

Another possibility would be to set its back to its default, but there
is a command for that already (three of them actually):

" set back to default, using current [no]compatible setting:
        :set option&
" set back to Vim default (as with 'nocompatible'):
        :set option&vim
" set back to Vi default (as with 'compatible'):
        :set option&vi


Best regards,
Tony.

Reply | Threaded
Open this post in threaded view
|

Re: Making ":unset [varname]" = ":set no[varname]"

Stephen R Laniel
In reply to this post by Gautam Iyer
On Mon, Jun 27, 2005 at 03:23:50PM -0500, GI wrote:
> your command :Unset instead of :unset. If you decide you *really* can't
> live with that, try
>     :cab unset Unset

But let's imagine I really did want to patch vim to handle
this -- if only because I want to start contributing to the
free-software movement. Where might I look in the source?

--
Stephen R. Laniel
[hidden email]
+(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Making ":unset [varname]" = ":set no[varname]"

Bram Moolenaar

Stephen R Laniel wrote:

> But let's imagine I really did want to patch vim to handle
> this -- if only because I want to start contributing to the
> free-software movement. Where might I look in the source?

Read the src/README.txt file.

--
hundred-and-one symptoms of being an internet addict:
169. You hire a housekeeper for your home page.

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///