Skip to content

Commit 9ba647c

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents d872ea2 + ee2cbcd commit 9ba647c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1082
-105
lines changed

runtime/autoload/dist/ft.vim

+3-3
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ func dist#ft#FTm()
269269
return
270270
endif
271271

272-
let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|for\|function\|if\|methods\|parfor\|properties\|switch\|while\)\>'
272+
" excluding end(for|function|if|switch|while) common to Murphi
273+
let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|methods\|parfor\|properties\)\>'
273274

274275
let n = 1
275276
let saw_comment = 0 " Whether we've seen a multiline comment leader.
@@ -285,8 +286,7 @@ func dist#ft#FTm()
285286
setf objc
286287
return
287288
endif
288-
if line =~ '^\s*\%(#\|%!\|[#%]{\=\s*$\)' ||
289-
\ line =~ '^\s*unwind_protect\>' ||
289+
if line =~ '^\s*\%(#\|%!\)' || line =~ '^\s*unwind_protect\>' ||
290290
\ line =~ '\%(^\|;\)\s*' .. octave_block_terminators
291291
setf octave
292292
return

runtime/doc/autocmd.txt

+18-1
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ Name triggered by ~
368368
|InsertCharPre| when a character was typed in Insert mode, before
369369
inserting it
370370

371+
|ModeChanged| after changing the mode
372+
371373
|TextChanged| after a change was made to the text in Normal mode
372374
|TextChangedI| after a change was made to the text in Insert mode
373375
when popup menu is not visible
@@ -927,7 +929,22 @@ MenuPopup Just before showing the popup menu (under the
927929
i Insert
928930
c Command line
929931
tl Terminal
930-
*OptionSet*
932+
*ModeChanged*
933+
ModeChanged After changing the mode. The pattern is
934+
matched against `'old_mode:new_mode'`, for
935+
example match against `i:*` to simulate
936+
|InsertLeave|.
937+
The following values of |v:event| are set:
938+
old_mode The mode before it changed.
939+
new_mode The new mode as also returned
940+
by |mode()|.
941+
When ModeChanged is triggered, old_mode will
942+
have the value of new_mode when the event was
943+
last triggered.
944+
Usage example to use relative line numbers
945+
when entering visual mode: >
946+
:autocmd ModeChanged *:v set relativenumber
947+
< *OptionSet*
931948
OptionSet After setting an option. The pattern is
932949
matched against the long option name.
933950
|<amatch>| indicates what option has been set.

runtime/doc/eval.txt

+27-1
Original file line numberDiff line numberDiff line change
@@ -2481,6 +2481,7 @@ atan2({expr1}, {expr2}) Float arc tangent of {expr1} / {expr2}
24812481
balloon_gettext() String current text in the balloon
24822482
balloon_show({expr}) none show {expr} inside the balloon
24832483
balloon_split({msg}) List split {msg} as used for a balloon
2484+
blob2list({blob}) List convert {blob} into a list of numbers
24842485
browse({save}, {title}, {initdir}, {default})
24852486
String put up a file requester
24862487
browsedir({title}, {initdir}) String put up a directory requester
@@ -2733,7 +2734,8 @@ libcallnr({lib}, {func}, {arg}) Number idem, but return a Number
27332734
line({expr} [, {winid}]) Number line nr of cursor, last line or mark
27342735
line2byte({lnum}) Number byte count of line {lnum}
27352736
lispindent({lnum}) Number Lisp indent for line {lnum}
2736-
list2str({list} [, {utf8}]) String turn numbers in {list} into a String
2737+
list2blob({list}) Blob turn {list} of numbers into a Blob
2738+
list2str({list} [, {utf8}]) String turn {list} of numbers into a String
27372739
listener_add({callback} [, {buf}])
27382740
Number add a callback to listen to changes
27392741
listener_flush([{buf}]) none invoke listener callbacks
@@ -3367,6 +3369,17 @@ balloon_split({msg}) *balloon_split()*
33673369
< {only available when compiled with the |+balloon_eval_term|
33683370
feature}
33693371

3372+
blob2list({blob}) *blob2list()*
3373+
Return a List containing the number value of each byte in Blob
3374+
{blob}. Examples: >
3375+
blob2list(0z0102.0304) returns [1, 2, 3, 4]
3376+
blob2list(0z) returns []
3377+
< Returns an empty List on error. |list2blob()| does the
3378+
opposite.
3379+
3380+
Can also be used as a |method|: >
3381+
GetBlob()->blob2list()
3382+
33703383
*browse()*
33713384
browse({save}, {title}, {initdir}, {default})
33723385
Put up a file requester. This only works when "has("browse")"
@@ -7220,6 +7233,19 @@ lispindent({lnum}) *lispindent()*
72207233
Can also be used as a |method|: >
72217234
GetLnum()->lispindent()
72227235

7236+
list2blob({list}) *list2blob()*
7237+
Return a Blob concatenating all the number values in {list}.
7238+
Examples: >
7239+
list2blob([1, 2, 3, 4]) returns 0z01020304
7240+
list2blob([]) returns 0z
7241+
< Returns an empty Blob on error. If one of the numbers is
7242+
negative or more than 255 error *E1239* is given.
7243+
7244+
|blob2list()| does the opposite.
7245+
7246+
Can also be used as a |method|: >
7247+
GetList()->list2blob()
7248+
72237249
list2str({list} [, {utf8}]) *list2str()*
72247250
Convert each number in {list} to a character string can
72257251
concatenate them all. Examples: >

runtime/doc/map.txt

+4
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,10 @@ See |:verbose-cmd| for more information.
13681368
:delc[ommand] {cmd} *:delc* *:delcommand* *E184*
13691369
Delete the user-defined command {cmd}.
13701370

1371+
:delc[ommand] -buffer {cmd} *E1237*
1372+
Delete the user-defined command {cmd} that was defined
1373+
for the current buffer.
1374+
13711375
:comc[lear] *:comc* *:comclear*
13721376
Delete all user-defined commands.
13731377

runtime/doc/options.txt

+14-5
Original file line numberDiff line numberDiff line change
@@ -5034,16 +5034,25 @@ A jump table for the options with a short description can be found at |Q_op|.
50345034
*lcs-space*
50355035
space:c Character to show for a space. When omitted, spaces
50365036
are left blank.
5037+
*lcs-multispace*
5038+
multispace:c...
5039+
One or more characters to use cyclically to show for
5040+
multiple consecutive spaces. Overrides the "space"
5041+
setting, except for single spaces. When omitted, the
5042+
"space" setting is used. For example,
5043+
`:set listchars=multispace:---+` shows ten consecutive
5044+
spaces as:
5045+
---+---+--
50375046
*lcs-lead*
50385047
lead:c Character to show for leading spaces. When omitted,
5039-
leading spaces are blank. Overrides the "space"
5040-
setting for leading spaces. You can combine it with
5041-
"tab:", for example: >
5048+
leading spaces are blank. Overrides the "space" and
5049+
"multispace" settings for leading spaces. You can
5050+
combine it with "tab:", for example: >
50425051
:set listchars+=tab:>-,lead:.
50435052
< *lcs-trail*
50445053
trail:c Character to show for trailing spaces. When omitted,
5045-
trailing spaces are blank. Overrides the "space"
5046-
setting for trailing spaces.
5054+
trailing spaces are blank. Overrides the "space" and
5055+
"multispace" settings for trailing spaces.
50475056
*lcs-extends*
50485057
extends:c Character to show in the last column, when 'wrap' is
50495058
off and the line continues beyond the right of the

runtime/doc/usr_41.txt

+6
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,10 @@ Floating point computation: *float-functions*
723723
isinf() check for infinity
724724
isnan() check for not a number
725725

726+
Blob manipulation: *blob-functions*
727+
blob2list() get a list of numbers from a blob
728+
list2blob() get a blob from a list of numbers
729+
726730
Other computation: *bitwise-function*
727731
and() bitwise AND
728732
invert() bitwise invert
@@ -1449,6 +1453,8 @@ is a List with arguments.
14491453
Function references are most useful in combination with a Dictionary, as is
14501454
explained in the next section.
14511455

1456+
More information about defining your own functions here: |user-functions|.
1457+
14521458
==============================================================================
14531459
*41.8* Lists and Dictionaries
14541460

src/autocmd.c

+16-2
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ static struct event_name
150150
{"InsertLeavePre", EVENT_INSERTLEAVEPRE},
151151
{"InsertCharPre", EVENT_INSERTCHARPRE},
152152
{"MenuPopup", EVENT_MENUPOPUP},
153+
{"ModeChanged", EVENT_MODECHANGED},
153154
{"OptionSet", EVENT_OPTIONSET},
154155
{"OSAppearanceChanged", EVENT_OSAPPCHANGED},
155156
{"QuickFixCmdPost", EVENT_QUICKFIXCMDPOST},
@@ -1818,6 +1819,17 @@ has_completechanged(void)
18181819
}
18191820
#endif
18201821

