Loading ...
Sorry, an error occurred while loading the content.

Re: How to use emenu in a locale-independent manner?

Expand Messages
  • Bram Moolenaar
    ... Good, thanks. I do think that, for backwards compatibility, :emenu needs to accept both the translated and the untranslated menu name. I suppose that when
    Message 1 of 4 , Mar 30, 2008
      Bjorn Winckler wrote:

      > On 22/03/2008, björn <bjorn.winckler@...> wrote:
      > > On 17/03/2008, Charles E Campbell Jr <drchip@...> 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.

      Good, thanks. I do think that, for backwards compatibility, :emenu
      needs to accept both the translated and the untranslated menu name.
      I suppose that when translation fails it works that way, so it should be

      > 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)?

      Cleanup would be good, but then we also need some tests to verify it
      still works the same way. Not really interesting for a SoC project, I

      hundred-and-one symptoms of being an internet addict:
      193. You ask your girlfriend to drive home so you can sit back with
      your PDA and download the information to your laptop

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ download, build and distribute -- http://www.A-A-P.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
    Your message has been successfully submitted and would be delivered to recipients shortly.