0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.1.0825: code for autocommands is mixed with file I/O code

Problem:    Code for autocommands is mixed with file I/O code.
Solution:   Move autocommand code to a separate file. (Yegappan Lakshmanan,
            closes #3863)
This commit is contained in:
Bram Moolenaar 2019-01-26 16:21:07 +01:00
parent 1ecc5e4a99
commit 3e460fd8b7
19 changed files with 2672 additions and 2620 deletions

View File

@ -14,6 +14,7 @@ SRC_ALL = \
src/arabic.c \ src/arabic.c \
src/arabic.h \ src/arabic.h \
src/ascii.h \ src/ascii.h \
src/autocmd.c \
src/beval.c \ src/beval.c \
src/beval.h \ src/beval.h \
src/blob.c \ src/blob.c \
@ -146,6 +147,7 @@ SRC_ALL = \
src/proto.h \ src/proto.h \
src/protodef.h \ src/protodef.h \
src/proto/arabic.pro \ src/proto/arabic.pro \
src/proto/autocmd.pro \
src/proto/beval.pro \ src/proto/beval.pro \
src/proto/blob.pro \ src/proto/blob.pro \
src/proto/blowfish.pro \ src/proto/blowfish.pro \

View File

@ -525,6 +525,7 @@ vimwinmain = \
vimobj = \ vimobj = \
$(OBJDIR)\arabic.obj \ $(OBJDIR)\arabic.obj \
$(OBJDIR)\autocmd.obj \
$(OBJDIR)\blowfish.obj \ $(OBJDIR)\blowfish.obj \
$(OBJDIR)\buffer.obj \ $(OBJDIR)\buffer.obj \
$(OBJDIR)\charset.obj \ $(OBJDIR)\charset.obj \

View File

@ -695,6 +695,7 @@ GUIOBJ = $(OUTDIR)/gui.o $(OUTDIR)/gui_w32.o $(OUTDIR)/gui_beval.o $(OUTDIR)/os
CUIOBJ = $(OUTDIR)/iscygpty.o CUIOBJ = $(OUTDIR)/iscygpty.o
OBJ = \ OBJ = \
$(OUTDIR)/arabic.o \ $(OUTDIR)/arabic.o \
$(OUTDIR)/autocmd.o \
$(OUTDIR)/beval.o \ $(OUTDIR)/beval.o \
$(OUTDIR)/blob.o \ $(OUTDIR)/blob.o \
$(OUTDIR)/blowfish.o \ $(OUTDIR)/blowfish.o \

View File

@ -27,6 +27,7 @@ LD = dcc
SRC = \ SRC = \
arabic.c \ arabic.c \
autocmd.c \
blowfish.c \ blowfish.c \
buffer.c \ buffer.c \
charset.c \ charset.c \
@ -84,6 +85,7 @@ SRC = \
version.c version.c
OBJ = o/arabic.o \ OBJ = o/arabic.o \
o/autocmd.o \
o/blowfish.o \ o/blowfish.o \
o/buffer.o \ o/buffer.o \
o/charset.o \ o/charset.o \
@ -161,6 +163,8 @@ $(SYMS) : vim.h globals.h keymap.h macros.h ascii.h term.h os_amiga.h structs.h
o/arabic.o: arabic.c $(SYMS) o/arabic.o: arabic.c $(SYMS)
o/autocmd.o: autocmd.c $(SYMS)
o/blowfish.o: blowfish.c $(SYMS) o/blowfish.o: blowfish.c $(SYMS)
o/buffer.o: buffer.c $(SYMS) o/buffer.o: buffer.c $(SYMS)

View File

@ -211,6 +211,7 @@ ALL : .\$(VIM).exe vimrun.exe install.exe uninstal.exe xxd/xxd.exe GvimExt/gvime
LINK32_OBJS= \ LINK32_OBJS= \
$(EXTRAS) \ $(EXTRAS) \
"$(INTDIR)/arabic.obj" \ "$(INTDIR)/arabic.obj" \
"$(INTDIR)/autocmd.obj" \
"$(INTDIR)/blowfish.obj" \ "$(INTDIR)/blowfish.obj" \
"$(INTDIR)/buffer.obj" \ "$(INTDIR)/buffer.obj" \
"$(INTDIR)/charset.obj" \ "$(INTDIR)/charset.obj" \
@ -341,6 +342,10 @@ GvimExt/gvimext.dll: GvimExt/gvimext.cpp GvimExt/gvimext.rc GvimExt/gvimext.h
SOURCE=.\arabic.c SOURCE=.\arabic.c
# End Source File # End Source File
# Begin Source File # Begin Source File
#
SOURCE=.\autocmd.c
# End Source File
# Begin Source File
SOURCE=.\blowfish.c SOURCE=.\blowfish.c
# End Source File # End Source File

View File

@ -37,6 +37,7 @@ REN = $(SHELL) -c mv -f
DEL = $(SHELL) -c rm -f DEL = $(SHELL) -c rm -f
SRC = arabic.c \ SRC = arabic.c \
autocmd.c \
blowfish.c \ blowfish.c \
buffer.c \ buffer.c \
charset.c \ charset.c \
@ -96,6 +97,7 @@ SRC = arabic.c \
INCL = vim.h feature.h keymap.h macros.h ascii.h term.h structs.h os_amiga.h INCL = vim.h feature.h keymap.h macros.h ascii.h term.h structs.h os_amiga.h
OBJ = obj/arabic.o \ OBJ = obj/arabic.o \
obj/autocmd.o \
obj/blowfish.o \ obj/blowfish.o \
obj/buffer.o \ obj/buffer.o \
obj/charset.o \ obj/charset.o \
@ -153,6 +155,7 @@ OBJ = obj/arabic.o \
$(TERMLIB) $(TERMLIB)
PRO = proto/arabic.pro \ PRO = proto/arabic.pro \
proto/autocmd.pro \
proto/blowfish.pro \ proto/blowfish.pro \
proto/buffer.pro \ proto/buffer.pro \
proto/charset.pro \ proto/charset.pro \
@ -256,6 +259,9 @@ $(OBJ): $(SYMS)
obj/arabic.o: arabic.c obj/arabic.o: arabic.c
$(CCSYM) $@ arabic.c $(CCSYM) $@ arabic.c
obj/autocmd.o: autocmd.c
$(CCSYM) $@ autocmd.c
obj/blowfish.o: blowfish.c obj/blowfish.o: blowfish.c
$(CCSYM) $@ blowfish.c $(CCSYM) $@ blowfish.c

View File

@ -25,6 +25,7 @@ RM = rm
${CC} ${CFLAGS} $< -o $@ ${CC} ${CFLAGS} $< -o $@
SRC = arabic.c \ SRC = arabic.c \
autocmd.c \
blowfish.c \ blowfish.c \
buffer.c \ buffer.c \
charset.c \ charset.c \

View File

@ -700,6 +700,7 @@ INCL = vim.h alloc.h arabic.h ascii.h ex_cmds.h farsi.h feature.h globals.h \
OBJ = \ OBJ = \
$(OUTDIR)\arabic.obj \ $(OUTDIR)\arabic.obj \
$(OUTDIR)\autocmd.obj \
$(OUTDIR)\beval.obj \ $(OUTDIR)\beval.obj \
$(OUTDIR)\blob.obj \ $(OUTDIR)\blob.obj \
$(OUTDIR)\blowfish.obj \ $(OUTDIR)\blowfish.obj \
@ -1345,6 +1346,8 @@ $(NEW_TESTS):
$(OUTDIR)/arabic.obj: $(OUTDIR) arabic.c $(INCL) $(OUTDIR)/arabic.obj: $(OUTDIR) arabic.c $(INCL)
$(OUTDIR)/autocmd.obj: $(OUTDIR) autocmd.c $(INCL)
$(OUTDIR)/beval.obj: $(OUTDIR) beval.c $(INCL) $(OUTDIR)/beval.obj: $(OUTDIR) beval.c $(INCL)
$(OUTDIR)/blob.obj: $(OUTDIR) blob.c $(INCL) $(OUTDIR)/blob.obj: $(OUTDIR) blob.c $(INCL)
@ -1619,6 +1622,7 @@ auto:
# End Custom Build # End Custom Build
proto.h: \ proto.h: \
proto/arabic.pro \ proto/arabic.pro \
proto/autocmd.pro \
proto/blob.pro \ proto/blob.pro \
proto/blowfish.pro \ proto/blowfish.pro \
proto/buffer.pro \ proto/buffer.pro \

View File

@ -90,6 +90,7 @@ PROPT = DEF=PROTO GPROTO GPPARM MAXIMUMERRORS=999 GENPROTOSTATICS GENPROTOPARAME
SRC = \ SRC = \
arabic.c \ arabic.c \
autocmd.c \
blowfish.c \ blowfish.c \
buffer.c \ buffer.c \
charset.c \ charset.c \
@ -148,6 +149,7 @@ SRC = \
OBJ = \ OBJ = \
arabic.o \ arabic.o \
autocmd.o \
blowfish.o \ blowfish.o \
buffer.o \ buffer.o \
charset.o \ charset.o \
@ -206,6 +208,7 @@ OBJ = \
PRO = \ PRO = \
proto/arabic.pro \ proto/arabic.pro \
proto/autocmd.pro \
proto/blowfish.pro \ proto/blowfish.pro \
proto/buffer.pro \ proto/buffer.pro \
proto/charset.pro \ proto/charset.pro \
@ -319,6 +322,8 @@ $(PRO): $(GST) vim.h
# dependencies # dependencies
arabic.o: arabic.c arabic.o: arabic.c
proto/arabic.pro: arabic.c proto/arabic.pro: arabic.c
autocmd.o: autocmd.c
proto/autocmd.pro: autocmd.c
blowfish.o: blowfish.c blowfish.o: blowfish.c
proto/blowfish.pro: blowfish.c proto/blowfish.pro: blowfish.c
buffer.o: buffer.c buffer.o: buffer.c

View File

@ -312,7 +312,7 @@ ALL_CFLAGS_VER = /def=($(MODEL_DEF)$(DEFS)$(DEBUG_DEF)$(PERL_DEF)$(PYTHON_DEF) -
ALL_LIBS = $(LIBS) $(GUI_LIB_DIR) $(GUI_LIB) \ ALL_LIBS = $(LIBS) $(GUI_LIB_DIR) $(GUI_LIB) \
$(PERL_LIB) $(PYTHON_LIB) $(TCL_LIB) $(RUBY_LIB) $(PERL_LIB) $(PYTHON_LIB) $(TCL_LIB) $(RUBY_LIB)
SRC = arabic.c beval.obj blob.c blowfish.c buffer.c charset.c crypt.c crypt_zip.c dict.c diff.c digraph.c edit.c eval.c \ SRC = arabic.c autocmd.c beval.c blob.c blowfish.c buffer.c charset.c crypt.c crypt_zip.c dict.c diff.c digraph.c edit.c eval.c \
evalfunc.c ex_cmds.c ex_cmds2.c ex_docmd.c ex_eval.c ex_getln.c if_cscope.c if_xcmdsrv.c farsi.c fileio.c fold.c \ evalfunc.c ex_cmds.c ex_cmds2.c ex_docmd.c ex_eval.c ex_getln.c if_cscope.c if_xcmdsrv.c farsi.c fileio.c fold.c \
getchar.c hardcopy.c hashtab.c json.c list.c main.c mark.c menu.c mbyte.c memfile.c memline.c message.c misc1.c \ getchar.c hardcopy.c hashtab.c json.c list.c main.c mark.c menu.c mbyte.c memfile.c memline.c message.c misc1.c \
misc2.c move.c normal.c ops.c option.c popupmnu.c quickfix.c regexp.c search.c sha256.c sign.c \ misc2.c move.c normal.c ops.c option.c popupmnu.c quickfix.c regexp.c search.c sha256.c sign.c \
@ -321,7 +321,7 @@ SRC = arabic.c beval.obj blob.c blowfish.c buffer.c charset.c crypt.c crypt_zip.
$(GUI_SRC) $(PERL_SRC) $(PYTHON_SRC) $(TCL_SRC) \ $(GUI_SRC) $(PERL_SRC) $(PYTHON_SRC) $(TCL_SRC) \
$(RUBY_SRC) $(HANGULIN_SRC) $(MZSCH_SRC) $(XDIFF_SRC) $(RUBY_SRC) $(HANGULIN_SRC) $(MZSCH_SRC) $(XDIFF_SRC)
OBJ = arabic.obj beval.obj blob.obj blowfish.obj buffer.obj charset.obj crypt.obj crypt_zip.obj dict.obj diff.obj digraph.obj \ OBJ = arabic.obj autocmd.obj beval.obj blob.obj blowfish.obj buffer.obj charset.obj crypt.obj crypt_zip.obj dict.obj diff.obj digraph.obj \
edit.obj eval.obj evalfunc.obj ex_cmds.obj ex_cmds2.obj ex_docmd.obj ex_eval.obj ex_getln.obj if_cscope.obj \ edit.obj eval.obj evalfunc.obj ex_cmds.obj ex_cmds2.obj ex_docmd.obj ex_eval.obj ex_getln.obj if_cscope.obj \
if_xcmdsrv.obj farsi.obj fileio.obj fold.obj getchar.obj hardcopy.obj hashtab.obj json.obj list.obj main.obj mark.obj \ if_xcmdsrv.obj farsi.obj fileio.obj fold.obj getchar.obj hardcopy.obj hashtab.obj json.obj list.obj main.obj mark.obj \
menu.obj memfile.obj memline.obj message.obj misc1.obj misc2.obj \ menu.obj memfile.obj memline.obj message.obj misc1.obj misc2.obj \
@ -500,6 +500,7 @@ ruby_env :
.ENDIF .ENDIF
arabic.obj : arabic.c vim.h arabic.obj : arabic.c vim.h
autocmd.obj : autocmd.c vim.h [.auto]config.h feature.h os_unix.h
blowfish.obj : blowfish.c vim.h [.auto]config.h feature.h os_unix.h blowfish.obj : blowfish.c vim.h [.auto]config.h feature.h os_unix.h
blob.obj : blob.c vim.h [.auto]config.h feature.h os_unix.h blob.obj : blob.c vim.h [.auto]config.h feature.h os_unix.h
buffer.obj : buffer.c vim.h [.auto]config.h feature.h os_unix.h \ buffer.obj : buffer.c vim.h [.auto]config.h feature.h os_unix.h \

View File

@ -1572,6 +1572,7 @@ include testdir/Make_all.mak
BASIC_SRC = \ BASIC_SRC = \
arabic.c \ arabic.c \
autocmd.c \
beval.c \ beval.c \
blob.c \ blob.c \
blowfish.c \ blowfish.c \
@ -1684,6 +1685,7 @@ LINT_SRC = $(BASIC_SRC) $(GUI_SRC) $(HANGULIN_SRC) \
OBJ_COMMON = \ OBJ_COMMON = \
objects/arabic.o \ objects/arabic.o \
objects/autocmd.o \
objects/beval.o \ objects/beval.o \
objects/buffer.o \ objects/buffer.o \
objects/blob.o \ objects/blob.o \
@ -1809,6 +1811,7 @@ ALL_OBJ = $(OBJ_COMMON) \
PRO_AUTO = \ PRO_AUTO = \
arabic.pro \ arabic.pro \
autocmd.pro \
blowfish.pro \ blowfish.pro \
buffer.pro \ buffer.pro \
charset.pro \ charset.pro \
@ -2934,6 +2937,9 @@ $(ALL_OBJ): objects/.dirstamp
objects/arabic.o: arabic.c objects/arabic.o: arabic.c
$(CCC) -o $@ arabic.c $(CCC) -o $@ arabic.c
objects/autocmd.o: autocmd.c
$(CCC) -o $@ autocmd.c
objects/blob.o: blob.c objects/blob.o: blob.c
$(CCC) -o $@ blob.c $(CCC) -o $@ blob.c
@ -3376,6 +3382,10 @@ objects/arabic.o: arabic.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
proto.h globals.h farsi.h arabic.h proto.h globals.h farsi.h arabic.h
objects/autocmd.o: autocmd.c vim.h protodef.h auto/config.h feature.h \
os_unix.h os_mac.h ascii.h keymap.h term.h macros.h option.h beval.h \
structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h proto.h globals.h \
farsi.h arabic.h
objects/beval.o: beval.c vim.h protodef.h auto/config.h feature.h os_unix.h \ objects/beval.o: beval.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \

View File

@ -17,6 +17,7 @@ use the CTRL-] command. Use CTRL-T or CTRL-O to jump back.
To jump to a file, move the cursor on its name and use the "gf" command. To jump to a file, move the cursor on its name and use the "gf" command.
Most code can be found in a file with an obvious name (incomplete list): Most code can be found in a file with an obvious name (incomplete list):
autocmd.c autocommands
buffer.c manipulating buffers (loaded files) buffer.c manipulating buffers (loaded files)
diff.c diff mode (vimdiff) diff.c diff mode (vimdiff)
eval.c expression evaluation eval.c expression evaluation

2579
src/autocmd.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -397,6 +397,7 @@ EXTERN int autocmd_no_enter INIT(= FALSE); /* *Enter autocmds disabled */
EXTERN int autocmd_no_leave INIT(= FALSE); /* *Leave autocmds disabled */ EXTERN int autocmd_no_leave INIT(= FALSE); /* *Leave autocmds disabled */
EXTERN int modified_was_set; /* did ":set modified" */ EXTERN int modified_was_set; /* did ":set modified" */
EXTERN int did_filetype INIT(= FALSE); /* FileType event found */ EXTERN int did_filetype INIT(= FALSE); /* FileType event found */
EXTERN int au_did_filetype INIT(= FALSE);
EXTERN int keep_filetype INIT(= FALSE); /* value for did_filetype when EXTERN int keep_filetype INIT(= FALSE); /* value for did_filetype when
starting to execute starting to execute
autocommands */ autocommands */

View File

@ -62,6 +62,7 @@ extern int _stricoll(char *a, char *b);
# include "crypt.pro" # include "crypt.pro"
# include "crypt_zip.pro" # include "crypt_zip.pro"
# endif # endif
# include "autocmd.pro"
# include "buffer.pro" # include "buffer.pro"
# include "charset.pro" # include "charset.pro"
# ifdef FEAT_CSCOPE # ifdef FEAT_CSCOPE

39
src/proto/autocmd.pro Normal file
View File

@ -0,0 +1,39 @@
/* autocmd.c */
void aubuflocal_remove(buf_T *buf);
int au_has_group(char_u *name);
void do_augroup(char_u *arg, int del_group);
void free_all_autocmds(void);
int check_ei(void);
char_u *au_event_disable(char *what);
void au_event_restore(char_u *old_ei);
void do_autocmd(char_u *arg_in, int forceit);
int do_doautocmd(char_u *arg, int do_msg, int *did_something);
void ex_doautoall(exarg_T *eap);
int check_nomodeline(char_u **argp);
void aucmd_prepbuf(aco_save_T *aco, buf_T *buf);
void aucmd_restbuf(aco_save_T *aco);
int apply_autocmds(event_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf);
int apply_autocmds_exarg(event_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf, exarg_T *eap);
int apply_autocmds_retval(event_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf, int *retval);
int has_cursorhold(void);
int trigger_cursorhold(void);
int has_cursormoved(void);
int has_cursormovedI(void);
int has_textchanged(void);
int has_textchangedI(void);
int has_textchangedP(void);
int has_insertcharpre(void);
int has_cmdundefined(void);
int has_funcundefined(void);
int has_textyankpost(void);
void block_autocmds(void);
void unblock_autocmds(void);
int is_autocmd_blocked(void);
char_u *getnextac(int c, void *cookie, int indent);
int has_autocmd(event_T event, char_u *sfname, buf_T *buf);
char_u *get_augroup_name(expand_T *xp, int idx);
char_u *set_context_in_autocmd(expand_T *xp, char_u *arg, int doautocmd);
char_u *get_event_name(expand_T *xp, int idx);
int autocmd_supported(char_u *name);
int au_exists(char_u *arg);
/* vim: set ft=c : */

View File

@ -28,42 +28,7 @@ int delete_recursive(char_u *name);
void vim_deltempdir(void); void vim_deltempdir(void);
char_u *vim_tempname(int extra_char, int keep); char_u *vim_tempname(int extra_char, int keep);
void forward_slash(char_u *fname); void forward_slash(char_u *fname);
void aubuflocal_remove(buf_T *buf); int match_file_pat(char_u *pattern, regprog_T **prog, char_u *fname, char_u *sfname, char_u *tail, int allow_dirs);
int au_has_group(char_u *name);
void do_augroup(char_u *arg, int del_group);
void free_all_autocmds(void);
int check_ei(void);
char_u *au_event_disable(char *what);
void au_event_restore(char_u *old_ei);
void do_autocmd(char_u *arg_in, int forceit);
int do_doautocmd(char_u *arg, int do_msg, int *did_something);
void ex_doautoall(exarg_T *eap);
int check_nomodeline(char_u **argp);
void aucmd_prepbuf(aco_save_T *aco, buf_T *buf);
void aucmd_restbuf(aco_save_T *aco);
int apply_autocmds(event_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf);
int apply_autocmds_retval(event_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf, int *retval);
int has_cursorhold(void);
int trigger_cursorhold(void);
int has_cursormoved(void);
int has_cursormovedI(void);
int has_textchanged(void);
int has_textchangedI(void);
int has_textchangedP(void);
int has_insertcharpre(void);
int has_cmdundefined(void);
int has_funcundefined(void);
int has_textyankpost(void);
void block_autocmds(void);
void unblock_autocmds(void);
int is_autocmd_blocked(void);
char_u *getnextac(int c, void *cookie, int indent);
int has_autocmd(event_T event, char_u *sfname, buf_T *buf);
char_u *get_augroup_name(expand_T *xp, int idx);
char_u *set_context_in_autocmd(expand_T *xp, char_u *arg, int doautocmd);
char_u *get_event_name(expand_T *xp, int idx);
int autocmd_supported(char_u *name);
int au_exists(char_u *arg);
int match_file_list(char_u *list, char_u *sfname, char_u *ffname); int match_file_list(char_u *list, char_u *sfname, char_u *ffname);
char_u *file_pat_to_reg_pat(char_u *pat, char_u *pat_end, char *allow_dirs, int no_bslash); char_u *file_pat_to_reg_pat(char_u *pat, char_u *pat_end, char *allow_dirs, int no_bslash);
long read_eintr(int fd, void *buf, size_t bufsize); long read_eintr(int fd, void *buf, size_t bufsize);

View File

@ -787,6 +787,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
825,
/**/ /**/
824, 824,
/**/ /**/