Skip to content

Commit e30d19e

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 1954f8f + 169ebb0 commit e30d19e

24 files changed

Lines changed: 248 additions & 212 deletions

runtime/doc/channel.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*channel.txt* For Vim version 7.4. Last change: 2016 Sep 01
1+
*channel.txt* For Vim version 7.4. Last change: 2016 Sep 07
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -646,6 +646,8 @@ See |job_setoptions()| and |ch_setoptions()|.
646646
"out_buf": number the number of the buffer to write to
647647
"out_modifiable": 0 when writing to a buffer, 'modifiable' will be off
648648
(see below)
649+
"out_msg": 0 when writing to a new buffer, the first line will be
650+
set to "Reading from channel output..."
649651

650652
*job-err_io* *err_name* *err_buf*
651653
"err_io": "out" stderr messages to go to stdout
@@ -657,6 +659,8 @@ See |job_setoptions()| and |ch_setoptions()|.
657659
"err_buf": number the number of the buffer to write to
658660
"err_modifiable": 0 when writing to a buffer, 'modifiable' will be off
659661
(see below)
662+
"err_msg": 0 when writing to a new buffer, the first line will be
663+
set to "Reading from channel error..."
660664

661665
"block_write": number only for testing: pretend every other write to stdin
662666
will block
@@ -686,8 +690,16 @@ buffer number.
686690

687691
For a new buffer 'buftype' is set to "nofile" and 'bufhidden' to "hide". If
688692
you prefer other settings, create the buffer first and pass the buffer number.
689-
693+
*out_modifiable* *err_modifiable*
690694
The "out_modifiable" and "err_modifiable" options can be used to set the
695+
'modifiable' option off, or write to a buffer that has 'modifiable' off. That
696+
means that lines will be appended to the buffer, but the user can't easily
697+
change the buffer.
698+
*out_msg* *err_msg*
699+
The "out_msg" option can be used to specify whether a new buffer will have the
700+
first line set to "Reading from channel output...". The default is to add the
701+
message. "err_msg" does the same for channel error.
702+
691703
'modifiable' option off, or write to a buffer that has 'modifiable' off. That
692704
means that lines will be appended to the buffer, but the user can't easily
693705
change the buffer.

src/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,7 @@ test1 \
20582058
test_search_mbyte \
20592059
test_utf8 \
20602060
test_wordcount \
2061-
test2 test3 test4 test5 test6 test7 test8 test9 \
2061+
test3 test4 test5 test6 test7 test8 test9 \
20622062
test11 test12 test14 test15 test17 test18 test19 \
20632063
test20 test21 test22 test23 test24 test25 test26 test27 test28 test29 \
20642064
test30 test31 test32 test33 test34 test36 test37 test38 test39 \
@@ -2102,12 +2102,14 @@ test_arglist \
21022102
test_fnameescape \
21032103
test_fnamemodify \
21042104
test_glob2regpat \
2105+
test_gf \
21052106
test_gn \
21062107
test_goto \
21072108
test_gui \
21082109
test_hardcopy \
21092110
test_help_tagjump \
21102111
test_history \
2112+
test_hlsearch \
21112113
test_increment \
21122114
test_increment_dbcs \
21132115
test_job_fails \
@@ -2145,6 +2147,7 @@ test_arglist \
21452147
test_signs \
21462148
test_sort \
21472149
test_source_utf8 \
2150+
test_smartindent \
21482151
test_startup \
21492152
test_startup_utf8 \
21502153
test_stat \

