Strange issues with getreg('=')

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

Strange issues with getreg('=')

David Fishburn

Vim 6.3.76 WinXP SP2

I am using the Intellisense plugin (for Windows), which does code completion
by poping up a windows box (with the code in it).  You then hit enter (to
select) or esc to close.

While editing an HTML file it defines these maps:
imap <silent><buffer> < <<C-R>=IN_ShowVISDialog("showMethodList")<CR>
imap <silent><buffer> <C-Space>
<Space><Left><C-R>=IN_ShowVISDialog("showGenList")<CR>

If I go into insert mode, press <, the window pops up (good).
Hit ESC.
Leave insert mode.


Now execute this line:
:echo getreg('=')

Now this is where it gets strange.

For some reason this pops up the Intellisense completion window.
So it is like pressing <.


Looking at the help:
:h getreg

getreg([{regname}]) *getreg()*
                The result is a String, which is the contents of register
                {regname}. Example: >
                        :let cliptext = getreg('*')
                getreg('=') returns the last evaluated value of the
expression
                register. (For use in maps).
                If {regname} is not specified, |v:register| is used.


Can anyone think given this:
getreg('=') returns the last evaluated value of the expression register.

Why this might launch the Intellisense plugin.
What can you look for to prevent this from happening?

The getreg() call is actually part of another plugin (which just so happens
to be mine, YankRing.vim).  I traced the call to it.

TIA,
Dave

Reply | Threaded
Open this post in threaded view
|

Re: Strange issues with getreg('=')

Eric Arnold


--- David Fishburn <[hidden email]> wrote:

>
> Vim 6.3.76 WinXP SP2
>
> I am using the Intellisense plugin (for Windows), which does code completion
> by poping up a windows box (with the code in it).  You then hit enter (to
> select) or esc to close.
>
> While editing an HTML file it defines these maps:
> imap <silent><buffer> < <<C-R>=IN_ShowVISDialog("showMethodList")<CR>
> imap <silent><buffer> <C-Space>
> <Space><Left><C-R>=IN_ShowVISDialog("showGenList")<CR>
>
> If I go into insert mode, press <, the window pops up (good).
> Hit ESC.
> Leave insert mode.
>
>
> Now execute this line:
> :echo getreg('=')
>
> Now this is where it gets strange.

Strange yes, but it's the normal behavior.  Any access of the expression
register causes it to evaluate an expression.

If you want the last expression itself, use:

        let reg_expr = histget("=",-1)


>
> For some reason this pops up the Intellisense completion window.
> So it is like pressing <.
>
>
> Looking at the help:
> :h getreg
>
> getreg([{regname}]) *getreg()*
> The result is a String, which is the contents of register
> {regname}. Example: >
> :let cliptext = getreg('*')
> getreg('=') returns the last evaluated value of the
> expression
> register. (For use in maps).
> If {regname} is not specified, |v:register| is used.
>
>
> Can anyone think given this:
> getreg('=') returns the last evaluated value of the expression register.

It's got to be because the last expression used launched the plugin:
  <Space><Left><C-R>=IN_ShowVISDialog("showGenList")<CR>
.....................^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Remember accessing the expression register either with   getreg()   or
by name   @=   doesn't return the last expression but the active
*evaluation* of the last expression.

>
> Why this might launch the Intellisense plugin.
> What can you look for to prevent this from happening?
>
> The getreg() call is actually part of another plugin (which just so happens
> to be mine, YankRing.vim).  I traced the call to it.
>
> TIA,
> Dave
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Strange issues with getreg('=')

Eric Arnold

--- Eric Arnold <[hidden email]> wrote:
> Remember accessing the expression register either with   getreg()   or
> by name   @=   doesn't return the last expression but the active
> *evaluation* of the last expression.

Well, I thought I did something(anything?) with   @=   once, but I
can't get  :let @a = @=  to assign @a to anything, either the last
expression OR the evaluation of the last expression.  getreg('=')  
works as described.