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

Re: 'list', :list, and 'listchars'

Expand Messages
  • Christian Brabandt
    ... Here is a patch, that adds nbsp support to :list command. I leave out conceal, as I don t think this makes sense here: diff --git a/src/message.c
    Message 1 of 5 , Jan 31, 2011
    • 0 Attachment
      On Sat, January 29, 2011 10:59 am, Andy Wokula wrote:
      > Am 26.01.2011 18:41, schrieb Ben Fritz:
      >>> From looking at :list, it seems like it's basically supposed to print
      >> the line as it would show with 'list' turned on. However, I have a few
      >> questions:
      >>
      >> :help :list says it will use '^' for unprintable characters, and
      >> additionally says "This can be changed with the 'listchars' option.
      >> However, there does not seem to be any 'listchars' option controlling
      >> the display of unprintable characters. What does setting 'list' do for
      >> unprintable characters? Anything?
      >>
      >> :help :list only mentions EOL and unprintable behavior, but
      >> experimentation shows that "trail", "extends", and "tab" also apply
      >> from 'listchars'. "precedes" and "extends" certainly would not make
      >> sense in this context, but what about "nbsp" and "conceal"?
      >> Experimentation shows that these two options do not have any effect.
      >> Should they? I could understand "conceal" having no effect, but I
      >> would certainly expect "nbsp" to apply, since "trail", etc. all apply.
      >
      > Unprintable characters basically are control characters
      > :h 'isprint
      > Tab is a control character - when 'listchars' does not include
      > 'tab:xy', then tab will be printed as '^I'.
      >
      > "nbsp" was added recently, maybe just forgotten to be implemented for
      > :list ...
      > :list is such a rarely used command ...

      Here is a patch, that adds nbsp support to :list command. I leave out
      conceal, as I don't think this makes sense here:

      diff --git a/src/message.c b/src/message.c
      --- a/src/message.c
      +++ b/src/message.c
      @@ -1637,8 +1637,18 @@
      else if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1)
      {
      col += (*mb_ptr2cells)(s);
      - mch_memmove(buf, s, (size_t)l);
      - buf[l] = NUL;
      + if (mb_ptr2char(s) == 160 && list && lcs_nbsp != NUL)
      + {
      + int ll=0;
      + mb_char2bytes(lcs_nbsp, buf);
      + ll=(*mb_ptr2len)(buf);
      + buf[ll] = NUL;
      + }
      + else
      + {
      + mch_memmove(buf, s, (size_t)l);
      + buf[l] = NUL;
      + }
      msg_puts(buf);
      s += l;
      continue;


      regards,
      Christian

      --
      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
    • Bram Moolenaar
      ... That only works when enc is a multi-byte encoding. It should also work for latin1. Please insert spaces around = . You don t actually need the ll
      Message 2 of 5 , Feb 1, 2011
      • 0 Attachment
        Christian Brabandt wrote:

        > On Sat, January 29, 2011 10:59 am, Andy Wokula wrote:
        > > Am 26.01.2011 18:41, schrieb Ben Fritz:
        > >>> From looking at :list, it seems like it's basically supposed to print
        > >> the line as it would show with 'list' turned on. However, I have a few
        > >> questions:
        > >>
        > >> :help :list says it will use '^' for unprintable characters, and
        > >> additionally says "This can be changed with the 'listchars' option.
        > >> However, there does not seem to be any 'listchars' option controlling
        > >> the display of unprintable characters. What does setting 'list' do for
        > >> unprintable characters? Anything?
        > >>
        > >> :help :list only mentions EOL and unprintable behavior, but
        > >> experimentation shows that "trail", "extends", and "tab" also apply
        > >> from 'listchars'. "precedes" and "extends" certainly would not make
        > >> sense in this context, but what about "nbsp" and "conceal"?
        > >> Experimentation shows that these two options do not have any effect.
        > >> Should they? I could understand "conceal" having no effect, but I
        > >> would certainly expect "nbsp" to apply, since "trail", etc. all apply.
        > >
        > > Unprintable characters basically are control characters
        > > :h 'isprint
        > > Tab is a control character - when 'listchars' does not include
        > > 'tab:xy', then tab will be printed as '^I'.
        > >
        > > "nbsp" was added recently, maybe just forgotten to be implemented for
        > > :list ...
        > > :list is such a rarely used command ...
        >
        > Here is a patch, that adds nbsp support to :list command. I leave out
        > conceal, as I don't think this makes sense here:
        >
        > diff --git a/src/message.c b/src/message.c
        > --- a/src/message.c
        > +++ b/src/message.c
        > @@ -1637,8 +1637,18 @@
        > else if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1)
        > {
        > col += (*mb_ptr2cells)(s);
        > - mch_memmove(buf, s, (size_t)l);
        > - buf[l] = NUL;
        > + if (mb_ptr2char(s) == 160 && list && lcs_nbsp != NUL)
        > + {
        > + int ll=0;
        > + mb_char2bytes(lcs_nbsp, buf);
        > + ll=(*mb_ptr2len)(buf);
        > + buf[ll] = NUL;
        > + }
        > + else
        > + {
        > + mch_memmove(buf, s, (size_t)l);
        > + buf[l] = NUL;
        > + }
        > msg_puts(buf);
        > s += l;
        > continue;

        That only works when 'enc' is a multi-byte encoding. It should also
        work for latin1.

        Please insert spaces around "=". You don't actually need the "ll"
        variable.

        --
        hundred-and-one symptoms of being an internet addict:
        175. You send yourself e-mail before you go to bed to remind you
        what to do when you wake up.

        /// 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
      • Christian Brabandt
        ... Upps forgotten. I somehow thought, this is only relevant for multibyte encodings. Here is an updated patch. ... Done. ... I don t? But I need the width of
        Message 3 of 5 , Feb 1, 2011
        • 0 Attachment
          On Tue, February 1, 2011 2:14 pm, Bram Moolenaar wrote:
          > Christian Brabandt wrote:
          >> Here is a patch, that adds nbsp support to :list command. I leave out
          >> conceal, as I don't think this makes sense here:
          > That only works when 'enc' is a multi-byte encoding. It should also
          > work for latin1.
          >

          Upps forgotten. I somehow thought, this is only relevant for multibyte
          encodings. Here is an updated patch.

          > Please insert spaces around "=".

          Done.

          > You don't actually need the "ll" variable.

          I don't? But I need the width of the lcs_nbsp char for the output buffer
          and the width of the non-breaking char in the line to advance the pointer
          in the line.

          regards,
          Christian

          --
          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
        • Bram Moolenaar
          ... Thanks. ... The value is used only once, thus you can put the mb_ptr2len() right there. -- If Microsoft would build a car... ... You d have to press the
          Message 4 of 5 , Feb 1, 2011
          • 0 Attachment
            Christian Brabandt wrote:

            > >> Here is a patch, that adds nbsp support to :list command. I leave out
            > >> conceal, as I don't think this makes sense here:
            > > That only works when 'enc' is a multi-byte encoding. It should also
            > > work for latin1.
            > >
            >
            > Upps forgotten. I somehow thought, this is only relevant for multibyte
            > encodings. Here is an updated patch.

            Thanks.

            > > Please insert spaces around "=".
            >
            > Done.
            >
            > > You don't actually need the "ll" variable.
            >
            > I don't? But I need the width of the lcs_nbsp char for the output buffer
            > and the width of the non-breaking char in the line to advance the pointer
            > in the line.

            The value is used only once, thus you can put the mb_ptr2len() right
            there.

            --
            If Microsoft would build a car...
            ... You'd have to press the "Start" button to turn the engine off.

            /// 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
          • Christian Brabandt
            Hi Bram! ... Ah yes of course. regards, Christian -- -- You received this message from the vim_dev maillist. Do not top-post! Type your reply below the text
            Message 5 of 5 , Feb 1, 2011
            • 0 Attachment
              Hi Bram!

              On Di, 01 Feb 2011, Bram Moolenaar wrote:

              > The value is used only once, thus you can put the mb_ptr2len() right
              > there.

              Ah yes of course.

              regards,
              Christian
              --

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