Loading ...
Sorry, an error occurred while loading the content.

76175Re: Patch 7.4.264

Expand Messages
  • Alex Efros
    Apr 24, 2014
    • 0 Attachment
      Hi!

      On Thu, Apr 24, 2014 at 12:43:01PM +0200, Bram Moolenaar wrote:
      > > Me, too. The following used to work:
      > >
      > > fun! Foo()
      > > endfun
      > > let g:Foo = function('Foo')
      > >
      > > After 7.4.264, I get:
      > > " E705: Variable name conflicts with existing function: g:Foo
      >
      > That is correct. Previously Foo() and g:Foo were different names, which
      > is wrong. Both refer to the same function.

      So, what is the right way to implement this, compatible with pre-patch-260
      and current one? I wanna use global variable to define user-configurable
      handler function, and I've in my plugin code exactly as shown above.
      My plugin uses exists() and type() for testing value of that global
      variable, and they return different results for g:Foo in cases
      fun g:Foo()
      endfun
      and
      fun Foo()
      endfun
      let g:Foo = function('Foo')
      That's why such let operation was added.

      My guess right solution should be
      fun s:Foo()
      endfun
      let g:Foo = function('s:Foo')
      but I'm not 100% sure.

      Also in my plugin I allow users to use symbolic funcref for their custom
      handlers:
      fun MyHandler()
      endfun
      let g:Handler = 'MyHandler'
      by using type() to detect is variable contains text and then converting it
      to real funcref using exists('*MyHandler') and then function('MyHandler) -
      is this logic still correct after patch 265? Real code is here:
      https://code.google.com/p/vim-plugin-viewdoc/source/browse/plugin/viewdoc.vim#181


      P.S. One more difference between fun g:Foo and let g:Foo=function() is
      while auto-complete 'Foo<Tab>' in command line - first case shown as
      'Foo(', second as 'Foo' - maybe it makes sense to detect variables with
      funcref values and show them with '(' in autocomplete too?

      --
      WBR, Alex.

      --
      --
      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 vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/d/optout.
    • Show all 22 messages in this topic