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.


Patch 8.1.1820

2019-08-05 Fir de Conversatie Bram Moolenaar


Patch 8.1.1820
Problem:Using expr->FuncRef() does not work.
Solution:   Make FuncRef work as a method.
Files:  src/eval.c, src/userfunc.c, src/testdir/test_method.vim


*** ../vim-8.1.1819/src/eval.c  2019-08-04 23:04:35.525945914 +0200
--- src/eval.c  2019-08-05 22:49:59.044167083 +0200
***
*** 3655,3660 
--- 3655,3728 
  }
  
  /*
+  * Handle a name followed by "(".  Both for just "name(arg)" and for
+  * "expr->name(arg)".
+  * Returns OK or FAIL.
+  */
+ static int
+ eval_func(
+   char_u  **arg,  // points to "(", will be advanced
+   char_u  *name,
+   int name_len,
+   typval_T*rettv,
+   int evaluate,
+   typval_T*basetv)// "expr" for "expr->name(arg)"
+ {
+ char_u*s = name;
+ int   len = name_len;
+ partial_T *partial;
+ int   ret = OK;
+ 
+ if (!evaluate)
+   check_vars(s, len);
+ 
+ /* If "s" is the name of a variable of type VAR_FUNC
+  * use its contents. */
+ s = deref_func_name(s, &len, &partial, !evaluate);
+ 
+ /* Need to make a copy, in case evaluating the arguments makes
+  * the name invalid. */
+ s = vim_strsave(s);
+ if (s == NULL)
+   ret = FAIL;
+ else
+ {
+   funcexe_T funcexe;
+ 
+   // Invoke the function.
+   vim_memset(&funcexe, 0, sizeof(funcexe));
+   funcexe.firstline = curwin->w_cursor.lnum;
+   funcexe.lastline = curwin->w_cursor.lnum;
+   funcexe.doesrange = &len;
+   funcexe.evaluate = evaluate;
+   funcexe.partial = partial;
+   funcexe.basetv = basetv;
+   ret = get_func_tv(s, len, rettv, arg, &funcexe);
+ }
+ vim_free(s);
+ 
+ /* If evaluate is FALSE rettv->v_type was not set in
+  * get_func_tv, but it's needed in handle_subscript() to parse
+  * what follows. So set it here. */
+ if (rettv->v_type == VAR_UNKNOWN && !evaluate && **arg == '(')
+ {
+   rettv->vval.v_string = NULL;
+   rettv->v_type = VAR_FUNC;
+ }
+ 
+ /* Stop the expression evaluation when immediately
+  * aborting on error, or when an interrupt occurred or
+  * an exception was thrown but not caught. */
+ if (evaluate && aborting())
+ {
+   if (ret == OK)
+   clear_tv(rettv);
+   ret = FAIL;
+ }
+ return ret;
+ }
+ 
+ /*
   * The "evaluate" argument: When FALSE, the argument is only parsed but not
   * executed.  The function may return OK, but the rettv will be of type
   * VAR_UNKNOWN.  The function still returns FAIL for a syntax error.
***
*** 4671,4725 
else
{
if (**arg == '(')   /* recursive! */
!   {
!   partial_T *partial;
! 
!   if (!evaluate)
!   check_vars(s, len);
! 
!   /* If "s" is the name of a variable of type VAR_FUNC
!* use its contents. */
!   s = deref_func_name(s, &len, &partial, !evaluate);
! 
!   /* Need to make a copy, in case evaluating the arguments makes
!* the name invalid. */
!   s = vim_strsave(s);
!   if (s == NULL)
!   ret = FAIL;
!   else
!   {
!   funcexe_T funcexe;
! 
!   // Invoke the function.
!   vim_memset(&funcexe, 0, sizeof(funcexe));
!   funcexe.firstline = curwin->w_cursor.lnum;
!   funcexe.lastline = curwin->w_cursor.lnum;
!   funcexe.doesrange = &len;
!   funcexe.evaluate = evaluate;
!   funcexe.partial = partial;
!   ret = get_func_tv(s, len, rettv, arg, &funcexe);
!   }
!   vim_free(s);
! 
!   /* If evaluate is FALSE rettv->v_type was not set in
!* get_func_tv, but it's needed in handle_subscript() to parse
!* what follows. So set it here. */
!   if (rettv->v_type == VAR_UNKNOWN && !evaluate && **arg == '(')
!   {
!   rettv->vval.v_string = NULL;
!   rettv->v_type = VAR_FUNC;
!   }
! 
!   /* Stop the expression evaluation when immediately
!* aborting on error, or when an interrupt occurred or
!* an exception was thrown but not caught. */
!   if (evaluate && aborting())
!   {
!   if (ret == OK)
!   clear_tv(rettv);
!   ret = FAIL;
!   }
!   }
else if (evaluate)
ret = get_var_tv(s, len, rettv, NULL, TRUE, FALSE);
else
--- 4739,4745 
else
{
if (**arg == '(')   /* recursive! */
!   ret = eval_func(arg, s, len, rettv, evaluate, NULL);
else if (evaluate)
ret = get_var_tv(s, len, rettv, NULL, TRU

Patch 8.1.1819

2019-08-05 Fir de Conversatie Bram Moolenaar


Patch 8.1.1819
Problem::pedit does not work with a popup preview window.
Solution:   Avoid aborting with an error. (fixes #4777)  Also double check
that after prepare_tagpreview() the current window is not a
popup window.
Files:  src/ex_docmd.c, src/popupmenu.c, src/search.c, src/tag.c,
src/testdir/test_popupwin.vim,
src/testdir/dumps/Test_popupwin_previewpopup_6.dump,
src/testdir/dumps/Test_popupwin_previewpopup_7.dump,
src/testdir/dumps/Test_popupwin_previewpopup_8.dump


*** ../vim-8.1.1818/src/ex_docmd.c  2019-08-04 15:30:12.202919941 +0200
--- src/ex_docmd.c  2019-08-05 20:28:51.493596761 +0200
***
*** 7083,7089 
  int   need_hide;
  int   exmode_was = exmode_active;
  
! if (ERROR_IF_POPUP_WINDOW)
return;
  /*
   * ":vi" command ends Ex mode.
--- 7083,7089 
  int   need_hide;
  int   exmode_was = exmode_active;
  
! if (eap->cmdidx != CMD_pedit && ERROR_IF_POPUP_WINDOW)
return;
  /*
   * ":vi" command ends Ex mode.
***
*** 8798,8806 
--- 8798,8808 
  
  g_do_tagpreview = p_pvh;
  prepare_tagpreview(TRUE);
+ 
  keep_help_flag = bt_help(curwin_save->w_buffer);
  do_exedit(eap, NULL);
  keep_help_flag = FALSE;
+ 
  if (curwin != curwin_save && win_valid(curwin_save))
  {
/* Return cursor to where we were */
***
*** 8808,8813 
--- 8810,8822 
redraw_later(VALID);
win_enter(curwin_save, TRUE);
  }
+ # ifdef FEAT_TEXT_PROP
+ else if (WIN_IS_POPUP(curwin))
+ {
+   // can't keep focus in popup window
+   win_enter(firstwin, TRUE);
+ }
+ # endif
  g_do_tagpreview = 0;
  }
  #endif
*** ../vim-8.1.1818/src/search.c2019-07-23 22:15:21.311518857 +0200
--- src/search.c2019-08-05 21:47:54.418987768 +0200
***
*** 5632,5637 
--- 5632,5642 
redraw_later(VALID);
win_enter(curwin_save, TRUE);
}
+ # ifdef FEAT_TEXT_PROP
+   else if (WIN_IS_POPUP(curwin))
+   // can't keep focus in popup window
+   win_enter(firstwin, TRUE);
+ # endif
  #endif