src/channel.c

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ channel_set_job(channel_T *channel, job_T *job, jobopt_T *options)
11001100
* Returns NULL if there is something very wrong (error already reported).
11011101
*/
11021102
static buf_T *
1103-
find_buffer(char_u *name, int err)
1103+
find_buffer(char_u *name, int err, int msg)
11041104
{
11051105
buf_T *buf = NULL;
11061106
buf_T *save_curbuf = curbuf;
@@ -1125,7 +1125,8 @@ find_buffer(char_u *name, int err)
11251125
#endif
11261126
if (curbuf->b_ml.ml_mfp == NULL)
11271127
ml_open(curbuf);
1128-
ml_replace(1, (char_u *)(err ? "Reading from channel error..."
1128+
if (msg)
1129+
ml_replace(1, (char_u *)(err ? "Reading from channel error..."
11291130
: "Reading from channel output..."), TRUE);
11301131
changed_bytes(1, 0);
11311132
curbuf = save_curbuf;
@@ -1217,7 +1218,11 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
12171218
}
12181219
else
12191220
{
1220-
buf = find_buffer(opt->jo_io_name[PART_OUT], FALSE);
1221+
int msg = TRUE;
1222+
1223+
if (opt->jo_set2 & JO2_OUT_MSG)
1224+
msg = opt->jo_message[PART_OUT];
1225+
buf = find_buffer(opt->jo_io_name[PART_OUT], FALSE, msg);
12211226
}
12221227
if (buf != NULL)
12231228
{
@@ -1256,7 +1261,13 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
12561261
EMSGN(_(e_nobufnr), (long)opt->jo_io_buf[PART_ERR]);
12571262
}
12581263
else
1259-
buf = find_buffer(opt->jo_io_name[PART_ERR], TRUE);
1264+
{
1265+
int msg = TRUE;
1266+
1267+
if (opt->jo_set2 & JO2_ERR_MSG)
1268+
msg = opt->jo_message[PART_ERR];
1269+
buf = find_buffer(opt->jo_io_name[PART_ERR], TRUE, msg);
1270+
}
12601271
if (buf != NULL)
12611272
{
12621273
if (opt->jo_set & JO_ERR_MODIFIABLE)
@@ -2248,6 +2259,7 @@ append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, int part)
22482259
int save_write_to = buffer->b_write_to_channel;
22492260
chanpart_T *ch_part = &channel->ch_part[part];
22502261
int save_p_ma = buffer->b_p_ma;
2262+
int empty = (buffer->b_ml.ml_flags & ML_EMPTY);
22512263

22522264
if (!buffer->b_p_ma && !ch_part->ch_nomodifiable)
22532265
{
@@ -2274,9 +2286,16 @@ append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, int part)
22742286
curbuf = buffer;
22752287
u_sync(TRUE);
22762288
/* ignore undo failure, undo is not very useful here */
2277-
ignored = u_save(lnum, lnum + 1);
2289+
ignored = u_save(lnum, lnum + 1 + (empty ? 1 : 0));
22782290

2279-
ml_append(lnum, msg, 0, FALSE);
2291+
if (empty)
2292+
{
2293+
/* The buffer is empty, replace the first (dummy) line. */
2294+
ml_replace(lnum, msg, TRUE);
2295+
lnum = 0;
2296+
}
2297+
else
2298+
ml_append(lnum, msg, 0, FALSE);
22802299
appended_lines_mark(lnum, 1L);
22812300
curbuf = save_curbuf;
22822301
if (ch_part->ch_nomodifiable)
@@ -4108,6 +4127,16 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported)
41084127
opt->jo_set |= JO_OUT_MODIFIABLE << (part - PART_OUT);
41094128
opt->jo_modifiable[part] = get_tv_number(item);
41104129
}
4130+
else if (STRCMP(hi->hi_key, "out_msg") == 0
4131+
|| STRCMP(hi->hi_key, "err_msg") == 0)
4132+
{
4133+
part = part_from_char(*hi->hi_key);
4134+
4135+
if (!(supported & JO_OUT_IO))
4136+
break;
4137+
opt->jo_set2 |= JO2_OUT_MSG << (part - PART_OUT);
4138+
opt->jo_message[part] = get_tv_number(item);
4139+
}
41114140
else if (STRCMP(hi->hi_key, "in_top") == 0
41124141
|| STRCMP(hi->hi_key, "in_bot") == 0)
41134142
{

src/structs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,10 @@ struct channel_S {
16371637
#define JO_ERR_MODIFIABLE 0x40000000 /* "err_modifiable" (JO_OUT_ << 1) */
16381638
#define JO_ALL 0x7fffffff
16391639

1640+
#define JO2_OUT_MSG 0x0001 /* "out_msg" */
1641+
#define JO2_ERR_MSG 0x0002 /* "err_msg" (JO_OUT_ << 1) */
1642+
#define JO2_ALL 0x0003
1643+
16401644
#define JO_MODE_ALL (JO_MODE + JO_IN_MODE + JO_OUT_MODE + JO_ERR_MODE)
16411645
#define JO_CB_ALL \
16421646
(JO_CALLBACK + JO_OUT_CALLBACK + JO_ERR_CALLBACK + JO_CLOSE_CALLBACK)
@@ -1648,6 +1652,7 @@ struct channel_S {
16481652
typedef struct
16491653
{
16501654
int jo_set; /* JO_ bits for values that were set */
1655+
int jo_set2; /* JO2_ bits for values that were set */
16511656

16521657
ch_mode_T jo_mode;
16531658
ch_mode_T jo_in_mode;
@@ -1659,6 +1664,7 @@ typedef struct
16591664
char_u *jo_io_name[4]; /* not allocated! */
16601665
int jo_io_buf[4];
16611666
int jo_modifiable[4];
1667+
int jo_message[4];
16621668
channel_T *jo_channel;
16631669

16641670
linenr_T jo_in_top;

src/testdir/Make_all.mak

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@ SCRIPTS_ALL = \
1313
test3.out \
1414
test4.out \
1515
test5.out \
16-
test6.out \
1716
test7.out \
1817
test8.out \
1918
test9.out \
2019
test14.out \
2120
test15.out \
22-
test18.out \
2321
test19.out \
2422
test20.out \
25-
test21.out \
2623
test22.out \
2724
test23.out \
2825
test24.out \
@@ -74,7 +71,6 @@ SCRIPTS_ALL = \
7471
test95.out \
7572
test98.out \
7673
test99.out \
77-
test101.out \
7874
test103.out \
7975
test104.out \
8076
test107.out \
@@ -109,7 +105,6 @@ SCRIPTS_MORE1 = \
109105

110106
# Tests that run on most systems, but not on Amiga and DOS/Windows.
111107
SCRIPTS_MORE2 = \
112-
test2.out \
113108
test12.out \
114109
test25.out \
115110
test49.out \
@@ -147,7 +142,7 @@ SCRIPTS_GUI =
147142
# Keep test_alot*.res as the last one, sort the others.
148143
NEW_TESTS = test_arglist.res \
149144
test_assert.res \
150-
test_autochdir \
145+
test_autochdir.res \
151146
test_backspace_opt.res \
152147
test_bufwintabinfo.res \
153148
test_cdo.res \
@@ -159,10 +154,12 @@ NEW_TESTS = test_arglist.res \
159154
test_digraph.res \
160155
test_farsi.res \
161156
test_fnameescape.res \
157+
test_gf.res \
162158
test_gn.res \
163159
test_gui.res \
164160
test_hardcopy.res \
165161
test_history.res \
162+
test_hlsearch.res \
166163
test_increment.res \
167164
test_increment_dbcs.res \
168165
test_job_fails.res \
@@ -180,6 +177,7 @@ NEW_TESTS = test_arglist.res \
180177
test_ruby.res \
181178
test_search.res \
182179
test_signs.res \
180+
test_smartindent.res \
183181
test_startup.res \
184182
test_startup_utf8.res \
185183
test_stat.res \

src/testdir/test101.in

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/testdir/test101.ok

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/testdir/test18.in

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/testdir/test18.ok

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/testdir/test2.in

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)