/bookmark-frecency.el

Sort Emacs bookmarks by frecency

Primary LanguageEmacs LispGNU General Public License v3.0GPL-3.0

bookmark-frecency-mode for Emacs

https://melpa.org/packages/bookmark-frecency-badge.svg

This library exposes bookmark-frecency-mode, which is a global mode that tracks access to your bookmarks and sorts them by frecency, using the algorithm described in A faster, smarter Quick Switcher - Slack Engineering.

The most notable feature of this library is integration with dashboard package. With bookmark-frecency-mode, bookmarks in the dashboard widget will be sorted at the cost of minimum addition to Emacs startup time.

Installation

This package is available as bookmark-frecency from MELPA. Alternatively, you can just clone the repository and add the directory to load-path using your favorite Emacs package manager.

Configuration

Turn on bookmark-frecency-mode.

On every visit to a bookmark, the visited bookmark will be updated with the information needed to calculate the frecency score later. Thus your bookmarks should be persisted to bookmark-file at some point after a call to bookmark-jump. You can customize this behavior by customizing bookmark-save-flag variable.

If you are using dashboard package, entries in the bookmark widget will be sorted out of the box once you turn on the global mode.

Also, to sort the result of bookmark-maybe-sort-alist (which is used in bookmark-bmenu-list and other commmands using bookmark-completing-read) by frecency, set the value of bookmark-sort-flag to last-modified. This is weird according to what the option value is supposed to mean, but bookmark-bmenu-list wouldn’t work for a non-standard value.

Usage

To retrieve a sorted list of bookmarks, use either bookmark-all-names (only names) or bookmark-maybe-sort-alist (full records).

There is nothing else you have to (or can) do with this package. When you turn on bookmark-frecency-mode, every visit to a bookmark will have a side-effect on the bookmark set, and all other libraries using bookmark-all-names and bookmark-maybe-sort-alist will get a sorted list of bookmarks.

Acknowledgement

bookmark-frecency.el is inspired by frecency.el by Adam Porter (a.k.a. alphapapa). The package is not a dependency of this package because of subtlety in implementation details.