aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-06-18 22:46:02 +0000
committerRichard M. Stallman1995-06-18 22:46:02 +0000
commit4eadcdf806c1a7487ca165ea954af5b1c4854f13 (patch)
treeee47fb38e2d534f49b13beebef66eb5dc1ec5eed
parent087feab3c8e5ee514ed0f2ba4968cffbbbcd8cfe (diff)
downloademacs-4eadcdf806c1a7487ca165ea954af5b1c4854f13.tar.gz
emacs-4eadcdf806c1a7487ca165ea954af5b1c4854f13.zip
Make doc strings and argument names consistent where necessary.
Moved user variables to own section. (bookmark-alist): Better doc string. (bookmark-insert-current-bookmark): Doc string. (bookmark-insert-buffer-name): Doc string. (bookmark-set): Take optional NAME argument. (bookmark-bmenu-select): Use member to test for string's presence. Use a more efficent test at end, as suggested by Mikio Nakajima.
-rw-r--r--lisp/bookmark.el353
1 files changed, 200 insertions, 153 deletions
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 6c6902ebe65..2fbd68fc337 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -5,13 +5,14 @@
5;; Author: Karl Fogel <kfogel@cyclic.com> 5;; Author: Karl Fogel <kfogel@cyclic.com>
6;; Maintainer: Karl Fogel <kfogel@cyclic.com> 6;; Maintainer: Karl Fogel <kfogel@cyclic.com>
7;; Created: July, 1993 7;; Created: July, 1993
8;; Author's Update Number: 2.6.10 8;; Author's Update Number: 2.6.13
9;; Keywords: bookmarks, placeholders, annotations 9;; Keywords: bookmarks, placeholders, annotations
10 10
11;;; Summary: 11;;; Summary:
12;; This package is for setting "bookmarks" in files. A bookmark 12;; This package is for setting "bookmarks" in files. A bookmark
13;; associates a string with a location in a certain file. Thus, you 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. 14;; can navigate your way to that location by providing the string.
15;; See the "User Variables" section for customizations.
15 16
16;;; Copyright info: 17;;; Copyright info:
17;; This file is part of GNU Emacs. 18;; This file is part of GNU Emacs.
@@ -65,6 +66,9 @@
65;; Based on info-bookmark.el, by Karl Fogel and Ken Olstad 66;; Based on info-bookmark.el, by Karl Fogel and Ken Olstad
66;; <olstad@msc.edu>. 67;; <olstad@msc.edu>.
67 68
69;; Thanks to Mikio Nakajima <PBC01764@niftyserve.or.jp> for many bugs
70;; reported and fixed.
71
68;; Enough with the credits already, get on to the good stuff: 72;; Enough with the credits already, get on to the good stuff:
69 73
70;; FAVORITE CHINESE RESTAURANT: 74;; FAVORITE CHINESE RESTAURANT:
@@ -87,13 +91,96 @@
87;; the list will be presented in the order it is recorded 91;; the list will be presented in the order it is recorded
88;; (chronologically), which is actually fairly useful as well. 92;; (chronologically), which is actually fairly useful as well.
89 93
90;;; Code: 94;;; User Variables
95
96(defvar bookmark-use-annotations nil
97 "*If non-nil, saving a bookmark will query for an annotation in a
98buffer.")
99
100
101(defvar bookmark-save-flag t
102 "*Controls when Emacs saves bookmarks to a file.
103--> Nil means never save bookmarks, except when `bookmark-save' is
104 explicitly called \(\\[bookmark-save]\).
105--> t means save bookmarks when Emacs is killed.
106--> Otherise, it should be a number that is the frequency with which
107 the bookmark list is saved \(i.e.: the number of times which
108 Emacs' bookmark list may be modified before it is automatically
109 saved.\). If it is a number, Emacs will also automatically save
110 bookmarks when it is killed.
111
112Therefore, the way to get it to save every time you make or delete a
113bookmark is to set this variable to 1 \(or 0, which produces the same
114behavior.\)
115
116To specify the file in which to save them, modify the variable
117bookmark-default-file, which is `~/.emacs.bmk' by default.")
118
119
120(defconst bookmark-old-default-file "~/.emacs-bkmrks"
121 "*The .emacs.bmk file used to be called this.")
122
123
124;; defvarred to avoid a compilation warning:
125(defvar bookmark-file nil
126 "Old name for `bookmark-default-file'.")
127
128(defvar bookmark-default-file
129 (if bookmark-file
130 ;; In case user set `bookmark-file' in her .emacs:
131 bookmark-file
132 (if (eq system-type 'ms-dos)
133 "~/emacs.bmk" ; Cannot have initial dot [Yuck!]
134 "~/.emacs.bmk"))
135 "*File in which to save bookmarks by default.")
136
137
138(defvar bookmark-version-control 'nospecial
139 "*Whether or not to make numbered backups of the bookmark file.
140It can have four values: t, nil, `never', and `nospecial'.
141The first three have the same meaning that they do for the
142variable `version-control', and the final value `nospecial' means just
143use the value of `version-control'.")
144
145
146(defvar bookmark-completion-ignore-case t
147 "*Non-nil means bookmark functions ignore case in completion.")
148
149
150(defvar bookmark-sort-flag t
151 "*Non-nil means that bookmarks will be displayed sorted by bookmark
152name. Otherwise they will be displayed in LIFO order (that is, most
153recently set ones come first, oldest ones come last).")
154
155
156(defvar bookmark-automatically-show-annotations t
157 "*Nil means don't show annotations when jumping to a bookmark.")
158
159
160(defvar bookmark-bmenu-file-column 30
161 "*Column at which to display filenames in a buffer listing bookmarks.
162You can toggle whether files are shown with \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-toggle-filenames].")
163
164
165(defvar bookmark-bmenu-toggle-filenames t
166 "*Non-nil means show filenames when listing bookmarks.
167This may result in truncated bookmark names. To disable this, put the
168following in your .emacs:
169
170\(setq bookmark-bmenu-toggle-filenames nil\)")
171
172
173(defvar bookmark-menu-length 70
174 "*Maximum length of a bookmark name displayed on a popup menu.")
175
176
177;;; No user-serviceable parts beyond this point.
91 178
92;; Added for lucid emacs compatibility, db 179;; Added for lucid emacs compatibility, db
93(or (fboundp 'defalias) (fset 'defalias 'fset)) 180(or (fboundp 'defalias) (fset 'defalias 'fset))
94 181
95;; suggested for lucid compatibility by david hughes: 182;; suggested for lucid compatibility by david hughes:
96(or (fboundp 'frame-height) (fset 'frame-height 'screen-height)) 183(or (fboundp 'frame-height) (defalias 'frame-height 'screen-height))
97 184
98 185
99 186
@@ -120,10 +207,6 @@ so that you have a bookmark prefix, just use `global-set-key' and bind a
120key of your choice to `bookmark-map'. All interactive bookmark 207key of your choice to `bookmark-map'. All interactive bookmark
121functions have a binding in this keymap.") 208functions have a binding in this keymap.")
122 209
123(defvar bookmark-use-annotations nil
124 "*If non-nil, saving a bookmark will query for an annotation in a
125buffer.")
126
127;;;###autoload 210;;;###autoload
128(define-prefix-command 'bookmark-map) 211(define-prefix-command 'bookmark-map)
129 212
@@ -167,7 +250,24 @@ buffer.")
167(defvar bookmark-alist () 250(defvar bookmark-alist ()
168 "Association list of bookmarks and their records. 251 "Association list of bookmarks and their records.
169You probably don't want to change the value of this alist yourself; 252You probably don't want to change the value of this alist yourself;
170instead, let the various bookmark functions do it for you.") 253instead, let the various bookmark functions do it for you.
254
255The format of the alist is
256
257 \(BOOKMARK1 BOOKMARK2 ...\)
258
259where each BOOKMARK is of the form
260
261\(NAME
262 \(filename . FILE\)
263 \(front-context-string . FRONT-STR\)
264 \(rear-context-string . REAR-STR\)
265 \(position . POS\)
266 \(info-node . POS\)
267 \(annotation . ANNOTATION\)\)
268
269So the cdr of each bookmark is an alist too.
270`info-node' is optional, by the way.")
171 271
172 272
173(defvar bookmarks-already-loaded nil) 273(defvar bookmarks-already-loaded nil)
@@ -193,69 +293,10 @@ through a file easier.")
193(make-variable-buffer-local 'bookmark-current-bookmark) 293(make-variable-buffer-local 'bookmark-current-bookmark)
194 294
195 295
196(defvar bookmark-save-flag t
197 "*Controls when Emacs saves bookmarks to a file.
198--> Nil means never save bookmarks, except when `bookmark-save' is
199 explicitly called \(\\[bookmark-save]\).
200--> t means save bookmarks when Emacs is killed.
201--> Otherise, it should be a number that is the frequency with which
202 the bookmark list is saved \(i.e.: the number of times which
203 Emacs' bookmark list may be modified before it is automatically
204 saved.\). If it is a number, Emacs will also automatically save
205 bookmarks when it is killed.
206
207Therefore, the way to get it to save every time you make or delete a
208bookmark is to set this variable to 1 \(or 0, which produces the same
209behavior.\)
210
211To specify the file in which to save them, modify the variable
212bookmark-default-file, which is `~/.emacs.bmk' by default.")
213
214
215(defvar bookmark-alist-modification-count 0 296(defvar bookmark-alist-modification-count 0
216 "Number of modifications to bookmark list since it was last saved.") 297 "Number of modifications to bookmark list since it was last saved.")
217 298
218 299
219(defconst bookmark-old-default-file "~/.emacs-bkmrks"
220 "*The .emacs.bmk file used to be called this.")
221
222
223;; defvarred to avoid a compilation warning:
224(defvar bookmark-file nil
225 "Old name for `bookmark-default-file'.")
226
227(defvar bookmark-default-file
228 (if bookmark-file
229 ;; In case user set `bookmark-file' in her .emacs:
230 bookmark-file
231 (if (eq system-type 'ms-dos)
232 "~/emacs.bmk" ; Cannot have initial dot [Yuck!]
233 "~/.emacs.bmk"))
234 "*File in which to save bookmarks by default.")
235
236
237(defvar bookmark-version-control 'nospecial
238 "This variable controls whether or not to make numbered backups of
239the master bookmark file. It can have four values: t, nil, never, and
240nospecial. The first three have the same meaning that they do for the
241variable version-control, and the final value nospecial means just use
242the value of version-control.")
243
244
245(defvar bookmark-completion-ignore-case t
246 "*Non-nil means bookmark functions ignore case in completion.")
247
248
249(defvar bookmark-sort-flag t
250 "*Non-nil means that bookmarks will be displayed sorted by bookmark
251name. Otherwise they will be displayed in LIFO order (that is, most
252recently set ones come first, oldest ones come last).")
253
254
255(defvar bookmark-automatically-show-annotations t
256 "*Nil means don't show annotations when jumping to a bookmark.")
257
258
259(defvar bookmark-search-size 16 300(defvar bookmark-search-size 16
260 "Length of the context strings recorded on either side of a bookmark.") 301 "Length of the context strings recorded on either side of a bookmark.")
261 302
@@ -273,7 +314,7 @@ recently set ones come first, oldest ones come last).")
273;; Everyone else should go through them. 314;; Everyone else should go through them.
274 315
275(defun bookmark-name-from-full-record (full-record) 316(defun bookmark-name-from-full-record (full-record)
276 "Return name of BOOKMARK \(an alist element instead of a string\)." 317 "Return name of FULL-RECORD \(an alist element instead of a string\)."
277 (car full-record)) 318 (car full-record))
278 319
279 320
@@ -308,7 +349,7 @@ That is, all information but the name."
308 349
309 350
310(defun bookmark-set-annotation (bookmark ann) 351(defun bookmark-set-annotation (bookmark ann)
311 "Set the annotation of BOOKMARK." 352 "Set the annotation of BOOKMARK to ANN."
312 (let ((cell (assq 'annotation (bookmark-get-bookmark-record bookmark)))) 353 (let ((cell (assq 'annotation (bookmark-get-bookmark-record bookmark))))
313 (if cell 354 (if cell
314 (setcdr cell ann) 355 (setcdr cell ann)
@@ -375,6 +416,7 @@ That is, all information but the name."
375 416
376 417
377(defun bookmark-get-info-node (bookmark) 418(defun bookmark-get-info-node (bookmark)
419 "Get the info node associated with BOOKMARK."
378 (cdr (assq 'info-node (bookmark-get-bookmark-record bookmark)))) 420 (cdr (assq 'info-node (bookmark-get-bookmark-record bookmark))))
379 421
380 422
@@ -425,16 +467,16 @@ menus, so `completing-read' never gets a chance to set `bookmark-history'."
425 (setq bookmark-history (cons (, string) bookmark-history))))) 467 (setq bookmark-history (cons (, string) bookmark-history)))))
426 468
427 469
428(defun bookmark-make (str &optional annotation overwrite) 470(defun bookmark-make (name &optional annotation overwrite)
429 "Make a bookmark named NAME. 471 "Make a bookmark named NAME.
430Optional second arg ANNOTATION gives it an annotation. 472Optional second arg ANNOTATION gives it an annotation.
431Optional third arg OVERWRITE means replace any existing bookmarks with 473Optional third arg OVERWRITE means replace any existing bookmarks with
432this name." 474this name."
433 (bookmark-maybe-load-default-file) 475 (bookmark-maybe-load-default-file)
434 (if (and (bookmark-get-bookmark str) (not overwrite)) 476 (if (and (bookmark-get-bookmark name) (not overwrite))
435 ;; already existing boookmark under that name and 477 ;; already existing boookmark under that name and
436 ;; no prefix arg means just overwrite old bookmark 478 ;; no prefix arg means just overwrite old bookmark
437 (setcdr (bookmark-get-bookmark str) 479 (setcdr (bookmark-get-bookmark name)
438 (list (bookmark-make-cell annotation))) 480 (list (bookmark-make-cell annotation)))
439 481
440 ;; otherwise just cons it onto the front (either the bookmark 482 ;; otherwise just cons it onto the front (either the bookmark
@@ -443,12 +485,12 @@ this name."
443 485
444 (setq bookmark-alist 486 (setq bookmark-alist
445 (cons 487 (cons
446 (list str 488 (list name
447 (bookmark-make-cell annotation)) 489 (bookmark-make-cell annotation))
448 bookmark-alist))) 490 bookmark-alist)))
449 491
450 ;; Added by db 492 ;; Added by db
451 (setq bookmark-current-bookmark str) 493 (setq bookmark-current-bookmark name)
452 (setq bookmark-alist-modification-count 494 (setq bookmark-alist-modification-count
453 (1+ bookmark-alist-modification-count)) 495 (1+ bookmark-alist-modification-count))
454 (if (bookmark-time-to-save-p) 496 (if (bookmark-time-to-save-p)
@@ -456,10 +498,9 @@ this name."
456 498
457 499
458(defun bookmark-make-cell (annotation) 500(defun bookmark-make-cell (annotation)
459 "Return the record part of a bookmark. 501 "Return the record part of a new bookmark, given ANNOTATION.
460Must be at the correct position in the buffer in which the bookmark is 502Must be at the correct position in the buffer in which the bookmark is
461being set. This will change soon. 503being set. This will change soon."
462Takes ANNOTATION as an argument."
463 (` ((filename . (, (bookmark-buffer-file-name))) 504 (` ((filename . (, (bookmark-buffer-file-name)))
464 (front-context-string 505 (front-context-string
465 . (, (if (>= (- (point-max) (point)) bookmark-search-size) 506 . (, (if (>= (- (point-max) (point)) bookmark-search-size)
@@ -565,7 +606,7 @@ affect point."
565 606
566 607
567(defun bookmark-upgrade-version-0-alist (old-list) 608(defun bookmark-upgrade-version-0-alist (old-list)
568 "Upgrade a version 0 alist to the current version." 609 "Upgrade a version 0 alist OLD-LIST to the current version."
569 (mapcar 610 (mapcar
570 (lambda (bookmark) 611 (lambda (bookmark)
571 (let* ((name (car bookmark)) 612 (let* ((name (car bookmark))
@@ -647,8 +688,9 @@ This expects to be called from point-min in a bookmark file."
647;;; Core code: 688;;; Core code:
648 689
649;;;###autoload 690;;;###autoload
650(defun bookmark-set (&optional parg) 691(defun bookmark-set (&optional name parg)
651 "Set a bookmark named NAME inside a file. 692 "Set a bookmark named NAME inside a file.
693If name is nil, then the user will be prompted.
652With prefix arg, will not overwrite a bookmark that has the same name 694With prefix arg, will not overwrite a bookmark that has the same name
653as NAME if such a bookmark already exists, but instead will \"push\" 695as NAME if such a bookmark already exists, but instead will \"push\"
654the new bookmark onto the bookmark alist. Thus the most recently set 696the new bookmark onto the bookmark alist. Thus the most recently set
@@ -668,7 +710,7 @@ name of the file being visited.
668Use \\[bookmark-delete] to remove bookmarks \(you give it a name, 710Use \\[bookmark-delete] to remove bookmarks \(you give it a name,
669and it removes only the first instance of a bookmark with that name from 711and it removes only the first instance of a bookmark with that name from
670the list of bookmarks.\)" 712the list of bookmarks.\)"
671 (interactive "P") 713 (interactive (list nil current-prefix-arg))
672 (or 714 (or
673 (bookmark-buffer-file-name) 715 (bookmark-buffer-file-name)
674 (error "Buffer not visiting a file or directory.")) 716 (error "Buffer not visiting a file or directory."))
@@ -682,15 +724,16 @@ the list of bookmarks.\)"
682 (let* ((default (or bookmark-current-bookmark 724 (let* ((default (or bookmark-current-bookmark
683 (bookmark-buffer-name))) 725 (bookmark-buffer-name)))
684 (str 726 (str
685 (read-from-minibuffer 727 (or name
686 (format "Set bookmark (%s): " default) 728 (read-from-minibuffer
687 nil 729 (format "Set bookmark (%s): " default)
688 (let ((now-map (copy-keymap minibuffer-local-map))) 730 nil
689 (progn (define-key now-map "\C-w" 731 (let ((now-map (copy-keymap minibuffer-local-map)))
690 'bookmark-yank-word) 732 (progn (define-key now-map "\C-w"
691 (define-key now-map "\C-u" 733 'bookmark-yank-word)
692 'bookmark-insert-current-bookmark)) 734 (define-key now-map "\C-u"
693 now-map))) 735 'bookmark-insert-current-bookmark))
736 now-map))))
694 (annotation nil)) 737 (annotation nil))
695 (and (string-equal str "") (setq str default)) 738 (and (string-equal str "") (setq str default))
696 ;; Ask for an annotation buffer for this bookmark 739 ;; Ask for an annotation buffer for this bookmark
@@ -773,6 +816,7 @@ as a string, as an arg.")
773 816
774(defun bookmark-read-annotation-mode (buf point parg bookmark) 817(defun bookmark-read-annotation-mode (buf point parg bookmark)
775 "Mode for composing annotations for a bookmark. 818 "Mode for composing annotations for a bookmark.
819Wants BUF POINT PARG and BOOKMARK.
776When you have finished composing, type \\[bookmark-send-annotation] to send 820When you have finished composing, type \\[bookmark-send-annotation] to send
777the annotation. 821the annotation.
778 822
@@ -861,8 +905,8 @@ as the new annotation for a bookmark."
861 905
862 906
863(defun bookmark-insert-current-bookmark () 907(defun bookmark-insert-current-bookmark ()
864 ;; insert this buffer's value of bookmark-current-bookmark, default 908 "Insert this buffer's value of bookmark-current-bookmark, default
865 ;; to file name if it's nil. 909to file name if it's nil."
866 (interactive) 910 (interactive)
867 (let ((str 911 (let ((str
868 (save-excursion 912 (save-excursion
@@ -872,8 +916,8 @@ as the new annotation for a bookmark."
872 916
873 917
874(defun bookmark-insert-buffer-name () 918(defun bookmark-insert-buffer-name ()
875 ;; insert the name (sans path) of the current file into the bookmark 919 "Insert the name (sans path) of the current file into the bookmark
876 ;; name that is being set. 920name that is being set."
877 (interactive) 921 (interactive)
878 (let ((str 922 (let ((str
879 (save-excursion 923 (save-excursion
@@ -966,7 +1010,7 @@ For example, if this is a Info buffer, return the Info file's name."
966 1010
967 1011
968;;;###autoload 1012;;;###autoload
969(defun bookmark-jump (str) 1013(defun bookmark-jump (bookmark)
970 "Jump to bookmark BOOKMARK (a point in some file). 1014 "Jump to bookmark BOOKMARK (a point in some file).
971You may have a problem using this function if the value of variable 1015You may have a problem using this function if the value of variable
972`bookmark-alist' is nil. If that happens, you need to load in some 1016`bookmark-alist' is nil. If that happens, you need to load in some
@@ -979,15 +1023,15 @@ will then jump to the new location, as well as recording it in place
979of the old one in the permanent bookmark record." 1023of the old one in the permanent bookmark record."
980 (interactive 1024 (interactive
981 (bookmark-completing-read "Jump to bookmark" bookmark-current-bookmark)) 1025 (bookmark-completing-read "Jump to bookmark" bookmark-current-bookmark))
982 (bookmark-maybe-historicize-string str) 1026 (bookmark-maybe-historicize-string bookmark)
983 (let ((cell (bookmark-jump-noselect str))) 1027 (let ((cell (bookmark-jump-noselect bookmark)))
984 (and cell 1028 (and cell
985 (switch-to-buffer (car cell)) 1029 (switch-to-buffer (car cell))
986 (goto-char (cdr cell)) 1030 (goto-char (cdr cell))
987 (if bookmark-automatically-show-annotations 1031 (if bookmark-automatically-show-annotations
988 ;; if there is an annotation for this bookmark, 1032 ;; if there is an annotation for this bookmark,
989 ;; show it in a buffer. 1033 ;; show it in a buffer.
990 (bookmark-show-annotation str))))) 1034 (bookmark-show-annotation bookmark)))))
991 1035
992 1036
993(defun bookmark-jump-noselect (str) 1037(defun bookmark-jump-noselect (str)
@@ -1058,47 +1102,47 @@ of the old one in the permanent bookmark record."
1058 1102
1059 1103
1060;;;###autoload 1104;;;###autoload
1061(defun bookmark-relocate (str) 1105(defun bookmark-relocate (bookmark)
1062 "Relocate BOOKMARK -- prompts for a filename, and makes an already 1106 "Relocate BOOKMARK -- prompts for a filename, and makes an already
1063existing bookmark point to that file, instead of the one it used to 1107existing bookmark point to that file, instead of the one it used to
1064point at. Useful when a file has been renamed after a bookmark was 1108point at. Useful when a file has been renamed after a bookmark was
1065set in it." 1109set in it."
1066 (interactive (bookmark-completing-read "Bookmark to relocate")) 1110 (interactive (bookmark-completing-read "Bookmark to relocate"))
1067 (bookmark-maybe-historicize-string str) 1111 (bookmark-maybe-historicize-string bookmark)
1068 (bookmark-maybe-load-default-file) 1112 (bookmark-maybe-load-default-file)
1069 (let* ((bmrk-filename (bookmark-get-filename str)) 1113 (let* ((bmrk-filename (bookmark-get-filename bookmark))
1070 (newloc (expand-file-name 1114 (newloc (expand-file-name
1071 (read-file-name 1115 (read-file-name
1072 (format "Relocate %s to: " str) 1116 (format "Relocate %s to: " bookmark)
1073 (file-name-directory bmrk-filename))))) 1117 (file-name-directory bmrk-filename)))))
1074 (bookmark-set-filename str newloc))) 1118 (bookmark-set-filename bookmark newloc)))
1075 1119
1076 1120
1077;;;###autoload 1121;;;###autoload
1078(defun bookmark-insert-location (str &optional no-history) 1122(defun bookmark-insert-location (bookmark &optional no-history)
1079 "Insert the name of the file associated with BOOKMARK. 1123 "Insert the name of the file associated with BOOKMARK.
1080Optional second arg NO-HISTORY means don't record this in the 1124Optional second arg NO-HISTORY means don't record this in the
1081minibuffer history list `bookmark-history'." 1125minibuffer history list `bookmark-history'."
1082 (interactive (bookmark-completing-read "Insert bookmark location")) 1126 (interactive (bookmark-completing-read "Insert bookmark location"))
1083 (or no-history (bookmark-maybe-historicize-string str)) 1127 (or no-history (bookmark-maybe-historicize-string bookmark))
1084 (insert (bookmark-location str))) 1128 (insert (bookmark-location bookmark)))
1085 1129
1086 1130
1087(defun bookmark-location (str) 1131(defun bookmark-location (bookmark)
1088 "Return the name of the file associated with BOOKMARK." 1132 "Return the name of the file associated with BOOKMARK."
1089 (bookmark-maybe-load-default-file) 1133 (bookmark-maybe-load-default-file)
1090 (bookmark-get-filename str)) 1134 (bookmark-get-filename bookmark))
1091 1135
1092 1136
1093;;;###autoload 1137;;;###autoload
1094(defun bookmark-rename (old &optional new) 1138(defun bookmark-rename (old &optional new)
1095 "Change the name of OLD-BOOKMARK to NEWNAME. 1139 "Change the name of OLD bookmark to NEW name. If called from
1096If called from keyboard, prompts for OLD-BOOKMARK and NEWNAME. 1140keyboard, prompts for OLD and NEW. If called from menubar, OLD is
1097If called from menubar, OLD-BOOKMARK is selected from a menu, and 1141selected from a menu, and prompts for NEW.
1098prompts for NEWNAME. 1142
1099If called from Lisp, prompts for NEWNAME if only OLD-BOOKMARK was 1143If called from Lisp, prompts for NEW if only OLD was passed as an
1100passed as an argument. If called with two strings, then no prompting 1144argument. If called with two strings, then no prompting is done. You
1101is done. You must pass at least OLD-BOOKMARK when calling from Lisp. 1145must pass at least OLD when calling from Lisp.
1102 1146
1103While you are entering the new name, consecutive C-w's insert 1147While you are entering the new name, consecutive C-w's insert
1104consectutive words from the text of the buffer into the new bookmark 1148consectutive words from the text of the buffer into the new bookmark
@@ -1131,19 +1175,19 @@ name."
1131 1175
1132 1176
1133;;;###autoload 1177;;;###autoload
1134(defun bookmark-insert (str) 1178(defun bookmark-insert (bookmark)
1135 "Insert the text of the file pointed to by bookmark BOOKMARK. 1179 "Insert the text of the file pointed to by bookmark BOOKMARK.
1136You may have a problem using this function if the value of variable 1180You may have a problem using this function if the value of variable
1137`bookmark-alist' is nil. If that happens, you need to load in some 1181`bookmark-alist' is nil. If that happens, you need to load in some
1138bookmarks. See help on function `bookmark-load' for more about 1182bookmarks. See help on function `bookmark-load' for more about
1139this." 1183this."
1140 (interactive (bookmark-completing-read "Insert bookmark contents")) 1184 (interactive (bookmark-completing-read "Insert bookmark contents"))
1141 (bookmark-maybe-historicize-string str) 1185 (bookmark-maybe-historicize-string bookmark)
1142 (bookmark-maybe-load-default-file) 1186 (bookmark-maybe-load-default-file)
1143 (let ((orig-point (point)) 1187 (let ((orig-point (point))
1144 (str-to-insert 1188 (str-to-insert
1145 (save-excursion 1189 (save-excursion
1146 (set-buffer (car (bookmark-jump-noselect str))) 1190 (set-buffer (car (bookmark-jump-noselect bookmark)))
1147 (buffer-substring (point-min) (point-max))))) 1191 (buffer-substring (point-min) (point-max)))))
1148 (insert str-to-insert) 1192 (insert str-to-insert)
1149 (push-mark) 1193 (push-mark)
@@ -1209,7 +1253,8 @@ instead."
1209(defun bookmark-save (&optional parg file) 1253(defun bookmark-save (&optional parg file)
1210 "Save currently defined bookmarks. 1254 "Save currently defined bookmarks.
1211Saves by default in the file defined by the variable 1255Saves by default in the file defined by the variable
1212`bookmark-default-file'. With a prefix arg, save it in file FILE. 1256`bookmark-default-file'. With a prefix arg, save it in file FILE
1257\(second argument\).
1213 1258
1214If you are calling this from Lisp, the two arguments are PREFIX-ARG 1259If you are calling this from Lisp, the two arguments are PREFIX-ARG
1215and FILE, and if you just want it to write to the default file, then 1260and FILE, and if you just want it to write to the default file, then
@@ -1328,19 +1373,6 @@ explicitly."
1328(defvar bookmark-bmenu-hidden-bookmarks ()) 1373(defvar bookmark-bmenu-hidden-bookmarks ())
1329 1374
1330 1375
1331(defvar bookmark-bmenu-file-column 30
1332 "*Column at which to display filenames in a buffer listing bookmarks.
1333You can toggle whether files are shown with \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-toggle-filenames].")
1334
1335
1336(defvar bookmark-bmenu-toggle-filenames t
1337 "*Non-nil means show filenames when listing bookmarks.
1338This may result in truncated bookmark names. To disable this, put the
1339following in your .emacs:
1340
1341\(setq bookmark-bmenu-toggle-filenames nil\)")
1342
1343
1344(defvar bookmark-bmenu-mode-map nil) 1376(defvar bookmark-bmenu-mode-map nil)
1345 1377
1346 1378
@@ -1482,12 +1514,12 @@ Bookmark names preceeded by a \"*\" have annotations.
1482 (run-hooks 'bookmark-bmenu-mode-hook)) 1514 (run-hooks 'bookmark-bmenu-mode-hook))
1483 1515
1484 1516
1485(defun bookmark-bmenu-toggle-filenames (&optional parg) 1517(defun bookmark-bmenu-toggle-filenames (&optional show)
1486 "Toggle whether filenames are shown in the bookmark list. 1518 "Toggle whether filenames are shown in the bookmark list.
1487Optional argument SHOW means show them unconditionally." 1519Optional argument SHOW means show them unconditionally."
1488 (interactive) 1520 (interactive)
1489 (cond 1521 (cond
1490 (parg 1522 (show
1491 (setq bookmark-bmenu-toggle-filenames nil) 1523 (setq bookmark-bmenu-toggle-filenames nil)
1492 (bookmark-bmenu-show-filenames) 1524 (bookmark-bmenu-show-filenames)
1493 (setq bookmark-bmenu-toggle-filenames t)) 1525 (setq bookmark-bmenu-toggle-filenames t))
@@ -1656,20 +1688,19 @@ You can mark bookmarks with the \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-mar
1656 (delete-char -1) 1688 (delete-char -1)
1657 (insert ?\ )) 1689 (insert ?\ ))
1658 (or (string-equal tem bmrk) 1690 (or (string-equal tem bmrk)
1659 (memq tem others) 1691 (member tem others)
1660 (setq others (cons tem others)))) 1692 (setq others (cons tem others))))
1661 (setq others (nreverse others) 1693 (setq others (nreverse others)
1662 tem (/ (1- (frame-height)) (1+ (length others)))) 1694 tem (/ (1- (frame-height)) (1+ (length others))))
1663 (delete-other-windows) 1695 (delete-other-windows)
1664 (bookmark-jump bmrk) 1696 (bookmark-jump bmrk)
1665 (bury-buffer menu) 1697 (bury-buffer menu)
1666 (if (equal (length others) 0) 1698 (if others
1667 nil 1699 (while others
1668 (while others 1700 (split-window nil tem)
1669 (split-window nil tem) 1701 (other-window 1)
1670 (other-window 1) 1702 (bookmark-jump (car others))
1671 (bookmark-jump (car others)) 1703 (setq others (cdr others)))
1672 (setq others (cdr others)))
1673 (other-window 1))))) 1704 (other-window 1)))))
1674 1705
1675 1706
@@ -1791,7 +1822,7 @@ The current window remains selected."
1791 1822
1792(defun bookmark-bmenu-unmark (&optional backup) 1823(defun bookmark-bmenu-unmark (&optional backup)
1793 "Cancel all requested operations on bookmark on this line and move down. 1824 "Cancel all requested operations on bookmark on this line and move down.
1794Optional ARG means move up." 1825Optional BACKUP means move up."
1795 (interactive "P") 1826 (interactive "P")
1796 (beginning-of-line) 1827 (beginning-of-line)
1797 (if (bookmark-bmenu-check-position) 1828 (if (bookmark-bmenu-check-position)
@@ -1895,10 +1926,6 @@ and then move up one line"
1895 1926
1896;;; Menu bar stuff. Prefix is "bookmark-menu". 1927;;; Menu bar stuff. Prefix is "bookmark-menu".
1897 1928
1898(defvar bookmark-menu-length 70
1899 "*Maximum length of a bookmark name displayed on a popup menu.")
1900
1901
1902(defun bookmark-menu-build-paned-menu (name entries) 1929(defun bookmark-menu-build-paned-menu (name entries)
1903 "Build a multi-paned menu named NAME from the strings in ENTRIES. 1930 "Build a multi-paned menu named NAME from the strings in ENTRIES.
1904That is, ENTRIES is a list of strings which appear as the choices 1931That is, ENTRIES is a list of strings which appear as the choices
@@ -1967,7 +1994,11 @@ The number of panes depends on the number of bookmarks."
1967You may have a problem using this function if the value of variable 1994You may have a problem using this function if the value of variable
1968`bookmark-alist' is nil. If that happens, you need to load in some 1995`bookmark-alist' is nil. If that happens, you need to load in some
1969bookmarks. See help on function `bookmark-load' for more about 1996bookmarks. See help on function `bookmark-load' for more about
1970this." 1997this.
1998
1999Warning: this function only takes an EVENT as argument. Use the
2000corresponding bookmark function from Lisp \(the one without the
2001\"-menu-\" in its name\)."
1971 (interactive "e") 2002 (interactive "e")
1972 (bookmark-popup-menu-and-apply-function 2003 (bookmark-popup-menu-and-apply-function
1973 'bookmark-insert "Insert Bookmark Contents" event)) 2004 'bookmark-insert "Insert Bookmark Contents" event))
@@ -1979,7 +2010,11 @@ this."
1979You may have a problem using this function if the value of variable 2010You may have a problem using this function if the value of variable
1980`bookmark-alist' is nil. If that happens, you need to load in some 2011`bookmark-alist' is nil. If that happens, you need to load in some
1981bookmarks. See help on function `bookmark-load' for more about 2012bookmarks. See help on function `bookmark-load' for more about
1982this." 2013this.
2014
2015Warning: this function only takes an EVENT as argument. Use the
2016corresponding bookmark function from Lisp \(the one without the
2017\"-menu-\" in its name\)."
1983 (interactive "e") 2018 (interactive "e")
1984 (bookmark-popup-menu-and-apply-function 2019 (bookmark-popup-menu-and-apply-function
1985 'bookmark-jump "Jump to Bookmark" event)) 2020 'bookmark-jump "Jump to Bookmark" event))
@@ -1988,7 +2023,11 @@ this."
1988;;;###autoload 2023;;;###autoload
1989(defun bookmark-menu-locate (event) 2024(defun bookmark-menu-locate (event)
1990 "Insert the name of the file associated with BOOKMARK. 2025 "Insert the name of the file associated with BOOKMARK.
1991\(This is not the same as the contents of that file\)." 2026\(This is not the same as the contents of that file\).
2027
2028Warning: this function only takes an EVENT as argument. Use the
2029corresponding bookmark function from Lisp \(the one without the
2030\"-menu-\" in its name\)."
1992 (interactive "e") 2031 (interactive "e")
1993 (bookmark-popup-menu-and-apply-function 2032 (bookmark-popup-menu-and-apply-function
1994 'bookmark-insert-location "Insert Bookmark Location" event)) 2033 'bookmark-insert-location "Insert Bookmark Location" event))
@@ -2006,7 +2045,11 @@ is done. You must pass at least OLD-BOOKMARK when calling from Lisp.
2006 2045
2007While you are entering the new name, consecutive C-w's insert 2046While you are entering the new name, consecutive C-w's insert
2008consectutive words from the text of the buffer into the new bookmark 2047consectutive words from the text of the buffer into the new bookmark
2009name." 2048name.
2049
2050Warning: this function only takes an EVENT as argument. Use the
2051corresponding bookmark function from Lisp \(the one without the
2052\"-menu-\" in its name\)."
2010 (interactive "e") 2053 (interactive "e")
2011 (bookmark-popup-menu-and-apply-function 2054 (bookmark-popup-menu-and-apply-function
2012 'bookmark-rename "Rename Bookmark" event)) 2055 'bookmark-rename "Rename Bookmark" event))
@@ -2018,7 +2061,11 @@ name."
2018Removes only the first instance of a bookmark with that name. If 2061Removes only the first instance of a bookmark with that name. If
2019there are one or more other bookmarks with the same name, they will 2062there are one or more other bookmarks with the same name, they will
2020not be deleted. Defaults to the \"current\" bookmark \(that is, the 2063not be deleted. Defaults to the \"current\" bookmark \(that is, the
2021one most recently used in this file, if any\)." 2064one most recently used in this file, if any\).
2065
2066Warning: this function only takes an EVENT as argument. Use the
2067corresponding bookmark function from Lisp \(the one without the
2068\"-menu-\" in its name\)."
2022 (interactive "e") 2069 (interactive "e")
2023 (bookmark-popup-menu-and-apply-function 2070 (bookmark-popup-menu-and-apply-function
2024 'bookmark-delete "Delete Bookmark" event)) 2071 'bookmark-delete "Delete Bookmark" event))
@@ -2034,7 +2081,7 @@ one most recently used in this file, if any\)."
2034(defvar menu-bar-bookmark-map (make-sparse-keymap "Bookmark functions")) 2081(defvar menu-bar-bookmark-map (make-sparse-keymap "Bookmark functions"))
2035 2082
2036;;;###autoload 2083;;;###autoload
2037(fset 'menu-bar-bookmark-map (symbol-value 'menu-bar-bookmark-map)) 2084(defalias 'menu-bar-bookmark-map (symbol-value 'menu-bar-bookmark-map))
2038 2085
2039;;;###autoload 2086;;;###autoload
2040(define-key menu-bar-bookmark-map [load] 2087(define-key menu-bar-bookmark-map [load]