How to handle multi-line quotes

M

MartinRinehart

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

ianaré

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

All the editors I use (Gedit, notepad++, boa contructor) will color
the remainder of the document as a quote until I close it. I would say
keep it that way, but maybe I'm only saying that since I'm so used to
this behavior.
 
L

Lie

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

Bruno Desthuilliers

(e-mail address removed) 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.
 
R

riquito

(e-mail address removed) a écrit :



The RightThing(tm), that is:


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
 
H

Hendrik van Rooyen

MartinRinehart said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,166
Latest member
DollyBff32
Top