mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 15:38:33 +00:00
feat(autocmd): add Recording autocmds
feat(eval): add reg_recorded() This function is used the get the last recorded register. style(Recording): rename handler to match suggestions fix(RecordingLeave): send autocommand earlier This makes the autocommand fire just before setting reg_recorded to reg_recording, this way we clearly show that we are actually just before actually quitting the recording mode.
This commit is contained in:

committed by
Axel Dahlberg

parent
b1757e1c29
commit
8a4e26c6fe
@@ -75,6 +75,8 @@ return {
|
||||
'QuickFixCmdPost', -- after :make, :grep etc.
|
||||
'QuickFixCmdPre', -- before :make, :grep etc.
|
||||
'QuitPre', -- before :quit
|
||||
'RecordingEnter', -- when starting to record a macro
|
||||
'RecordingLeave', -- when stopping to record a macro
|
||||
'RemoteReply', -- upon string reception from a remote vim
|
||||
'SearchWrapped', -- after the search wrapped around
|
||||
'SessionLoadPost', -- after loading a session file
|
||||
@@ -131,6 +133,8 @@ return {
|
||||
BufModifiedSet=true,
|
||||
DiagnosticChanged=true,
|
||||
DirChanged=true,
|
||||
RecordingEnter=true,
|
||||
RecordingLeave=true,
|
||||
Signal=true,
|
||||
TabClosed=true,
|
||||
TabNew=true,
|
||||
|
@@ -277,6 +277,7 @@ return {
|
||||
readfile={args={1, 3}, base=1},
|
||||
reg_executing={},
|
||||
reg_recording={},
|
||||
reg_recorded={},
|
||||
reltime={args={0, 2}, base=1},
|
||||
reltimefloat={args=1, base=1},
|
||||
reltimestr={args=1, base=1},
|
||||
|
@@ -7398,6 +7398,11 @@ static void f_reg_recording(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
return_register(reg_recording, rettv);
|
||||
}
|
||||
|
||||
static void f_reg_recorded(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
return_register(reg_recorded, rettv);
|
||||
}
|
||||
|
||||
/// list2proftime - convert a List to proftime_T
|
||||
///
|
||||
/// @param arg The input list, must be of type VAR_LIST and have
|
||||
|
@@ -632,6 +632,7 @@ EXTERN bool ex_no_reprint INIT(=false); // No need to print after z or p.
|
||||
|
||||
EXTERN int reg_recording INIT(= 0); // register for recording or zero
|
||||
EXTERN int reg_executing INIT(= 0); // register being executed or zero
|
||||
EXTERN int reg_recorded INIT(= 0); // last recorded register or zero
|
||||
|
||||
EXTERN int no_mapping INIT(= false); // currently no mapping allowed
|
||||
EXTERN int no_zero_mapping INIT(= 0); // mapping zero not allowed
|
||||
|
@@ -229,7 +229,7 @@ static const struct nv_cmd {
|
||||
{ 'N', nv_next, 0, SEARCH_REV },
|
||||
{ 'O', nv_open, 0, 0 },
|
||||
{ 'P', nv_put, 0, 0 },
|
||||
{ 'Q', nv_exmode, NV_NCW, 0 },
|
||||
{ 'Q', nv_regreplay, 0, 0 },
|
||||
{ 'R', nv_Replace, 0, false },
|
||||
{ 'S', nv_subst, NV_KEEPREG, 0 },
|
||||
{ 'T', nv_csearch, NV_NCH_ALW|NV_LANG, BACKWARD },
|
||||
@@ -4028,15 +4028,18 @@ dozet:
|
||||
/*
|
||||
* "Q" command.
|
||||
*/
|
||||
static void nv_exmode(cmdarg_T *cap)
|
||||
static void nv_regreplay(cmdarg_T *cap)
|
||||
{
|
||||
/*
|
||||
* Ignore 'Q' in Visual mode, just give a beep.
|
||||
*/
|
||||
if (VIsual_active) {
|
||||
vim_beep(BO_EX);
|
||||
} else if (!checkclearop(cap->oap)) {
|
||||
do_exmode();
|
||||
if (checkclearop(cap->oap)) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (cap->count1-- && !got_int) {
|
||||
if (do_execreg(reg_recorded, false, false, false) == false) {
|
||||
clearopbeep(cap->oap);
|
||||
break;
|
||||
}
|
||||
line_breakcheck();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -912,13 +912,14 @@ int do_record(int c)
|
||||
showmode();
|
||||
regname = c;
|
||||
retval = OK;
|
||||
apply_autocmds(EVENT_RECORDINGENTER, NULL, NULL, false, curbuf);
|
||||
}
|
||||
} else { // stop recording
|
||||
/*
|
||||
* Get the recorded key hits. K_SPECIAL and CSI will be escaped, this
|
||||
* needs to be removed again to put it in a register. exec_reg then
|
||||
* adds the escaping back later.
|
||||
*/
|
||||
} else { // stop recording
|
||||
// Get the recorded key hits. K_SPECIAL and CSI will be escaped, this
|
||||
// needs to be removed again to put it in a register. exec_reg then
|
||||
// adds the escaping back later.
|
||||
apply_autocmds(EVENT_RECORDINGLEAVE, NULL, NULL, false, curbuf);
|
||||
reg_recorded = reg_recording;
|
||||
reg_recording = 0;
|
||||
if (ui_has(kUIMessages)) {
|
||||
showmode();
|
||||
@@ -932,10 +933,8 @@ int do_record(int c)
|
||||
// Remove escaping for CSI and K_SPECIAL in multi-byte chars.
|
||||
vim_unescape_csi(p);
|
||||
|
||||
/*
|
||||
* We don't want to change the default register here, so save and
|
||||
* restore the current register name.
|
||||
*/
|
||||
// We don't want to change the default register here, so save and
|
||||
// restore the current register name.
|
||||
old_y_previous = y_previous;
|
||||
|
||||
retval = stuff_yank(regname, p);
|
||||
|
Reference in New Issue
Block a user