38436
|
1 ;;; bookmark.el --- set bookmarks, maybe annotate them, jump to them later
|
4537
|
2
|
36588
|
3 ;; Copyright (C) 1993, 1994, 1995, 1996, 1997, 2001 Free Software Foundation
|
4537
|
4
|
14039
|
5 ;; Author: Karl Fogel <kfogel@red-bean.com>
|
|
6 ;; Maintainer: Karl Fogel <kfogel@red-bean.com>
|
4537
|
7 ;; Created: July, 1993
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
8 ;; Keywords: bookmarks, placeholders, annotations
|
4537
|
9
|
|
10 ;; This file is part of GNU Emacs.
|
|
11
|
|
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
13 ;; it under the terms of the GNU General Public License as published by
|
|
14 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
15 ;; any later version.
|
|
16
|
|
17 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20 ;; GNU General Public License for more details.
|
|
21
|
|
22 ;; You should have received a copy of the GNU General Public License
|
14169
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
25 ;; Boston, MA 02111-1307, USA.
|
|
26
|
|
27 ;;; Commentary:
|
|
28
|
|
29 ;; This package is for setting "bookmarks" in files. A bookmark
|
|
30 ;; associates a string with a location in a certain file. Thus, you
|
|
31 ;; can navigate your way to that location by providing the string.
|
|
32 ;; See the "User Variables" section for customizations.
|
4537
|
33
|
|
34 ;; Thanks to David Bremner <bremner@cs.sfu.ca> for thinking of and
|
|
35 ;; then implementing the bookmark-current-bookmark idea. He even
|
4891
|
36 ;; sent *patches*, bless his soul...
|
4537
|
37
|
|
38 ;; Thanks to Gregory M. Saunders <saunders@cis.ohio-state.edu> for
|
|
39 ;; fixing and improving bookmark-time-to-save-p.
|
|
40
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
41 ;; Thanks go to Andrew V. Klein <avk@cig.mot.com> for the code that
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
42 ;; sorts the alist before presenting it to the user (in bookmark-bmenu-list
|
4891
|
43 ;; and the menu-bar).
|
|
44
|
4848
|
45 ;; And much thanks to David Hughes <djh@harston.cv.com> for many small
|
|
46 ;; suggestions and the code to implement them (like
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
47 ;; bookmark-bmenu-check-position, and some of the Lucid compatibility
|
4848
|
48 ;; stuff).
|
|
49
|
14039
|
50 ;; Kudos (whatever they are) go to Jim Blandy <jimb@red-bean.com>
|
4891
|
51 ;; for his eminently sensible suggestion to separate bookmark-jump
|
|
52 ;; into bookmark-jump and bookmark-jump-noselect, which made many
|
|
53 ;; other things cleaner as well.
|
|
54
|
4848
|
55 ;; Thanks to Roland McGrath for encouragement and help with defining
|
|
56 ;; autoloads on the menu-bar.
|
|
57
|
12880
|
58 ;; Jonathan Stigelman <stig@hackvan.com> gave patches for default
|
4891
|
59 ;; values in bookmark-jump and bookmark-set. Everybody please keep
|
|
60 ;; all the keystrokes they save thereby and send them to him at the
|
|
61 ;; end of each year :-) (No, seriously, thanks Jonathan!)
|
|
62
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
63 ;; Buckets of gratitude to John Grabowski <johng@media.mit.edu> for
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
64 ;; thinking up the annotations feature and implementing it so well.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
65
|
4537
|
66 ;; Based on info-bookmark.el, by Karl Fogel and Ken Olstad
|
|
67 ;; <olstad@msc.edu>.
|
|
68
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
69 ;; Thanks to Mikio Nakajima <PBC01764@niftyserve.or.jp> for many bugs
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
70 ;; reported and fixed.
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
71
|
13895
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
72 ;; Thank you, Michael Kifer, for contributing the XEmacs support.
|
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
73
|
4848
|
74 ;; Enough with the credits already, get on to the good stuff:
|
4537
|
75
|
35283
|
76 ;; FAVORITE CHINESE RESTAURANT:
|
4537
|
77 ;; Boy, that's a tough one. Probably Hong Min, or maybe Emperor's
|
|
78 ;; Choice (both in Chicago's Chinatown). Well, both. How about you?
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
79
|
38436
|
80 ;;; Code:
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
81
|
14169
|
82 (require 'pp)
|
|
83
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
84 ;;; Misc comments:
|
4537
|
85 ;;
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
86 ;; If variable bookmark-use-annotations is non-nil, an annotation is
|
35283
|
87 ;; queried for when setting a bookmark.
|
4595
|
88 ;;
|
4848
|
89 ;; The bookmark list is sorted lexically by default, but you can turn
|
|
90 ;; this off by setting bookmark-sort-flag to nil. If it is nil, then
|
|
91 ;; the list will be presented in the order it is recorded
|
|
92 ;; (chronologically), which is actually fairly useful as well.
|
4537
|
93
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
94 ;;; User Variables
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
95
|
17411
|
96 (defgroup bookmark nil
|
17412
|
97 "Setting, annotation and jumping to bookmarks."
|
17411
|
98 :group 'matching)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
99
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
100
|
17411
|
101 (defcustom bookmark-use-annotations nil
|
17412
|
102 "*If non-nil, saving a bookmark queries for an annotation in a buffer."
|
17411
|
103 :type 'boolean
|
|
104 :group 'bookmark)
|
|
105
|
|
106
|
|
107 (defcustom bookmark-save-flag t
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
108 "*Controls when Emacs saves bookmarks to a file.
|
17412
|
109 --> nil means never save bookmarks, except when `bookmark-save' is
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
110 explicitly called \(\\[bookmark-save]\).
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
111 --> t means save bookmarks when Emacs is killed.
|
13969
|
112 --> Otherwise, it should be a number that is the frequency with which
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
113 the bookmark list is saved \(i.e.: the number of times which
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
114 Emacs' bookmark list may be modified before it is automatically
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
115 saved.\). If it is a number, Emacs will also automatically save
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
116 bookmarks when it is killed.
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
117
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
118 Therefore, the way to get it to save every time you make or delete a
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
119 bookmark is to set this variable to 1 \(or 0, which produces the same
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
120 behavior.\)
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
121
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
122 To specify the file in which to save them, modify the variable
|
17412
|
123 `bookmark-default-file', which is `~/.emacs.bmk' by default."
|
22568
|
124 :type '(choice (const nil) integer (other t))
|
17411
|
125 :group 'bookmark)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
126
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
127
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
128 (defconst bookmark-old-default-file "~/.emacs-bkmrks"
|
17412
|
129 "*The `.emacs.bmk' file used to be called this name.")
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
130
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
131
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
132 ;; defvarred to avoid a compilation warning:
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
133 (defvar bookmark-file nil
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
134 "Old name for `bookmark-default-file'.")
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
135
|
17411
|
136 (defcustom bookmark-default-file
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
137 (if bookmark-file
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
138 ;; In case user set `bookmark-file' in her .emacs:
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
139 bookmark-file
|
16036
|
140 (convert-standard-filename "~/.emacs.bmk"))
|
17411
|
141 "*File in which to save bookmarks by default."
|
|
142 :type 'file
|
|
143 :group 'bookmark)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
144
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
145
|
17411
|
146 (defcustom bookmark-version-control 'nospecial
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
147 "*Whether or not to make numbered backups of the bookmark file.
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
148 It can have four values: t, nil, `never', and `nospecial'.
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
149 The first three have the same meaning that they do for the
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
150 variable `version-control', and the final value `nospecial' means just
|
17411
|
151 use the value of `version-control'."
|
22568
|
152 :type '(choice (const nil) (const never) (const nospecial)
|
|
153 (other t))
|
17411
|
154 :group 'bookmark)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
155
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
156
|
17411
|
157 (defcustom bookmark-completion-ignore-case t
|
|
158 "*Non-nil means bookmark functions ignore case in completion."
|
|
159 :type 'boolean
|
|
160 :group 'bookmark)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
161
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
162
|
17411
|
163 (defcustom bookmark-sort-flag t
|
17412
|
164 "*Non-nil means that bookmarks will be displayed sorted by bookmark name.
|
|
165 Otherwise they will be displayed in LIFO order (that is, most
|
17411
|
166 recently set ones come first, oldest ones come last)."
|
|
167 :type 'boolean
|
|
168 :group 'bookmark)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
169
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
170
|
17411
|
171 (defcustom bookmark-automatically-show-annotations t
|
42206
|
172 "*nil means don't show annotations when jumping to a bookmark."
|
17411
|
173 :type 'boolean
|
|
174 :group 'bookmark)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
175
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
176
|
17411
|
177 (defcustom bookmark-bmenu-file-column 30
|
|
178 "*Column at which to display filenames in a buffer listing bookmarks.
|
|
179 You can toggle whether files are shown with \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-toggle-filenames]."
|
|
180 :type 'integer
|
|
181 :group 'bookmark)
|
|
182
|
|
183
|
|
184 (defcustom bookmark-bmenu-toggle-filenames t
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
185 "*Non-nil means show filenames when listing bookmarks.
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
186 This may result in truncated bookmark names. To disable this, put the
|
17412
|
187 following in your `.emacs' file:
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
188
|
17411
|
189 \(setq bookmark-bmenu-toggle-filenames nil\)"
|
|
190 :type 'boolean
|
|
191 :group 'bookmark)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
192
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
193
|
17411
|
194 (defcustom bookmark-menu-length 70
|
|
195 "*Maximum length of a bookmark name displayed on a popup menu."
|
|
196 :type 'integer
|
|
197 :group 'boolean)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
198
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
199
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
200 ;;; No user-serviceable parts beyond this point.
|
4537
|
201
|
13895
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
202 ;; Is it XEmacs?
|
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
203 (defconst bookmark-xemacsp
|
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
204 (string-match "\\(Lucid\\|Xemacs\\)" emacs-version))
|
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
205
|
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
206
|
4537
|
207 ;; Added for lucid emacs compatibility, db
|
|
208 (or (fboundp 'defalias) (fset 'defalias 'fset))
|
|
209
|
4848
|
210 ;; suggested for lucid compatibility by david hughes:
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
211 (or (fboundp 'frame-height) (defalias 'frame-height 'screen-height))
|
4848
|
212
|
13895
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
213 ;; This variable is probably obsolete now...
|
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
214 (or (boundp 'baud-rate)
|
35283
|
215 ;; some random value higher than 9600
|
13895
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
216 (setq baud-rate 19200))
|
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
217
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
218
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
219
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
220 ;;; Keymap stuff:
|
18709
|
221
|
|
222 ;; Set up these bindings dumping time *only*;
|
|
223 ;; if the user alters them, don't override the user when loading bookmark.el.
|
4537
|
224
|
18709
|
225 ;;;###autoload (define-key ctl-x-map "rb" 'bookmark-jump)
|
|
226 ;;;###autoload (define-key ctl-x-map "rm" 'bookmark-set)
|
|
227 ;;;###autoload (define-key ctl-x-map "rl" 'bookmark-bmenu-list)
|
4537
|
228
|
4848
|
229 ;;;###autoload
|
4633
|
230 (defvar bookmark-map nil
|
|
231 "Keymap containing bindings to bookmark functions.
|
|
232 It is not bound to any key by default: to bind it
|
|
233 so that you have a bookmark prefix, just use `global-set-key' and bind a
|
|
234 key of your choice to `bookmark-map'. All interactive bookmark
|
4537
|
235 functions have a binding in this keymap.")
|
|
236
|
4848
|
237 ;;;###autoload
|
4537
|
238 (define-prefix-command 'bookmark-map)
|
|
239
|
|
240 ;; Read the help on all of these functions for details...
|
4848
|
241 ;;;###autoload
|
4537
|
242 (define-key bookmark-map "x" 'bookmark-set)
|
4848
|
243 ;;;###autoload
|
|
244 (define-key bookmark-map "m" 'bookmark-set) ; "m" for "mark"
|
|
245 ;;;###autoload
|
4537
|
246 (define-key bookmark-map "j" 'bookmark-jump)
|
4848
|
247 ;;;###autoload
|
|
248 (define-key bookmark-map "g" 'bookmark-jump) ; "g" for "go"
|
|
249 ;;;###autoload
|
4537
|
250 (define-key bookmark-map "i" 'bookmark-insert)
|
4848
|
251 ;;;###autoload
|
|
252 (define-key bookmark-map "e" 'edit-bookmarks)
|
|
253 ;;;###autoload
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
254 (define-key bookmark-map "f" 'bookmark-insert-location) ; "f" for "find"
|
4848
|
255 ;;;###autoload
|
4633
|
256 (define-key bookmark-map "r" 'bookmark-rename)
|
4848
|
257 ;;;###autoload
|
4537
|
258 (define-key bookmark-map "d" 'bookmark-delete)
|
4848
|
259 ;;;###autoload
|
4537
|
260 (define-key bookmark-map "l" 'bookmark-load)
|
4848
|
261 ;;;###autoload
|
|
262 (define-key bookmark-map "w" 'bookmark-write)
|
|
263 ;;;###autoload
|
4537
|
264 (define-key bookmark-map "s" 'bookmark-save)
|
|
265
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
266
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
267 ;;; The annotation maps.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
268 (defvar bookmark-read-annotation-mode-map (copy-keymap text-mode-map)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
269 "Keymap for composing an annotation for a bookmark.")
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
270
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
271 (define-key bookmark-read-annotation-mode-map "\C-c\C-c"
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
272 'bookmark-send-annotation)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
273
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
274
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
275
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
276 ;;; Core variables and data structures:
|
4634
|
277 (defvar bookmark-alist ()
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
278 "Association list of bookmarks and their records.
|
4634
|
279 You probably don't want to change the value of this alist yourself;
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
280 instead, let the various bookmark functions do it for you.
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
281
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
282 The format of the alist is
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
283
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
284 \(BOOKMARK1 BOOKMARK2 ...\)
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
285
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
286 where each BOOKMARK is of the form
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
287
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
288 \(NAME
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
289 \(filename . FILE\)
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
290 \(front-context-string . FRONT-STR\)
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
291 \(rear-context-string . REAR-STR\)
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
292 \(position . POS\)
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
293 \(info-node . POS\)
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
294 \(annotation . ANNOTATION\)\)
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
295
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
296 So the cdr of each bookmark is an alist too.
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
297 `info-node' is optional, by the way.")
|
4634
|
298
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
299
|
4848
|
300 (defvar bookmarks-already-loaded nil)
|
|
301
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
302
|
4537
|
303 ;; more stuff added by db.
|
4848
|
304
|
35283
|
305 (defvar bookmark-current-bookmark nil
|
4633
|
306 "Name of bookmark most recently used in the current file.
|
|
307 It is buffer local, used to make moving a bookmark forward
|
4631
|
308 through a file easier.")
|
4537
|
309
|
|
310 (make-variable-buffer-local 'bookmark-current-bookmark)
|
|
311
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
312
|
4537
|
313 (defvar bookmark-alist-modification-count 0
|
4633
|
314 "Number of modifications to bookmark list since it was last saved.")
|
4537
|
315
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
316
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
317 (defvar bookmark-search-size 16
|
4633
|
318 "Length of the context strings recorded on either side of a bookmark.")
|
4537
|
319
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
320
|
4537
|
321 (defvar bookmark-current-point 0)
|
|
322 (defvar bookmark-yank-point 0)
|
|
323 (defvar bookmark-current-buffer nil)
|
|
324
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
325
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
326
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
327 ;; Helper functions.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
328
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
329 ;; Only functions on this page and the next one (file formats) need to
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
330 ;; know anything about the format of bookmark-alist entries.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
331 ;; Everyone else should go through them.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
332
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
333 (defun bookmark-name-from-full-record (full-record)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
334 "Return name of FULL-RECORD \(an alist element instead of a string\)."
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
335 (car full-record))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
336
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
337
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
338 (defun bookmark-all-names ()
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
339 "Return a list of all current bookmark names."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
340 (bookmark-maybe-load-default-file)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
341 (mapcar
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
342 (lambda (full-record)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
343 (bookmark-name-from-full-record full-record))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
344 bookmark-alist))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
345
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
346
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
347 (defun bookmark-get-bookmark (bookmark)
|
37041
|
348 "Return the full entry for BOOKMARK in bookmark-alist.
|
|
349 If BOOKMARK is not a string, return nil."
|
|
350 (when (stringp bookmark)
|
|
351 (apply (if bookmark-completion-ignore-case
|
|
352 #'assoc-ignore-case
|
|
353 #'assoc)
|
|
354 (list bookmark bookmark-alist))))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
355
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
356
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
357 (defun bookmark-get-bookmark-record (bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
358 "Return the guts of the entry for BOOKMARK in bookmark-alist.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
359 That is, all information but the name."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
360 (car (cdr (bookmark-get-bookmark bookmark))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
361
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
362
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
363 (defun bookmark-set-name (bookmark newname)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
364 "Set BOOKMARK's name to NEWNAME."
|
19472
|
365 (setcar
|
|
366 (if (stringp bookmark) (bookmark-get-bookmark bookmark) bookmark)
|
|
367 newname))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
368
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
369
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
370 (defun bookmark-get-annotation (bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
371 "Return the annotation of BOOKMARK, or nil if none."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
372 (cdr (assq 'annotation (bookmark-get-bookmark-record bookmark))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
373
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
374
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
375 (defun bookmark-set-annotation (bookmark ann)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
376 "Set the annotation of BOOKMARK to ANN."
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
377 (let ((cell (assq 'annotation (bookmark-get-bookmark-record bookmark))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
378 (if cell
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
379 (setcdr cell ann)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
380 (nconc (bookmark-get-bookmark-record bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
381 (list (cons 'annotation ann))))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
382
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
383
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
384 (defun bookmark-get-filename (bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
385 "Return the full filename of BOOKMARK."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
386 (cdr (assq 'filename (bookmark-get-bookmark-record bookmark))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
387
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
388
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
389 (defun bookmark-set-filename (bookmark filename)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
390 "Set the full filename of BOOKMARK to FILENAME."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
391 (let ((cell (assq 'filename (bookmark-get-bookmark-record bookmark))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
392 (if cell
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
393 (setcdr cell filename)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
394 (nconc (bookmark-get-bookmark-record bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
395 (list (cons 'filename filename))))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
396
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
397
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
398 (defun bookmark-get-position (bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
399 "Return the position \(i.e.: point\) of BOOKMARK."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
400 (cdr (assq 'position (bookmark-get-bookmark-record bookmark))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
401
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
402
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
403 (defun bookmark-set-position (bookmark position)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
404 "Set the position \(i.e.: point\) of BOOKMARK to POSITION."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
405 (let ((cell (assq 'position (bookmark-get-bookmark-record bookmark))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
406 (if cell
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
407 (setcdr cell position)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
408 (nconc (bookmark-get-bookmark-record bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
409 (list (cons 'position position))))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
410
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
411
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
412 (defun bookmark-get-front-context-string (bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
413 "Return the front-context-string of BOOKMARK."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
414 (cdr (assq 'front-context-string (bookmark-get-bookmark-record bookmark))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
415
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
416
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
417 (defun bookmark-set-front-context-string (bookmark string)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
418 "Set the front-context-string of BOOKMARK to STRING."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
419 (let ((cell (assq 'front-context-string
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
420 (bookmark-get-bookmark-record bookmark))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
421 (if cell
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
422 (setcdr cell string)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
423 (nconc (bookmark-get-bookmark-record bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
424 (list (cons 'front-context-string string))))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
425
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
426
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
427 (defun bookmark-get-rear-context-string (bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
428 "Return the rear-context-string of BOOKMARK."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
429 (cdr (assq 'rear-context-string (bookmark-get-bookmark-record bookmark))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
430
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
431
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
432 (defun bookmark-set-rear-context-string (bookmark string)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
433 "Set the rear-context-string of BOOKMARK to STRING."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
434 (let ((cell (assq 'rear-context-string
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
435 (bookmark-get-bookmark-record bookmark))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
436 (if cell
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
437 (setcdr cell string)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
438 (nconc (bookmark-get-bookmark-record bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
439 (list (cons 'rear-context-string string))))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
440
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
441
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
442 (defun bookmark-get-info-node (bookmark)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
443 "Get the info node associated with BOOKMARK."
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
444 (cdr (assq 'info-node (bookmark-get-bookmark-record bookmark))))
|
35283
|
445
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
446
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
447 (defun bookmark-set-info-node (bookmark node)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
448 "Set the Info node of BOOKMARK to NODE."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
449 (let ((cell (assq 'info-node
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
450 (bookmark-get-bookmark-record bookmark))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
451 (if cell
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
452 (setcdr cell node)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
453 (nconc (bookmark-get-bookmark-record bookmark)
|
15183
|
454 (list (cons 'info-node node)))))
|
|
455
|
|
456 (message "%S" (assq 'info-node (bookmark-get-bookmark-record bookmark)))
|
|
457 (sit-for 4)
|
|
458 )
|
35283
|
459
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
460
|
10994
|
461 (defvar bookmark-history nil
|
|
462 "The history list for bookmark functions.")
|
|
463
|
|
464
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
465 (defun bookmark-completing-read (prompt &optional default)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
466 "Prompting with PROMPT, read a bookmark name in completion.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
467 PROMPT will get a \": \" stuck on the end no matter what, so you
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
468 probably don't want to include one yourself.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
469 Optional second arg DEFAULT is a string to return if the user enters
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
470 the empty string."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
471 (bookmark-maybe-load-default-file) ; paranoia
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
472 (let* ((completion-ignore-case bookmark-completion-ignore-case)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
473 (default default)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
474 (prompt (if default
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
475 (concat prompt (format " (%s): " default))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
476 (concat prompt ": ")))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
477 (str
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
478 (completing-read prompt
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
479 bookmark-alist
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
480 nil
|
10994
|
481 0
|
|
482 nil
|
|
483 'bookmark-history)))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
484 (if (string-equal "" str)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
485 (list default)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
486 (list str))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
487
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
488
|
10994
|
489 (defmacro bookmark-maybe-historicize-string (string)
|
|
490 "Put STRING into the bookmark prompt history, if caller non-interactive.
|
|
491 We need this because sometimes bookmark functions are invoked from
|
|
492 menus, so `completing-read' never gets a chance to set `bookmark-history'."
|
35283
|
493 `(or
|
|
494 (interactive-p)
|
|
495 (setq bookmark-history (cons ,string bookmark-history))))
|
10994
|
496
|
|
497
|
15183
|
498 (defun bookmark-make (name &optional annotation overwrite info-node)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
499 "Make a bookmark named NAME.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
500 Optional second arg ANNOTATION gives it an annotation.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
501 Optional third arg OVERWRITE means replace any existing bookmarks with
|
15183
|
502 this name.
|
|
503 Optional fourth arg INFO-NODE means this bookmark is at info node
|
|
504 INFO-NODE, so record this fact in the bookmark's entry."
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
505 (bookmark-maybe-load-default-file)
|
12569
|
506 (let ((stripped-name (copy-sequence name)))
|
13895
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
507 (or bookmark-xemacsp
|
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
508 ;; XEmacs's `set-text-properties' doesn't work on
|
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
509 ;; free-standing strings, apparently.
|
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
510 (set-text-properties 0 (length stripped-name) nil stripped-name))
|
12569
|
511 (if (and (bookmark-get-bookmark stripped-name) (not overwrite))
|
13969
|
512 ;; already existing bookmark under that name and
|
12569
|
513 ;; no prefix arg means just overwrite old bookmark
|
|
514 (setcdr (bookmark-get-bookmark stripped-name)
|
15183
|
515 (list (bookmark-make-cell annotation info-node)))
|
35283
|
516
|
12569
|
517 ;; otherwise just cons it onto the front (either the bookmark
|
|
518 ;; doesn't exist already, or there is no prefix arg. In either
|
|
519 ;; case, we want the new bookmark consed onto the alist...)
|
35283
|
520
|
12569
|
521 (setq bookmark-alist
|
|
522 (cons
|
35283
|
523 (list stripped-name
|
15183
|
524 (bookmark-make-cell annotation info-node))
|
12569
|
525 bookmark-alist)))
|
35283
|
526
|
12569
|
527 ;; Added by db
|
|
528 (setq bookmark-current-bookmark stripped-name)
|
|
529 (setq bookmark-alist-modification-count
|
|
530 (1+ bookmark-alist-modification-count))
|
|
531 (if (bookmark-time-to-save-p)
|
|
532 (bookmark-save))))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
533
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
534
|
15183
|
535 (defun bookmark-make-cell (annotation &optional info-node)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
536 "Return the record part of a new bookmark, given ANNOTATION.
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
537 Must be at the correct position in the buffer in which the bookmark is
|
15183
|
538 being set. This might change someday.
|
|
539 Optional second arg INFO-NODE means this bookmark is at info node
|
|
540 INFO-NODE, so record this fact in the bookmark's entry."
|
|
541 (let ((the-record
|
41608
|
542 `((filename . ,(bookmark-buffer-file-name))
|
|
543 (front-context-string
|
|
544 . ,(if (>= (- (point-max) (point)) bookmark-search-size)
|
|
545 (buffer-substring-no-properties
|
|
546 (point)
|
|
547 (+ (point) bookmark-search-size))
|
|
548 nil))
|
|
549 (rear-context-string
|
|
550 . ,(if (>= (- (point) (point-min)) bookmark-search-size)
|
|
551 (buffer-substring-no-properties
|
|
552 (point)
|
|
553 (- (point) bookmark-search-size))
|
|
554 nil))
|
|
555 (position . ,(point)))))
|
15183
|
556
|
|
557 ;; Now fill in the optional parts:
|
19472
|
558
|
|
559 ;; Take no chances with text properties
|
|
560 (set-text-properties 0 (length annotation) nil annotation)
|
|
561 (set-text-properties 0 (length info-node) nil info-node)
|
|
562
|
15183
|
563 (if annotation
|
|
564 (nconc the-record (list (cons 'annotation annotation))))
|
|
565 (if info-node
|
|
566 (nconc the-record (list (cons 'info-node info-node))))
|
|
567
|
|
568 ;; Finally, return the completed record.
|
|
569 the-record))
|
35283
|
570
|
|
571
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
572
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
573 ;;; File format stuff
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
574
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
575 ;; The OLD format of the bookmark-alist was:
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
576 ;;
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
577 ;; ((bookmark-name (filename
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
578 ;; string-in-front
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
579 ;; string-behind
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
580 ;; point))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
581 ;; ...)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
582 ;;
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
583 ;; The NEW format of the bookmark-alist is:
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
584 ;;
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
585 ;; ((bookmark-name ((filename . FILENAME)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
586 ;; (front-context-string . string-in-front)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
587 ;; (rear-context-string . string-behind)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
588 ;; (position . POINT)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
589 ;; (annotation . annotation)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
590 ;; (whatever . VALUE)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
591 ;; ...
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
592 ;; ))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
593 ;; ...)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
594 ;;
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
595 ;;
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
596 ;; I switched to using an internal as well as external alist because I
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
597 ;; felt that would be a more flexible framework in which to add
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
598 ;; features. It means that the order in which values appear doesn't
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
599 ;; matter, and it means that arbitrary values can be added without
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
600 ;; risk of interfering with existing ones.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
601 ;;
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
602 ;; BOOKMARK-NAME is the string the user gives the bookmark and
|
35283
|
603 ;; accesses it by from then on.
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
604 ;;
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
605 ;; FILENAME is the location of the file in which the bookmark is set.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
606 ;;
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
607 ;; STRING-IN-FRONT is a string of `bookmark-search-size' chars of
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
608 ;; context in front of the point at which the bookmark is set.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
609 ;;
|
35283
|
610 ;; STRING-BEHIND is the same thing, but after the point.
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
611 ;;
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
612 ;; The context strings exist so that modifications to a file don't
|
35283
|
613 ;; necessarily cause a bookmark's position to be invalidated.
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
614 ;; bookmark-jump will search for STRING-BEHIND and STRING-IN-FRONT in
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
615 ;; case the file has changed since the bookmark was set. It will
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
616 ;; attempt to place the user before the changes, if there were any.
|
15183
|
617 ;; ANNOTATION is the annotation for the bookmark; it may not exist
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
618 ;; (for backward compatibility), be nil (no annotation), or be a
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
619 ;; string.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
620
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
621
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
622 (defconst bookmark-file-format-version 1
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
623 "The current version of the format used by bookmark files.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
624 You should never need to change this.")
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
625
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
626
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
627 (defconst bookmark-end-of-version-stamp-marker
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
628 "-*- End Of Bookmark File Format Version Stamp -*-\n"
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
629 "This string marks the end of the version stamp in a bookmark file.")
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
630
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
631
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
632 (defun bookmark-alist-from-buffer ()
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
633 "Return a bookmark-alist (in any format) from the current buffer.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
634 The buffer must of course contain bookmark format information.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
635 Does not care from where in the buffer it is called, and does not
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
636 affect point."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
637 (save-excursion
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
638 (goto-char (point-min))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
639 (if (search-forward bookmark-end-of-version-stamp-marker nil t)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
640 (read (current-buffer))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
641 ;; Else we're dealing with format version 0
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
642 (if (search-forward "(" nil t)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
643 (progn
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
644 (forward-char -1)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
645 (read (current-buffer)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
646 ;; Else no hope of getting information here.
|
14354
|
647 (error "Not bookmark format")))))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
648
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
649
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
650 (defun bookmark-upgrade-version-0-alist (old-list)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
651 "Upgrade a version 0 alist OLD-LIST to the current version."
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
652 (mapcar
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
653 (lambda (bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
654 (let* ((name (car bookmark))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
655 (record (car (cdr bookmark)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
656 (filename (nth 0 record))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
657 (front-str (nth 1 record))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
658 (rear-str (nth 2 record))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
659 (position (nth 3 record))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
660 (ann (nth 4 record)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
661 (list
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
662 name
|
41608
|
663 `((filename . ,filename)
|
|
664 (front-context-string . ,(or front-str ""))
|
|
665 (rear-context-string . ,(or rear-str ""))
|
|
666 (position . ,position)
|
|
667 (annotation . ,ann)))))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
668 old-list))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
669
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
670
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
671 (defun bookmark-upgrade-file-format-from-0 ()
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
672 "Upgrade a bookmark file of format 0 (the original format) to format 1.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
673 This expects to be called from point-min in a bookmark file."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
674 (message "Upgrading bookmark format from 0 to %d..."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
675 bookmark-file-format-version)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
676 (let* ((old-list (bookmark-alist-from-buffer))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
677 (new-list (bookmark-upgrade-version-0-alist old-list)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
678 (delete-region (point-min) (point-max))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
679 (bookmark-insert-file-format-version-stamp)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
680 (pp new-list (current-buffer))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
681 (save-buffer))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
682 (goto-char (point-min))
|
14039
|
683 (message "Upgrading bookmark format from 0 to %d...done"
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
684 bookmark-file-format-version)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
685 )
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
686
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
687
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
688 (defun bookmark-grok-file-format-version ()
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
689 "Return an integer which is the file-format version of this bookmark file.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
690 This expects to be called from point-min in a bookmark file."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
691 (if (looking-at "^;;;;")
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
692 (save-excursion
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
693 (save-match-data
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
694 (re-search-forward "[0-9]")
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
695 (forward-char -1)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
696 (read (current-buffer))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
697 ;; Else this is format version 0, the original one, which didn't
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
698 ;; even have version stamps.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
699 0))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
700
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
701
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
702 (defun bookmark-maybe-upgrade-file-format ()
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
703 "Check the file-format version of this bookmark file.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
704 If the version is not up-to-date, upgrade it automatically.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
705 This expects to be called from point-min in a bookmark file."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
706 (let ((version (bookmark-grok-file-format-version)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
707 (cond
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
708 ((= version bookmark-file-format-version)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
709 ) ; home free -- version is current
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
710 ((= version 0)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
711 (bookmark-upgrade-file-format-from-0))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
712 (t
|
14354
|
713 (error "Bookmark file format version strangeness")))))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
714
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
715
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
716 (defun bookmark-insert-file-format-version-stamp ()
|
15193
|
717 "Insert text indicating current version of bookmark file format."
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
718 (insert
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
719 (format ";;;; Emacs Bookmark Format Version %d ;;;;\n"
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
720 bookmark-file-format-version))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
721 (insert ";;; This format is meant to be slightly human-readable;\n"
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
722 ";;; nevertheless, you probably don't want to edit it.\n"
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
723 ";;; "
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
724 bookmark-end-of-version-stamp-marker))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
725
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
726
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
727 ;;; end file-format stuff
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
728
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
729
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
730 ;;; Core code:
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
731
|
4848
|
732 ;;;###autoload
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
733 (defun bookmark-set (&optional name parg)
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
734 "Set a bookmark named NAME inside a file.
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
735 If name is nil, then the user will be prompted.
|
4633
|
736 With prefix arg, will not overwrite a bookmark that has the same name
|
|
737 as NAME if such a bookmark already exists, but instead will \"push\"
|
|
738 the new bookmark onto the bookmark alist. Thus the most recently set
|
|
739 bookmark with name NAME would be the one in effect at any given time,
|
|
740 but the others are still there, should you decide to delete the most
|
|
741 recent one.
|
4537
|
742
|
|
743 To yank words from the text of the buffer and use them as part of the
|
4633
|
744 bookmark name, type C-w while setting a bookmark. Successive C-w's
|
4537
|
745 yank successive words.
|
|
746
|
10994
|
747 Typing C-u inserts the name of the last bookmark used in the buffer
|
|
748 \(as an aid in using a single bookmark name to track your progress
|
|
749 through a large file\). If no bookmark was used, then C-u inserts the
|
|
750 name of the file being visited.
|
4537
|
751
|
|
752 Use \\[bookmark-delete] to remove bookmarks \(you give it a name,
|
|
753 and it removes only the first instance of a bookmark with that name from
|
|
754 the list of bookmarks.\)"
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
755 (interactive (list nil current-prefix-arg))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
756 (or
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
757 (bookmark-buffer-file-name)
|
14354
|
758 (error "Buffer not visiting a file or directory"))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
759
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
760 (bookmark-maybe-load-default-file)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
761
|
4537
|
762 (setq bookmark-current-point (point))
|
|
763 (setq bookmark-yank-point (point))
|
|
764 (setq bookmark-current-buffer (current-buffer))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
765
|
4848
|
766 (let* ((default (or bookmark-current-bookmark
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
767 (bookmark-buffer-name)))
|
4848
|
768 (str
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
769 (or name
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
770 (read-from-minibuffer
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
771 (format "Set bookmark (%s): " default)
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
772 nil
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
773 (let ((now-map (copy-keymap minibuffer-local-map)))
|
19472
|
774 (define-key now-map "\C-w" 'bookmark-yank-word)
|
|
775 (define-key now-map "\C-u" 'bookmark-insert-current-bookmark)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
776 now-map))))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
777 (annotation nil))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
778 (and (string-equal str "") (setq str default))
|
35283
|
779 ;; Ask for an annotation buffer for this bookmark
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
780 (if bookmark-use-annotations
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
781 (bookmark-read-annotation parg str)
|
19472
|
782 (bookmark-make str annotation parg (bookmark-info-current-node))
|
|
783 (setq bookmark-current-bookmark str)
|
|
784 (bookmark-bmenu-surreptitiously-rebuild-list)
|
|
785 (goto-char bookmark-current-point))))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
786
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
787
|
15183
|
788 (defun bookmark-info-current-node ()
|
|
789 "If in Info-mode, return current node name (a string), else nil."
|
|
790 (if (eq major-mode 'Info-mode)
|
|
791 Info-current-node))
|
|
792
|
|
793
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
794 (defun bookmark-kill-line (&optional newline-too)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
795 "Kill from point to end of line.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
796 If optional arg NEWLINE-TOO is non-nil, delete the newline too.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
797 Does not affect the kill-ring."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
798 (let ((eol (save-excursion (end-of-line) (point))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
799 (delete-region (point) eol)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
800 (if (and newline-too (looking-at "\n"))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
801 (delete-char 1))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
802
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
803
|
10994
|
804 ;; Defvars to avoid compilation warnings:
|
|
805 (defvar bookmark-annotation-paragraph nil)
|
|
806 (defvar bookmark-annotation-name nil)
|
|
807 (defvar bookmark-annotation-buffer nil)
|
|
808 (defvar bookmark-annotation-file nil)
|
|
809 (defvar bookmark-annotation-point nil)
|
|
810
|
|
811
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
812 (defun bookmark-send-annotation ()
|
15193
|
813 "Use buffer contents as the annotation for a bookmark.
|
|
814 Exclude lines that begin with `#'.
|
|
815 Store the annotation text in the bookmark list with
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
816 the bookmark (and file, and point) specified in buffer local variables."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
817 (interactive)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
818 (if (not (eq major-mode 'bookmark-read-annotation-mode))
|
14354
|
819 (error "Not in bookmark-read-annotation-mode"))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
820 (goto-char (point-min))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
821 (while (< (point) (point-max))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
822 (if (looking-at "^#")
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
823 (bookmark-kill-line t)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
824 (forward-line 1)))
|
19472
|
825 (let ((annotation (buffer-string))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
826 (parg bookmark-annotation-paragraph)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
827 (bookmark bookmark-annotation-name)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
828 (pt bookmark-annotation-point)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
829 (buf bookmark-annotation-buffer))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
830 ;; for bookmark-make-cell to work, we need to be
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
831 ;; in the relevant buffer, at the relevant point.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
832 ;; Actually, bookmark-make-cell should probably be re-written,
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
833 ;; to avoid this need. Should I handle the error if a buffer is
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
834 ;; killed between "C-x r m" and a "C-c C-c" in the annotation buffer?
|
35283
|
835 (save-excursion
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
836 (pop-to-buffer buf)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
837 (goto-char pt)
|
15183
|
838 (bookmark-make bookmark annotation parg (bookmark-info-current-node))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
839 (setq bookmark-current-bookmark bookmark))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
840 (bookmark-bmenu-surreptitiously-rebuild-list)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
841 (goto-char bookmark-current-point))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
842 (kill-buffer (current-buffer)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
843
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
844
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
845 (defun bookmark-default-annotation-text (bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
846 (concat "# Type the annotation for bookmark '" bookmark "' here.\n"
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
847 "# All lines which start with a '#' will be deleted.\n"
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
848 "# Type C-c C-c when done.\n#\n"
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
849 "# Author: " (user-full-name) " <" (user-login-name) "@"
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
850 (system-name) ">\n"
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
851 "# Date: " (current-time-string) "\n"))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
852
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
853
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
854 (defvar bookmark-read-annotation-text-func 'bookmark-default-annotation-text
|
15193
|
855 "Function to return default text to use for a bookmark annotation.
|
|
856 It takes the name of the bookmark, as a string, as an arg.")
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
857
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
858 (defun bookmark-read-annotation-mode (buf point parg bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
859 "Mode for composing annotations for a bookmark.
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
860 Wants BUF POINT PARG and BOOKMARK.
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
861 When you have finished composing, type \\[bookmark-send-annotation] to send
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
862 the annotation.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
863
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
864 \\{bookmark-read-annotation-mode-map}
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
865 "
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
866 (interactive)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
867 (kill-all-local-variables)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
868 (make-local-variable 'bookmark-annotation-paragraph)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
869 (make-local-variable 'bookmark-annotation-name)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
870 (make-local-variable 'bookmark-annotation-buffer)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
871 (make-local-variable 'bookmark-annotation-file)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
872 (make-local-variable 'bookmark-annotation-point)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
873 (setq bookmark-annotation-paragraph parg)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
874 (setq bookmark-annotation-name bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
875 (setq bookmark-annotation-buffer buf)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
876 (setq bookmark-annotation-file (buffer-file-name buf))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
877 (setq bookmark-annotation-point point)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
878 (use-local-map bookmark-read-annotation-mode-map)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
879 (setq major-mode 'bookmark-read-annotation-mode)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
880 (insert (funcall bookmark-read-annotation-text-func bookmark))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
881 (run-hooks 'text-mode-hook))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
882
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
883
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
884 (defun bookmark-read-annotation (parg bookmark)
|
15193
|
885 "Pop up a buffer for entering a bookmark annotation.
|
|
886 Text surrounding the bookmark is PARG; the bookmark name is BOOKMARK."
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
887 (let ((buf (current-buffer))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
888 (point (point)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
889 (pop-to-buffer (generate-new-buffer-name "*Bookmark Annotation Compose*"))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
890 (bookmark-read-annotation-mode buf point parg bookmark)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
891
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
892
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
893 (defvar bookmark-edit-annotation-mode-map (copy-keymap text-mode-map)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
894 "Keymap for editing an annotation of a bookmark.")
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
895
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
896
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
897 (define-key bookmark-edit-annotation-mode-map "\C-c\C-c"
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
898 'bookmark-send-edited-annotation)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
899
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
900
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
901 (defun bookmark-edit-annotation-mode (bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
902 "Mode for editing the annotation of bookmark BOOKMARK.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
903 When you have finished composing, type \\[bookmark-send-annotation].
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
904
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
905 \\{bookmark-edit-annotation-mode-map}
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
906 "
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
907 (interactive)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
908 (kill-all-local-variables)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
909 (make-local-variable 'bookmark-annotation-name)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
910 (setq bookmark-annotation-name bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
911 (use-local-map bookmark-edit-annotation-mode-map)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
912 (setq major-mode 'bookmark-edit-annotation-mode)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
913 (insert (funcall bookmark-read-annotation-text-func bookmark))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
914 (let ((annotation (bookmark-get-annotation bookmark)))
|
19472
|
915 (if (and annotation (not (string-equal annotation "")))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
916 (insert annotation)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
917 (run-hooks 'text-mode-hook))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
918
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
919
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
920 (defun bookmark-send-edited-annotation ()
|
15193
|
921 "Use buffer contents (minus beginning with `#' as annotation for a bookmark."
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
922 (interactive)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
923 (if (not (eq major-mode 'bookmark-edit-annotation-mode))
|
14354
|
924 (error "Not in bookmark-edit-annotation-mode"))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
925 (goto-char (point-min))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
926 (while (< (point) (point-max))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
927 (if (looking-at "^#")
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
928 (bookmark-kill-line t)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
929 (forward-line 1)))
|
19472
|
930 (let ((annotation (buffer-string))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
931 (bookmark bookmark-annotation-name))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
932 (bookmark-set-annotation bookmark annotation)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
933 (bookmark-bmenu-surreptitiously-rebuild-list)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
934 (goto-char bookmark-current-point))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
935 (kill-buffer (current-buffer)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
936
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
937
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
938 (defun bookmark-edit-annotation (bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
939 "Pop up a buffer for editing bookmark BOOKMARK's annotation."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
940 (let ((buf (current-buffer))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
941 (point (point)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
942 (pop-to-buffer (generate-new-buffer-name "*Bookmark Annotation Compose*"))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
943 (bookmark-edit-annotation-mode bookmark)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
944
|
4537
|
945
|
|
946 (defun bookmark-insert-current-bookmark ()
|
15193
|
947 "Insert this buffer's value of bookmark-current-bookmark.
|
|
948 Default to file name if it's nil."
|
4537
|
949 (interactive)
|
|
950 (let ((str
|
|
951 (save-excursion
|
|
952 (set-buffer bookmark-current-buffer)
|
|
953 bookmark-current-bookmark)))
|
10960
|
954 (if str (insert str) (bookmark-insert-buffer-name))))
|
4537
|
955
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
956
|
10960
|
957 (defun bookmark-insert-buffer-name ()
|
15193
|
958 "Insert the current file name into the bookmark name being set.
|
|
959 The directory part of the file name is not used."
|
4537
|
960 (interactive)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
961 (let ((str
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
962 (save-excursion
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
963 (set-buffer bookmark-current-buffer)
|
10960
|
964 (bookmark-buffer-name))))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
965 (insert str)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
966
|
4537
|
967
|
10960
|
968 (defun bookmark-buffer-name ()
|
|
969 "Return the name of the current buffer's file, non-directory.
|
|
970 In Info, return the current node."
|
|
971 (cond
|
|
972 ;; Are we in Info?
|
|
973 ((string-equal mode-name "Info") Info-current-node)
|
|
974 ;; Or are we a file?
|
|
975 (buffer-file-name (file-name-nondirectory buffer-file-name))
|
|
976 ;; Or are we a directory?
|
|
977 ((and (boundp 'dired-directory) dired-directory)
|
|
978 (let* ((dirname (if (stringp dired-directory)
|
|
979 dired-directory
|
|
980 (car dired-directory)))
|
|
981 (idx (1- (length dirname))))
|
|
982 ;; Strip the trailing slash.
|
|
983 (if (= ?/ (aref dirname idx))
|
|
984 (file-name-nondirectory (substring dirname 0 idx))
|
|
985 ;; Else return the current-buffer
|
|
986 (buffer-name (current-buffer)))))
|
|
987 ;; If all else fails, use the buffer's name.
|
|
988 (t
|
|
989 (buffer-name (current-buffer)))))
|
|
990
|
|
991
|
4537
|
992 (defun bookmark-yank-word ()
|
|
993 (interactive)
|
|
994 ;; get the next word from the buffer and append it to the name of
|
|
995 ;; the bookmark currently being set.
|
|
996 (let ((string (save-excursion
|
4848
|
997 (set-buffer bookmark-current-buffer)
|
|
998 (goto-char bookmark-yank-point)
|
12569
|
999 (buffer-substring-no-properties
|
4848
|
1000 (point)
|
19472
|
1001 (progn
|
4848
|
1002 (forward-word 1)
|
|
1003 (setq bookmark-yank-point (point)))))))
|
4537
|
1004 (insert string)))
|
|
1005
|
|
1006
|
|
1007 (defun bookmark-buffer-file-name ()
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1008 "Return the current buffer's file in a way useful for bookmarks.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1009 For example, if this is a Info buffer, return the Info file's name."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1010 (if (eq major-mode 'Info-mode)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1011 Info-current-file
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1012 (or
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1013 buffer-file-name
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1014 (if (and (boundp 'dired-directory) dired-directory)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1015 (if (stringp dired-directory)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1016 dired-directory
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1017 (car dired-directory))))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1018
|
4537
|
1019
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1020 (defun bookmark-maybe-load-default-file ()
|
4848
|
1021 (and (not bookmarks-already-loaded)
|
|
1022 (null bookmark-alist)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1023 (prog2
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1024 (and
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1025 ;; Possibly the old bookmark file, "~/.emacs-bkmrks", needs
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1026 ;; to be renamed.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1027 (file-exists-p (expand-file-name bookmark-old-default-file))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1028 (not (file-exists-p (expand-file-name bookmark-default-file)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1029 (rename-file (expand-file-name bookmark-old-default-file)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1030 (expand-file-name bookmark-default-file)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1031 ;; return t so the `and' will continue...
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1032 t)
|
35283
|
1033
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1034 (file-readable-p (expand-file-name bookmark-default-file))
|
19472
|
1035 (bookmark-load bookmark-default-file t t)
|
|
1036 (setq bookmarks-already-loaded t)))
|
4631
|
1037
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1038
|
4848
|
1039 (defun bookmark-maybe-sort-alist ()
|
|
1040 ;;Return the bookmark-alist for display. If the bookmark-sort-flag
|
|
1041 ;;is non-nil, then return a sorted copy of the alist.
|
|
1042 (if bookmark-sort-flag
|
|
1043 (setq bookmark-alist
|
|
1044 (sort (copy-alist bookmark-alist)
|
|
1045 (function
|
|
1046 (lambda (x y) (string-lessp (car x) (car y))))))))
|
|
1047
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1048
|
4848
|
1049 ;;;###autoload
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1050 (defun bookmark-jump (bookmark)
|
35283
|
1051 "Jump to bookmark BOOKMARK (a point in some file).
|
4633
|
1052 You may have a problem using this function if the value of variable
|
|
1053 `bookmark-alist' is nil. If that happens, you need to load in some
|
|
1054 bookmarks. See help on function `bookmark-load' for more about
|
4848
|
1055 this.
|
|
1056
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1057 If the file pointed to by BOOKMARK no longer exists, you will be asked
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1058 if you wish to give the bookmark a new location, and bookmark-jump
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1059 will then jump to the new location, as well as recording it in place
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1060 of the old one in the permanent bookmark record."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1061 (interactive
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1062 (bookmark-completing-read "Jump to bookmark" bookmark-current-bookmark))
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1063 (bookmark-maybe-historicize-string bookmark)
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1064 (let ((cell (bookmark-jump-noselect bookmark)))
|
4848
|
1065 (and cell
|
|
1066 (switch-to-buffer (car cell))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1067 (goto-char (cdr cell))
|
11070
|
1068 (if bookmark-automatically-show-annotations
|
|
1069 ;; if there is an annotation for this bookmark,
|
|
1070 ;; show it in a buffer.
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1071 (bookmark-show-annotation bookmark)))))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1072
|
4537
|
1073
|
28013
|
1074 (defun bookmark-file-or-variation-thereof (file)
|
|
1075 "Return FILE (a string) if it exists in any reasonable variation, else nil.
|
|
1076 Reasonable variations are FILE.gz, FILE.Z, FILE.info, FILE.info.gz, etc."
|
35283
|
1077 (cond
|
28013
|
1078 ((file-exists-p file) file)
|
|
1079 ((file-exists-p (concat file ".Z")) (concat file ".Z"))
|
|
1080 ((file-exists-p (concat file ".gz")) (concat file ".gz"))
|
|
1081 ((file-exists-p (concat file ".z")) (concat file ".z"))
|
|
1082 ((file-exists-p (concat file ".info")) (concat file ".info"))
|
|
1083 ((file-exists-p (concat file ".info.gz")) (concat file ".info.gz"))
|
|
1084 ((file-exists-p (concat file ".info.Z")) (concat file ".info.Z"))
|
|
1085 ((file-exists-p (concat file ".info.z")) (concat file ".info.z"))
|
|
1086 ((vc-backend file) file) ; maybe VC has it?
|
|
1087 (t nil)))
|
|
1088
|
|
1089
|
4848
|
1090 (defun bookmark-jump-noselect (str)
|
|
1091 ;; a leetle helper for bookmark-jump :-)
|
|
1092 ;; returns (BUFFER . POINT)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1093 (bookmark-maybe-load-default-file)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1094 (let* ((file (expand-file-name (bookmark-get-filename str)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1095 (forward-str (bookmark-get-front-context-string str))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1096 (behind-str (bookmark-get-rear-context-string str))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1097 (place (bookmark-get-position str))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1098 (info-node (bookmark-get-info-node str))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1099 (orig-file file)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1100 )
|
28013
|
1101 (if (setq file (bookmark-file-or-variation-thereof file))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1102 (save-excursion
|
22251
|
1103 (save-window-excursion
|
|
1104 (if info-node
|
|
1105 ;; Info nodes must be visited with care.
|
|
1106 (progn
|
|
1107 (require 'info)
|
|
1108 (Info-find-node file info-node))
|
|
1109 ;; Else no Info. Can do an ordinary find-file:
|
|
1110 (set-buffer (find-file-noselect file))
|
|
1111 (goto-char place))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1112
|
22251
|
1113 ;; Go searching forward first. Then, if forward-str exists and
|
|
1114 ;; was found in the file, we can search backward for behind-str.
|
|
1115 ;; Rationale is that if text was inserted between the two in the
|
|
1116 ;; file, it's better to be put before it so you can read it,
|
|
1117 ;; rather than after and remain perhaps unaware of the changes.
|
|
1118 (if forward-str
|
|
1119 (if (search-forward forward-str (point-max) t)
|
|
1120 (goto-char (match-beginning 0))))
|
|
1121 (if behind-str
|
|
1122 (if (search-backward behind-str (point-min) t)
|
|
1123 (goto-char (match-end 0))))
|
|
1124 ;; added by db
|
|
1125 (setq bookmark-current-bookmark str)
|
|
1126 (cons (current-buffer) (point))))
|
|
1127
|
19472
|
1128 ;; Else unable to find the marked file, so ask if user wants to
|
|
1129 ;; relocate the bookmark, else remind them to consider deletion.
|
|
1130 (ding)
|
|
1131 (if (y-or-n-p (concat (file-name-nondirectory orig-file)
|
|
1132 " nonexistent. Relocate \""
|
|
1133 str
|
|
1134 "\"? "))
|
|
1135 (progn
|
|
1136 (bookmark-relocate str)
|
|
1137 ;; gasp! It's a recursive function call in Emacs Lisp!
|
|
1138 (bookmark-jump-noselect str))
|
35283
|
1139 (message
|
19472
|
1140 "Bookmark not relocated; consider removing it \(%s\)." str)
|
|
1141 nil))))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1142
|
4848
|
1143
|
|
1144 ;;;###autoload
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1145 (defun bookmark-relocate (bookmark)
|
15193
|
1146 "Relocate BOOKMARK to another file (reading file name with minibuffer).
|
|
1147 This makes an already existing bookmark point to that file, instead of
|
|
1148 the one it used to point at. Useful when a file has been renamed
|
|
1149 after a bookmark was set in it."
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1150 (interactive (bookmark-completing-read "Bookmark to relocate"))
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1151 (bookmark-maybe-historicize-string bookmark)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1152 (bookmark-maybe-load-default-file)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1153 (let* ((bmrk-filename (bookmark-get-filename bookmark))
|
4848
|
1154 (newloc (expand-file-name
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1155 (read-file-name
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1156 (format "Relocate %s to: " bookmark)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1157 (file-name-directory bmrk-filename)))))
|
19472
|
1158 (bookmark-set-filename bookmark newloc)
|
|
1159 (bookmark-bmenu-surreptitiously-rebuild-list)))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1160
|
4537
|
1161
|
4848
|
1162 ;;;###autoload
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1163 (defun bookmark-insert-location (bookmark &optional no-history)
|
10994
|
1164 "Insert the name of the file associated with BOOKMARK.
|
|
1165 Optional second arg NO-HISTORY means don't record this in the
|
|
1166 minibuffer history list `bookmark-history'."
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1167 (interactive (bookmark-completing-read "Insert bookmark location"))
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1168 (or no-history (bookmark-maybe-historicize-string bookmark))
|
17265
|
1169 (let ((start (point)))
|
|
1170 (prog1
|
|
1171 (insert (bookmark-location bookmark)) ; *Return this line*
|
29476
0797cad76554
Applied this patch from Eli Zaretskii. Pretty much taking on faith
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
1172 (if (and (display-color-p) (display-mouse-p))
|
38173
|
1173 (add-text-properties start
|
|
1174 (save-excursion (re-search-backward
|
|
1175 "[^ \t]")
|
|
1176 (1+ (point)))
|
|
1177 '(mouse-face highlight
|
|
1178 help-echo "mouse-2: go to this bookmark"))))))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1179
|
15189
|
1180 ;;;###autoload
|
15183
|
1181 (defalias 'bookmark-locate 'bookmark-insert-location)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1182
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1183 (defun bookmark-location (bookmark)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1184 "Return the name of the file associated with BOOKMARK."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1185 (bookmark-maybe-load-default-file)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1186 (bookmark-get-filename bookmark))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1187
|
4848
|
1188
|
|
1189 ;;;###autoload
|
4633
|
1190 (defun bookmark-rename (old &optional new)
|
15193
|
1191 "Change the name of OLD bookmark to NEW name.
|
|
1192 If called from keyboard, prompt for OLD and NEW. If called from
|
|
1193 menubar, select OLD from a menu and prompt for NEW.
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1194
|
15193
|
1195 If called from Lisp, prompt for NEW if only OLD was passed as an
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1196 argument. If called with two strings, then no prompting is done. You
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1197 must pass at least OLD when calling from Lisp.
|
4633
|
1198
|
|
1199 While you are entering the new name, consecutive C-w's insert
|
13969
|
1200 consecutive words from the text of the buffer into the new bookmark
|
10994
|
1201 name."
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1202 (interactive (bookmark-completing-read "Old bookmark name"))
|
10994
|
1203 (bookmark-maybe-historicize-string old)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1204 (bookmark-maybe-load-default-file)
|
19472
|
1205
|
|
1206 (setq bookmark-current-point (point))
|
|
1207 (setq bookmark-yank-point (point))
|
|
1208 (setq bookmark-current-buffer (current-buffer))
|
|
1209 (let ((newname
|
|
1210 (or new ; use second arg, if non-nil
|
|
1211 (read-from-minibuffer
|
|
1212 "New name: "
|
|
1213 nil
|
|
1214 (let ((now-map (copy-keymap minibuffer-local-map)))
|
|
1215 (define-key now-map "\C-w" 'bookmark-yank-word)
|
|
1216 now-map)
|
|
1217 nil
|
|
1218 'bookmark-history))))
|
|
1219 (bookmark-set-name old newname)
|
|
1220 (setq bookmark-current-bookmark newname)
|
|
1221 (bookmark-bmenu-surreptitiously-rebuild-list)
|
|
1222 (setq bookmark-alist-modification-count
|
|
1223 (1+ bookmark-alist-modification-count))
|
|
1224 (if (bookmark-time-to-save-p)
|
|
1225 (bookmark-save))))
|
4537
|
1226
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1227
|
4848
|
1228 ;;;###autoload
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1229 (defun bookmark-insert (bookmark)
|
35283
|
1230 "Insert the text of the file pointed to by bookmark BOOKMARK.
|
4633
|
1231 You may have a problem using this function if the value of variable
|
|
1232 `bookmark-alist' is nil. If that happens, you need to load in some
|
|
1233 bookmarks. See help on function `bookmark-load' for more about
|
4631
|
1234 this."
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1235 (interactive (bookmark-completing-read "Insert bookmark contents"))
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1236 (bookmark-maybe-historicize-string bookmark)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1237 (bookmark-maybe-load-default-file)
|
4848
|
1238 (let ((orig-point (point))
|
|
1239 (str-to-insert
|
|
1240 (save-excursion
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1241 (set-buffer (car (bookmark-jump-noselect bookmark)))
|
19472
|
1242 (buffer-string))))
|
4848
|
1243 (insert str-to-insert)
|
|
1244 (push-mark)
|
|
1245 (goto-char orig-point)))
|
4537
|
1246
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1247
|
4848
|
1248 ;;;###autoload
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1249 (defun bookmark-delete (bookmark &optional batch)
|
35283
|
1250 "Delete BOOKMARK from the bookmark list.
|
4633
|
1251 Removes only the first instance of a bookmark with that name. If
|
|
1252 there are one or more other bookmarks with the same name, they will
|
|
1253 not be deleted. Defaults to the \"current\" bookmark \(that is, the
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1254 one most recently used in this file, if any\).
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1255 Optional second arg BATCH means don't update the bookmark list buffer,
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1256 probably because we were called from there."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1257 (interactive
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1258 (bookmark-completing-read "Delete bookmark" bookmark-current-bookmark))
|
10994
|
1259 (bookmark-maybe-historicize-string bookmark)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1260 (bookmark-maybe-load-default-file)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1261 (let ((will-go (bookmark-get-bookmark bookmark)))
|
4595
|
1262 (setq bookmark-alist (delq will-go bookmark-alist))
|
|
1263 ;; Added by db, nil bookmark-current-bookmark if the last
|
13969
|
1264 ;; occurrence has been deleted
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1265 (or (bookmark-get-bookmark bookmark-current-bookmark)
|
4595
|
1266 (setq bookmark-current-bookmark nil)))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1267 ;; Don't rebuild the list
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1268 (if batch
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1269 nil
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1270 (bookmark-bmenu-surreptitiously-rebuild-list)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1271 (setq bookmark-alist-modification-count
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1272 (1+ bookmark-alist-modification-count))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1273 (if (bookmark-time-to-save-p)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1274 (bookmark-save))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1275
|
4537
|
1276
|
|
1277 (defun bookmark-time-to-save-p (&optional last-time)
|
|
1278 ;; By Gregory M. Saunders <saunders@cis.ohio-state.edu>
|
|
1279 ;; finds out whether it's time to save bookmarks to a file, by
|
|
1280 ;; examining the value of variable bookmark-save-flag, and maybe
|
|
1281 ;; bookmark-alist-modification-count. Returns t if they should be
|
|
1282 ;; saved, nil otherwise. if last-time is non-nil, then this is
|
|
1283 ;; being called when emacs is killed.
|
35283
|
1284 (cond (last-time
|
4537
|
1285 (and (> bookmark-alist-modification-count 0)
|
|
1286 bookmark-save-flag))
|
|
1287 ((numberp bookmark-save-flag)
|
|
1288 (>= bookmark-alist-modification-count bookmark-save-flag))
|
|
1289 (t
|
|
1290 nil)))
|
|
1291
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1292
|
4848
|
1293 ;;;###autoload
|
4537
|
1294 (defun bookmark-write ()
|
15193
|
1295 "Write bookmarks to a file (reading the file name with the minibuffer).
|
|
1296 Don't use this in Lisp programs; use `bookmark-save' instead."
|
4537
|
1297 (interactive)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1298 (bookmark-maybe-load-default-file)
|
4537
|
1299 (bookmark-save t))
|
|
1300
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1301
|
4848
|
1302 ;;;###autoload
|
35283
|
1303 (defun bookmark-save (&optional parg file)
|
4633
|
1304 "Save currently defined bookmarks.
|
|
1305 Saves by default in the file defined by the variable
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1306 `bookmark-default-file'. With a prefix arg, save it in file FILE
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1307 \(second argument\).
|
4537
|
1308
|
|
1309 If you are calling this from Lisp, the two arguments are PREFIX-ARG
|
|
1310 and FILE, and if you just want it to write to the default file, then
|
|
1311 pass no arguments. Or pass in nil and FILE, and it will save in FILE
|
|
1312 instead. If you pass in one argument, and it is non-nil, then the
|
|
1313 user will be interactively queried for a file to save in.
|
|
1314
|
4595
|
1315 When you want to load in the bookmarks from a file, use
|
4633
|
1316 \`bookmark-load\', \\[bookmark-load]. That function will prompt you
|
4595
|
1317 for a file, defaulting to the file defined by variable
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1318 `bookmark-default-file'."
|
4537
|
1319 (interactive "P")
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1320 (bookmark-maybe-load-default-file)
|
4537
|
1321 (cond
|
|
1322 ((and (null parg) (null file))
|
|
1323 ;;whether interactive or not, write to default file
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1324 (bookmark-write-file bookmark-default-file))
|
4537
|
1325 ((and (null parg) file)
|
|
1326 ;;whether interactive or not, write to given file
|
|
1327 (bookmark-write-file file))
|
|
1328 ((and parg (not file))
|
|
1329 ;;have been called interactively w/ prefix arg
|
|
1330 (let ((file (read-file-name "File to save bookmarks in: ")))
|
|
1331 (bookmark-write-file file)))
|
|
1332 (t ; someone called us with prefix-arg *and* a file, so just write to file
|
|
1333 (bookmark-write-file file)))
|
|
1334 ;; signal that we have synced the bookmark file by setting this to
|
|
1335 ;; 0. If there was an error at any point before, it will not get
|
|
1336 ;; set, which is what we want.
|
|
1337 (setq bookmark-alist-modification-count 0))
|
|
1338
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1339
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1340
|
4537
|
1341 (defun bookmark-write-file (file)
|
|
1342 (save-excursion
|
4848
|
1343 (save-window-excursion
|
|
1344 (if (>= baud-rate 9600)
|
14339
f2dfcd4d4b9b
(bookmark-write-file, bookmark-load): Delete format call inside message.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
1345 (message "Saving bookmarks to file %s..." file))
|
4893
|
1346 (set-buffer (let ((enable-local-variables nil))
|
4891
|
1347 (find-file-noselect file)))
|
4848
|
1348 (goto-char (point-min))
|
41608
|
1349 (let ((print-length nil)
|
39122
|
1350 (print-level nil))
|
|
1351 (delete-region (point-min) (point-max))
|
|
1352 (bookmark-insert-file-format-version-stamp)
|
|
1353 (pp bookmark-alist (current-buffer))
|
|
1354 (let ((version-control
|
|
1355 (cond
|
|
1356 ((null bookmark-version-control) nil)
|
|
1357 ((eq 'never bookmark-version-control) 'never)
|
|
1358 ((eq 'nospecial bookmark-version-control) version-control)
|
|
1359 (t
|
|
1360 t))))
|
|
1361 (write-file file)
|
|
1362 (kill-buffer (current-buffer))
|
|
1363 (if (>= baud-rate 9600)
|
|
1364 (message "Saving bookmarks to file %s...done" file)))))))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1365
|
4537
|
1366
|
19472
|
1367 (defun bookmark-import-new-list (new-list)
|
|
1368 ;; Walk over the new list, adding each individual bookmark
|
|
1369 ;; carefully. "Carefully" means checking against the existing
|
|
1370 ;; bookmark-alist and renaming the new bookmarks with <N> extensions
|
|
1371 ;; as necessary.
|
|
1372 (let ((lst new-list)
|
|
1373 (names (bookmark-all-names)))
|
|
1374 (while lst
|
|
1375 (let* ((full-record (car lst)))
|
|
1376 (bookmark-maybe-rename full-record names)
|
|
1377 (setq bookmark-alist (nconc bookmark-alist (list full-record)))
|
|
1378 (setq names (cons (bookmark-name-from-full-record full-record) names))
|
|
1379 (setq lst (cdr lst))))))
|
|
1380
|
|
1381
|
|
1382 (defun bookmark-maybe-rename (full-record names)
|
|
1383 ;; just a helper for bookmark-import-new-list; it is only for
|
|
1384 ;; readability that this is not inlined.
|
|
1385 ;;
|
|
1386 ;; Once this has found a free name, it sets full-record to that
|
|
1387 ;; name.
|
|
1388 (let ((found-name (bookmark-name-from-full-record full-record)))
|
|
1389 (if (member found-name names)
|
|
1390 ;; We've got a conflict, so generate a new name
|
|
1391 (let ((count 2)
|
|
1392 (new-name found-name))
|
|
1393 (while (member new-name names)
|
|
1394 (setq new-name (concat found-name (format "<%d>" count)))
|
|
1395 (setq count (1+ count)))
|
|
1396 (bookmark-set-name full-record new-name)))))
|
|
1397
|
|
1398
|
4848
|
1399 ;;;###autoload
|
19472
|
1400 (defun bookmark-load (file &optional overwrite no-msg)
|
4633
|
1401 "Load bookmarks from FILE (which must be in bookmark format).
|
|
1402 Appends loaded bookmarks to the front of the list of bookmarks. If
|
19472
|
1403 optional second argument OVERWRITE is non-nil, existing bookmarks are
|
4633
|
1404 destroyed. Optional third arg NO-MSG means don't display any messages
|
|
1405 while loading.
|
4537
|
1406
|
|
1407 If you load a file that doesn't contain a proper bookmark alist, you
|
4633
|
1408 will corrupt Emacs's bookmark list. Generally, you should only load
|
4537
|
1409 in files that were created with the bookmark functions in the first
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1410 place. Your own personal bookmark file, `~/.emacs.bmk', is
|
4631
|
1411 maintained automatically by Emacs; you shouldn't need to load it
|
19472
|
1412 explicitly.
|
|
1413
|
|
1414 If you load a file containing bookmarks with the same names as
|
|
1415 bookmarks already present in your Emacs, the new bookmarks will get
|
|
1416 unique numeric suffixes \"<2>\", \"<3>\", ... following the same
|
|
1417 method buffers use to resolve name collisions."
|
4537
|
1418 (interactive
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1419 (list (read-file-name
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1420 (format "Load bookmarks from: (%s) "
|
35283
|
1421 bookmark-default-file)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1422 ;;Default might not be used often,
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1423 ;;but there's no better default, and
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1424 ;;I guess it's better than none at all.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1425 "~/" bookmark-default-file 'confirm)))
|
4537
|
1426 (setq file (expand-file-name file))
|
|
1427 (if (file-readable-p file)
|
|
1428 (save-excursion
|
4848
|
1429 (save-window-excursion
|
|
1430 (if (and (null no-msg) (>= baud-rate 9600))
|
14339
f2dfcd4d4b9b
(bookmark-write-file, bookmark-load): Delete format call inside message.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
1431 (message "Loading bookmarks from %s..." file))
|
4893
|
1432 (set-buffer (let ((enable-local-variables nil))
|
4891
|
1433 (find-file-noselect file)))
|
4848
|
1434 (goto-char (point-min))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1435 (bookmark-maybe-upgrade-file-format)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1436 (let ((blist (bookmark-alist-from-buffer)))
|
4848
|
1437 (if (listp blist)
|
|
1438 (progn
|
19472
|
1439 (if overwrite
|
|
1440 (progn
|
|
1441 (setq bookmark-alist blist)
|
|
1442 (setq bookmark-alist-modification-count 0))
|
|
1443 ;; else
|
|
1444 (bookmark-import-new-list blist)
|
|
1445 (setq bookmark-alist-modification-count
|
|
1446 (1+ bookmark-alist-modification-count)))
|
|
1447 (if (string-equal
|
|
1448 (expand-file-name bookmark-default-file)
|
|
1449 file)
|
|
1450 (setq bookmarks-already-loaded t))
|
35283
|
1451 (bookmark-bmenu-surreptitiously-rebuild-list))
|
14354
|
1452 (error "Invalid bookmark list in %s" file)))
|
4848
|
1453 (kill-buffer (current-buffer)))
|
|
1454 (if (and (null no-msg) (>= baud-rate 9600))
|
14339
f2dfcd4d4b9b
(bookmark-write-file, bookmark-load): Delete format call inside message.
Karl Heuer <kwzh@gnu.org>
diff
changeset
|
1455 (message "Loading bookmarks from %s...done" file)))
|
14354
|
1456 (error "Cannot read bookmark file %s" file)))
|
4848
|
1457
|
|
1458
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1459
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1460 ;;; Code supporting the dired-like bookmark menu. Prefix is
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1461 ;;; "bookmark-bmenu" for "buffer-menu":
|
4848
|
1462
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1463
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1464 (defvar bookmark-bmenu-bookmark-column nil)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1465
|
4848
|
1466
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1467 (defvar bookmark-bmenu-hidden-bookmarks ())
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1468
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1469
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1470 (defvar bookmark-bmenu-mode-map nil)
|
4848
|
1471
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1472
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1473 (if bookmark-bmenu-mode-map
|
4848
|
1474 nil
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1475 (setq bookmark-bmenu-mode-map (make-keymap))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1476 (suppress-keymap bookmark-bmenu-mode-map t)
|
21094
|
1477 (define-key bookmark-bmenu-mode-map "q" 'quit-window)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1478 (define-key bookmark-bmenu-mode-map "v" 'bookmark-bmenu-select)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1479 (define-key bookmark-bmenu-mode-map "w" 'bookmark-bmenu-locate)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1480 (define-key bookmark-bmenu-mode-map "2" 'bookmark-bmenu-2-window)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1481 (define-key bookmark-bmenu-mode-map "1" 'bookmark-bmenu-1-window)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1482 (define-key bookmark-bmenu-mode-map "j" 'bookmark-bmenu-this-window)
|
15189
|
1483 (define-key bookmark-bmenu-mode-map "\C-c\C-c" 'bookmark-bmenu-this-window)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1484 (define-key bookmark-bmenu-mode-map "f" 'bookmark-bmenu-this-window)
|
26773
|
1485 (define-key bookmark-bmenu-mode-map "\C-m" 'bookmark-bmenu-this-window)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1486 (define-key bookmark-bmenu-mode-map "o" 'bookmark-bmenu-other-window)
|
15189
|
1487 (define-key bookmark-bmenu-mode-map "\C-o"
|
|
1488 'bookmark-bmenu-switch-other-window)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1489 (define-key bookmark-bmenu-mode-map "s" 'bookmark-bmenu-save)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1490 (define-key bookmark-bmenu-mode-map "k" 'bookmark-bmenu-delete)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1491 (define-key bookmark-bmenu-mode-map "\C-d" 'bookmark-bmenu-delete-backwards)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1492 (define-key bookmark-bmenu-mode-map "x" 'bookmark-bmenu-execute-deletions)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1493 (define-key bookmark-bmenu-mode-map "d" 'bookmark-bmenu-delete)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1494 (define-key bookmark-bmenu-mode-map " " 'next-line)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1495 (define-key bookmark-bmenu-mode-map "n" 'next-line)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1496 (define-key bookmark-bmenu-mode-map "p" 'previous-line)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1497 (define-key bookmark-bmenu-mode-map "\177" 'bookmark-bmenu-backup-unmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1498 (define-key bookmark-bmenu-mode-map "?" 'describe-mode)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1499 (define-key bookmark-bmenu-mode-map "u" 'bookmark-bmenu-unmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1500 (define-key bookmark-bmenu-mode-map "m" 'bookmark-bmenu-mark)
|
35283
|
1501 (define-key bookmark-bmenu-mode-map "l" 'bookmark-bmenu-load)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1502 (define-key bookmark-bmenu-mode-map "r" 'bookmark-bmenu-rename)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1503 (define-key bookmark-bmenu-mode-map "t" 'bookmark-bmenu-toggle-filenames)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1504 (define-key bookmark-bmenu-mode-map "a" 'bookmark-bmenu-show-annotation)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1505 (define-key bookmark-bmenu-mode-map "A" 'bookmark-bmenu-show-all-annotations)
|
17265
|
1506 (define-key bookmark-bmenu-mode-map "e" 'bookmark-bmenu-edit-annotation)
|
|
1507 (define-key bookmark-bmenu-mode-map [mouse-2]
|
|
1508 'bookmark-bmenu-other-window-with-mouse))
|
4848
|
1509
|
35283
|
1510
|
4848
|
1511
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1512 ;; Bookmark Buffer Menu mode is suitable only for specially formatted
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1513 ;; data.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1514 (put 'bookmark-bmenu-mode 'mode-class 'special)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1515
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1516
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1517 ;; todo: need to display whether or not bookmark exists as a buffer in
|
35283
|
1518 ;; flag column.
|
4848
|
1519
|
|
1520 ;; Format:
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1521 ;; FLAGS BOOKMARK [ LOCATION ]
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1522
|
4848
|
1523
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1524 (defun bookmark-bmenu-surreptitiously-rebuild-list ()
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1525 "Rebuild the Bookmark List if it exists.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1526 Don't affect the buffer ring order."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1527 (if (get-buffer "*Bookmark List*")
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1528 (save-excursion
|
35283
|
1529 (save-window-excursion
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1530 (bookmark-bmenu-list)))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1531
|
4848
|
1532
|
|
1533 ;;;###autoload
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1534 (defun bookmark-bmenu-list ()
|
4848
|
1535 "Display a list of existing bookmarks.
|
|
1536 The list is displayed in a buffer named `*Bookmark List*'.
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1537 The leftmost column displays a D if the bookmark is flagged for
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1538 deletion, or > if it is flagged for displaying."
|
4848
|
1539 (interactive)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1540 (bookmark-maybe-load-default-file)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1541 (if (interactive-p)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1542 (switch-to-buffer (get-buffer-create "*Bookmark List*"))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1543 (set-buffer (get-buffer-create "*Bookmark List*")))
|
4848
|
1544 (let ((buffer-read-only nil))
|
|
1545 (delete-region (point-max) (point-min))
|
|
1546 (goto-char (point-min)) ;sure are playing it safe...
|
|
1547 (insert "% Bookmark\n- --------\n")
|
|
1548 (bookmark-maybe-sort-alist)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1549 (mapcar
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1550 (lambda (full-record)
|
13969
|
1551 ;; if a bookmark has an annotation, prepend a "*"
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1552 ;; in the list of bookmarks.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1553 (let ((annotation (bookmark-get-annotation
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1554 (bookmark-name-from-full-record full-record))))
|
19472
|
1555 (if (and annotation (not (string-equal annotation "")))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1556 (insert " *")
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1557 (insert " "))
|
17265
|
1558 (let ((start (point)))
|
|
1559 (insert (bookmark-name-from-full-record full-record))
|
29476
0797cad76554
Applied this patch from Eli Zaretskii. Pretty much taking on faith
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
1560 (if (and (display-color-p) (display-mouse-p))
|
38173
|
1561 (add-text-properties start
|
|
1562 (save-excursion (re-search-backward
|
|
1563 "[^ \t]")
|
|
1564 (1+ (point)))
|
|
1565 '(mouse-face highlight
|
|
1566 help-echo "mouse-2: go to this bookmark")))
|
17265
|
1567 (insert "\n")
|
|
1568 )))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1569 bookmark-alist))
|
4848
|
1570 (goto-char (point-min))
|
|
1571 (forward-line 2)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1572 (bookmark-bmenu-mode)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1573 (if bookmark-bmenu-toggle-filenames
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1574 (bookmark-bmenu-toggle-filenames t)))
|
4848
|
1575
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1576 ;;;###autoload
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1577 (defalias 'list-bookmarks 'bookmark-bmenu-list)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1578 ;;;###autoload
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1579 (defalias 'edit-bookmarks 'bookmark-bmenu-list)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1580
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1581
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1582
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1583 (defun bookmark-bmenu-mode ()
|
4848
|
1584 "Major mode for editing a list of bookmarks.
|
|
1585 Each line describes one of the bookmarks in Emacs.
|
|
1586 Letters do not insert themselves; instead, they are commands.
|
13969
|
1587 Bookmark names preceded by a \"*\" have annotations.
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1588 \\<bookmark-bmenu-mode-map>
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1589 \\[bookmark-bmenu-mark] -- mark bookmark to be displayed.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1590 \\[bookmark-bmenu-select] -- select bookmark of line point is on.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1591 Also show bookmarks marked using m in other windows.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1592 \\[bookmark-bmenu-toggle-filenames] -- toggle displaying of filenames (they may obscure long bookmark names).
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1593 \\[bookmark-bmenu-locate] -- display (in minibuffer) location of this bookmark.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1594 \\[bookmark-bmenu-1-window] -- select this bookmark in full-frame window.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1595 \\[bookmark-bmenu-2-window] -- select this bookmark in one window,
|
4848
|
1596 together with bookmark selected before this one in another window.
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1597 \\[bookmark-bmenu-this-window] -- select this bookmark in place of the bookmark menu buffer.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1598 \\[bookmark-bmenu-other-window] -- select this bookmark in another window,
|
4848
|
1599 so the bookmark menu bookmark remains visible in its window.
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1600 \\[bookmark-bmenu-switch-other-window] -- switch the other window to this bookmark.
|
35283
|
1601 \\[bookmark-bmenu-rename] -- rename this bookmark \(prompts for new name\).
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1602 \\[bookmark-bmenu-delete] -- mark this bookmark to be deleted, and move down.
|
35283
|
1603 \\[bookmark-bmenu-delete-backwards] -- mark this bookmark to be deleted, and move up.
|
14039
|
1604 \\[bookmark-bmenu-execute-deletions] -- delete bookmarks marked with `\\[bookmark-bmenu-delete]'.
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1605 \\[bookmark-bmenu-save] -- save the current bookmark list in the default file.
|
4848
|
1606 With a prefix arg, prompts for a file to save in.
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1607 \\[bookmark-bmenu-load] -- load in a file of bookmarks (prompts for file.)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1608 \\[bookmark-bmenu-unmark] -- remove all kinds of marks from current line.
|
4848
|
1609 With prefix argument, also move up one line.
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1610 \\[bookmark-bmenu-backup-unmark] -- back up a line and remove marks.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1611 \\[bookmark-bmenu-show-annotation] -- show the annotation, if it exists, for the current bookmark
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1612 in another buffer.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1613 \\[bookmark-bmenu-show-all-annotations] -- show the annotations of all bookmarks in another buffer.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1614 \\[bookmark-bmenu-edit-annotation] -- edit the annotation for the current bookmark."
|
4848
|
1615 (kill-all-local-variables)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1616 (use-local-map bookmark-bmenu-mode-map)
|
4848
|
1617 (setq truncate-lines t)
|
|
1618 (setq buffer-read-only t)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1619 (setq major-mode 'bookmark-bmenu-mode)
|
4848
|
1620 (setq mode-name "Bookmark Menu")
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1621 (run-hooks 'bookmark-bmenu-mode-hook))
|
4848
|
1622
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1623
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1624 (defun bookmark-bmenu-toggle-filenames (&optional show)
|
4848
|
1625 "Toggle whether filenames are shown in the bookmark list.
|
|
1626 Optional argument SHOW means show them unconditionally."
|
|
1627 (interactive)
|
|
1628 (cond
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1629 (show
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1630 (setq bookmark-bmenu-toggle-filenames nil)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1631 (bookmark-bmenu-show-filenames)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1632 (setq bookmark-bmenu-toggle-filenames t))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1633 (bookmark-bmenu-toggle-filenames
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1634 (bookmark-bmenu-hide-filenames)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1635 (setq bookmark-bmenu-toggle-filenames nil))
|
4848
|
1636 (t
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1637 (bookmark-bmenu-show-filenames)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1638 (setq bookmark-bmenu-toggle-filenames t))))
|
4848
|
1639
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1640
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1641 (defun bookmark-bmenu-show-filenames (&optional force)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1642 (if (and (not force) bookmark-bmenu-toggle-filenames)
|
4848
|
1643 nil ;already shown, so do nothing
|
|
1644 (save-excursion
|
|
1645 (save-window-excursion
|
4537
|
1646 (goto-char (point-min))
|
4848
|
1647 (forward-line 2)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1648 (setq bookmark-bmenu-hidden-bookmarks ())
|
4848
|
1649 (let ((buffer-read-only nil))
|
|
1650 (while (< (point) (point-max))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1651 (let ((bmrk (bookmark-bmenu-bookmark)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1652 (setq bookmark-bmenu-hidden-bookmarks
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1653 (cons bmrk bookmark-bmenu-hidden-bookmarks))
|
17265
|
1654 (let ((start (save-excursion (end-of-line) (point))))
|
|
1655 (move-to-column bookmark-bmenu-file-column t)
|
|
1656 ;; Strip off `mouse-face' from the white spaces region.
|
29476
0797cad76554
Applied this patch from Eli Zaretskii. Pretty much taking on faith
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
1657 (if (and (display-color-p) (display-mouse-p))
|
17265
|
1658 (remove-text-properties start (point)
|
38173
|
1659 '(mouse-face nil help-echo nil))))
|
17265
|
1660 (delete-region (point) (progn (end-of-line) (point)))
|
4848
|
1661 (insert " ")
|
10994
|
1662 ;; Pass the NO-HISTORY arg:
|
|
1663 (bookmark-insert-location bmrk t)
|
4848
|
1664 (forward-line 1))))))))
|
|
1665
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1666
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1667 (defun bookmark-bmenu-hide-filenames (&optional force)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1668 (if (and (not force) bookmark-bmenu-toggle-filenames)
|
4848
|
1669 ;; nothing to hide if above is nil
|
|
1670 (save-excursion
|
|
1671 (save-window-excursion
|
|
1672 (goto-char (point-min))
|
|
1673 (forward-line 2)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1674 (setq bookmark-bmenu-hidden-bookmarks
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1675 (nreverse bookmark-bmenu-hidden-bookmarks))
|
4848
|
1676 (save-excursion
|
|
1677 (goto-char (point-min))
|
|
1678 (search-forward "Bookmark")
|
|
1679 (backward-word 1)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1680 (setq bookmark-bmenu-bookmark-column (current-column)))
|
4848
|
1681 (save-excursion
|
|
1682 (let ((buffer-read-only nil))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1683 (while bookmark-bmenu-hidden-bookmarks
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1684 (move-to-column bookmark-bmenu-bookmark-column t)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1685 (bookmark-kill-line)
|
17265
|
1686 (let ((start (point)))
|
|
1687 (insert (car bookmark-bmenu-hidden-bookmarks))
|
29476
0797cad76554
Applied this patch from Eli Zaretskii. Pretty much taking on faith
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
1688 (if (and (display-color-p) (display-mouse-p))
|
38173
|
1689 (add-text-properties start
|
|
1690 (save-excursion (re-search-backward
|
|
1691 "[^ \t]")
|
|
1692 (1+ (point)))
|
|
1693 '(mouse-face highlight
|
|
1694 help-echo
|
|
1695 "mouse-2: go to this bookmark"))))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1696 (setq bookmark-bmenu-hidden-bookmarks
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1697 (cdr bookmark-bmenu-hidden-bookmarks))
|
4848
|
1698 (forward-line 1))))))))
|
|
1699
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1700
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1701 (defun bookmark-bmenu-check-position ()
|
19472
|
1702 ;; Returns non-nil if on a line with a bookmark.
|
|
1703 ;; (The actual value returned is bookmark-alist).
|
|
1704 ;; Else reposition and try again, else return nil.
|
4848
|
1705 (cond ((< (count-lines (point-min) (point)) 2)
|
|
1706 (goto-char (point-min))
|
|
1707 (forward-line 2)
|
19472
|
1708 bookmark-alist)
|
4848
|
1709 ((and (bolp) (eobp))
|
|
1710 (beginning-of-line 0)
|
19472
|
1711 bookmark-alist)
|
4848
|
1712 (t
|
19472
|
1713 bookmark-alist)))
|
4848
|
1714
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1715
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1716 (defun bookmark-bmenu-bookmark ()
|
4848
|
1717 ;; return a string which is bookmark of this line.
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1718 (if (bookmark-bmenu-check-position)
|
4848
|
1719 (save-excursion
|
|
1720 (save-window-excursion
|
|
1721 (goto-char (point-min))
|
|
1722 (search-forward "Bookmark")
|
|
1723 (backward-word 1)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1724 (setq bookmark-bmenu-bookmark-column (current-column)))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1725 (if bookmark-bmenu-toggle-filenames
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1726 (bookmark-bmenu-hide-filenames))
|
4848
|
1727 (save-excursion
|
|
1728 (save-window-excursion
|
|
1729 (beginning-of-line)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1730 (forward-char bookmark-bmenu-bookmark-column)
|
4848
|
1731 (prog1
|
35283
|
1732 (buffer-substring-no-properties (point)
|
|
1733 (progn
|
4848
|
1734 (end-of-line)
|
|
1735 (point)))
|
|
1736 ;; well, this is certainly crystal-clear:
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1737 (if bookmark-bmenu-toggle-filenames
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1738 (bookmark-bmenu-toggle-filenames t))))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1739
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1740
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1741 (defun bookmark-show-annotation (bookmark)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1742 "Display the annotation for bookmark named BOOKMARK in a buffer,
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1743 if an annotation exists."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1744 (let ((annotation (bookmark-get-annotation bookmark)))
|
19472
|
1745 (if (and annotation (not (string-equal annotation "")))
|
|
1746 (save-excursion
|
|
1747 (let ((old-buf (current-buffer)))
|
|
1748 (pop-to-buffer (get-buffer-create "*Bookmark Annotation*") t)
|
|
1749 (delete-region (point-min) (point-max))
|
|
1750 ;; (insert (concat "Annotation for bookmark '" bookmark "':\n\n"))
|
|
1751 (insert annotation)
|
|
1752 (goto-char (point-min))
|
|
1753 (pop-to-buffer old-buf))))))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1754
|
4848
|
1755
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1756 (defun bookmark-show-all-annotations ()
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1757 "Display the annotations for all bookmarks in a buffer."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1758 (let ((old-buf (current-buffer)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1759 (pop-to-buffer (get-buffer-create "*Bookmark Annotation*") t)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1760 (delete-region (point-min) (point-max))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1761 (mapcar
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1762 (lambda (full-record)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1763 (let* ((name (bookmark-name-from-full-record full-record))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1764 (ann (bookmark-get-annotation name)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1765 (insert (concat name ":\n"))
|
19472
|
1766 (if (and ann (not (string-equal ann "")))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1767 ;; insert the annotation, indented by 4 spaces.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1768 (progn
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1769 (save-excursion (insert ann))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1770 (while (< (point) (point-max))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1771 (beginning-of-line) ; paranoia
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1772 (insert " ")
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1773 (forward-line)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1774 (end-of-line))))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1775 bookmark-alist)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1776 (goto-char (point-min))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1777 (pop-to-buffer old-buf)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1778
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1779
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1780 (defun bookmark-bmenu-mark ()
|
15193
|
1781 "Mark bookmark on this line to be displayed by \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-select]."
|
4848
|
1782 (interactive)
|
|
1783 (beginning-of-line)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1784 (if (bookmark-bmenu-check-position)
|
4848
|
1785 (let ((buffer-read-only nil))
|
|
1786 (delete-char 1)
|
|
1787 (insert ?>)
|
19472
|
1788 (forward-line 1)
|
|
1789 (bookmark-bmenu-check-position))))
|
4848
|
1790
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1791
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1792 (defun bookmark-bmenu-select ()
|
4848
|
1793 "Select this line's bookmark; also display bookmarks marked with `>'.
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1794 You can mark bookmarks with the \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-mark] command."
|
4848
|
1795 (interactive)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1796 (if (bookmark-bmenu-check-position)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1797 (let ((bmrk (bookmark-bmenu-bookmark))
|
35283
|
1798 (menu (current-buffer))
|
4848
|
1799 (others ())
|
|
1800 tem)
|
|
1801 (goto-char (point-min))
|
|
1802 (while (re-search-forward "^>" nil t)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1803 (setq tem (bookmark-bmenu-bookmark))
|
4848
|
1804 (let ((buffer-read-only nil))
|
|
1805 (delete-char -1)
|
|
1806 (insert ?\ ))
|
35283
|
1807 (or (string-equal tem bmrk)
|
|
1808 (member tem others)
|
4848
|
1809 (setq others (cons tem others))))
|
|
1810 (setq others (nreverse others)
|
|
1811 tem (/ (1- (frame-height)) (1+ (length others))))
|
|
1812 (delete-other-windows)
|
|
1813 (bookmark-jump bmrk)
|
|
1814 (bury-buffer menu)
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1815 (if others
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1816 (while others
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1817 (split-window nil tem)
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1818 (other-window 1)
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1819 (bookmark-jump (car others))
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1820 (setq others (cdr others)))
|
4848
|
1821 (other-window 1)))))
|
|
1822
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1823
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1824 (defun bookmark-bmenu-save (parg)
|
4848
|
1825 "Save the current list into a bookmark file.
|
|
1826 With a prefix arg, prompts for a file to save them in."
|
|
1827 (interactive "P")
|
|
1828 (save-excursion
|
|
1829 (save-window-excursion
|
|
1830 (bookmark-save parg))))
|
|
1831
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1832
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1833 (defun bookmark-bmenu-load ()
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1834 "Load the bookmark file and rebuild the bookmark menu-buffer."
|
4848
|
1835 (interactive)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1836 (if (bookmark-bmenu-check-position)
|
4848
|
1837 (save-excursion
|
|
1838 (save-window-excursion
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1839 ;; This will call `bookmark-bmenu-list'
|
4848
|
1840 (call-interactively 'bookmark-load)))))
|
|
1841
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1842
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1843 (defun bookmark-bmenu-1-window ()
|
4848
|
1844 "Select this line's bookmark, alone, in full frame."
|
|
1845 (interactive)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1846 (if (bookmark-bmenu-check-position)
|
4848
|
1847 (progn
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1848 (bookmark-jump (bookmark-bmenu-bookmark))
|
4848
|
1849 (bury-buffer (other-buffer))
|
|
1850 (delete-other-windows))))
|
|
1851
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1852
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1853 (defun bookmark-bmenu-2-window ()
|
4848
|
1854 "Select this line's bookmark, with previous buffer in second window."
|
|
1855 (interactive)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1856 (if (bookmark-bmenu-check-position)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1857 (let ((bmrk (bookmark-bmenu-bookmark))
|
4848
|
1858 (menu (current-buffer))
|
|
1859 (pop-up-windows t))
|
|
1860 (delete-other-windows)
|
|
1861 (switch-to-buffer (other-buffer))
|
11021
|
1862 (let* ((pair (bookmark-jump-noselect bmrk))
|
|
1863 (buff (car pair))
|
|
1864 (pos (cdr pair)))
|
|
1865 (pop-to-buffer buff)
|
|
1866 (goto-char pos))
|
4848
|
1867 (bury-buffer menu))))
|
|
1868
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1869
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1870 (defun bookmark-bmenu-this-window ()
|
4848
|
1871 "Select this line's bookmark in this window."
|
|
1872 (interactive)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1873 (if (bookmark-bmenu-check-position)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1874 (bookmark-jump (bookmark-bmenu-bookmark))))
|
4848
|
1875
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1876
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1877 (defun bookmark-bmenu-other-window ()
|
4848
|
1878 "Select this line's bookmark in other window, leaving bookmark menu visible."
|
|
1879 (interactive)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1880 (let ((bookmark (bookmark-bmenu-bookmark)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1881 (if (bookmark-bmenu-check-position)
|
11021
|
1882 (let* ((pair (bookmark-jump-noselect bookmark))
|
|
1883 (buff (car pair))
|
|
1884 (pos (cdr pair)))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1885 (switch-to-buffer-other-window buff)
|
11021
|
1886 (goto-char pos)
|
|
1887 (set-window-point (get-buffer-window buff) pos)
|
|
1888 (bookmark-show-annotation bookmark)))))
|
|
1889
|
|
1890
|
|
1891 (defun bookmark-bmenu-switch-other-window ()
|
|
1892 "Make the other window select this line's bookmark.
|
|
1893 The current window remains selected."
|
|
1894 (interactive)
|
22251
|
1895 (let ((bookmark (bookmark-bmenu-bookmark))
|
|
1896 (pop-up-windows t)
|
35283
|
1897 same-window-buffer-names
|
22251
|
1898 same-window-regexps)
|
11021
|
1899 (if (bookmark-bmenu-check-position)
|
|
1900 (let* ((pair (bookmark-jump-noselect bookmark))
|
|
1901 (buff (car pair))
|
|
1902 (pos (cdr pair)))
|
|
1903 (display-buffer buff)
|
|
1904 (let ((o-buffer (current-buffer)))
|
|
1905 ;; save-excursion won't do
|
|
1906 (set-buffer buff)
|
|
1907 (goto-char pos)
|
|
1908 (set-window-point (get-buffer-window buff) pos)
|
|
1909 (set-buffer o-buffer))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1910 (bookmark-show-annotation bookmark)))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1911
|
17265
|
1912 (defun bookmark-bmenu-other-window-with-mouse (event)
|
|
1913 "Select bookmark at the mouse pointer in other window, leaving bookmark menu visible."
|
|
1914 (interactive "e")
|
|
1915 (save-excursion
|
|
1916 (set-buffer (window-buffer (posn-window (event-end event))))
|
|
1917 (save-excursion
|
|
1918 (goto-char (posn-point (event-end event)))
|
|
1919 (bookmark-bmenu-other-window))))
|
|
1920
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1921
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1922 (defun bookmark-bmenu-show-annotation ()
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1923 "Show the annotation for the current bookmark in another window."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1924 (interactive)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1925 (let ((bookmark (bookmark-bmenu-bookmark)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1926 (if (bookmark-bmenu-check-position)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1927 (bookmark-show-annotation bookmark))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1928
|
4848
|
1929
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1930 (defun bookmark-bmenu-show-all-annotations ()
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1931 "Show the annotation for all bookmarks in another window."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1932 (interactive)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1933 (bookmark-show-all-annotations))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1934
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1935
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1936 (defun bookmark-bmenu-edit-annotation ()
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1937 "Edit the annotation for the current bookmark in another window."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1938 (interactive)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1939 (let ((bookmark (bookmark-bmenu-bookmark)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1940 (if (bookmark-bmenu-check-position)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1941 (bookmark-edit-annotation bookmark))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1942
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1943
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1944 (defun bookmark-bmenu-unmark (&optional backup)
|
4848
|
1945 "Cancel all requested operations on bookmark on this line and move down.
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1946 Optional BACKUP means move up."
|
4848
|
1947 (interactive "P")
|
|
1948 (beginning-of-line)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1949 (if (bookmark-bmenu-check-position)
|
4848
|
1950 (progn
|
|
1951 (let ((buffer-read-only nil))
|
|
1952 (delete-char 1)
|
|
1953 ;; any flags to reset according to circumstances? How about a
|
|
1954 ;; flag indicating whether this bookmark is being visited?
|
|
1955 ;; well, we don't have this now, so maybe later.
|
|
1956 (insert " "))
|
19472
|
1957 (forward-line (if backup -1 1))
|
|
1958 (bookmark-bmenu-check-position))))
|
4848
|
1959
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1960
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1961 (defun bookmark-bmenu-backup-unmark ()
|
4848
|
1962 "Move up and cancel all requested operations on bookmark on line above."
|
|
1963 (interactive)
|
|
1964 (forward-line -1)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1965 (if (bookmark-bmenu-check-position)
|
4848
|
1966 (progn
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1967 (bookmark-bmenu-unmark)
|
19472
|
1968 (forward-line -1)
|
|
1969 (bookmark-bmenu-check-position))))
|
4848
|
1970
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1971
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1972 (defun bookmark-bmenu-delete ()
|
15193
|
1973 "Mark bookmark on this line to be deleted.
|
|
1974 To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-execute-deletions]."
|
4848
|
1975 (interactive)
|
|
1976 (beginning-of-line)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1977 (if (bookmark-bmenu-check-position)
|
4848
|
1978 (let ((buffer-read-only nil))
|
|
1979 (delete-char 1)
|
|
1980 (insert ?D)
|
19472
|
1981 (forward-line 1)
|
|
1982 (bookmark-bmenu-check-position))))
|
4848
|
1983
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1984
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1985 (defun bookmark-bmenu-delete-backwards ()
|
15193
|
1986 "Mark bookmark on this line to be deleted, then move up one line.
|
|
1987 To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-execute-deletions]."
|
4848
|
1988 (interactive)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1989 (bookmark-bmenu-delete)
|
4848
|
1990 (forward-line -2)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1991 (if (bookmark-bmenu-check-position)
|
19472
|
1992 (forward-line 1))
|
|
1993 (bookmark-bmenu-check-position))
|
4848
|
1994
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1995
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
1996 (defun bookmark-bmenu-execute-deletions ()
|
4848
|
1997 "Delete bookmarks marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands."
|
|
1998 (interactive)
|
14039
|
1999 (message "Deleting bookmarks...")
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2000 (let ((hide-em bookmark-bmenu-toggle-filenames)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2001 (o-point (point))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2002 (o-str (save-excursion
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2003 (beginning-of-line)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2004 (if (looking-at "^D")
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2005 nil
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2006 (buffer-substring
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2007 (point)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2008 (progn (end-of-line) (point))))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2009 (o-col (current-column)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2010 (if hide-em (bookmark-bmenu-hide-filenames))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2011 (setq bookmark-bmenu-toggle-filenames nil)
|
4848
|
2012 (goto-char (point-min))
|
|
2013 (forward-line 1)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2014 (while (re-search-forward "^D" (point-max) t)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2015 (bookmark-delete (bookmark-bmenu-bookmark) t)) ; pass BATCH arg
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2016 (bookmark-bmenu-list)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2017 (setq bookmark-bmenu-toggle-filenames hide-em)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2018 (if bookmark-bmenu-toggle-filenames
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2019 (bookmark-bmenu-toggle-filenames t))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2020 (if o-str
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2021 (progn
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2022 (goto-char (point-min))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2023 (search-forward o-str)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2024 (beginning-of-line)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2025 (forward-char o-col))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2026 (goto-char o-point))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2027 (beginning-of-line)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2028 (setq bookmark-alist-modification-count
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2029 (1+ bookmark-alist-modification-count))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2030 (if (bookmark-time-to-save-p)
|
14039
|
2031 (bookmark-save))
|
|
2032 (message "Deleting bookmarks...done")
|
|
2033 ))
|
4848
|
2034
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2035
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2036 (defun bookmark-bmenu-rename ()
|
4848
|
2037 "Rename bookmark on current line. Prompts for a new name."
|
|
2038 (interactive)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2039 (if (bookmark-bmenu-check-position)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2040 (let ((bmrk (bookmark-bmenu-bookmark))
|
4848
|
2041 (thispoint (point)))
|
|
2042 (bookmark-rename bmrk)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2043 (bookmark-bmenu-list)
|
4848
|
2044 (goto-char thispoint))))
|
|
2045
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2046
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2047 (defun bookmark-bmenu-locate ()
|
4848
|
2048 "Display location of this bookmark. Displays in the minibuffer."
|
|
2049 (interactive)
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2050 (if (bookmark-bmenu-check-position)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2051 (let ((bmrk (bookmark-bmenu-bookmark)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2052 (message (bookmark-location bmrk)))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2053
|
4537
|
2054
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2055
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2056 ;;; Menu bar stuff. Prefix is "bookmark-menu".
|
4537
|
2057
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2058 (defun bookmark-menu-build-paned-menu (name entries)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2059 "Build a multi-paned menu named NAME from the strings in ENTRIES.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2060 That is, ENTRIES is a list of strings which appear as the choices
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2061 in the menu. The number of panes depends on the number of entries.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2062 The visible entries are truncated to `bookmark-menu-length', but the
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2063 strings returned are not."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2064 (let* ((f-height (/ (frame-height) 2))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2065 (pane-list
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2066 (let (temp-pane-list
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2067 (iter 0))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2068 (while entries
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2069 (let (lst
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2070 (count 0))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2071 (while (and (< count f-height) entries)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2072 (let ((str (car entries)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2073 (setq lst (cons
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2074 (cons
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2075 (if (> (length str) bookmark-menu-length)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2076 (substring str 0 bookmark-menu-length)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2077 str)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2078 str)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2079 lst))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2080 (setq entries (cdr entries))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2081 (setq count (1+ count))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2082 (setq iter (1+ iter))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2083 (setq
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2084 temp-pane-list
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2085 (cons
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2086 (cons
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2087 (format "-*- %s (%d) -*-" name iter)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2088 (nreverse lst))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2089 temp-pane-list))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2090 (nreverse temp-pane-list))))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2091
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2092 ;; Return the menu:
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2093 (cons (concat "-*- " name " -*-") pane-list)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2094
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2095
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2096 (defun bookmark-menu-popup-paned-menu (event name entries)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2097 "Pop up multi-paned menu at EVENT, return string chosen from ENTRIES.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2098 That is, ENTRIES is a list of strings which appear as the choices
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2099 in the menu.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2100 The number of panes depends on the number of entries."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2101 (interactive "e")
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2102 (x-popup-menu event (bookmark-menu-build-paned-menu name entries)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2103
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2104
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2105 (defun bookmark-menu-popup-paned-bookmark-menu (event name)
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2106 "Pop up menu of bookmarks, return chosen bookmark.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2107 Pop up at EVENT, menu's name is NAME.
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2108 The number of panes depends on the number of bookmarks."
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2109 (bookmark-menu-popup-paned-menu event name (bookmark-all-names)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2110
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2111
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2112 (defun bookmark-popup-menu-and-apply-function (func-sym menu-label event)
|
4537
|
2113 ;; help function for making menus that need to apply a bookmark
|
|
2114 ;; function to a string.
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2115 (let* ((choice (bookmark-menu-popup-paned-bookmark-menu
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2116 event menu-label)))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2117 (if choice (apply func-sym (list choice)))))
|
4537
|
2118
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2119
|
11218
|
2120 ;;;###autoload
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2121 (defun bookmark-menu-insert (event)
|
35283
|
2122 "Insert the text of the file pointed to by bookmark BOOKMARK.
|
4633
|
2123 You may have a problem using this function if the value of variable
|
|
2124 `bookmark-alist' is nil. If that happens, you need to load in some
|
|
2125 bookmarks. See help on function `bookmark-load' for more about
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2126 this.
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2127
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2128 Warning: this function only takes an EVENT as argument. Use the
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2129 corresponding bookmark function from Lisp \(the one without the
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2130 \"-menu-\" in its name\)."
|
4537
|
2131 (interactive "e")
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2132 (bookmark-popup-menu-and-apply-function
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2133 'bookmark-insert "Insert Bookmark Contents" event))
|
4537
|
2134
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2135
|
11218
|
2136 ;;;###autoload
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2137 (defun bookmark-menu-jump (event)
|
35283
|
2138 "Jump to bookmark BOOKMARK (a point in some file).
|
4633
|
2139 You may have a problem using this function if the value of variable
|
|
2140 `bookmark-alist' is nil. If that happens, you need to load in some
|
|
2141 bookmarks. See help on function `bookmark-load' for more about
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2142 this.
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2143
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2144 Warning: this function only takes an EVENT as argument. Use the
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2145 corresponding bookmark function from Lisp \(the one without the
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2146 \"-menu-\" in its name\)."
|
4537
|
2147 (interactive "e")
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2148 (bookmark-popup-menu-and-apply-function
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2149 'bookmark-jump "Jump to Bookmark" event))
|
4537
|
2150
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2151
|
11218
|
2152 ;;;###autoload
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2153 (defun bookmark-menu-locate (event)
|
35283
|
2154 "Insert the name of the file associated with BOOKMARK.
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2155 \(This is not the same as the contents of that file\).
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2156
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2157 Warning: this function only takes an EVENT as argument. Use the
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2158 corresponding bookmark function from Lisp \(the one without the
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2159 \"-menu-\" in its name\)."
|
4537
|
2160 (interactive "e")
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2161 (bookmark-popup-menu-and-apply-function
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2162 'bookmark-insert-location "Insert Bookmark Location" event))
|
4537
|
2163
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2164
|
11218
|
2165 ;;;###autoload
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2166 (defun bookmark-menu-rename (event)
|
35283
|
2167 "Change the name of OLD-BOOKMARK to NEWNAME.
|
4848
|
2168 If called from keyboard, prompts for OLD-BOOKMARK and NEWNAME.
|
|
2169 If called from menubar, OLD-BOOKMARK is selected from a menu, and
|
35283
|
2170 prompts for NEWNAME.
|
4848
|
2171 If called from Lisp, prompts for NEWNAME if only OLD-BOOKMARK was
|
|
2172 passed as an argument. If called with two strings, then no prompting
|
|
2173 is done. You must pass at least OLD-BOOKMARK when calling from Lisp.
|
4633
|
2174
|
|
2175 While you are entering the new name, consecutive C-w's insert
|
13969
|
2176 consecutive words from the text of the buffer into the new bookmark
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2177 name.
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2178
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2179 Warning: this function only takes an EVENT as argument. Use the
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2180 corresponding bookmark function from Lisp \(the one without the
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2181 \"-menu-\" in its name\)."
|
4537
|
2182 (interactive "e")
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2183 (bookmark-popup-menu-and-apply-function
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2184 'bookmark-rename "Rename Bookmark" event))
|
4537
|
2185
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2186
|
11218
|
2187 ;;;###autoload
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2188 (defun bookmark-menu-delete (event)
|
35283
|
2189 "Delete the bookmark named NAME from the bookmark list.
|
4633
|
2190 Removes only the first instance of a bookmark with that name. If
|
|
2191 there are one or more other bookmarks with the same name, they will
|
|
2192 not be deleted. Defaults to the \"current\" bookmark \(that is, the
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2193 one most recently used in this file, if any\).
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2194
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2195 Warning: this function only takes an EVENT as argument. Use the
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2196 corresponding bookmark function from Lisp \(the one without the
|
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2197 \"-menu-\" in its name\)."
|
4537
|
2198 (interactive "e")
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2199 (bookmark-popup-menu-and-apply-function
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2200 'bookmark-delete "Delete Bookmark" event))
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2201
|
4537
|
2202
|
4848
|
2203 ;; Thanks to Roland McGrath for fixing menubar.el so that the
|
|
2204 ;; following works, and for explaining what to do to make it work.
|
4537
|
2205
|
11218
|
2206 ;; We MUST autoload EACH form used to set up this variable's value, so
|
|
2207 ;; that the whole job is done in loaddefs.el.
|
4537
|
2208
|
15193
|
2209 ;; Emacs menubar stuff.
|
13895
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2210
|
11218
|
2211 ;;;###autoload
|
|
2212 (defvar menu-bar-bookmark-map (make-sparse-keymap "Bookmark functions"))
|
13895
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2213
|
11218
|
2214 ;;;###autoload
|
12310
afad1c3ce9bd
Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2215 (defalias 'menu-bar-bookmark-map (symbol-value 'menu-bar-bookmark-map))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2216
|
13895
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2217 ;; make bookmarks appear toward the right side of the menu.
|
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2218 (if (boundp 'menu-bar-final-items)
|
35283
|
2219 (if menu-bar-final-items
|
13895
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2220 (setq menu-bar-final-items
|
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2221 (cons 'bookmark menu-bar-final-items)))
|
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2222 (setq menu-bar-final-items '(bookmark)))
|
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2223
|
11218
|
2224 ;;;###autoload
|
4848
|
2225 (define-key menu-bar-bookmark-map [load]
|
13895
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2226 '("Load a Bookmark File..." . bookmark-load))
|
4848
|
2227
|
11218
|
2228 ;;;###autoload
|
4848
|
2229 (define-key menu-bar-bookmark-map [write]
|
13895
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2230 '("Save Bookmarks As..." . bookmark-write))
|
4537
|
2231
|
11218
|
2232 ;;;###autoload
|
4848
|
2233 (define-key menu-bar-bookmark-map [save]
|
13895
0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2234 '("Save Bookmarks" . bookmark-save))
|
4848
|
2235
|
11218
|
2236 ;;;###autoload
|
4848
|
2237 (define-key menu-bar-bookmark-map [edit]
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2238 '("Edit Bookmark List" . bookmark-bmenu-list))
|
4848
|
2239
|
11218
|
2240 ;;;###autoload
|
4848
|
2241 (define-key menu-bar-bookmark-map [delete]
|
12033
|
2242 '("Delete Bookmark" . bookmark-menu-delete))
|
4848
|
2243
|
11218
|
2244 ;;;###autoload
|
4848
|
2245 (define-key menu-bar-bookmark-map [rename]
|
12033
|
2246 '("Rename Bookmark" . bookmark-menu-rename))
|
4848
|
2247
|
11218
|
2248 ;;;###autoload
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2249 (define-key menu-bar-bookmark-map [locate]
|
12033
|
2250 '("Insert Location" . bookmark-menu-locate))
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2251
|
11218
|
2252 ;;;###autoload
|
4848
|
2253 (define-key menu-bar-bookmark-map [insert]
|
12033
|
2254 '("Insert Contents" . bookmark-menu-insert))
|
4848
|
2255
|
11218
|
2256 ;;;###autoload
|
4848
|
2257 (define-key menu-bar-bookmark-map [set]
|
12033
|
2258 '("Set Bookmark" . bookmark-set))
|
4848
|
2259
|
11218
|
2260 ;;;###autoload
|
35283
|
2261 (define-key menu-bar-bookmark-map [jump]
|
12033
|
2262 '("Jump to Bookmark" . bookmark-menu-jump))
|
4537
|
2263
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2264 ;;;; end bookmark menu stuff ;;;;
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2265
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2266
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2267 ;;; Load Hook
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2268 (defvar bookmark-load-hook nil
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2269 "Hook to run at the end of loading bookmark.")
|
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2270
|
34529
8e38e93616a7
* bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2271 ;;; Exit Hook, called from kill-emacs-hook
|
8e38e93616a7
* bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2272 (defvar bookmark-exit-hook nil
|
8e38e93616a7
* bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2273 "Hook to run when emacs exits")
|
35283
|
2274
|
34529
8e38e93616a7
* bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2275 (defun bookmark-exit-hook-internal ()
|
8e38e93616a7
* bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2276 "Save bookmark state, if necessary, at Emacs exit time.
|
8e38e93616a7
* bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2277 This also runs `bookmark-exit-hooks'."
|
8e38e93616a7
* bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2278 (and
|
8e38e93616a7
* bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2279 (progn (run-hooks 'bookmark-exit-hooks) t)
|
8e38e93616a7
* bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2280 bookmark-alist
|
8e38e93616a7
* bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2281 (bookmark-time-to-save-p t)
|
8e38e93616a7
* bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2282 (bookmark-save)))
|
8e38e93616a7
* bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2283
|
8e38e93616a7
* bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2284 (add-hook 'kill-emacs-hook 'bookmark-exit-hook-internal)
|
8e38e93616a7
* bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2285
|
8e38e93616a7
* bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
diff
changeset
|
2286
|
10952
6069707b1151
Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
2287 (run-hooks 'bookmark-load-hook)
|
4537
|
2288
|
|
2289 (provide 'bookmark)
|
35283
|
2290
|
4595
|
2291 ;;; bookmark.el ends here
|