Data Structures | Macros | Typedefs | Enumerations | Functions
ex_cmds2.c File Reference
#include <assert.h>
#include <fcntl.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
#include "nvim/ascii.h"
#include "nvim/globals.h"
#include "nvim/vim.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/debugger.h"
#include "nvim/eval/userfunc.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_eval.h"
#include "nvim/ex_getln.h"
#include "nvim/fileio.h"
#include "nvim/garray.h"
#include "nvim/lua/executor.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
#include "nvim/os/fs_defs.h"
#include "nvim/os/input.h"
#include "nvim/os/shell.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/profile.h"
#include "nvim/quickfix.h"
#include "nvim/regexp.h"
#include "nvim/strings.h"
#include "nvim/undo.h"
#include "nvim/version.h"
#include "nvim/window.h"

Data Structures

struct  sn_prl_S
struct  source_cookie
struct  GetBufferLineCookie
struct  GetStrLineCookie


#define SCRIPT_ITEM(id)   (((scriptitem_T *)script_items.ga_data)[(id) - 1])
#define PRL_ITEM(si, idx)   (((sn_prl_T *)(si)->sn_prl_ga.ga_data)[(idx)])
#define AL_SET   1
 Code to handle the argument list. More...
#define AL_ADD   2
#define AL_DEL   3


typedef struct sn_prl_S sn_prl_T




void ex_profile (exarg_T *eap)
 ":profile cmd args" More...
void ex_ruby (exarg_T *eap)
void ex_rubyfile (exarg_T *eap)
void ex_rubydo (exarg_T *eap)
void ex_python3 (exarg_T *eap)
void ex_py3file (exarg_T *eap)
void ex_pydo3 (exarg_T *eap)
void ex_perl (exarg_T *eap)
void ex_perlfile (exarg_T *eap)
void ex_perldo (exarg_T *eap)
char * get_profile_name (expand_T *xp, int idx) FUNC_ATTR_PURE
void set_context_in_profile_cmd (expand_T *xp, const char *arg)
 Handle command line completion for :profile command. More...
void profile_dump (void)
 Dump the profiling info. More...
void script_prof_save (proftime_T *tm)
void script_prof_restore (proftime_T *tm)
 Count time spent in children after invoking another script or function. More...
void prof_inchar_enter (void)
 Called when starting to wait for the user to type a character. More...
void prof_inchar_exit (void)
 Called when finished waiting for the user to type a character. More...
bool prof_def_func (void)
int autowrite (buf_T *buf, int forceit)
void autowrite_all (void)
 Flush all buffers, except the ones that are readonly or are never written. More...
bool check_changed (buf_T *buf, int flags)
void dialog_changed (buf_T *buf, bool checkall)
bool dialog_close_terminal (buf_T *buf)
bool can_abandon (buf_T *buf, int forceit)
bool check_changed_any (bool hidden, bool unload)
int check_fname (void)
int buf_write_all (buf_T *buf, int forceit)
int get_arglist_exp (char_u *str, int *fcountp, char_u ***fnamesp, bool wig)
void check_arg_idx (win_T *win)
 Check if window "win" is editing the w_arg_idx file in its argument list. More...
void ex_args (exarg_T *eap)
 ":args", ":argslocal" and ":argsglobal". More...
void ex_previous (exarg_T *eap)
 ":previous", ":sprevious", ":Next" and ":sNext". More...
void ex_rewind (exarg_T *eap)
 ":rewind", ":first", ":sfirst" and ":srewind". More...
void ex_last (exarg_T *eap)
 ":last" and ":slast". More...
void ex_argument (exarg_T *eap)
 ":argument" and ":sargument". More...
void do_argfile (exarg_T *eap, int argn)
 Edit file "argn" of the argument lists. More...
void ex_next (exarg_T *eap)
 ":next", and commands that behave like it. More...
void ex_argedit (exarg_T *eap)
 ":argedit" More...
void ex_argadd (exarg_T *eap)
 ":argadd" More...
