Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
ex_docmd.c File Reference
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "nvim/api/private/helpers.h"
#include "nvim/ascii.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/debugger.h"
#include "nvim/diff.h"
#include "nvim/digraph.h"
#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/eval/userfunc.h"
#include "nvim/event/rstream.h"
#include "nvim/event/wstream.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/ex_getln.h"
#include "nvim/ex_session.h"
#include "nvim/file_search.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/globals.h"
#include "nvim/hardcopy.h"
#include "nvim/if_cscope.h"
#include "nvim/keymap.h"
#include "nvim/lua/executor.h"
#include "nvim/main.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/menu.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
#include "nvim/mouse.h"
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/quickfix.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/search.h"
#include "nvim/shada.h"
#include "nvim/sign.h"
#include "nvim/spell.h"
#include "nvim/spellfile.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/tag.h"
#include "nvim/terminal.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/version.h"
#include "nvim/vim.h"
#include "nvim/window.h"

Data Structures

struct  ucmd
struct  wcmd_T
struct  loop_cookie
struct  dbg_stuff
struct  cmdmod


#define UC_BUFFER   1
#define USER_CMD(i)   (&((ucmd_T *)(ucmds.ga_data))[i])
#define USER_CMD_GA(gap, i)   (&((ucmd_T *)((gap)->ga_data))[i])
#define IS_USER_CMDIDX(idx)   ((int)(idx) < 0)
#define FREE_WCMD(wcmd)   xfree((wcmd)->line)
#define ex_language   ex_ni
#define CURRENT_WIN_NR   current_win_nr(curwin)
#define LAST_WIN_NR   current_win_nr(NULL)
#define CURRENT_TAB_NR   current_tab_nr(curtab)
#define LAST_TAB_NR   current_tab_nr(NULL)
#define ESCAPE_CHARS   escape_chars
#define FREE_AENTRY_FNAME(arg)   xfree(arg->ae_fname)


typedef struct ucmd ucmd_T


