Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5580 > unrolled thread

Suppressing quotes around strings in Input style.

Started bymmausr <opngid@gmail.com>
First post2011-10-10 09:56 +0000
Last post2011-10-16 11:14 +0000
Articles 4 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Suppressing quotes around strings in Input style. mmausr <opngid@gmail.com> - 2011-10-10 09:56 +0000
    Re: Suppressing quotes around strings in Input style. "Chris Degnen" <degnen@cwgsy.net> - 2011-10-11 08:26 +0000
    Re: Suppressing quotes around strings in Input style. "andre.robin3" <andre.robin3@wanadoo.fr> - 2011-10-11 08:26 +0000
      Re: Suppressing quotes around strings in Input style. mmausr <opngid@gmail.com> - 2011-10-16 11:14 +0000

#5580 — Suppressing quotes around strings in Input style.

Frommmausr <opngid@gmail.com>
Date2011-10-10 09:56 +0000
SubjectSuppressing quotes around strings in Input style.
Message-ID<j6uffk$ggg$1@smc.vnet.net>
Mathematica suppresses the quotes surrounding a string by default in
the Output style.  Quotes surrounding strings in the Input style can
be suppressed as well by setting the ShowStringCharacters option to
False in the notebook's style sheet for the Input style.

This approach is not entirely satisfactory, however, for the following
reasons.  (i)  Entering a double quote in an Input style cell after
setting the ShowStringCharacters flag to False will register an error
in the front end.  (ii)  It would be helpful to retain the color
change that is used for strings (gray by default) while the double
quotes are suppressed, but this does not appear to be possible with
the ShowStringCharacters flag set to False.  In fact, manually
attempting to change the color of a string with the
ShowStringCharacters flag set to false will also register an error in
the front end.  (iii) Inserting a file path does does not work
properly because of the explicit double quotes that surround the file
path string; this appears to be a special case of (i).

What would be useful is to have a special character that is invisible
that functionally acts like the double quote.  Special characters
already exist as invisible equivalents for the @ symbol for function
application, the comma for argument separation, and the times operator
for multiplication.  These invisible equivalents are respectively: \
[InvisibleApplication] \[InvisibleComma] \[InvisibleTimes].

It appears that the special character \:f3b5 somewhat plays the role
of a non-existent \[InvisibleDoubleQuote] character, but its precise
behavior depends on whether or not the ShowStringCharacters flag is
set.  For example, if the flag is True, then a single \:f3b5 is
invisible, but entering a second (matching) \:f3b5 will make the pair
of double quotes visible.

Defining the following syntax transformation in
KeyEventTransformations.tr creates a pair of invisible double quotes:

Item[KeyEvent["`",Modifiers->{Control}],
FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],"\:f3b5\
[SelectionPlaceholder]
\:f3b5"],FrontEndToken["MovePreviousPlaceHolder"]}]]

Perhaps the color change could be defined in here, but I'm not sure
how.  I'd also like to have the ability to insert double quotes for
certain situations into a notebook with the ShowStringCharacters flag
set to False, not just to insert file paths (that's easy to clean up
by just deleting the surrounding quotes and copying the result between
two \:f3b5 characters) but for strings that represent text messages.

My primary interest in being able to remove quotes around certain
strings is because I'd prefer to use strings as field names for
structs in an OO package that I'm developing instead of using
Protected symbols -- much for the same reason that many built-in
functions are using strings for option names instead of symbols in
later versions of Mathematica.

Any thoughts?

[toc] | [next] | [standalone]


#5587

From"Chris Degnen" <degnen@cwgsy.net>
Date2011-10-11 08:26 +0000
Message-ID<j70uj4$ru$1@smc.vnet.net>
In reply to#5580
mmausr wrote:
> . . .
>
> My primary interest in being able to remove quotes around certain
> strings is because I'd prefer to use strings as field names for
> structs in an OO package ...
> 
> Any thoughts?


Reminds me of this post:

http://forums.wolfram.com/mathgroup/archive/2010/Jun/msg00148.html


Cell[OutputFormData@expr] removes quotes.


[toc] | [prev] | [next] | [standalone]


#5588

