Sublime Forum

API method to expand Build System Variables

#1

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:

$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.

2 Likes

Dev Build 3067
#2

+1
Getting them out with current API is really awkward
github.com/wuub/SublimeREPL/blo … em_hack.py
github.com/wuub/SublimeREPL/blo … lime-build

0 Likes

#3

:astonished:
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.

0 Likes

#4

bump.
Please, give us this API.
I’ve more and more plugins where I need it.

0 Likes

#5

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.

0 Likes

#6

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.

0 Likes

#7

[quote=“FichteFoll”]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.
[/quote]

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).

0 Likes

#8

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.

0 Likes