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

[patch] Fix handling of \L/\U

Expand Messages
  • James McCoy
    Bram, The other day in #vim, someone was wondering why :s/SOMEWORD/ L u&/ was resulting in sOMEWORD instead of title-case (Someword). That seemed like a
    Message 1 of 7 , Feb 13, 2013
    • 0 Attachment
      Bram,

      The other day in #vim, someone was wondering why :s/SOMEWORD/\L\u&/
      was resulting in sOMEWORD instead of title-case (Someword).

      That seemed like a reasonable expectation and is how PCRE would treat
      that substitution, so I came up with the attached patch to make Vim work
      like that. Also included are tests.

      Cheers,
      --
      James
      GPG Key: 4096R/331BA3DB 2011-12-05 James McCoy <jamessan@...>
    • James McCoy
      ... Oops, messed up my example. :s/sOmeWord/ L u&/ is better as the expected outcome is Someword but only the u takes effect so it s actually SOmeWord .
      Message 2 of 7 , Feb 13, 2013
      • 0 Attachment
        On Wed, Feb 13, 2013 at 09:53:59PM -0500, James McCoy wrote:
        > The other day in #vim, someone was wondering why :s/SOMEWORD/\L\u&/
        > was resulting in sOMEWORD instead of title-case (Someword).

        Oops, messed up my example. :s/sOmeWord/\L\u&/ is better as the
        expected outcome is "Someword" but only the \u takes effect so it's
        actually "SOmeWord".

        Cheers,
        --
        James
        GPG Key: 4096R/331BA3DB 2011-12-05 James McCoy <jamessan@...>
      • Bram Moolenaar
        ... Thanks, sounds like a good solution. Implementation is fairly simple. Can you also write an update for the documentation? -- MICHAEL PALIN PLAYED: 1ST
        Message 3 of 7 , Feb 14, 2013
        • 0 Attachment
          James McCoy wrote:

          > The other day in #vim, someone was wondering why :s/SOMEWORD/\L\u&/
          > was resulting in sOMEWORD instead of title-case (Someword).
          >
          > That seemed like a reasonable expectation and is how PCRE would treat
          > that substitution, so I came up with the attached patch to make Vim work
          > like that. Also included are tests.

          Thanks, sounds like a good solution. Implementation is fairly simple.

          Can you also write an update for the documentation?


          --
          MICHAEL PALIN PLAYED: 1ST SOLDIER WITH A KEEN INTEREST IN BIRDS, DENNIS, MR
          DUCK (A VILLAGE CARPENTER WHO IS ALMOST KEENER THAN
          ANYONE ELSE TO BURN WITCHES), THREE-HEADED KNIGHT, SIR
          GALAHAD, KING OF SWAMP CASTLE, BROTHER MAYNARD'S ROOMATE
          "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

          /// 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.
        • James McCoy
          ... That s the other part I forgot to mention. The documentation already describes the behavior I implemented. James -- -- You received this message from the
          Message 4 of 7 , Feb 14, 2013
          • 0 Attachment


            On Feb 14, 2013 4:08 PM, "Bram Moolenaar" <Bram@...> wrote:
            >
            >
            > James McCoy wrote:
            >
            > > The other day in #vim, someone was wondering why :s/SOMEWORD/\L\u&/
            > > was resulting in sOMEWORD instead of title-case (Someword).
            > >
            > > That seemed like a reasonable expectation and is how PCRE would treat
            > > that substitution, so I came up with the attached patch to make Vim work
            > > like that.  Also included are tests.
            >
            > Thanks, sounds like a good solution.  Implementation is fairly simple.
            >
            > Can you also write an update for the documentation?

            That's the other part I forgot to mention.  The documentation already describes the behavior I implemented.

            James

            --
            --
            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
            ... Where? I cannot find a match for L u in the documentation. -- An SQL statement walks into a bar. He approaches two tables and says, Mind if I join
            Message 5 of 7 , Feb 15, 2013
            • 0 Attachment
              James McCoy wrote:

              > > > The other day in #vim, someone was wondering why :s/SOMEWORD/\L\u&/
              > > > was resulting in sOMEWORD instead of title-case (Someword).
              > > >
              > > > That seemed like a reasonable expectation and is how PCRE would treat
              > > > that substitution, so I came up with the attached patch to make Vim work
              > > > like that. Also included are tests.
              > >
              > > Thanks, sounds like a good solution. Implementation is fairly simple.
              > >
              > > Can you also write an update for the documentation?
              >
              > That's the other part I forgot to mention. The documentation already
              > describes the behavior I implemented.

              Where? I cannot find a match for \L\u in the documentation.

              --
              An SQL statement walks into a bar. He approaches two tables
              and says, "Mind if I join you?"

              /// 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.
            • James McCoy
              ... treat ... work ... The s/ L topic states following characters made uppercase, until E and s/ u states next character made uppercase so a u should only
              Message 6 of 7 , Feb 15, 2013
              • 0 Attachment


                On Feb 15, 2013 9:24 AM, "Bram Moolenaar" <Bram@...> wrote:
                >
                >
                >
                > James McCoy wrote:
                >
                > > > > The other day in #vim, someone was wondering why :s/SOMEWORD/\L\u&/
                > > > > was resulting in sOMEWORD instead of title-case (Someword).
                > > > >
                > > > > That seemed like a reasonable expectation and is how PCRE would treat
                > > > > that substitution, so I came up with the attached patch to make Vim work
                > > > > like that.  Also included are tests.
                > > >
                > > > Thanks, sounds like a good solution.  Implementation is fairly simple.
                > > >
                > > > Can you also write an update for the documentation?
                > >
                > > That's the other part I forgot to mention.  The documentation already
                > > describes the behavior I implemented.
                >
                > Where?  I cannot find a match for \L\u in the documentation.

                The s/\L topic states

                  following characters made uppercase, until \E

                and s/\u states

                  next character made uppercase

                so a \u should only affect the character after it, not terminate the existing \L effect.  Were you looking for this specific example to be documented?

                James

                --
                --
                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
                ... But it never worked that way, so far a u would undo a previous L. That was not explicitly mentioned, but it has always worked that way. I think it s good
                Message 7 of 7 , Feb 15, 2013
                • 0 Attachment
                  James McCoy wrote:

                  > > > > > The other day in #vim, someone was wondering why :s/SOMEWORD/\L\u&/
                  > > > > > was resulting in sOMEWORD instead of title-case (Someword).
                  > > > > >
                  > > > > > That seemed like a reasonable expectation and is how PCRE would treat
                  > > > > > that substitution, so I came up with the attached patch to make Vim work
                  > > > > > like that. Also included are tests.
                  > > > >
                  > > > > Thanks, sounds like a good solution. Implementation is fairly simple.
                  > > > >
                  > > > > Can you also write an update for the documentation?
                  > > >
                  > > > That's the other part I forgot to mention. The documentation already
                  > > > describes the behavior I implemented.
                  > >
                  > > Where? I cannot find a match for \L\u in the documentation.
                  >
                  > The s/\L topic states
                  >
                  > following characters made uppercase, until \E
                  >
                  > and s/\u states
                  >
                  > next character made uppercase
                  >
                  > so a \u should only affect the character after it, not terminate the
                  > existing \L effect. Were you looking for this specific example to be
                  > documented?

                  But it never worked that way, so far a \u would undo a previous \L.
                  That was not explicitly mentioned, but it has always worked that way.
                  I think it's good to explicitly state how this works.

                  There should be a specific example of how to change a line of words into
                  title case. It's very useful. We might even want to put it in the user
                  manual. That would be usr_10.txt

                  --
                  FATAL ERROR! SYSTEM HALTED! - Press any key to continue doing nothing.

                  /// 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.
                Your message has been successfully submitted and would be delivered to recipients shortly.