Home Download Buy Blog Forum Support

DogEars - Named Bookmarks for Sublime Text 2

DogEars - Named Bookmarks for Sublime Text 2

Postby skyronic on Thu Mar 22, 2012 2:45 am

DogEars allows you to create Bookmarks inside your code, and give them names. It also allows you to search for them using a quick panel (like the Ctrl + P Dialog). Currently it only maintains bookmarks in a particular open view, but I plan to evolve it to become a neat bookmark manager so you can jump to important locations in your project.

http://github.com/skyronic/DogEars

What works:

* Create a bookmark Ctrl + Shift + B
* Access a bookmark Ctrl + Shift + M

What doesn't work(yet):

* You can only access bookmarks in the same file for now.
* The bookmarks aren't stored on your hard drive. If you close Sublime Text, the bookmarks are lost
* Deleting bookmarks
* The bookmarks are still shown in case the section of text containing the bookmark has been deleted
* A single panel to show all the bookmarks
* Stability issues


I am not too experienced with python. I would really appreciate any feedback on the code, and suggestions on how I can take this forward.
skyronic
 
Posts: 14
Joined: Fri Mar 16, 2012 8:45 am

Re: DogEars - Named Bookmarks for Sublime Text 2

Postby atomi on Thu Mar 22, 2012 4:36 am

Thats a pretty neat idea.
I'm not great at python either.
How are you persisting the bookmarks I see BOOKMARS = {} array
I'm wondering if there is something in Sublime for persisting things like this and I'd be really interested in seeing how reopen_last_file command works since it stores a list I would guess of the last opened files and would be the best way to handle storing bookmars as well I assume.

Congratulations on the plugin.
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: DogEars - Named Bookmarks for Sublime Text 2

Postby skyronic on Thu Mar 22, 2012 8:22 am

atomi wrote:Thats a pretty neat idea.
I'm not great at python either.
How are you persisting the bookmarks I see BOOKMARS = {} array
I'm wondering if there is something in Sublime for persisting things like this and I'd be really interested in seeing how reopen_last_file command works since it stores a list I would guess of the last opened files and would be the best way to handle storing bookmars as well I assume.

Congratulations on the plugin.


Hey! Thanks for checking it out!

I am using BOOKMARKS now because I am still confused about the best way to persist it. Sublime has a neat feature where I can pick out a region (for a bookmark), and ask it to persist across sessions. The best part is that if I add text above or below, the bounds will get re-calculated (like how good bookmarking systems should).

The annoying part is that I will have to keep a list of all the bookmarks in all the files. So when the user searches the global list of bookmarks, it needs to open the appropriate file (if it isn't opened already) and then move to the correct bookmark.

However, am not sure the best way to persist BOOKMARKS. So I'm just putting it inside a global array. Since the chance of two views writing it simultaneously is none, it shouldn't have any thread-safety problems. But I'm not sure whether to serialize using CPickle, or JSON, or whatever.
skyronic
 
Posts: 14
Joined: Fri Mar 16, 2012 8:45 am

Re: DogEars - Named Bookmarks for Sublime Text 2

Postby tito on Thu Mar 22, 2012 8:36 am

Use CPickle is the fastest way. I use it in https://github.com/SublimeText/BufferSc ... rScroll.py

The problem you will find is that because the application is not sending "on project close/open" and "on application closed" you need to write to that file very often, which is very inefficient.
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 854
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: DogEars - Named Bookmarks for Sublime Text 2

Postby skyronic on Thu Mar 22, 2012 9:07 am

tito wrote:Use CPickle is the fastest way. I use it in https://github.com/SublimeText/BufferSc ... rScroll.py

The problem you will find is that because the application is not sending "on project close/open" and "on application closed" you need to write to that file very often, which is very inefficient.


Hi tito,

yup, I was using the source code of BufferScroll as a reference.

I actually figured out a way to write the bookmarks to disk and keep it efficient.

I maintain one master table containing the global list of bookmarks - which file contains which bookmark, etc. I only write to this on creation of a new bookmark, or deletion of an existing one.

I can use application_close and view_close to pick up the exact caret location of each bookmark inside the open views and store them. It's going to be a lot more tricky in practice but I think I can pull it off.
skyronic
 
Posts: 14
Joined: Fri Mar 16, 2012 8:45 am

Re: DogEars - Named Bookmarks for Sublime Text 2

Postby tito on Thu Mar 22, 2012 10:41 am

A good adition, keep it up. : )

* You can only access bookmarks in the same file for now.

I believe you can just open the file with "sublime.active_window().open_file(path)", this will refocus the tab if unfocused.
* The bookmarks are still shown in case the section of text containing the bookmark has been deleted

Allow an easy deletion, or save a hash of the content of the line.
* A single panel to show all the bookmarks
* Deleting bookmarks

There is a tiny example on how to use the panel in this file https://github.com/weslly/Nettuts-Fetch ... r/Fetch.py
You give to the show_quick_panel function a list and the panel will return the index of the selected item.
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 854
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: DogEars - Named Bookmarks for Sublime Text 2

Postby tito on Thu Mar 22, 2012 10:42 am

Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 854
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: DogEars - Named Bookmarks for Sublime Text 2

Postby Grant on Thu Feb 14, 2013 3:03 pm

@skyronic or @tito: Any word on merging efforts or updating this plugin for ST3?
It seems that bookmarks are already saved in ST3, but adding the names would be invaluable :D
Grant
 
Posts: 68
Joined: Fri Jan 20, 2012 2:42 pm


Return to Plugin Announcements

Who is online

Users browsing this forum: Google [Bot] and 8 guests