mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.1.0825: code for autocommands is mixed with file I/O code (#13305)
This commit is contained in:
parent
a6bd52d877
commit
7574918dc7
2092
src/nvim/autocmd.c
Normal file
2092
src/nvim/autocmd.c
Normal file
File diff suppressed because it is too large
Load Diff
81
src/nvim/autocmd.h
Normal file
81
src/nvim/autocmd.h
Normal file
@ -0,0 +1,81 @@
|
||||
#ifndef NVIM_AUTOCMD_H
|
||||
#define NVIM_AUTOCMD_H
|
||||
|
||||
#include "nvim/buffer_defs.h"
|
||||
#include "nvim/ex_cmds_defs.h"
|
||||
|
||||
// Struct to save values in before executing autocommands for a buffer that is
|
||||
// not the current buffer.
|
||||
typedef struct {
|
||||
buf_T *save_curbuf; ///< saved curbuf
|
||||
int use_aucmd_win; ///< using aucmd_win
|
||||
win_T *save_curwin; ///< saved curwin
|
||||
win_T *save_prevwin; ///< saved prevwin
|
||||
win_T *new_curwin; ///< new curwin
|
||||
bufref_T new_curbuf; ///< new curbuf
|
||||
char_u *globaldir; ///< saved value of globaldir
|
||||
} aco_save_T;
|
||||
|
||||
typedef struct AutoCmd {
|
||||
char_u *cmd; // Command to be executed (NULL when
|
||||
// command has been removed)
|
||||
bool once; // "One shot": removed after execution
|
||||
bool nested; // If autocommands nest here
|
||||
bool last; // last command in list
|
||||
sctx_T script_ctx; // script context where defined
|
||||
struct AutoCmd *next; // Next AutoCmd in list
|
||||
} AutoCmd;
|
||||
|
||||
typedef struct AutoPat {
|
||||
struct AutoPat *next; // next AutoPat in AutoPat list; MUST
|
||||
// be the first entry
|
||||
char_u *pat; // pattern as typed (NULL when pattern
|
||||
// has been removed)
|
||||
regprog_T *reg_prog; // compiled regprog for pattern
|
||||
AutoCmd *cmds; // list of commands to do
|
||||
int group; // group ID
|
||||
int patlen; // strlen() of pat
|
||||
int buflocal_nr; // !=0 for buffer-local AutoPat
|
||||
char allow_dirs; // Pattern may match whole path
|
||||
char last; // last pattern for apply_autocmds()
|
||||
} AutoPat;
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "auevents_enum.generated.h"
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Struct used to keep status while executing autocommands for an event.
|
||||
///
|
||||
typedef struct AutoPatCmd {
|
||||
AutoPat *curpat; // next AutoPat to examine
|
||||
AutoCmd *nextcmd; // next AutoCmd to execute
|
||||
int group; // group being used
|
||||
char_u *fname; // fname to match with
|
||||
char_u *sfname; // sfname to match with
|
||||
char_u *tail; // tail of fname
|
||||
event_T event; // current event
|
||||
int arg_bufnr; // initially equal to <abuf>, set to zero when
|
||||
// buf is deleted
|
||||
struct AutoPatCmd *next; // chain of active apc-s for auto-invalidation
|
||||
} AutoPatCmd;
|
||||
|
||||
|
||||
// Set by the apply_autocmds_group function if the given event is equal to
|
||||
// EVENT_FILETYPE. Used by the readfile function in order to determine if
|
||||
// EVENT_BUFREADPOST triggered the EVENT_FILETYPE.
|
||||
//
|
||||
// Relying on this value requires one to reset it prior calling
|
||||
// apply_autocmds_group.
|
||||
EXTERN bool au_did_filetype INIT(= false);
|
||||
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "autocmd.h.generated.h"
|
||||
#endif
|
||||
|
||||
#define AUGROUP_DEFAULT -1 // default autocmd group
|
||||
#define AUGROUP_ERROR -2 // erroneous autocmd group
|
||||
#define AUGROUP_ALL -3 // all autocmd groups
|
||||
|
||||
#endif // NVIM_AUTOCMD_H
|
2147
src/nvim/fileio.c
2147
src/nvim/fileio.c
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,7 @@
|
||||
|
||||
#include "nvim/buffer_defs.h"
|
||||
#include "nvim/os/os.h"
|
||||
#include "nvim/autocmd.h"
|
||||
|
||||
// Values for readfile() flags
|
||||
#define READ_NEW 0x01 // read a file into a new buffer
|
||||
@ -15,23 +16,8 @@
|
||||
|
||||
#define READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))
|
||||
|
||||
/*
|
||||
* Struct to save values in before executing autocommands for a buffer that is
|
||||
* not the current buffer.
|
||||
*/
|
||||
typedef struct {
|
||||
buf_T *save_curbuf; ///< saved curbuf
|
||||
int use_aucmd_win; ///< using aucmd_win
|
||||
win_T *save_curwin; ///< saved curwin
|
||||
win_T *save_prevwin; ///< saved prevwin
|
||||
win_T *new_curwin; ///< new curwin
|
||||
bufref_T new_curbuf; ///< new curbuf
|
||||
char_u *globaldir; ///< saved value of globaldir
|
||||
} aco_save_T;
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
// Events for autocommands
|
||||
# include "auevents_enum.generated.h"
|
||||
# include "fileio.h.generated.h"
|
||||
#endif
|
||||
#endif // NVIM_FILEIO_H
|
||||
|
@ -41,22 +41,27 @@ names_tgt:write('\n {0, NULL, (event_T)0},')
|
||||
enum_tgt:write('\n} event_T;\n')
|
||||
names_tgt:write('\n};\n')
|
||||
|
||||
names_tgt:write('\nstatic AutoPat *first_autopat[NUM_EVENTS] = {\n ')
|
||||
local line_len = 1
|
||||
for _ = 1,((#events) - 1) do
|
||||
line_len = line_len + #(' NULL,')
|
||||
if line_len > 80 then
|
||||
names_tgt:write('\n ')
|
||||
line_len = 1 + #(' NULL,')
|
||||
local gen_autopat_events = function(name)
|
||||
names_tgt:write(string.format('\nstatic AutoPat *%s[NUM_EVENTS] = {\n ', name))
|
||||
local line_len = 1
|
||||
for _ = 1,((#events) - 1) do
|
||||
line_len = line_len + #(' NULL,')
|
||||
if line_len > 80 then
|
||||
names_tgt:write('\n ')
|
||||
line_len = 1 + #(' NULL,')
|
||||
end
|
||||
names_tgt:write(' NULL,')
|
||||
end
|
||||
names_tgt:write(' NULL,')
|
||||
if line_len + #(' NULL') > 80 then
|
||||
names_tgt:write('\n NULL')
|
||||
else
|
||||
names_tgt:write(' NULL')
|
||||
end
|
||||
names_tgt:write('\n};\n')
|
||||
end
|
||||
if line_len + #(' NULL') > 80 then
|
||||
names_tgt:write('\n NULL')
|
||||
else
|
||||
names_tgt:write(' NULL')
|
||||
end
|
||||
names_tgt:write('\n};\n')
|
||||
|
||||
gen_autopat_events("first_autopat")
|
||||
gen_autopat_events("last_autopat")
|
||||
|
||||
enum_tgt:close()
|
||||
names_tgt:close()
|
||||
|
Loading…
Reference in New Issue
Block a user