Re: Add syntax highlighting to own command
- To: mathgroup at smc.vnet.net
- Subject: [mg101630] Re: Add syntax highlighting to own command
- From: earthnut at web.de (Bastian Erdnuess)
- Date: Fri, 10 Jul 2009 23:28:41 -0400 (EDT)
- References: <200907090600.CAA17547@smc.vnet.net> <h3766u$f9h$1@smc.vnet.net>
Leonid Shifrin <lshifr at gmail.com> 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 it. > 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 Let[ { 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. Bastian
- References:
- Add syntax highlighting to own command
- From: earthnut@web.de (Bastian Erdnuess)
- Add syntax highlighting to own command