Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting global InputAutoReplacements

46 views
Skip to first unread message

Leo Alekseyev

unread,
Nov 20, 2009, 6:40:32 AM11/20/09
to
Dear Mathgroup,

I am trying to create a few custom InputAutoReplacements that would
apply to all input cells by default. I am trying to follow John
Fultz's instructions on
http://forums.wolfram.com/mathgroup/archive/2000/Oct/msg00157.html,
but running into difficulties: the style for the input cell seems to
be defined by Core.nb, and when I select the "local definitions for
style "Input"" cell and go to the options inspector, the
InputAutoReplacements option is specified as {ParentsList}; I can't
figure out where the usual InputAutoReplacements rules (e.g. -> goes
to \[Rule]) are stored so that I could append my own. I'd appreciate
any help with this!

Thanks,
--Leo

John Fultz

unread,
Nov 21, 2009, 3:42:17 AM11/21/09
to

This particular option isn't as easy to figure out or set as I'd like. Two
clarifications...

ParentList represents the ones which have been inherited from the notebook level
(which, in this case, actually refers to replacements that are set globally
throughout the system).

And the settings for "->", ":>", etc., are actually set in the StandardForm
style, not the Input style.

So, to add the "abc"->"123' replacement, you'd add a StandardForm style cell to
your stylesheet as follows...

Cell[StyleData["StandardForm"],
InputAutoReplacements->{
"abc" -> "123", "->" -> "\[Rule]", ":>" -> "\[RuleDelayed]", "<=" ->
"\[LessEqual]", ">=" -> "\[GreaterEqual]", "!=" -> "\[NotEqual]",
"==" -> "\[Equal]", ParentList}]


Sincerely,

John Fultz
jfu...@wolfram.com
User Interface Group
Wolfram Research, Inc.


Leo Alekseyev

unread,
Nov 23, 2009, 6:50:55 AM11/23/09
to
Thanks for the clarification. Originally I assumed your cell had to
replace the original one exactly where it appeared in the Core.nb
template -- which made the procedure needlessly complicated.

On Sun, Nov 22, 2009 at 6:40 PM, John Fultz <jfu...@wolfram.com> wrote:
> Format->Edit Stylesheet...
>
> Paste the cell I included. For a single notebook, you're done.
>
> Click Install in the toolbar. Choose a filename and install it. That name will
> now show up in the Stylesheets menu. Choose that stylesheet and it works.
>
> Or, choose the name of an existing stylesheet (like Default.nb). This will,
> unfortunately require a restart of M-- to see it, but now it works for all
> notebooks using that stylesheet.
>
> These are much better than editing a stylesheet inside of the installation
> directory, a procedure I don't encourage.


>
> Sincerely,
>
> John Fultz
> jfu...@wolfram.com
> User Interface Group
> Wolfram Research, Inc.
>
>

