Hi, On Fri, Aug 28, 2020 at 6:49 AM lacygoill <[email protected]> wrote:
> @yegappan <https://github.com/yegappan> Thank you for implementing > expandcmd(). I would like to use it but I have 2 questions: > > Would it make sense for the function to also expand // into /last search > pattern/? > > https://github.com/vim/vim/blob/7a3330fc578033f06a94c23de61a23edcc59f95e/runtime/doc/quickfix.txt#L1026-L1027 > > As an example, it could perform this expansion: > > /my pattern > :echo expandcmd('vim //gj %') > vim /my pattern/gj current_file > > The expandcmd() function expands the special characters listed under ":h cmdline-special". As the empty search pattern (//) is not a special character, it won't be expanded. Just like how commands like 'vimgrep' handle the empty search pattern and replace it with the last search pattern, the command itself should handle the argument. ------------------------------ > > Also, expandcmd() does not escape special characters when they're > generated by an expansion (e.g. a filename containing the literal character > %). For %, #, !, I guess it's not an issue, because we can use > fnameescape(); but for spaces, it's different: > > $ vim /tmp/foo\ bar/baz > :echo expandcmd('vim /pat/ %') > > vim /pat/ /tmp/foo bar/baz > > In the expansion, how can we know whether the original command was > grepping into the file /tmp/foo bar/baz, or in the files /tmp/foo and > $PWD/bar/baz? > > Shouldn't expandcmd() at least escape a space when it's used in a > filename? > > vim /pat/ /tmp/foo\ bar/baz > ^ > > > I think you can use the ":S" filename modifier to escape the special characters in the file name. - 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/CAAW7x7%3DYd8_7%3DSLiKBT%3DT9COFDKp3E5E9DRus3NUMKiLPk6DZg%40mail.gmail.com.