enum  {


void do_exmode (void)
 Repeatedly get commands for Ex mode, until the ":vi" command is given. More...
int do_cmdline_cmd (const char *cmd)
int do_cmdline (char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
int getline_equal (LineGetter fgetline, void *cookie, LineGetter func)
voidgetline_cookie (LineGetter fgetline, void *cookie)
int parse_command_modifiers (exarg_T *eap, char **errormsg, bool skip_only)
int parse_cmd_address (exarg_T *eap, char **errormsg, bool silent) FUNC_ATTR_NONNULL_ALL
int checkforcmd (char_u **pp, char *cmd, int len)
int modifier_len (char_u *cmd)
int cmd_exists (const char *const name)
const char * set_one_cmd_context (expand_T *xp, const char *buff)
char_uskip_range (const char_u *cmd, int *ctx)
void ex_ni (exarg_T *eap)
 Stub function for command which is Not Implemented. NI! More...
int expand_filename (exarg_T *eap, char_u **cmdlinep, char **errormsgp)
void separate_nextcmd (exarg_T *eap)
int get_bad_opt (const char_u *p, exarg_T *eap) FUNC_ATTR_NONNULL_ALL
int ends_excmd (int c) FUNC_ATTR_CONST
char_ufind_nextcmd (const char_u *p)
char_ucheck_nextcmd (char_u *p)
char_uget_command_name (expand_T *xp, int idx)
 replace_termcodes (rep, STRLEN(rep), &rep_buf, false, false, true, CPO_TO_CPO_FLAGS)
 if (rep_buf==NULL)
 if (flags &UC_BUFFER)
 for (i=0;i< gap->ga_len;++i)
 if (cmp !=0)
 xfree (compl_arg)
void ex_comclear (exarg_T *eap)
void uc_clear (garray_T *gap)
char_uget_user_cmd_addr_type (expand_T *xp, int idx)
char_uget_user_commands (expand_T *xp FUNC_ATTR_UNUSED, int idx) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
char_uget_user_cmd_flags (expand_T *xp, int idx)
char_uget_user_cmd_nargs (expand_T *xp, int idx)
char_uget_user_cmd_complete (expand_T *xp, int idx)
int parse_addr_type_arg (char_u *value, int vallen, cmd_addr_T *addr_type_arg) FUNC_ATTR_NONNULL_ALL
int parse_compl_arg (const char_u *value, int vallen, int *complp, uint32_t *argt, char_u **compl_arg) FUNC_ATTR_NONNULL_ALL
int cmdcomplete_str_to_type (const char *complete_str)
void not_exiting (void)
bool before_quit_autocmds (win_T *wp, bool quit_all, bool forceit)
void ex_win_close (int forceit, win_T *win, tabpage_T *tp)
void tabpage_close (int forceit)
void tabpage_close_other (tabpage_T *tp, int forceit)
void ex_all (exarg_T *eap)
void alist_clear (alist_T *al)
void alist_init (alist_T *al)
void alist_unlink (alist_T *al)
void alist_new (void)
void alist_expand (int *fnum_list, int fnum_len)
void alist_set (alist_T *al, int count, char_u **files, int use_curbuf, int *fnum_list, int fnum_len)
void alist_add (alist_T *al, char_u *fname, int set_fnum)
void ex_splitview (exarg_T *eap)
void tabpage_new (void)
void do_exedit (exarg_T *eap, win_T *old_curwin)
void post_chdir (CdScope scope, bool trigger_dirchanged)
bool changedir_func (char_u *new_dir, CdScope scope)
void ex_cd (exarg_T *eap)
 ":cd", ":tcd", ":lcd", ":chdir", "tchdir" and ":lchdir". More...
void do_sleep (long msec)
void ex_may_print (exarg_T *eap)
int vim_mkdir_emsg (const char *const name, const int prot) FUNC_ATTR_NONNULL_ALL
FILE * open_exfile (char_u *fname, int forceit, char *mode)
void update_topline_cursor (void)
bool save_current_state (save_state_T *sst) FUNC_ATTR_NONNULL_ALL
void restore_current_state (save_state_T *sst) FUNC_ATTR_NONNULL_ALL
void exec_normal_cmd (char_u *cmd, int remap, bool silent)
void exec_normal (bool was_typed)
ssize_t find_cmdline_var (const char_u *src, size_t *usedlen) FUNC_ATTR_NONNULL_ALL
char_ueval_vars (char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnump, char **errormsg, int *escaped)
char_uexpand_sfile (char_u *arg)
void dialog_msg (char_u *buff, char *format, char_u *fname)
char_uget_behave_arg (expand_T *xp, int idx)
char_uget_messages_arg (expand_T *xp FUNC_ATTR_UNUSED, int idx)
char_uget_mapclear_arg (expand_T *xp FUNC_ATTR_UNUSED, int idx)
void filetype_maybe_enable (void)
 Set all :filetype options ON if user did not explicitly set any to OFF. More...
void set_no_hlsearch (bool flag)
bool is_loclist_cmd (int cmdidx) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
bool get_pressedreturn (void)
void set_pressedreturn (bool val)
bool cmd_can_preview (char_u *cmd)
Dictionary commands_array (buf_T *buf)
void verify_command (char_u *cmd)


static int int i
int cmp = 1
char_urep_buf = NULL
cmd uc_rep = rep_buf
cmd uc_argt = argt
cmd uc_def = def
cmd uc_compl = compl
cmd uc_script_ctx = current_sctx
cmd uc_script_ctx sc_lnum = sourcing_lnum
cmd uc_compl_arg = compl_arg
cmd uc_addr_type = addr_type
return OK
fail __pad0__
return FAIL

Macro Definition Documentation


#define CURRENT_TAB_NR   current_tab_nr(curtab)


#define CURRENT_WIN_NR   current_win_nr(curwin)


#define ESCAPE_CHARS   escape_chars

◆ ex_language

#define ex_language   ex_ni


#define FREE_AENTRY_FNAME (   arg)    xfree(arg->ae_fname)


#define FREE_WCMD (   wcmd)    xfree((wcmd)->line)


#define IS_USER_CMDIDX (   idx)    ((int)(idx) < 0)


#define LAST_TAB_NR   current_tab_nr(NULL)


#define LAST_WIN_NR   current_win_nr(NULL)


#define UC_BUFFER   1


#define USER_CMD (   i)    (&((ucmd_T *)(ucmds.ga_data))[i])


#define USER_CMD_GA (   gap,
)    (&((ucmd_T *)((gap)->ga_data))[i])

Typedef Documentation

◆ ucmd_T

typedef struct ucmd ucmd_T

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Function Documentation

◆ alist_add()

void alist_add ( alist_T al,
char_u fname,
int  set_fnum 

Add file "fname" to argument list "al". "fname" must have been allocated and "al" must have been checked for room.

set_fnum1: set buffer number; 2: re-use curbuf

◆ alist_clear()

void alist_clear ( alist_T al)

◆ alist_expand()

void alist_expand ( int *  fnum_list,
int  fnum_len 

◆ alist_init()

void alist_init ( alist_T al)

◆ alist_new()

void alist_new ( void  )

◆ alist_set()

void alist_set ( alist_T al,
int  count,
char_u **  files,
int  use_curbuf,
int *  fnum_list,
int  fnum_len 

◆ alist_unlink()

void alist_unlink ( alist_T al)

◆ before_quit_autocmds()

bool before_quit_autocmds ( win_T wp,
bool  quit_all,
bool  forceit 

◆ changedir_func()

bool changedir_func ( char_u new_dir,
CdScope  scope 

Change directory function used by :cd/:tcd/:lcd Ex commands and the chdir() function.

new_dirThe directory to change to.
scopeScope of the function call (global, tab or window).
true if the directory is successfully changed.

◆ check_nextcmd()

char_u* check_nextcmd ( char_u p)

Check if *p is a separator between Ex commands, skipping over white space. Return NULL if it isn't, the following character if it is.

◆ checkforcmd()

int checkforcmd ( char_u **  pp,
char *  cmd,
int  len 

Check for an Ex command with optional tail. If there is a match advance "pp" to the argument and return TRUE.

ppstart of command
cmdname of command
lenrequired length

◆ cmd_can_preview()

bool cmd_can_preview ( char_u cmd)

Checks if cmd is "previewable" (i.e. supported by 'inccommand').

[in]cmdCommandline to check. May start with a range or modifier.
true if cmd is previewable

◆ cmd_exists()

int cmd_exists ( const char *const  name)

◆ cmdcomplete_str_to_type()

int cmdcomplete_str_to_type ( const char *  complete_str)

◆ commands_array()

Dictionary commands_array ( buf_T buf)

Gets a map of maps describing user-commands defined for buffer buf or defined globally if buf is NULL.

bufBuffer to inspect, or NULL to get global commands.
Map of maps describing commands

◆ dialog_msg()

void dialog_msg ( char_u buff,
char *  format,
char_u fname 

◆ do_cmdline()

int do_cmdline ( char_u cmdline,
LineGetter  fgetline,
void cookie,
int  flags 

do_cmdline(): execute one Ex command line

  1. Execute "cmdline" when it is not NULL. If "cmdline" is NULL, or more lines are needed, fgetline() is used.
  2. Split up in parts separated with '|'.

This function can be called recursively!

flags: DOCMD_VERBOSE - The command will be included in the error message. DOCMD_NOWAIT - Don't call wait_return() and friends. DOCMD_REPEAT - Repeat execution until fgetline() returns NULL. DOCMD_KEYTYPED - Don't reset KeyTyped. DOCMD_EXCRESET - Reset the exception environment (used for debugging). DOCMD_KEEPLINE - Store first typed line (for repeating with "."). DOCMD_PREVIEW - During 'inccommand' preview.

cookieargument for fgetline()
FAIL if cmdline could not be executed, OK otherwise

◆ do_cmdline_cmd()

int do_cmdline_cmd ( const char *  cmd)

◆ do_exedit()

void do_exedit ( exarg_T eap,
win_T old_curwin 

":edit <file>" command and alikes.

old_curwincurwin before doing a split or NULL

◆ do_exmode()

void do_exmode ( void  )

Repeatedly get commands for Ex mode, until the ":vi" command is given.

◆ do_sleep()

void do_sleep ( long  msec)

◆ ends_excmd()

int ends_excmd ( int  c)

◆ eval_vars()

char_u* eval_vars ( char_u src,
char_u srcstart,
size_t *  usedlen,
linenr_T lnump,
char **  errormsg,
int *  escaped 

Evaluate cmdline variables.

change '' to curbuf->b_ffname '#' to curwin->w_alt_fnum '<cword>' to word under the cursor '<cWORD>' to WORD under the cursor '<cexpr>' to C-expression under the cursor '<cfile>' to path name under the cursor '<sfile>' to sourced file name '<slnum>' to sourced file line number '<afile>' to file name for autocommand '<abuf>' to buffer number for autocommand '<amatch>' to matching name for autocommand

When an error is detected, "errormsg" is set to a non-NULL pointer (may be "" for error without a message) and NULL is returned.

srcpointer into commandline
srcstartbeginning of valid memory for src
usedlencharacters after src that are used
lnumpline number for :e command, or NULL
errormsgpointer to error message
escapedreturn value has escaped white space (can be NULL)
an allocated string if a valid match was found. Returns NULL if no match was found. "usedlen" then still contains the number of characters to skip.

◆ ex_all()

void ex_all ( exarg_T eap)

◆ ex_cd()

void ex_cd ( exarg_T eap)

":cd", ":tcd", ":lcd", ":chdir", "tchdir" and ":lchdir".

◆ ex_comclear()

void ex_comclear ( exarg_T eap)

◆ ex_may_print()

void ex_may_print ( exarg_T eap)

◆ ex_ni()

void ex_ni ( exarg_T eap)

Stub function for command which is Not Implemented. NI!

◆ ex_splitview()

void ex_splitview ( exarg_T eap)

◆ ex_win_close()

void ex_win_close ( int  forceit,
win_T win,
tabpage_T tp 

Close window "win" and take care of handling closing the last window for a modified buffer.

tpNULL or the tab page "win" is in

◆ exec_normal()

void exec_normal ( bool  was_typed)

Execute normal_cmd() until there is no typeahead left.

was_typedwhether or not something was typed

◆ exec_normal_cmd()

void exec_normal_cmd ( char_u cmd,
int  remap,
bool  silent 

◆ expand_filename()

int expand_filename ( exarg_T eap,
char_u **  cmdlinep,
char **  errormsgp 

◆ expand_sfile()

char_u* expand_sfile ( char_u arg)

◆ filetype_maybe_enable()

void filetype_maybe_enable ( void  )

Set all :filetype options ON if user did not explicitly set any to OFF.

◆ find_cmdline_var()

ssize_t find_cmdline_var ( const char_u src,
size_t *  usedlen 

◆ find_nextcmd()

char_u* find_nextcmd ( const char_u p)

◆ for()

for ( i  = 0; i < gap->ga_len; ++i)

◆ get_bad_opt()

int get_bad_opt ( const char_u p,
exarg_T eap 

◆ get_behave_arg()

char_u* get_behave_arg ( expand_T xp,
int  idx 

◆ get_command_name()

char_u* get_command_name ( expand_T xp,
int  idx 

◆ get_mapclear_arg()

char_u* get_mapclear_arg ( expand_T *xp  FUNC_ATTR_UNUSED,
int  idx 

◆ get_messages_arg()

char_u* get_messages_arg ( expand_T *xp  FUNC_ATTR_UNUSED,
int  idx 

◆ get_pressedreturn()

bool get_pressedreturn ( void  )

◆ get_user_cmd_addr_type()

char_u* get_user_cmd_addr_type ( expand_T xp,
int  idx 

◆ get_user_cmd_complete()

char_u* get_user_cmd_complete ( expand_T xp,
int  idx 

◆ get_user_cmd_flags()

char_u* get_user_cmd_flags ( expand_T xp,
int  idx 

◆ get_user_cmd_nargs()

char_u* get_user_cmd_nargs ( expand_T xp,
int  idx 

◆ get_user_commands()

char_u* get_user_commands ( expand_T *xp  FUNC_ATTR_UNUSED,
int  idx 

◆ getline_cookie()

void* getline_cookie ( LineGetter  fgetline,
void cookie 

If "fgetline" is get_loop_line(), return the cookie used by the original getline function. Otherwise return "cookie".

cookieargument for fgetline()

◆ getline_equal()

int getline_equal ( LineGetter  fgetline,
void cookie,
LineGetter  func 

If "fgetline" is get_loop_line(), return TRUE if the getline it uses equals "func". * Otherwise return TRUE when "fgetline" equals "func".

cookieargument for fgetline()

◆ if() [1/3]

if ( cmp = 0)

◆ if() [2/3]

if ( flags &  UC_BUFFER)

◆ if() [3/3]

if ( rep_buf  = NULL)

◆ is_loclist_cmd()

bool is_loclist_cmd ( int  cmdidx)

◆ modifier_len()

int modifier_len ( char_u cmd)

◆ not_exiting()

void not_exiting ( void  )

◆ open_exfile()

FILE* open_exfile ( char_u fname,
int  forceit,
char *  mode 

Open a file for writing for an Ex command, with some checks.

mode"w" for create new file or "a" for append
file descriptor, or NULL on failure.

◆ parse_addr_type_arg()

int parse_addr_type_arg ( char_u value,
int  vallen,
cmd_addr_T addr_type_arg 

◆ parse_cmd_address()

int parse_cmd_address ( exarg_T eap,
char **  errormsg,
bool  silent 

◆ parse_command_modifiers()

int parse_command_modifiers ( exarg_T eap,
char **  errormsg,
bool  skip_only 

◆ parse_compl_arg()

int parse_compl_arg ( const char_u value,
int  vallen,
int *  complp,
uint32_t *  argt,
char_u **  compl_arg 

◆ post_chdir()

void post_chdir ( CdScope  scope,
bool  trigger_dirchanged 

Deal with the side effects of changing the current directory.

scopeScope of the function call (global, tab or window).

◆ replace_termcodes()

replace_termcodes ( rep  ,
STRLEN(rep)  ,
false  ,
false  ,
true  ,

◆ restore_current_state()

void restore_current_state ( save_state_T sst)

◆ save_current_state()

bool save_current_state ( save_state_T sst)

◆ separate_nextcmd()

void separate_nextcmd ( exarg_T eap)

◆ set_no_hlsearch()

void set_no_hlsearch ( bool  flag)

◆ set_one_cmd_context()

const char* set_one_cmd_context ( expand_T xp,
const char *  buff 

This is all pretty much copied from do_one_cmd(), with all the extra stuff we don't need/want deleted. Maybe this could be done better if we didn't repeat all this stuff. The only problem is that they may not stay perfectly compatible with each other, but then the command line syntax probably won't change that much – webb.

buffbuffer for command string

◆ set_pressedreturn()

void set_pressedreturn ( bool  val)

◆ skip_range()

char_u* skip_range ( const char_u cmd,
int *  ctx 

Skip a range specifier of the form: addr [,addr] [;addr] ..

Backslashed delimiters after / or ? will be skipped, and commands will not be expanded between /'s and ?'s or after "'".

Also skip white space and ":" characters.

ctxpointer to xp_context or NULL
the "cmd" pointer advanced to beyond the range.

◆ tabpage_close()

void tabpage_close ( int  forceit)

◆ tabpage_close_other()

void tabpage_close_other ( tabpage_T tp,
int  forceit 

◆ tabpage_new()

void tabpage_new ( void  )

◆ uc_clear()

void uc_clear ( garray_T gap)

◆ update_topline_cursor()

void update_topline_cursor ( void  )

◆ verify_command()

void verify_command ( char_u cmd)

◆ vim_mkdir_emsg()

int vim_mkdir_emsg ( const char *const  name,
const int  prot 

Try creating a directory, give error message on failure

[in]nameDirectory to create.
[in]protDirectory permissions.
OK in case of success, FAIL otherwise.

◆ xfree()

xfree ( compl_arg  )

Variable Documentation

◆ __pad0__

fail __pad0__

◆ cmp

int cmp = 1

◆ else

Initial value:
gap = &ucmds

◆ expand


return FAIL

◆ gap

garray_T* gap

◆ i

int int i
Initial value:
ucmd_T *cmd = NULL

◆ name

char* name

◆ OK

return OK

◆ rep_buf

char_u* rep_buf = NULL

◆ sc_lnum

◆ shortname

char* shortname

◆ uc_addr_type

cmd uc_addr_type = addr_type

◆ uc_argt

cmd uc_argt = argt

◆ uc_compl

cmd uc_compl = compl

◆ uc_compl_arg

cmd uc_compl_arg = compl_arg

◆ uc_def

cmd uc_def = def

◆ uc_rep

cmd uc_rep = rep_buf

◆ uc_script_ctx

cmd uc_script_ctx = current_sctx
garray_T * gap
Definition: ex_docmd.c:5155
return NULL
Definition: eval.c:10355
Definition: ex_docmd.c:83