On Fr, 17 Okt 2014, Bram Moolenaar wrote:
> Christian Brabandt wrote:
>
> > > > Bram,
> > > > what is the reason, setting 'lmap' applies to when a mapping is
> > > > remapped?
> > >
> > > I can't remember. I believe it has always been this way. Perhaps not
> > > intentionally.
> > >
> > > > Consider this:
> > > > ~$ cat lmap.vim
> > > > imap <tab> <Plug>MyPluginEcho
> > > > imap <Plug>MyPluginEcho <c-r>="hello"<cr>
> > > > cmap <tab> <Plug>MyPluginEcho
> > > > cmap <Plug>MyPluginEcho <c-r>="hello"<cr>
> > > > " set lmap=i;k
> > > >
> > > > run vim -u lmap.vim -N
> > > > and type <tab> in insert mode, note, how "hello" is printed in either
> > > > insert mode or command line mode.
> > > > Now do
> > > > :set lmap=i;k
> > > > and do it again. Note that <Plug>MyPluginEcho will be output.
> > > >
> > > > The problem is, setting lmap breaks plugins (see e.g. here:
> > > > http://stackoverflow.com/questions/12450803)
> > > >
> > > > I would consider this is a bug and actually think, that setting 'lmap'
> > > > should never be applied to when recursively resolving a mapping.
> > >
> > > Since langmap is supposed to map typed characters, it makes sense that
> > > the RHS of a mapping is not langmapped.
> > >
> > > > Also, I do not understand what this part of the help is trying to say:
> > > >
> > > > ,----[ :h 'lmap' ]-
> > > > | This will allow you to activate vim actions without having to switch
> > > > | back and forth between the languages. Your language characters will
> > > > | be understood as normal vim English characters (according to the
> > > > | langmap mappings) in the following cases:
> > > > | o Normal/Visual mode (commands, buffer/register names, user mappings)
> > > > | o Insert/Replace Mode: Register names after CTRL-R
> > > > | o Insert/Replace Mode: Mappings
> > > > | Characters entered in Command-line mode will NOT be affected by
> > > > | this option. Note that this option can be changed at any time
> > > > | allowing to switch between mappings for different languages/encodings.
> > > > | Use a mapping to avoid having to type it each time!
> > > > `----
> > > >
> > > > What are the language characters? What is the relationship to lmap
> > > > mappings?
> > >
> > > Language characters is what comes out of the keyboard when switched to a
> > > specific language, e.g. Greek. Then the "a" key produces the "α"
> > > character.
> > >
> > > It's possible that this was only tested for when the keyboard produces
> > > non-ascii characters.
> > >
> > > > This patch could fix it, but I am not sure, this fixes it correctly.
> > >
> > > I think you need to compare mlen to typebuf.tb_maplen.
> >
> > Okay, here is a patch, that does that when the new option 'langnoremap'
> > is set (which defaults to off for backwards compatibility)
>
> Thanks. I'll leave it to others to try it out.
Turns out, the check for langnoremap has to be checked in a couple of
more places.
Here is an updated patch that fixes an issue, that when using <c-r>=
the righthand side would still be langmapped (e.g. when using set
lmap==-)
Therefore, I moved the check for the langnoremap option into the
LANGMAP_ADJUST macro.
> Perhaps we should set the 'langnoremap' option in vimrc_example.vim
> script. Most new users will want it on.
[X] Done
Best,
Christian
--
--
--
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/d/optout.
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -4589,6 +4589,16 @@ A jump table for the options with a shor
:source $VIMRUNTIME/menu.vim
< Warning: This deletes all menus that you defined yourself!
+ *'langmap'* *'lmap'* *E357* *E358*
+'langnoremap' 'lnr' boolean (default off)
+ global
+ {not in Vi}
+ {only available when compiled with the |+langmap|
+ feature}
+ When on, setting 'lmap' does not apply when resolving mappings
+ recursively. This basically means, if you noticed that setting 'lmap'
+ will disable your mappings, try setting this option.
+
*'laststatus'* *'ls'*
'laststatus' 'ls' number (default 1)
global
diff --git a/runtime/vimrc_example.vim b/runtime/vimrc_example.vim
--- a/runtime/vimrc_example.vim
+++ b/runtime/vimrc_example.vim
@@ -95,3 +95,9 @@ if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
+
+if has('langmap') && exists('+langnoremap')
+" Prevent, that the langmap option applies to the rhs of a mapping
+" if unset (default), this may break plugins.
+ set langnoremap
+endif
diff --git a/src/macros.h b/src/macros.h
--- a/src/macros.h
+++ b/src/macros.h
@@ -128,13 +128,16 @@
* Adjust chars in a language according to 'langmap' option.
* NOTE that there is no noticeable overhead if 'langmap' is not set.
* When set the overhead for characters < 256 is small.
- * Don't apply 'langmap' if the character comes from the Stuff buffer.
+ * Don't apply 'langmap' if the character comes from the Stuff buffer
+ * or from a mapping and the langnoremap option was set.
* The do-while is just to ignore a ';' after the macro.
*/
# ifdef FEAT_MBYTE
# define LANGMAP_ADJUST(c, condition) \
do { \
- if (*p_langmap && (condition) && !KeyStuffed && (c) >= 0) \
+ if (*p_langmap && (condition) && \
+ (!p_lnr || (p_lnr && typebuf_maplen() == 0)) \
+ && !KeyStuffed && (c) >= 0) \
{ \
if ((c) < 256) \
c = langmap_mapchar[c]; \
@@ -145,7 +148,9 @@
# else
# define LANGMAP_ADJUST(c, condition) \
do { \
- if (*p_langmap && (condition) && !KeyStuffed && (c) >= 0 && (c) < 256) \
+ if (*p_langmap && (condition) && \
+ (!p_lnr || (p_lnr && typebuf_maplen() == 0)) \
+ && !KeyStuffed && (c) >= 0 && (c) < 256) \
c = langmap_mapchar[c]; \
} while (0)
# endif
diff --git a/src/option.c b/src/option.c
--- a/src/option.c
+++ b/src/option.c
@@ -1691,6 +1691,13 @@ static struct vimoption
(char_u *)NULL, PV_NONE,
#endif
{(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
+ {"langnoremap", "lnr", P_BOOL|P_VI_DEF,
+#ifdef FEAT_LANGMAP
+ (char_u *)&p_lnr, PV_NONE,
+#else
+ (char_u *)NULL, PV_NONE,
+#endif
+ {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
{"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
#ifdef FEAT_WINDOWS
(char_u *)&p_ls, PV_NONE,
diff --git a/src/option.h b/src/option.h
--- a/src/option.h
+++ b/src/option.h
@@ -576,6 +576,7 @@ EXTERN char_u *p_kp; /* 'keywordprg' */
EXTERN char_u *p_km; /* 'keymodel' */
#ifdef FEAT_LANGMAP
EXTERN char_u *p_langmap; /* 'langmap'*/
+EXTERN int p_lnr; /* 'langnoremap' */
#endif
#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
EXTERN char_u *p_lm; /* 'langmenu' */