ErgoEmacsEmacsLispBlogEmacsLispBuy Tutorial
Web Hosting by 1&1

Using Emacs's Bookmark Feature

Xah Lee, , …,

This page is a tutorial on emacs's bookmark feature. Emacs's Bookmarks is similar to browser's bookmark. Emacs bookmark lets you easily open frequently needed files.

emacs bookmark
Emacs's Bookmark feature.

Using Bookmark

Add a File to Bookmark

Open the file you want to add. Then, call bookmark-setCtrl+x r m】 . It will prompt you for a name.

Opening Bookmark File

To open bookmark, call bookmark-bmenu-listCtrl+x r l】. This displays your bookmarks. From there, you can open your files, by just pressing Enter ↵, click on it, or press o to open it in a split window.

Saving Your Bookmark

When your bookmark file is open , call bookmark-saves】 to save it. If you don't save it, newly added bookmarks will be for the current session only, and won't show up when you restart emacs.

Removing Or Renaming A Bookmark

When in the bookmark file, type D to remove a file listing, or type r to rename its bookmark title.

How to Remember Bookmark Commands or Shortcuts?

Bookmark commands are right under the menu 〖Edit ▸ Bookmarks〗. If you forgot the commands or shortcuts, look at the menu. The menu is a great way to remember many emacs's commands.

emacs bookmark menu
emacs bookmark menu

Also, the bookmark commands all starts with “bookmark-”. The only one you really need to remember is bookmark-bmenu-list. Once you have the bookmark open, you can call describe-modeF1 m】 to see its commands and shortcuts.

Starting Emacs with Bookmark

To have emacs open bookmarks on startup, add this to the end of your elisp init file:

(setq inhibit-splash-screen t)
(require 'bookmark)
(bookmark-bmenu-list)
(switch-to-buffer "*Bookmark List*")

Bookmark Raw File Location

In emacs 24.x, bookmark file is at 〔~/.emacs.d/bookmarks〕.

In emacs 23.x, it's at 〔~/.emacs.bmk〕.

The default location is controlled by the variable bookmark-default-file. Call describe-variableF1 v】 to see its value.

In emacs 23.2, many preference files are moved to the 〔~/.emacs.d/〕 directory. 〔☛ Emacs 23.2 Features〕 However, bookmark didn't make it. You can set it yourself, like this:

(setq bookmark-default-file  (concat user-emacs-directory "bookmarks"))

The syntax to load a bookmark file is this:

(bookmark-load bookmark-default-file t)

Open File Fast: Recentf-Mode

See: Emacs: Open File Fast: recentf-mode

See also: Emacs Lisp: Hotkeys to Open File Fast

blog comments powered by Disqus