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

'formatlistpat' broke for punctuation chars?

Expand Messages
  • Maciej Kalisiak
    I am trying to :set flp=^ s*- s*, so that I can do properly indented bullet list using dashes. In older versions of Vim this works as expected. That is, I
    Message 1 of 5 , Mar 7, 2013
    • 0 Attachment
      I am trying to :set flp=^\\s*-\\s*, so that I can do properly indented bullet list using dashes. In older versions of Vim this works as expected. That is, I get this formatting:

      - aoeu aoeu aeou oeu aoeu oaeu
      aeouaeouaoeu aoeuaoue eauo aou

      (i.e., 2nd and consecutive lines are indented)

      But with some recent versions of Vim it's as if the dash is not recognized as a list bullet, and all lines are flushed left; i.e.,

      - aoeu aoeu aoeu aoeu aoeu
      aoeu aoeu aoeu aoeu aaoeu

      I've noticed same behaviour if I use '#' or '*' for bullet character, while digits or letters always work fine.

      Versions where things work properly:
      - vim 7.3 on OS X with (as far as I can tell) no patches applied (i.e., stock on my Macbook Air).
      - MacVim 7.2 patches 1-376 on OS X

      Versions where things do NOT work properly:
      - MacVim 7.3 patches 1-754 on OS X
      - Vim 7.3 patches 1-831 on Linux


      HOW TO REPRODUCE

      Start vim with:
      $ vim -u NONE -U NONE

      Set options:
      :set fo=tn
      :set autoindent
      :set tw=40 " so don't have to type much to hit margin
      :set flp=^\\s*X\\s*

      Note the 'X'... this always works. That is, I get proper indenting:

      X aoeu aoeu aeou aoeu aoeu aoeu aoeu
      aoeu aoeu aoeu aoeu aeou aoue aoeu

      Now I switch 'X' to one of the problematic characters:
      :set flp=^\\s*-\\s*

      With this, on the "broken" versions, there is no indentation:

      - aoeu aoeu aoeu aoeu aoeu aoeu aoeu aoeu
      aoeu aoeu aoeu aoeu aou aoeu aoeu aoeu

      while on "not broken" versions it indents as expected:

      - aoeu aoeu aoeu aoeu aeou aeou aoeu aoeu aoeu
      aoeu aoeu aoeu aoeu aoeu oaeu aoeu aoeu

      As I said, this behaviour is same if I use '*' or '#', and possibly other characters, but letters and digits seem unaffected.

      --
      --
      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.
    • Maciej Kalisiak
      FYI, I had a look at the code. I believe this behaviour was introduced by following patch:
      Message 2 of 5 , Mar 8, 2013
      • 0 Attachment
        FYI, I had a look at the code. I believe this behaviour was introduced by following patch:
        https://code.google.com/p/vim/source/detail?r=7e3fedfc3d08d020e3ce047ec1a1cfd195af9ed7

        In particular, this piece of code:

        #ifdef FEAT_COMMENTS
        /* In format_lines() (i.e. not insert mode), fo+=q is needed too... */
        if ((State & INSERT) || has_format_option(FO_Q_COMS))
        lead_len = get_leader_len(ml_get(lnum), NULL, FALSE, TRUE);
        #endif

        Seems to me this means that this discarding of comment characters from indentation count happens in INSERT mode regardless of all settings.

        To confirm, I tried reproducing my steps after doing ':set comments=' and indeed that seems to correct things. So at least that's a work-around. (Recall that the default value for 'comments' is "s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-", which indeed has all the chars I had trouble with)

        I think this is a bug, the use of non-zero lead_len is unintuitive and surprising. Perhaps it should be gated by having fo+=c, namely where we have indicated we want comments to be formatted. But I am not sure of this, still getting the hang of the semantics of all the 'fo' options. Regardless, the current behaviour seems to me overly aggressive, being applied even when there are no comments.

        I would point out that this breaks formatting in packages such as vimwiki, which use fo+=n for formatting their bullet lists. It's how I encountered this issue.


        On Thursday, March 7, 2013 10:05:58 PM UTC-5, Maciej Kalisiak wrote:
        > I am trying to :set flp=^\\s*-\\s*, so that I can do properly indented bullet list using dashes. In older versions of Vim this works as expected. That is, I get this formatting:
        >
        > - aoeu aoeu aeou oeu aoeu oaeu
        > aeouaeouaoeu aoeuaoue eauo aou
        >
        > (i.e., 2nd and consecutive lines are indented)
        >
        > But with some recent versions of Vim it's as if the dash is not recognized as a list bullet, and all lines are flushed left; i.e.,
        >
        > - aoeu aoeu aoeu aoeu aoeu
        > aoeu aoeu aoeu aoeu aaoeu
        >
        > I've noticed same behaviour if I use '#' or '*' for bullet character, while digits or letters always work fine.
        >
        > Versions where things work properly:
        > - vim 7.3 on OS X with (as far as I can tell) no patches applied (i.e., stock on my Macbook Air).
        > - MacVim 7.2 patches 1-376 on OS X
        >
        > Versions where things do NOT work properly:
        > - MacVim 7.3 patches 1-754 on OS X
        > - Vim 7.3 patches 1-831 on Linux
        >
        >
        > HOW TO REPRODUCE
        >
        > Start vim with:
        > $ vim -u NONE -U NONE
        >
        > Set options:
        > :set fo=tn
        > :set autoindent
        > :set tw=40 " so don't have to type much to hit margin
        > :set flp=^\\s*X\\s*
        >
        > Note the 'X'... this always works. That is, I get proper indenting:
        >
        > X aoeu aoeu aeou aoeu aoeu aoeu aoeu
        > aoeu aoeu aoeu aoeu aeou aoue aoeu
        >
        > Now I switch 'X' to one of the problematic characters:
        > :set flp=^\\s*-\\s*
        >
        > With this, on the "broken" versions, there is no indentation:
        >
        > - aoeu aoeu aoeu aoeu aoeu aoeu aoeu aoeu
        > aoeu aoeu aoeu aoeu aou aoeu aoeu aoeu
        >
        > while on "not broken" versions it indents as expected:
        >
        > - aoeu aoeu aoeu aoeu aeou aeou aoeu aoeu aoeu
        > aoeu aoeu aoeu aoeu aoeu oaeu aoeu aoeu
        >
        > As I said, this behaviour is same if I use '*' or '#', and possibly other characters, but letters and digits seem unaffected.

        --
        --
        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.
      • Maciej Kalisiak
        I propose following patch (I tested to confirm that it resolves the issue when I repeat steps): diff -r 22683fa1b4ed src/misc1.c ... +++ b/src/misc1.c Fri Mar
        Message 3 of 5 , Mar 8, 2013
        • 0 Attachment
          I propose following patch (I tested to confirm that it resolves the issue when I repeat steps):

          diff -r 22683fa1b4ed src/misc1.c
          --- a/src/misc1.c Thu Mar 07 19:38:54 2013 +0100
          +++ b/src/misc1.c Fri Mar 08 10:47:54 2013 -0500
          @@ -438,7 +438,8 @@

          #ifdef FEAT_COMMENTS
          /* In format_lines() (i.e. not insert mode), fo+=q is needed too... */
          - if ((State & INSERT) || has_format_option(FO_Q_COMS))
          + if (((State & INSERT) && has_format_option(FO_WRAP_COMS))
          + || has_format_option(FO_Q_COMS))
          lead_len = get_leader_len(ml_get(lnum), NULL, FALSE, TRUE);
          #endif
          regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC);


          "make test" passes, as far as I can tell (reports "ALL DONE").

          --
          --
          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.
        • Ben Fritz
          ... I reproduced, using fo=tn, but I actually think this is correct behavior. The indentation works as intended with fo=cn instead of fo=tn. The default
          Message 4 of 5 , Mar 8, 2013
          • 0 Attachment
            On Thursday, March 7, 2013 9:05:58 PM UTC-6, Maciej Kalisiak wrote:
            > while on "not broken" versions it indents as expected:
            >
            > - aoeu aoeu aoeu aoeu aeou aeou aoeu aoeu aoeu
            > aoeu aoeu aoeu aoeu aoeu oaeu aoeu aoeu
            >
            > As I said, this behaviour is same if I use '*' or '#', and possibly other characters, but letters and digits seem unaffected.

            I reproduced, using fo=tn, but I actually think this is "correct" behavior.

            The indentation works as intended with fo=cn instead of fo=tn.

            The default setting for the 'comments' option, which determines whether the current line is a comment or not for automatic formatting, includes - as well as * and # as starting a line comment. So, with default settings, lines starting with #, *, or - all are formatted as comment lines. Since you do not have comment lines being formatted in your formatoptions setting, automatic formatting does not apply to these lines.

            Either add 'c' to your formatoptions setting, or remove '-' and other desired characters from your 'comments' setting.

            --
            --
            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.
          • Maciej Kalisiak
            ... Ah, very interesting, I didn t realize that was the interpretation of this option (manual frames it differently). This puts things in a different light.
            Message 5 of 5 , Mar 9, 2013
            • 0 Attachment
              On Fri, Mar 8, 2013 at 11:13 AM, Ben Fritz <fritzophrenic@...> wrote:
              On Thursday, March 7, 2013 9:05:58 PM UTC-6, Maciej Kalisiak wrote:
              > while on "not broken" versions it indents as expected:
              >
              > -  aoeu aoeu aoeu aoeu aeou aeou aoeu aoeu aoeu
              >    aoeu aoeu aoeu aoeu aoeu oaeu aoeu aoeu
              >
              > As I said, this behaviour is same if I use '*' or '#', and possibly other characters, but letters and digits seem unaffected.

              I reproduced, using fo=tn, but I actually think this is "correct" behavior.

              The indentation works as intended with fo=cn instead of fo=tn.

              The default setting for the 'comments' option, which determines whether the current line is a comment or not for automatic formatting,

              Ah, very interesting, I didn't realize that was the interpretation of this option (manual frames it differently).  This puts things in a different light.
               
              includes - as well as * and # as starting a line comment. So, with default settings, lines starting with #, *, or - all are formatted as comment lines. Since you do not have comment lines being formatted in your formatoptions setting, automatic formatting does not apply to these lines.

              Yeah, in that light this makes sense.
               

              Either add 'c' to your formatoptions setting, or remove '-' and other desired characters from your 'comments' setting.

              Hmm, neither leads to desired behaviour with Vimwiki... I suspect the latter might need to be updated in light of this change.

              Essentially, what I am really after, is to be able to do point form PARAGRAPHS in a vimwiki bullet list, something that was possible before the mentioned change; that is, I want to achieve the following layout and indentation (which I assume is how vimwiki is intended to work), by entering only words, spaces, and hitting return to at end of each bullet paragraph:

              * short item<CR>
              * a much much much much much much much longer
                item that requires a line wrap<CR>
              * another very very very very long bullet point that also
                requires a line wrap<CR>

              With recent Vim those paragraphs will not be indented properly; as mentioned earlier, I'll get:

              * short item<CR>
              * a much much much much much much much longer
              item that requires a line wrap<CR>
              * another very very very very long bullet point that also
              requires a line wrap<CR>

              If I throw on fo+=c, I instead get the asterisk on every line:

              * short item<CR>
              * a much much much much much much much longer
              * item that requires a line wrap<CR>
              * another very very very very long bullet point that also
              * requires a line wrap<CR>

              Removing the character from 'comments' on the other hand leads to the bullet no longer being automatically inserted for next item when you hit <CR>.

              I suppose though that this is then an issue with how Vimwiki implements this bullet entry functionality, and the script needs to be adapted after this change.



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





              --
              Maciej Kalisiak
              mkalisiak@...

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