This page is a tutorial on emacs's bookmark feature. Emacs's Bookmarks is similar to browser's bookmark. It lets you easily open frequently needed files.
Open the file you want to add. Then, call
bookmark-set 【Ctrl+x r m】 . It will prompt you for a name.
To open bookmark, call
bookmark-bmenu-list 【Ctrl+x r l】. This displays your bookmarks.
To open a bookmarked item, call
bookmark-jump 【Ctrl+x r b】, then type a name.
You can use
* for wildcard. ➢ for example:
*today will match
bookmark-save to save it. (Press 【s】 while in bookmark)
Sometimes in or before 〔➤see Emacs 24.4 New Features (released 2014-10) (2014-10)〕, by default, bookmarks are automatically saved when emacs quit. Before, 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.
You can control bookmark auto save behavior by bookmark-save-flag.
(setq bookmark-save-flag 1) ; everytime bookmark is changed, automatically save it (setq bookmark-save-flag t) ; save bookmark when emacs quits (setq bookmark-save-flag nil) ; never auto save.
When in the bookmark file:
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.
Also, the bookmark commands all start with “bookmark-”. The only one you really need to remember is
bookmark-bmenu-list. Once you have the bookmark open, call
describe-mode 【Ctrl+h m】 to see its commands and shortcuts.
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*")
In emacs 24.x, bookmark file is at
In emacs 23.x, it's at
The default location is controlled by the variable bookmark-default-file. Call
describe-variable 【Ctrl+h v】 to see its value.
You can set default bookmark location 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)