I know, I know. "What new-line state?", you ask. Well, let me show you:
append [] w: first new-line [hello] on
== [
hello
]
W is a now a word that creates a new-line when appended to a block.
You can turn it off, for example this way in Rebol 3:
append [] to word! w
== [hello]
But I have not found a good way to turn it on. Can you, Rebol guru?
Clarification: I am looking for some 'f such that:
append [] f to word! "hello"
has a new-line in it.
Seemingly the new-line state is assigned to the word based on whether the assigned value has a preceding new-line at the time of assignment (I'll ruminate on the correctness of that statement for a while).
This function reassigns the same value (should retain context) to the word with a new new-line state:
set-new-line: func [
'word [word!]
state [logic!]
][
set/any word first new-line reduce [get/any word] state
]
We can also test the new-line state of a given word:
has-new-line?: func [
'word [word!]
][
new-line? reduce [get/any word]
]
In use:
>> x: "Foo"
== "Foo"
>> has-new-line? x
== false
>> reduce [x]
== ["Foo"]
>> set-new-line x on
== "Foo"
>> has-new-line? x
== true
>> reduce [x]
== [
"Foo"
]
>> reduce [set-new-line x on set-new-line x off set-new-line x on]
== [
"Foo" "Foo"
"Foo"
]