On 22/03/2008, björn <[EMAIL PROTECTED]> wrote:
> On 17/03/2008, Charles E Campbell Jr <[EMAIL PROTECTED]> wrote:
>  >
>  >  Hello!
>  >
>  >  Netrw is using
>  >
>  >   silent! emenu Buffers.Refresh\ menu
>  >
>  >  to make certain that the buffers menu is refreshed.  Unfortunately, this
>  >  doesn't work for non-English locales, as was pointed out to me by Stefan
>  >  Bittner:
>  >
>  >   :emenu Puffer.Aktualisieren    -> Works
>  >   :emenu Buffers.Refresh        -> E334      (the silent! prevents any
>  >  obvious problems, but the refresh isn't being done)
>  >
>  >  So, how may I penetrate the maze (at least to me) of locale and get this
>  >  menu refreshed?  Note that the function calls <SID>BMShow() -- so the
>  >  underlying function isn't available to be called.
>
>
> I have been thinking about this problem from another viewpoint.
>
>  In MacVim I have a command that needs to locate menu items from a menu
>  descriptor (e.g. "Buffers.Refresh") just like :emenu does.  The
>  problem with the :emenu routine (as pointed out above) is that it only
>  works if the (input) descriptor has been translated already (when
>  using non-English locales, of course).
>
>  I will be writing a routine for MacVim that takes a descriptor and
>  first translates it, then looks it up in the menu hierarchy.  Once
>  done I could use this routine in :emenu as well, thereby fixing the
>  problem Chip describes above.  Would such a patch be desirable?
>  (Otherwise I'll keep it inside MacVim.)

Attached to this post is a patch that makes :emenu accept English menu
descriptors even when the menus have been translated.  Basically, I've
just made ex_emenu() work the same way ex_menu() does; that is, given
a descriptor, translate it first, then look for the translated
descriptor in the menu hierarchy.  (An alternative approach to this
patch would be to make menu_namecmp() locale independent.)

With this patch it is possible to write scripts that call :emenu and
which work independently of whether a user has translated menus or
not.  Without this patch :emenu must be passed the translated menu
name, hence making :emenu pretty much useless in scripts.

There is quite a lot of code duplication in menu.c already and this
patch actually adds to the chaos.  Maybe it would be worthwhile to try
to get rid of code duplication?  Might I suggest this as a "simple"
GSoC project (or part of a larger project)?


/Björn

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Attachment: menu.c.patch
Description: Binary data

Raspunde prin e-mail lui