Hi Gary!
On Di, 19 Mär 2013, Gary Johnson wrote:
> On 2013-03-19, Christian Brabandt wrote:
> > On Tue, March 19, 2013 17:43, Gary Johnson wrote:
> > > On 2013-03-19, Christian Brabandt wrote:
> > >> On Fri, March 15, 2013 20:29, Gary Johnson wrote:
> > >>
> > >> > Should the function of "!" in :normal and of "nore" in mappings be
> > >> > extended to also ignore any non-default settings of 'cedit'?
> > >>
> > >> I think, plugin writers should take care of properly escaping
> > >> the cedit key by themselves. That is, if they issue a search like this
> > >> :exe "norm! /"
> > >> they need to take care to replace the cedit key by Ctrl-V cedit key.
> > >
> > > But the writer in this case was not trying to use the cedit key--he
> > > was innocently using another key (<Esc>) that I had chosen to be the
> > > cedit key.
> >
> > I don't see, how this is different from other settings that might
> > interfer plugins (e.g. 'gdefault', 'magic', 'remap', 'ed').
>
> That's why I suggested that the plugin function save the current
> 'cedit' setting, set the default, do the work of the function, then
> restore the original setting before returning.
>
> > Say you don't want to use the search() function,
> > but want to use
> > :exe variable
> > with variable being something like 'norm! /....<Esc>'
> >
> > There shouldn't be a problem with first substituting that variable by
> > :let variable = substitute(variable, &cedit, '^V'.&cedit, 'g')
> > where ^V is the literal Ctrl-V (and not the 2 distinct characters ^ and V)
>
> Maybe I'm just being thick this morning--haven't even finished my
> first coffee--but I don't think you understand the problem. The
> 'cedit' key is used to open the command-line window. The plugin
> writer doesn't want to open the command-line window. The plugin
> writer doesn't even care that command-line window exists. All he
> wants to do is execute a normal-mode command that ends with an
> <Esc>,
>
> exe 'norm! /\%'.leftcol."v\<Esc>"
>
> which :help says should behave as follows in that context:
>
> <Esc> When typed and 'x' not present in 'cpoptions', quit
> Command-line mode without executing. In macros or
> when 'x' present in 'cpoptions', start entered command.
>
> Instead of getting that documented behavior, the normal-mode command
> is interpreting that <Esc> as the cedit key and entering the
> command-line window. The plugin writer just wants to execute his
> command. I don't see any way to escape that <Esc> to make it do
> what :help says it does and not enter the command-line window when
> 'cedit' is set to <Esc>.
>
> I think if the &cedit character was escaped with ^V as you
> suggested, that would place a literal &cedit in the text, which is
> not what the plugin writer wants, either.
>
> The only solution I see, without modifying Vim as I suggested, is to
> save and restore 'cedit' as I also suggested.
Here is a patch, that makes :norm! ignore the cedit key, while :norm
behaves as is.
regards,
Christian
--
Wer die Menge unbedeutender ungenial(ischer) Bücher sieht, hält die
Menschen für noch unbedeutender.
-- Jean Paul
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1341,6 +1341,7 @@
:set cedit=<Esc>
< |Nvi| also has this option, but it only uses the first character.
See |cmdwin|.
+ (Not evaluated for :norm! commands, but applies to mappings.)
*'charconvert'* *'ccv'* *E202* *E214* *E513*
'charconvert' 'ccv' string (default "")
diff --git a/src/ex_getln.c b/src/ex_getln.c
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -746,14 +746,18 @@
}
#ifdef FEAT_CMDWIN
- if (c == cedit_key || c == K_CMDWIN)
- {
- /*
- * Open a window to edit the command line (and history).
- */
- c = ex_window();
- some_key_typed = TRUE;
- }
+ if ((c == cedit_key || c == K_CMDWIN) &&
+ !typebuf_norm_remap())
+ //!(((typebuf.tb_noremap[typebuf.tb_off + typebuf.tb_len -1]
+ // & (1|4)) != 0 && ex_normal_busy))) // || KeyTyped))
+ {
+ /*
+ * Open a window to edit the command line (and history).
+ * not valid for norm! commands, but mappings should work
+ */
+ c = ex_window();
+ some_key_typed = TRUE;
+ }
# ifdef FEAT_DIGRAPHS
else
# endif
diff --git a/src/getchar.c b/src/getchar.c
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -1125,6 +1125,17 @@
return typebuf.tb_maplen == 0;
}
+/*
+ * Return TRUE if last characters in the typeahead buffer is remappable and a
+ * :norm command is currently executing (e.g. this means, it is :norm but not :norm! )
+ */
+ int
+typebuf_norm_remap()
+{
+ return (((typebuf.tb_noremap[typebuf.tb_off + typebuf.tb_len -1]
+ & RM_NONE) != 0 && ex_normal_busy));
+}
+
#if defined(FEAT_VISUAL) || defined(PROTO)
/*
* Return the number of characters that are mapped (or not typed).
diff --git a/src/proto/getchar.pro b/src/proto/getchar.pro
--- a/src/proto/getchar.pro
+++ b/src/proto/getchar.pro
@@ -25,6 +25,7 @@
void ins_char_typebuf __ARGS((int c));
int typebuf_changed __ARGS((int tb_change_cnt));
int typebuf_typed __ARGS((void));
+int typebuf_norm_remap __ARGS((void));
int typebuf_maplen __ARGS((void));
void del_typebuf __ARGS((int len, int offset));
int alloc_typebuf __ARGS((void));