Function: bookmark-set

bookmark-set is an autoloaded, interactive and byte-compiled function defined in bookmark.el.gz.

Signature

(bookmark-set &optional NAME NO-OVERWRITE)

Documentation

Set a bookmark named NAME at the current location.

If NAME is nil, then prompt the user.

With a prefix arg (non-nil NO-OVERWRITE), do not overwrite any existing bookmark that has the same name as NAME, but instead push the new bookmark onto the bookmark alist. The most recently set bookmark with name NAME is thus the one in effect at any given time, but the others are still there, should the user decide to delete the most recent one.

To yank words from the text of the buffer and use them as part of the bookmark name, type C-w (bookmark-yank-word) while setting a bookmark. Successive C-w (bookmark-yank-word)'s yank successive words.

Typing C-u (universal-argument) inserts (at the bookmark name prompt) the name of the last bookmark used in the document where the new bookmark is being set; this helps you use a single bookmark name to track progress through a large document. If there is no prior bookmark for this document, then C-u (universal-argument) inserts an appropriate name based on the buffer or file.

Use M-x bookmark-delete (bookmark-delete) to remove bookmarks (you give it a name and it removes only the first instance of a bookmark with that name from the list of bookmarks.)

View in manual

Probably introduced at or before Emacs version 25.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/bookmark.el.gz
;;;###autoload
(defun bookmark-set (&optional name no-overwrite)
  "Set a bookmark named NAME at the current location.
If NAME is nil, then prompt the user.

With a prefix arg (non-nil NO-OVERWRITE), do not overwrite any
existing bookmark that has the same name as NAME, but instead push the
new bookmark onto the bookmark alist.  The most recently set bookmark
with name NAME is thus the one in effect at any given time, but the
others are still there, should the user decide to delete the most
recent one.

To yank words from the text of the buffer and use them as part of the
bookmark name, type \\<bookmark-minibuffer-read-name-map>\
\\[bookmark-yank-word] while setting a bookmark.  Successive \
\\[bookmark-yank-word]'s
yank successive words.

Typing \\[universal-argument] inserts (at the bookmark name prompt) the name of the last
bookmark used in the document where the new bookmark is being set;
this helps you use a single bookmark name to track progress through a
large document.  If there is no prior bookmark for this document, then
\\[universal-argument] inserts an appropriate name based on the buffer or file.

Use \\[bookmark-delete] to remove bookmarks (you give it a name and
it removes only the first instance of a bookmark with that name from
the list of bookmarks.)"
  (interactive (list nil current-prefix-arg))
  (let ((prompt
         (if no-overwrite "Add bookmark named" "Set bookmark named")))
    (bookmark-set-internal prompt name (if no-overwrite 'push 'overwrite))))