Re: Patch 8.1.1510

2019-08-05 Fir de Conversatie Yegappan Lakshmanan
Hi Andy,

On Mon, Aug 5, 2019 at 11:53 AM 'Andy Wokula' via vim_dev
 wrote:
>
> Am 09.06.2019 um 17:22 schrieb Bram Moolenaar:
> > Patch 8.1.1510
> > Problem:A plugin cannot easily expand a command like done internally.
> > Solution:   Add the expandcmd() function. (Yegappan Lakshmanan, closes 
> > #4514)
> > Files:runtime/doc/eval.txt, runtime/doc/usr_41.txt, 
> > src/evalfunc.c,
> >  src/testdir/test_expand.vim
>
> "cannot easily" is not true I think:
>
>
> func! ExpandCmd(args)
>  exec 'NwoExpand '. a:args
> endfunc
>
> " Internal:
> com! -nargs=? -complete=file NwoExpand return 
>
>
> "cannot nicely" may hit it better because of the internal command.
> This side effect of file completion was undocumented.
> Works for Vim 7.0.
>
> Not sure if it really does the same as expandcmd().
>

Your solution is similar to the expand() function used by the dispatch
plugin 
(https://github.com/tpope/vim-dispatch/blob/master/autoload/dispatch.vim).
Your solution is simpler than the one used by the dispatch plugin.
But the Vim plugins have to use this as a workaround to expand the
wildcards anywhere in the command-line instead of a native solution.

Regards,
Yegappan

-- 
-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7n1e%3DMRP1QQPkt5QN4-NcrKDPdUTDrJdWT7yFxHEwQ4Ow%40mail.gmail.com.


Re: Patch 8.1.1510

2019-08-05 Fir de Conversatie 'Andy Wokula' via vim_dev

Am 09.06.2019 um 17:22 schrieb Bram Moolenaar:

Patch 8.1.1510
Problem:A plugin cannot easily expand a command like done internally.
Solution:   Add the expandcmd() function. (Yegappan Lakshmanan, closes #4514)
Files:  runtime/doc/eval.txt, runtime/doc/usr_41.txt, src/evalfunc.c,
 src/testdir/test_expand.vim


"cannot easily" is not true I think:


func! ExpandCmd(args)
exec 'NwoExpand '. a:args
endfunc

" Internal:
com! -nargs=? -complete=file NwoExpand return 


"cannot nicely" may hit it better because of the internal command.
This side effect of file completion was undocumented.
Works for Vim 7.0.

Not sure if it really does the same as expandcmd().

--
Andy

--
--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/5D487B35.600%40yahoo.de.


Patch 8.1.1510

2019-06-09 Fir de Conversatie Bram Moolenaar


Patch 8.1.1510
Problem:A plugin cannot easily expand a command like done internally.
Solution:   Add the expandcmd() function. (Yegappan Lakshmanan, closes #4514)
Files:  runtime/doc/eval.txt, runtime/doc/usr_41.txt, src/evalfunc.c,
src/testdir/test_expand.vim


*** ../vim-8.1.1509/runtime/doc/eval.txt2019-06-09 13:42:36.428522167 
+0200
--- runtime/doc/eval.txt2019-06-09 17:06:36.603194124 +0200
***
*** 2325,2330 
--- 2326,2332 
  exp({expr})   Float   exponential of {expr}
  expand({expr} [, {nosuf} [, {list}]])
any expand special keywords in {expr}
+ expandcmd({expr}) String  expand {expr} like with `:edit`
  feedkeys({string} [, {mode}]) Number  add key sequence to typeahead buffer
  filereadable({file})  Number  |TRUE| if {file} is a readable file
  filewritable({file})  Number  |TRUE| if {file} is a writable file
***
*** 4217,4222 
--- 4219,4232 
See |glob()| for finding existing files.  See |system()| for
getting the raw output of an external command.
  
+ expandcmd({expr}) *expandcmd()*
+   Expand special items in {expr} like what is done for an Ex
+   command such as `:edit`.  This expands special keywords, like
+   with |expand()|, and environment variables, anywhere in
+   {expr}.  Returns the expanded string.
+   Example: >
+   :echo expandcmd('make %<.o')
+ <
  extend({expr1}, {expr2} [, {expr3}])  *extend()*
{expr1} and {expr2} must be both |Lists| or both
|Dictionaries|.
*** ../vim-8.1.1509/runtime/doc/usr_41.txt  2019-05-11 21:14:02.332269584 
+0200
--- runtime/doc/usr_41.txt  2019-06-09 17:07:15.550875139 +0200
***
*** 608,619 
--- 609,622 
strcharpart()   get part of a string using char index
strgetchar()get character from a string using char index
expand()expand special keywords
+   expandcmd() expand a command like done for `:edit`
iconv() convert text from one encoding to another
byteidx()   byte index of a character in a string
byteidxcomp()   like byteidx() but count composing characters
repeat()repeat a string multiple times
eval()  evaluate a string expression
execute()   execute an Ex command and get the output
+   win_execute()   like execute() but in a specified window
trim()  trim characters from a string
  
  List manipulation:*list-functions*
***
*** 813,818 
--- 816,822 
appendbufline() append a list of lines in the specified buffer
deletebufline() delete lines from a specified buffer
listener_add()  add a callback to listen to changes
+   listener_flush()invoke listener callbacks
listener_remove()   remove a listener callback
win_findbuf()   find windows containing a buffer
win_getid() get window ID of a window
*** ../vim-8.1.1509/src/evalfunc.c  2019-06-09 13:42:36.428522167 +0200
--- src/evalfunc.c  2019-06-09 17:14:51.367682702 +0200
***
*** 149,154 
--- 149,155 
  static void f_exp(typval_T *argvars, typval_T *rettv);
  #endif
  static void f_expand(typval_T *argvars, typval_T *rettv);
+ static void f_expandcmd(typval_T *argvars, typval_T *rettv);
  static void f_extend(typval_T *argvars, typval_T *rettv);
  static void f_feedkeys(typval_T *argvars, typval_T *rettv);
  static void f_filereadable(typval_T *argvars, typval_T *rettv);
***
*** 646,651 
--- 647,653 
  {"exp",   1, 1, f_exp},
  #endif
  {"expand",1, 3, f_expand},
+ {"expandcmd", 1, 1, f_expandcmd},
  {"extend",2, 3, f_extend},
  {"feedkeys",  1, 2, f_feedkeys},
  {"file_readable", 1, 1, f_filereadable},  /* obsolete */
***
*** 3791,3796 
--- 3793,3827 
  }
  
  /*
+  * "expandcmd()" function
+  * Expand all the special characters in a command string.
+  */
+ static void
+ f_expandcmd(typval_T *argvars, typval_T *rettv)
+ {
+ exarg_T   eap;
+ char_u*cmdstr;
+ char  *errormsg = NULL;
+ 
+ rettv->v_type = VAR_STRING;
+ cmdstr = vim_strsave(tv_get_string(&argvars[0]));
+ 
+ memset(&eap, 0, sizeof(eap));
+ eap.cmd = cmdstr;
+ eap.arg = cmdstr;
+ eap.argt |= NOSPC;
+ eap.usefilter = FALSE;
+ eap.nextcmd = NULL;
+ eap.cmdidx = CMD_USER;
+ 
+ exp