Macros | Functions
autocmd.c File Reference
#include "nvim/api/private/helpers.h"
#include "nvim/ascii.h"
#include "nvim/autocmd.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/eval/userfunc.h"
#include "nvim/ex_docmd.h"
#include "nvim/fileio.h"
#include "nvim/getchar.h"
#include "nvim/misc1.h"
#include "nvim/option.h"
#include "nvim/regexp.h"
#include "nvim/search.h"
#include "nvim/state.h"
#include "nvim/ui_compositor.h"
#include "nvim/vim.h"

Macros

#define AUGROUP_NAME(i)   (((char **)augroups.ga_data)[i])
 
#define BUFLOCAL_PAT_LEN   25
 

Functions

void aubuflocal_remove (buf_T *buf)
 
bool au_has_group (const char_u *name) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
void do_augroup (char_u *arg, int del_group)
 ":augroup {name}". More...
 
int check_ei (void)
 
char_uau_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, bool do_msg, bool *did_something)
 
void ex_doautoall (exarg_T *eap)
 
bool check_nomodeline (char_u **argp) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
 
void aucmd_prepbuf (aco_save_T *aco, buf_T *buf)
 
void aucmd_restbuf (aco_save_T *aco)
 
bool apply_autocmds (event_T event, char_u *fname, char_u *fname_io, bool force, buf_T *buf)
 
bool apply_autocmds_exarg (event_T event, char_u *fname, char_u *fname_io, bool force, buf_T *buf, exarg_T *eap)
 
bool apply_autocmds_retval (event_T event, char_u *fname, char_u *fname_io, bool force, buf_T *buf, int *retval)
 
bool has_event (event_T event) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
bool has_cursorhold (void)
 
bool trigger_cursorhold (void)
 Return true if the CursorHold/CursorHoldI event can be triggered. More...
 
void block_autocmds (void)
 
void unblock_autocmds (void)
 
bool is_autocmd_blocked (void)
 
void auto_next_pat (AutoPatCmd *apc, int stop_at_last)
 
char_ugetnextac (int c, void *cookie, int indent, bool do_concat)
 
bool has_autocmd (event_T event, char_u *sfname, buf_T *buf) FUNC_ATTR_WARN_UNUSED_RESULT
 
char_uget_augroup_name (expand_T *xp, int idx)
 
char_uset_context_in_autocmd (expand_T *xp, char_u *arg, int doautocmd)
 
char_uget_event_name (expand_T *xp, int idx)
 
bool autocmd_supported (const char *const event) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
bool au_exists (const char *const arg) FUNC_ATTR_WARN_UNUSED_RESULT
 

Macro Definition Documentation

◆ AUGROUP_NAME

#define AUGROUP_NAME (   i)    (((char **)augroups.ga_data)[i])

◆ BUFLOCAL_PAT_LEN

#define BUFLOCAL_PAT_LEN   25

Function Documentation

◆ apply_autocmds()

bool apply_autocmds ( event_T  event,
char_u fname,
char_u fname_io,
bool  force,
buf_T buf 
)

Execute autocommands for "event" and file name "fname".

Parameters
eventevent that occurred
fnamefilename, NULL or empty means use actual file name
fname_iofilename to use for <afile> on cmdline
forceWhen true, ignore autocmd_busy
bufBuffer for <abuf>
Returns
true if some commands were executed.

◆ apply_autocmds_exarg()

bool apply_autocmds_exarg ( event_T  event,
char_u fname,
char_u fname_io,
bool  force,
buf_T buf,
exarg_T eap 
)

Like apply_autocmds(), but with extra "eap" argument. This takes care of setting v:filearg.

Parameters
eventevent that occurred
fnameNULL or empty means use actual file name
fname_iofname to use for <afile> on cmdline
forceWhen true, ignore autocmd_busy
bufBuffer for <abuf>
exargEx command arguments
Returns
true if some commands were executed.

◆ apply_autocmds_retval()

bool apply_autocmds_retval ( event_T  event,
char_u fname,
char_u fname_io,
bool  force,
buf_T buf,
int *  retval 
)

Like apply_autocmds(), but handles the caller's retval. If the script processing is being aborted or if retval is FAIL when inside a try conditional, no autocommands are executed. If otherwise the autocommands cause the script to be aborted, retval is set to FAIL.