1822+
#if defined(FEAT_EVAL) || defined(PROTO)
1823+
/*
1824+
* Return TRUE when there is a ModeChanged autocommand defined.
1825+
*/
1826+
int
1827+
has_modechanged(void)
1828+
{
1829+
return (first_autopat[(int)EVENT_MODECHANGED] != NULL);
1830+
}
1831+
#endif
1832+
18211833
/*
18221834
* Execute autocommands for "event" and file name "fname".
18231835
* Return TRUE if some commands were executed.
@@ -1939,7 +1951,8 @@ apply_autocmds_group(
19391951
if (fname_io == NULL)
19401952
{
19411953
if (event == EVENT_COLORSCHEME || event == EVENT_COLORSCHEMEPRE
1942-
|| event == EVENT_OPTIONSET)
1954+
|| event == EVENT_OPTIONSET
1955+
|| event == EVENT_MODECHANGED)
19431956
autocmd_fname = NULL;
19441957
else if (fname != NULL && !ends_excmd(*fname))
19451958
autocmd_fname = fname;
@@ -2012,7 +2025,8 @@ apply_autocmds_group(
20122025
|| event == EVENT_COLORSCHEMEPRE
20132026
|| event == EVENT_OPTIONSET
20142027
|| event == EVENT_QUICKFIXCMDPOST
2015-
|| event == EVENT_DIRCHANGED)
2028+
|| event == EVENT_DIRCHANGED
2029+
|| event == EVENT_MODECHANGED)
20162030
{
20172031
fname = vim_strsave(fname);
20182032
autocmd_fname_full = TRUE; // don't expand it later

src/blob.c

+61
Original file line numberDiff line numberDiff line change
@@ -483,4 +483,65 @@ blob_remove(typval_T *argvars, typval_T *rettv, char_u *arg_errmsg)
483483
}
484484
}
485485

486+
/*
487+
* blob2list() function
488+
*/
489+
void
490+
f_blob2list(typval_T *argvars, typval_T *rettv)
491+
{
492+
blob_T *blob;
493+
list_T *l;
494+
int i;
495+
496+
if (rettv_list_alloc(rettv) == FAIL)
497+
return;
498+
499+
if (check_for_blob_arg(argvars, 0) == FAIL)
500+
return;
501+
502+
blob = argvars->vval.v_blob;
503+
l = rettv->vval.v_list;
504+
for (i = 0; i < blob_len(blob); i++)
505+
list_append_number(l, blob_get(blob, i));
506+
}
507+
508+
/*
509+
* list2blob() function
510+
*/
511+
void
512+
f_list2blob(typval_T *argvars, typval_T *rettv)
513+
{
514+
list_T *l;
515+
listitem_T *li;
516+
blob_T *blob;
517+
518+
if (rettv_blob_alloc(rettv) == FAIL)
519+
return;
520+
blob = rettv->vval.v_blob;
521+
522+
if (check_for_list_arg(argvars, 0) == FAIL)
523+
return;
524+
525+
l = argvars->vval.v_list;
526+
if (l == NULL)
527+
return;
528+
529+
FOR_ALL_LIST_ITEMS(l, li)
530+
{
531+
int error;
532+
varnumber_T n;
533+
534+
error = FALSE;
535+
n = tv_get_number_chk(&li->li_tv, &error);
536+
if (error == TRUE || n < 0 || n > 255)
537+
{
538+
if (!error)
539+
semsg(_(e_invalid_value_for_blob_nr), n);
540+
ga_clear(&blob->bv_ga);
541+
return;
542+
}
543+
ga_append(&blob->bv_ga, n);
544+
}
545+
}
546+
486547
#endif // defined(FEAT_EVAL)