void ex_argdelete (exarg_T *eap)
 ":argdelete" More...
void ex_listdo (exarg_T *eap)
 ":argdo", ":windo", ":bufdo", ":tabdo", ":cdo", ":ldo", ":cfdo" and ":lfdo" More...
char * get_arglist_name (expand_T *xp FUNC_ATTR_UNUSED, int idx)
void ex_compiler (exarg_T *eap)
 ":compiler[!] {name}" More...
void ex_options (exarg_T *eap)
 ":options" More...
void ex_source (exarg_T *eap)
 ":source [{fname}]" More...
linenr_Tsource_breakpoint (void *cookie)
int * source_dbg_tick (void *cookie)
int source_level (void *cookie) FUNC_ATTR_PURE
scriptitem_Tnew_script_item (char *const name, scid_T *const sid_out)
int do_source_str (const char *cmd, const char *traceback_name)
int do_source (char *fname, int check_other, int is_vimrc)
scriptitem_Tget_current_script_id (char_u *fname, sctx_T *ret_sctx)
void ex_scriptnames (exarg_T *eap)
 ":scriptnames" More...
char_uget_scriptname (LastSet last_set, bool *should_free)
linenr_T get_sourced_lnum (LineGetter fgetline, void *cookie) FUNC_ATTR_PURE
char * getsourceline (int c, void *cookie, int indent, bool do_concat)
void script_line_start (void)
void script_line_exec (void)
 Called when actually executing a function line. More...
void script_line_end (void)
 Called when done with a function line. More...
void ex_scriptencoding (exarg_T *eap)
void ex_finish (exarg_T *eap)
 ":finish": Mark a sourced file as finished. More...
void do_finish (exarg_T *eap, int reanimate)
bool source_finished (LineGetter fgetline, void *cookie)
void ex_checktime (exarg_T *eap)
 ":checktime [buffer]" More...
char * get_mess_lang (void)
void set_lang_var (void)
void ex_drop (exarg_T *eap)

Detailed Description

Some more functions for command line commands

Macro Definition Documentation


#define AL_ADD   2


#define AL_DEL   3


#define AL_SET   1

Code to handle the argument list.


#define PRL_ITEM (   si,
)    (((sn_prl_T *)(si)->sn_prl_ga.ga_data)[(idx)])


#define SCRIPT_ITEM (   id)    (((scriptitem_T *)script_items.ga_data)[(id) - 1])

Typedef Documentation

◆ sn_prl_T

typedef struct sn_prl_S sn_prl_T

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

expand :profile sub-commands


expand :profile func {funcname}

Function Documentation

◆ autowrite()

