Skip to content

Instantly share code, notes, and snippets.

@tyru
Last active November 11, 2018 09:59
Show Gist options
  • Save tyru/ccaff001f3af31e42267f5a0c5693541 to your computer and use it in GitHub Desktop.
Save tyru/ccaff001f3af31e42267f5a0c5693541 to your computer and use it in GitHub Desktop.
diff --git a/src/eval.c b/src/eval.c
index 4a3cf9912..cdb1d2f4e 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -8109,6 +8109,7 @@ ex_echohl(exarg_T *eap)
ex_execute(exarg_T *eap)
{
char_u *arg = eap->arg;
+ char_u *trans_arg;
typval_T rettv;
int ret = OK;
char_u *p;
@@ -8120,6 +8121,27 @@ ex_execute(exarg_T *eap)
if (eap->skip)
++emsg_skip;
+
+ /*
+ * Change <SNR> in the middle of argument.
+ * NOTE: If arg starts with "<SNR>", eval1() changes it.
+ */
+ p = vim_strsave(arg);
+ trans_arg = p;
+ while (*p != NUL && *p != '|' && *p != '\n')
+ {
+ if (p[0] == '<' && STRNCMP(p, "<SNR>", 5) == 0)
+ {
+ /* Change "<SNR>" to the byte sequence. */
+ p[0] = K_SPECIAL;
+ p[1] = KS_EXTRA;
+ p[2] = (int)KE_SNR;
+ mch_memmove(p + 3, p + 5, STRLEN(p + 5) + 1);
+ }
+ p++;
+ }
+ arg = trans_arg;
+
while (*arg != NUL && *arg != '|' && *arg != '\n')
{
p = arg;
@@ -8190,6 +8212,8 @@ ex_execute(exarg_T *eap)
--emsg_skip;
eap->nextcmd = check_nextcmd(arg);
+
+ vim_free(trans_arg);
}
/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment