On Wednesday, February 11, 2015 at 11:58:24 AM UTC-6, Enno wrote:
> > Actually, the problem has nothing to do with the 'secure' option. Setting 
> > nosecure gives the same result, if I correct your mapping:
> > 
> > xnoremap <expr> * "\<Esc>/".GetVis()."\<CR>"
> > 
> > The problem is not 'secure' but rather the fact that you're using :normal 
> > inside an <expr> mapping. :help :map-<expr> says: 
> > 
> > > Be very careful about side effects!  The expression is evaluated while
> > > obtaining characters, you may very well make the command dysfunctional.
> > > For this reason the following is blocked:
> > > - Changing the buffer text |textlock|.
> > > - Editing another buffer.
> > > - The |:normal| command.
> > 
> > This alternate mapping works fine (although it is admittedly not as 
> > elegant):
> > 
> > xnoremap * <Esc>/<C-R>=GetVis()<CR><CR>
> 
> Yeah, 
> 
> I thought that too, almost. That's where the deleted message above comes from.
> 
> However, then I found out that it is rather the place of definition of 
> GetVis().
> 
> The mapping
> 
> xnoremap <expr> * '/'.grep#GetVis() . '<CR>'
> 
> still gives, once `viw*` is hit the error message
> 
> Error detected while processing function grep#GetVis:
> line    2:
> E523: Not allowed here
> 
> as long as you use grep#GetVis() defined in ~/.vim/autoload/grep.vim 
> and NOT a global function GetVis().

Yes, because as I said, ":normal" is not allowed in any <expr> mapping.

In what way does it depend on using an autoload function?

Using :normal in an expression mapping should *always* fail, regardless of the 
'secure' setting or function definition.

Use the expression-register method instead, and it should work fine.

-- 
-- 
You received this message from the "vim_use" 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_use" 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.

Reply via email to