1 ;;; bookmark.el --- set bookmarks, maybe annotate them, jump to them later.
3 ;; Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation
5 ;; Author: Karl Fogel <kfogel@red-bean.com>
6 ;; Maintainer: Karl Fogel <kfogel@red-bean.com>
8 ;; Author's Update Number: see variable `bookmark-version'.
9 ;; Keywords: bookmarks, placeholders, annotations
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
30 ;; This package is for setting "bookmarks" in files. A bookmark
31 ;; associates a string with a location in a certain file. Thus, you
32 ;; can navigate your way to that location by providing the string.
33 ;; See the "User Variables" section for customizations.
35 ;; Thanks to David Bremner <bremner@cs.sfu.ca> for thinking of and
36 ;; then implementing the bookmark-current-bookmark idea. He even
37 ;; sent *patches*, bless his soul...
39 ;; Thanks to Gregory M. Saunders <saunders@cis.ohio-state.edu> for
40 ;; fixing and improving bookmark-time-to-save-p.
42 ;; Thanks go to Andrew V. Klein <avk@cig.mot.com> for the code that
43 ;; sorts the alist before presenting it to the user (in bookmark-bmenu-list
46 ;; And much thanks to David Hughes <djh@harston.cv.com> for many small
47 ;; suggestions and the code to implement them (like
48 ;; bookmark-bmenu-check-position, and some of the Lucid compatibility
51 ;; Kudos (whatever they are) go to Jim Blandy <jimb@red-bean.com>
52 ;; for his eminently sensible suggestion to separate bookmark-jump
53 ;; into bookmark-jump and bookmark-jump-noselect, which made many
54 ;; other things cleaner as well.
56 ;; Thanks to Roland McGrath for encouragement and help with defining
57 ;; autoloads on the menu-bar.
59 ;; Jonathan Stigelman <stig@hackvan.com> gave patches for default
60 ;; values in bookmark-jump and bookmark-set. Everybody please keep
61 ;; all the keystrokes they save thereby and send them to him at the
62 ;; end of each year :-) (No, seriously, thanks Jonathan!)
64 ;; Buckets of gratitude to John Grabowski <johng@media.mit.edu> for
65 ;; thinking up the annotations feature and implementing it so well.
67 ;; Based on info-bookmark.el, by Karl Fogel and Ken Olstad
70 ;; Thanks to Mikio Nakajima <PBC01764@niftyserve.or.jp> for many bugs
71 ;; reported and fixed.
73 ;; Thank you, Michael Kifer, for contributing the XEmacs support.
75 ;; Enough with the credits already, get on to the good stuff:
77 ;; FAVORITE CHINESE RESTAURANT:
78 ;; Boy, that's a tough one. Probably Hong Min, or maybe Emperor's
79 ;; Choice (both in Chicago's Chinatown). Well, both. How about you?
85 (defconst bookmark-version "2.6.4"
86 "Version number of bookmark.el. This is not related to the version
87 of Emacs bookmark comes with; it is used solely by bookmark's
88 maintainers to avoid version confusion.")
92 ;; If variable bookmark-use-annotations is non-nil, an annotation is
93 ;; queried for when setting a bookmark.
95 ;; The bookmark list is sorted lexically by default, but you can turn
96 ;; this off by setting bookmark-sort-flag to nil. If it is nil, then
97 ;; the list will be presented in the order it is recorded
98 ;; (chronologically), which is actually fairly useful as well.
102 (defgroup bookmarks nil
103 "Set bookmarks, maybe annotate them, jump to them later."
108 (defcustom bookmark-use-annotations nil
109 "*If non-nil, saving a bookmark will query for an annotation in a
115 (defcustom bookmark-save-flag t
116 "*Controls when Emacs saves bookmarks to a file.
117 --> Nil means never save bookmarks, except when `bookmark-save' is
118 explicitly called \(\\[bookmark-save]\).
119 --> t means save bookmarks when Emacs is killed.
120 --> Otherwise, it should be a number that is the frequency with which
121 the bookmark list is saved \(i.e.: the number of times which
122 Emacs' bookmark list may be modified before it is automatically
123 saved.\). If it is a number, Emacs will also automatically save
124 bookmarks when it is killed.
126 Therefore, the way to get it to save every time you make or delete a
127 bookmark is to set this variable to 1 \(or 0, which produces the same
130 To specify the file in which to save them, modify the variable
131 bookmark-default-file, which is `~/.emacs.bmk' by default."
132 :type '(choice (const :tag "Never" nil)
133 (const :tag "On Exit" t)
134 (number :tag "Frequency" 1))
138 (defconst bookmark-old-default-file "~/.emacs-bkmrks"
139 "*The .emacs.bmk file used to be called this.")
142 ;; defvarred to avoid a compilation warning:
143 (defvar bookmark-file nil
144 "Old name for `bookmark-default-file'.")
146 (defvar bookmark-default-file
148 ;; In case user set `bookmark-file' in her .emacs:
150 (convert-standard-filename "~/.emacs.bmk"))
151 "*File in which to save bookmarks by default.")
154 (defcustom bookmark-version-control 'nospecial
155 "*Whether or not to make numbered backups of the bookmark file.
156 It can have four values: t, nil, `never', and `nospecial'.
157 The first three have the same meaning that they do for the
158 variable `version-control', and the final value `nospecial' means just
159 use the value of `version-control'."
160 :type '(choice (const t) (const nil) (const never) (const nospecial))
164 (defcustom bookmark-completion-ignore-case t
165 "*Non-nil means bookmark functions ignore case in completion."
170 (defcustom bookmark-sort-flag t
171 "*Non-nil means that bookmarks will be displayed sorted by bookmark
172 name. Otherwise they will be displayed in LIFO order (that is, most
173 recently set ones come first, oldest ones come last)."
178 (defcustom bookmark-automatically-show-annotations t
179 "*Nil means don't show annotations when jumping to a bookmark."
184 (defcustom bookmark-bmenu-file-column 30
185 "*Column at which to display filenames in a buffer listing bookmarks.
186 You can toggle whether files are shown with \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-toggle-filenames]."
191 (defcustom bookmark-bmenu-toggle-filenames t
192 "*Non-nil means show filenames when listing bookmarks.
193 This may result in truncated bookmark names. To disable this, put the
194 following in your .emacs:
196 \(setq bookmark-bmenu-toggle-filenames nil\)"
201 (defcustom bookmark-menu-length 70
202 "*Maximum length of a bookmark name displayed on a popup menu."
207 ;;; No user-serviceable parts beyond this point.
210 (defconst bookmark-xemacsp
211 (string-match "\\(Lucid\\|XEmacs\\)" emacs-version))
214 ;; Added for lucid emacs compatibility, db
215 (or (fboundp 'defalias) (fset 'defalias 'fset))
217 ;; suggested for lucid compatibility by david hughes:
218 (or (fboundp 'frame-height) (defalias 'frame-height 'screen-height))
220 ;; This variable is probably obsolete now...
222 ;(or (boundp 'baud-rate)
223 ; ;; some random value higher than 9600
224 ; (setq baud-rate 19200))
226 ;; XEmacs apparently call this `buffer-substring-without-properties',
228 (or (fboundp 'buffer-substring-no-properties)
229 (if (fboundp 'buffer-substring-without-properties)
230 (fset 'buffer-substring-no-properties
231 'buffer-substring-without-properties)
232 (fset 'buffer-substring-no-properties 'buffer-substring)))
236 ;; some people have C-x r set to rmail or whatever. We don't want to
237 ;; assume that C-x r is a prefix map just because it's distributed
239 ;; These are the distribution keybindings suggested by RMS, everything
240 ;; else will be done with M-x or the menubar:
242 (if (symbolp (key-binding "\C-xr"))
244 (progn (define-key ctl-x-map "rb" 'bookmark-jump)
245 (define-key ctl-x-map "rm" 'bookmark-set)
246 (define-key ctl-x-map "rl" 'bookmark-bmenu-list)))
248 ;; define the map, so it can be bound by those who desire to do so:
251 (defvar bookmark-map nil
252 "Keymap containing bindings to bookmark functions.
253 It is not bound to any key by default: to bind it
254 so that you have a bookmark prefix, just use `global-set-key' and bind a
255 key of your choice to `bookmark-map'. All interactive bookmark
256 functions have a binding in this keymap.")
259 (define-prefix-command 'bookmark-map)
261 ;; Read the help on all of these functions for details...
263 (define-key bookmark-map "x" 'bookmark-set)
265 (define-key bookmark-map "m" 'bookmark-set) ; "m" for "mark"
267 (define-key bookmark-map "j" 'bookmark-jump)
269 (define-key bookmark-map "g" 'bookmark-jump) ; "g" for "go"
271 (define-key bookmark-map "i" 'bookmark-insert)
273 (define-key bookmark-map "e" 'edit-bookmarks)
275 (define-key bookmark-map "f" 'bookmark-insert-location) ; "f" for "find"
277 (define-key bookmark-map "r" 'bookmark-rename)
279 (define-key bookmark-map "d" 'bookmark-delete)
281 (define-key bookmark-map "l" 'bookmark-load)
283 (define-key bookmark-map "w" 'bookmark-write)
285 (define-key bookmark-map "s" 'bookmark-save)
288 ;;; The annotation maps.
289 (defvar bookmark-read-annotation-mode-map (copy-keymap text-mode-map)
290 "Keymap for composing an annotation for a bookmark.")
292 (define-key bookmark-read-annotation-mode-map "\C-c\C-c"
293 'bookmark-send-annotation)
297 ;;; Core variables and data structures:
298 (defvar bookmark-alist ()
299 "Association list of bookmarks and their records.
300 You probably don't want to change the value of this alist yourself;
301 instead, let the various bookmark functions do it for you.
303 The format of the alist is
305 \(BOOKMARK1 BOOKMARK2 ...\)
307 where each BOOKMARK is of the form
311 \(front-context-string . FRONT-STR\)
312 \(rear-context-string . REAR-STR\)
315 \(annotation . ANNOTATION\)\)
317 So the cdr of each bookmark is an alist too.
318 `info-node' is optional, by the way.")
321 (defvar bookmarks-already-loaded nil)
324 ;; just add the hook to make sure that people don't lose bookmarks
325 ;; when they kill Emacs, unless they don't want to save them.
327 (add-hook 'kill-emacs-hook
329 (lambda () (and (featurep 'bookmark)
331 (bookmark-time-to-save-p t)
334 ;; more stuff added by db.
336 (defvar bookmark-current-bookmark nil
337 "Name of bookmark most recently used in the current file.
338 It is buffer local, used to make moving a bookmark forward
339 through a file easier.")
341 (make-variable-buffer-local 'bookmark-current-bookmark)
344 (defvar bookmark-alist-modification-count 0
345 "Number of modifications to bookmark list since it was last saved.")
348 (defvar bookmark-search-size 16
349 "Length of the context strings recorded on either side of a bookmark.")
352 (defvar bookmark-current-point 0)
353 (defvar bookmark-yank-point 0)
354 (defvar bookmark-current-buffer nil)
360 ;; Only functions on this page and the next one (file formats) need to
361 ;; know anything about the format of bookmark-alist entries.
362 ;; Everyone else should go through them.
364 (defun bookmark-name-from-full-record (full-record)
365 "Return name of FULL-RECORD \(an alist element instead of a string\)."
369 (defun bookmark-all-names ()
370 "Return a list of all current bookmark names."
371 (bookmark-maybe-load-default-file)
373 (lambda (full-record)
374 (bookmark-name-from-full-record full-record))
378 (defun bookmark-get-bookmark (bookmark)
379 "Return the full entry for BOOKMARK in bookmark-alist."
380 (assoc bookmark bookmark-alist))
383 (defun bookmark-get-bookmark-record (bookmark)
384 "Return the guts of the entry for BOOKMARK in bookmark-alist.
385 That is, all information but the name."
386 (car (cdr (bookmark-get-bookmark bookmark))))
389 (defun bookmark-set-name (bookmark newname)
390 "Set BOOKMARK's name to NEWNAME."
391 (setcar (bookmark-get-bookmark bookmark) newname))
394 (defun bookmark-get-annotation (bookmark)
395 "Return the annotation of BOOKMARK, or nil if none."
396 (cdr (assq 'annotation (bookmark-get-bookmark-record bookmark))))
399 (defun bookmark-set-annotation (bookmark ann)
400 "Set the annotation of BOOKMARK to ANN."
401 (let ((cell (assq 'annotation (bookmark-get-bookmark-record bookmark))))
404 (nconc (bookmark-get-bookmark-record bookmark)
405 (list (cons 'annotation ann))))))
408 (defun bookmark-get-filename (bookmark)
409 "Return the full filename of BOOKMARK."
410 (cdr (assq 'filename (bookmark-get-bookmark-record bookmark))))
413 (defun bookmark-set-filename (bookmark filename)
414 "Set the full filename of BOOKMARK to FILENAME."
415 (let ((cell (assq 'filename (bookmark-get-bookmark-record bookmark))))
417 (setcdr cell filename)
418 (nconc (bookmark-get-bookmark-record bookmark)
419 (list (cons 'filename filename))))))
422 (defun bookmark-get-position (bookmark)
423 "Return the position \(i.e.: point\) of BOOKMARK."
424 (cdr (assq 'position (bookmark-get-bookmark-record bookmark))))
427 (defun bookmark-set-position (bookmark position)
428 "Set the position \(i.e.: point\) of BOOKMARK to POSITION."
429 (let ((cell (assq 'position (bookmark-get-bookmark-record bookmark))))
431 (setcdr cell position)
432 (nconc (bookmark-get-bookmark-record bookmark)
433 (list (cons 'position position))))))
436 (defun bookmark-get-front-context-string (bookmark)
437 "Return the front-context-string of BOOKMARK."
438 (cdr (assq 'front-context-string (bookmark-get-bookmark-record bookmark))))
441 (defun bookmark-set-front-context-string (bookmark string)
442 "Set the front-context-string of BOOKMARK to STRING."
443 (let ((cell (assq 'front-context-string
444 (bookmark-get-bookmark-record bookmark))))
447 (nconc (bookmark-get-bookmark-record bookmark)
448 (list (cons 'front-context-string string))))))
451 (defun bookmark-get-rear-context-string (bookmark)
452 "Return the rear-context-string of BOOKMARK."
453 (cdr (assq 'rear-context-string (bookmark-get-bookmark-record bookmark))))
456 (defun bookmark-set-rear-context-string (bookmark string)
457 "Set the rear-context-string of BOOKMARK to STRING."
458 (let ((cell (assq 'rear-context-string
459 (bookmark-get-bookmark-record bookmark))))
462 (nconc (bookmark-get-bookmark-record bookmark)
463 (list (cons 'rear-context-string string))))))
466 (defun bookmark-get-info-node (bookmark)
467 "Get the info node associated with BOOKMARK."
468 (cdr (assq 'info-node (bookmark-get-bookmark-record bookmark))))
471 (defun bookmark-set-info-node (bookmark node)
472 "Set the Info node of BOOKMARK to NODE."
473 (let ((cell (assq 'info-node
474 (bookmark-get-bookmark-record bookmark))))
477 (nconc (bookmark-get-bookmark-record bookmark)
478 (list (cons 'info-node node)))))
480 (message "%S" (assq 'info-node (bookmark-get-bookmark-record bookmark)))
485 (defvar bookmark-history nil
486 "The history list for bookmark functions.")
489 (defun bookmark-completing-read (prompt &optional default)
490 "Prompting with PROMPT, read a bookmark name in completion.
491 PROMPT will get a \": \" stuck on the end no matter what, so you
492 probably don't want to include one yourself.
493 Optional second arg DEFAULT is a string to return if the user enters
495 (bookmark-maybe-load-default-file) ; paranoia
496 (let* ((completion-ignore-case bookmark-completion-ignore-case)
499 (concat prompt (format " (%s): " default))
500 (concat prompt ": ")))
503 ;; XEmacs 21.2 adds the default argument.
504 (completing-read prompt
511 (wrong-number-of-arguments
512 (completing-read prompt
517 'bookmark-history)))))
518 ;; Take care of the lack of the default argument in XEmacs 21.1.
519 (if (string-equal "" str)
524 (defmacro bookmark-maybe-historicize-string (string)
525 "Put STRING into the bookmark prompt history, if caller non-interactive.
526 We need this because sometimes bookmark functions are invoked from
527 menus, so `completing-read' never gets a chance to set `bookmark-history'."
530 (setq bookmark-history (cons (, string) bookmark-history)))))
533 (defun bookmark-make (name &optional annotation overwrite info-node)
534 "Make a bookmark named NAME.
535 Optional second arg ANNOTATION gives it an annotation.
536 Optional third arg OVERWRITE means replace any existing bookmarks with
538 Optional fourth arg INFO-NODE means this bookmark is at info node
539 INFO-NODE, so record this fact in the bookmark's entry."
540 (bookmark-maybe-load-default-file)
541 (let ((stripped-name (copy-sequence name)))
543 ;; XEmacs's `set-text-properties' doesn't work on
544 ;; free-standing strings, apparently.
545 (set-text-properties 0 (length stripped-name) nil stripped-name))
546 (if (and (bookmark-get-bookmark stripped-name) (not overwrite))
547 ;; already existing bookmark under that name and
548 ;; no prefix arg means just overwrite old bookmark
549 (setcdr (bookmark-get-bookmark stripped-name)
550 (list (bookmark-make-cell annotation info-node)))
552 ;; otherwise just cons it onto the front (either the bookmark
553 ;; doesn't exist already, or there is no prefix arg. In either
554 ;; case, we want the new bookmark consed onto the alist...)
559 (bookmark-make-cell annotation info-node))
563 (setq bookmark-current-bookmark stripped-name)
564 (setq bookmark-alist-modification-count
565 (1+ bookmark-alist-modification-count))
566 (if (bookmark-time-to-save-p)
570 (defun bookmark-make-cell (annotation &optional info-node)
571 "Return the record part of a new bookmark, given ANNOTATION.
572 Must be at the correct position in the buffer in which the bookmark is
573 being set. This might change someday.
574 Optional second arg INFO-NODE means this bookmark is at info node
575 INFO-NODE, so record this fact in the bookmark's entry."
577 (` ((filename . (, (bookmark-buffer-file-name)))
578 (front-context-string
579 . (, (if (>= (- (point-max) (point)) bookmark-search-size)
580 (buffer-substring-no-properties
582 (+ (point) bookmark-search-size))
585 . (, (if (>= (- (point) (point-min)) bookmark-search-size)
586 (buffer-substring-no-properties
588 (- (point) bookmark-search-size))
590 (position . (, (point)))
593 ;; Now fill in the optional parts:
595 (nconc the-record (list (cons 'annotation annotation))))
597 (nconc the-record (list (cons 'info-node info-node))))
599 ;; Finally, return the completed record.
604 ;;; File format stuff
606 ;; The OLD format of the bookmark-alist was:
608 ;; ((bookmark-name (filename
614 ;; The NEW format of the bookmark-alist is:
616 ;; ((bookmark-name ((filename . FILENAME)
617 ;; (front-context-string . string-in-front)
618 ;; (rear-context-string . string-behind)
619 ;; (position . POINT)
620 ;; (annotation . annotation)
621 ;; (whatever . VALUE)
627 ;; I switched to using an internal as well as external alist because I
628 ;; felt that would be a more flexible framework in which to add
629 ;; features. It means that the order in which values appear doesn't
630 ;; matter, and it means that arbitrary values can be added without
631 ;; risk of interfering with existing ones.
633 ;; BOOKMARK-NAME is the string the user gives the bookmark and
634 ;; accesses it by from then on.
636 ;; FILENAME is the location of the file in which the bookmark is set.
638 ;; STRING-IN-FRONT is a string of `bookmark-search-size' chars of
639 ;; context in front of the point at which the bookmark is set.
641 ;; STRING-BEHIND is the same thing, but after the point.
643 ;; The context strings exist so that modifications to a file don't
644 ;; necessarily cause a bookmark's position to be invalidated.
645 ;; bookmark-jump will search for STRING-BEHIND and STRING-IN-FRONT in
646 ;; case the file has changed since the bookmark was set. It will
647 ;; attempt to place the user before the changes, if there were any.
648 ;; ANNOTATION is the annotation for the bookmark; it may not exist
649 ;; (for backward compatibility), be nil (no annotation), or be a
653 (defconst bookmark-file-format-version 1
654 "The current version of the format used by bookmark files.
655 You should never need to change this.")
658 (defconst bookmark-end-of-version-stamp-marker
659 "-*- End Of Bookmark File Format Version Stamp -*-\n"
660 "This string marks the end of the version stamp in a bookmark file.")
663 (defun bookmark-alist-from-buffer ()
664 "Return a bookmark-alist (in any format) from the current buffer.
665 The buffer must of course contain bookmark format information.
666 Does not care from where in the buffer it is called, and does not
669 (goto-char (point-min))
670 (if (search-forward bookmark-end-of-version-stamp-marker nil t)
671 (read (current-buffer))
672 ;; Else we're dealing with format version 0
673 (if (search-forward "(" nil t)
676 (read (current-buffer)))
677 ;; Else no hope of getting information here.
678 (error "Not bookmark format")))))
681 (defun bookmark-upgrade-version-0-alist (old-list)
682 "Upgrade a version 0 alist OLD-LIST to the current version."
685 (let* ((name (car bookmark))
686 (record (car (cdr bookmark)))
687 (filename (nth 0 record))
688 (front-str (nth 1 record))
689 (rear-str (nth 2 record))
690 (position (nth 3 record))
691 (ann (nth 4 record)))
694 (` ((filename . (, filename))
695 (front-context-string . (, (or front-str "")))
696 (rear-context-string . (, (or rear-str "")))
697 (position . (, position))
698 (annotation . (, ann)))))))
702 (defun bookmark-upgrade-file-format-from-0 ()
703 "Upgrade a bookmark file of format 0 (the original format) to format 1.
704 This expects to be called from point-min in a bookmark file."
705 (message "Upgrading bookmark format from 0 to %d..."
706 bookmark-file-format-version)
707 (let* ((old-list (bookmark-alist-from-buffer))
708 (new-list (bookmark-upgrade-version-0-alist old-list)))
709 (delete-region (point-min) (point-max))
710 (bookmark-insert-file-format-version-stamp)
711 (pp new-list (current-buffer))
713 (goto-char (point-min))
714 (message "Upgrading bookmark format from 0 to %d...done"
715 bookmark-file-format-version)
719 (defun bookmark-grok-file-format-version ()
720 "Return an integer which is the file-format version of this bookmark file.
721 This expects to be called from point-min in a bookmark file."
722 (if (looking-at "^;;;;")
725 (re-search-forward "[0-9]")
727 (read (current-buffer))))
728 ;; Else this is format version 0, the original one, which didn't
729 ;; even have version stamps.
733 (defun bookmark-maybe-upgrade-file-format ()
734 "Check the file-format version of this bookmark file.
735 If the version is not up-to-date, upgrade it automatically.
736 This expects to be called from point-min in a bookmark file."
737 (let ((version (bookmark-grok-file-format-version)))
739 ((= version bookmark-file-format-version)
740 ) ; home free -- version is current
742 (bookmark-upgrade-file-format-from-0))
744 (error "Bookmark file format version strangeness")))))
747 (defun bookmark-insert-file-format-version-stamp ()
748 "Insert text indicating current version of bookmark file format."
750 (format ";;;; Emacs Bookmark Format Version %d ;;;;\n"
751 bookmark-file-format-version))
752 (insert ";;; This format is meant to be slightly human-readable;\n"
753 ";;; nevertheless, you probably don't want to edit it.\n"
755 bookmark-end-of-version-stamp-marker))
758 ;;; end file-format stuff
764 (defun bookmark-set (&optional name parg)
765 "Set a bookmark named NAME inside a file.
766 If name is nil, then the user will be prompted.
767 With prefix arg, will not overwrite a bookmark that has the same name
768 as NAME if such a bookmark already exists, but instead will \"push\"
769 the new bookmark onto the bookmark alist. Thus the most recently set
770 bookmark with name NAME would be the one in effect at any given time,
771 but the others are still there, should you decide to delete the most
774 To yank words from the text of the buffer and use them as part of the
775 bookmark name, type C-w while setting a bookmark. Successive C-w's
776 yank successive words.
778 Typing C-u inserts the name of the last bookmark used in the buffer
779 \(as an aid in using a single bookmark name to track your progress
780 through a large file\). If no bookmark was used, then C-u inserts the
781 name of the file being visited.
783 Use \\[bookmark-delete] to remove bookmarks \(you give it a name,
784 and it removes only the first instance of a bookmark with that name from
785 the list of bookmarks.\)"
786 (interactive (list nil current-prefix-arg))
788 (bookmark-buffer-file-name)
789 (error "Buffer not visiting a file or directory"))
791 (bookmark-maybe-load-default-file)
793 (setq bookmark-current-point (point))
794 (setq bookmark-yank-point (point))
795 (setq bookmark-current-buffer (current-buffer))
797 (let* ((default (or bookmark-current-bookmark
798 (bookmark-buffer-name)))
801 (read-from-minibuffer
802 (format "Set bookmark (%s): " default)
804 (let ((now-map (copy-keymap minibuffer-local-map)))
805 (progn (define-key now-map "\C-w"