From 9c2099d5850a6a434f7269913d316d57da1362e2 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 4 Jun 2018 02:06:32 +0200 Subject: Ex mode: use getexline() instead of getexmodeline() This changes Ex mode (Q, -e) to work like Vim's "improved Ex mode" (gQ, -E). That brings some small behavior differences, but should not impact most Ex scripts (unless, for example, they depend on mappings being disabled--but that can be solved for -e by skipping user config). Before this change: * the screen test hangs. After this change: * Q acts like gQ. * -e/-es differs from -E/-Es only in its treatment of stdin. This moves towards potentially removing getexmodeline(). (HINT: That does NOT mean "removing Ex mode", it means removing the Vi-compatible Ex mode, which differs from Vim's "improved Ex mode" only in some minor details (e.g. mappings are disabled).) ref #1089 :-)~ --- src/nvim/ex_docmd.c | 18 ++++-------------- src/nvim/main.c | 6 +++--- 2 files changed, 7 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 9590a3715e..2f41080a41 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -188,15 +188,8 @@ static void restore_dbg_stuff(struct dbg_stuff *dsp) current_exception = dsp->current_exception; } - -/* - * do_exmode(): Repeatedly get commands for the "Ex" mode, until the ":vi" - * command is given. - */ -void -do_exmode ( - int improved /* TRUE for "improved Ex" mode */ -) +/// Repeatedly get commands for Ex mode, until the ":vi" command is given. +void do_exmode(int improved) { int save_msg_scroll; int prev_msg_row; @@ -232,11 +225,8 @@ do_exmode ( changedtick = curbuf->b_changedtick; prev_msg_row = msg_row; prev_line = curwin->w_cursor.lnum; - if (improved) { - cmdline_row = msg_row; - do_cmdline(NULL, getexline, NULL, 0); - } else - do_cmdline(NULL, getexmodeline, NULL, DOCMD_NOWAIT); + cmdline_row = msg_row; + do_cmdline(NULL, getexline, NULL, 0); lines_left = Rows - 1; if ((prev_line != curwin->w_cursor.lnum diff --git a/src/nvim/main.c b/src/nvim/main.c index 8d98f9e915..7296d9a7de 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -872,7 +872,7 @@ static void command_line_scan(mparm_T *parmp) exmode_active = EXMODE_NORMAL; break; } - case 'E': { // "-E" Improved Ex mode + case 'E': { // "-E" Ex mode exmode_active = EXMODE_VIM; break; } @@ -1896,8 +1896,8 @@ static void usage(void) mch_msg("\n"); mch_msg(_(" -b Binary mode\n")); mch_msg(_(" -d Diff mode\n")); - mch_msg(_(" -e, -E Ex mode, Improved Ex mode\n")); - mch_msg(_(" -es Silent (batch) mode\n")); + mch_msg(_(" -e, -E Ex mode\n")); + mch_msg(_(" -es, -Es Silent (batch) mode\n")); mch_msg(_(" -h, --help Print this help message\n")); mch_msg(_(" -i Use this shada file\n")); mch_msg(_(" -m Modifications (writing files) not allowed\n")); -- cgit From 487cf98c0b61ade023fc71d945a64e61f8374eac Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 17 Jun 2018 14:22:02 +0200 Subject: startup: fix -E/-Es without `-u NONE` Before this change, -E/-Es without `-u NONE` reads stdin as Ex commands. It should always read stdin as text (into buffer 1), like this: echo foo | nvim -Es +'%p' foo echo foo | nvim -Es -u NORC +'%p' foo --- src/nvim/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/main.c b/src/nvim/main.c index 7296d9a7de..ea43b93b30 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -301,9 +301,11 @@ int main(int argc, char **argv) // Read ex-commands if invoked with "-es". // bool reading_tty = !headless_mode + && !silent_mode && (params.input_isatty || params.output_isatty || params.err_isatty); - bool reading_excmds = !params.input_isatty && silent_mode + bool reading_excmds = !params.input_isatty + && silent_mode && exmode_active == EXMODE_NORMAL; if (reading_tty || reading_excmds) { // One of the startup commands (arguments, sourced scripts or plugins) may -- cgit