|
Karsten Hopp |
04f819 |
To: vim-dev@vim.org
|
|
Karsten Hopp |
04f819 |
Subject: Patch 7.2.266
|
|
Karsten Hopp |
04f819 |
Fcc: outbox
|
|
Karsten Hopp |
04f819 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
04f819 |
Mime-Version: 1.0
|
|
Karsten Hopp |
04f819 |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
04f819 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
04f819 |
------------
|
|
Karsten Hopp |
04f819 |
|
|
Karsten Hopp |
04f819 |
Patch 7.2.266
|
|
Karsten Hopp |
04f819 |
Problem: When an expression abbreviation is triggered, the typed character
|
|
Karsten Hopp |
04f819 |
is unknown.
|
|
Karsten Hopp |
04f819 |
Solution: Make the typed character available in v:char.
|
|
Karsten Hopp |
04f819 |
Files: runtime/doc/map.txt, src/eval.c, src/getchar.c, src/ops.c,
|
|
Karsten Hopp |
04f819 |
src/proto/eval.pro
|
|
Karsten Hopp |
04f819 |
|
|
Karsten Hopp |
04f819 |
|
|
Karsten Hopp |
04f819 |
*** ../vim-7.2.265/runtime/doc/map.txt 2008-08-09 19:36:49.000000000 +0200
|
|
Karsten Hopp |
04f819 |
--- runtime/doc/map.txt 2009-09-23 19:39:19.000000000 +0200
|
|
Karsten Hopp |
04f819 |
***************
|
|
Karsten Hopp |
04f819 |
*** 224,229 ****
|
|
Karsten Hopp |
04f819 |
--- 224,233 ----
|
|
Karsten Hopp |
04f819 |
The result of the InsertDot() function will be inserted. It could check the
|
|
Karsten Hopp |
04f819 |
text before the cursor and start omni completion when some condition is met.
|
|
Karsten Hopp |
04f819 |
|
|
Karsten Hopp |
04f819 |
+ For abbreviations |v:char| is set to the character that was typed to trigger
|
|
Karsten Hopp |
04f819 |
+ the abbreviation. You can use this to decide how to expand the {lhs}. You
|
|
Karsten Hopp |
04f819 |
+ can't change v:char and you should not insert it.
|
|
Karsten Hopp |
04f819 |
+
|
|
Karsten Hopp |
04f819 |
Be very careful about side effects! The expression is evaluated while
|
|
Karsten Hopp |
04f819 |
obtaining characters, you may very well make the command dysfunctional.
|
|
Karsten Hopp |
04f819 |
For this reason the following is blocked:
|
|
Karsten Hopp |
04f819 |
*** ../vim-7.2.265/src/eval.c 2009-06-03 14:25:47.000000000 +0200
|
|
Karsten Hopp |
04f819 |
--- src/eval.c 2009-09-23 19:36:32.000000000 +0200
|
|
Karsten Hopp |
04f819 |
***************
|
|
Karsten Hopp |
04f819 |
*** 18101,18106 ****
|
|
Karsten Hopp |
04f819 |
--- 18101,18131 ----
|
|
Karsten Hopp |
04f819 |
}
|
|
Karsten Hopp |
04f819 |
|
|
Karsten Hopp |
04f819 |
/*
|
|
Karsten Hopp |
04f819 |
+ * Set v:char to character "c".
|
|
Karsten Hopp |
04f819 |
+ */
|
|
Karsten Hopp |
04f819 |
+ void
|
|
Karsten Hopp |
04f819 |
+ set_vim_var_char(c)
|
|
Karsten Hopp |
04f819 |
+ int c;
|
|
Karsten Hopp |
04f819 |
+ {
|
|
Karsten Hopp |
04f819 |
+ #ifdef FEAT_MBYTE
|
|
Karsten Hopp |
04f819 |
+ char_u buf[MB_MAXBYTES];
|
|
Karsten Hopp |
04f819 |
+ #else
|
|
Karsten Hopp |
04f819 |
+ char_u buf[2];
|
|
Karsten Hopp |
04f819 |
+ #endif
|
|
Karsten Hopp |
04f819 |
+
|
|
Karsten Hopp |
04f819 |
+ #ifdef FEAT_MBYTE
|
|
Karsten Hopp |
04f819 |
+ if (has_mbyte)
|
|
Karsten Hopp |
04f819 |
+ buf[(*mb_char2bytes)(c, buf)] = NUL;
|
|
Karsten Hopp |
04f819 |
+ else
|
|
Karsten Hopp |
04f819 |
+ #endif
|
|
Karsten Hopp |
04f819 |
+ {
|
|
Karsten Hopp |
04f819 |
+ buf[0] = c;
|
|
Karsten Hopp |
04f819 |
+ buf[1] = NUL;
|
|
Karsten Hopp |
04f819 |
+ }
|
|
Karsten Hopp |
04f819 |
+ set_vim_var_string(VV_CHAR, buf, -1);
|
|
Karsten Hopp |
04f819 |
+ }
|
|
Karsten Hopp |
04f819 |
+
|
|
Karsten Hopp |
04f819 |
+ /*
|
|
Karsten Hopp |
04f819 |
* Set v:count to "count" and v:count1 to "count1".
|
|
Karsten Hopp |
04f819 |
* When "set_prevcount" is TRUE first set v:prevcount from v:count.
|
|
Karsten Hopp |
04f819 |
*/
|
|
Karsten Hopp |
04f819 |
*** ../vim-7.2.265/src/getchar.c 2009-07-14 13:44:43.000000000 +0200
|
|
Karsten Hopp |
04f819 |
--- src/getchar.c 2009-09-23 19:35:54.000000000 +0200
|
|
Karsten Hopp |
04f819 |
***************
|
|
Karsten Hopp |
04f819 |
*** 129,135 ****
|
|
Karsten Hopp |
04f819 |
static void validate_maphash __ARGS((void));
|
|
Karsten Hopp |
04f819 |
static void showmap __ARGS((mapblock_T *mp, int local));
|
|
Karsten Hopp |
04f819 |
#ifdef FEAT_EVAL
|
|
Karsten Hopp |
04f819 |
! static char_u *eval_map_expr __ARGS((char_u *str));
|
|
Karsten Hopp |
04f819 |
#endif
|
|
Karsten Hopp |
04f819 |
|
|
Karsten Hopp |
04f819 |
/*
|
|
Karsten Hopp |
04f819 |
--- 129,135 ----
|
|
Karsten Hopp |
04f819 |
static void validate_maphash __ARGS((void));
|
|
Karsten Hopp |
04f819 |
static void showmap __ARGS((mapblock_T *mp, int local));
|
|
Karsten Hopp |
04f819 |
#ifdef FEAT_EVAL
|
|
Karsten Hopp |
04f819 |
! static char_u *eval_map_expr __ARGS((char_u *str, int c));
|
|
Karsten Hopp |
04f819 |
#endif
|
|
Karsten Hopp |
04f819 |
|
|
Karsten Hopp |
04f819 |
/*
|
|
Karsten Hopp |
04f819 |
***************
|
|
Karsten Hopp |
04f819 |
*** 2446,2452 ****
|
|
Karsten Hopp |
04f819 |
if (tabuf.typebuf_valid)
|
|
Karsten Hopp |
04f819 |
{
|
|
Karsten Hopp |
04f819 |
vgetc_busy = 0;
|
|
Karsten Hopp |
04f819 |
! s = eval_map_expr(mp->m_str);
|
|
Karsten Hopp |
04f819 |
vgetc_busy = save_vgetc_busy;
|
|
Karsten Hopp |
04f819 |
}
|
|
Karsten Hopp |
04f819 |
else
|
|
Karsten Hopp |
04f819 |
--- 2446,2452 ----
|
|
Karsten Hopp |
04f819 |
if (tabuf.typebuf_valid)
|
|
Karsten Hopp |
04f819 |
{
|
|
Karsten Hopp |
04f819 |
vgetc_busy = 0;
|
|
Karsten Hopp |
04f819 |
! s = eval_map_expr(mp->m_str, NUL);
|
|
Karsten Hopp |
04f819 |
vgetc_busy = save_vgetc_busy;
|
|
Karsten Hopp |
04f819 |
}
|
|
Karsten Hopp |
04f819 |
else
|
|
Karsten Hopp |
04f819 |
***************
|
|
Karsten Hopp |
04f819 |
*** 4367,4375 ****
|
|
Karsten Hopp |
04f819 |
* abbreviation, but is not inserted into the input stream.
|
|
Karsten Hopp |
04f819 |
*/
|
|
Karsten Hopp |
04f819 |
j = 0;
|
|
Karsten Hopp |
04f819 |
- /* special key code, split up */
|
|
Karsten Hopp |
04f819 |
if (c != Ctrl_RSB)
|
|
Karsten Hopp |
04f819 |
{
|
|
Karsten Hopp |
04f819 |
if (IS_SPECIAL(c) || c == K_SPECIAL)
|
|
Karsten Hopp |
04f819 |
{
|
|
Karsten Hopp |
04f819 |
tb[j++] = K_SPECIAL;
|
|
Karsten Hopp |
04f819 |
--- 4367,4375 ----
|
|
Karsten Hopp |
04f819 |
* abbreviation, but is not inserted into the input stream.
|
|
Karsten Hopp |
04f819 |
*/
|
|
Karsten Hopp |
04f819 |
j = 0;
|
|
Karsten Hopp |
04f819 |
if (c != Ctrl_RSB)
|
|
Karsten Hopp |
04f819 |
{
|
|
Karsten Hopp |
04f819 |
+ /* special key code, split up */
|
|
Karsten Hopp |
04f819 |
if (IS_SPECIAL(c) || c == K_SPECIAL)
|
|
Karsten Hopp |
04f819 |
{
|
|
Karsten Hopp |
04f819 |
tb[j++] = K_SPECIAL;
|
|
Karsten Hopp |
04f819 |
***************
|
|
Karsten Hopp |
04f819 |
*** 4398,4404 ****
|
|
Karsten Hopp |
04f819 |
}
|
|
Karsten Hopp |
04f819 |
#ifdef FEAT_EVAL
|
|
Karsten Hopp |
04f819 |
if (mp->m_expr)
|
|
Karsten Hopp |
04f819 |
! s = eval_map_expr(mp->m_str);
|
|
Karsten Hopp |
04f819 |
else
|
|
Karsten Hopp |
04f819 |
#endif
|
|
Karsten Hopp |
04f819 |
s = mp->m_str;
|
|
Karsten Hopp |
04f819 |
--- 4398,4404 ----
|
|
Karsten Hopp |
04f819 |
}
|
|
Karsten Hopp |
04f819 |
#ifdef FEAT_EVAL
|
|
Karsten Hopp |
04f819 |
if (mp->m_expr)
|
|
Karsten Hopp |
04f819 |
! s = eval_map_expr(mp->m_str, c);
|
|
Karsten Hopp |
04f819 |
else
|
|
Karsten Hopp |
04f819 |
#endif
|
|
Karsten Hopp |
04f819 |
s = mp->m_str;
|
|
Karsten Hopp |
04f819 |
***************
|
|
Karsten Hopp |
04f819 |
*** 4434,4441 ****
|
|
Karsten Hopp |
04f819 |
* special characters.
|
|
Karsten Hopp |
04f819 |
*/
|
|
Karsten Hopp |
04f819 |
static char_u *
|
|
Karsten Hopp |
04f819 |
! eval_map_expr(str)
|
|
Karsten Hopp |
04f819 |
char_u *str;
|
|
Karsten Hopp |
04f819 |
{
|
|
Karsten Hopp |
04f819 |
char_u *res;
|
|
Karsten Hopp |
04f819 |
char_u *p;
|
|
Karsten Hopp |
04f819 |
--- 4434,4442 ----
|
|
Karsten Hopp |
04f819 |
* special characters.
|
|
Karsten Hopp |
04f819 |
*/
|
|
Karsten Hopp |
04f819 |
static char_u *
|
|
Karsten Hopp |
04f819 |
! eval_map_expr(str, c)
|
|
Karsten Hopp |
04f819 |
char_u *str;
|
|
Karsten Hopp |
04f819 |
+ int c; /* NUL or typed character for abbreviation */
|
|
Karsten Hopp |
04f819 |
{
|
|
Karsten Hopp |
04f819 |
char_u *res;
|
|
Karsten Hopp |
04f819 |
char_u *p;
|
|
Karsten Hopp |
04f819 |
***************
|
|
Karsten Hopp |
04f819 |
*** 4452,4457 ****
|
|
Karsten Hopp |
04f819 |
--- 4453,4459 ----
|
|
Karsten Hopp |
04f819 |
#ifdef FEAT_EX_EXTRA
|
|
Karsten Hopp |
04f819 |
++ex_normal_lock;
|
|
Karsten Hopp |
04f819 |
#endif
|
|
Karsten Hopp |
04f819 |
+ set_vim_var_char(c); /* set v:char to the typed character */
|
|
Karsten Hopp |
04f819 |
save_cursor = curwin->w_cursor;
|
|
Karsten Hopp |
04f819 |
p = eval_to_string(str, NULL, FALSE);
|
|
Karsten Hopp |
04f819 |
--textlock;
|
|
Karsten Hopp |
04f819 |
*** ../vim-7.2.265/src/ops.c 2009-07-01 18:04:30.000000000 +0200
|
|
Karsten Hopp |
04f819 |
--- src/ops.c 2009-09-23 19:11:40.000000000 +0200
|
|
Karsten Hopp |
04f819 |
***************
|
|
Karsten Hopp |
04f819 |
*** 4473,4483 ****
|
|
Karsten Hopp |
04f819 |
int use_sandbox = was_set_insecurely((char_u *)"formatexpr",
|
|
Karsten Hopp |
04f819 |
OPT_LOCAL);
|
|
Karsten Hopp |
04f819 |
int r;
|
|
Karsten Hopp |
04f819 |
- #ifdef FEAT_MBYTE
|
|
Karsten Hopp |
04f819 |
- char_u buf[MB_MAXBYTES];
|
|
Karsten Hopp |
04f819 |
- #else
|
|
Karsten Hopp |
04f819 |
- char_u buf[2];
|
|
Karsten Hopp |
04f819 |
- #endif
|
|
Karsten Hopp |
04f819 |
|
|
Karsten Hopp |
04f819 |
/*
|
|
Karsten Hopp |
04f819 |
* Set v:lnum to the first line number and v:count to the number of lines.
|
|
Karsten Hopp |
04f819 |
--- 4473,4478 ----
|
|
Karsten Hopp |
04f819 |
***************
|
|
Karsten Hopp |
04f819 |
*** 4485,4501 ****
|
|
Karsten Hopp |
04f819 |
*/
|
|
Karsten Hopp |
04f819 |
set_vim_var_nr(VV_LNUM, lnum);
|
|
Karsten Hopp |
04f819 |
set_vim_var_nr(VV_COUNT, count);
|
|
Karsten Hopp |
04f819 |
!
|
|
Karsten Hopp |
04f819 |
! #ifdef FEAT_MBYTE
|
|
Karsten Hopp |
04f819 |
! if (has_mbyte)
|
|
Karsten Hopp |
04f819 |
! buf[(*mb_char2bytes)(c, buf)] = NUL;
|
|
Karsten Hopp |
04f819 |
! else
|
|
Karsten Hopp |
04f819 |
! #endif
|
|
Karsten Hopp |
04f819 |
! {
|
|
Karsten Hopp |
04f819 |
! buf[0] = c;
|
|
Karsten Hopp |
04f819 |
! buf[1] = NUL;
|
|
Karsten Hopp |
04f819 |
! }
|
|
Karsten Hopp |
04f819 |
! set_vim_var_string(VV_CHAR, buf, -1);
|
|
Karsten Hopp |
04f819 |
|
|
Karsten Hopp |
04f819 |
/*
|
|
Karsten Hopp |
04f819 |
* Evaluate the function.
|
|
Karsten Hopp |
04f819 |
--- 4480,4486 ----
|
|
Karsten Hopp |
04f819 |
*/
|
|
Karsten Hopp |
04f819 |
set_vim_var_nr(VV_LNUM, lnum);
|
|
Karsten Hopp |
04f819 |
set_vim_var_nr(VV_COUNT, count);
|
|
Karsten Hopp |
04f819 |
! set_vim_var_char(c);
|
|
Karsten Hopp |
04f819 |
|
|
Karsten Hopp |
04f819 |
/*
|
|
Karsten Hopp |
04f819 |
* Evaluate the function.
|
|
Karsten Hopp |
04f819 |
*** ../vim-7.2.265/src/proto/eval.pro 2008-11-20 16:11:03.000000000 +0100
|
|
Karsten Hopp |
04f819 |
--- src/proto/eval.pro 2009-09-23 19:36:30.000000000 +0200
|
|
Karsten Hopp |
04f819 |
***************
|
|
Karsten Hopp |
04f819 |
*** 61,66 ****
|
|
Karsten Hopp |
04f819 |
--- 61,67 ----
|
|
Karsten Hopp |
04f819 |
long get_vim_var_nr __ARGS((int idx));
|
|
Karsten Hopp |
04f819 |
char_u *get_vim_var_str __ARGS((int idx));
|
|
Karsten Hopp |
04f819 |
list_T *get_vim_var_list __ARGS((int idx));
|
|
Karsten Hopp |
04f819 |
+ void set_vim_var_char __ARGS((int c));
|
|
Karsten Hopp |
04f819 |
void set_vcount __ARGS((long count, long count1, int set_prevcount));
|
|
Karsten Hopp |
04f819 |
void set_vim_var_string __ARGS((int idx, char_u *val, int len));
|
|
Karsten Hopp |
04f819 |
void set_vim_var_list __ARGS((int idx, list_T *val));
|
|
Karsten Hopp |
04f819 |
*** ../vim-7.2.265/src/version.c 2009-09-30 13:23:57.000000000 +0200
|
|
Karsten Hopp |
04f819 |
--- src/version.c 2009-09-30 15:11:29.000000000 +0200
|
|
Karsten Hopp |
04f819 |
***************
|
|
Karsten Hopp |
04f819 |
*** 678,679 ****
|
|
Karsten Hopp |
04f819 |
--- 678,681 ----
|
|
Karsten Hopp |
04f819 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
04f819 |
+ /**/
|
|
Karsten Hopp |
04f819 |
+ 266,
|
|
Karsten Hopp |
04f819 |
/**/
|
|
Karsten Hopp |
04f819 |
|
|
Karsten Hopp |
04f819 |
--
|
|
Karsten Hopp |
04f819 |
Life would be so much easier if we could just look at the source code.
|
|
Karsten Hopp |
04f819 |
|
|
Karsten Hopp |
04f819 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
04f819 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
04f819 |
\\\ download, build and distribute -- http://www.A-A-P.org ///
|
|
Karsten Hopp |
04f819 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|