Home Download Buy Blog Forum Support

Dev Build 2024

Dev Build 2024

Postby jps on Tue Feb 15, 2011 6:54 am

Dev Build 2024 is out now. If you haven't used a dev build before, keep in mind that they're even more alpha than the alpha builds, and updated more frequently.

Firstly, the Linux build now has single instance support, so if an instance is already running, running it a second time will pass the command line off to the first instance. This means that if you have Sublime Text 2 already running, you can open files from the terminal by typing sublime_text foo (assuming you've got sublime_text or a symlink to it in your path). You can also use -w to wait for the file to be closed, and hence use it as your $EDITOR. See --help for the full list of command line options.

Bookmarks have made an appearance too. They're implemented using a region ('bookmarks'), so you can interact with them from the API using get_regions / set_regions. The bookmark commands also take the name of the region as a parameter, so you can have multiple sets of bookmarks if you wish. Along with bookmarks comes the ability to add icons to the gutter in the API (again, working via the regions API functions) - see Default/mark.py for an example. The scope name given to the region will be used to tint the icon.

In finishing off support for native OS X key bindings, I've also added some emacs-style functionality in this build: marks and a kill ring. The kill ring has items added to it when you delete a word or line without selecting it first (e.g., ctrl+backspace on Windows, or ctrl+k on OS X), delete using 'Delete to Mark', or explicitly add the selection to it using the add_to_kill_ring command (unbound by default). Currently the only interaction with the kill ring is via the yank command (Ctrl+Y on OS X, Ctrl+K,Ctrl+Y on Windows and Linux), which pastes the last item added to the kill ring. I'm planning on adding the ability to paste from older entries in the kill ring in the future. The implementation is entirely in Python, you can see it in Packages/Default/kill_ring.py

Marks are another emacs-ism required to support OS X key bindings. You can see the commands for interacting with the marks in the Edit/Mark menu. Again, the implementation is entirely in Python, in Packages/Default/mark.py. Marks and the kill ring both operate nicely with multiple selections.
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm

Re: Dev Build 2024

Postby stiang on Tue Feb 15, 2011 7:37 am

Dev Build 2024 is a great build for me, since it implements a few things that I’ve really waited for. Thanks!

Is there any way to make select_to_mark happen whenever the cursor moves and a mark is active? This is sort of the default behavior in Emacs, and it would be great if stuff like Toggle Comment just worked when you have marked a region. I tried using the event listener I added to the EmacsKillRing plugin to just do view.run_command('select_to_mark'), but expanding the selection in an on_selection_modified event doesn’t seem to work well (after the first expansion, the cursor just locks).

Also, stuff that gets deleted with ctrl+k doesn’t seem to get added to the kill ring, so a yank after a ctrl+k doesn’t produce the desired result (for me, at least).

Finally, I was really pleased to see this:

any keys bound to move by lines will take effect in Goto Anything and the filter window. Specifically, on OSX Ctrl+P and Ctrl+N can be used to select the next and previous items.


That really saved my day!

Now if you were to implement a stacked/adaptive Goto File/Anything list Sublime Text 2 would be pretty close to being perfect :)
stiang
 
Posts: 39
Joined: Sat Jan 29, 2011 12:34 pm

Re: Dev Build 2024

Postby stiang on Tue Feb 15, 2011 7:41 am

BTW, to those who want to be able to use ctrl+g to cancel the mark, like in Emacs:

Code: Select all
  { "keys": ["ctrl+g"], "command": "clear_bookmarks", "args": {"name": "mark"} },

(Found it in the menu file.)
stiang
 
Posts: 39
Joined: Sat Jan 29, 2011 12:34 pm

Re: Dev Build 2024

Postby jps on Tue Feb 15, 2011 8:33 am

stiang wrote:Is there any way to make select_to_mark happen whenever the cursor moves and a mark is active? This is sort of the default behavior in Emacs


As you saw, automatically changing the selection every time the selection is changed isn't going to end well. If you want some equivalent to emacs' transient mark mode, I imagine the best way would be to write a new set of cursor movement commands: for each region in the selection, act as though the 'a' end of the region is the mark, and modify the 'b' end only. It's not something I'm planning to add to Sublime Text myself.

stiang wrote:Also, stuff that gets deleted with ctrl+k doesn’t seem to get added to the kill ring, so a yank after a ctrl+k doesn’t produce the desired result (for me, at least).


It works for me - is it possible you've got Ctrl+K bound to a command in the EmacsKillRing plugin?
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm

Re: Dev Build 2024

Postby jps on Tue Feb 15, 2011 8:53 am

