Possible to get value of environment variable in macro?

Is it possible to access arbitrary environment variables within macros? I can’t seem to find anything within the application help on the subject.

Seems like it would be a logical addition to the interpolation capability (unless I have just missed it and it is already there).

Yes; Cc["@activestate.com/koOs;1"].getService().getenv("PATH") for example. If you’re using Python, just use the normal os.environ.

Interpolation tends to be used for run commands and things like that, not macros? It seems to not support environment variables yet, though. Do you have an example of where you would want to interpolate in environment variables outside the context of a run command? Note that running echo $PATH works here (on Linux), since it gets passed to the shell anyway. On Windows it would be echo %PATH% as usual.

@mook: I have a couple language-specific macros written in JS that wrap the current editor selection with a date-stamped comment, and am using interpolation to generate the date-stamp. I would like to use an environment variable like $USER to include the username with the date-stamp. I can envision similar usage in templates, which also support interpolation (although I haven’t played much with interpolation there).

Mook gave the way to get the Komodo environment variables (which should be fine for the USER case, but just note it also contains Komodo modifications). Generally you’ll want to be using the special koIUserEnviron, which is the original user environment plus any changes made to the Environment preferences:


@toddw: Thanks. My next stupid question is going to be what are “Cc” and “Ci” within the context of the examples you and @mook offered?

They are shortcut aliases for:

var Ci = Components.interfaces;
var Cc = Components.classes;

Ah, thanks; that helps.