Sublime Forum

Dev Build 2024

#1

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.

1 Like

#2

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:

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 :smile:

0 Likes

#3

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

  { "keys": "ctrl+g"], "command": "clear_bookmarks", "args": {"name": "mark"} },

(Found it in the menu file.)

0 Likes

#4

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.

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

0 Likes

#5

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.

0 Likes

#6

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:

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?

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?

0 Likes

#7

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:

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

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)

0 Likes

#8

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 :smile:

0 Likes

#9

What’s the typo? :slight_smile:

0 Likes

#10

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

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.

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?

0 Likes

#11

I ran into errors when trying to install this build.

See: DEV BUILD 2024 undefined symbol: g_bus_own_name

0 Likes

#12

That worked, thanks!

0 Likes

#13

Yeah yeah yeah yeah yeah, bookmarks.

Nuff’ said.

Cheers Jon :smiley: I HEART YOUR FACE!

0 Likes

#14

[size=150]1:[/size]
Updating to 2024 linux x64 gives me this error:

./sublime_text: symbol lookup error: ./sublime_text: undefined symbol: g_bus_own_name

Ubuntu 10.04 x64
Going back to 2023 does fix it.

[size=150]2:[/size]
And I think sublime-projects should have relative paths. Otherwise I have to create the sublime-project on each computer.

[size=150]3:[/size]
Minimap should be draggable past the viewable buffer like the scrollbar.

[size=150]4:[/size]
How do I bind numpad enter to newline?

0 Likes

#15

Ah, I see what you’re talking about now. I’ll try to address this for the next version.

0 Likes

#16

Ah hah, thanks :slight_smile:

0 Likes