break;
}
*** ../vim-8.1.1818/src/tag.c   2019-08-04 20:42:39.811198885 +0200
--- src/tag.c   2019-08-05 20:49:39.277741614 +0200
***
*** 3693,3698 
--- 3693,3703 
}
  #endif
  }
+ #if defined(FEAT_QUICKFIX) && defined(FEAT_TEXT_PROP)
+ if (WIN_IS_POPUP(curwin))
+   // something went wrong, still in popup, but it can't have focus
+   win_enter(firstwin, TRUE);
+ #endif
  
  erret:
  #if defined(FEAT_QUICKFIX)
*** ../vim-8.1.1818/src/testdir/test_popupwin.vim   2019-08-04 
21:11:48.558856798 +0200
--- src/testdir/test_popupwin.vim   2019-08-05 21:50:14.718087405 +0200
***
*** 2174,2184 
  \ + ['this is another place']
  \ + range(29, 40),
  \ "Xtagfile")
let lines =<< trim END
  set tags=Xtags
call setline(1, [
  \ 'one',
! \ 'two',
  \ 'three',
  \ 'four',
  \ 'five',
--- 2174,2188 
  \ + ['this is another place']
  \ + range(29, 40),
  \ "Xtagfile")
+   call writefile(range(1,10)
+ \ + ['searched word is here']
+ \ + range(12, 20),
+ \ "Xheader.h")
let lines =<< trim END
  set tags=Xtags
call setline(1, [
  \ 'one',
! \ '#include "Xheader.h"',
  \ 'three',
  \ 'four',
  \ 'five',
***
*** 2189,2194 
--- 2193,2201 
  \ 'this is another word',
  \ 'very long line where the word is also another'])
  set previewpopup=height:4,width:40
+   set path=.
+   call ch_logfile('logfile', 'w')
+   call ch_log('logfile started')
END
call writefile(lines, 'XtestPreviewPopup')
let buf = RunVimInTerminal('-S XtestPreviewPopup', #{rows: 14})
***
*** 2209,2219 
--- 2216,2240 
  
call term_sendkeys(buf, ":cd ..\:\")
call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_5', {})
+   call term_sendkeys(buf, ":cd testdir\")
+ 
+   call term_sendkeys(buf, ":pclose\")
+   call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_6', {})
+ 
+   call term_sendkeys(buf, ":pedit +/theword Xtagfile\")
+   call term_sendkeys(buf, ":\")
+   call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_7', {})
+ 
+   call term_sendkeys(buf, ":pclose\")
+   call term_sendkeys(buf, ":psearch searched\")
+   call term_sendkeys(buf, ":\")
+   call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_8', {})
  
call StopVimInTerminal(buf)
call delete('Xtags')
call delete('Xtagfile')
call delete('XtestPreviewPopup')
+   call delete

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.1818

2019-08-05 Fir de Conversatie Bram Moolenaar


Patch 8.1.1818
Problem:Unused variable.
Solution:   Remove the variable. (Mike Williams)
Files:  src/sound.c


*** ../vim-8.1.1817/src/sound.c 2019-08-03 18:31:08.309893093 +0200
--- src/sound.c 2019-08-05 20:14:12.327620273 +0200
***
*** 228,234 
{
typval_Targv[3];
typval_Trettv;
-   int dummy;
charbuf[32];
  
vim_snprintf(buf, sizeof(buf), "close sound%06ld",
--- 228,233 
*** ../vim-8.1.1817/src/version.c   2019-08-04 23:22:05.028688178 +0200
--- src/version.c   2019-08-05 20:18:02.910579028 +0200
***
*** 775,776 
--- 775,778 
  {   /* Add new patch number below this line */
+ /**/
+ 1818,
  /**/

-- 
How To Keep A Healthy Level Of Insanity:
10. Ask people what sex they are. Laugh hysterically after they answer.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
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/201908051819.x75IJ75H018216%40masaka.moolenaar.net.