To: vim_dev@googlegroups.com Subject: Patch 8.2.4740 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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 ', expandcmd("edit ")) :call assert_equal('edit ', expandcmd("edit ")) :call assert_fails('autocmd User MyCmd echo ""', '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 ', expandcmd("edit ")) :call assert_equal('edit ', expandcmd("edit ")) :call assert_fails('autocmd User MyCmd echo ""', 'E498:') + : + :call assert_equal('', expand('