MathGroup Archive 2009

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

Search the Archive

Re: Add syntax highlighting to own command

  • To: mathgroup at
  • Subject: [mg101630] Re: Add syntax highlighting to own command
  • From: earthnut at (Bastian Erdnuess)
  • Date: Fri, 10 Jul 2009 23:28:41 -0400 (EDT)
  • References: <> <h3766u$f9h$>

Leonid Shifrin <lshifr at> wrote:

> While I won't be able to authoritatively answer most of  your questions,
> I would not place your function into a System` context. What
> I would do is to place your function into a separate package with its
> own context, and make that package autoloadable. I am not a big expert
> on this, I am pretty sure you will get great advice from other people here.

It's probably a good idea to make a MyToolBox` context and put things
like that in there.  "Autoload Package" was a good key word, with this I
think I can figure out how to do what I want to do.

> As for the highlighting, I would also very much like to learn if this can be
> extended to user-defined functions.

Probably, a Mathematica developer can tell how Mathematica handles
syntax highlighting internally and if there is any kind of interface to

> Regarding your code, I think it is a very clever piece. I don't know why
> you would want to improve it - it seems quite a piece of art to me.

I'm glad you like it.  I changed the ReplaceAll (/.) to a Replace.  It
seems that it doesn't do so, but i fear the ReplaceAll could mess
something up in a call like

      a = { "A", "B", "C" },
      b = { "X", "Y", "Z" }
    Print[ "done" ];

> I was first somewhat surprised that it works.

I'm still.  I tried different things and I have actually no clue why
only exactly this one was working.

> I think it very cleverly uses the
> fact that  RuleDelayed, being a scoping construct, does not respect the
> possible colliding variables in inner scoping constructs (like With here)
> and in this respect is different from other scoping constructs such as
> Module, Block, With, or Function (thus your substitution works as intended,
> instead of internal variables simply being renamed).

Interesting.  I need to try to understand how RuleDelayed works.
Probably, I can then try to understand my own code, too.


  • Prev by Date: Re: Help with FindRoot
  • Next by Date: Re: Symbolic summation
  • Previous by thread: Re: Add syntax highlighting to own command
  • Next by thread: Re: Add syntax highlighting to own command