Previous: Keyboard Macro Registers, Up: Registers [Contents][Index]
15.8 BookmarksBookmarks are somewhat like registers in that they record positions you can jump to. Unlike registers, they have long names, and they persist automatically from one Emacs session to the next. The prototypical use of bookmarks is to record where you were reading in various files.
Set the bookmark for the visited file, at point.
Set the bookmark named bookmark at point (bookmark-set
).
Like C-x r m, but don’t overwrite an existing bookmark.
Jump to the bookmark named bookmark (bookmark-jump
).
List all bookmarks (list-bookmarks
).
Save all the current bookmark values in the default bookmark file.
To record the current position in the visited file, use the command C-x r m, which sets a bookmark using the visited file name as the default for the bookmark name. If you name each bookmark after the file it points to, then you can conveniently revisit any of those files with C-x r b (bookmark-jump
), and move to the position of the bookmark at the same time.
In addition to recording the current position, on graphical displays C-x r m places a special image on the left fringe (see Window Fringes) of the screen line corresponding to the recorded position, to indicate that there’s a bookmark there. This can be controlled by the user option bookmark-fringe-mark
: customize it to nil
to disable the fringe mark. The default value is bookmark-mark
, which is the bitmap used for this purpose. When you later use C-x r b to jump back to the bookmark, the fringe mark will be again shown on the fringe.
The command C-x r M (bookmark-set-no-overwrite
) works like C-x r m, but it signals an error if the specified bookmark already exists, instead of overwriting it.
To display a list of all your bookmarks in a separate buffer, type C-x r l (list-bookmarks
). If you switch to that buffer, you can use it to edit your bookmark definitions or annotate the bookmarks. Type C-h m in the bookmark buffer for more information about its special editing commands.
When you kill Emacs, Emacs saves your bookmarks, if you have changed any bookmark values. You can also save the bookmarks at any time with the M-x bookmark-save command. Bookmarks are saved to the file ~/.emacs.d/bookmarks (for compatibility with older versions of Emacs, if you have a file named ~/.emacs.bmk, that is used instead). The bookmark commands load your default bookmark file automatically. This saving and loading is how bookmarks persist from one Emacs session to the next.
If you set the variable bookmark-save-flag
to 1, each command that sets a bookmark will also save your bookmarks; this way, you don’t lose any bookmark values even if Emacs crashes. The value, if a number, says how many bookmark modifications should go by between saving. If you set this variable to nil
, Emacs only saves bookmarks if you explicitly use M-x bookmark-save.
The variable bookmark-default-file
specifies the file in which to save bookmarks by default.
If you set the variable bookmark-use-annotations
to t
, setting a bookmark will query for an annotation. If a bookmark has an annotation, it is automatically shown in a separate window when you jump to the bookmark.
Bookmark position values are saved with surrounding context, so that bookmark-jump
can find the proper position even if the file is modified slightly. The variable bookmark-search-size
says how many characters of context to record on each side of the bookmark’s position. (In buffers that are visiting encrypted files, no context is saved in the bookmarks file no matter the value of this variable.)
Here are some additional commands for working with bookmarks:
Load a file named filename that contains a list of bookmark values. You can use this command, as well as bookmark-write
, to work with other files of bookmark values in addition to your default bookmark file.
Save all the current bookmark values in the file filename.
Delete the bookmark named bookmark.
Insert in the buffer the name of the file that bookmark bookmark points to.
Insert in the buffer the contents of the file that bookmark bookmark points to.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4