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

Re: why vim give error on removing non existing mapping

Expand Messages
  • Nikolay Pavlov
    ... to perform an action (*delete* mapping, *unmap*) and if action cannot be performed (no such mapping) reporting failure is expected. If it was mapclear and
    Message 1 of 10 , Jul 13, 2013
    • 0 Attachment


      On Jul 13, 2013 8:59 PM, "Albert Netymk" <albertnetymk@...> wrote:
      >
      >
      > > For a command called unmap this behavior is indeed intuitive: you asked to perform an action (*delete* mapping, *unmap*) and if action cannot be performed (no such mapping) reporting failure is expected. If it was mapclear and it accepted argument like unmap I would call *this* command's behavior counter-intuitive: you asked to clear the mapping and if it is already cleared it is perfectly fine.
      >
      > Since we don't have the mapclear that works on a single mapping, should unmap stands out and take this responsibility. It seems that E31 (no such mapping) is the only error that could happen inside unmap, so it's always safe to
      > `silent! unmap <some-mapping>` regardless of the existence of one mapping. Therefore, unmap should take `silent!` as default behavior.

      To make this intuitive :unmap should be renamed to :mapclear.

      I see no reason for making :unmap taking the "responsibility" of :silent! unmap with nobody retaining original behavior. Failing :unmap can show wrong execution context problems, not failing is nothing more then a few characters save.

      > >
      > > I do not think I would benefit from either behavior (especially with regex-based error capturing which looks brain-damaged after more modern languages) though.
      >
      > --
      > --
      > 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.
      >
      >

      --
      --
      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.
       
       
    • Ingo Karkat
      ... No, because you can t :unsilent (there s such a command, but it does not change the error handling, only reenables output) such a modified :unmap command
      Message 2 of 10 , Jul 13, 2013
      • 0 Attachment
        On 13-Jul-2013 19:00 +0200, Albert Netymk wrote:

        >> For a command called unmap this behavior is indeed intuitive: you
        >> asked to perform an action (*delete* mapping, *unmap*) and if action
        >> cannot be performed (no such mapping) reporting failure is expected.
        >> If it was mapclear and it accepted argument like unmap I would call
        >> *this* command's behavior counter-intuitive: you asked to clear the
        >> mapping and if it is already cleared it is perfectly fine.
        >
        > Since we don't have the mapclear that works on a single mapping,
        > should unmap stands out and take this responsibility. It seems that
        > E31 (no such mapping) is the only error that could happen inside
        > unmap, so it's always safe to `silent! unmap <some-mapping>`
        > regardless of the existence of one mapping. Therefore, unmap should
        > take `silent!` as default behavior, I believe.

        No, because you can't :unsilent (there's such a command, but it does not
        change the error handling, only reenables output) such a modified :unmap
        command if you're indeed interested in getting an error when the mapping
        does not exist.

        I don't see your point. Just prepend :silent! if you're not interested
        in the error. Especially with :unmap, this is mostly used in personal
        customizations. Some people like to be informed about an obsolete
        unmapping (when they've uninstalled the plugin), others don't care about
        this. The current behavior easily satisfies both, and it won't be
        changed for backwards compatibility, anyway.

        -- regards, ingo

        --
        --
        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.