Mercurial > vim
comparison src/autocmd.c @ 23758:97296182d336 v8.2.2420
patch 8.2.2420: too many problems with using all autocommand events
Commit: https://github.com/vim/vim/commit/9a046fd08bcae319d39a4dbde2be81decee19013
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 28 13:47:59 2021 +0100
patch 8.2.2420: too many problems with using all autocommand events
Problem: Too many problems with using all autocommand events.
Solution: Disallow defining an autocommand for all events.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 28 Jan 2021 14:00:04 +0100 |
parents | 9a5f12b36273 |
children | 03438d77d8ab |
comparison
equal
deleted
inserted
replaced
23757:b873d83d2f87 | 23758:97296182d336 |
---|---|
954 */ | 954 */ |
955 last_event = (event_T)-1; // for listing the event name | 955 last_event = (event_T)-1; // for listing the event name |
956 last_group = AUGROUP_ERROR; // for listing the group name | 956 last_group = AUGROUP_ERROR; // for listing the group name |
957 if (*arg == '*' || *arg == NUL || *arg == '|') | 957 if (*arg == '*' || *arg == NUL || *arg == '|') |
958 { | 958 { |
959 for (event = (event_T)0; (int)event < (int)NUM_EVENTS; | 959 if (!forceit && *cmd != NUL) |
960 event = (event_T)((int)event + 1)) | 960 emsg(_(e_cannot_define_autocommands_for_all_events)); |
961 if (do_autocmd_event(event, pat, | 961 else |
962 once, nested, cmd, forceit, group) == FAIL) | 962 for (event = (event_T)0; (int)event < (int)NUM_EVENTS; |
963 break; | 963 event = (event_T)((int)event + 1)) |
964 if (do_autocmd_event(event, pat, | |
965 once, nested, cmd, forceit, group) == FAIL) | |
966 break; | |
964 } | 967 } |
965 else | 968 else |
966 { | 969 { |
967 while (*arg && *arg != '|' && !VIM_ISWHITE(*arg)) | 970 while (*arg && *arg != '|' && !VIM_ISWHITE(*arg)) |
968 if (do_autocmd_event(event_name2nr(arg, &arg), pat, | 971 if (do_autocmd_event(event_name2nr(arg, &arg), pat, |