Patch 8.0.1090
Problem: cannot get the text under the cursor like v:beval_text
Solution: Add <cexpr>.
Files: src/ex_docmd.c, src/testdir/test_normal.vim,
runtime/doc/cmdline.txt
*** ../vim-8.0.1089/src/ex_docmd.c 2017-09-10 17:34:30.378823252 +0200
--- src/ex_docmd.c 2017-09-10 17:50:58.748842944 +0200
***************
*** 10650,10680 ****
"%",
#define SPEC_PERC 0
"#",
! #define SPEC_HASH 1
"<cword>", /* cursor word */
! #define SPEC_CWORD 2
"<cWORD>", /* cursor WORD */
! #define SPEC_CCWORD 3
"<cfile>", /* cursor path name */
! #define SPEC_CFILE 4
"<sfile>", /* ":so" file name */
! #define SPEC_SFILE 5
"<slnum>", /* ":so" file line number */
! #define SPEC_SLNUM 6
#ifdef FEAT_AUTOCMD
"<afile>", /* autocommand file name */
! # define SPEC_AFILE 7
"<abuf>", /* autocommand buffer number */
! # define SPEC_ABUF 8
"<amatch>", /* autocommand match name */
! # define SPEC_AMATCH 9
#endif
#ifdef FEAT_CLIENTSERVER
"<client>"
# ifdef FEAT_AUTOCMD
! # define SPEC_CLIENT 10
# else
! # define SPEC_CLIENT 7
# endif
#endif
};
--- 10650,10682 ----
"%",
#define SPEC_PERC 0
"#",
! #define SPEC_HASH (SPEC_PERC + 1)
"<cword>", /* cursor word */
! #define SPEC_CWORD (SPEC_HASH + 1)
"<cWORD>", /* cursor WORD */
! #define SPEC_CCWORD (SPEC_CWORD + 1)
! "<cexpr>", /* expr under cursor */
! #define SPEC_CEXPR (SPEC_CCWORD + 1)
"<cfile>", /* cursor path name */
! #define SPEC_CFILE (SPEC_CEXPR + 1)
"<sfile>", /* ":so" file name */
! #define SPEC_SFILE (SPEC_CFILE + 1)
"<slnum>", /* ":so" file line number */
! #define SPEC_SLNUM (SPEC_SFILE + 1)
#ifdef FEAT_AUTOCMD
"<afile>", /* autocommand file name */
! # define SPEC_AFILE (SPEC_SLNUM + 1)
"<abuf>", /* autocommand buffer number */
! # define SPEC_ABUF (SPEC_AFILE + 1)
"<amatch>", /* autocommand match name */
! # define SPEC_AMATCH (SPEC_ABUF + 1)
#endif
#ifdef FEAT_CLIENTSERVER
"<client>"
# ifdef FEAT_AUTOCMD
! # define SPEC_CLIENT (SPEC_AMATCH + 1)
# else
! # define SPEC_CLIENT (SPEC_SLNUM + 1)
# endif
#endif
};
***************
*** 10762,10771 ****
/*
* word or WORD under cursor
*/
! if (spec_idx == SPEC_CWORD || spec_idx == SPEC_CCWORD)
{
! resultlen = find_ident_under_cursor(&result, spec_idx == SPEC_CWORD ?
! (FIND_IDENT|FIND_STRING) : FIND_STRING);
if (resultlen == 0)
{
*errormsg = (char_u *)"";
--- 10764,10776 ----
/*
* word or WORD under cursor
*/
! if (spec_idx == SPEC_CWORD || spec_idx == SPEC_CCWORD
! || spec_idx == SPEC_CEXPR)
{
! resultlen = find_ident_under_cursor(&result,
! spec_idx == SPEC_CWORD ? (FIND_IDENT | FIND_STRING)
! : spec_idx == SPEC_CEXPR ? (FIND_IDENT | FIND_STRING | FIND_EVAL)
! : FIND_STRING);
if (resultlen == 0)
{
*errormsg = (char_u *)"";
*** ../vim-8.0.1089/src/testdir/test_normal.vim 2017-04-09 14:58:11.653002677
+0200
--- src/testdir/test_normal.vim 2017-09-10 18:01:48.185005534 +0200
***************
*** 389,398 ****
call setline(1, ['1', 'ifooar,,cbar'])
2
norm! $
! let a=expand('<cword>')
! let b=expand('<cWORD>')
! call assert_equal('cbar', a)
! call assert_equal('ifooar,,cbar', b)
" clean up
bw!
endfunc
--- 389,410 ----
call setline(1, ['1', 'ifooar,,cbar'])
2
norm! $
! call assert_equal('cbar', expand('<cword>'))
! call assert_equal('ifooar,,cbar', expand('<cWORD>'))
!
! call setline(1, ['prx = list[idx];'])
! 1
! let expected = ['', 'prx', 'prx', 'prx',
! \ 'list', 'list', 'list', 'list', 'list', 'list', 'list',
! \ 'idx', 'idx', 'idx', 'idx',
! \ 'list[idx]',
! \ '];',
! \ ]
! for i in range(1, 16)
! exe 'norm ' . i . '|'
! call assert_equal(expected[i], expand('<cexpr>'), 'i == ' . i)
! endfor
!
" clean up
bw!
endfunc
*** ../vim-8.0.1089/runtime/doc/cmdline.txt 2016-12-01 17:57:40.779167445
+0100
--- runtime/doc/cmdline.txt 2017-09-10 18:14:01.624553911 +0200
***************
*** 826,831 ****
--- 830,840 ----
Note: these are typed literally, they are not special keys!
<cword> is replaced with the word under the cursor (like |star|)
<cWORD> is replaced with the WORD under the cursor (see |WORD|)
+ <cexpr> is replaced with the word under the cursor, including more
+ to form a C expression. E.g., when the cursor is on "arg"
+ of "ptr->arg" then the result is "ptr->arg"; when the
+ cursor is on "]" of "list[idx]" then the result is
+ "list[idx]". This is used for |v:beval_text|.
<cfile> is replaced with the path name under the cursor (like what
|gf| uses)
<afile> When executing autocommands, is replaced with the file name
*** ../vim-8.0.1089/src/version.c 2017-09-10 17:34:30.378823252 +0200
--- src/version.c 2017-09-10 17:45:28.862768973 +0200
***************
*** 771,772 ****
--- 771,774 ----
{ /* Add new patch number below this line */
+ /**/
+ 1090,
/**/
--
>From "know your smileys":
<|-) Chinese
<|-( Chinese and doesn't like these kind of jokes
/// Bram Moolenaar -- [email protected] -- 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 [email protected].
For more options, visit https://groups.google.com/d/optout.