Hi, Bram,
I started this patch as it seemed a while ago some aspects it may be helpful
for
MacVim. Recently I have dug it up and further revised it, as I was coming
across
some other troubles using --remote-expr when Vim is running in different modes.
It
extends the mode() function to return a more full set of modes.
The one bearing most comment is the one for when a shell is running (:shell in
the
GUI). I'm not entirely convinced having this as a separate 'mode' is really the
best thing. Hoewver, the alternative would be somehow delaying a server's
processing and reply to --remote-expr et al. and I suspect this is pretty
non-trivial. Having mode() return something different is a good step even if it
isn't the final one, I think.
Would you be able to include this?
Ben.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index fc6aa5d..3160e9b 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -3848,6 +3848,7 @@ mkdir({name} [, {path} [, {prot}]])
*mode()*
mode() Return a string that indicates the current mode:
n Normal
+ o Operator-pending
v Visual by character
V Visual by line
CTRL-V Visual blockwise
@@ -3857,9 +3858,14 @@ mode() Return a string that indicates the current mode:
i Insert
R Replace
c Command-line
+ C Vim Ex mode |gQ|
+ Q Normal Ex mode |Q|
r Hit-enter prompt
- This is useful in the 'statusline' option. In most other
- places it always returns "c" or "n".
+ ? A |:confirm| query of some sort
+ ! Shell or external command is executing
+ This is useful in the 'statusline' option or when used
+ with |remote_expr()| In most other places it always returns
+ "c" or "n".
nextnonblank({lnum}) *nextnonblank()*
Return the line number of the first line at or below {lnum}
diff --git a/src/eval.c b/src/eval.c
index 9e2999b..956e3f0 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -12862,8 +12862,12 @@ f_mode(argvars, rettv)
}
else
#endif
- if (State == HITRETURN || State == ASKMORE || State == SETWSIZE)
+ if (State == HITRETURN || State == ASKMORE || State == SETWSIZE)
buf[0] = 'r';
+ else if (State == CONFIRM)
+ buf[0] = '?';
+ else if (State == EXTERNCMD)
+ buf[0] = '!';
else if (State & INSERT)
{
if (State & REPLACE_FLAG)
@@ -12872,7 +12876,16 @@ f_mode(argvars, rettv)
buf[0] = 'i';
}
else if (State & CMDLINE)
- buf[0] = 'c';
+ {
+ if (exmode_active)
+ buf[0] = 'C';
+ else
+ buf[0] = 'c';
+ }
+ else if (exmode_active)
+ buf[0] = 'Q';
+ else if (finish_op)
+ buf[0] = 'o';
else
buf[0] = 'n';