Home Download Buy Blog Forum Support

API method to expand Build System Variables

API method to expand Build System Variables

Postby bizoo on Mon Mar 04, 2013 11:11 am

I like to have an API method that expand the Build System Variables what happened when used in the "cmd" tag in the .sublime-build:
Code: Select all
$file_path               The directory of the current file, e. g., C:\Files.
$file                   The full path to the current file, e. g., C:\Files\Chapter1.txt.
$file_name               The name portion of the current file, e. g., Chapter1.txt.
$file_extension           The extension portion of the current file, e. g., txt.
$file_base_name           The name only portion of the current file, e. g., Document.
$packages               The full path to the Packages folder.
$project               The full path to the current project file.
$project_path           The directory of the current project file.
$project_name           The name portion of the current project file.
$project_extension       The extension portion of the current project file.
$project_base_name       The name only portion of the current project file.

A method in the View class look the right place to do this.
Some plugins use some kind of "cmd" too and need this kind of vars.
If the internal method is exposed, we don't need to do it by ourself for each plugins.
bizoo
 
Posts: 934
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: API method to expand Build System Variables

Postby wuub on Mon Mar 04, 2013 11:20 am

SublimeREPL via Package Control & SublimePTY dev/pre-alpha. Donations are appreciated, but not required :) Twitter: @wuub
wuub
 
Posts: 221
Joined: Wed Aug 10, 2011 8:16 am
Location: Poland

Re: API method to expand Build System Variables

Postby bizoo on Mon Mar 04, 2013 12:37 pm

:o
Whoa, never thought to do it this way. Very clever.
But very very hacky way to do it, so please jon give us an API method.
bizoo
 
Posts: 934
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: API method to expand Build System Variables

Postby bizoo on Mon Oct 07, 2013 9:00 am

bump.
Please, give us this API.
I've more and more plugins where I need it.
bizoo
 
Posts: 934
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: API method to expand Build System Variables

Postby bizoo on Fri Apr 04, 2014 8:43 am

As I have no more hope to see this feature coming, does anyone have an alternate solution or an implementation of this request ?
I want to execute an external program with the current file in parameters, but "exec" command doesn't expand variables.
bizoo
 
Posts: 934
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: API method to expand Build System Variables

Postby FichteFoll on Mon Feb 02, 2015 12:30 am

To be fair, you can get all of the above information from other API functions and some path math, so writing a small function that replaces all these substrings shouldn't be the hardest task.

It maybe wasn't the case back when the thread was created, but it is now.
FichteFoll
 
Posts: 565
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: API method to expand Build System Variables

Postby bizoo on Mon Feb 02, 2015 9:10 am

FichteFoll wrote:To be fair, you can get all of the above information from other API functions and some path math, so writing a small function that replaces all these substrings shouldn't be the hardest task.

You're correct, it is what I've done.

Now if 100 plugins need this feature, you've to rewrite/duplicate 100 times this function.
As the code to do this already exists in ST, it's probably a matter of minutes to add it to the API (and make me happy).
bizoo
 
Posts: 934
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: API method to expand Build System Variables

Postby FichteFoll on Mon Feb 02, 2015 10:53 am

When guillermo and I get around with patching up the unofficial docs to current standards we'd like to refactor the sublime_lib module from AAAPackageDev and make it available as a dependency in package control (thanks to its updates in 3.0.0). I'm sure this would be a nice addition to it.
FichteFoll
 
Posts: 565
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: No registered users and 9 guests