To: vim_dev@googlegroups.com Subject: Patch 7.4.1509 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1509 Problem: Keeping both a variable for a job and the channel it refers to is a hassle. Solution: Allow passing the job where a channel is expected. (Damien) Files: src/eval.c, src/testdir/test_channel.vim *** ../vim-7.4.1508/src/eval.c 2016-03-07 15:23:59.946423625 +0100 --- src/eval.c 2016-03-07 21:10:57.218766358 +0100 *************** *** 10285,10298 **** static channel_T * get_channel_arg(typval_T *tv) { ! channel_T *channel; ! if (tv->v_type != VAR_CHANNEL) { EMSG2(_(e_invarg2), get_tv_string(tv)); return NULL; } - channel = tv->vval.v_channel; if (channel == NULL || !channel_is_open(channel)) { --- 10285,10306 ---- static channel_T * get_channel_arg(typval_T *tv) { ! channel_T *channel = NULL; ! if (tv->v_type == VAR_JOB) ! { ! if (tv->vval.v_job != NULL) ! channel = tv->vval.v_job->jv_channel; ! } ! else if (tv->v_type == VAR_CHANNEL) ! { ! channel = tv->vval.v_channel; ! } ! else { EMSG2(_(e_invarg2), get_tv_string(tv)); return NULL; } if (channel == NULL || !channel_is_open(channel)) { *************** *** 15106,15112 **** * "job_start()" function */ static void ! f_job_start(typval_T *argvars UNUSED, typval_T *rettv) { job_T *job; char_u *cmd = NULL; --- 15114,15120 ---- * "job_start()" function */ static void ! f_job_start(typval_T *argvars, typval_T *rettv) { job_T *job; char_u *cmd = NULL; *** ../vim-7.4.1508/src/testdir/test_channel.vim 2016-03-06 23:06:20.671506716 +0100 --- src/testdir/test_channel.vim 2016-03-07 21:11:58.878117058 +0100 *************** *** 463,478 **** let job = job_start(s:python . " test_channel_pipe.py", {'mode': 'raw'}) call assert_equal("run", job_status(job)) try ! let handle = job_getchannel(job) ! call ch_sendraw(handle, "echo something\n") ! let msg = ch_readraw(handle) call assert_equal("something\n", substitute(msg, "\r", "", 'g')) ! call ch_sendraw(handle, "double this\n") ! let msg = ch_readraw(handle) call assert_equal("this\nAND this\n", substitute(msg, "\r", "", 'g')) ! let reply = ch_evalraw(handle, "quit\n", {'timeout': 100}) call assert_equal("Goodbye!\n", substitute(reply, "\r", "", 'g')) finally call job_stop(job) --- 463,478 ---- let job = job_start(s:python . " test_channel_pipe.py", {'mode': 'raw'}) call assert_equal("run", job_status(job)) try ! " For a change use the job where a channel is expected. ! call ch_sendraw(job, "echo something\n") ! let msg = ch_readraw(job) call assert_equal("something\n", substitute(msg, "\r", "", 'g')) ! call ch_sendraw(job, "double this\n") ! let msg = ch_readraw(job) call assert_equal("this\nAND this\n", substitute(msg, "\r", "", 'g')) ! let reply = ch_evalraw(job, "quit\n", {'timeout': 100}) call assert_equal("Goodbye!\n", substitute(reply, "\r", "", 'g')) finally call job_stop(job) *** ../vim-7.4.1508/src/version.c 2016-03-07 20:58:45.922477535 +0100 --- src/version.c 2016-03-07 21:09:56.699403778 +0100 *************** *** 745,746 **** --- 745,748 ---- { /* Add new patch number below this line */ + /**/ + 1509, /**/ -- The process for understanding customers primarily involves sitting around with other marketing people and talking about what you would to if you were dumb enough to be a customer. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///