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

Re: [bug] searching for []

Expand Messages
  • Tony Mechelynck
    ... Christian: did you notice the comment immediately after your addition? «If there is no matching ] , we assume the [ is a normal character.» T ain t a
    Message 1 of 4 , Apr 19, 2013
    • 0 Attachment
      On 19/04/13 23:57, Christian Brabandt wrote:
      > Bram,
      >
      > I noticed, that searching in Vim for [] will match '[]' literally. This seems
      > to be a little bit unexpected, because I would either expect to match
      > everything because the collation [] contains nothing, or an error message,
      > since we are missing a closing ']' as grep or awk does (also nvi):
      >
      > ~$ grep '[]' ~/.vimrc
      > grep: Unmatched [ or [^
      >
      > At the very least, this special behaviour needs to be documented, but I tend to consider this behaviour as a bug.
      >
      > BTW: POSIX says this about it:
      >
      > ,----
      > | The right-bracket ( ']' ) shall lose its special meaning and represent itself
      > | in a bracket expression if it occurs first in the list (after an initial
      > | circumflex ( '^' ), if any)
      > `----
      >
      > This patch makes Vim report an error message:
      >
      > diff --git a/src/regexp.c b/src/regexp.c
      > --- a/src/regexp.c
      > +++ b/src/regexp.c
      > @@ -2283,6 +2283,9 @@
      > {
      > char_u *lp;
      >
      > + if (*regparse == ']')
      > + EMSG_M_RET_NULL(_("E769: Missing ] after %s["),
      > + reg_magic > MAGIC_OFF);
      > /*
      > * If there is no matching ']', we assume the '[' is a normal
      > * character. This makes 'incsearch' and ":help [" work.
      >
      >
      >
      > regards,
      > Christian
      >
      Christian: did you notice the comment immediately after your addition?
      «If there is no matching ']', we assume the '[' is a normal character.»

      T'ain't a bug, it's a feature.


      Best regards,
      Tony.
      --
      Omnibiblious, adj.:
      Indifferent to type of drink. "Oh, you can get me anything.
      I'm omnibiblious."

      --
      --
      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.
    • Bram Moolenaar
      ... I don t like errors... I m not sure if this is an improvement. And in case of doubt it s better to leave it as it is. How about adding this to the docs: -
      Message 2 of 4 , Apr 20, 2013
      • 0 Attachment
        Christian Brabandt wrote:

        > I noticed, that searching in Vim for [] will match '[]' literally. This seems
        > to be a little bit unexpected, because I would either expect to match
        > everything because the collation [] contains nothing, or an error message,
        > since we are missing a closing ']' as grep or awk does (also nvi):
        >
        > ~$ grep '[]' ~/.vimrc
        > grep: Unmatched [ or [^
        >
        > At the very least, this special behaviour needs to be documented, but I tend to consider this behaviour as a bug.
        >
        > BTW: POSIX says this about it:
        >
        > ,----
        > | The right-bracket ( ']' ) shall lose its special meaning and represent itself
        > | in a bracket expression if it occurs first in the list (after an initial
        > | circumflex ( '^' ), if any)
        > `----
        >
        > This patch makes Vim report an error message:

        I don't like errors...

        I'm not sure if this is an improvement. And in case of doubt it's
        better to leave it as it is.

        How about adding this to the docs:

        - Omitting the trailing ] is not considered an error. "[]" works like
        "[]]", it matches the ']' character.

        --
        % cat /usr/include/sys/errno.h
        #define EPERM 1 /* Operation not permitted */
        #define ENOENT 2 /* No such file or directory */
        #define ESRCH 3 /* No such process */
        [...]
        #define EMACS 666 /* Too many macros */
        %

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ an exciting new programming language -- http://www.Zimbu.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

        --
        --
        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.
      • Christian Brabandt
        Hi Bram! ... Okay, this is fine with me. regards, Christian -- Nur ein mittelmäßiger Mensch ist immer in Hochform. -- William Somerset Maugham -- -- You
        Message 3 of 4 , Apr 20, 2013
        • 0 Attachment
          Hi Bram!

          On Sa, 20 Apr 2013, Bram Moolenaar wrote:

          >
          > Christian Brabandt wrote:
          >
          > > I noticed, that searching in Vim for [] will match '[]' literally. This seems
          > > to be a little bit unexpected, because I would either expect to match
          > > everything because the collation [] contains nothing, or an error message,
          > > since we are missing a closing ']' as grep or awk does (also nvi):
          > >
          > > ~$ grep '[]' ~/.vimrc
          > > grep: Unmatched [ or [^
          > >
          > > At the very least, this special behaviour needs to be documented, but I tend to consider this behaviour as a bug.
          > >
          > > BTW: POSIX says this about it:
          > >
          > > ,----
          > > | The right-bracket ( ']' ) shall lose its special meaning and represent itself
          > > | in a bracket expression if it occurs first in the list (after an initial
          > > | circumflex ( '^' ), if any)
          > > `----
          > >
          > > This patch makes Vim report an error message:
          >
          > I don't like errors...
          >
          > I'm not sure if this is an improvement. And in case of doubt it's
          > better to leave it as it is.
          >
          > How about adding this to the docs:
          >
          > - Omitting the trailing ] is not considered an error. "[]" works like
          > "[]]", it matches the ']' character.

          Okay, this is fine with me.

          regards,
          Christian
          --
          Nur ein mittelmäßiger Mensch ist immer in Hochform.
          -- William Somerset Maugham

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