src/change.c

+32-6
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,18 @@ f_listener_flush(typval_T *argvars, typval_T *rettv UNUSED)
293293
invoke_listeners(buf);
294294
}
295295

296+
297+
static void
298+
remove_listener(buf_T *buf, listener_T *lnr, listener_T *prev)
299+
{
300+
if (prev != NULL)
301+
prev->lr_next = lnr->lr_next;
302+
else
303+
buf->b_listener = lnr->lr_next;
304+
free_callback(&lnr->lr_callback);
305+
vim_free(lnr);
306+
}
307+
296308
/*
297309
* listener_remove() function
298310
*/
@@ -317,12 +329,13 @@ f_listener_remove(typval_T *argvars, typval_T *rettv)
317329
next = lnr->lr_next;
318330
if (lnr->lr_id == id)
319331
{
320-
if (prev != NULL)
321-
prev->lr_next = lnr->lr_next;
322-
else
323-
buf->b_listener = lnr->lr_next;
324-
free_callback(&lnr->lr_callback);
325-
vim_free(lnr);
332+
if (textwinlock > 0)
333+
{
334+
// in invoke_listeners(), clear ID and delete later
335+
lnr->lr_id = 0;
336+
return;
337+
}
338+
remove_listener(buf, lnr, prev);
326339
rettv->vval.v_number = 1;
327340
return;
328341
}
@@ -357,6 +370,7 @@ invoke_listeners(buf_T *buf)
357370
linenr_T added = 0;
358371
int save_updating_screen = updating_screen;
359372
static int recursive = FALSE;
373+
listener_T *next;
360374