Parameters
eventevent that occurred
fnameNULL or empty means use actual file name
fname_iofname to use for <afile> on cmdline
forceWhen true, ignore autocmd_busy
bufBuffer for <abuf>
[in,out]retvalcaller's retval
Returns
true if some autocommands were executed

◆ au_event_disable()

char_u* au_event_disable ( char *  what)

◆ au_event_restore()

void au_event_restore ( char_u old_ei)

◆ au_exists()

bool au_exists ( const char *const  arg)

Return true if an autocommand is defined for a group, event and pattern: The group can be omitted to accept any group. event and pattern can be omitted to accept any event and pattern. Buffer-local patterns <buffer> or <buffer=N> are accepted. Used for: exists("#Group") or exists("#Group#Event") or exists("#Group#Event#pat") or exists("#Event") or exists("#Event#pat")

Parameters
argautocommand string

◆ au_has_group()

bool au_has_group ( const char_u name)

Return true if augroup "name" exists.

Parameters
nameaugroup name

◆ aubuflocal_remove()

void aubuflocal_remove ( buf_T buf)

◆ aucmd_prepbuf()

void aucmd_prepbuf ( aco_save_T aco,
buf_T buf 
)

Prepare for executing autocommands for (hidden) buffer buf. If the current buffer is not in any visible window, put it in a temporary floating window aucmd_win. Set curbuf and curwin to match buf.

Parameters
acostructure to save values in
bufnew curbuf

◆ aucmd_restbuf()

void aucmd_restbuf ( aco_save_T aco)

Cleanup after executing autocommands for a (hidden) buffer. Restore the window as it was (if possible).

Parameters
acostructure holding saved values

◆ auto_next_pat()

void auto_next_pat ( AutoPatCmd apc,
int  stop_at_last 
)

Find next autocommand pattern that matches. stop when 'last' flag is set

◆ autocmd_supported()

bool autocmd_supported ( const char *const  event)

Check whether given autocommand is supported

Parameters
[in]eventEvent to check.
Returns
True if it is, false otherwise.

◆ block_autocmds()

void block_autocmds ( void  )

◆ check_ei()

int check_ei ( void  )

◆ check_nomodeline()

bool check_nomodeline ( char_u **  argp)

Check *argp for <nomodeline>. When it is present return false, otherwise return true and advance *argp to after it. Thus do_modelines() should be called when true is returned.

Parameters
[in,out]argpargument string

◆ do_augroup()

void do_augroup ( char_u arg,
int  del_group 
)

":augroup {name}".

◆ do_autocmd()

void do_autocmd ( char_u arg_in,
int  forceit 
)

◆ do_doautocmd()

int do_doautocmd ( char_u arg,
bool  do_msg,
bool did_something 
)

Implementation of ":doautocmd [group] event [fname]". Return OK for success, FAIL for failure;

Parameters
do_msggive message for no matching autocmds?

◆ ex_doautoall()

void ex_doautoall ( exarg_T eap)

◆ get_augroup_name()

char_u* get_augroup_name ( expand_T xp,
int  idx 
)

◆ get_event_name()

char_u* get_event_name ( expand_T xp,
int  idx 
)

◆ getnextac()

char_u* getnextac ( int  c,
void cookie,
int  indent,
bool  do_concat 
)

Get next autocommand command. Called by do_cmdline() to get the next line for ":if".

Returns
allocated string, or NULL for end of autocommands.

◆ has_autocmd()

bool has_autocmd ( event_T  event,
char_u sfname,
buf_T buf 
)

Return true if there is a matching autocommand for "fname". To account for buffer-local autocommands, function needs to know in which buffer the file will be opened.

Parameters
eventevent that occurred.
sfnamefilename the event occurred in.
bufbuffer the file is open in

◆ has_cursorhold()

bool has_cursorhold ( void  )

Return true when there is a CursorHold/CursorHoldI autocommand defined for the current mode.

◆ has_event()

bool has_event ( event_T  event)

Return true if "event" autocommand is defined.

Parameters
eventthe autocommand to check

◆ is_autocmd_blocked()

bool is_autocmd_blocked ( void  )

◆ set_context_in_autocmd()

char_u* set_context_in_autocmd ( expand_T xp,
char_u arg,
int  doautocmd 
)
Parameters
doautocmdtrue for :doauto*, false for :autocmd

◆ trigger_cursorhold()

bool trigger_cursorhold ( void  )

Return true if the CursorHold/CursorHoldI event can be triggered.

◆ unblock_autocmds()

void unblock_autocmds ( void  )