Patch 8.2.4740
Problem:    When expand() fails there is no error message.
Solution:   When 'verbose' is set give an error message.
Files:      runtime/doc/builtin.txt, src/evalfunc.c,
            src/testdir/test_expand.vim


*** ../vim-8.2.4739/runtime/doc/builtin.txt     2022-04-03 21:30:25.022559205 
+0100
--- runtime/doc/builtin.txt     2022-04-12 12:42:19.223839133 +0100
***************
*** 2262,2267 ****
--- 2272,2280 ----
                is not defined, an empty string is used.  Using "%:p" in a
                buffer with no name, results in the current directory, with a
                '/' added.
+               When 'verbose' is set then expanding '%', '#' and <> items
+               will result in an error message if the argument cannot be
+               expanded.
  
                When {string} does not start with '%', '#' or '<', it is
                expanded like a file name is expanded on the command line.
*** ../vim-8.2.4739/src/evalfunc.c      2022-04-10 17:59:23.343015280 +0100
--- src/evalfunc.c      2022-04-12 12:39:25.363957727 +0100
***************
*** 4065,4071 ****
  {
      char_u    *s;
      int               len;
-     char      *errormsg;
      int               options = WILD_SILENT|WILD_USE_NL|WILD_LIST_NOTFOUND;
      expand_T  xpc;
      int               error = FALSE;
--- 4065,4070 ----
***************
*** 4096,4104 ****
      s = tv_get_string(&argvars[0]);
      if (*s == '%' || *s == '#' || *s == '<')
      {
!       ++emsg_off;
        result = eval_vars(s, s, &len, NULL, &errormsg, NULL);
!       --emsg_off;
        if (rettv->v_type == VAR_LIST)
        {
            if (rettv_list_alloc(rettv) != FAIL && result != NULL)
--- 4095,4109 ----
      s = tv_get_string(&argvars[0]);
      if (*s == '%' || *s == '#' || *s == '<')
      {
!       char    *errormsg = NULL;
! 
!       if (p_verbose == 0)
!           ++emsg_off;
        result = eval_vars(s, s, &len, NULL, &errormsg, NULL);
!       if (p_verbose == 0)
!           --emsg_off;
!       else if (errormsg != NULL)
!           emsg(errormsg);
        if (rettv->v_type == VAR_LIST)
        {
            if (rettv_list_alloc(rettv) != FAIL && result != NULL)
*** ../vim-8.2.4739/src/testdir/test_expand.vim 2022-04-09 21:41:22.266689586 
+0100
--- src/testdir/test_expand.vim 2022-04-12 12:52:01.456903531 +0100
***************
*** 128,140 ****
      :call assert_equal('edit <cword>', expandcmd("edit <cword>"))
      :call assert_equal('edit <cexpr>', expandcmd("edit <cexpr>"))
      :call assert_fails('autocmd User MyCmd echo "<sfile>"', 'E498:')
      :call writefile(v:errors, 'Xresult')
      :qall!
- 
    [SCRIPT]
    call writefile(lines, 'Xscript')
    if RunVim([], [], '--clean -s Xscript')
!     call assert_equal([], readfile('Xresult'))
    endif
    call delete('Xscript')
    call delete('Xresult')
--- 128,148 ----
      :call assert_equal('edit <cword>', expandcmd("edit <cword>"))
      :call assert_equal('edit <cexpr>', expandcmd("edit <cexpr>"))
      :call assert_fails('autocmd User MyCmd echo "<sfile>"', 'E498:')
+     :
+     :call assert_equal('', expand('<script>'))
+     :verbose echo expand('<script>')
+     :call add(v:errors, v:errmsg)
+     :verbose echo expand('<sfile>')
+     :call add(v:errors, v:errmsg)
      :call writefile(v:errors, 'Xresult')
      :qall!
    [SCRIPT]
    call writefile(lines, 'Xscript')
    if RunVim([], [], '--clean -s Xscript')
!     call assert_equal([
!           \ 'E1274: No script file name to substitute for "<script>"',
!           \ 'E498: no :source file name to substitute for "<sfile>"'],
!           \ readfile('Xresult'))
    endif
    call delete('Xscript')
    call delete('Xresult')
*** ../vim-8.2.4739/src/version.c       2022-04-12 11:32:41.428327316 +0100
--- src/version.c       2022-04-12 12:40:52.683898299 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4740,
  /**/

-- 
   A village.  Sound of chanting of Latin canon, punctuated by short, sharp
   cracks.  It comes nearer.  We see it is a line of MONKS ala SEVENTH SEAL
   flagellation scene, chanting and banging themselves on the foreheads with
   wooden boards.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220412115441.8AD6F1C08E1%40moolenaar.net.

Raspunde prin e-mail lui