361375
if (buf->b_recorded_changes == NULL // nothing changed
362376
|| buf->b_listener == NULL // no listeners
@@ -400,6 +414,18 @@ invoke_listeners(buf_T *buf)
400414
clear_tv(&rettv);
401415
}
402416

417+
// If f_listener_remove() was called may have to remove a listener now.
418+
for (lnr = buf->b_listener; lnr != NULL; lnr = next)
419+
{
420+
listener_T *prev = NULL;
421+
422+
next = lnr->lr_next;
423+
if (lnr->lr_id == 0)
424+
remove_listener(buf, lnr, prev);
425+
else
426+
prev = lnr;
427+
}
428+
403429
--textwinlock;
404430
list_unref(buf->b_recorded_changes);
405431
buf->b_recorded_changes = NULL;

src/cmdexpand.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -2274,7 +2274,8 @@ ExpandGeneric(
22742274
{
22752275
if (xp->xp_context == EXPAND_EXPRESSION
22762276
|| xp->xp_context == EXPAND_FUNCTIONS
2277-
|| xp->xp_context == EXPAND_USER_FUNC)
2277+
|| xp->xp_context == EXPAND_USER_FUNC
2278+
|| xp->xp_context == EXPAND_DISASSEMBLE)
22782279
// <SNR> functions should be sorted to the end.
22792280
qsort((void *)*file, (size_t)*num_file, sizeof(char_u *),
22802281
sort_func_compare);

0 commit comments

Comments
 (0)