Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Suppressing quotes around strings in Input style.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122143] Re: Suppressing quotes around strings in Input style.
  • From: mmausr <opngid at gmail.com>
  • Date: Sun, 16 Oct 2011 07:07:30 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j6uffk$ggg$1@smc.vnet.net> <j70uk3$s3$1@smc.vnet.net>

On Oct 11, 4:26 am, "andre.robin3" <andre.rob... at wanadoo.fr> wrote:
> Concerning the colors, you may use :
> $PrePrint = (# /. x_String :> Style[x, Red] &)
>
> ?
>
> "mmausr" <opn... at gmail.com> a crit dans le message de news:
> j6uffk$gg... at 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]



  • Prev by Date: Re: Constructing a huge graph
  • Next by Date: Limit of nested function
  • Previous by thread: Re: Suppressing quotes around strings in Input style.
  • Next by thread: Re: Fittings 2 sets of equations and 2 data sets with nonlinearmodelfit