From"andre.robin3" <andre.robin3@wanadoo.fr>
Date2011-10-11 08:26 +0000
Message-ID<j70uk3$s3$1@smc.vnet.net>
In reply to#5580
Concerning the colors, you may use :
$PrePrint = (# /. x_String :> Style[x, Red] &)

?


"mmausr" <opngid@gmail.com> a écrit dans le message de news: 
j6uffk$ggg$1@smc.vnet.net...
> Mathematica suppresses the quotes surrounding a string by default in
> the Output style.  Quotes surrounding strings in the Input style can
> be suppressed as well by setting the ShowStringCharacters option to
> False in the notebook's style sheet for the Input style.
>
> This approach is not entirely satisfactory, however, for the following
> reasons.  (i)  Entering a double quote in an Input style cell after
> setting the ShowStringCharacters flag to False will register an error
> in the front end.  (ii)  It would be helpful to retain the color
> change that is used for strings (gray by default) while the double
> quotes are suppressed, but this does not appear to be possible with
> the ShowStringCharacters flag set to False.  In fact, manually
> attempting to change the color of a string with the
> ShowStringCharacters flag set to false will also register an error in
> the front end.  (iii) Inserting a file path does does not work
> properly because of the explicit double quotes that surround the file
> path string; this appears to be a special case of (i).
>
> What would be useful is to have a special character that is invisible
> that functionally acts like the double quote.  Special characters
> already exist as invisible equivalents for the @ symbol for function
> application, the comma for argument separation, and the times operator
> for multiplication.  These invisible equivalents are respectively: \
> [InvisibleApplication] \[InvisibleComma] \[InvisibleTimes].
>
> It appears that the special character \:f3b5 somewhat plays the role
> of a non-existent \[InvisibleDoubleQuote] character, but its precise
> behavior depends on whether or not the ShowStringCharacters flag is
> set.  For example, if the flag is True, then a single \:f3b5 is
> invisible, but entering a second (matching) \:f3b5 will make the pair
> of double quotes visible.
>
> Defining the following syntax transformation in
> KeyEventTransformations.tr creates a pair of invisible double quotes:
>
> Item[KeyEvent["`",Modifiers->{Control}],
> FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],"\:f3b5\
> [SelectionPlaceholder]
> \:f3b5"],FrontEndToken["MovePreviousPlaceHolder"]}]]
>
> Perhaps the color change could be defined in here, but I'm not sure
> how.  I'd also like to have the ability to insert double quotes for
> certain situations into a notebook with the ShowStringCharacters flag
> set to False, not just to insert file paths (that's easy to clean up
> by just deleting the surrounding quotes and copying the result between
> two \:f3b5 characters) but for strings that represent text messages.
>
> My primary interest in being able to remove quotes around certain
> strings is because I'd prefer to use strings as field names for
> structs in an OO package that I'm developing instead of using
> Protected symbols -- much for the same reason that many built-in
> functions are using strings for option names instead of symbols in
> later versions of Mathematica.
>
> Any thoughts?
>
> 


[toc] | [prev] | [next] | [standalone]


#5676

Frommmausr <opngid@gmail.com>
Date2011-10-16 11:14 +0000
Message-ID<j7eea3$ejl$1@smc.vnet.net>
In reply to#5588
On Oct 11, 4:26 am, "andre.robin3" <andre.rob...@wanadoo.fr> wrote:
> Concerning the colors, you may use :
> $PrePrint = (# /. x_String :> Style[x, Red] &)
>
> ?
>
> "mmausr" <opn...@gmail.com> a crit dans le message de news:
> j6uffk$gg...@smc.vnet.net...
>
>
>
>
>
>
>
> > Mathematica suppresses the quotes surrounding a string by default in
> > the Output style.  Quotes surrounding strings in the Input style can
> > be suppressed as well by setting the ShowStringCharacters option to
> > False in the notebook's style sheet for the Input style.
>
> > This approach is not entirely satisfactory, however, for the following
> > reasons.  (i)  Entering a double quote in an Input style cell after
> > setting the ShowStringCharacters flag to False will register an error
> > in the front end.  (ii)  It would be helpful to retain the color
> > change that is used for strings (gray by default) while the double
> > quotes are suppressed, but this does not appear to be possible with
> > the ShowStringCharacters flag set to False.  In fact, manually
> > attempting to change the color of a string with the
> > ShowStringCharacters flag set to false will also register an error in
> > the front end.  (iii) Inserting a file path does does not work
> > properly because of the explicit double quotes that surround the file
> > path string; this appears to be a special case of (i).
>
> > What would be useful is to have a special character that is invisible
> > that functionally acts like the double quote.  Special characters
> > already exist as invisible equivalents for the @ symbol for function
> > application, the comma for argument separation, and the times operator
> > for multiplication.  These invisible equivalents are respectively: \
> > [InvisibleApplication] \[InvisibleComma] \[InvisibleTimes].
>
> > It appears that the special character \:f3b5 somewhat plays the role
> > of a non-existent \[InvisibleDoubleQuote] character, but its precise
> > behavior depends on whether or not the ShowStringCharacters flag is
> > set.  For example, if the flag is True, then a single \:f3b5 is
> > invisible, but entering a second (matching) \:f3b5 will make the pair
> > of double quotes visible.
>
> > Defining the following syntax transformation in
> > KeyEventTransformations.tr creates a pair of invisible double quotes:
>
> > Item[KeyEvent["`",Modifiers->{Control}],
> > FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],"\:f3b=
5\
> > [SelectionPlaceholder]
> > \:f3b5"],FrontEndToken["MovePreviousPlaceHolder"]}]]
>
> > Perhaps the color change could be defined in here, but I'm not sure
> > how.  I'd also like to have the ability to insert double quotes for
> > certain situations into a notebook with the ShowStringCharacters flag
> > set to False, not just to insert file paths (that's easy to clean up
> > by just deleting the surrounding quotes and copying the result between
> > two \:f3b5 characters) but for strings that represent text messages.
>
> > My primary interest in being able to remove quotes around certain
> > strings is because I'd prefer to use strings as field names for
> > structs in an OO package that I'm developing instead of using
> > Protected symbols -- much for the same reason that many built-in
> > functions are using strings for option names instead of symbols in
> > later versions of Mathematica.
>
> > Any thoughts?

Thanks for the suggestions ... my current approach (in case this helps
anyone else) is just to use an inline text cell in the middle of the
expression (using the Ctrl-9 keyboard shortcut).  If I need the text
cell to be interpreted as a string by Mathematica, then I evaluate in
place HideQuotes["myString"], where

HideQuotes[string_] := Interpretation[ExpressionCell[string,
ShowStringCharacters -> False], string]

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web