> On Sun, 22 Nov 2009 06:23:16 -0500, Leo Alekseyev wrote:
>> John, much thanks for the quick reply. Allow me to elaborate, for the
>> benefits of whoever might be interested in setting up replacement
>> aliases (I think they are very handy!)
>>
>> First, back up the existing Core.nb.
>> Then, open the options inspector, select "Core.nb" from the first
>> drop-down box, and under Notebook Options -> File Options select
>> "Editable" and Saveable" (in that order). Then in Core.nb expand
>> the last item, "Styles for Mathematica System-specific Elements" and
>> then expand "FormatType Styles". Find local definitions for
>> StandardForm .
>>
>> At this point you could try fiddling with InputAutoReplacements via
>> the options inspector , but this results in an error (at least for
>> me). So what you need to do is open Core.nb in a text editor, search
>> for the line Cell[StyleData["StandardForm"], and add custom
>> replacement (as per John's instruction). Alternatively, select the
>> cell, go to Edit->Copy As cell expression, paste it in a text editor
>> somewhere, make the necessary modifications, paste the cell expression
>> back (interpreting it) and delete the old cell. You are done!
>>
>> I hope this procedure is made easier in future versions :)


>>
>>
>>> This particular option isn't as easy to figure out or set as I'd like.
>>> Two
>>> clarifications...
>>>
>>> ParentList represents the ones which have been inherited from the
>>> notebook level
>>> (which, in this case, actually refers to replacements that are set
>>> globally
>>> throughout the system).
>>>
>>> And the settings for "->", ":>", etc., are actually set in the
>>> StandardForm
>>> style, not the Input style.
>>>
>>> So, to add the "abc"->"123' replacement, you'd add a StandardForm style
>>> cell to
>>> your stylesheet as follows...
>>>
>>> Cell[StyleData["StandardForm"],
>>> InputAutoReplacements->{
>>> "abc" -> "123", "->" -> "\[Rule]", ":>" -> "\[RuleDelayed]", "<=" ->

>>> "\[LessEqual]", ">=" -> "\[GreaterEqual]", "!=" -> "\[NotEqual]"=

John Fultz

unread,
Nov 23, 2009, 6:59:21 AM11/23/09
to
Format->Edit Stylesheet...

>> "\[LessEqual]", ">=" -> "\[GreaterEqual]", "!=" -> "\[NotEqual]",

Leo Alekseyev

unread,
Nov 23, 2009, 7:10:38 AM11/23/09
to
John, much thanks for the quick reply. Allow me to elaborate, for the
benefits of whoever might be interested in setting up replacement
aliases (I think they are very handy!)

First, back up the existing Core.nb.
Then, open the options inspector, select "Core.nb" from the first
drop-down box, and under Notebook Options -> File Options select
"Editable" and Saveable" (in that order). Then in Core.nb expand
the last item, "Styles for Mathematica System-specific Elements" and
then expand "FormatType Styles". Find local definitions for
StandardForm .

At this point you could try fiddling with InputAutoReplacements via
the options inspector , but this results in an error (at least for
me). So what you need to do is open Core.nb in a text editor, search
for the line Cell[StyleData["StandardForm"], and add custom
replacement (as per John's instruction). Alternatively, select the
cell, go to Edit->Copy As cell expression, paste it in a text editor
somewhere, make the necessary modifications, paste the cell expression
back (interpreting it) and delete the old cell. You are done!

I hope this procedure is made easier in future versions :)

> This particular option isn't as easy to figure out or set as I'd like. =
Two
> clarifications...
>
> ParentList represents the ones which have been inherited from the noteboo=
k level
> (which, in this case, actually refers to replacements that are set global=
ly
> throughout the system).
>
> And the settings for "->", ":>", etc., are actually set in the StandardFo=


rm
> style, not the Input style.
>

> So, to add the "abc"->"123' replacement, you'd add a StandardForm style c=

mkr

unread,
Nov 28, 2009, 1:07:51 AM11/28/09
to
On Nov 23, 4:10 am, Leo Alekseyev <dnqu...@gmail.com> wrote:
> John, much thanks for the quick reply. Allow me to elaborate, for the
> benefits of whoever might be interested in setting up replacement
> aliases (I think they are very handy!)
>
> First, back up the existing Core.nb.
> Then, open the options inspector, select "Core.nb" from the first
> drop-down box, and under Notebook Options -> File Options select
> "Editable" and Saveable" (in that order). Then in Core.nb expand
> the last item, "Styles for Mathematica System-specific Elements" and
> then expand "FormatType Styles". Find local definitions for
> StandardForm .
>
> At this point you could try fiddling with InputAutoReplacements via
> the options inspector , but this results in an error (at least for
> me). So what you need to do is open Core.nb in a text editor, search
> for the line Cell[StyleData["StandardForm"], and add custom
> replacement (as per John's instruction). Alternatively, select the
> cell, go to Edit->Copy As cell expression, paste it in a text editor
> somewhere, make the necessary modifications, paste the cell expression
> back (interpreting it) and delete the old cell. You are done!
>
> I hope this procedure is made easier in future versions :)
>
>
>
> > This particular option isn't as easy to figure out or set as I'd like.
> Two
> > clarifications...
>
> > ParentList represents the ones which have been inherited from the notebook level
> > (which, in this case, actually refers to replacements that are set globally
> > throughout the system).
>
> > And the settings for "->", ":>", etc., are actually set in the StandardForm

> > style, not the Input style.
>
> > So, to add the "abc"->"123' replacement, you'd add a StandardForm style cell to

> > your stylesheet as follows...
>
> > Cell[StyleData["StandardForm"],
> > InputAutoReplacements->{
> > "abc" -> "123", "->" -> "\[Rule]", ":>" -> "\[RuleDelayed]", "<=" ->
> > "\[LessEqual]", ">=" -> "\[GreaterEqual]", "!=" -> "\[NotEqual]",
> > "==" -> "\[Equal]", ParentList}]
>
> > Sincerely,
>
> > John Fultz
> > jfu...@wolfram.com
> > User Interface Group
> > Wolfram Research, Inc.


I am new to OSX, and purchased TextExpander in order to handle text
substitution / auto expansion for Mathematica; unfortunately there
appears to be some sort of conflict between Mathematica's keystroke
filtering and TextExpander's, such that TE does not work for Mathematica
(searching this group revealed that it broke with v6). Under Windows,
Autohotkey has been very useful in allowing me to expand a few
keystrokes into medium to large size boilerplate code blocks.
Consequently, I am looking around for other ways to do custom
substitutions, and it looks like modifying KeyEventTranslations.tr is
another option.

A bit of searching both at the WRI site and on this group revealed
surprising little guidance on either InputAutoReplacements or
KeyEventTranslations. I find text expansion to be quite nice in Mathematica
programming (previously using Autohotkey on Windows), allowing a few
keystrokes to automatically expand into medium to large blocks of
boilerplate code, and I would imagine that making such a facility more
obvious/usable would be widely appreciated by the Mathematica user community.

Does anyone know of any decent guidance or resources for customizing
InputAutoReplacements and/or KeyEventTranslations?

Thanks,

Miles

David Park

unread,
Nov 29, 2009, 5:11:39 AM11/29/09
to
If you are talking about "medium to large size boilerplate code blocks" I
don't understand why you don't write them as definitions in a "Routines"
section in your notebook, or even put them into a package with
documentation. To put them into Mathematica system preferences, or notebook
preferences or a style sheet, or a KeyEventTranslation file just doesn't
seem like a convenient place. To do it that way makes your work much less
accessible to others, and even for yourself it makes it more difficult to
document, modify and expand it.

It just seems to me that to program with hot keys instead of definitions,
usage messages (and command completion for quick entry) is throwing away
many of the advantages of Mathematica. In my humble opinion.


David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/

0 new messages