3 minutes
World of Bookmarks
Vanilla Emacs bookmarks are for lhamas. Real octopodes use bookmark+ which enhances well known bookmarking in the way you didn’t even imagine. As the wiki page states:
Richer bookmarks. They record more. They are more accurate.
Here are some key features available to us for free:
- Bookmark tagging: similar to Delicious, you can use tags for sorting and filtering your bookmarks.
- Usage statistics: sort and filter your bookmarks based on how frequently they are used.
- Function, sequence, and variable-list bookmarking: While it may sound unusual, you can bookmark (and later invoke) a simple function or save/restore the value of a specific variable. If you find this too basic, you can combine various bookmarks into a sequence, which can be restored (or evaluated) by simply selecting the corresponding sequence bookmark.
- Region bookmarking: You can bookmark a region that becomes active whenever you select the associated bookmark.
- Improved relocation: According to the documentation, bookmarks+ are better at tracking their assigned locations in a more intelligent manner.
Now, turning to bookmark types. In addition to the function, sequence, and variable-list bookmarks mentioned earlier, bookmark+ introduces several additional types:
- Dired bookmarks: Dired buffers are restored immediately as they were bookmarked, which is especially useful when used with Tramp mode.
- Bookmark-list bookmarks: These save and restore the state of your bookmarks list. It may sound strange, but this can be quite handy when you meticulously adjust your bookmarks list using filters or sorting and want to restore it to the exact same state later.
- Desktop bookmarks: These are incredibly useful, allowing you to switch between projects in an instant.
- Gnus bookmarks: If you use Gnus, these bookmarks are perfect for you, as who doesn’t use Gnus these days?
Now, let’s set aside the marketing hype and focus on practical usage.
There are at least two reasons why I believe switching to bookmark+ is worthwhile.
Firstly, as mentioned, bookmark+ allows you to bookmark your current Emacs session, known as the desktop. When handling multiple active projects, being able to switch between them efficiently is essential. By “switching,” I mean restoring the last remembered desktop of the project you want to “visit.”
To enable desktops, you must activate them first (instructions can be found here: http://www.emacswiki.org/emacs/DeskTop).
Next, activate bookmark+ (link provided at the top) and, with crossed fingers, type `C-x p K` and specify the file where your desktop will be saved. To restore your desktop, display the list of bookmarks using `C-x r l` and select the bookmark you previously created.
To enhance convenience, I typically prefix my ‘desktop bookmarks’ with (desktop) (e.g., (desktop) my-secret-project) and sort bookmarks alphabetically. To further streamline the process, I also use Anything (surprise!).
(global-set-key (kbd "C-c b") 'anything-c-pp-bookmarks)
There is also second feature which makes bookmark+ attractive alternative for vanilla bookmarks. It’s something called Autonamed bookmarks.
What it is used for?
Quite often I need to create a temporary bookmark to remember the line of code I’m just working on and I immediately jump into different place to modify some other parameter/variable/whatever. I don’t want to keep this bookmark forever so inventing a name is just a waste of time. Instead of creating a plain bookmark, I create a ‘autonamed’ one (C-x p RET
) which means that Emacs takes care of inventing the bookmark name for me. Moreover, having the highlighting configured as '(bmkp-auto-light-when-set (quote autonamed-bookmark))
I have visually marked all autonamed bookmark created so far.
As autonamed bookmarks bacame part of my life, I wanted to jump between them in fastest possible way. This is why I reused meta-shift up and down keys:
(global-set-key [(M-S-down)] 'bmkp-next-bookmark-this-file)
(global-set-key [(M-S-up)] 'bmkp-previous-bookmark-this-file)
This post covers only the top of bookmark+ iceberg. I highly recommend reading the emacs wiki and going deeper into secret world of bookmarks :)