This page is about Emacs bookmarks. Bookmarks record locations so you can return to them later.
Emacs bookmarking makes use of three things that are related but different: a bookmark list, a bookmark file, and a bookmark-list display. Understanding these is important to using Emacs bookmarks. They are explained at Bookmark Basics.
Some bookmarking commands to get you started:
‘C-x r m’– set a bookmark at the current location (e.g. in a file)
‘C-x r b’– jump to a bookmark
‘C-x r l’– list your bookmarks
‘M-x bookmark-delete’– delete a bookmark by name
Your personal bookmark file is defined by option
‘bookmark-default-file’, which defaults to `
~/.emacs.bmk’. The file is maintained automatically by Emacs as you create, change, and delete bookmarks.
(Bookmark+ makes it easy to have multiple bookmark files – different sets of bookmarks for different uses.)
Some keys in
‘a’– show annotation for the current bookmark
‘A’– show all annotations for your bookmarks
‘d’– mark various entries for deletion (
‘x’– to delete them)
‘e’– edit the annotation for the current bookmark
‘m’– mark various entries for display and other operations, (
‘v’– to visit)
‘o’– visit the current bookmark in another window, keeping the bookmark list open
‘C-o’– switch to the current bookmark in another window
‘r’– rename the current bookmark
You can bookmark Info nodes also – just use
‘C-x r m’, as usual. Command
‘bookmark-bmenu-list’, bound to
‘C-x r l’, provides a convenient menu to access bookmarks.
If you hit
‘C-x C-f’ and then realize that you want a file that is bookmarked, you can get to the bookmark this way:
From: MatthiasMeulien Subject: Re: bookmarks and abbrevs Newsgroups: gnu.emacs.help Date: 17 Jun 2002 20:20:59 +0200
(defun bookmark-to-abbrevs () "Create abbrevs based on `bookmark-alist'." (dolist (bookmark bookmark-alist) (let* ((name (car bookmark)) (file (bookmark-get-filename name))) (define-abbrev global-abbrev-table name file))))
I did not realize how to use this until I googled and found the original post where the poster mentioned using C-x a e (expand-abbrev) and RET on the find-file prompt. Now, if we could make find-file grok this more or less automatically too… ☺ – MathiasDahl
‘M-x bookmark-open-in-simply-buffer’– switch to *Bookmark list*.
‘M-x bookmark-set-add’– Add this bookmark to bookmarks list. To use history, hit Up and Down. The first Up inserts expression which is near to a point.
‘M-x bookmark-jump-prev-cyclic’– Cycle bookmarks.
‘M-x bookmark-jump-backwards’– Move to last cursor position right after uses of commands
Using this method you’ll find frequently used bookmarks easily (cho-seiri-hou in Japanese). – rubikitch
(defadvice bookmark-jump (after bookmark-jump activate) (let ((latest (bookmark-get-bookmark bookmark))) (setq bookmark-alist (delq latest bookmark-alist)) (add-to-list 'bookmark-alist latest)))
I like to use OrgMode and RememberMode to keep my bookmarks for me. Just visit a file/web page/email and then do
‘M-x remember’ and add the item to a
bookmarks.org file. With it’s clever hierarchy handling you can keep bookmarks well organised for different projects.
zsh has a feature called
‘cd-able-vars’ which is similar to bookmarks but limited to directories on the local machine. Here’s some code to convert emacs’ bookmarks into code for zsh. First add this to your .zshrc:
setopt cd_able_vars [[ -r ~/.zsh.bmk ]] && source ~/.zsh.bmk
Add this to your .emacs:
(defadvice bookmark-write-file (after local-directory-bookmarks-to-zsh-advice activate) (local-directory-bookmarks-to-zsh))
(defun local-directory-bookmarks-to-zsh () (interactive) (when (and (require 'tramp nil t) (require 'bookmark nil t)) (set-buffer (find-file-noselect "~/.zsh.bmk" t t)) (delete-region (point-min) (point-max)) (insert "# -*- mode:sh -*-\n") (let (collect-names) (mapc (lambda (item) (let ((name (replace-regexp-in-string "-" "_" (car item))) (file (cdr (assoc 'filename (if (cddr item) item (cadr item)))))) (when (and (not (tramp-tramp-file-p file)) (file-directory-p file)) (setq collect-names (cons (concat "~" name) collect-names)) (insert (format "%s=\"%s\"\n" name (expand-file-name file) name))))) bookmark-alist) (insert ": " (mapconcat 'identity collect-names " ") "\n")) (let ((backup-inhibited t)) (save-buffer)) (kill-buffer (current-buffer))))
You can bookmark Info nodes. As an alternative, you can use Info+ to create a virtual Info book and use Info to navigate its nodes. If you also use Icicles you can have any number of persistent virtual Info books.
‘doremi-bookmarks’lets you cycle among bookmarks using the up and down arrow keys or a mouse wheel.
‘icicle-bookmark’lets you cycle cycle among bookmarks. Narrow the candidates using completion.
‘eshell/cd’with your bookmarks.