Ron DeVera | 25 Apr 2012 08:30
Gravatar

[SVN] Can't read `$TM_PROJECT_DIRECTORY` in TM2 bundle

Hey there,

I'm having trouble reading `$TM_PROJECT_DIRECTORY` from within another shell
variable. I have a TM2 bundle whose settings contain this:

    {	shellVariables = (
    		{	name = 'TM_TEST_A';
    			value = 'test A: $TM_DIRECTORY';
    		},
    		{	name = 'TM_TEST_B';
    			value = 'test B: $TM_PROJECT_DIRECTORY';
    		}
    	);
    }

Elsewhere in the bundle (in a `Support/` file), I have Ruby like this:

    puts "ENV['TM_TEST_A'] : #{(ENV['TM_TEST_A']).inspect}"
    puts "ENV['TM_TEST_B'] : #{(ENV['TM_TEST_B']).inspect}"
    puts "ENV['TM_PROJECT_DIRECTORY'] :
#{(ENV['TM_PROJECT_DIRECTORY']).inspect}"

When this runs, the `ENV['TM_TEST_A']` and `ENV['TM_PROJECT_DIRECTORY']` output
are correct, but the `ENV['TM_TEST_B']` output fails to read
`$TM_PROJECT_DIRECTORY` from the environment:

    ENV['TM_TEST_A'] : "test A: /path/to/my.tmbundle/Support"
    ENV['TM_TEST_B'] : "test B: "
    ENV['TM_PROJECT_DIRECTORY'] : "/path/to/my.tmbundle"

(Continue reading)

George McGinley Smith | 26 Apr 2012 14:01
Picon
Gravatar

[SVN] Re: Can't read `$TM_PROJECT_DIRECTORY` in TM2 bundle


Ron DeVera wrote:
> 
> I'm having trouble reading `$TM_PROJECT_DIRECTORY` from within another
> shell
> variable. I have a TM2 bundle whose settings contain this:
> 
> ...
> 
>     # Source: https://gist.github.com/1478685
>     projectDirectory = "$CWD"
> 
> This didn't seem to affect `$TM_PROJECT_DIRECTORY`, which remains blank.
> 
> 

Looks like TM2 uses projectDirectory instead of TM_PROJECT_DIRECTORY. You
could either add 

TM_PROJECT_DIRECTORY = "$projectDirectory"

after you initial

projectDirectory = "$CWD"

Which would enable backwards compatibility, or update your scripts to use
the $projectDirectory.
--

-- 
View this message in context: http://old.nabble.com/Can%27t-read-%60%24TM_PROJECT_DIRECTORY%60-in-TM2-bundle-tp33744575p33752172.html
Sent from the textmate-dev mailing list archive at Nabble.com.
(Continue reading)

Ron DeVera | 30 Apr 2012 03:47
Gravatar

[SVN] Re: Can't read `$TM_PROJECT_DIRECTORY` in TM2 bundle

On Thu, Apr 26, 2012 at 5:01 AM, George McGinley Smith
<george@...> wrote:
> Looks like TM2 uses projectDirectory instead of TM_PROJECT_DIRECTORY. You
> could either add
>
> TM_PROJECT_DIRECTORY = "$projectDirectory"
>
> after you initial
>
> projectDirectory = "$CWD"
>
> Which would enable backwards compatibility, or update your scripts to use
> the $projectDirectory.

Reading `$projectDirectory` directly in my bundle didn't seem to work,
but setting `TM_PROJECT_DIRECTORY = "$projectDirectory"` in
`.tm_properties` did the trick. Thanks!

Ron
Allan Odgaard | 28 Apr 2012 13:50
Favicon

[SVN] Re: Can't read `$TM_PROJECT_DIRECTORY` in TM2 bundle

On 25/04/2012, at 13.30, Ron DeVera wrote:

> I'm having trouble reading `$TM_PROJECT_DIRECTORY` from within another shell
> variable. I have a TM2 bundle whose settings contain this: […]

The TM_PROJECT_DIRECTORY is set after the bundle setting variables are set.

Why do you want to introduce a variable that is effectively an alias for TM_PROJECT_DIRECTORY? I.e.
wouldn’t it be more clear, and not clutter the global namespace, simply to use TM_PROJECT_DIRECTORY in
your script?
Ron DeVera | 30 Apr 2012 03:47
Gravatar

[SVN] Re: Can't read `$TM_PROJECT_DIRECTORY` in TM2 bundle

On Sat, Apr 28, 2012 at 4:50 AM, Allan Odgaard <mailinglist <at> textmate.org> wrote:
> The TM_PROJECT_DIRECTORY is set after the bundle setting variables are set.
>
> Why do you want to introduce a variable that is effectively an alias for TM_PROJECT_DIRECTORY? I.e.
wouldn’t it be more clear, and not clutter the global namespace, simply to use TM_PROJECT_DIRECTORY in
your script?

The bundle reads an environment variable `TM_OPTIONS_FILE` that other
users can point to a custom path, e.g., `~/.myconfig`,
`$TM_PROJECT_DIRECTORY/config/myconfig.yml`. The custom environment
variable is used not just as an alias, but as an optional part of a
path that can be either global or project-specific.

Cheers,
Ron
_______________________________________________
textmate-dev mailing list
textmate-dev <at> lists.macromates.com
http://lists.macromates.com/listinfo/textmate-dev
Allan Odgaard | 30 Apr 2012 05:05
Favicon

[SVN] Re: Can't read `$TM_PROJECT_DIRECTORY` in TM2 bundle

On 30/04/2012, at 08.47, Ron DeVera wrote:

> On Sat, Apr 28, 2012 at 4:50 AM, Allan Odgaard
<mailinglist@...> wrote:
>> […] Why do you want to introduce a variable that is effectively an alias for TM_PROJECT_DIRECTORY?
I.e. wouldn’t it be more clear, and not clutter the global namespace, simply to use
TM_PROJECT_DIRECTORY in your script?
> 
> The bundle reads an environment variable `TM_OPTIONS_FILE` that other
> users can point to a custom path, e.g., `~/.myconfig`,
> `$TM_PROJECT_DIRECTORY/config/myconfig.yml`. The custom environment
> variable is used not just as an alias, but as an optional part of a
> path that can be either global or project-specific.

OK, so users can _optionally_ set this TM_OPTIONS_FILE (in .tm_properties where TM_PROJECT_DIRECTORY
is available), right?

I.e. your bundle does not require it to be set (by your bundle).

Btw: It should preferably be TM_«bundle»_OPTIONS_FILE so to not conflict with variables used by other bundles.
Ron DeVera | 30 Apr 2012 08:22
Gravatar

[SVN] Re: Can't read `$TM_PROJECT_DIRECTORY` in TM2 bundle

On Sun, Apr 29, 2012 at 8:05 PM, Allan Odgaard <mailinglist <at> textmate.org> wrote:
> OK, so users can _optionally_ set this TM_OPTIONS_FILE (in .tm_properties where TM_PROJECT_DIRECTORY
is available), right?
>
> I.e. your bundle does not require it to be set (by your bundle).

Right, this environment variable is optional; the bundle has a default
value for this setting.

> Btw: It should preferably be TM_«bundle»_OPTIONS_FILE so to not conflict with variables used by other bundles.

Yup -- the actual environment variable's name is much longer, but I
shortened it here for discussion.

Cheers,
Ron
_______________________________________________
textmate-dev mailing list
textmate-dev <at> lists.macromates.com
http://lists.macromates.com/listinfo/textmate-dev

Gmane