Sublime Forum

run_command vs. internal API and the future of Sublime

#1

It’s quite hard to build sublime plugins with today’s API. E.g., if I want to make use of the “move_to” “brackets” functionality, I need to do a run_command. So, Sublime has API for things like find_by_class and substr() which take a buffer position as an argument, while other great pieces of functionality like bracket matching need to be accessed via run_command. The problem with run_command, however, is that it operates on all the cursors at once, and sometimes you don’t want that behavior.

So I guess what I am hoping for (some day) is a set of great functionality which is “cursor” independent, which takes a cursor as an argument, and is callable from commands. And then the commands that we know and love today (find matching bracket) could just be implemented in terms of these useful APIs.

Future of Sublime
I find myself wondering what is the state of Sublime development. Years ago I gave TextMate a try and was basically burned by the complete lack of development while the author did TextMate 2. When I found Sublime just recently it just seemed magical, but now a few weeks into it I am getting suspicious that the engineers are checked out. Is there any indication at all that this is still a product undergoing development? De they ever respond to questions or is it always the community that does that? Do we know where sublime is heading and can we impact it in any way with suggestions?

0 Likes

#2

Well after writing that little diatribe I was able to create a fairly nice piece of code to help me do what I want. It’s called: for_each_cursor.

[code]
#
# This provides a way to run a function on all the cursors, one after another. This maintains
# all the cursors and then calls the function with one cursor at a time, with the view’s
# selection state set to just that one cursor. So any calls to run_command within the function
# will operate on only that one cursor.
#
# The called function is supposed to return a new cursor position or None, in which case value
# is taken from the view itself.
#
# After the function is run on all the cursors, the view’s multi-cursor state is restored with
# new values for the cursor.
#
def for_each_cursor(self, function, *args, **kwargs):
view = self.view
selection = view.sel()

    # copy cursors into proper regions which sublime will manage while we potentially edit the
    # buffer and cause things to move around
    key = "tmp_cursors"
    cursors = [c for c in selection]
    view.add_regions(key, cursors, "tmp", "", sublime.HIDDEN)

    # run the command passing in each cursor and collecting the returned cursor
    for i in range(len(cursors)):
        selection.clear()
        regions = view.get_regions(key)
        cursor = regions*
        selection.add(cursor)
        cursor = function(cursor, *args, **kwargs)
        if cursor is not None:
            # update the cursor in its slot
            regions* = cursor
            view.add_regions(key, regions, "tmp", "", sublime.HIDDEN)

    # restore the cursors
    selection.clear()
    selection.add_all(view.get_regions(key))
    view.erase_regions(key)

[/code]**

0 Likes

#3

Looks cool! Keep in mind that messing with the cursors breaks cmd+u (soft undo) functionality though.

Re: the other questions.
memberlist.php?mode=viewprofile&u=2 jps hasn’t visited the site in almost a month. I would say “no”, “community”, and “no”.

0 Likes

#4

It blows my mind how many people have decided that Jon has checked out. Can a man not go on holiday?

0 Likes

#5

Yeah, he definitely can! I think a lot of people would just really appreciate maybe a one-line message about what’s going on.

You know I like Sublime Text as much as anyone. I started back before Sublime Text X even, and I’ve written my fair share of plugins (though nothing like Package Control - thanks for that!). But along with that, I also remember when Jon seemed to be fully into the project, and it hasn’t seemed that way in a long time. Even if he just posted this:

“Guys, I’m really burned out. I’ll be back full steam in six months.”

people wouldn’t have to wonder anymore.

0 Likes

#6

I think Jon is still working on ST. I think he will probably post something if he decides that he is ever done entirely with ST. I’m not really worried in that sense. I think the general lack of “official” technical support and Jon’s general distance from the community are to blame for people’s worries. I feel Jon doesn’t have an affinity for or doesn’t have time to interface with his community much, and that just makes people nervous. I have always felt if he had an official spokes person in the forums that was in the know of the progress of sublime, could hand out official statements, support, post teasers of what’s to come, etc. it would help a lot.

I think more so in these recent times, there is an expectation of more lively interaction with companies we buy products from. We expect twitter feeds, facebook statuses, etc. I know that I personally would not care to do all of that, but if I had a company, I would probably have someone who likes all of that doing it for me.

I personally use products that only see an update once every 3 to 4 months…if your lucky. I don’t think Jon having a span of 2 months with no release is a big deal. I think if Jon just interacted with the community more, there would be less flack about long times in between dev releases.

I think that is the real problem, not that sublime is still alive or dead, people just want the appearance of it being alive…whether it is or not :smile:.

0 Likes

#7

I think in this case it also has a lot to do with the expectation created when the project first started. We used to get new builds almost daily; now we’re at two months and counting. Again, I think if Jon just said something like “Hey, I’m moving to a longer-term release process. Look for builds every few/every six months, rather than the old nightly frequency”, then people would be less worried.

0 Likes