annotate lisp/packages/bookmark.el @ 211:78478c60bfcd r20-4b4

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