How to handle multi-line quotes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MartinRinehart@gmail.com

    How to handle multi-line quotes

    Thinking about unclosed multi-line quotes.

    When you open a multi-line quote (type '"""') what does your editor
    do? Does it color the remainder of your text as a quote, or does it
    color the line with the open quote as a quote and leave the rest of
    your code alone?

    What do you want it to do?

    This is a tokenizer question in disguise, of course. The simple way to
    handle it, which is what my editor sees, is for the tokenizer to
    return the remainder of the text as one great UNCLOSED_MULTIL INE_QUOTE
    token. The alternative is to assume that the line with the unclosed
    quote is in error and to continue to tokenize the rest. An editor
    might blink or otherwise draw attention to the unmatched quote.
  • Lie

    #2
    Re: How to handle multi-line quotes

    On Dec 22, 2:15 am, MartinRineh...@ gmail.com wrote:
    Thinking about unclosed multi-line quotes.
    >
    When you open a multi-line quote (type '"""') what does your editor
    do? Does it color the remainder of your text as a quote, or does it
    color the line with the open quote as a quote and leave the rest of
    your code alone?
    >
    What do you want it to do?
    >
    This is a tokenizer question in disguise, of course. The simple way to
    handle it, which is what my editor sees, is for the tokenizer to
    return the remainder of the text as one great UNCLOSED_MULTIL INE_QUOTE
    token. The alternative is to assume that the line with the unclosed
    quote is in error and to continue to tokenize the rest. An editor
    might blink or otherwise draw attention to the unmatched quote.
    Are you asking about IDLE? If it is, IDLE considers the remainder of
    the code as part of multiline-quote and thus colors them green (in
    default color scheme). This behavior is consistent with any other code
    editors way of handling multiline comments (Frontpage, Dreamweaver,
    etc). IMHO, it is a fine behavior, such a huge color change would be
    immediately noticed by any non-color-blind people and they'll
    immediately close the multiline (perhaps in panic) before filling the
    multiline.

    Comment

    • Bruno Desthuilliers

      #3
      Re: How to handle multi-line quotes

      MartinRinehart@ gmail.com a écrit :
      Thinking about unclosed multi-line quotes.
      >
      When you open a multi-line quote (type '"""') what does your editor
      do?
      The RightThing(tm), that is:
      Does it color the remainder of your text as a quote,
      Indeed.

      Comment

      • riquito@gmail.com

        #4
        Re: How to handle multi-line quotes

        On 21 Dic, 22:13, Bruno Desthuilliers
        <bdesth.quelque ch...@free.quel quepart.frwrote :
        MartinRineh...@ gmail.com a écrit :
        >
        Thinking about unclosed multi-line quotes.
        >
        When you open a multi-line quote (type '"""') what does your editor
        do?
        >
        The RightThing(tm), that is:
        >
        Does it color the remainder of your text as a quote,
        >
        Indeed.
        I'd call it "The CommonBehaviour (tm)".
        Other options, wich I've never seen, could be
        1) color every word as in normal mode, while changing the background
        color (with something similar peraps)
        2) color the remainder of the text as a quote, but using lighter/
        darker colors for the different kind of tokens

        Comment

        • Hendrik van Rooyen

          #5
          Re: How to handle multi-line quotes

          MartinRinehart wrote:
          Thinking about unclosed multi-line quotes.
          >
          When you open a multi-line quote (type '"""') what does your editor
          do? Does it color the remainder of your text as a quote, or does it
          color the line with the open quote as a quote and leave the rest of
          your code alone?
          >
          What do you want it to do?
          Warning: You don't want to hear this, but you did ask...
          ======

          It depends on context in my mind.

          If I am typing a new string, I want it to automatically add the trailing quotes
          and leave the cursor between them, ready for entry, until I use the arrow
          keys or the mouse to get "out of" the string.

          If I am commenting out a piece of code, I want it to give me the default
          behaviour - chunking the rest of the file in one big lump until I insert the
          closing quotes.

          But alas - it has always been thus - I seldom get what I want, because
          people and things always seem to misinterpret my intentions.

          So I will settle for the default initial behaviour, with a switch to the first
          style when I type the first displayable character after the opening quotes.

          Or the opposite, start with the full set of delimiters, the cursor between
          them, and if the cursor moves out of the empty string, fall back to the
          lumpy behaviour by removing the closing delimiters.

          Both would force one to explicitly define an empty string, but that is
          just the way the world works now, so that is fine by me.

          And just to make your day, I want the behaviour to nest or not, to give
          me control over how it works, and while we are parameterising - why not
          something to choose between the three styles? - you could define some
          globals, and write a lot more code. (and yes its three not two - think about
          it)

          Do you sometimes feel that becoming a fireman or a pizza salesman
          would have led to a less complicated life?

          - Hendrik


          Comment

          Working...