autocmd.h
Go to the documentation of this file.
1 #ifndef NVIM_AUTOCMD_H
2 #define NVIM_AUTOCMD_H
3 
4 #include "nvim/buffer_defs.h"
5 #include "nvim/ex_cmds_defs.h"
6 
7 // event_T definition
8 #ifdef INCLUDE_GENERATED_DECLARATIONS
9 # include "auevents_enum.generated.h"
10 #endif
11 
12 // Struct to save values in before executing autocommands for a buffer that is
13 // not the current buffer.
14 typedef struct {
21  char *globaldir;
23 } aco_save_T;
24 
25 typedef struct AutoCmd {
27  bool once; // "One shot": removed after execution
28  bool nested; // If autocommands nest here
29  bool last; // last command in list
30  int64_t id; // ID used for uniquely tracking an autocmd.
31  sctx_T script_ctx; // script context where defined
32  char *desc; // Description for the autocmd.
33  struct AutoCmd *next; // Next AutoCmd in list
34 } AutoCmd;
35 
36 typedef struct AutoPat {
37  struct AutoPat *next; // next AutoPat in AutoPat list; MUST
38  // be the first entry
39  char *pat; // pattern as typed (NULL when pattern
40  // has been removed)
41  regprog_T *reg_prog; // compiled regprog for pattern
42  AutoCmd *cmds; // list of commands to do
43  int group; // group ID
44  int patlen; // strlen() of pat
45  int buflocal_nr; // !=0 for buffer-local AutoPat
46  char allow_dirs; // Pattern may match whole path
47  char last; // last pattern for apply_autocmds()
48 } AutoPat;
49 
51 typedef struct AutoPatCmd {
52  AutoPat *curpat; // next AutoPat to examine
53  AutoCmd *nextcmd; // next AutoCmd to execute
54  int group; // group being used
55  char *fname; // fname to match with
56  char *sfname; // sfname to match with
57  char *tail; // tail of fname
58  event_T event; // current event
59  int arg_bufnr; // initially equal to <abuf>, set to zero when buf is deleted
60  struct AutoPatCmd *next; // chain of active apc-s for auto-invalidation
61 } AutoPatCmd;
62 
63 
64 // Set by the apply_autocmds_group function if the given event is equal to
65 // EVENT_FILETYPE. Used by the readfile function in order to determine if
66 // EVENT_BUFREADPOST triggered the EVENT_FILETYPE.
67 //
68 // Relying on this value requires one to reset it prior calling
69 // apply_autocmds_group.
70 EXTERN bool au_did_filetype INIT(= false);
71 
72 
73 #ifdef INCLUDE_GENERATED_DECLARATIONS
74 # include "autocmd.h.generated.h"
75 #endif
76 
77 #define AUGROUP_DEFAULT (-1) // default autocmd group
78 #define AUGROUP_ERROR (-2) // erroneous autocmd group
79 #define AUGROUP_ALL (-3) // all autocmd groups
80 #define AUGROUP_DELETED (-4) // all autocmd groups
81 // #define AUGROUP_NS -5 // TODO(tjdevries): Support namespaced based augroups
82 
83 #define BUFLOCAL_PAT_LEN 25
84 
86 #define FOR_ALL_AUEVENTS(event) \
87  for (event_T event = (event_T)0; (int)event < (int)NUM_EVENTS; event = (event_T)((int)event + 1)) // NOLINT
88 
89 #endif // NVIM_AUTOCMD_H
AutoPatCmd::fname
char * fname
Definition: autocmd.h:55
AutoCmd::desc
char * desc
Definition: autocmd.h:32
INIT
EXTERN bool au_did_filetype INIT(=false)
AutoCmd::next
struct AutoCmd * next
Definition: autocmd.h:33
AutoPatCmd::tail
char * tail
Definition: autocmd.h:57
AutoPat::cmds
AutoCmd * cmds
Definition: autocmd.h:42
AutoPat::next
struct AutoPat * next
Definition: autocmd.h:37
aco_save_T::save_VIsual_active
bool save_VIsual_active
saved VIsual_active
Definition: autocmd.h:22
AutoCmd::nested
bool nested
Definition: autocmd.h:28
AutoPatCmd::event
event_T event
Definition: autocmd.h:58
AutoPatCmd
struct AutoPatCmd AutoPatCmd
Struct used to keep status while executing autocommands for an event.
regprog
Definition: regexp_defs.h:70
AutoCmd::exec
AucmdExecutable exec
Definition: autocmd.h:26
aco_save_T::save_curwin_handle
handle_T save_curwin_handle
ID of saved curwin.
Definition: autocmd.h:17
aucmd_executable_t
Definition: ex_cmds_defs.h:114
AutoPatCmd::nextcmd
AutoCmd * nextcmd
Definition: autocmd.h:53
AutoPatCmd::next
struct AutoPatCmd * next
Definition: autocmd.h:60
sctx_T
Definition: typval.h:280
aco_save_T
Definition: autocmd.h:14
AutoCmd::last
bool last
Definition: autocmd.h:29
AutoPat::buflocal_nr
int buflocal_nr
Definition: autocmd.h:45
AutoPatCmd
Struct used to keep status while executing autocommands for an event.
Definition: autocmd.h:51
AutoCmd::once
bool once
Definition: autocmd.h:27
AutoPat
Definition: autocmd.h:36
AutoPat::allow_dirs
char allow_dirs
Definition: autocmd.h:46
AutoPatCmd::arg_bufnr
int arg_bufnr
Definition: autocmd.h:59
AutoPat
struct AutoPat AutoPat
aco_save_T::new_curwin_handle
handle_T new_curwin_handle
ID of new curwin.
Definition: autocmd.h:18
aco_save_T::use_aucmd_win
bool use_aucmd_win
using aucmd_win
Definition: autocmd.h:16
aco_save_T::save_prevwin_handle
handle_T save_prevwin_handle
ID of saved prevwin.
Definition: autocmd.h:19
EXTERN
#define EXTERN
Definition: macros.h:9
aco_save_T::globaldir
char * globaldir
saved value of globaldir
Definition: autocmd.h:21
aco_save_T::new_curbuf
bufref_T new_curbuf
new curbuf
Definition: autocmd.h:20
AutoPat::pat
char * pat
Definition: autocmd.h:39
AutoCmd
Definition: autocmd.h:25
AutoPat::reg_prog
regprog_T * reg_prog
Definition: autocmd.h:41
bufref_T
Definition: buffer_defs.h:13
handle_T
int handle_T
Definition: types.h:18
file_buffer
Definition: buffer_defs.h:521
ex_cmds_defs.h
AutoPat::patlen
int patlen
Definition: autocmd.h:44
aco_save_T::save_curbuf
buf_T * save_curbuf
saved curbuf
Definition: autocmd.h:15
AutoPatCmd::curpat
AutoPat * curpat
Definition: autocmd.h:52
AutoPatCmd::sfname
char * sfname
Definition: autocmd.h:56
buffer_defs.h
AutoCmd::script_ctx
sctx_T script_ctx
Definition: autocmd.h:31
AutoPat::last
char last
Definition: autocmd.h:47
AutoPatCmd::group
int group
Definition: autocmd.h:54
AutoCmd
struct AutoCmd AutoCmd
AutoCmd::id
int64_t id
Definition: autocmd.h:30
AutoPat::group
int group
Definition: autocmd.h:43