Sublime Forum

API Suggestions

#166

on_pre_build / on_post_build

This would, for instance, allow running eligibility test before a build starts. One of the most frequent support requests for my packages is about compilers not being in the user’s PATH. An example for on_post_build would be asking the user whether he wants to open a successfully transpiled document in the editor.

1 Like

#167

I just read this whole thread and couldn’t find this suggestion, but it’s a large thread so forgive me if I missed it.

Find Previous Command

This would simply add the API to be able to find the previous occurrence of a pattern.
I would suggest adding it as a flag to the already existing API. Something like sublime.REVERSE or similar.

This feature has been requested before:

0 Likes

#168

Way to update the Quick Panel items

I want to perform some work in background and update quick panel list items along the way
Right now I can only take user input, make full list and show it

0 Likes

#169

Minihtml is being used to create the interface for debuggers, see: https://github.com/daveleroy/sublime_db
is it possible to get some relative CSS units? So these interfaces can resize when sublime’s window resizes

0 Likes

#170

This would be useful. I already have to replace some of mine with ${x} just so it can be replaced properly later.

0 Likes

#171

Glad to see another XEDITer here :slight_smile:

0 Likes

#172

##Request to document Fold status of a region and list of folded regions
Importance: medium
Motivation: Being able to detect if a region is folded or not would allow selective processing.

Proposed solution:

Document the two view module functions view.is_folded(region) and view.folded_regions()

0 Likes

#173
More sorting methods
Importance: Minor

1 Like

#174

API functions to do that already exist, although they’re not currently officially documented (with all of the usual warnings that sort of thing entails). As such the request might better be made to promote them to being official.

2 Likes

#175

Okay Thanks.

0 Likes

#176

This is pretty much implemented now.

0 Likes

split this topic #178

3 posts were split to a new topic: What’s the meaning of using a position when calling view.meta_info?

0 Likes

#181

Create a new tab, use Set Syntax: C, then open the console and enter view.meta_info("shellVariables", 0). The result is the C shellVariables, which gives you the comment characters for that language:

[
{'name': 'TM_COMMENT_END_2', 'value': '*/'}, 
{'name': 'TM_COMMENT_START', 'value': '// '}, 
{'name': 'TM_COMMENT_START_2', 'value': '/*'}
]

Now use Set Syntax: Python and re-run the command in the console, and it returns the Python shellVariables instead:

[
{'name': 'TM_COMMENT_START', 'value': '# '}, 
{'name': 'TM_LINE_TERMINATOR', 'value': ':'}
]

For bonus points, use Set Syntax: HTML and paste this:

<script type="text/javascript"> var x=12; </script>

When you run it with a position of 0, you get the HTML variables, because that’s the syntax at that position:

[ 
{'name': 'TM_COMMENT_END', 'value': ' -->'}, 
{'name': 'TM_COMMENT_START', 'value': '<!-- '}
]

Position 32 is inside the JavaScript portion of the buffer, so provifing that position gives you JavaScript information instead:

[
{'name': 'TM_COMMENT_END_2', 'value': '*/'}, 
{'name': 'TM_COMMENT_START', 'value': '// '}, 
{'name': 'TM_COMMENT_START_2', 'value': '/*'}
]
1 Like

#182

Thank you very much, your last example really helps to understand the thing a little bit better! So as I can see, basically meta_info is using the scope name to figure out what content from the tmPreferences to use, for instance, if we consider:

HTML\Comments.tmPreferences:

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
    <key>name</key>
    <string>Comments</string>
    <key>scope</key>
    <string>text.html</string>
    <key>settings</key>
    <dict>
        <key>shellVariables</key>
        <array>
            <dict>
                <key>name</key>
                <string>TM_COMMENT_START</string>
                <key>value</key>
                <string><![CDATA[<!-- ]]></string>
            </dict>
            <dict>
                <key>name</key>
                <string>TM_COMMENT_END</string>
                <key>value</key>
                <string><![CDATA[ -->]]></string>
            </dict>
        </array>
    </dict>
</dict>
</plist>

Javascript\Comments.tmPreferences:

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
    <key>name</key>
    <string>Comments</string>
    <key>scope</key>
    <string>source.js, source.json</string>
    <key>settings</key>
    <dict>
        <key>shellVariables</key>
        <array>
            <dict>
                <key>name</key>
                <string>TM_COMMENT_START</string>
                <key>value</key>
                <string>// </string>
            </dict>
            <dict>
                <key>name</key>
                <string>TM_COMMENT_START_2</string>
                <key>value</key>
                <string>/*</string>
            </dict>
            <dict>
                <key>name</key>
                <string>TM_COMMENT_END_2</string>
                <key>value</key>
                <string>*/</string>
            </dict>
        </array>
    </dict>
</dict>
</plist>

In your example at position 32 you’ll get 'text.html.basic source.js.embedded.html source.js storage.type.js ' as scope_name, source.js appears there and that’s why it’s using the javascript shellVariables fragment.

Now, here’s another question, in a language like c++, would it be possible to have scope_names different than the ones living in C++\Comments (C++).tmPreferences (<string>source.c, source.c++, source.objc, source.objc++</string>)?

0 Likes

#183

Not sure I understand your question; you can use whatever scope you want, that’s why you specify it by scope. For example, if you create a file named Sample.tmPreferences in your User package:

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
    <key>scope</key>
    <string>source.python string.quoted</string>
    <key>settings</key>
    <dict>
        <key>shellVariables</key>
        <array>
            <dict>
                <key>name</key>
                <string>TM_COMMENT_START</string>
                <key>value</key>
                <string>### </string>
            </dict>
        </array>
    </dict>
</dict>
</plist>

Now when you use the comment key binding in Python, you end up commenting the line with ### if the cursor is inside of a string when you press the key, instead of the standard #.

In any case, this is really diverging away from API suggestions so you should probably take it to another thread (perhaps @wbond or @jbrooksuk can split this off directly?)

0 Likes

#184

You’re right… nah, no worries, I didn’t want to go offtopic any longer here :wink: . Plus, my question has become really clear and solved, tyvm once again!

0 Likes

#185

this was indeed helpful i was just missing the dict part and that is why i just got stuck. Python is no easy thing

0 Likes

#186

I just was looking for such type of information and now I found it here. Thank you very much for sharing it with all of us. I hope it will help me now as well as in future.

0 Likes

#187

if you give any access then you press ctrl+P.

0 Likes

#190

Any change on disk about a file/folder is created/changes/reloads/gets deleted, even if not opened. The current ugly hack is to recurse the folder till eternity..
.

0 Likes