int autowrite ( buf_T buf,
int  forceit 

If 'autowrite' option set, try to write the file. Careful: autocommands may make "buf" invalid!

FAIL for failure, OK otherwise

◆ autowrite_all()

void autowrite_all ( void  )

Flush all buffers, except the ones that are readonly or are never written.

◆ buf_write_all()

int buf_write_all ( buf_T buf,
int  forceit 

Flush the contents of a buffer, unless it has no file name.

FAIL for failure, OK otherwise

◆ can_abandon()

bool can_abandon ( buf_T buf,
int  forceit 
true if the buffer "buf" can be abandoned, either by making it hidden, autowriting it or unloading it.

◆ check_arg_idx()

void check_arg_idx ( win_T win)

Check if window "win" is editing the w_arg_idx file in its argument list.

◆ check_changed()

bool check_changed ( buf_T buf,
int  flags 
true if buffer was changed and cannot be abandoned. For flags use the CCGD_ values.

◆ check_changed_any()

bool check_changed_any ( bool  hidden,
bool  unload 

Check if any buffer was changed and cannot be abandoned. That changed buffer becomes the current buffer. When "unload" is true the current buffer is unloaded instead of making it hidden. This is used for ":q!".

[in]hiddenspecifies whether to check only hidden buffers.
[in]unloadspecifies whether to unload, instead of hide, the buffer.
true if any buffer is changed and cannot be abandoned

◆ check_fname()

int check_fname ( void  )
FAIL if there is no file name, OK if there is one. Give error message for FAIL.

◆ dialog_changed()

void dialog_changed ( buf_T buf,
bool  checkall 

Ask the user what to do when abandoning a changed buffer. Must check 'write' option first!

checkallmay abandon all changed buffers

◆ dialog_close_terminal()

bool dialog_close_terminal ( buf_T buf)

Ask the user whether to close the terminal buffer or not.

bufThe terminal buffer.
bool Whether to close the buffer or not.

◆ do_argfile()

void do_argfile ( exarg_T eap,
int  argn 

Edit file "argn" of the argument lists.

◆ do_finish()

void do_finish ( exarg_T eap,
int  reanimate 

Mark a sourced file as finished. Possibly makes the ":finish" pending. Also called for a pending finish at the ":endtry" or after returning from an extra do_cmdline(). "reanimate" is used in the latter case.

◆ do_source()

int do_source ( char *  fname,
int  check_other,
int  is_vimrc 

When fname is a 'lua' file nlua_exec_file() is invoked to source it. Otherwise reads the file fname and executes its lines as Ex commands.

This function may be called recursively!

See also
check_othercheck for .vimrc and _vimrc
is_vimrcDOSO_ value
FAIL if file could not be opened, OK otherwise

◆ do_source_str()

int do_source_str ( const char *  cmd,
const char *  traceback_name 

Executes lines in src as Ex commands.

See also

◆ ex_argadd()

void ex_argadd ( exarg_T eap)


◆ ex_argdelete()

void ex_argdelete ( exarg_T eap)


◆ ex_argedit()

void ex_argedit ( exarg_T eap)


◆ ex_args()

void ex_args ( exarg_T eap)

":args", ":argslocal" and ":argsglobal".

◆ ex_argument()

void ex_argument ( exarg_T eap)

":argument" and ":sargument".

◆ ex_checktime()

void ex_checktime ( exarg_T eap)

":checktime [buffer]"

◆ ex_compiler()

void ex_compiler ( exarg_T eap)

":compiler[!] {name}"

◆ ex_drop()

void ex_drop ( exarg_T eap)

":drop" Opens the first argument in a window. When there are two or more arguments the argument list is redefined.

◆ ex_finish()

void ex_finish ( exarg_T eap)

":finish": Mark a sourced file as finished.

◆ ex_last()

void ex_last ( exarg_T eap)

":last" and ":slast".

◆ ex_listdo()

void ex_listdo ( exarg_T eap)

":argdo", ":windo", ":bufdo", ":tabdo", ":cdo", ":ldo", ":cfdo" and ":lfdo"

◆ ex_next()

void ex_next ( exarg_T eap)

":next", and commands that behave like it.

◆ ex_options()

void ex_options ( exarg_T eap)


◆ ex_perl()

void ex_perl ( exarg_T eap)

◆ ex_perldo()

void ex_perldo ( exarg_T eap)

◆ ex_perlfile()

void ex_perlfile ( exarg_T eap)

◆ ex_previous()

void ex_previous ( exarg_T eap)

":previous", ":sprevious", ":Next" and ":sNext".

◆ ex_profile()

void ex_profile ( exarg_T eap)

":profile cmd args"

◆ ex_py3file()

void ex_py3file ( exarg_T eap)

◆ ex_pydo3()

void ex_pydo3 ( exarg_T eap)

◆ ex_python3()

void ex_python3 ( exarg_T eap)

◆ ex_rewind()

void ex_rewind ( exarg_T eap)

":rewind", ":first", ":sfirst" and ":srewind".

◆ ex_ruby()

void ex_ruby ( exarg_T eap)

◆ ex_rubydo()

void ex_rubydo ( exarg_T eap)

◆ ex_rubyfile()

void ex_rubyfile ( exarg_T eap)

◆ ex_scriptencoding()

void ex_scriptencoding ( exarg_T eap)

":scriptencoding": Set encoding conversion for a sourced script. Without the multi-byte feature it's simply ignored.

◆ ex_scriptnames()

void ex_scriptnames ( exarg_T eap)


◆ ex_source()

void ex_source ( exarg_T eap)

":source [{fname}]"

◆ get_arglist_exp()

int get_arglist_exp ( char_u str,
int *  fcountp,
char_u ***  fnamesp,
bool  wig 

Parse a list of arguments (file names), expand them and return in "fnames[fcountp]". When "wig" is true, removes files matching 'wildignore'.


◆ get_arglist_name()

char* get_arglist_name ( expand_T *xp  FUNC_ATTR_UNUSED,
int  idx 

◆ get_current_script_id()

scriptitem_T* get_current_script_id ( char_u fname,
sctx_T ret_sctx 

Check if fname was sourced before to finds its SID. If it's new, generate a new SID.

[in]fnamefile path of script
[out]ret_sctxsctx of this script

◆ get_mess_lang()

char* get_mess_lang ( void  )

Obtain the current messages language. Used to set the default for 'helplang'. May return NULL or an empty string.

◆ get_profile_name()

char* get_profile_name ( expand_T xp,
int  idx 

Function given to ExpandGeneric() to obtain the profile command specific expansion.

◆ get_scriptname()

char_u* get_scriptname ( LastSet  last_set,
bool should_free 

Get a pointer to a script name. Used for ":verbose set". Message appended to "Last set from "

◆ get_sourced_lnum()

linenr_T get_sourced_lnum ( LineGetter  fgetline,
void cookie 

◆ getsourceline()

char* getsourceline ( int  c,
void cookie,
int  indent,
bool  do_concat 

Get one full line from a sourced file. Called by do_cmdline() when it's called from do_source().

pointer to the line in allocated memory, or NULL for end-of-file or some error.

◆ new_script_item()

scriptitem_T* new_script_item ( char *const  name,
scid_T *const  sid_out 

Create a new script item and allocate script-local vars.

See also
nameFile name of the script. NULL for anonymous :source.
[out]sid_outSID of the new item.
pointer to the created script item.

◆ prof_def_func()

bool prof_def_func ( void  )
true when a function defined in the current script should be profiled.

◆ prof_inchar_enter()

void prof_inchar_enter ( void  )

Called when starting to wait for the user to type a character.

◆ prof_inchar_exit()

void prof_inchar_exit ( void  )

Called when finished waiting for the user to type a character.

◆ profile_dump()

void profile_dump ( void  )

Dump the profiling info.

◆ script_line_end()

void script_line_end ( void  )

Called when done with a function line.

◆ script_line_exec()

void script_line_exec ( void  )

Called when actually executing a function line.

◆ script_line_start()

void script_line_start ( void  )

Called when starting to read a script line. "sourcing_lnum" must be correct! When skipping lines it may not actually be executed, but we won't find out until later and we need to store the time now.

◆ script_prof_restore()

void script_prof_restore ( proftime_T tm)

Count time spent in children after invoking another script or function.

◆ script_prof_save()

void script_prof_save ( proftime_T tm)

Save time when starting to invoke another script or function.

tmplace to store wait time

◆ set_context_in_profile_cmd()

void set_context_in_profile_cmd ( expand_T xp,
const char *  arg 

Handle command line completion for :profile command.

◆ set_lang_var()

void set_lang_var ( void  )

Set the "v:lang" variable according to the current locale setting. Also do "v:lc_time"and "v:ctype".

◆ source_breakpoint()

linenr_T* source_breakpoint ( void cookie)

":source" and associated commands.

address holding the next breakpoint line for a source cookie

◆ source_dbg_tick()

int* source_dbg_tick ( void cookie)
the address holding the debug tick for a source cookie.

◆ source_finished()

bool source_finished ( LineGetter  fgetline,
void cookie 
true when a sourced file had the ":finish" command: Don't give error message for missing ":endif". false when not sourcing a file.

◆ source_level()

int source_level ( void cookie)
the nesting level for a source cookie.