aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-03-11 02:05:20 +0000
committerRichard M. Stallman1995-03-11 02:05:20 +0000
commite34379890042bdb66263d962e845328ac0b63f67 (patch)
tree925773eb766d59d17ef65b5866d5100a6f30c897
parent3d9652eb1520a3ad6d83fd22ef43ff4b72703265 (diff)
downloademacs-e34379890042bdb66263d962e845328ac0b63f67.tar.gz
emacs-e34379890042bdb66263d962e845328ac0b63f67.zip
Insure that all entry points call `bookmark-maybe-load-default-file'.
Changed format of bookmark-alist and therefore of bookmark files. Have version stamps in bookmark files. Automatically upgrade old bookmark files to new format. Changed name of default bookmark file to ".emacs.bmk". Replaced "Bookmark-menu" with "bookmark-bmenu". The capitalization signified nothing; "bmenu" means "buffer-menu" -- that is, bmenu code is for the dired-like of bookmarks that appears when `list-bookmarks' is run, and the "bookmark-menu" prefix is for the menu-bar. Internally, use an alist instead of hardcoded list-positions for storing bookmark information. Applied <johng@media.mit.edu>'s patches for annotation support: (bookmark-send-annotation, bookmark-read-annotation-mode) (bookmark-edit-annotation-mode, bookmark-default-annotation-text) (bookmark-read-annotation-text-func, bookmark-read-annotation) (bookmark-send-edited-annotation, bookmark-edit-annotation): New functions. (bookmark-get-bookmark, bookmark-get-bookmark-record) (bookmark-name-from-full-record, bookmark-set-name) (bookmark-get-annotation, bookmark-set-annotation) (bookmark-get-info-node, bookmark-set-info-node) (bookmark-get-filename, bookmark-set-filename) (bookmark-get-position, bookmark-set-position) (bookmark-get-front-context-string, bookmark-set-front-context-string) (bookmark-get-rear-context-string, bookmark-set-rear-context-string): New subroutines. (bookmark-file-format-version, bookmark-end-of-version-stamp-marker): New variables. (bookmark-grok-file-format-version, bookmark-maybe-upgrade-file-format) (bookmark-upgrade-version-0-alist, bookmark-upgrade-file-format-from-0) (bookmark-insert-file-format-version-stamp): New functions. (bookmark-maybe-load-default-file): Renamed from bookmark-try-default-file'. (bookmark-old-default-file): New variable. (bookmark-default-file): Renamed from `bookmark-file'. New initial value, ".emacs.bmk". (bookmark-make-cell): Use backquote. Produce with the new format (Format Version 1). Use `format' to strip text-properties. (bookmark-write-file): Use `pp' instead of `princ'. Call `bookmark-insert-file-format-version-stamp'. (bookmark-all-names, bookmark-menu-popup-paned-bookmark-menu) (bookmark-menu-build-paned-menu, bookmark-menu-popup-paned-menu) (bookmark-insert-location): New functions. (bookmark-completing-read): New function. Everyone who called `completing-read' in the interactive spec now calls this. (bookmark-load-hook): New hook. (bookmark-make-menu-alist): Function deleted. (bookmark-popup-menu-and-apply-function): replaces `bookmark-make-menu-with-function'. (bookmark-load): Use `bookmark-alist-from-buffer'. Call `bookmark-maybe-upgrade-file-format'. (bookmark-set): If Info mode, record Info-current-node. Use `bookmark-bmenu-surreptitiously-rebuild-list'. (bookmark-buffer-file-name): Handle Info files. (bookmark-buffer-name): If Info mode, return Info-current-node. (bookmark-jump-noselect): For info node, use Info-goto-node. Use the helper functions, don't mess with the raw alist (except in completion, which we'll take care of later). Don't count on `bookmark-search-size' being correct; use the length of `forward-str' and `behind-str' instead. (bookmark-relocate): Use the helper functions; don't mess with the raw alist except in completion. (bookmark-rename): C-o in minibuffer now inserts old name. (bookmark-delete): New arg BATCH. (bookmark-bmenu-execute-deletions): Was `bookmark-bmenu-execute'. Just call bookmark-delete with the BATCH arg. Set the modification count and maybe save when done. Save point intuitively. (bookmark-insert-current-file-name): Just use `file-name-nondirectory'. (bookmark-location): Made non-interactive. (bookmark-bmenu-list): Replaces `list-bookmarks'. Delete arg ANNOTATION. Use mapcar to simplify. If not interactive-p, then use `set-buffer' instead of `switch-to-buffer'. (bookmark-kill-line): New function, used instead of kill-line. (bookmark-search-size): Init to 16 instead of 500.
-rw-r--r--lisp/bookmark.el1835
1 files changed, 1273 insertions, 562 deletions
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index e8bbd30b9b0..34a3dc1513b 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -1,13 +1,19 @@
1;;; bookmark.el --- set bookmarks, jump to them later. 1;;; bookmark.el --- set bookmarks, maybe annotate them, jump to them later.
2 2
3;; Copyright (C) 1993, 1994 Free Software Foundation 3;; Copyright (C) 1993, 1994, 1995 Free Software Foundation
4 4
5;; Author: Karl Fogel <kfogel@cs.oberlin.edu> 5;; Author: Karl Fogel <kfogel@cyclic.com>
6;; Maintainer: Karl Fogel <kfogel@cs.oberlin.edu> 6;; Maintainer: Karl Fogel <kfogel@cyclic.com>
7;; Created: July, 1993 7;; Created: July, 1993
8;; Version: 2.5 8;; Version: 2.6.5
9;; Keywords: bookmarks, placeholders 9;; Keywords: bookmarks, placeholders, annotations
10 10
11;;; Summary:
12;; This package is for setting "bookmarks" in files. A bookmark
13;; associates a string with a location in a certain file. Thus, you
14;; can navigate your way to that location by providing the string.
15
16;;; Copyright info:
11;; This file is part of GNU Emacs. 17;; This file is part of GNU Emacs.
12 18
13;; GNU Emacs is free software; you can redistribute it and/or modify 19;; GNU Emacs is free software; you can redistribute it and/or modify
@@ -31,16 +37,16 @@
31;; Thanks to Gregory M. Saunders <saunders@cis.ohio-state.edu> for 37;; Thanks to Gregory M. Saunders <saunders@cis.ohio-state.edu> for
32;; fixing and improving bookmark-time-to-save-p. 38;; fixing and improving bookmark-time-to-save-p.
33 39
34;; Thanks go to Andrew V. Klein <avk@rtsg.mot.com> for the code that 40;; Thanks go to Andrew V. Klein <avk@cig.mot.com> for the code that
35;; sorts the alist before presenting it to the user (in list-bookmarks 41;; sorts the alist before presenting it to the user (in bookmark-bmenu-list
36;; and the menu-bar). 42;; and the menu-bar).
37 43
38;; And much thanks to David Hughes <djh@harston.cv.com> for many small 44;; And much thanks to David Hughes <djh@harston.cv.com> for many small
39;; suggestions and the code to implement them (like 45;; suggestions and the code to implement them (like
40;; Bookmark-menu-check-position, and some of the Lucid compatibility 46;; bookmark-bmenu-check-position, and some of the Lucid compatibility
41;; stuff). 47;; stuff).
42 48
43;; Kudos (whatever they are) go to Jim Blandy <jimb@cs.oberlin.edu> 49;; Kudos (whatever they are) go to Jim Blandy <jimb@cyclic.com>
44;; for his eminently sensible suggestion to separate bookmark-jump 50;; for his eminently sensible suggestion to separate bookmark-jump
45;; into bookmark-jump and bookmark-jump-noselect, which made many 51;; into bookmark-jump and bookmark-jump-noselect, which made many
46;; other things cleaner as well. 52;; other things cleaner as well.
@@ -53,13 +59,16 @@
53;; all the keystrokes they save thereby and send them to him at the 59;; all the keystrokes they save thereby and send them to him at the
54;; end of each year :-) (No, seriously, thanks Jonathan!) 60;; end of each year :-) (No, seriously, thanks Jonathan!)
55 61
62;; Buckets of gratitude to John Grabowski <johng@media.mit.edu> for
63;; thinking up the annotations feature and implementing it so well.
64
56;; Based on info-bookmark.el, by Karl Fogel and Ken Olstad 65;; Based on info-bookmark.el, by Karl Fogel and Ken Olstad
57;; <olstad@msc.edu>. 66;; <olstad@msc.edu>.
58 67
59;; LCD Archive Entry: 68;; LCD Archive Entry:
60;; bookmark|Karl Fogel|kfogel@cs.oberlin.edu| 69;; bookmark|Karl Fogel|kfogel@cyclic.com|
61;; Setting bookmarks in files or directories, jumping to them later.| 70;; Setting bookmarks in files or directories, jumping to them later.|
62;; 16-July-93|Version: 2.5|~/misc/bookmark.el.Z| 71;; 06-March-1995|Version: 2.6.5|~/misc/bookmark.el.Z|
63 72
64;; Enough with the credits already, get on to the good stuff: 73;; Enough with the credits already, get on to the good stuff:
65 74
@@ -67,25 +76,16 @@
67;; Boy, that's a tough one. Probably Hong Min, or maybe Emperor's 76;; Boy, that's a tough one. Probably Hong Min, or maybe Emperor's
68;; Choice (both in Chicago's Chinatown). Well, both. How about you? 77;; Choice (both in Chicago's Chinatown). Well, both. How about you?
69 78
70;;; Commentary: 79
80(require 'pp)
81
82
83;;;; Code:
71 84
72;; bookmark alist format: 85;;; Misc comments:
73;; (...
74;; (bookmark-name (filename
75;; string-in-front
76;; string-behind
77;; point))
78;; ...)
79;; 86;;
80;; bookmark-name is the string the user gives the bookmark and 87;; If variable bookmark-use-annotations is non-nil, an annotation is
81;; accesses it by from then on. filename is the location of the file 88;; queried for when setting a bookmark.
82;; in which the bookmark is set. string-in-front is a string of
83;; `bookmark-search-size' chars of context in front of the point the
84;; bookmark is set at, string-behind is the same thing after the
85;; point. bookmark-jump will search for string-behind and
86;; string-in-front in case the file has changed since the bookmark was
87;; set. It will attempt to place the user before the changes, if
88;; there were any.
89;; 89;;
90;; The bookmark list is sorted lexically by default, but you can turn 90;; The bookmark list is sorted lexically by default, but you can turn
91;; this off by setting bookmark-sort-flag to nil. If it is nil, then 91;; this off by setting bookmark-sort-flag to nil. If it is nil, then
@@ -100,18 +100,20 @@
100;; suggested for lucid compatibility by david hughes: 100;; suggested for lucid compatibility by david hughes:
101(or (fboundp 'frame-height) (fset 'frame-height 'screen-height)) 101(or (fboundp 'frame-height) (fset 'frame-height 'screen-height))
102 102
103
104
105;;; Keymap stuff:
103;; some people have C-x r set to rmail or whatever. We don't want to 106;; some people have C-x r set to rmail or whatever. We don't want to
104;; assume that C-x r is a prefix map just because it's distributed 107;; assume that C-x r is a prefix map just because it's distributed
105;; that way... 108;; that way...
106;; These are the distribution keybindings suggested by RMS, everything 109;; These are the distribution keybindings suggested by RMS, everything
107;; else will be done with M-x or the menubar: 110;; else will be done with M-x or the menubar:
108;;;###autoload 111;;;###autoload
109(if (or (symbolp (key-binding "\C-xr")) 112(if (symbolp (key-binding "\C-xr"))
110 (fboundp 'bookmark-set))
111 nil 113 nil
112 (progn (define-key ctl-x-map "rb" 'bookmark-jump) 114 (progn (define-key ctl-x-map "rb" 'bookmark-jump)
113 (define-key ctl-x-map "rm" 'bookmark-set) 115 (define-key ctl-x-map "rm" 'bookmark-set)
114 (define-key ctl-x-map "rl" 'list-bookmarks))) 116 (define-key ctl-x-map "rl" 'bookmark-bmenu-list)))
115 117
116;; define the map, so it can be bound by those who desire to do so: 118;; define the map, so it can be bound by those who desire to do so:
117 119
@@ -123,6 +125,10 @@ so that you have a bookmark prefix, just use `global-set-key' and bind a
123key of your choice to `bookmark-map'. All interactive bookmark 125key of your choice to `bookmark-map'. All interactive bookmark
124functions have a binding in this keymap.") 126functions have a binding in this keymap.")
125 127
128(defvar bookmark-use-annotations nil
129 "*If non-nil, saving a bookmark will query for an annotation in a
130buffer.")
131
126;;;###autoload 132;;;###autoload
127(define-prefix-command 'bookmark-map) 133(define-prefix-command 'bookmark-map)
128 134
@@ -140,7 +146,7 @@ functions have a binding in this keymap.")
140;;;###autoload 146;;;###autoload
141(define-key bookmark-map "e" 'edit-bookmarks) 147(define-key bookmark-map "e" 'edit-bookmarks)
142;;;###autoload 148;;;###autoload
143(define-key bookmark-map "f" 'bookmark-locate) ; "f" for "find" 149(define-key bookmark-map "f" 'bookmark-insert-location) ; "f" for "find"
144;;;###autoload 150;;;###autoload
145(define-key bookmark-map "r" 'bookmark-rename) 151(define-key bookmark-map "r" 'bookmark-rename)
146;;;###autoload 152;;;###autoload
@@ -152,15 +158,29 @@ functions have a binding in this keymap.")
152;;;###autoload 158;;;###autoload
153(define-key bookmark-map "s" 'bookmark-save) 159(define-key bookmark-map "s" 'bookmark-save)
154 160
161
162;;; The annotation maps.
163(defvar bookmark-read-annotation-mode-map (copy-keymap text-mode-map)
164 "Keymap for composing an annotation for a bookmark.")
165
166(define-key bookmark-read-annotation-mode-map "\C-c\C-c"
167 'bookmark-send-annotation)
168
169
170
171;;; Core variables and data structures:
155(defvar bookmark-alist () 172(defvar bookmark-alist ()
156 "Association list of bookmarks. 173 "Association list of bookmarks and their records.
157You probably don't want to change the value of this alist yourself; 174You probably don't want to change the value of this alist yourself;
158instead, let the various bookmark functions do it for you.") 175instead, let the various bookmark functions do it for you.")
159 176
177
160(defvar bookmarks-already-loaded nil) 178(defvar bookmarks-already-loaded nil)
161 179
180
162;; just add the hook to make sure that people don't lose bookmarks 181;; just add the hook to make sure that people don't lose bookmarks
163;; when they kill Emacs, unless they don't want to save them. 182;; when they kill Emacs, unless they don't want to save them.
183;;;###autoload
164(add-hook 'kill-emacs-hook 184(add-hook 'kill-emacs-hook
165 (function 185 (function
166 (lambda () (and (featurep 'bookmark) 186 (lambda () (and (featurep 'bookmark)
@@ -177,9 +197,10 @@ through a file easier.")
177 197
178(make-variable-buffer-local 'bookmark-current-bookmark) 198(make-variable-buffer-local 'bookmark-current-bookmark)
179 199
200
180(defvar bookmark-save-flag t 201(defvar bookmark-save-flag t
181 "*Controls when Emacs saves bookmarks to a file. 202 "*Controls when Emacs saves bookmarks to a file.
182--> nil means never save bookmarks, except when `bookmark-save' is 203--> Nil means never save bookmarks, except when `bookmark-save' is
183 explicitly called \(\\[bookmark-save]\). 204 explicitly called \(\\[bookmark-save]\).
184--> t means save bookmarks when Emacs is killed. 205--> t means save bookmarks when Emacs is killed.
185--> Otherise, it should be a number that is the frequency with which 206--> Otherise, it should be a number that is the frequency with which
@@ -193,42 +214,419 @@ bookmark is to set this variable to 1 \(or 0, which produces the same
193behavior.\) 214behavior.\)
194 215
195To specify the file in which to save them, modify the variable 216To specify the file in which to save them, modify the variable
196bookmark-file, which is `~/.emacs-bkmrks' by default.") 217bookmark-default-file, which is `~/.emacs.bmk' by default.")
218
197 219
198(defvar bookmark-alist-modification-count 0 220(defvar bookmark-alist-modification-count 0
199 "Number of modifications to bookmark list since it was last saved.") 221 "Number of modifications to bookmark list since it was last saved.")
200 222
201(defvar bookmark-file 223
202 (if (or (eq system-type 'ms-dos) (eq system-type 'windows-nt)) 224(defconst bookmark-old-default-file "~/.emacs-bkmrks"
203 "~/emacs.bmk" ; Cannot have initial dot [Yuck!] 225 "*The .emacs.bmk file used to be called this.")
204 "~/.emacs-bkmrks") 226
227
228(defvar bookmark-default-file
229 (if (and (boundp 'bookmark-file) bookmark-file)
230 ;; In case user set `bookmark-file' in her .emacs:
231 bookmark-file
232 (if (eq system-type 'ms-dos)
233 "~/emacs.bmk" ; Cannot have initial dot [Yuck!]
234 "~/.emacs.bmk"))
205 "*File in which to save bookmarks by default.") 235 "*File in which to save bookmarks by default.")
206 236
237
207(defvar bookmark-version-control 'nospecial 238(defvar bookmark-version-control 'nospecial
208 "Control whether to make numbered backups of the master bookmark file. 239 "This variable controls whether or not to make numbered backups of
209This variable can have four values: t, nil, `never', and `nospecial'. 240the master bookmark file. It can have four values: t, nil, never, and
210The first three have the same meaning that they do for the 241nospecial. The first three have the same meaning that they do for the
211variable `version-control'. 242variable version-control, and the final value nospecial means just use
212The value `nospecial' means just use the value of `version-control'.") 243the value of version-control.")
244
213 245
214(defvar bookmark-completion-ignore-case t 246(defvar bookmark-completion-ignore-case t
215 "*Non-nil means bookmark functions ignore case in completion.") 247 "*Non-nil means bookmark functions ignore case in completion.")
216 248
249
217(defvar bookmark-sort-flag t 250(defvar bookmark-sort-flag t
218 "*Non-nil means display bookmarks sorted by name. 251 "*Non-nil means that bookmarks will be displayed sorted by bookmark
219Otherwise they are displayed in LIFO order (that is, most 252name. Otherwise they will be displayed in LIFO order (that is, most
220recently set ones come first, oldest ones come last).") 253recently set ones come first, oldest ones come last).")
221 254
222(defvar bookmark-search-size 500 255
256(defvar bookmark-search-size 16
223 "Length of the context strings recorded on either side of a bookmark.") 257 "Length of the context strings recorded on either side of a bookmark.")
224 258
259
225(defvar bookmark-current-point 0) 260(defvar bookmark-current-point 0)
226(defvar bookmark-yank-point 0) 261(defvar bookmark-yank-point 0)
227(defvar bookmark-current-buffer nil) 262(defvar bookmark-current-buffer nil)
228 263
264
265
266;; Helper functions.
267
268;; Only functions on this page and the next one (file formats) need to
269;; know anything about the format of bookmark-alist entries.
270;; Everyone else should go through them.
271
272(defun bookmark-name-from-full-record (full-record)
273 "Return name of BOOKMARK \(an alist element instead of a string\)."
274 (car full-record))
275
276
277(defun bookmark-all-names ()
278 "Return a list of all current bookmark names."
279 (bookmark-maybe-load-default-file)
280 (mapcar
281 (lambda (full-record)
282 (bookmark-name-from-full-record full-record))
283 bookmark-alist))
284
285
286(defun bookmark-get-bookmark (bookmark)
287 "Return the full entry for BOOKMARK in bookmark-alist."
288 (assoc bookmark bookmark-alist))
289
290
291(defun bookmark-get-bookmark-record (bookmark)
292 "Return the guts of the entry for BOOKMARK in bookmark-alist.
293That is, all information but the name."
294 (car (cdr (bookmark-get-bookmark bookmark))))
295
296
297(defun bookmark-set-name (bookmark newname)
298 "Set BOOKMARK's name to NEWNAME."
299 (setcar (bookmark-get-bookmark bookmark) newname))
300
301
302(defun bookmark-get-annotation (bookmark)
303 "Return the annotation of BOOKMARK, or nil if none."
304 (cdr (assq 'annotation (bookmark-get-bookmark-record bookmark))))
305
306
307(defun bookmark-set-annotation (bookmark ann)
308 "Set the annotation of BOOKMARK."
309 (let ((cell (assq 'annotation (bookmark-get-bookmark-record bookmark))))
310 (if cell
311 (setcdr cell ann)
312 (nconc (bookmark-get-bookmark-record bookmark)
313 (list (cons 'annotation ann))))))
314
315
316(defun bookmark-get-filename (bookmark)
317 "Return the full filename of BOOKMARK."
318 (cdr (assq 'filename (bookmark-get-bookmark-record bookmark))))
319
320
321(defun bookmark-set-filename (bookmark filename)
322 "Set the full filename of BOOKMARK to FILENAME."
323 (let ((cell (assq 'filename (bookmark-get-bookmark-record bookmark))))
324 (if cell
325 (setcdr cell filename)
326 (nconc (bookmark-get-bookmark-record bookmark)
327 (list (cons 'filename filename))))))
328
329
330(defun bookmark-get-position (bookmark)
331 "Return the position \(i.e.: point\) of BOOKMARK."
332 (cdr (assq 'position (bookmark-get-bookmark-record bookmark))))
333
334
335(defun bookmark-set-position (bookmark position)
336 "Set the position \(i.e.: point\) of BOOKMARK to POSITION."
337 (let ((cell (assq 'position (bookmark-get-bookmark-record bookmark))))
338 (if cell
339 (setcdr cell position)
340 (nconc (bookmark-get-bookmark-record bookmark)
341 (list (cons 'position position))))))
342
343
344(defun bookmark-get-front-context-string (bookmark)
345 "Return the front-context-string of BOOKMARK."
346 (cdr (assq 'front-context-string (bookmark-get-bookmark-record bookmark))))
347
348
349(defun bookmark-set-front-context-string (bookmark string)
350 "Set the front-context-string of BOOKMARK to STRING."
351 (let ((cell (assq 'front-context-string
352 (bookmark-get-bookmark-record bookmark))))
353 (if cell
354 (setcdr cell string)
355 (nconc (bookmark-get-bookmark-record bookmark)
356 (list (cons 'front-context-string string))))))
357
358
359(defun bookmark-get-rear-context-string (bookmark)
360 "Return the rear-context-string of BOOKMARK."
361 (cdr (assq 'rear-context-string (bookmark-get-bookmark-record bookmark))))
362
363
364(defun bookmark-set-rear-context-string (bookmark string)
365 "Set the rear-context-string of BOOKMARK to STRING."
366 (let ((cell (assq 'rear-context-string
367 (bookmark-get-bookmark-record bookmark))))
368 (if cell
369 (setcdr cell string)
370 (nconc (bookmark-get-bookmark-record bookmark)
371 (list (cons 'rear-context-string string))))))
372
373
374(defun bookmark-get-info-node (bookmark)
375 (cdr (assq 'info-node (bookmark-get-bookmark-record bookmark))))
376
377
378(defun bookmark-set-info-node (bookmark node)
379 "Set the Info node of BOOKMARK to NODE."
380 (let ((cell (assq 'info-node
381 (bookmark-get-bookmark-record bookmark))))
382 (if cell
383 (setcdr cell node)
384 (nconc (bookmark-get-bookmark-record bookmark)
385 (list (cons 'info-node node))))))
386
387
388(defun bookmark-completing-read (prompt &optional default)
389 "Prompting with PROMPT, read a bookmark name in completion.
390PROMPT will get a \": \" stuck on the end no matter what, so you
391probably don't want to include one yourself.
392Optional second arg DEFAULT is a string to return if the user enters
393the empty string."
394 (bookmark-maybe-load-default-file) ; paranoia
395 (let* ((completion-ignore-case bookmark-completion-ignore-case)
396 (default default)
397 (prompt (if default
398 (concat prompt (format " (%s): " default))
399 (concat prompt ": ")))
400 (str
401 (completing-read prompt
402 bookmark-alist
403 nil
404 0)))
405 (if (string-equal "" str)
406 (list default)
407 (list str))))
408
409
410(defun bookmark-make (str &optional annotation overwrite)
411 "Make a bookmark named NAME.
412Optional second arg ANNOTATION gives it an annotation.
413Optional third arg OVERWRITE means replace any existing bookmarks with
414this name."
415 (bookmark-maybe-load-default-file)
416 (if (and (bookmark-get-bookmark str) (not overwrite))
417 ;; already existing boookmark under that name and
418 ;; no prefix arg means just overwrite old bookmark
419 (setcdr (bookmark-get-bookmark str)
420 (list (bookmark-make-cell annotation)))
421
422 ;; otherwise just cons it onto the front (either the bookmark
423 ;; doesn't exist already, or there is no prefix arg. In either
424 ;; case, we want the new bookmark consed onto the alist...)
425
426 (setq bookmark-alist
427 (cons
428 (list str
429 (bookmark-make-cell annotation))
430 bookmark-alist)))
431
432 ;; Added by db
433 (setq bookmark-current-bookmark str)
434 (setq bookmark-alist-modification-count
435 (1+ bookmark-alist-modification-count))
436 (if (bookmark-time-to-save-p)
437 (bookmark-save)))
438
439
440(defun bookmark-make-cell (annotation)
441 "Return the record part of a bookmark.
442Must be at the correct position in the buffer in which the bookmark is
443being set. This will change soon.
444Takes ANNOTATION as an argument."
445 (` ((filename . (, (bookmark-buffer-file-name)))
446 (front-context-string
447 . (, (if (>= (- (point-max) (point)) bookmark-search-size)
448 ;; strip text props via `format':
449 (format "%s"
450 (buffer-substring
451 (point)
452 (+ (point) bookmark-search-size)))
453 nil)))
454 (rear-context-string
455 . (, (if (>= (- (point) (point-min)) bookmark-search-size)
456 ;; strip text props via `format':
457 (format "%s"
458 (buffer-substring
459 (point)
460 (- (point) bookmark-search-size)))
461 nil)))
462 (position . (, (point)))
463 (annotation . (, annotation)))))
464
465
466;;; File format stuff
467
468;; The OLD format of the bookmark-alist was:
469;;
470;; ((bookmark-name (filename
471;; string-in-front
472;; string-behind
473;; point))
474;; ...)
475;;
476;; The NEW format of the bookmark-alist is:
477;;
478;; ((bookmark-name ((filename . FILENAME)
479;; (front-context-string . string-in-front)
480;; (rear-context-string . string-behind)
481;; (position . POINT)
482;; (annotation . annotation)
483;; (whatever . VALUE)
484;; ...
485;; ))
486;; ...)
487;;
488;;
489;; I switched to using an internal as well as external alist because I
490;; felt that would be a more flexible framework in which to add
491;; features. It means that the order in which values appear doesn't
492;; matter, and it means that arbitrary values can be added without
493;; risk of interfering with existing ones.
494;;
495;; BOOKMARK-NAME is the string the user gives the bookmark and
496;; accesses it by from then on.
497;;
498;; FILENAME is the location of the file in which the bookmark is set.
499;;
500;; STRING-IN-FRONT is a string of `bookmark-search-size' chars of
501;; context in front of the point at which the bookmark is set.
502;;
503;; STRING-BEHIND is the same thing, but after the point.
504;;
505;; The context strings exist so that modifications to a file don't
506;; necessarily cause a bookmark's position to be invalidated.
507;; bookmark-jump will search for STRING-BEHIND and STRING-IN-FRONT in
508;; case the file has changed since the bookmark was set. It will
509;; attempt to place the user before the changes, if there were any.
510;; annotation is the annotation for the bookmark; it may not exist
511;; (for backward compatibility), be nil (no annotation), or be a
512;; string.
513;;
514;; ANNOTATION is an annotation for the bookmark.
515
516
517(defconst bookmark-file-format-version 1
518 "The current version of the format used by bookmark files.
519You should never need to change this.")
520
521
522(defconst bookmark-end-of-version-stamp-marker
523 "-*- End Of Bookmark File Format Version Stamp -*-\n"
524 "This string marks the end of the version stamp in a bookmark file.")
525
526
527(defun bookmark-alist-from-buffer ()
528 "Return a bookmark-alist (in any format) from the current buffer.
529The buffer must of course contain bookmark format information.
530Does not care from where in the buffer it is called, and does not
531affect point."
532 (save-excursion
533 (goto-char (point-min))
534 (if (search-forward bookmark-end-of-version-stamp-marker nil t)
535 (read (current-buffer))
536 ;; Else we're dealing with format version 0
537 (if (search-forward "(" nil t)
538 (progn
539 (forward-char -1)
540 (read (current-buffer)))
541 ;; Else no hope of getting information here.
542 (error "Not bookmark format.")))))
543
544
545(defun bookmark-upgrade-version-0-alist (old-list)
546 "Upgrade a version 0 alist to the current version."
547 (mapcar
548 (lambda (bookmark)
549 (let* ((name (car bookmark))
550 (record (car (cdr bookmark)))
551 (filename (nth 0 record))
552 (front-str (nth 1 record))
553 (rear-str (nth 2 record))
554 (position (nth 3 record))
555 (ann (nth 4 record)))
556 (list
557 name
558 (` ((filename . (, filename))
559 (front-context-string . (, (or front-str "")))
560 (rear-context-string . (, (or rear-str "")))
561 (position . (, position))
562 (annotation . (, ann)))))))
563 old-list))
564
565
566(defun bookmark-upgrade-file-format-from-0 ()
567 "Upgrade a bookmark file of format 0 (the original format) to format 1.
568This expects to be called from point-min in a bookmark file."
569 (message "Upgrading bookmark format from 0 to %d..."
570 bookmark-file-format-version)
571 (let* ((old-list (bookmark-alist-from-buffer))
572 (new-list (bookmark-upgrade-version-0-alist old-list)))
573 (delete-region (point-min) (point-max))
574 (bookmark-insert-file-format-version-stamp)
575 (pp new-list (current-buffer))
576 (save-buffer))
577 (goto-char (point-min))
578 (message "Upgrading bookmark format from 0 to %d... done."
579 bookmark-file-format-version)
580 )
581
582
583(defun bookmark-grok-file-format-version ()
584 "Return an integer which is the file-format version of this bookmark file.
585This expects to be called from point-min in a bookmark file."
586 (if (looking-at "^;;;;")
587 (save-excursion
588 (save-match-data
589 (re-search-forward "[0-9]")
590 (forward-char -1)
591 (read (current-buffer))))
592 ;; Else this is format version 0, the original one, which didn't
593 ;; even have version stamps.
594 0))
595
596
597(defun bookmark-maybe-upgrade-file-format ()
598 "Check the file-format version of this bookmark file.
599If the version is not up-to-date, upgrade it automatically.
600This expects to be called from point-min in a bookmark file."
601 (let ((version (bookmark-grok-file-format-version)))
602 (cond
603 ((= version bookmark-file-format-version)
604 ) ; home free -- version is current
605 ((= version 0)
606 (bookmark-upgrade-file-format-from-0))
607 (t
608 (error "Bookmark file format version strangeness.")))))
609
610
611(defun bookmark-insert-file-format-version-stamp ()
612 "Insert text indicating current version of bookmark file-format."
613 (insert
614 (format ";;;; Emacs Bookmark Format Version %d ;;;;\n"
615 bookmark-file-format-version))
616 (insert ";;; This format is meant to be slightly human-readable;\n"
617 ";;; nevertheless, you probably don't want to edit it.\n"
618 ";;; "
619 bookmark-end-of-version-stamp-marker))
620
621
622;;; end file-format stuff
623
624
625;;; Core code:
626
229;;;###autoload 627;;;###autoload
230(defun bookmark-set (&optional parg) 628(defun bookmark-set (&optional parg)
231 "Set a bookmark named NAME inside the visited file. 629 "Set a bookmark named NAME inside a file.
232With prefix arg, will not overwrite a bookmark that has the same name 630With prefix arg, will not overwrite a bookmark that has the same name
233as NAME if such a bookmark already exists, but instead will \"push\" 631as NAME if such a bookmark already exists, but instead will \"push\"
234the new bookmark onto the bookmark alist. Thus the most recently set 632the new bookmark onto the bookmark alist. Thus the most recently set
@@ -240,7 +638,7 @@ To yank words from the text of the buffer and use them as part of the
240bookmark name, type C-w while setting a bookmark. Successive C-w's 638bookmark name, type C-w while setting a bookmark. Successive C-w's
241yank successive words. 639yank successive words.
242 640
243Typing C-v inserts the name of the current file being visited. Typing 641Typing C-v inserts the name of the current file being visited. Typing
244C-u inserts the name of the last bookmark used in the buffer \(as an 642C-u inserts the name of the last bookmark used in the buffer \(as an
245aid in using a single bookmark name to track your progress through a 643aid in using a single bookmark name to track your progress through a
246large file\). If no bookmark was used, then C-u behaves like C-v and 644large file\). If no bookmark was used, then C-u behaves like C-v and
@@ -250,14 +648,18 @@ Use \\[bookmark-delete] to remove bookmarks \(you give it a name,
250and it removes only the first instance of a bookmark with that name from 648and it removes only the first instance of a bookmark with that name from
251the list of bookmarks.\)" 649the list of bookmarks.\)"
252 (interactive "P") 650 (interactive "P")
253 (if (not (bookmark-buffer-file-name)) 651 (or
254 (error "Buffer not visiting a file or directory.")) 652 (bookmark-buffer-file-name)
255 (bookmark-try-default-file) 653 (error "Buffer not visiting a file or directory."))
654
655 (bookmark-maybe-load-default-file)
656
256 (setq bookmark-current-point (point)) 657 (setq bookmark-current-point (point))
257 (setq bookmark-yank-point (point)) 658 (setq bookmark-yank-point (point))
258 (setq bookmark-current-buffer (current-buffer)) 659 (setq bookmark-current-buffer (current-buffer))
660
259 (let* ((default (or bookmark-current-bookmark 661 (let* ((default (or bookmark-current-bookmark
260 (buffer-name (current-buffer)))) 662 (bookmark-buffer-name)))
261 (str 663 (str
262 (read-from-minibuffer 664 (read-from-minibuffer
263 (format "Set bookmark (%s): " default) 665 (format "Set bookmark (%s): " default)
@@ -269,16 +671,167 @@ the list of bookmarks.\)"
269 'bookmark-insert-current-file-name) 671 'bookmark-insert-current-file-name)
270 (define-key now-map "\C-u" 672 (define-key now-map "\C-u"
271 'bookmark-insert-current-bookmark)) 673 'bookmark-insert-current-bookmark))
272 now-map)))) 674 now-map)))
273 (and (string-equal str "") (setq str default)) 675 (annotation nil))
274 (progn 676 (and (string-equal str "") (setq str default))
275 (bookmark-make parg str) 677 ;; Ask for an annotation buffer for this bookmark
276 (setq bookmark-current-bookmark str) 678 (if bookmark-use-annotations
277 (if (get-buffer "*Bookmark List*") ;rebuild the bookmark list 679 (bookmark-read-annotation parg str)
278 (save-excursion 680 (progn
279 (save-window-excursion 681 (bookmark-make str annotation parg)
280 (list-bookmarks)))) 682 ;; In Info, there's a little more information to record:
281 (goto-char bookmark-current-point)))) 683 (if (eq major-mode 'Info-mode)
684 (bookmark-set-info-node str Info-current-node))
685 (setq bookmark-current-bookmark str)
686 (bookmark-bmenu-surreptitiously-rebuild-list)
687 (goto-char bookmark-current-point)))))
688
689
690(defun bookmark-kill-line (&optional newline-too)
691 "Kill from point to end of line.
692If optional arg NEWLINE-TOO is non-nil, delete the newline too.
693Does not affect the kill-ring."
694 (let ((eol (save-excursion (end-of-line) (point))))
695 (delete-region (point) eol)
696 (if (and newline-too (looking-at "\n"))
697 (delete-char 1))))
698
699
700(defun bookmark-send-annotation ()
701 "After remove lines beginning with '#', use the contents of this buffer
702as the annotation for a bookmark, and store it in the bookmark list with
703the bookmark (and file, and point) specified in buffer local variables."
704 (interactive)
705 (if (not (eq major-mode 'bookmark-read-annotation-mode))
706 (error "Not in bookmark-read-annotation-mode."))
707 (goto-char (point-min))
708 (while (< (point) (point-max))
709 (if (looking-at "^#")
710 (bookmark-kill-line t)
711 (forward-line 1)))
712 (let ((annotation (buffer-substring (point-min) (point-max)))
713 (parg bookmark-annotation-paragraph)
714 (bookmark bookmark-annotation-name)
715 (pt bookmark-annotation-point)
716 (buf bookmark-annotation-buffer))
717 ;; for bookmark-make-cell to work, we need to be
718 ;; in the relevant buffer, at the relevant point.
719 ;; Actually, bookmark-make-cell should probably be re-written,
720 ;; to avoid this need. Should I handle the error if a buffer is
721 ;; killed between "C-x r m" and a "C-c C-c" in the annotation buffer?
722 (save-excursion
723 (pop-to-buffer buf)
724 (goto-char pt)
725 (bookmark-make bookmark annotation parg)
726 (setq bookmark-current-bookmark bookmark))
727 (bookmark-bmenu-surreptitiously-rebuild-list)
728 (goto-char bookmark-current-point))
729 (kill-buffer (current-buffer)))
730
731
732(defun bookmark-default-annotation-text (bookmark)
733 (concat "# Type the annotation for bookmark '" bookmark "' here.\n"
734 "# All lines which start with a '#' will be deleted.\n"
735 "# Type C-c C-c when done.\n#\n"
736 "# Author: " (user-full-name) " <" (user-login-name) "@"
737 (system-name) ">\n"
738 "# Date: " (current-time-string) "\n"))
739
740
741(defvar bookmark-read-annotation-text-func 'bookmark-default-annotation-text
742 "A variable containing a function which returns the text to insert
743into an annotation compisition buffer. It takes the name of the bookmark,
744as a string, as an arg.")
745
746
747(defun bookmark-read-annotation-mode (buf point parg bookmark)
748 "Mode for composing annotations for a bookmark.
749When you have finished composing, type \\[bookmark-send-annotation] to send
750the annotation.
751
752\\{bookmark-read-annotation-mode-map}
753"
754 (interactive)
755 (kill-all-local-variables)
756 (make-local-variable 'bookmark-annotation-paragraph)
757 (make-local-variable 'bookmark-annotation-name)
758 (make-local-variable 'bookmark-annotation-buffer)
759 (make-local-variable 'bookmark-annotation-file)
760 (make-local-variable 'bookmark-annotation-point)
761 (setq bookmark-annotation-paragraph parg)
762 (setq bookmark-annotation-name bookmark)
763 (setq bookmark-annotation-buffer buf)
764 (setq bookmark-annotation-file (buffer-file-name buf))
765 (setq bookmark-annotation-point point)
766 (use-local-map bookmark-read-annotation-mode-map)
767 (setq major-mode 'bookmark-read-annotation-mode)
768 (insert (funcall bookmark-read-annotation-text-func bookmark))
769 (run-hooks 'text-mode-hook))
770
771
772(defun bookmark-read-annotation (parg bookmark)
773 "Pop up a buffer for entering a bookmark annotation. Text surrounding
774the bookmark is PARG; the bookmark name is BOOKMARK."
775 (let ((buf (current-buffer))
776 (point (point)))
777 (pop-to-buffer (generate-new-buffer-name "*Bookmark Annotation Compose*"))
778 (bookmark-read-annotation-mode buf point parg bookmark)))
779
780
781(defvar bookmark-edit-annotation-mode-map (copy-keymap text-mode-map)
782 "Keymap for editing an annotation of a bookmark.")
783
784
785(define-key bookmark-edit-annotation-mode-map "\C-c\C-c"
786 'bookmark-send-edited-annotation)
787
788
789(defun bookmark-edit-annotation-mode (bookmark)
790 "Mode for editing the annotation of bookmark BOOKMARK.
791When you have finished composing, type \\[bookmark-send-annotation].
792
793\\{bookmark-edit-annotation-mode-map}
794"
795 (interactive)
796 (kill-all-local-variables)
797 (make-local-variable 'bookmark-annotation-name)
798 (setq bookmark-annotation-name bookmark)
799 (use-local-map bookmark-edit-annotation-mode-map)
800 (setq major-mode 'bookmark-edit-annotation-mode)
801 (insert (funcall bookmark-read-annotation-text-func bookmark))
802 (let ((annotation (bookmark-get-annotation bookmark)))
803 (if (and (not (eq annotation nil))
804 (not (string-equal annotation "")))
805 (insert annotation)))
806 (run-hooks 'text-mode-hook))
807
808
809(defun bookmark-send-edited-annotation ()
810 "After remove lines beginning with '#', use the contents of this buffer
811as the new annotation for a bookmark."
812 (interactive)
813 (if (not (eq major-mode 'bookmark-edit-annotation-mode))
814 (error "Not in bookmark-edit-annotation-mode."))
815 (goto-char (point-min))
816 (while (< (point) (point-max))
817 (if (looking-at "^#")
818 (bookmark-kill-line t)
819 (forward-line 1)))
820 (let ((annotation (buffer-substring (point-min) (point-max)))
821 (bookmark bookmark-annotation-name))
822 (bookmark-set-annotation bookmark annotation)
823 (bookmark-bmenu-surreptitiously-rebuild-list)
824 (goto-char bookmark-current-point))
825 (kill-buffer (current-buffer)))
826
827
828(defun bookmark-edit-annotation (bookmark)
829 "Pop up a buffer for editing bookmark BOOKMARK's annotation."
830 (let ((buf (current-buffer))
831 (point (point)))
832 (pop-to-buffer (generate-new-buffer-name "*Bookmark Annotation Compose*"))
833 (bookmark-edit-annotation-mode bookmark)))
834
282 835
283(defun bookmark-insert-current-bookmark () 836(defun bookmark-insert-current-bookmark ()
284 ;; insert this buffer's value of bookmark-current-bookmark, default 837 ;; insert this buffer's value of bookmark-current-bookmark, default
@@ -290,18 +843,17 @@ the list of bookmarks.\)"
290 bookmark-current-bookmark))) 843 bookmark-current-bookmark)))
291 (if str (insert str) (bookmark-insert-current-file-name)))) 844 (if str (insert str) (bookmark-insert-current-file-name))))
292 845
846
293(defun bookmark-insert-current-file-name () 847(defun bookmark-insert-current-file-name ()
294 ;; insert the name (sans path) of the current file into the bookmark 848 ;; insert the name (sans path) of the current file into the bookmark
295 ;; name that is being set. 849 ;; name that is being set.
296 (interactive) 850 (interactive)
297 (let ((str (save-excursion 851 (let ((str
298 (set-buffer bookmark-current-buffer) 852 (save-excursion
299 (bookmark-buffer-file-name)))) 853 (set-buffer bookmark-current-buffer)
300 (insert (substring 854 (file-name-nondirectory (bookmark-buffer-file-name)))))
301 str 855 (insert str)))
302 (1+ (string-match 856
303 "\\(/[^/]*\\)/*$"
304 str))))))
305 857
306(defun bookmark-yank-word () 858(defun bookmark-yank-word ()
307 (interactive) 859 (interactive)
@@ -317,63 +869,54 @@ the list of bookmarks.\)"
317 (setq bookmark-yank-point (point))))))) 869 (setq bookmark-yank-point (point)))))))
318 (insert string))) 870 (insert string)))
319 871
320(defun bookmark-make (parg str)
321 (if (and (assoc str bookmark-alist) (not parg))
322 ;; already existing boookmark under that name and
323 ;; no prefix arg means just overwrite old bookmark
324 (setcdr (assoc str bookmark-alist)
325 (list (bookmark-make-cell)))
326
327 ;; otherwise just cons it onto the front (either the bookmark
328 ;; doesn't exist already, or there is no prefix arg. In either
329 ;; case, we want the new bookmark consed onto the alist...)
330
331 (setq bookmark-alist
332 (cons
333 (list str
334 (bookmark-make-cell))
335 bookmark-alist)))
336 ;; Added by db
337 (setq bookmark-current-bookmark str)
338 (setq bookmark-alist-modification-count
339 (1+ bookmark-alist-modification-count))
340 (if (bookmark-time-to-save-p)
341 (bookmark-save)))
342
343(defun bookmark-make-cell ()
344 ;; make the cell that is the cdr of a bookmark alist element. It
345 ;; looks like this:
346 ;; (filename search-forward-str search-back-str point)
347 (list
348 (bookmark-buffer-file-name)
349 (if (>= (- (point-max) (point)) bookmark-search-size)
350 (buffer-substring
351 (point)
352 (+ (point) bookmark-search-size))
353 nil)
354 (if (>= (- (point) (point-min)) bookmark-search-size)
355 (buffer-substring
356 (point)
357 (- (point) bookmark-search-size))
358 nil)
359 (point)))
360 872
361(defun bookmark-buffer-file-name () 873(defun bookmark-buffer-file-name ()
362 (or 874 "Return the current buffer's file in a way useful for bookmarks.
363 buffer-file-name 875For example, if this is a Info buffer, return the Info file's name."
364 (if (and (boundp 'dired-directory) dired-directory) 876 (if (eq major-mode 'Info-mode)
365 (if (stringp dired-directory) 877 Info-current-file
366 dired-directory 878 (or
367 (car dired-directory))))) 879 buffer-file-name
368 880 (if (and (boundp 'dired-directory) dired-directory)
369(defun bookmark-try-default-file () 881 (if (stringp dired-directory)
882 dired-directory
883 (car dired-directory))))))
884
885
886(defun bookmark-buffer-name ()
887 "Return the name of the current buffer in a way useful for bookmarks.
888For example, if this is a Info buffer, return the Info node's name."
889 (if (string-equal mode-name "Info")
890 Info-current-node
891 (or
892 buffer-file-name
893 (if (and (boundp 'dired-directory) dired-directory)
894 (if (stringp dired-directory)
895 dired-directory
896 (car dired-directory))))))
897
898
899(defun bookmark-maybe-load-default-file ()
370 (and (not bookmarks-already-loaded) 900 (and (not bookmarks-already-loaded)
371 (null bookmark-alist) 901 (null bookmark-alist)
372 (file-readable-p (expand-file-name bookmark-file)) 902
903 (prog2
904 (and
905 ;; Possibly the old bookmark file, "~/.emacs-bkmrks", needs
906 ;; to be renamed.
907 (file-exists-p (expand-file-name bookmark-old-default-file))
908 (not (file-exists-p (expand-file-name bookmark-default-file)))
909 (rename-file (expand-file-name bookmark-old-default-file)
910 (expand-file-name bookmark-default-file)))
911 ;; return t so the `and' will continue...
912 t)
913
914 (file-readable-p (expand-file-name bookmark-default-file))
373 (progn 915 (progn
374 (bookmark-load bookmark-file t t) 916 (bookmark-load bookmark-default-file t t)
375 (setq bookmarks-already-loaded t)))) 917 (setq bookmarks-already-loaded t))))
376 918
919
377(defun bookmark-maybe-sort-alist () 920(defun bookmark-maybe-sort-alist ()
378 ;;Return the bookmark-alist for display. If the bookmark-sort-flag 921 ;;Return the bookmark-alist for display. If the bookmark-sort-flag
379 ;;is non-nil, then return a sorted copy of the alist. 922 ;;is non-nil, then return a sorted copy of the alist.
@@ -383,6 +926,7 @@ the list of bookmarks.\)"
383 (function 926 (function
384 (lambda (x y) (string-lessp (car x) (car y)))))))) 927 (lambda (x y) (string-lessp (car x) (car y))))))))
385 928
929
386;;;###autoload 930;;;###autoload
387(defun bookmark-jump (str) 931(defun bookmark-jump (str)
388 "Jump to bookmark BOOKMARK (a point in some file). 932 "Jump to bookmark BOOKMARK (a point in some file).
@@ -391,131 +935,116 @@ You may have a problem using this function if the value of variable
391bookmarks. See help on function `bookmark-load' for more about 935bookmarks. See help on function `bookmark-load' for more about
392this. 936this.
393 937
394If the file pointed to by BOOKMARK no longer exists, `bookmark-jump' 938If the file pointed to by BOOKMARK no longer exists, you will be asked
395asks you to specify a different file to use instead. If you specify 939if you wish to give the bookmark a new location, and bookmark-jump
396one, it also updates BOOKMARK to refer to that file." 940will then jump to the new location, as well as recording it in place
397 (interactive (progn (bookmark-try-default-file) 941of the old one in the permanent bookmark record."
398 (let* ((completion-ignore-case 942 (interactive
399 bookmark-completion-ignore-case) 943 (bookmark-completing-read "Jump to bookmark" bookmark-current-bookmark))
400 (default
401 (or (and
402 (assoc bookmark-current-bookmark
403 bookmark-alist)
404 bookmark-current-bookmark)
405 (and (assoc (buffer-name (current-buffer))
406 bookmark-alist)
407 (buffer-name (current-buffer)))))
408 (str
409 (completing-read
410 (if default
411 (format "Jump to bookmark (%s): "
412 default)
413 "Jump to bookmark: ")
414 bookmark-alist
415 nil
416 0)))
417 (and (string-equal "" str)
418 (setq str default))
419 (list str))))
420 (let ((cell (bookmark-jump-noselect str))) 944 (let ((cell (bookmark-jump-noselect str)))
421 (and cell 945 (and cell
422 (switch-to-buffer (car cell)) 946 (switch-to-buffer (car cell))
423 (goto-char (cdr cell))))) 947 (goto-char (cdr cell))
948 ;; if there is an annotation for this bookmark,
949 ;; show it in a buffer.
950 (bookmark-show-annotation str))))
951
424 952
425(defun bookmark-jump-noselect (str) 953(defun bookmark-jump-noselect (str)
426 ;; a leetle helper for bookmark-jump :-) 954 ;; a leetle helper for bookmark-jump :-)
427 ;; returns (BUFFER . POINT) 955 ;; returns (BUFFER . POINT)
428 (let ((whereto-list (car (cdr (assoc str bookmark-alist))))) 956 (bookmark-maybe-load-default-file)
429 (let* ((file (expand-file-name (car whereto-list))) 957 (let* ((file (expand-file-name (bookmark-get-filename str)))
430 (orig-file file) 958 (forward-str (bookmark-get-front-context-string str))
431 (forward-str (car (cdr whereto-list))) 959 (behind-str (bookmark-get-rear-context-string str))
432 (behind-str (car (cdr (cdr whereto-list)))) 960 (place (bookmark-get-position str))
433 (place (car (cdr (cdr (cdr whereto-list)))))) 961 (info-node (bookmark-get-info-node str))
434 (if (or 962 (orig-file file)
435 (file-exists-p file) 963 )
436 ;; else try some common compression extensions 964 (if (or
437 ;; and Emacs better handle it right! 965 (file-exists-p file)
438 (setq file 966 ;; else try some common compression extensions
439 (or 967 ;; and Emacs better handle it right!
440 (let ((altname (concat file ".Z"))) 968 ;; Sigh: I think it may *not* be handled at the moment. What
441 (and (file-exists-p altname) 969 ;; to do about this?
442 altname)) 970 (setq file
443 (let ((altname (concat file ".gz"))) 971 (or
444 (and (file-exists-p altname) 972 (let ((altname (concat file ".Z")))
445 altname)) 973 (and (file-exists-p altname)
446 (let ((altname (concat file ".z"))) 974 altname))
447 (and (file-exists-p altname) 975 (let ((altname (concat file ".gz")))
448 altname))))) 976 (and (file-exists-p altname)
449 (save-excursion 977 altname))
450 (set-buffer (find-file-noselect file)) 978 (let ((altname (concat file ".z")))
451 (goto-char place) 979 (and (file-exists-p altname)
452 ;; Go searching forward first. Then, if forward-str exists and 980 altname)))))
453 ;; was found in the file, we can search backward for behind-str. 981 (save-excursion
454 ;; Rationale is that if text was inserted between the two in the 982 (if info-node
455 ;; file, it's better to be put before it so you can read it, 983 ;; Info nodes must be visited with care.
456 ;; rather than after and remain perhaps unaware of the changes.
457 (if forward-str
458 (if (search-forward forward-str (point-max) t)
459 (backward-char bookmark-search-size)))
460 (if behind-str
461 (if (search-backward behind-str (point-min) t)
462 (forward-char bookmark-search-size)))
463 ;; added by db
464 (setq bookmark-current-bookmark str)
465 (cons (current-buffer) (point)))
466 (progn
467 (ding)
468 (if (y-or-n-p (concat (file-name-nondirectory orig-file)
469 " nonexistent. Relocate \""
470 str
471 "\"? "))
472 (progn 984 (progn
473 (bookmark-relocate str) 985 (require 'info)
474 ;; gasp! It's a recursive function call in Emacs Lisp! 986 (Info-find-node file info-node))
475 (bookmark-jump-noselect str)) 987 ;; Else no Info. Can do an ordinary find-file:
476 (message 988 (set-buffer (find-file-noselect file))
477 "Bookmark not relocated, but deleting it would be a good idea.") 989 (goto-char place))
478 nil)))))) 990
991 ;; Go searching forward first. Then, if forward-str exists and
992 ;; was found in the file, we can search backward for behind-str.
993 ;; Rationale is that if text was inserted between the two in the
994 ;; file, it's better to be put before it so you can read it,
995 ;; rather than after and remain perhaps unaware of the changes.
996 (if forward-str
997 (if (search-forward forward-str (point-max) t)
998 (backward-char (length forward-str))))
999 (if behind-str
1000 (if (search-backward behind-str (point-min) t)
1001 (forward-char (length behind-str))))
1002 ;; added by db
1003 (setq bookmark-current-bookmark str)
1004 (cons (current-buffer) (point)))
1005 (progn
1006 (ding)
1007 (if (y-or-n-p (concat (file-name-nondirectory orig-file)
1008 " nonexistent. Relocate \""
1009 str
1010 "\"? "))
1011 (progn
1012 (bookmark-relocate str)
1013 ;; gasp! It's a recursive function call in Emacs Lisp!
1014 (bookmark-jump-noselect str))
1015 (message
1016 "Bookmark not relocated; consider removing it \(%s\)." str)
1017 nil)))))
1018
479 1019
480;;;###autoload 1020;;;###autoload
481(defun bookmark-relocate (bookmark) 1021(defun bookmark-relocate (str)
482 "Relocate bookmark BOOKMARK. 1022 "Relocate BOOKMARK -- prompts for a filename, and makes an already
483Prompt for a filename, and makes the bookmark BOOKMARK point to that 1023existing bookmark point to that file, instead of the one it used to
484file, instead of the one it used to point at. Useful when a file has 1024point at. Useful when a file has been renamed after a bookmark was
485been renamed after a bookmark was set in it." 1025set in it."
486 (interactive (let ((completion-ignore-case 1026 (interactive (bookmark-completing-read "Bookmark to relocate"))
487 bookmark-completion-ignore-case)) 1027 (bookmark-maybe-load-default-file)
488 (progn (bookmark-try-default-file) 1028 (let* ((bmrk-filename (bookmark-get-filename str))
489 (list (completing-read
490 "Bookmark to relocate: "
491 bookmark-alist
492 nil
493 0)))))
494 (let* ((bmrk (assoc bookmark bookmark-alist))
495 (bmrk-filename (car (car (cdr bmrk))))
496 (newloc (expand-file-name 1029 (newloc (expand-file-name
497 (read-file-name 1030 (read-file-name
498 (format "Relocate %s to: " bookmark) 1031 (format "Relocate %s to: " str)
499 (file-name-directory bmrk-filename))))) 1032 (file-name-directory bmrk-filename)))))
500 (setcar (car (cdr bmrk)) newloc))) 1033 (bookmark-set-filename str newloc)))
1034
501 1035
502;;;###autoload 1036;;;###autoload
503(defun bookmark-locate (str &optional no-insertion) 1037(defun bookmark-insert-location (str)
504 "Insert the name of the file associated with BOOKMARK. 1038 "Insert the name of the file associated with BOOKMARK."
505Optional second arg NO-INSERTION means merely return the filename as a 1039 (interactive (bookmark-completing-read "Insert bookmark location"))
506string." 1040 (insert (bookmark-location str)))
507 (interactive (let ((completion-ignore-case 1041
508 bookmark-completion-ignore-case)) 1042
509 (progn (bookmark-try-default-file) 1043(defun bookmark-location (str)
510 (list (completing-read 1044 "Return the name of the file associated with BOOKMARK."
511 "Insert bookmark location: " 1045 (bookmark-maybe-load-default-file)
512 bookmark-alist 1046 (bookmark-get-filename str))
513 nil 1047
514 0)))))
515 (let ((where (car (car (cdr (assoc str bookmark-alist))))))
516 (if no-insertion
517 where
518 (insert where))))
519 1048
520;;;###autoload 1049;;;###autoload
521(defun bookmark-rename (old &optional new) 1050(defun bookmark-rename (old &optional new)
@@ -529,20 +1058,17 @@ is done. You must pass at least OLD-BOOKMARK when calling from Lisp.
529 1058
530While you are entering the new name, consecutive C-w's insert 1059While you are entering the new name, consecutive C-w's insert
531consectutive words from the text of the buffer into the new bookmark 1060consectutive words from the text of the buffer into the new bookmark
532name, and C-v inserts the name of the file." 1061name.
533 (interactive (let ((completion-ignore-case 1062C-v inserts the name of the file.
534 bookmark-completion-ignore-case)) 1063C-o inserts the old name of the bookmark; this is helpful when you
535 (progn (bookmark-try-default-file) 1064just want to make minor changes to the old name."
536 (list (completing-read "Old bookmark name: " 1065 (interactive (bookmark-completing-read "Old bookmark name"))
537 bookmark-alist 1066 (bookmark-maybe-load-default-file)
538 nil
539 0)))))
540 (progn 1067 (progn
541 (setq bookmark-current-point (point)) 1068 (setq bookmark-current-point (point))
542 (setq bookmark-yank-point (point)) 1069 (setq bookmark-yank-point (point))
543 (setq bookmark-current-buffer (current-buffer)) 1070 (setq bookmark-current-buffer (current-buffer))
544 (let ((cell (assoc old bookmark-alist)) 1071 (let ((newname
545 (str
546 (or new ; use second arg, if non-nil 1072 (or new ; use second arg, if non-nil
547 (read-from-minibuffer 1073 (read-from-minibuffer
548 "New name: " 1074 "New name: "
@@ -550,19 +1076,23 @@ name, and C-v inserts the name of the file."
550 (let ((now-map (copy-keymap minibuffer-local-map))) 1076 (let ((now-map (copy-keymap minibuffer-local-map)))
551 (progn (define-key now-map "\C-w" 1077 (progn (define-key now-map "\C-w"
552 'bookmark-yank-word) 1078 'bookmark-yank-word)
1079 (define-key now-map "\C-o"
1080 (lambda ()
1081 (interactive)
1082 (insert old)))
553 (define-key now-map "\C-v" 1083 (define-key now-map "\C-v"
554 'bookmark-insert-current-file-name)) 1084 'bookmark-insert-current-file-name))
555 now-map))))) 1085 now-map)))))
556 (progn 1086 (progn
557 (setcar cell str) 1087 (bookmark-set-name old newname)
558 (setq bookmark-current-bookmark str) 1088 (setq bookmark-current-bookmark newname)
559 (if (get-buffer "*Bookmark List*") 1089 (bookmark-bmenu-surreptitiously-rebuild-list)
560 (save-excursion (save-window-excursion (list-bookmarks))))
561 (setq bookmark-alist-modification-count 1090 (setq bookmark-alist-modification-count
562 (1+ bookmark-alist-modification-count)) 1091 (1+ bookmark-alist-modification-count))
563 (if (bookmark-time-to-save-p) 1092 (if (bookmark-time-to-save-p)
564 (bookmark-save)))))) 1093 (bookmark-save))))))
565 1094
1095
566;;;###autoload 1096;;;###autoload
567(defun bookmark-insert (str) 1097(defun bookmark-insert (str)
568 "Insert the text of the file pointed to by bookmark BOOKMARK. 1098 "Insert the text of the file pointed to by bookmark BOOKMARK.
@@ -570,14 +1100,8 @@ You may have a problem using this function if the value of variable
570`bookmark-alist' is nil. If that happens, you need to load in some 1100`bookmark-alist' is nil. If that happens, you need to load in some
571bookmarks. See help on function `bookmark-load' for more about 1101bookmarks. See help on function `bookmark-load' for more about
572this." 1102this."
573 (interactive (let ((completion-ignore-case 1103 (interactive (bookmark-completing-read "Insert bookmark contents"))
574 bookmark-completion-ignore-case)) 1104 (bookmark-maybe-load-default-file)
575 (progn (bookmark-try-default-file)
576 (list (completing-read
577 "Insert bookmark contents: "
578 bookmark-alist
579 nil
580 0)))))
581 (let ((orig-point (point)) 1105 (let ((orig-point (point))
582 (str-to-insert 1106 (str-to-insert
583 (save-excursion 1107 (save-excursion
@@ -587,35 +1111,34 @@ this."
587 (push-mark) 1111 (push-mark)
588 (goto-char orig-point))) 1112 (goto-char orig-point)))
589 1113
1114
590;;;###autoload 1115;;;###autoload
591(defun bookmark-delete (str) 1116(defun bookmark-delete (bookmark &optional batch)
592 "Delete the bookmark named NAME from the bookmark list. 1117 "Delete BOOKMARK from the bookmark list.
593Removes only the first instance of a bookmark with that name. If 1118Removes only the first instance of a bookmark with that name. If
594there are one or more other bookmarks with the same name, they will 1119there are one or more other bookmarks with the same name, they will
595not be deleted. Defaults to the \"current\" bookmark \(that is, the 1120not be deleted. Defaults to the \"current\" bookmark \(that is, the
596one most recently used in this file, if any\)." 1121one most recently used in this file, if any\).
597 (interactive (let ((completion-ignore-case 1122Optional second arg BATCH means don't update the bookmark list buffer,
598 bookmark-completion-ignore-case)) 1123probably because we were called from there."
599 (progn (bookmark-try-default-file) 1124 (interactive
600 (list 1125 (bookmark-completing-read "Delete bookmark" bookmark-current-bookmark))
601 (completing-read 1126 (bookmark-maybe-load-default-file)
602 "Delete bookmark: " 1127 (let ((will-go (bookmark-get-bookmark bookmark)))
603 bookmark-alist
604 nil
605 0
606 bookmark-current-bookmark)))))
607 (let ((will-go (assoc str bookmark-alist)))
608 (setq bookmark-alist (delq will-go bookmark-alist)) 1128 (setq bookmark-alist (delq will-go bookmark-alist))
609 ;; Added by db, nil bookmark-current-bookmark if the last 1129 ;; Added by db, nil bookmark-current-bookmark if the last
610 ;; occurence has been deleted 1130 ;; occurence has been deleted
611 (or (assoc bookmark-current-bookmark bookmark-alist) 1131 (or (bookmark-get-bookmark bookmark-current-bookmark)
612 (setq bookmark-current-bookmark nil))) 1132 (setq bookmark-current-bookmark nil)))
613 (if (get-buffer "*Bookmark List*") 1133 ;; Don't rebuild the list
614 (save-excursion (save-window-excursion (list-bookmarks)))) 1134 (if batch
615 (setq bookmark-alist-modification-count 1135 nil
616 (1+ bookmark-alist-modification-count)) 1136 (bookmark-bmenu-surreptitiously-rebuild-list)
617 (if (bookmark-time-to-save-p) 1137 (setq bookmark-alist-modification-count
618 (bookmark-save))) 1138 (1+ bookmark-alist-modification-count))
1139 (if (bookmark-time-to-save-p)
1140 (bookmark-save))))
1141
619 1142
620(defun bookmark-time-to-save-p (&optional last-time) 1143(defun bookmark-time-to-save-p (&optional last-time)
621 ;; By Gregory M. Saunders <saunders@cis.ohio-state.edu> 1144 ;; By Gregory M. Saunders <saunders@cis.ohio-state.edu>
@@ -632,19 +1155,22 @@ one most recently used in this file, if any\)."
632 (t 1155 (t
633 nil))) 1156 nil)))
634 1157
1158
635;;;###autoload 1159;;;###autoload
636(defun bookmark-write () 1160(defun bookmark-write ()
637 "Write bookmarks to a specified file. 1161 "Write bookmarks to a file \(for which the user will be prompted
638Don't use this in Lisp programs; use `bookmark-save' instead." 1162interactively\). Don't use this in Lisp programs; use bookmark-save
1163instead."
639 (interactive) 1164 (interactive)
640 (bookmark-try-default-file) 1165 (bookmark-maybe-load-default-file)
641 (bookmark-save t)) 1166 (bookmark-save t))
642 1167
1168
643;;;###autoload 1169;;;###autoload
644(defun bookmark-save (&optional parg file) 1170(defun bookmark-save (&optional parg file)
645 "Save currently defined bookmarks. 1171 "Save currently defined bookmarks.
646Saves by default in the file defined by the variable 1172Saves by default in the file defined by the variable
647`bookmark-file'. With a prefix arg, save it in file FILE. 1173`bookmark-default-file'. With a prefix arg, save it in file FILE.
648 1174
649If you are calling this from Lisp, the two arguments are PREFIX-ARG 1175If you are calling this from Lisp, the two arguments are PREFIX-ARG
650and FILE, and if you just want it to write to the default file, then 1176and FILE, and if you just want it to write to the default file, then
@@ -655,13 +1181,13 @@ user will be interactively queried for a file to save in.
655When you want to load in the bookmarks from a file, use 1181When you want to load in the bookmarks from a file, use
656\`bookmark-load\', \\[bookmark-load]. That function will prompt you 1182\`bookmark-load\', \\[bookmark-load]. That function will prompt you
657for a file, defaulting to the file defined by variable 1183for a file, defaulting to the file defined by variable
658`bookmark-file'." 1184`bookmark-default-file'."
659 (interactive "P") 1185 (interactive "P")
660 (bookmark-try-default-file) 1186 (bookmark-maybe-load-default-file)
661 (cond 1187 (cond
662 ((and (null parg) (null file)) 1188 ((and (null parg) (null file))
663 ;;whether interactive or not, write to default file 1189 ;;whether interactive or not, write to default file
664 (bookmark-write-file bookmark-file)) 1190 (bookmark-write-file bookmark-default-file))
665 ((and (null parg) file) 1191 ((and (null parg) file)
666 ;;whether interactive or not, write to given file 1192 ;;whether interactive or not, write to given file
667 (bookmark-write-file file)) 1193 (bookmark-write-file file))
@@ -676,16 +1202,19 @@ for a file, defaulting to the file defined by variable
676 ;; set, which is what we want. 1202 ;; set, which is what we want.
677 (setq bookmark-alist-modification-count 0)) 1203 (setq bookmark-alist-modification-count 0))
678 1204
1205
1206
679(defun bookmark-write-file (file) 1207(defun bookmark-write-file (file)
680 (save-excursion 1208 (save-excursion
681 (save-window-excursion 1209 (save-window-excursion
682 (if (>= baud-rate 9600) 1210 (if (>= baud-rate 9600)
683 (message (format "Saving bookmarks to file %s." file))) 1211 (message (format "Saving bookmarks to file %s..." file)))
684 (set-buffer (let ((enable-local-variables nil)) 1212 (set-buffer (let ((enable-local-variables nil))
685 (find-file-noselect file))) 1213 (find-file-noselect file)))
686 (goto-char (point-min)) 1214 (goto-char (point-min))
687 (delete-region (point-min) (point-max)) 1215 (delete-region (point-min) (point-max))
688 (print bookmark-alist (current-buffer)) 1216 (bookmark-insert-file-format-version-stamp)
1217 (pp bookmark-alist (current-buffer))
689 (let ((version-control 1218 (let ((version-control
690 (cond 1219 (cond
691 ((null bookmark-version-control) nil) 1220 ((null bookmark-version-control) nil)
@@ -694,7 +1223,11 @@ for a file, defaulting to the file defined by variable
694 (t 1223 (t
695 t)))) 1224 t))))
696 (write-file file) 1225 (write-file file)
697 (kill-buffer (current-buffer)))))) 1226 (kill-buffer (current-buffer))
1227 (if (>= baud-rate 9600)
1228 (message (format "Saving bookmarks to file %s... done." file)))
1229 ))))
1230
698 1231
699;;;###autoload 1232;;;###autoload
700(defun bookmark-load (file &optional revert no-msg) 1233(defun bookmark-load (file &optional revert no-msg)
@@ -707,18 +1240,17 @@ while loading.
707If you load a file that doesn't contain a proper bookmark alist, you 1240If you load a file that doesn't contain a proper bookmark alist, you
708will corrupt Emacs's bookmark list. Generally, you should only load 1241will corrupt Emacs's bookmark list. Generally, you should only load
709in files that were created with the bookmark functions in the first 1242in files that were created with the bookmark functions in the first
710place. Your own personal bookmark file, `~/.emacs-bkmrks', is 1243place. Your own personal bookmark file, `~/.emacs.bmk', is
711maintained automatically by Emacs; you shouldn't need to load it 1244maintained automatically by Emacs; you shouldn't need to load it
712explicitly." 1245explicitly."
713 (interactive 1246 (interactive
714 (progn (bookmark-try-default-file) 1247 (list (read-file-name
715 (list (read-file-name 1248 (format "Load bookmarks from: (%s) "
716 (format "Load bookmarks from: (%s) " 1249 bookmark-default-file)
717 bookmark-file) 1250 ;;Default might not be used often,
718 ;;Default might not be used often, 1251 ;;but there's no better default, and
719 ;;but there's no better default, and 1252 ;;I guess it's better than none at all.
720 ;;I guess it's better than none at all. 1253 "~/" bookmark-default-file 'confirm)))
721 "~/" bookmark-file 'confirm))))
722 (setq file (expand-file-name file)) 1254 (setq file (expand-file-name file))
723 (if (file-readable-p file) 1255 (if (file-readable-p file)
724 (save-excursion 1256 (save-excursion
@@ -728,8 +1260,8 @@ explicitly."
728 (set-buffer (let ((enable-local-variables nil)) 1260 (set-buffer (let ((enable-local-variables nil))
729 (find-file-noselect file))) 1261 (find-file-noselect file)))
730 (goto-char (point-min)) 1262 (goto-char (point-min))
731 (let ((blist (car (read-from-string 1263 (bookmark-maybe-upgrade-file-format)
732 (buffer-substring (point-min) (point-max)))))) 1264 (let ((blist (bookmark-alist-from-buffer)))
733 (if (listp blist) 1265 (if (listp blist)
734 (progn 1266 (progn
735 (if (not revert) 1267 (if (not revert)
@@ -738,198 +1270,244 @@ explicitly."
738 (setq bookmark-alist-modification-count 0)) 1270 (setq bookmark-alist-modification-count 0))
739 (setq bookmark-alist 1271 (setq bookmark-alist
740 (append blist (if (not revert) bookmark-alist))) 1272 (append blist (if (not revert) bookmark-alist)))
741 (if (get-buffer "*Bookmark List*") 1273 (bookmark-bmenu-surreptitiously-rebuild-list))
742 (save-excursion (list-bookmarks))))
743 (error (format "Invalid bookmark list in %s." file)))) 1274 (error (format "Invalid bookmark list in %s." file))))
744 (kill-buffer (current-buffer))) 1275 (kill-buffer (current-buffer)))
745 (if (and (null no-msg) (>= baud-rate 9600)) 1276 (if (and (null no-msg) (>= baud-rate 9600))
746 (message (format "Loading bookmarks from %s... done" file)))) 1277 (message (format "Loading bookmarks from %s... done" file))))
747 (error (format "Cannot read bookmark file %s." file)))) 1278 (error (format "Cannot read bookmark file %s." file))))
748 1279
749;;;; bookmark-menu-mode stuff ;;;;
750 1280
751(defvar Bookmark-menu-bookmark-column nil) 1281
1282;;; Code supporting the dired-like bookmark menu. Prefix is
1283;;; "bookmark-bmenu" for "buffer-menu":
1284
1285
1286(defvar bookmark-bmenu-bookmark-column nil)
752 1287
753(defvar Bookmark-menu-hidden-bookmarks ())
754 1288
755(defvar Bookmark-menu-file-column 30 1289(defvar bookmark-bmenu-hidden-bookmarks ())
1290
1291
1292(defvar bookmark-bmenu-file-column 30
756 "*Column at which to display filenames in a buffer listing bookmarks. 1293 "*Column at which to display filenames in a buffer listing bookmarks.
757You can toggle whether files are shown with \\<Bookmark-menu-mode-map>\\[Bookmark-menu-toggle-filenames].") 1294You can toggle whether files are shown with \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-toggle-filenames].")
1295
758 1296
759(defvar Bookmark-menu-toggle-filenames t 1297(defvar bookmark-bmenu-toggle-filenames t
760 "*Non-nil means show filenames when listing bookmarks. 1298 "*Non-nil means show filenames when listing bookmarks.
761This may result in truncated bookmark names. To disable this, put the 1299This may result in truncated bookmark names. To disable this, put the
762following in your .emacs: 1300following in your .emacs:
763 1301
764\(setq Bookmark-menu-toggle-filenames nil\)") 1302\(setq bookmark-bmenu-toggle-filenames nil\)")
1303
1304
1305(defvar bookmark-bmenu-mode-map nil)
765 1306
766(defvar Bookmark-menu-mode-map nil)
767 1307
768(if Bookmark-menu-mode-map 1308(if bookmark-bmenu-mode-map
769 nil 1309 nil
770 (setq Bookmark-menu-mode-map (make-keymap)) 1310 (setq bookmark-bmenu-mode-map (make-keymap))
771 (suppress-keymap Bookmark-menu-mode-map t) 1311 (suppress-keymap bookmark-bmenu-mode-map t)
772 (define-key Bookmark-menu-mode-map "q" 'Bookmark-menu-quit) 1312 (define-key bookmark-bmenu-mode-map "q" 'bookmark-bmenu-quit)
773 (define-key Bookmark-menu-mode-map "v" 'Bookmark-menu-select) 1313 (define-key bookmark-bmenu-mode-map "v" 'bookmark-bmenu-select)
774 (define-key Bookmark-menu-mode-map "w" 'Bookmark-menu-locate) 1314 (define-key bookmark-bmenu-mode-map "w" 'bookmark-bmenu-locate)
775 (define-key Bookmark-menu-mode-map "2" 'Bookmark-menu-2-window) 1315 (define-key bookmark-bmenu-mode-map "2" 'bookmark-bmenu-2-window)
776 (define-key Bookmark-menu-mode-map "1" 'Bookmark-menu-1-window) 1316 (define-key bookmark-bmenu-mode-map "1" 'bookmark-bmenu-1-window)
777 (define-key Bookmark-menu-mode-map "j" 'Bookmark-menu-this-window) 1317 (define-key bookmark-bmenu-mode-map "j" 'bookmark-bmenu-this-window)
778 (define-key Bookmark-menu-mode-map "f" 'Bookmark-menu-this-window) 1318 (define-key bookmark-bmenu-mode-map "f" 'bookmark-bmenu-this-window)
779 (define-key Bookmark-menu-mode-map "o" 'Bookmark-menu-other-window) 1319 (define-key bookmark-bmenu-mode-map "o" 'bookmark-bmenu-other-window)
780 (define-key Bookmark-menu-mode-map "\C-o" 'Bookmark-menu-switch-other-window) 1320 (define-key bookmark-bmenu-mode-map "\C-o" 'bookmark-bmenu-switch-other-window)
781 (define-key Bookmark-menu-mode-map "s" 'Bookmark-menu-save) 1321 (define-key bookmark-bmenu-mode-map "s" 'bookmark-bmenu-save)
782 (define-key Bookmark-menu-mode-map "k" 'Bookmark-menu-delete) 1322 (define-key bookmark-bmenu-mode-map "k" 'bookmark-bmenu-delete)
783 (define-key Bookmark-menu-mode-map "\C-d" 'Bookmark-menu-delete-backwards) 1323 (define-key bookmark-bmenu-mode-map "\C-d" 'bookmark-bmenu-delete-backwards)
784 (define-key Bookmark-menu-mode-map "x" 'Bookmark-menu-execute) 1324 (define-key bookmark-bmenu-mode-map "x" 'bookmark-bmenu-execute-deletions)
785 (define-key Bookmark-menu-mode-map "\C-k" 'Bookmark-menu-delete) 1325 (define-key bookmark-bmenu-mode-map "\C-k" 'bookmark-bmenu-delete)
786 (define-key Bookmark-menu-mode-map "d" 'Bookmark-menu-delete) 1326 (define-key bookmark-bmenu-mode-map "d" 'bookmark-bmenu-delete)
787 (define-key Bookmark-menu-mode-map " " 'next-line) 1327 (define-key bookmark-bmenu-mode-map " " 'next-line)
788 (define-key Bookmark-menu-mode-map "n" 'next-line) 1328 (define-key bookmark-bmenu-mode-map "n" 'next-line)
789 (define-key Bookmark-menu-mode-map "p" 'previous-line) 1329 (define-key bookmark-bmenu-mode-map "p" 'previous-line)
790 (define-key Bookmark-menu-mode-map "\177" 'Bookmark-menu-backup-unmark) 1330 (define-key bookmark-bmenu-mode-map "\177" 'bookmark-bmenu-backup-unmark)
791 (define-key Bookmark-menu-mode-map "?" 'describe-mode) 1331 (define-key bookmark-bmenu-mode-map "?" 'describe-mode)
792 (define-key Bookmark-menu-mode-map "u" 'Bookmark-menu-unmark) 1332 (define-key bookmark-bmenu-mode-map "u" 'bookmark-bmenu-unmark)
793 (define-key Bookmark-menu-mode-map "m" 'Bookmark-menu-mark) 1333 (define-key bookmark-bmenu-mode-map "m" 'bookmark-bmenu-mark)
794 (define-key Bookmark-menu-mode-map "l" 'Bookmark-menu-load) 1334 (define-key bookmark-bmenu-mode-map "l" 'bookmark-bmenu-load)
795 (define-key Bookmark-menu-mode-map "r" 'Bookmark-menu-rename) 1335 (define-key bookmark-bmenu-mode-map "r" 'bookmark-bmenu-rename)
796 (define-key Bookmark-menu-mode-map "t" 'Bookmark-menu-toggle-filenames)) 1336 (define-key bookmark-bmenu-mode-map "t" 'bookmark-bmenu-toggle-filenames)
797 1337 (define-key bookmark-bmenu-mode-map "a" 'bookmark-bmenu-show-annotation)
798;; Bookmark Menu mode is suitable only for specially formatted data. 1338 (define-key bookmark-bmenu-mode-map "A" 'bookmark-bmenu-show-all-annotations)
799(put 'Bookmark-menu-mode 'mode-class 'special) 1339 (define-key bookmark-bmenu-mode-map "e" 'bookmark-bmenu-edit-annotation))
800 1340
801;; need to display whether or not bookmark exists as a buffer in flag 1341
802;; column. 1342
1343;; Bookmark Buffer Menu mode is suitable only for specially formatted
1344;; data.
1345(put 'bookmark-bmenu-mode 'mode-class 'special)
1346
1347
1348;; todo: need to display whether or not bookmark exists as a buffer in
1349;; flag column.
803 1350
804;; Format: 1351;; Format:
805;; FLAGS BOOKMARK (/FILE/NAME/HERE/WHAT/REGEXP/TO/USE?) 1352;; FLAGS BOOKMARK [ LOCATION ]
806;; goto bookmark-column and then search till "(/[^)]*)$" or "(/.*)$" ? 1353
1354
1355(defun bookmark-bmenu-surreptitiously-rebuild-list ()
1356 "Rebuild the Bookmark List if it exists.
1357Don't affect the buffer ring order."
1358 (if (get-buffer "*Bookmark List*")
1359 (save-excursion
1360 (save-window-excursion
1361 (bookmark-bmenu-list)))))
807 1362
808;;;###autoload
809(defalias 'edit-bookmarks 'list-bookmarks)
810 1363
811;;;###autoload 1364;;;###autoload
812(defun list-bookmarks () 1365(defun bookmark-bmenu-list ()
813 "Display a list of existing bookmarks. 1366 "Display a list of existing bookmarks.
814The list is displayed in a buffer named `*Bookmark List*'. 1367The list is displayed in a buffer named `*Bookmark List*'.
815The leftmost column displays a `D' if the bookmark is flagged for 1368The leftmost column displays a D if the bookmark is flagged for
816deletion, or `>' if it is flagged for displaying." 1369deletion, or > if it is flagged for displaying."
817 (interactive) 1370 (interactive)
818 (bookmark-try-default-file) 1371 (bookmark-maybe-load-default-file)
819 (switch-to-buffer (get-buffer-create "*Bookmark List*")) 1372 (if (interactive-p)
1373 (switch-to-buffer (get-buffer-create "*Bookmark List*"))
1374 (set-buffer (get-buffer-create "*Bookmark List*")))
820 (let ((buffer-read-only nil)) 1375 (let ((buffer-read-only nil))
821 (delete-region (point-max) (point-min)) 1376 (delete-region (point-max) (point-min))
822 (goto-char (point-min)) ;sure are playing it safe... 1377 (goto-char (point-min)) ;sure are playing it safe...
823 (insert "% Bookmark\n- --------\n") 1378 (insert "% Bookmark\n- --------\n")
824 (bookmark-maybe-sort-alist) 1379 (bookmark-maybe-sort-alist)
825 (let ((lst bookmark-alist)) 1380 (mapcar
826 (while lst 1381 (lambda (full-record)
827 (insert 1382 ;; if a bookmark has an annotation, preceed it with a "*"
828 (concat " " (car (car lst)) "\n")) 1383 ;; in the list of bookmarks.
829 (setq lst (cdr lst))))) 1384 (let ((annotation (bookmark-get-annotation
1385 (bookmark-name-from-full-record full-record))))
1386 (if (and (not (eq annotation nil))
1387 (not (string-equal annotation "")))
1388 (insert " *")
1389 (insert " "))
1390 (insert (concat (bookmark-name-from-full-record full-record) "\n"))))
1391 bookmark-alist))
830 (goto-char (point-min)) 1392 (goto-char (point-min))
831 (forward-line 2) 1393 (forward-line 2)
832 (bookmark-menu-mode) 1394 (bookmark-bmenu-mode)
833 (if Bookmark-menu-toggle-filenames 1395 (if bookmark-bmenu-toggle-filenames
834 (Bookmark-menu-toggle-filenames t))) 1396 (bookmark-bmenu-toggle-filenames t)))
1397
1398;;;###autoload
1399(defalias 'list-bookmarks 'bookmark-bmenu-list)
1400;;;###autoload
1401(defalias 'edit-bookmarks 'bookmark-bmenu-list)
835 1402
836(defun bookmark-menu-mode () 1403
1404
1405(defun bookmark-bmenu-mode ()
837 "Major mode for editing a list of bookmarks. 1406 "Major mode for editing a list of bookmarks.
838Each line describes one of the bookmarks in Emacs. 1407Each line describes one of the bookmarks in Emacs.
839Letters do not insert themselves; instead, they are commands. 1408Letters do not insert themselves; instead, they are commands.
840\\<Bookmark-menu-mode-map> 1409Bookmark names preceeded by a \"*\" have annotations.
841\\[Bookmark-menu-mark] -- mark bookmark to be displayed. 1410\\<bookmark-bmenu-mode-map>
842\\[Bookmark-menu-select] -- select bookmark of line point is on. 1411\\[bookmark-bmenu-mark] -- mark bookmark to be displayed.
843 Also show bookmarks marked using `m' in other windows. 1412\\[bookmark-bmenu-select] -- select bookmark of line point is on.
844\\[Bookmark-menu-toggle-filenames] -- toggle displaying of filenames (they may obscure long bookmark names). 1413 Also show bookmarks marked using m in other windows.
845\\[Bookmark-menu-locate] -- display (in minibuffer) location of this bookmark. 1414\\[bookmark-bmenu-toggle-filenames] -- toggle displaying of filenames (they may obscure long bookmark names).
846\\[Bookmark-menu-1-window] -- select this bookmark in full-frame window. 1415\\[bookmark-bmenu-locate] -- display (in minibuffer) location of this bookmark.
847\\[Bookmark-menu-2-window] -- select this bookmark in one window, 1416\\[bookmark-bmenu-1-window] -- select this bookmark in full-frame window.
1417\\[bookmark-bmenu-2-window] -- select this bookmark in one window,
848 together with bookmark selected before this one in another window. 1418 together with bookmark selected before this one in another window.
849\\[Bookmark-menu-this-window] -- select this bookmark in place of the bookmark menu buffer. 1419\\[bookmark-bmenu-this-window] -- select this bookmark in place of the bookmark menu buffer.
850\\[Bookmark-menu-other-window] -- select this bookmark in another window, 1420\\[bookmark-bmenu-other-window] -- select this bookmark in another window,
851 so the bookmark menu bookmark remains visible in its window. 1421 so the bookmark menu bookmark remains visible in its window.
852\\[Bookmark-menu-switch-other-window] -- switch the other window to this bookmark. 1422\\[bookmark-bmenu-switch-other-window] -- switch the other window to this bookmark.
853\\[Bookmark-menu-rename] -- rename this bookmark \(prompts for new name\). 1423\\[bookmark-bmenu-rename] -- rename this bookmark \(prompts for new name\).
854\\[Bookmark-menu-delete] -- mark this bookmark to be deleted, and move down. 1424\\[bookmark-bmenu-delete] -- mark this bookmark to be deleted, and move down.
855\\[Bookmark-menu-delete-backwards] -- mark this bookmark to be deleted, and move up. 1425\\[bookmark-bmenu-delete-backwards] -- mark this bookmark to be deleted, and move up.
856\\[Bookmark-menu-execute] -- delete marked bookmarks. 1426\\[bookmark-bmenu-execute-deletions] -- delete marked bookmarks.
857\\[Bookmark-menu-save] -- save the current bookmark list in the default file. 1427\\[bookmark-bmenu-save] -- save the current bookmark list in the default file.
858 With a prefix arg, prompts for a file to save in. 1428 With a prefix arg, prompts for a file to save in.
859\\[Bookmark-menu-load] -- load in a file of bookmarks (prompts for file.) 1429\\[bookmark-bmenu-load] -- load in a file of bookmarks (prompts for file.)
860\\[Bookmark-menu-unmark] -- remove all kinds of marks from current line. 1430\\[bookmark-bmenu-unmark] -- remove all kinds of marks from current line.
861 With prefix argument, also move up one line. 1431 With prefix argument, also move up one line.
862\\[Bookmark-menu-backup-unmark] -- back up a line and remove marks." 1432\\[bookmark-bmenu-backup-unmark] -- back up a line and remove marks.
1433\\[bookmark-bmenu-show-annotation] -- show the annotation, if it exists, for the current bookmark
1434 in another buffer.
1435\\[bookmark-bmenu-show-all-annotations] -- show the annotations of all bookmarks in another buffer.
1436\\[bookmark-bmenu-edit-annotation] -- edit the annotation for the current bookmark."
863 (kill-all-local-variables) 1437 (kill-all-local-variables)
864 (use-local-map Bookmark-menu-mode-map) 1438 (use-local-map bookmark-bmenu-mode-map)
865 (setq truncate-lines t) 1439 (setq truncate-lines t)
866 (setq buffer-read-only t) 1440 (setq buffer-read-only t)
867 (setq major-mode 'bookmark-menu-mode) 1441 (setq major-mode 'bookmark-bmenu-mode)
868 (setq mode-name "Bookmark Menu") 1442 (setq mode-name "Bookmark Menu")
869 (run-hooks 'bookmark-menu-mode-hook)) 1443 (run-hooks 'bookmark-bmenu-mode-hook))
870 1444
871(defun Bookmark-menu-toggle-filenames (&optional parg) 1445
1446(defun bookmark-bmenu-toggle-filenames (&optional parg)
872 "Toggle whether filenames are shown in the bookmark list. 1447 "Toggle whether filenames are shown in the bookmark list.
873Optional argument SHOW means show them unconditionally." 1448Optional argument SHOW means show them unconditionally."
874 (interactive) 1449 (interactive)
875 (cond 1450 (cond
876 (parg 1451 (parg
877 (setq Bookmark-menu-toggle-filenames nil) 1452 (setq bookmark-bmenu-toggle-filenames nil)
878 (Bookmark-menu-show-filenames) 1453 (bookmark-bmenu-show-filenames)
879 (setq Bookmark-menu-toggle-filenames t)) 1454 (setq bookmark-bmenu-toggle-filenames t))
880 (Bookmark-menu-toggle-filenames 1455 (bookmark-bmenu-toggle-filenames
881 (Bookmark-menu-hide-filenames) 1456 (bookmark-bmenu-hide-filenames)
882 (setq Bookmark-menu-toggle-filenames nil)) 1457 (setq bookmark-bmenu-toggle-filenames nil))
883 (t 1458 (t
884 (Bookmark-menu-show-filenames) 1459 (bookmark-bmenu-show-filenames)
885 (setq Bookmark-menu-toggle-filenames t)))) 1460 (setq bookmark-bmenu-toggle-filenames t))))
1461
886 1462
887(defun Bookmark-menu-show-filenames (&optional force) 1463(defun bookmark-bmenu-show-filenames (&optional force)
888 (if (and (not force) Bookmark-menu-toggle-filenames) 1464 (if (and (not force) bookmark-bmenu-toggle-filenames)
889 nil ;already shown, so do nothing 1465 nil ;already shown, so do nothing
890 (save-excursion 1466 (save-excursion
891 (save-window-excursion 1467 (save-window-excursion
892 (goto-char (point-min)) 1468 (goto-char (point-min))
893 (forward-line 2) 1469 (forward-line 2)
894 (setq Bookmark-menu-hidden-bookmarks ()) 1470 (setq bookmark-bmenu-hidden-bookmarks ())
895 (let ((buffer-read-only nil)) 1471 (let ((buffer-read-only nil))
896 (while (< (point) (point-max)) 1472 (while (< (point) (point-max))
897 (let ((bmrk (Bookmark-menu-bookmark))) 1473 (let ((bmrk (bookmark-bmenu-bookmark)))
898 (setq Bookmark-menu-hidden-bookmarks 1474 (setq bookmark-bmenu-hidden-bookmarks
899 (cons bmrk Bookmark-menu-hidden-bookmarks)) 1475 (cons bmrk bookmark-bmenu-hidden-bookmarks))
900 (move-to-column Bookmark-menu-file-column t) 1476 (move-to-column bookmark-bmenu-file-column t)
901 (delete-region (point) (progn (end-of-line) (point))) 1477 (delete-region (point) (progn (end-of-line) (point)))
902 (insert " ") 1478 (insert " ")
903 (bookmark-locate bmrk) 1479 (bookmark-insert-location bmrk)
904 (forward-line 1)))))))) 1480 (forward-line 1))))))))
905 1481
906(defun Bookmark-menu-hide-filenames (&optional force) 1482
907 (if (and (not force) Bookmark-menu-toggle-filenames) 1483(defun bookmark-bmenu-hide-filenames (&optional force)
1484 (if (and (not force) bookmark-bmenu-toggle-filenames)
908 ;; nothing to hide if above is nil 1485 ;; nothing to hide if above is nil
909 (save-excursion 1486 (save-excursion
910 (save-window-excursion 1487 (save-window-excursion
911 (goto-char (point-min)) 1488 (goto-char (point-min))
912 (forward-line 2) 1489 (forward-line 2)
913 (setq Bookmark-menu-hidden-bookmarks 1490 (setq bookmark-bmenu-hidden-bookmarks
914 (nreverse Bookmark-menu-hidden-bookmarks)) 1491 (nreverse bookmark-bmenu-hidden-bookmarks))
915 (save-excursion 1492 (save-excursion
916 (goto-char (point-min)) 1493 (goto-char (point-min))
917 (search-forward "Bookmark") 1494 (search-forward "Bookmark")
918 (backward-word 1) 1495 (backward-word 1)
919 (setq Bookmark-menu-bookmark-column (current-column))) 1496 (setq bookmark-bmenu-bookmark-column (current-column)))
920 (save-excursion 1497 (save-excursion
921 (let ((buffer-read-only nil)) 1498 (let ((buffer-read-only nil))
922 (while Bookmark-menu-hidden-bookmarks 1499 (while bookmark-bmenu-hidden-bookmarks
923 (move-to-column Bookmark-menu-bookmark-column t) 1500 (move-to-column bookmark-bmenu-bookmark-column t)
924 (kill-line) 1501 (bookmark-kill-line)
925 (insert (car Bookmark-menu-hidden-bookmarks)) 1502 (insert (car bookmark-bmenu-hidden-bookmarks))
926 (setq Bookmark-menu-hidden-bookmarks 1503 (setq bookmark-bmenu-hidden-bookmarks
927 (cdr Bookmark-menu-hidden-bookmarks)) 1504 (cdr bookmark-bmenu-hidden-bookmarks))
928 (forward-line 1)))))))) 1505 (forward-line 1))))))))
929 1506
1507
930;; if you look at this next function from far away, it resembles a 1508;; if you look at this next function from far away, it resembles a
931;; gun. But only with this comment above... 1509;; gun. But only with this comment above...
932(defun Bookmark-menu-check-position () 1510(defun bookmark-bmenu-check-position ()
933 ;; Returns t if on a line with a bookmark. 1511 ;; Returns t if on a line with a bookmark.
934 ;; Otherwise, repositions and returns t. 1512 ;; Otherwise, repositions and returns t.
935 ;; written by David Hughes <djh@harston.cv.com> 1513 ;; written by David Hughes <djh@harston.cv.com>
@@ -944,52 +1522,96 @@ Optional argument SHOW means show them unconditionally."
944 (t 1522 (t
945 t))) 1523 t)))
946 1524
947(defun Bookmark-menu-bookmark () 1525
1526(defun bookmark-bmenu-bookmark ()
948 ;; return a string which is bookmark of this line. 1527 ;; return a string which is bookmark of this line.
949 (if (Bookmark-menu-check-position) 1528 (if (bookmark-bmenu-check-position)
950 (save-excursion 1529 (save-excursion
951 (save-window-excursion 1530 (save-window-excursion
952 (goto-char (point-min)) 1531 (goto-char (point-min))
953 (search-forward "Bookmark") 1532 (search-forward "Bookmark")
954 (backward-word 1) 1533 (backward-word 1)
955 (setq Bookmark-menu-bookmark-column (current-column))))) 1534 (setq bookmark-bmenu-bookmark-column (current-column)))))
956 (if Bookmark-menu-toggle-filenames 1535 (if bookmark-bmenu-toggle-filenames
957 (Bookmark-menu-hide-filenames)) 1536 (bookmark-bmenu-hide-filenames))
958 (save-excursion 1537 (save-excursion
959 (save-window-excursion 1538 (save-window-excursion
960 (beginning-of-line) 1539 (beginning-of-line)
961 (forward-char Bookmark-menu-bookmark-column) 1540 (forward-char bookmark-bmenu-bookmark-column)
962 (prog1 1541 (prog1
963 (buffer-substring (point) 1542 (buffer-substring (point)
964 (progn 1543 (progn
965 (end-of-line) 1544 (end-of-line)
966 (point))) 1545 (point)))
967 ;; well, this is certainly crystal-clear: 1546 ;; well, this is certainly crystal-clear:
968 (if Bookmark-menu-toggle-filenames 1547 (if bookmark-bmenu-toggle-filenames
969 (Bookmark-menu-toggle-filenames t)))))) 1548 (bookmark-bmenu-toggle-filenames t))))))
970 1549
971(defun Bookmark-menu-mark () 1550
972 "Mark bookmark on this line to be displayed by \\<Bookmark-menu-mode-map>\\[Bookmark-menu-select] command." 1551(defun bookmark-show-annotation (bookmark)
1552 "Display the annotation for bookmark named BOOKMARK in a buffer,
1553if an annotation exists."
1554 (let ((annotation (bookmark-get-annotation bookmark)))
1555 (if (and (not (eq annotation nil))
1556 (not (string-equal annotation "")))
1557 (progn
1558 (save-excursion
1559 (let ((old-buf (current-buffer)))
1560 (pop-to-buffer (get-buffer-create "*Bookmark Annotation*") t)
1561 (delete-region (point-min) (point-max))
1562 ; (insert (concat "Annotation for bookmark '" bookmark "':\n\n"))
1563 (insert annotation)
1564 (goto-char (point-min))
1565 (pop-to-buffer old-buf)))))))
1566
1567
1568(defun bookmark-show-all-annotations ()
1569 "Display the annotations for all bookmarks in a buffer."
1570 (let ((old-buf (current-buffer)))
1571 (pop-to-buffer (get-buffer-create "*Bookmark Annotation*") t)
1572 (delete-region (point-min) (point-max))
1573 (mapcar
1574 (lambda (full-record)
1575 (let* ((name (bookmark-name-from-full-record full-record))
1576 (ann (bookmark-get-annotation name)))
1577 (insert (concat name ":\n"))
1578 (if (and (not (eq ann nil)) (not (string-equal ann "")))
1579 ;; insert the annotation, indented by 4 spaces.
1580 (progn
1581 (save-excursion (insert ann))
1582 (while (< (point) (point-max))
1583 (beginning-of-line) ; paranoia
1584 (insert " ")
1585 (forward-line)
1586 (end-of-line))))))
1587 bookmark-alist)
1588 (goto-char (point-min))
1589 (pop-to-buffer old-buf)))
1590
1591
1592(defun bookmark-bmenu-mark ()
1593 "Mark bookmark on this line to be displayed by \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-select] command."
973 (interactive) 1594 (interactive)
974 (beginning-of-line) 1595 (beginning-of-line)
975 (if (Bookmark-menu-check-position) 1596 (if (bookmark-bmenu-check-position)
976 (let ((buffer-read-only nil)) 1597 (let ((buffer-read-only nil))
977 (delete-char 1) 1598 (delete-char 1)
978 (insert ?>) 1599 (insert ?>)
979 (forward-line 1)))) 1600 (forward-line 1))))
980 1601
981(defun Bookmark-menu-select () 1602
1603(defun bookmark-bmenu-select ()
982 "Select this line's bookmark; also display bookmarks marked with `>'. 1604 "Select this line's bookmark; also display bookmarks marked with `>'.
983You can mark bookmarks with the \\<Bookmark-menu-mode-map>\\[Bookmark-menu-mark] command." 1605You can mark bookmarks with the \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-mark] command."
984 (interactive) 1606 (interactive)
985 (if (Bookmark-menu-check-position) 1607 (if (bookmark-bmenu-check-position)
986 (let ((bmrk (Bookmark-menu-bookmark)) 1608 (let ((bmrk (bookmark-bmenu-bookmark))
987 (menu (current-buffer)) 1609 (menu (current-buffer))
988 (others ()) 1610 (others ())
989 tem) 1611 tem)
990 (goto-char (point-min)) 1612 (goto-char (point-min))
991 (while (re-search-forward "^>" nil t) 1613 (while (re-search-forward "^>" nil t)
992 (setq tem (Bookmark-menu-bookmark)) 1614 (setq tem (bookmark-bmenu-bookmark))
993 (let ((buffer-read-only nil)) 1615 (let ((buffer-read-only nil))
994 (delete-char -1) 1616 (delete-char -1)
995 (insert ?\ )) 1617 (insert ?\ ))
@@ -1010,7 +1632,8 @@ You can mark bookmarks with the \\<Bookmark-menu-mode-map>\\[Bookmark-menu-mark]
1010 (setq others (cdr others))) 1632 (setq others (cdr others)))
1011 (other-window 1))))) 1633 (other-window 1)))))
1012 1634
1013(defun Bookmark-menu-save (parg) 1635
1636(defun bookmark-bmenu-save (parg)
1014 "Save the current list into a bookmark file. 1637 "Save the current list into a bookmark file.
1015With a prefix arg, prompts for a file to save them in." 1638With a prefix arg, prompts for a file to save them in."
1016 (interactive "P") 1639 (interactive "P")
@@ -1018,28 +1641,32 @@ With a prefix arg, prompts for a file to save them in."
1018 (save-window-excursion 1641 (save-window-excursion
1019 (bookmark-save parg)))) 1642 (bookmark-save parg))))
1020 1643
1021(defun Bookmark-menu-load () 1644
1022 "Load a bookmark file and rebuild list." 1645(defun bookmark-bmenu-load ()
1646 "Load the bookmark file and rebuild the bookmark menu-buffer."
1023 (interactive) 1647 (interactive)
1024 (if (Bookmark-menu-check-position) 1648 (if (bookmark-bmenu-check-position)
1025 (save-excursion 1649 (save-excursion
1026 (save-window-excursion 1650 (save-window-excursion
1651 ;; This will call `bookmark-bmenu-list'
1027 (call-interactively 'bookmark-load))))) 1652 (call-interactively 'bookmark-load)))))
1028 1653
1029(defun Bookmark-menu-1-window () 1654
1655(defun bookmark-bmenu-1-window ()
1030 "Select this line's bookmark, alone, in full frame." 1656 "Select this line's bookmark, alone, in full frame."
1031 (interactive) 1657 (interactive)
1032 (if (Bookmark-menu-check-position) 1658 (if (bookmark-bmenu-check-position)
1033 (progn 1659 (progn
1034 (bookmark-jump (Bookmark-menu-bookmark)) 1660 (bookmark-jump (bookmark-bmenu-bookmark))
1035 (bury-buffer (other-buffer)) 1661 (bury-buffer (other-buffer))
1036 (delete-other-windows)))) 1662 (delete-other-windows))))
1037 1663
1038(defun Bookmark-menu-2-window () 1664
1665(defun bookmark-bmenu-2-window ()
1039 "Select this line's bookmark, with previous buffer in second window." 1666 "Select this line's bookmark, with previous buffer in second window."
1040 (interactive) 1667 (interactive)
1041 (if (Bookmark-menu-check-position) 1668 (if (bookmark-bmenu-check-position)
1042 (let ((bmrk (Bookmark-menu-bookmark)) 1669 (let ((bmrk (bookmark-bmenu-bookmark))
1043 (menu (current-buffer)) 1670 (menu (current-buffer))
1044 (pop-up-windows t)) 1671 (pop-up-windows t))
1045 (delete-other-windows) 1672 (delete-other-windows)
@@ -1048,40 +1675,71 @@ With a prefix arg, prompts for a file to save them in."
1048 (pop-to-buffer buff)) 1675 (pop-to-buffer buff))
1049 (bury-buffer menu)))) 1676 (bury-buffer menu))))
1050 1677
1051(defun Bookmark-menu-this-window () 1678
1679(defun bookmark-bmenu-this-window ()
1052 "Select this line's bookmark in this window." 1680 "Select this line's bookmark in this window."
1053 (interactive) 1681 (interactive)
1054 (if (Bookmark-menu-check-position) 1682 (if (bookmark-bmenu-check-position)
1055 (bookmark-jump (Bookmark-menu-bookmark)))) 1683 (bookmark-jump (bookmark-bmenu-bookmark))))
1056 1684
1057(defun Bookmark-menu-other-window () 1685
1686(defun bookmark-bmenu-other-window ()
1058 "Select this line's bookmark in other window, leaving bookmark menu visible." 1687 "Select this line's bookmark in other window, leaving bookmark menu visible."
1059 (interactive) 1688 (interactive)
1060 (if (Bookmark-menu-check-position) 1689 (let ((bookmark (bookmark-bmenu-bookmark)))
1061 (let ((buff (car (bookmark-jump-noselect (Bookmark-menu-bookmark))))) 1690 (if (bookmark-bmenu-check-position)
1062 (switch-to-buffer-other-window buff)))) 1691 (let ((buff (car (bookmark-jump-noselect bookmark))))
1692 (switch-to-buffer-other-window buff)
1693 (bookmark-show-annotation bookmark)))))
1694
1695
1696(defun bookmark-bmenu-show-annotation ()
1697 "Show the annotation for the current bookmark in another window."
1698 (interactive)
1699 (let ((bookmark (bookmark-bmenu-bookmark)))
1700 (if (bookmark-bmenu-check-position)
1701 (bookmark-show-annotation bookmark))))
1063 1702
1064(defun Bookmark-menu-switch-other-window () 1703
1704(defun bookmark-bmenu-show-all-annotations ()
1705 "Show the annotation for all bookmarks in another window."
1706 (interactive)
1707 (bookmark-show-all-annotations))
1708
1709
1710(defun bookmark-bmenu-edit-annotation ()
1711 "Edit the annotation for the current bookmark in another window."
1712 (interactive)
1713 (let ((bookmark (bookmark-bmenu-bookmark)))
1714 (if (bookmark-bmenu-check-position)
1715 (bookmark-edit-annotation bookmark))))
1716
1717
1718(defun bookmark-bmenu-switch-other-window ()
1065 "Make the other window select this line's bookmark. 1719 "Make the other window select this line's bookmark.
1066The current window remains selected." 1720The current window remains selected."
1067 (interactive) 1721 (interactive)
1068 (if (Bookmark-menu-check-position) 1722 (let ((bookmark (bookmark-bmenu-bookmark)))
1069 (let ((buff (car (bookmark-jump-noselect (Bookmark-menu-bookmark))))) 1723 (if (bookmark-bmenu-check-position)
1070 (display-buffer buff)))) 1724 (let ((buff (car (bookmark-jump-noselect bookmark))))
1725 (display-buffer buff)
1726 (bookmark-show-annotation bookmark)))))
1071 1727
1072(defun Bookmark-menu-quit () 1728
1729(defun bookmark-bmenu-quit ()
1073 "Quit the bookmark menu." 1730 "Quit the bookmark menu."
1074 (interactive) 1731 (interactive)
1075 (let ((buffer (current-buffer))) 1732 (let ((buffer (current-buffer)))
1076 (switch-to-buffer (other-buffer)) 1733 (switch-to-buffer (other-buffer))
1077 (bury-buffer buffer))) 1734 (bury-buffer buffer)))
1078 1735
1079(defun Bookmark-menu-unmark (&optional backup) 1736
1737(defun bookmark-bmenu-unmark (&optional backup)
1080 "Cancel all requested operations on bookmark on this line and move down. 1738 "Cancel all requested operations on bookmark on this line and move down.
1081Optional ARG means move up." 1739Optional ARG means move up."
1082 (interactive "P") 1740 (interactive "P")
1083 (beginning-of-line) 1741 (beginning-of-line)
1084 (if (Bookmark-menu-check-position) 1742 (if (bookmark-bmenu-check-position)
1085 (progn 1743 (progn
1086 (let ((buffer-read-only nil)) 1744 (let ((buffer-read-only nil))
1087 (delete-char 1) 1745 (delete-char 1)
@@ -1091,141 +1749,194 @@ Optional ARG means move up."
1091 (insert " ")) 1749 (insert " "))
1092 (forward-line (if backup -1 1))))) 1750 (forward-line (if backup -1 1)))))
1093 1751
1094(defun Bookmark-menu-backup-unmark () 1752
1753(defun bookmark-bmenu-backup-unmark ()
1095 "Move up and cancel all requested operations on bookmark on line above." 1754 "Move up and cancel all requested operations on bookmark on line above."
1096 (interactive) 1755 (interactive)
1097 (forward-line -1) 1756 (forward-line -1)
1098 (if (Bookmark-menu-check-position) 1757 (if (bookmark-bmenu-check-position)
1099 (progn 1758 (progn
1100 (Bookmark-menu-unmark) 1759 (bookmark-bmenu-unmark)
1101 (forward-line -1)))) 1760 (forward-line -1))))
1102 1761
1103(defun Bookmark-menu-delete () 1762
1104 "Mark bookmark on this line to be deleted by \\<Bookmark-menu-mode-map>\\[Bookmark-menu-execute] command." 1763(defun bookmark-bmenu-delete ()
1764 "Mark bookmark on this line to be deleted by \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-execute-deletions] command."
1105 (interactive) 1765 (interactive)
1106 (beginning-of-line) 1766 (beginning-of-line)
1107 (if (Bookmark-menu-check-position) 1767 (if (bookmark-bmenu-check-position)
1108 (let ((buffer-read-only nil)) 1768 (let ((buffer-read-only nil))
1109 (delete-char 1) 1769 (delete-char 1)
1110 (insert ?D) 1770 (insert ?D)
1111 (forward-line 1)))) 1771 (forward-line 1))))
1112 1772
1113(defun Bookmark-menu-delete-backwards () 1773
1114 "Mark bookmark on this line to be deleted by \\<Bookmark-menu-mode-map>\\[Bookmark-menu-execute] command. 1774(defun bookmark-bmenu-delete-backwards ()
1115Then move up one line" 1775 "Mark bookmark on this line to be deleted by \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-execute-deletions] command
1776and then move up one line"
1116 (interactive) 1777 (interactive)
1117 (Bookmark-menu-delete) 1778 (bookmark-bmenu-delete)
1118 (forward-line -2) 1779 (forward-line -2)
1119 (if (Bookmark-menu-check-position) 1780 (if (bookmark-bmenu-check-position)
1120 (forward-line 1))) 1781 (forward-line 1)))
1121 1782
1122(defun Bookmark-menu-execute () 1783
1784(defun bookmark-bmenu-execute-deletions ()
1123 "Delete bookmarks marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands." 1785 "Delete bookmarks marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands."
1124 (interactive) 1786 (interactive)
1125 (let ((hide-em Bookmark-menu-toggle-filenames)) 1787 (let ((hide-em bookmark-bmenu-toggle-filenames)
1126 (if hide-em (Bookmark-menu-hide-filenames)) 1788 (o-point (point))
1127 (setq Bookmark-menu-toggle-filenames nil) 1789 (o-str (save-excursion
1790 (beginning-of-line)
1791 (if (looking-at "^D")
1792 nil
1793 (buffer-substring
1794 (point)
1795 (progn (end-of-line) (point))))))
1796 (o-col (current-column)))
1797 (if hide-em (bookmark-bmenu-hide-filenames))
1798 (setq bookmark-bmenu-toggle-filenames nil)
1128 (goto-char (point-min)) 1799 (goto-char (point-min))
1129 (forward-line 1) 1800 (forward-line 1)
1130 (let ((deaders ())) 1801 (while (re-search-forward "^D" (point-max) t)
1131 (while (re-search-forward "^D" (point-max) t) 1802 (bookmark-delete (bookmark-bmenu-bookmark) t)) ; pass BATCH arg
1132 (setq deaders (cons (Bookmark-menu-bookmark) deaders))) 1803 (bookmark-bmenu-list)
1133 (mapcar (lambda (str) 1804 (setq bookmark-bmenu-toggle-filenames hide-em)
1134 (setq bookmark-alist 1805 (if bookmark-bmenu-toggle-filenames
1135 (delq (assoc str bookmark-alist) bookmark-alist))) 1806 (bookmark-bmenu-toggle-filenames t))
1136 deaders)) 1807 (if o-str
1137 (list-bookmarks) 1808 (progn
1138 (goto-char (point-min)) 1809 (goto-char (point-min))
1139 (forward-line 2) 1810 (search-forward o-str)
1140 (setq Bookmark-menu-toggle-filenames hide-em) 1811 (beginning-of-line)
1141 (if Bookmark-menu-toggle-filenames 1812 (forward-char o-col))
1142 (Bookmark-menu-toggle-filenames t)))) 1813 (goto-char o-point))
1143 1814 (beginning-of-line)
1144(defun Bookmark-menu-rename () 1815 (setq bookmark-alist-modification-count
1816 (1+ bookmark-alist-modification-count))
1817 (if (bookmark-time-to-save-p)
1818 (bookmark-save))))
1819
1820
1821(defun bookmark-bmenu-rename ()
1145 "Rename bookmark on current line. Prompts for a new name." 1822 "Rename bookmark on current line. Prompts for a new name."
1146 (interactive) 1823 (interactive)
1147 (if (Bookmark-menu-check-position) 1824 (if (bookmark-bmenu-check-position)
1148 (let ((bmrk (Bookmark-menu-bookmark)) 1825 (let ((bmrk (bookmark-bmenu-bookmark))
1149 (thispoint (point))) 1826 (thispoint (point)))
1150 (bookmark-rename bmrk) 1827 (bookmark-rename bmrk)
1151 (list-bookmarks) 1828 (bookmark-bmenu-list)
1152 (goto-char thispoint)))) 1829 (goto-char thispoint))))
1153 1830
1154(defun Bookmark-menu-locate () 1831
1832(defun bookmark-bmenu-locate ()
1155 "Display location of this bookmark. Displays in the minibuffer." 1833 "Display location of this bookmark. Displays in the minibuffer."
1156 (interactive) 1834 (interactive)
1157 (if (Bookmark-menu-check-position) 1835 (if (bookmark-bmenu-check-position)
1158 (let ((bmrk (Bookmark-menu-bookmark))) 1836 (let ((bmrk (bookmark-bmenu-bookmark)))
1159 (message (bookmark-locate bmrk t))))) 1837 (message (bookmark-location bmrk)))))
1838
1160 1839
1161;;;; bookmark menu bar stuff ;;;; 1840
1841;;; Menu bar stuff. Prefix is "bookmark-menu".
1162 1842
1163(defvar bookmark-menu-bar-length 70 1843(defvar bookmark-menu-length 70
1164 "*Maximum length of a bookmark name displayed on a popup menu.") 1844 "*Maximum length of a bookmark name displayed on a popup menu.")
1165 1845
1166(defun bookmark-make-menu-bar-alist () 1846
1167 (bookmark-try-default-file) 1847(defun bookmark-menu-build-paned-menu (name entries)
1168 (bookmark-maybe-sort-alist) 1848 "Build a multi-paned menu named NAME from the strings in ENTRIES.
1169 (if bookmark-alist 1849That is, ENTRIES is a list of strings which appear as the choices
1170 (mapcar (lambda (cell) 1850in the menu. The number of panes depends on the number of entries.
1171 (let ((str (car cell))) 1851The visible entries are truncated to `bookmark-menu-length', but the
1172 (cons 1852strings returned are not."
1173 (if (> (length str) bookmark-menu-bar-length) 1853 (let* ((f-height (/ (frame-height) 2))
1174 (substring str 0 bookmark-menu-bar-length) 1854 (pane-list
1175 str) 1855 (let (temp-pane-list
1176 str))) 1856 (iter 0))
1177 bookmark-alist) 1857 (while entries
1178 (error "No bookmarks currently set."))) 1858 (let (lst
1179 1859 (count 0))
1180(defun bookmark-make-menu-bar-with-function (func-sym 1860 (while (and (< count f-height) entries)
1181 menu-label 1861 (let ((str (car entries)))
1182 menu-str event) 1862 (setq lst (cons
1863 (cons
1864 (if (> (length str) bookmark-menu-length)
1865 (substring str 0 bookmark-menu-length)
1866 str)
1867 str)
1868 lst))
1869 (setq entries (cdr entries))
1870 (setq count (1+ count))))
1871 (setq iter (1+ iter))
1872 (setq
1873 temp-pane-list
1874 (cons
1875 (cons
1876 (format "-*- %s (%d) -*-" name iter)
1877 (nreverse lst))
1878 temp-pane-list))))
1879 (nreverse temp-pane-list))))
1880
1881 ;; Return the menu:
1882 (cons (concat "-*- " name " -*-") pane-list)))
1883
1884
1885(defun bookmark-menu-popup-paned-menu (event name entries)
1886 "Pop up multi-paned menu at EVENT, return string chosen from ENTRIES.
1887That is, ENTRIES is a list of strings which appear as the choices
1888in the menu.
1889The number of panes depends on the number of entries."
1890 (interactive "e")
1891 (x-popup-menu event (bookmark-menu-build-paned-menu name entries)))
1892
1893
1894(defun bookmark-menu-popup-paned-bookmark-menu (event name)
1895 "Pop up menu of bookmarks, return chosen bookmark.
1896Pop up at EVENT, menu's name is NAME.
1897The number of panes depends on the number of bookmarks."
1898 (bookmark-menu-popup-paned-menu event name (bookmark-all-names)))
1899
1900
1901(defun bookmark-popup-menu-and-apply-function (func-sym menu-label event)
1183 ;; help function for making menus that need to apply a bookmark 1902 ;; help function for making menus that need to apply a bookmark
1184 ;; function to a string. 1903 ;; function to a string.
1185 (let* ((menu (bookmark-make-menu-bar-alist)) 1904 (let* ((choice (bookmark-menu-popup-paned-bookmark-menu
1186 (str (x-popup-menu event 1905 event menu-label)))
1187 (list menu-label 1906 (if choice (apply func-sym (list choice)))))
1188 (cons menu-str menu)))))
1189 (if str (apply func-sym (list str)))))
1190 1907
1191;;;###autoload 1908
1192(defun bookmark-menu-bar-insert (event) 1909(defun bookmark-menu-insert (event)
1193 "Insert the text of the file pointed to by bookmark BOOKMARK. 1910 "Insert the text of the file pointed to by bookmark BOOKMARK.
1194You may have a problem using this function if the value of variable 1911You may have a problem using this function if the value of variable
1195`bookmark-alist' is nil. If that happens, you need to load in some 1912`bookmark-alist' is nil. If that happens, you need to load in some
1196bookmarks. See help on function `bookmark-load' for more about 1913bookmarks. See help on function `bookmark-load' for more about
1197this." 1914this."
1198 (interactive "e") 1915 (interactive "e")
1199 (bookmark-make-menu-bar-with-function 'bookmark-insert 1916 (bookmark-popup-menu-and-apply-function
1200 "Bookmark Insert Menu" 1917 'bookmark-insert "Insert Bookmark Contents" event))
1201 "--- Insert Contents ---"
1202 event))
1203 1918
1204;;;###autoload 1919
1205(defun bookmark-menu-bar-jump (event) 1920(defun bookmark-menu-jump (event)
1206 "Jump to bookmark BOOKMARK (a point in some file). 1921 "Jump to bookmark BOOKMARK (a point in some file).
1207You may have a problem using this function if the value of variable 1922You may have a problem using this function if the value of variable
1208`bookmark-alist' is nil. If that happens, you need to load in some 1923`bookmark-alist' is nil. If that happens, you need to load in some
1209bookmarks. See help on function `bookmark-load' for more about 1924bookmarks. See help on function `bookmark-load' for more about
1210this." 1925this."
1211 (interactive "e") 1926 (interactive "e")
1212 (bookmark-make-menu-bar-with-function 'bookmark-jump 1927 (bookmark-popup-menu-and-apply-function
1213 "Bookmark Jump Menu" 1928 'bookmark-jump "Jump to Bookmark" event))
1214 "--- Jump to Bookmark ---"
1215 event))
1216 1929
1217;;;###autoload 1930
1218(defun bookmark-menu-bar-locate (event) 1931(defun bookmark-menu-locate (event)
1219 "Insert the name of the file associated with BOOKMARK. 1932 "Insert the name of the file associated with BOOKMARK.
1220\(This is not the same as the contents of that file\)." 1933\(This is not the same as the contents of that file\)."
1221 (interactive "e") 1934 (interactive "e")
1222 (bookmark-make-menu-bar-with-function 'bookmark-locate 1935 (bookmark-popup-menu-and-apply-function
1223 "Bookmark Locate Menu" 1936 'bookmark-insert-location "Insert Bookmark Location" event))
1224 "--- Insert Location ---"
1225 event))
1226 1937
1227;;;###autoload 1938
1228(defun bookmark-menu-bar-rename (event) 1939(defun bookmark-menu-rename (event)
1229 "Change the name of OLD-BOOKMARK to NEWNAME. 1940 "Change the name of OLD-BOOKMARK to NEWNAME.
1230If called from keyboard, prompts for OLD-BOOKMARK and NEWNAME. 1941If called from keyboard, prompts for OLD-BOOKMARK and NEWNAME.
1231If called from menubar, OLD-BOOKMARK is selected from a menu, and 1942If called from menubar, OLD-BOOKMARK is selected from a menu, and
@@ -1238,76 +1949,76 @@ While you are entering the new name, consecutive C-w's insert
1238consectutive words from the text of the buffer into the new bookmark 1949consectutive words from the text of the buffer into the new bookmark
1239name, and C-v inserts the name of the file." 1950name, and C-v inserts the name of the file."
1240 (interactive "e") 1951 (interactive "e")
1241 (bookmark-make-menu-bar-with-function 'bookmark-rename 1952 (bookmark-popup-menu-and-apply-function
1242 "Bookmark Rename Menu" 1953 'bookmark-rename "Rename Bookmark" event))
1243 "--- Rename Bookmark ---"
1244 event))
1245 1954
1246;;;###autoload 1955
1247(defun bookmark-menu-bar-delete (event) 1956(defun bookmark-menu-delete (event)
1248 "Delete the bookmark named NAME from the bookmark list. 1957 "Delete the bookmark named NAME from the bookmark list.
1249Removes only the first instance of a bookmark with that name. If 1958Removes only the first instance of a bookmark with that name. If
1250there are one or more other bookmarks with the same name, they will 1959there are one or more other bookmarks with the same name, they will
1251not be deleted. Defaults to the \"current\" bookmark \(that is, the 1960not be deleted. Defaults to the \"current\" bookmark \(that is, the
1252one most recently used in this file, if any\)." 1961one most recently used in this file, if any\)."
1253 (interactive "e") 1962 (interactive "e")
1254 (bookmark-make-menu-bar-with-function 'bookmark-delete 1963 (bookmark-popup-menu-and-apply-function
1255 "Bookmark Delete Menu" 1964 'bookmark-delete "Delete Bookmark" event))
1256 "--- Delete Bookmark ---" 1965
1257 event))
1258 1966
1259;; Thanks to Roland McGrath for fixing menubar.el so that the 1967;; Thanks to Roland McGrath for fixing menubar.el so that the
1260;; following works, and for explaining what to do to make it work. 1968;; following works, and for explaining what to do to make it work.
1261 1969
1262;;;###autoload
1263(defvar menu-bar-bookmark-map (make-sparse-keymap "Bookmark functions.")) 1970(defvar menu-bar-bookmark-map (make-sparse-keymap "Bookmark functions."))
1264 1971
1265;;;###autoload
1266(fset 'menu-bar-bookmark-map (symbol-value 'menu-bar-bookmark-map))
1267 1972
1268;;;###autoload 1973;; make bookmarks appear toward the right side of the menu.
1974(if (boundp 'menu-bar-final-items)
1975 (if menu-bar-final-items
1976 (setq menu-bar-final-items
1977 (cons 'bookmark menu-bar-final-items)))
1978 (setq menu-bar-final-items '(bookmark)))
1979
1269(define-key menu-bar-bookmark-map [load] 1980(define-key menu-bar-bookmark-map [load]
1270 '("Load a bookmark file" . bookmark-load)) 1981 '("Load a bookmark file" . bookmark-load))
1271 1982
1272;;;###autoload
1273(define-key menu-bar-bookmark-map [write] 1983(define-key menu-bar-bookmark-map [write]
1274 '("Write \(to another file\)" . bookmark-write)) 1984 '("Write \(to another file\)" . bookmark-write))
1275 1985
1276;;;###autoload
1277(define-key menu-bar-bookmark-map [save] 1986(define-key menu-bar-bookmark-map [save]
1278 '("Save \(in default file\)" . bookmark-save)) 1987 '("Save \(in default file\)" . bookmark-save))
1279 1988
1280;;;###autoload
1281(define-key menu-bar-bookmark-map [edit] 1989(define-key menu-bar-bookmark-map [edit]
1282 '("Edit Bookmark List" . list-bookmarks)) 1990 '("Edit Bookmark List" . bookmark-bmenu-list))
1283 1991
1284;;;###autoload
1285(define-key menu-bar-bookmark-map [delete] 1992(define-key menu-bar-bookmark-map [delete]
1286 '("Delete bookmark" . bookmark-menu-bar-delete)) 1993 '("Delete bookmark" . bookmark-menu-delete))
1287 1994
1288;;;###autoload
1289(define-key menu-bar-bookmark-map [rename] 1995(define-key menu-bar-bookmark-map [rename]
1290 '("Rename bookmark" . bookmark-menu-bar-rename)) 1996 '("Rename bookmark" . bookmark-menu-rename))
1291 1997
1292;;;###autoload
1293(define-key menu-bar-bookmark-map [locate] 1998(define-key menu-bar-bookmark-map [locate]
1294 '("Insert location" . bookmark-menu-bar-locate)) 1999 '("Insert location" . bookmark-menu-locate))
1295 2000
1296;;;###autoload
1297(define-key menu-bar-bookmark-map [insert] 2001(define-key menu-bar-bookmark-map [insert]
1298 '("Insert contents" . bookmark-menu-bar-insert)) 2002 '("Insert contents" . bookmark-menu-insert))
1299 2003
1300;;;###autoload
1301(define-key menu-bar-bookmark-map [set] 2004(define-key menu-bar-bookmark-map [set]
1302 '("Set bookmark" . bookmark-set)) 2005 '("Set bookmark" . bookmark-set))
1303 2006
1304;;;###autoload
1305(define-key menu-bar-bookmark-map [jump] 2007(define-key menu-bar-bookmark-map [jump]
1306 '("Jump to bookmark" . bookmark-menu-bar-jump)) 2008 '("Jump to bookmark" . bookmark-menu-jump))
2009
2010;;;###autoload (autoload 'menu-bar-bookmark-map "bookmark" nil t 'keymap)
1307 2011
1308(fset 'menu-bar-bookmark-map (symbol-value 'menu-bar-bookmark-map)) 2012(fset 'menu-bar-bookmark-map (symbol-value 'menu-bar-bookmark-map))
1309 2013
1310;;;; end bookmark menu-bar stuff ;;;; 2014;;;; end bookmark menu stuff ;;;;
2015
2016
2017;;; Load Hook
2018(defvar bookmark-load-hook nil
2019 "Hook to run at the end of loading bookmark.")
2020
2021(run-hooks 'bookmark-load-hook)
1311 2022
1312(provide 'bookmark) 2023(provide 'bookmark)
1313 2024