diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-03-09 23:14:07 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-03-09 23:14:07 +0100 |
commit | 29fd03878c41526a586d77b3f3cd7938d26297af (patch) | |
tree | 4457df959faca15aa580deca111a62a4b179c675 /src/eval.c | |
parent | af1a0e371e739f8dff337fd31da0ff8ffb347b43 (diff) |
patch 7.4.1529v7.4.1529
Problem: Specifying buffer number for channel not implemented yet.
Solution: Implement passing a buffer number.
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/src/eval.c b/src/eval.c index 31c5ea2da9..825a606a70 100644 --- a/src/eval.c +++ b/src/eval.c @@ -10119,6 +10119,27 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported) opt->jo_io_name[part] = get_tv_string_buf_chk(item, opt->jo_io_name_buf[part]); } + else if (STRCMP(hi->hi_key, "in-buf") == 0 + || STRCMP(hi->hi_key, "out-buf") == 0 + || STRCMP(hi->hi_key, "err-buf") == 0) + { + part = part_from_char(*hi->hi_key); + + if (!(supported & JO_OUT_IO)) + break; + opt->jo_set |= JO_OUT_BUF << (part - PART_OUT); + opt->jo_io_buf[part] = get_tv_number(item); + if (opt->jo_io_buf[part] <= 0) + { + EMSG2(_(e_invarg2), get_tv_string(item)); + return FAIL; + } + if (buflist_findnr(opt->jo_io_buf[part]) == NULL) + { + EMSGN(_(e_nobufnr), (long)opt->jo_io_buf[part]); + return FAIL; + } + } else if (STRCMP(hi->hi_key, "in-top") == 0 || STRCMP(hi->hi_key, "in-bot") == 0) { @@ -15156,21 +15177,36 @@ f_job_start(typval_T *argvars, typval_T *rettv) if ((opt.jo_set & JO_IN_IO) && opt.jo_io[PART_IN] == JIO_BUFFER) { - buf_T *buf; + buf_T *buf = NULL; /* check that we can find the buffer before starting the job */ - if (!(opt.jo_set & JO_IN_NAME)) + if (opt.jo_set & JO_IN_BUF) { - EMSG(_("E915: in-io buffer requires in-name to be set")); - return; + buf = buflist_findnr(opt.jo_io_buf[PART_IN]); + if (buf == NULL) + EMSGN(_(e_nobufnr), (long)opt.jo_io_buf[PART_IN]); } - buf = buflist_find_by_name(opt.jo_io_name[PART_IN], FALSE); + else if (!(opt.jo_set & JO_IN_NAME)) + { + EMSG(_("E915: in-io buffer requires in-buf or in-name to be set")); + } + else + buf = buflist_find_by_name(opt.jo_io_name[PART_IN], FALSE); if (buf == NULL) return; if (buf->b_ml.ml_mfp == NULL) { - EMSG2(_("E918: buffer must be loaded: %s"), - opt.jo_io_name[PART_IN]); + char_u buf[NUMBUFLEN]; + char_u *s; + + if (opt.jo_set & JO_IN_BUF) + { + sprintf((char *)buf, "%d", opt.jo_io_buf[PART_IN]); + s = buf; + } + else + s = opt.jo_io_name[PART_IN]; + EMSG2(_("E918: buffer must be loaded: %s"), s); return; } job->jv_in_buf = buf; |