jps wrote:If you want some equivalent to emacs' transient mark mode, I imagine the best way would be to write a new set of cursor movement commands: for each region in the selection, act as though the 'a' end of the region is the mark, and modify the 'b' end only.


Actually, you don't even have to do that: all the selection commands act this way already. Transient mark mode, iirc, is essentially just holding the shift key down for you, with a couple of extra bits on top. You could implement the same thing in Sublime Text by changing the movement key bindings to have the "extend" parameter set to true, and use an option context to selectively enable/disable these bindings. Setting the mark would turn the option the option on, and ctrl+g would turn it off.
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm

Re: Dev Build 2024

Postby stiang on Tue Feb 15, 2011 9:44 am

Thanks for the workarounds. I am very close to making this last approach work. However, when I press ctrl+g to execute the following command my cursor disappears when the last line gets executed:

Code: Select all
class LocalCancelMark(sublime_plugin.TextCommand):
  def run(self, edit, args=None):
    self.view.settings().set('transient_mode_on', False)
    self.view.run_command('clear_bookmarks', {"name": "mark"})
    self.view.sel().clear()

Is there a better way to clear any selections, but keep the cursor in the current position?

If there was an on_cursor_move event this would all be quite easy to achieve without remapping every cursor movement command. Any plans for that?

It works for me - is it possible you've got Ctrl+K bound to a command in the EmacsKillRing plugin?


I wasn’t being precise. Ctrl+k works, but not ctrl+k, ctrl+k (deleting an entire line) - the yank command inserts a blank line instead of the just deleted line. The EmacsKillRing plugin is completely disabled, and I have no bindings for ctrl+k in my User keymap. Does ctrl+k, ctrl+k work for you as well?
stiang
 
Posts: 39
Joined: Sat Jan 29, 2011 12:34 pm

Re: Dev Build 2024

Postby jps on Tue Feb 15, 2011 10:08 am

stiang wrote:Is there a better way to clear any selections, but keep the cursor in the current position?


The cursor and the selection are the same thing: a 'cursor' is just an empty selection. To make all the selections empty, you want something like:

Code: Select all
regions = [s.b for s in self.view.sel()]
self.view.sel().clear()
for r in regions:
    self.view.sel().add(r)


stiang wrote:I wasn’t being precise. Ctrl+k works, but not ctrl+k, ctrl+k (deleting an entire line)


Assuming you're on OS X, then there's no Ctrl+k,Ctrl+k binding, that'll just be interpreted as deleting to the end of the line twice, which is consistent with the standard cocoa behavior, at least (i.e., TextEdit)
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm

Re: Dev Build 2024

Postby hnrch on Tue Feb 15, 2011 11:20 am

The new features are so great, very useful, just want to say something about the single instance support for linux, would be nice to focus back on ST2 after the next files are loaded? i mean i open a file in ST2, then go to filezilla, and select 'edit' option in another file, and filezilla still having the focus instead of ST2. Cheers :)
hnrch
 
Posts: 6
Joined: Mon Nov 22, 2010 4:52 pm
Location: México

Re: Dev Build 2024

Postby jps on Tue Feb 15, 2011 12:04 pm

What's the typo? :)
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm

Re: Dev Build 2024

Postby stiang on Tue Feb 15, 2011 12:45 pm

jps wrote:To make all the selections empty, you want something like:
Code: Select all
regions = [s.b for s in self.view.sel()]
self.view.sel().clear()
for r in regions:
    self.view.sel().add(r)


I tried adding this to my command, but I get the following error:

Code: Select all
Traceback (most recent call last):
  File "./sublime_plugin.py", line 226, in run_
  File "./StianCommands.py", line 41, in run
    self.view.sel().add(r) 
Boost.Python.ArgumentError: Python argument types in
    RegionSet.add(RegionSet, long)
did not match C++ signature:
    add(SelectionSet {lvalue}, SelectionRegion)

Do you have a quick fix for this? I understand that the types don’t match, but I don’t really know how to solve this.

jps wrote:Assuming you're on OS X, then there's no Ctrl+k,Ctrl+k binding, that'll just be interpreted as deleting to the end of the line twice, which is consistent with the standard cocoa behavior, at least (i.e., TextEdit)

I am indeed on OS X. Hmm, but if I go to the start of a line in TextEdit, press ctrl+k twice, then ctrl+y, I get the line that was killed back. In ST2 I get a blank line. Is this the expected behavior for ST2 or is there something funny with my installation?
stiang
 
Posts: 39
Joined: Sat Jan 29, 2011 12:34 pm

Next

Return to General Discussion

Who is online

Users browsing this forum: Exabot [Bot] and 24 guests