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

[PATCH] add option to toggle the default remap behavior for feedkeys()

Expand Messages
  • René Köcher
    ... OK I accept you point in general however I may argue it does not apply for this special case. Let me try to explain: Plugin writers expect feedkeys() to
    Message 1 of 4 , Feb 6, 2013
    • 0 Attachment
      Am 06.02.2013 um 16:06 schrieb Bram Moolenaar <Bram@...>:

      >René Köcher wrote:
      >>the attached patch adds support for a new option called
      >>'feedkeysremap' or 'fkrm'. By default this option is always enabled
      >>resulting in feedkeys() behaving just as it did before the patch (keys
      >>will be remapped unless the optional mode parameter is set to 'n').
      >>Disabling the option (set nofeedkeysremap / nofkrm) will toggle this
      >>behavior and feedkeys() will default to *not* remap the keys (same
      >>behavior as with mode=='n').
      >>I'm a user of the langmap feature (+langmap) which helps me to keep
      >>the keyboard navigation working while still being able to use my
      >>preferred keyboard layout [dvorak-de-t2]. However the downside is
      >>that most plugins don't care about langmap and thus may break in
      >>unexpected ways when using feedkeys().
      >>Now it would be possible to file bugs for a gazillion of plugins to
      >>set the optional mode parameter in calls to feedkeys() however I find
      >>it more reasonable to offer a global way to settle default remapping
      >>mode to active / inactive. In my test it worked pretty well with 'set
      >>nofkrm' so I thought I'd share it.
      >>There are two versions of the patch - one which depends on langmap
      >>being available and otherwise sets 'fkrm' to a no-op, the second one
      >>working without langmap.
      >>Be kind, this is my first public vim patch ;)
      >Well, I'm afraid this is the wrong solution. We do not want to add
      >global options that change how functions work. In your specific example
      >it may fix a problem, but in general it causes problems. That's because
      >script writers most likely will not handle the option being not at the
      >default value.

      OK I accept you point in general however I may argue it does not apply
      for this special case.
      Let me try to explain:

      Plugin writers expect feedkeys() to send the keys they pass to it.
      With langmap in effect that's certainly not always the case.
      So basically you already provide a global option to changes how a
      function works! ;)

      Using my patch along with an active langmap/keymap just restores what
      the plugins author had in mind before remapping got in the way.
      If they would really care about the final outcome more plugins would
      make use of the 'm' and 'n' flags.

      And again my patch doesn't break here:
      There is still the possibility to check &fkrm
      or just explicitly pass the appropriate mode to feedkeys.
      (Same could be said about langmap..)
      fkrm only defines the default and doesn't invert or change how the
      mode flags work.

      >So, you indeed need to tell script writers to fix their script.
      >I know that's a pain, but it's the right solution.

      Nah, trust me I tried..
      Most writers answered with blunt rejection.

      I'm fine if you think this patch is not suited for upstream
      I already had it in my local vim
      for some time and am always able to
      add it to the latest release.
      But trust me, so far nothing has broken
      but rather returned to work 'as expected'.

      Another idea would be to drop the
      'optional' flag of feedkeys 'mode' and
      force plugin authors to *think* a little
      what mode is really needed.
      The reference states 'remapping' however it doesn't mention to what
      or that a lang- or keymap will probably
      break things.

      Anyway, thanks for replying!


      P.S. Repost - missed to CC to vim-dev

      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 vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    Your message has been successfully submitted and would be delivered to recipients shortly.