Mercurial > emacs
annotate lisp/bookmark.el @ 6249:365e7cbd7292
(term_get_fkeys_1): New local var ADDRESS, init to term_get_fkeys_address.
author | Roland McGrath <roland@gnu.org> |
---|---|
date | Tue, 08 Mar 1994 06:45:43 +0000 |
parents | 069c54e77fd1 |
children | 1b76cf849b2f |
rev | line source |
---|---|
4537 | 1 ;;; bookmark.el --- set bookmarks, jump to them later. |
2 | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
3 ;; Copyright (C) 1993 Free Software Foundation |
4537 | 4 |
5 ;; Author: Karl Fogel <kfogel@cs.oberlin.edu> | |
4631 | 6 ;; Maintainer: Karl Fogel <kfogel@cs.oberlin.edu> |
4537 | 7 ;; Created: July, 1993 |
4891 | 8 ;; Version: 2.5 |
4537 | 9 ;; Keywords: bookmarks, placeholders |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
14 ;; it under the terms of the GNU General Public License as published by | |
15 ;; the Free Software Foundation; either version 2, or (at your option) | |
16 ;; any later version. | |
17 | |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
24 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
25 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
26 | |
27 ;; Thanks to David Bremner <bremner@cs.sfu.ca> for thinking of and | |
28 ;; then implementing the bookmark-current-bookmark idea. He even | |
4891 | 29 ;; sent *patches*, bless his soul... |
4537 | 30 |
31 ;; Thanks to Gregory M. Saunders <saunders@cis.ohio-state.edu> for | |
32 ;; fixing and improving bookmark-time-to-save-p. | |
33 | |
4891 | 34 ;; Thanks go to Andrew V. Klein <avk@rtsg.mot.com> for the code that |
35 ;; sorts the alist before presenting it to the user (in list-bookmarks | |
36 ;; and the menu-bar). | |
37 | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
38 ;; And much thanks to David Hughes <djh@harston.cv.com> for many small |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
39 ;; suggestions and the code to implement them (like |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
40 ;; Bookmark-menu-check-position, and some of the Lucid compatibility |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
41 ;; stuff). |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
42 |
4891 | 43 ;; Kudos (whatever they are) go to Jim Blandy <jimb@cs.oberlin.edu> |
44 ;; for his eminently sensible suggestion to separate bookmark-jump | |
45 ;; into bookmark-jump and bookmark-jump-noselect, which made many | |
46 ;; other things cleaner as well. | |
47 | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
48 ;; Thanks to Roland McGrath for encouragement and help with defining |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
49 ;; autoloads on the menu-bar. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
50 |
4891 | 51 ;; Jonathan Stigelman <stig@key.amdahl.com> gave patches for default |
52 ;; values in bookmark-jump and bookmark-set. Everybody please keep | |
53 ;; all the keystrokes they save thereby and send them to him at the | |
54 ;; end of each year :-) (No, seriously, thanks Jonathan!) | |
55 | |
4537 | 56 ;; Based on info-bookmark.el, by Karl Fogel and Ken Olstad |
57 ;; <olstad@msc.edu>. | |
58 | |
59 ;; LCD Archive Entry: | |
60 ;; bookmark|Karl Fogel|kfogel@cs.oberlin.edu| | |
61 ;; Setting bookmarks in files or directories, jumping to them later.| | |
4891 | 62 ;; 16-July-93|Version: 2.5|~/misc/bookmark.el.Z| |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
63 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
64 ;; Enough with the credits already, get on to the good stuff: |
4537 | 65 |
66 ;; FAVORITE CHINESE RESTAURANT: | |
67 ;; Boy, that's a tough one. Probably Hong Min, or maybe Emperor's | |
68 ;; Choice (both in Chicago's Chinatown). Well, both. How about you? | |
69 | |
70 ;;; Commentary on code: | |
71 | |
72 ;; bookmark alist format: | |
73 ;; (... | |
74 ;; (bookmark-name (filename | |
75 ;; string-in-front | |
76 ;; string-behind | |
77 ;; point)) | |
78 ;; ...) | |
79 ;; | |
80 ;; bookmark-name is the string the user gives the bookmark and | |
81 ;; accesses it by from then on. filename is the location of the file | |
82 ;; in which the bookmark is set. string-in-front is a string of | |
83 ;; `bookmark-search-size' chars of context in front of the point the | |
84 ;; bookmark is set at, string-behind is the same thing after the | |
85 ;; point. bookmark-jump will search for string-behind and | |
86 ;; string-in-front in case the file has changed since the bookmark was | |
87 ;; set. It will attempt to place the user before the changes, if | |
88 ;; there were any. | |
4595 | 89 ;; |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
90 ;; The bookmark list is sorted lexically by default, but you can turn |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
91 ;; this off by setting bookmark-sort-flag to nil. If it is nil, then |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
92 ;; the list will be presented in the order it is recorded |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
93 ;; (chronologically), which is actually fairly useful as well. |
4537 | 94 |
95 ;;; Code: | |
96 | |
97 ;; Added for lucid emacs compatibility, db | |
98 (or (fboundp 'defalias) (fset 'defalias 'fset)) | |
99 | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
100 ;; suggested for lucid compatibility by david hughes: |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
101 (or (fboundp 'frame-height) (fset 'frame-height 'screen-height)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
102 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
103 ;; some people have C-x r set to rmail or whatever. We don't want to |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
104 ;; assume that C-x r is a prefix map just because it's distributed |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
105 ;; that way... |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
106 ;; These are the distribution keybindings suggested by RMS, everything |
4537 | 107 ;; else will be done with M-x or the menubar: |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
108 ;;;###autoload |
5307
069c54e77fd1
Don't repeat at load time any bindings that are autoloaded.
Richard M. Stallman <rms@gnu.org>
parents:
4893
diff
changeset
|
109 (if (or (symbolp (key-binding "\C-xr")) |
069c54e77fd1
Don't repeat at load time any bindings that are autoloaded.
Richard M. Stallman <rms@gnu.org>
parents:
4893
diff
changeset
|
110 (fboundp 'bookmark-set)) |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
111 nil |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
112 (progn (define-key ctl-x-map "rb" 'bookmark-jump) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
113 (define-key ctl-x-map "rm" 'bookmark-set) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
114 (define-key ctl-x-map "rl" 'list-bookmarks))) |
4537 | 115 |
116 ;; define the map, so it can be bound by those who desire to do so: | |
117 | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
118 ;;;###autoload |
4633 | 119 (defvar bookmark-map nil |
120 "Keymap containing bindings to bookmark functions. | |
121 It is not bound to any key by default: to bind it | |
122 so that you have a bookmark prefix, just use `global-set-key' and bind a | |
123 key of your choice to `bookmark-map'. All interactive bookmark | |
4537 | 124 functions have a binding in this keymap.") |
125 | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
126 ;;;###autoload |
4537 | 127 (define-prefix-command 'bookmark-map) |
128 | |
129 ;; Read the help on all of these functions for details... | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
130 ;;;###autoload |
4537 | 131 (define-key bookmark-map "x" 'bookmark-set) |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
132 ;;;###autoload |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
133 (define-key bookmark-map "m" 'bookmark-set) ; "m" for "mark" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
134 ;;;###autoload |
4537 | 135 (define-key bookmark-map "j" 'bookmark-jump) |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
136 ;;;###autoload |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
137 (define-key bookmark-map "g" 'bookmark-jump) ; "g" for "go" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
138 ;;;###autoload |
4537 | 139 (define-key bookmark-map "i" 'bookmark-insert) |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
140 ;;;###autoload |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
141 (define-key bookmark-map "e" 'edit-bookmarks) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
142 ;;;###autoload |
4537 | 143 (define-key bookmark-map "f" 'bookmark-locate) ; "f" for "find" |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
144 ;;;###autoload |
4633 | 145 (define-key bookmark-map "r" 'bookmark-rename) |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
146 ;;;###autoload |
4537 | 147 (define-key bookmark-map "d" 'bookmark-delete) |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
148 ;;;###autoload |
4537 | 149 (define-key bookmark-map "l" 'bookmark-load) |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
150 ;;;###autoload |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
151 (define-key bookmark-map "w" 'bookmark-write) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
152 ;;;###autoload |
4537 | 153 (define-key bookmark-map "s" 'bookmark-save) |
154 | |
4634
cd8eef9ec0c4
(bookmark-alist): Move defvar before first use.
Richard M. Stallman <rms@gnu.org>
parents:
4633
diff
changeset
|
155 (defvar bookmark-alist () |
cd8eef9ec0c4
(bookmark-alist): Move defvar before first use.
Richard M. Stallman <rms@gnu.org>
parents:
4633
diff
changeset
|
156 "Association list of bookmarks. |
cd8eef9ec0c4
(bookmark-alist): Move defvar before first use.
Richard M. Stallman <rms@gnu.org>
parents:
4633
diff
changeset
|
157 You probably don't want to change the value of this alist yourself; |
cd8eef9ec0c4
(bookmark-alist): Move defvar before first use.
Richard M. Stallman <rms@gnu.org>
parents:
4633
diff
changeset
|
158 instead, let the various bookmark functions do it for you.") |
cd8eef9ec0c4
(bookmark-alist): Move defvar before first use.
Richard M. Stallman <rms@gnu.org>
parents:
4633
diff
changeset
|
159 |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
160 (defvar bookmarks-already-loaded nil) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
161 |
4537 | 162 ;; just add the hook to make sure that people don't lose bookmarks |
163 ;; when they kill Emacs, unless they don't want to save them. | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
164 ;;;###autoload |
4537 | 165 (add-hook 'kill-emacs-hook |
166 (function | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
167 (lambda () (and (featurep 'bookmark) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
168 bookmark-alist |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
169 (bookmark-time-to-save-p t) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
170 (bookmark-save))))) |
4537 | 171 |
172 ;; more stuff added by db. | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
173 |
4537 | 174 (defvar bookmark-current-bookmark nil |
4633 | 175 "Name of bookmark most recently used in the current file. |
176 It is buffer local, used to make moving a bookmark forward | |
4631 | 177 through a file easier.") |
4537 | 178 |
179 (make-variable-buffer-local 'bookmark-current-bookmark) | |
180 | |
181 (defvar bookmark-save-flag t | |
4633 | 182 "*Controls when Emacs saves bookmarks to a file. |
183 --> Nil means never save bookmarks, except when `bookmark-save' is | |
184 explicitly called \(\\[bookmark-save]\). | |
185 --> t means save bookmarks when Emacs is killed. | |
186 --> Otherise, it should be a number that is the frequency with which | |
187 the bookmark list is saved \(i.e.: the number of times which | |
188 Emacs' bookmark list may be modified before it is automatically | |
189 saved.\). If it is a number, Emacs will also automatically save | |
190 bookmarks when it is killed. | |
4537 | 191 |
192 Therefore, the way to get it to save every time you make or delete a | |
193 bookmark is to set this variable to 1 \(or 0, which produces the same | |
194 behavior.\) | |
195 | |
196 To specify the file in which to save them, modify the variable | |
4633 | 197 bookmark-file, which is `~/.emacs-bkmrks' by default.") |
4537 | 198 |
199 (defvar bookmark-alist-modification-count 0 | |
4633 | 200 "Number of modifications to bookmark list since it was last saved.") |
4537 | 201 |
202 (defvar bookmark-file "~/.emacs-bkmrks" | |
203 "*File in which to save bookmarks by default.") | |
204 | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
205 (defvar bookmark-version-control 'nospecial |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
206 "This variable controls whether or not to make numbered backups of |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
207 the master bookmark file. It can have four values: t, nil, never, and |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
208 nospecial. The first three have the same meaning that they do for the |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
209 variable version-control, and the final value nospecial means just use |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
210 the value of version-control.") |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
211 |
4537 | 212 (defvar bookmark-completion-ignore-case t |
4633 | 213 "*Non-nil means bookmark functions ignore case in completion.") |
4537 | 214 |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
215 (defvar bookmark-sort-flag t |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
216 "*Non-nil means that bookmarks will be displayed sorted by bookmark |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
217 name. Otherwise they will be displayed in LIFO order (that is, most |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
218 recently set ones come first, oldest ones come last).") |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
219 |
4633 | 220 (defvar bookmark-search-size 500 |
221 "Length of the context strings recorded on either side of a bookmark.") | |
4537 | 222 |
223 (defvar bookmark-current-point 0) | |
224 (defvar bookmark-yank-point 0) | |
225 (defvar bookmark-current-buffer nil) | |
226 | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
227 ;;;###autoload |
4537 | 228 (defun bookmark-set (&optional parg) |
4633 | 229 "Set a bookmark named NAME inside a file. |
230 With prefix arg, will not overwrite a bookmark that has the same name | |
231 as NAME if such a bookmark already exists, but instead will \"push\" | |
232 the new bookmark onto the bookmark alist. Thus the most recently set | |
233 bookmark with name NAME would be the one in effect at any given time, | |
234 but the others are still there, should you decide to delete the most | |
235 recent one. | |
4537 | 236 |
237 To yank words from the text of the buffer and use them as part of the | |
4633 | 238 bookmark name, type C-w while setting a bookmark. Successive C-w's |
4537 | 239 yank successive words. |
240 | |
241 Typing C-v inserts the name of the current file being visited. Typing | |
242 C-u inserts the name of the last bookmark used in the buffer \(as an | |
243 aid in using a single bookmark name to track your progress through a | |
244 large file\). If no bookmark was used, then C-u behaves like C-v and | |
245 inserts the name of the file being visited. | |
246 | |
247 Use \\[bookmark-delete] to remove bookmarks \(you give it a name, | |
248 and it removes only the first instance of a bookmark with that name from | |
249 the list of bookmarks.\)" | |
250 (interactive "P") | |
251 (if (not (bookmark-buffer-file-name)) | |
252 (error "Buffer not visiting a file or directory.")) | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
253 (bookmark-try-default-file) |
4537 | 254 (setq bookmark-current-point (point)) |
255 (setq bookmark-yank-point (point)) | |
256 (setq bookmark-current-buffer (current-buffer)) | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
257 (let* ((default (or bookmark-current-bookmark |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
258 (buffer-name (current-buffer)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
259 (str |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
260 (read-from-minibuffer |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
261 (format "Set bookmark (%s): " default) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
262 nil |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
263 (let ((now-map (copy-keymap minibuffer-local-map))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
264 (progn (define-key now-map "\C-w" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
265 'bookmark-yank-word) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
266 (define-key now-map "\C-v" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
267 'bookmark-insert-current-file-name) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
268 (define-key now-map "\C-u" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
269 'bookmark-insert-current-bookmark)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
270 now-map)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
271 (and (string-equal str "") (setq str default)) |
4537 | 272 (progn |
273 (bookmark-make parg str) | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
274 (setq bookmark-current-bookmark str) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
275 (if (get-buffer "*Bookmark List*") ;rebuild the bookmark list |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
276 (save-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
277 (save-window-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
278 (list-bookmarks)))) |
4537 | 279 (goto-char bookmark-current-point)))) |
280 | |
281 (defun bookmark-insert-current-bookmark () | |
282 ;; insert this buffer's value of bookmark-current-bookmark, default | |
283 ;; to file name if it's nil. | |
284 (interactive) | |
285 (let ((str | |
286 (save-excursion | |
287 (set-buffer bookmark-current-buffer) | |
288 bookmark-current-bookmark))) | |
289 (if str (insert str) (bookmark-insert-current-file-name)))) | |
290 | |
291 (defun bookmark-insert-current-file-name () | |
292 ;; insert the name (sans path) of the current file into the bookmark | |
293 ;; name that is being set. | |
294 (interactive) | |
295 (let ((str (save-excursion | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
296 (set-buffer bookmark-current-buffer) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
297 (bookmark-buffer-file-name)))) |
4537 | 298 (insert (substring |
299 str | |
300 (1+ (string-match | |
301 "\\(/[^/]*\\)/*$" | |
302 str)))))) | |
303 | |
304 (defun bookmark-yank-word () | |
305 (interactive) | |
306 ;; get the next word from the buffer and append it to the name of | |
307 ;; the bookmark currently being set. | |
308 (let ((string (save-excursion | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
309 (set-buffer bookmark-current-buffer) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
310 (goto-char bookmark-yank-point) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
311 (buffer-substring |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
312 (point) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
313 (save-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
314 (forward-word 1) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
315 (setq bookmark-yank-point (point))))))) |
4537 | 316 (insert string))) |
317 | |
318 (defun bookmark-make (parg str) | |
319 (if (and (assoc str bookmark-alist) (not parg)) | |
320 ;; already existing boookmark under that name and | |
321 ;; no prefix arg means just overwrite old bookmark | |
322 (setcdr (assoc str bookmark-alist) | |
323 (list (bookmark-make-cell))) | |
324 | |
325 ;; otherwise just cons it onto the front (either the bookmark | |
326 ;; doesn't exist already, or there is no prefix arg. In either | |
327 ;; case, we want the new bookmark consed onto the alist...) | |
328 | |
329 (setq bookmark-alist | |
330 (cons | |
331 (list str | |
332 (bookmark-make-cell)) | |
333 bookmark-alist))) | |
334 ;; Added by db | |
335 (setq bookmark-current-bookmark str) | |
336 (setq bookmark-alist-modification-count | |
337 (1+ bookmark-alist-modification-count)) | |
338 (if (bookmark-time-to-save-p) | |
339 (bookmark-save))) | |
340 | |
341 (defun bookmark-make-cell () | |
342 ;; make the cell that is the cdr of a bookmark alist element. It | |
343 ;; looks like this: | |
344 ;; (filename search-forward-str search-back-str point) | |
345 (list | |
346 (bookmark-buffer-file-name) | |
347 (if (>= (- (point-max) (point)) bookmark-search-size) | |
348 (buffer-substring | |
349 (point) | |
350 (+ (point) bookmark-search-size)) | |
351 nil) | |
352 (if (>= (- (point) (point-min)) bookmark-search-size) | |
353 (buffer-substring | |
354 (point) | |
355 (- (point) bookmark-search-size)) | |
356 nil) | |
357 (point))) | |
358 | |
359 (defun bookmark-buffer-file-name () | |
360 (or | |
361 buffer-file-name | |
362 (if (and (boundp 'dired-directory) dired-directory) | |
363 (if (stringp dired-directory) | |
364 dired-directory | |
365 (car dired-directory))))) | |
366 | |
367 (defun bookmark-try-default-file () | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
368 (and (not bookmarks-already-loaded) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
369 (null bookmark-alist) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
370 (file-readable-p (expand-file-name bookmark-file)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
371 (progn |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
372 (bookmark-load bookmark-file t t) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
373 (setq bookmarks-already-loaded t)))) |
4631 | 374 |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
375 (defun bookmark-maybe-sort-alist () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
376 ;;Return the bookmark-alist for display. If the bookmark-sort-flag |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
377 ;;is non-nil, then return a sorted copy of the alist. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
378 (if bookmark-sort-flag |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
379 (setq bookmark-alist |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
380 (sort (copy-alist bookmark-alist) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
381 (function |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
382 (lambda (x y) (string-lessp (car x) (car y)))))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
383 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
384 ;;;###autoload |
4537 | 385 (defun bookmark-jump (str) |
4633 | 386 "Jump to bookmark BOOKMARK (a point in some file). |
387 You may have a problem using this function if the value of variable | |
388 `bookmark-alist' is nil. If that happens, you need to load in some | |
389 bookmarks. See help on function `bookmark-load' for more about | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
390 this. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
391 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
392 If the file pointed to by BOOKMARK no longer exists, you will be asked |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
393 if you wish to give the bookmark a new location, and bookmark-jump |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
394 will then jump to the new location, as well as recording it in place |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
395 of the old one in the permanent bookmark record." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
396 (interactive (progn (bookmark-try-default-file) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
397 (let* ((completion-ignore-case |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
398 bookmark-completion-ignore-case) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
399 (default |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
400 (or (and |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
401 (assoc bookmark-current-bookmark |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
402 bookmark-alist) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
403 bookmark-current-bookmark) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
404 (and (assoc (buffer-name (current-buffer)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
405 bookmark-alist) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
406 (buffer-name (current-buffer))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
407 (str |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
408 (completing-read |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
409 (if default |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
410 (format "Jump to bookmark (%s): " |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
411 default) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
412 "Jump to bookmark: ") |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
413 bookmark-alist |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
414 nil |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
415 0))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
416 (and (string-equal "" str) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
417 (setq str default)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
418 (list str)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
419 (let ((cell (bookmark-jump-noselect str))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
420 (and cell |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
421 (switch-to-buffer (car cell)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
422 (goto-char (cdr cell))))) |
4537 | 423 |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
424 (defun bookmark-jump-noselect (str) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
425 ;; a leetle helper for bookmark-jump :-) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
426 ;; returns (BUFFER . POINT) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
427 (let ((whereto-list (car (cdr (assoc str bookmark-alist))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
428 (let* ((file (expand-file-name (car whereto-list))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
429 (orig-file file) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
430 (forward-str (car (cdr whereto-list))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
431 (behind-str (car (cdr (cdr whereto-list)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
432 (place (car (cdr (cdr (cdr whereto-list)))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
433 (if (or |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
434 (file-exists-p file) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
435 ;; else try some common compression extensions |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
436 ;; and Emacs better handle it right! |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
437 (setq file |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
438 (or |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
439 (let ((altname (concat file ".Z"))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
440 (and (file-exists-p altname) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
441 altname)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
442 (let ((altname (concat file ".gz"))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
443 (and (file-exists-p altname) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
444 altname)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
445 (let ((altname (concat file ".z"))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
446 (and (file-exists-p altname) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
447 altname))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
448 (save-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
449 (set-buffer (find-file-noselect file)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
450 (goto-char place) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
451 ;; Go searching forward first. Then, if forward-str exists and |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
452 ;; was found in the file, we can search backward for behind-str. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
453 ;; Rationale is that if text was inserted between the two in the |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
454 ;; file, it's better to be put before it so you can read it, |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
455 ;; rather than after and remain perhaps unaware of the changes. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
456 (if forward-str |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
457 (if (search-forward forward-str (point-max) t) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
458 (backward-char bookmark-search-size))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
459 (if behind-str |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
460 (if (search-backward behind-str (point-min) t) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
461 (forward-char bookmark-search-size))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
462 ;; added by db |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
463 (setq bookmark-current-bookmark str) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
464 (cons (current-buffer) (point))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
465 (progn |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
466 (ding) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
467 (if (y-or-n-p (concat (file-name-nondirectory orig-file) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
468 " nonexistent. Relocate \"" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
469 str |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
470 "\"? ")) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
471 (progn |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
472 (bookmark-relocate str) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
473 ;; gasp! It's a recursive function call in Emacs Lisp! |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
474 (bookmark-jump-noselect str)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
475 (message |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
476 "Bookmark not relocated, but deleting it would be a good idea.") |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
477 nil)))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
478 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
479 ;;;###autoload |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
480 (defun bookmark-relocate (str) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
481 "Relocate BOOKMARK -- prompts for a filename, and makes an already |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
482 existing bookmark point to that file, instead of the one it used to |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
483 point at. Useful when a file has been renamed after a bookmark was |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
484 set in it." |
4595 | 485 (interactive (let ((completion-ignore-case |
486 bookmark-completion-ignore-case)) | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
487 (progn (bookmark-try-default-file) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
488 (list (completing-read |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
489 "Bookmark to relocate: " |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
490 bookmark-alist |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
491 nil |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
492 0))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
493 (let* ((bmrk (assoc str bookmark-alist)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
494 (bmrk-filename (car (car (cdr bmrk)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
495 (newloc (expand-file-name |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
496 (read-file-name |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
497 (format "Relocate %s to: " str) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
498 (file-name-directory bmrk-filename))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
499 (setcar (car (cdr bmrk)) newloc))) |
4537 | 500 |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
501 ;;;###autoload |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
502 (defun bookmark-locate (str &optional no-insertion) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
503 "Insert the name of the file associated with BOOKMARK. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
504 Optional second arg NO-INSERTION means merely return the filename as a |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
505 string." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
506 (interactive (let ((completion-ignore-case |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
507 bookmark-completion-ignore-case)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
508 (progn (bookmark-try-default-file) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
509 (list (completing-read |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
510 "Insert bookmark location: " |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
511 bookmark-alist |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
512 nil |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
513 0))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
514 (let ((where (car (car (cdr (assoc str bookmark-alist)))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
515 (if no-insertion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
516 where |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
517 (insert where)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
518 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
519 ;;;###autoload |
4633 | 520 (defun bookmark-rename (old &optional new) |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
521 "Change the name of OLD-BOOKMARK to NEWNAME. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
522 If called from keyboard, prompts for OLD-BOOKMARK and NEWNAME. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
523 If called from menubar, OLD-BOOKMARK is selected from a menu, and |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
524 prompts for NEWNAME. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
525 If called from Lisp, prompts for NEWNAME if only OLD-BOOKMARK was |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
526 passed as an argument. If called with two strings, then no prompting |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
527 is done. You must pass at least OLD-BOOKMARK when calling from Lisp. |
4633 | 528 |
529 While you are entering the new name, consecutive C-w's insert | |
530 consectutive words from the text of the buffer into the new bookmark | |
531 name, and C-v inserts the name of the file." | |
4595 | 532 (interactive (let ((completion-ignore-case |
533 bookmark-completion-ignore-case)) | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
534 (progn (bookmark-try-default-file) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
535 (list (completing-read "Old bookmark name: " |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
536 bookmark-alist |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
537 nil |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
538 0))))) |
4537 | 539 (progn |
540 (setq bookmark-current-point (point)) | |
541 (setq bookmark-yank-point (point)) | |
542 (setq bookmark-current-buffer (current-buffer)) | |
543 (let ((cell (assoc old bookmark-alist)) | |
544 (str | |
4633 | 545 (or new ; use second arg, if non-nil |
546 (read-from-minibuffer | |
547 "New name: " | |
548 nil | |
549 (let ((now-map (copy-keymap minibuffer-local-map))) | |
550 (progn (define-key now-map "\C-w" | |
551 'bookmark-yank-word) | |
552 (define-key now-map "\C-v" | |
553 'bookmark-insert-current-file-name)) | |
554 now-map))))) | |
4537 | 555 (progn |
556 (setcar cell str) | |
557 (setq bookmark-current-bookmark str) | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
558 (if (get-buffer "*Bookmark List*") |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
559 (save-excursion (save-window-excursion (list-bookmarks)))) |
4537 | 560 (setq bookmark-alist-modification-count |
561 (1+ bookmark-alist-modification-count)) | |
562 (if (bookmark-time-to-save-p) | |
563 (bookmark-save)))))) | |
564 | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
565 ;;;###autoload |
4537 | 566 (defun bookmark-insert (str) |
4633 | 567 "Insert the text of the file pointed to by bookmark BOOKMARK. |
568 You may have a problem using this function if the value of variable | |
569 `bookmark-alist' is nil. If that happens, you need to load in some | |
570 bookmarks. See help on function `bookmark-load' for more about | |
4631 | 571 this." |
4595 | 572 (interactive (let ((completion-ignore-case |
573 bookmark-completion-ignore-case)) | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
574 (progn (bookmark-try-default-file) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
575 (list (completing-read |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
576 "Insert bookmark contents: " |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
577 bookmark-alist |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
578 nil |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
579 0))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
580 (let ((orig-point (point)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
581 (str-to-insert |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
582 (save-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
583 (set-buffer (car (bookmark-jump-noselect str))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
584 (buffer-substring (point-min) (point-max))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
585 (insert str-to-insert) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
586 (push-mark) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
587 (goto-char orig-point))) |
4537 | 588 |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
589 ;;;###autoload |
4537 | 590 (defun bookmark-delete (str) |
4633 | 591 "Delete the bookmark named NAME from the bookmark list. |
592 Removes only the first instance of a bookmark with that name. If | |
593 there are one or more other bookmarks with the same name, they will | |
594 not be deleted. Defaults to the \"current\" bookmark \(that is, the | |
595 one most recently used in this file, if any\)." | |
4537 | 596 (interactive (let ((completion-ignore-case |
597 bookmark-completion-ignore-case)) | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
598 (progn (bookmark-try-default-file) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
599 (list |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
600 (completing-read |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
601 "Delete bookmark: " |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
602 bookmark-alist |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
603 nil |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
604 0 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
605 bookmark-current-bookmark))))) |
4595 | 606 (let ((will-go (assoc str bookmark-alist))) |
607 (setq bookmark-alist (delq will-go bookmark-alist)) | |
608 ;; Added by db, nil bookmark-current-bookmark if the last | |
609 ;; occurence has been deleted | |
4537 | 610 (or (assoc bookmark-current-bookmark bookmark-alist) |
4595 | 611 (setq bookmark-current-bookmark nil))) |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
612 (if (get-buffer "*Bookmark List*") |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
613 (save-excursion (save-window-excursion (list-bookmarks)))) |
4595 | 614 (setq bookmark-alist-modification-count |
615 (1+ bookmark-alist-modification-count)) | |
616 (if (bookmark-time-to-save-p) | |
617 (bookmark-save))) | |
4537 | 618 |
619 (defun bookmark-time-to-save-p (&optional last-time) | |
620 ;; By Gregory M. Saunders <saunders@cis.ohio-state.edu> | |
621 ;; finds out whether it's time to save bookmarks to a file, by | |
622 ;; examining the value of variable bookmark-save-flag, and maybe | |
623 ;; bookmark-alist-modification-count. Returns t if they should be | |
624 ;; saved, nil otherwise. if last-time is non-nil, then this is | |
625 ;; being called when emacs is killed. | |
626 (cond (last-time | |
627 (and (> bookmark-alist-modification-count 0) | |
628 bookmark-save-flag)) | |
629 ((numberp bookmark-save-flag) | |
630 (>= bookmark-alist-modification-count bookmark-save-flag)) | |
631 (t | |
632 nil))) | |
633 | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
634 ;;;###autoload |
4537 | 635 (defun bookmark-write () |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
636 "Write bookmarks to a file \(for which the user will be prompted |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
637 interactively\). Don't use this in Lisp programs; use bookmark-save |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
638 instead." |
4537 | 639 (interactive) |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
640 (bookmark-try-default-file) |
4537 | 641 (bookmark-save t)) |
642 | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
643 ;;;###autoload |
4595 | 644 (defun bookmark-save (&optional parg file) |
4633 | 645 "Save currently defined bookmarks. |
646 Saves by default in the file defined by the variable | |
647 `bookmark-file'. With a prefix arg, save it in file FILE. | |
4537 | 648 |
649 If you are calling this from Lisp, the two arguments are PREFIX-ARG | |
650 and FILE, and if you just want it to write to the default file, then | |
651 pass no arguments. Or pass in nil and FILE, and it will save in FILE | |
652 instead. If you pass in one argument, and it is non-nil, then the | |
653 user will be interactively queried for a file to save in. | |
654 | |
4595 | 655 When you want to load in the bookmarks from a file, use |
4633 | 656 \`bookmark-load\', \\[bookmark-load]. That function will prompt you |
4595 | 657 for a file, defaulting to the file defined by variable |
4633 | 658 `bookmark-file'." |
4537 | 659 (interactive "P") |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
660 (bookmark-try-default-file) |
4537 | 661 (cond |
662 ((and (null parg) (null file)) | |
663 ;;whether interactive or not, write to default file | |
664 (bookmark-write-file bookmark-file)) | |
665 ((and (null parg) file) | |
666 ;;whether interactive or not, write to given file | |
667 (bookmark-write-file file)) | |
668 ((and parg (not file)) | |
669 ;;have been called interactively w/ prefix arg | |
670 (let ((file (read-file-name "File to save bookmarks in: "))) | |
671 (bookmark-write-file file))) | |
672 (t ; someone called us with prefix-arg *and* a file, so just write to file | |
673 (bookmark-write-file file))) | |
674 ;; signal that we have synced the bookmark file by setting this to | |
675 ;; 0. If there was an error at any point before, it will not get | |
676 ;; set, which is what we want. | |
677 (setq bookmark-alist-modification-count 0)) | |
678 | |
679 (defun bookmark-write-file (file) | |
680 (save-excursion | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
681 (save-window-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
682 (if (>= baud-rate 9600) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
683 (message (format "Saving bookmarks to file %s." file))) |
4893
c4bab885aa8d
(bookmark-load, bookmark-write-file):
Richard M. Stallman <rms@gnu.org>
parents:
4891
diff
changeset
|
684 (set-buffer (let ((enable-local-variables nil)) |
4891 | 685 (find-file-noselect file))) |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
686 (goto-char (point-min)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
687 (delete-region (point-min) (point-max)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
688 (print bookmark-alist (current-buffer)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
689 (let ((version-control |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
690 (cond |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
691 ((null bookmark-version-control) nil) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
692 ((eq 'never bookmark-version-control) 'never) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
693 ((eq 'nospecial bookmark-version-control) version-control) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
694 (t |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
695 t)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
696 (write-file file) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
697 (kill-buffer (current-buffer)))))) |
4537 | 698 |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
699 ;;;###autoload |
4537 | 700 (defun bookmark-load (file &optional revert no-msg) |
4633 | 701 "Load bookmarks from FILE (which must be in bookmark format). |
702 Appends loaded bookmarks to the front of the list of bookmarks. If | |
703 optional second argument REVERT is non-nil, existing bookmarks are | |
704 destroyed. Optional third arg NO-MSG means don't display any messages | |
705 while loading. | |
4537 | 706 |
707 If you load a file that doesn't contain a proper bookmark alist, you | |
4633 | 708 will corrupt Emacs's bookmark list. Generally, you should only load |
4537 | 709 in files that were created with the bookmark functions in the first |
4633 | 710 place. Your own personal bookmark file, `~/.emacs-bkmrks', is |
4631 | 711 maintained automatically by Emacs; you shouldn't need to load it |
4595 | 712 explicitly." |
4537 | 713 (interactive |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
714 (progn (bookmark-try-default-file) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
715 (list (read-file-name |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
716 (format "Load bookmarks from: (%s) " |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
717 bookmark-file) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
718 ;;Default might not be used often, |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
719 ;;but there's no better default, and |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
720 ;;I guess it's better than none at all. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
721 "~/" bookmark-file 'confirm)))) |
4537 | 722 (setq file (expand-file-name file)) |
723 (if (file-readable-p file) | |
724 (save-excursion | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
725 (save-window-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
726 (if (and (null no-msg) (>= baud-rate 9600)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
727 (message (format "Loading bookmarks from %s..." file))) |
4893
c4bab885aa8d
(bookmark-load, bookmark-write-file):
Richard M. Stallman <rms@gnu.org>
parents:
4891
diff
changeset
|
728 (set-buffer (let ((enable-local-variables nil)) |
4891 | 729 (find-file-noselect file))) |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
730 (goto-char (point-min)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
731 (let ((blist (car (read-from-string |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
732 (buffer-substring (point-min) (point-max)))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
733 (if (listp blist) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
734 (progn |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
735 (if (not revert) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
736 (setq bookmark-alist-modification-count |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
737 (1+ bookmark-alist-modification-count)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
738 (setq bookmark-alist-modification-count 0)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
739 (setq bookmark-alist |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
740 (append blist (if (not revert) bookmark-alist))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
741 (if (get-buffer "*Bookmark List*") |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
742 (save-excursion (list-bookmarks)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
743 (error (format "Invalid bookmark list in %s." file)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
744 (kill-buffer (current-buffer))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
745 (if (and (null no-msg) (>= baud-rate 9600)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
746 (message (format "Loading bookmarks from %s... done" file)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
747 (error (format "Cannot read bookmark file %s." file)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
748 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
749 ;;;; bookmark-menu-mode stuff ;;;; |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
750 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
751 (defvar Bookmark-menu-bookmark-column nil) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
752 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
753 (defvar Bookmark-menu-hidden-bookmarks ()) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
754 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
755 (defvar Bookmark-menu-file-column 30 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
756 "*Column at which to display filenames in a buffer listing bookmarks. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
757 You can toggle whether files are shown with \\<Bookmark-menu-mode-map>\\[Bookmark-menu-toggle-filenames].") |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
758 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
759 (defvar Bookmark-menu-toggle-filenames t |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
760 "*Non-nil means show filenames when listing bookmarks. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
761 This may result in truncated bookmark names. To disable this, put the |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
762 following in your .emacs: |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
763 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
764 \(setq Bookmark-menu-toggle-filenames nil\)") |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
765 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
766 (defvar Bookmark-menu-mode-map nil) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
767 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
768 (if Bookmark-menu-mode-map |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
769 nil |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
770 (setq Bookmark-menu-mode-map (make-keymap)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
771 (suppress-keymap Bookmark-menu-mode-map t) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
772 (define-key Bookmark-menu-mode-map "q" 'Bookmark-menu-quit) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
773 (define-key Bookmark-menu-mode-map "v" 'Bookmark-menu-select) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
774 (define-key Bookmark-menu-mode-map "w" 'Bookmark-menu-locate) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
775 (define-key Bookmark-menu-mode-map "2" 'Bookmark-menu-2-window) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
776 (define-key Bookmark-menu-mode-map "1" 'Bookmark-menu-1-window) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
777 (define-key Bookmark-menu-mode-map "j" 'Bookmark-menu-this-window) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
778 (define-key Bookmark-menu-mode-map "f" 'Bookmark-menu-this-window) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
779 (define-key Bookmark-menu-mode-map "o" 'Bookmark-menu-other-window) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
780 (define-key Bookmark-menu-mode-map "\C-o" 'Bookmark-menu-switch-other-window) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
781 (define-key Bookmark-menu-mode-map "s" 'Bookmark-menu-save) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
782 (define-key Bookmark-menu-mode-map "k" 'Bookmark-menu-delete) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
783 (define-key Bookmark-menu-mode-map "\C-d" 'Bookmark-menu-delete-backwards) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
784 (define-key Bookmark-menu-mode-map "x" 'Bookmark-menu-execute) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
785 (define-key Bookmark-menu-mode-map "\C-k" 'Bookmark-menu-delete) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
786 (define-key Bookmark-menu-mode-map "d" 'Bookmark-menu-delete) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
787 (define-key Bookmark-menu-mode-map " " 'next-line) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
788 (define-key Bookmark-menu-mode-map "n" 'next-line) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
789 (define-key Bookmark-menu-mode-map "p" 'previous-line) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
790 (define-key Bookmark-menu-mode-map "\177" 'Bookmark-menu-backup-unmark) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
791 (define-key Bookmark-menu-mode-map "?" 'describe-mode) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
792 (define-key Bookmark-menu-mode-map "u" 'Bookmark-menu-unmark) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
793 (define-key Bookmark-menu-mode-map "m" 'Bookmark-menu-mark) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
794 (define-key Bookmark-menu-mode-map "l" 'Bookmark-menu-load) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
795 (define-key Bookmark-menu-mode-map "r" 'Bookmark-menu-rename) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
796 (define-key Bookmark-menu-mode-map "t" 'Bookmark-menu-toggle-filenames)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
797 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
798 ;; Bookmark Menu mode is suitable only for specially formatted data. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
799 (put 'Bookmark-menu-mode 'mode-class 'special) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
800 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
801 ;; need to display whether or not bookmark exists as a buffer in flag |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
802 ;; column. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
803 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
804 ;; Format: |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
805 ;; FLAGS BOOKMARK (/FILE/NAME/HERE/WHAT/REGEXP/TO/USE?) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
806 ;; goto bookmark-column and then search till "(/[^)]*)$" or "(/.*)$" ? |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
807 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
808 ;;;###autoload |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
809 (defalias 'edit-bookmarks 'list-bookmarks) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
810 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
811 ;;;###autoload |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
812 (defun list-bookmarks () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
813 "Display a list of existing bookmarks. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
814 The list is displayed in a buffer named `*Bookmark List*'. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
815 The leftmost column displays a D if the bookmark is flagged for |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
816 deletion, or > if it is flagged for displaying." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
817 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
818 (bookmark-try-default-file) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
819 (switch-to-buffer (get-buffer-create "*Bookmark List*")) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
820 (let ((buffer-read-only nil)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
821 (delete-region (point-max) (point-min)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
822 (goto-char (point-min)) ;sure are playing it safe... |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
823 (insert "% Bookmark\n- --------\n") |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
824 (bookmark-maybe-sort-alist) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
825 (let ((lst bookmark-alist)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
826 (while lst |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
827 (insert |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
828 (concat " " (car (car lst)) "\n")) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
829 (setq lst (cdr lst))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
830 (goto-char (point-min)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
831 (forward-line 2) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
832 (bookmark-menu-mode) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
833 (if Bookmark-menu-toggle-filenames |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
834 (Bookmark-menu-toggle-filenames t))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
835 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
836 (defun bookmark-menu-mode () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
837 "Major mode for editing a list of bookmarks. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
838 Each line describes one of the bookmarks in Emacs. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
839 Letters do not insert themselves; instead, they are commands. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
840 \\<Bookmark-menu-mode-map> |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
841 \\[Bookmark-menu-mark] -- mark bookmark to be displayed. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
842 \\[Bookmark-menu-select] -- select bookmark of line point is on. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
843 Also show bookmarks marked using m in other windows. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
844 \\[Bookmark-menu-toggle-filenames] -- toggle displaying of filenames (they may obscure long bookmark names). |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
845 \\[Bookmark-menu-locate] -- display (in minibuffer) location of this bookmark. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
846 \\[Bookmark-menu-1-window] -- select this bookmark in full-frame window. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
847 \\[Bookmark-menu-2-window] -- select this bookmark in one window, |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
848 together with bookmark selected before this one in another window. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
849 \\[Bookmark-menu-this-window] -- select this bookmark in place of the bookmark menu buffer. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
850 \\[Bookmark-menu-other-window] -- select this bookmark in another window, |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
851 so the bookmark menu bookmark remains visible in its window. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
852 \\[Bookmark-menu-switch-other-window] -- switch the other window to this bookmark. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
853 \\[Bookmark-menu-rename] -- rename this bookmark \(prompts for new name\). |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
854 \\[Bookmark-menu-delete] -- mark this bookmark to be deleted, and move down. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
855 \\[Bookmark-menu-delete-backwards] -- mark this bookmark to be deleted, and move up. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
856 \\[Bookmark-menu-execute] -- delete marked bookmarks. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
857 \\[Bookmark-menu-save] -- save the current bookmark list in the default file. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
858 With a prefix arg, prompts for a file to save in. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
859 \\[Bookmark-menu-load] -- load in a file of bookmarks (prompts for file.) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
860 \\[Bookmark-menu-unmark] -- remove all kinds of marks from current line. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
861 With prefix argument, also move up one line. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
862 \\[Bookmark-menu-backup-unmark] -- back up a line and remove marks." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
863 (kill-all-local-variables) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
864 (use-local-map Bookmark-menu-mode-map) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
865 (setq truncate-lines t) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
866 (setq buffer-read-only t) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
867 (setq major-mode 'bookmark-menu-mode) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
868 (setq mode-name "Bookmark Menu") |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
869 (run-hooks 'bookmark-menu-mode-hook)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
870 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
871 (defun Bookmark-menu-toggle-filenames (&optional parg) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
872 "Toggle whether filenames are shown in the bookmark list. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
873 Optional argument SHOW means show them unconditionally." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
874 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
875 (cond |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
876 (parg |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
877 (setq Bookmark-menu-toggle-filenames nil) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
878 (Bookmark-menu-show-filenames) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
879 (setq Bookmark-menu-toggle-filenames t)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
880 (Bookmark-menu-toggle-filenames |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
881 (Bookmark-menu-hide-filenames) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
882 (setq Bookmark-menu-toggle-filenames nil)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
883 (t |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
884 (Bookmark-menu-show-filenames) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
885 (setq Bookmark-menu-toggle-filenames t)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
886 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
887 (defun Bookmark-menu-show-filenames (&optional force) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
888 (if (and (not force) Bookmark-menu-toggle-filenames) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
889 nil ;already shown, so do nothing |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
890 (save-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
891 (save-window-excursion |
4537 | 892 (goto-char (point-min)) |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
893 (forward-line 2) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
894 (setq Bookmark-menu-hidden-bookmarks ()) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
895 (let ((buffer-read-only nil)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
896 (while (< (point) (point-max)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
897 (let ((bmrk (Bookmark-menu-bookmark))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
898 (setq Bookmark-menu-hidden-bookmarks |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
899 (cons bmrk Bookmark-menu-hidden-bookmarks)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
900 (move-to-column Bookmark-menu-file-column t) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
901 (delete-region (point) (progn (end-of-line) (point))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
902 (insert " ") |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
903 (bookmark-locate bmrk) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
904 (forward-line 1)))))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
905 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
906 (defun Bookmark-menu-hide-filenames (&optional force) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
907 (if (and (not force) Bookmark-menu-toggle-filenames) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
908 ;; nothing to hide if above is nil |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
909 (save-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
910 (save-window-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
911 (goto-char (point-min)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
912 (forward-line 2) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
913 (setq Bookmark-menu-hidden-bookmarks |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
914 (nreverse Bookmark-menu-hidden-bookmarks)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
915 (save-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
916 (goto-char (point-min)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
917 (search-forward "Bookmark") |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
918 (backward-word 1) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
919 (setq Bookmark-menu-bookmark-column (current-column))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
920 (save-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
921 (let ((buffer-read-only nil)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
922 (while Bookmark-menu-hidden-bookmarks |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
923 (move-to-column Bookmark-menu-bookmark-column t) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
924 (kill-line) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
925 (insert (car Bookmark-menu-hidden-bookmarks)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
926 (setq Bookmark-menu-hidden-bookmarks |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
927 (cdr Bookmark-menu-hidden-bookmarks)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
928 (forward-line 1)))))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
929 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
930 ;; if you look at this next function from far away, it resembles a |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
931 ;; gun. But only with this comment above... |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
932 (defun Bookmark-menu-check-position () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
933 ;; Returns t if on a line with a bookmark. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
934 ;; Otherwise, repositions and returns t. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
935 ;; written by David Hughes <djh@harston.cv.com> |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
936 ;; Mucho thanks, David! -karl |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
937 (cond ((< (count-lines (point-min) (point)) 2) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
938 (goto-char (point-min)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
939 (forward-line 2) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
940 t) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
941 ((and (bolp) (eobp)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
942 (beginning-of-line 0) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
943 t) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
944 (t |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
945 t))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
946 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
947 (defun Bookmark-menu-bookmark () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
948 ;; return a string which is bookmark of this line. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
949 (if (Bookmark-menu-check-position) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
950 (save-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
951 (save-window-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
952 (goto-char (point-min)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
953 (search-forward "Bookmark") |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
954 (backward-word 1) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
955 (setq Bookmark-menu-bookmark-column (current-column))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
956 (if Bookmark-menu-toggle-filenames |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
957 (Bookmark-menu-hide-filenames)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
958 (save-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
959 (save-window-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
960 (beginning-of-line) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
961 (forward-char Bookmark-menu-bookmark-column) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
962 (prog1 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
963 (buffer-substring (point) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
964 (progn |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
965 (end-of-line) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
966 (point))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
967 ;; well, this is certainly crystal-clear: |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
968 (if Bookmark-menu-toggle-filenames |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
969 (Bookmark-menu-toggle-filenames t)))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
970 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
971 (defun Bookmark-menu-mark () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
972 "Mark bookmark on this line to be displayed by \\<Bookmark-menu-mode-map>\\[Bookmark-menu-select] command." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
973 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
974 (beginning-of-line) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
975 (if (Bookmark-menu-check-position) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
976 (let ((buffer-read-only nil)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
977 (delete-char 1) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
978 (insert ?>) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
979 (forward-line 1)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
980 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
981 (defun Bookmark-menu-select () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
982 "Select this line's bookmark; also display bookmarks marked with `>'. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
983 You can mark bookmarks with the \\<Bookmark-menu-mode-map>\\[Bookmark-menu-mark] command." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
984 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
985 (if (Bookmark-menu-check-position) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
986 (let ((bmrk (Bookmark-menu-bookmark)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
987 (menu (current-buffer)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
988 (others ()) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
989 tem) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
990 (goto-char (point-min)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
991 (while (re-search-forward "^>" nil t) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
992 (setq tem (Bookmark-menu-bookmark)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
993 (let ((buffer-read-only nil)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
994 (delete-char -1) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
995 (insert ?\ )) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
996 (or (string-equal tem bmrk) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
997 (memq tem others) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
998 (setq others (cons tem others)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
999 (setq others (nreverse others) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1000 tem (/ (1- (frame-height)) (1+ (length others)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1001 (delete-other-windows) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1002 (bookmark-jump bmrk) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1003 (bury-buffer menu) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1004 (if (equal (length others) 0) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1005 nil |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1006 (while others |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1007 (split-window nil tem) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1008 (other-window 1) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1009 (bookmark-jump (car others)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1010 (setq others (cdr others))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1011 (other-window 1))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1012 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1013 (defun Bookmark-menu-save (parg) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1014 "Save the current list into a bookmark file. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1015 With a prefix arg, prompts for a file to save them in." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1016 (interactive "P") |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1017 (save-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1018 (save-window-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1019 (bookmark-save parg)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1020 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1021 (defun Bookmark-menu-load () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1022 "Load a bookmark file and rebuild list." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1023 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1024 (if (Bookmark-menu-check-position) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1025 (save-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1026 (save-window-excursion |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1027 (call-interactively 'bookmark-load))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1028 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1029 (defun Bookmark-menu-1-window () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1030 "Select this line's bookmark, alone, in full frame." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1031 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1032 (if (Bookmark-menu-check-position) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1033 (progn |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1034 (bookmark-jump (Bookmark-menu-bookmark)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1035 (bury-buffer (other-buffer)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1036 (delete-other-windows)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1037 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1038 (defun Bookmark-menu-2-window () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1039 "Select this line's bookmark, with previous buffer in second window." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1040 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1041 (if (Bookmark-menu-check-position) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1042 (let ((bmrk (Bookmark-menu-bookmark)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1043 (menu (current-buffer)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1044 (pop-up-windows t)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1045 (delete-other-windows) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1046 (switch-to-buffer (other-buffer)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1047 (let ((buff (car (bookmark-jump-noselect bmrk)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1048 (pop-to-buffer buff)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1049 (bury-buffer menu)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1050 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1051 (defun Bookmark-menu-this-window () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1052 "Select this line's bookmark in this window." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1053 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1054 (if (Bookmark-menu-check-position) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1055 (bookmark-jump (Bookmark-menu-bookmark)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1056 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1057 (defun Bookmark-menu-other-window () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1058 "Select this line's bookmark in other window, leaving bookmark menu visible." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1059 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1060 (if (Bookmark-menu-check-position) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1061 (let ((buff (car (bookmark-jump-noselect (Bookmark-menu-bookmark))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1062 (switch-to-buffer-other-window buff)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1063 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1064 (defun Bookmark-menu-switch-other-window () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1065 "Make the other window select this line's bookmark. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1066 The current window remains selected." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1067 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1068 (if (Bookmark-menu-check-position) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1069 (let ((buff (car (bookmark-jump-noselect (Bookmark-menu-bookmark))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1070 (display-buffer buff)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1071 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1072 (defun Bookmark-menu-quit () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1073 "Quit the bookmark menu." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1074 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1075 (let ((buffer (current-buffer))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1076 (switch-to-buffer (other-buffer)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1077 (bury-buffer buffer))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1078 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1079 (defun Bookmark-menu-unmark (&optional backup) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1080 "Cancel all requested operations on bookmark on this line and move down. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1081 Optional ARG means move up." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1082 (interactive "P") |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1083 (beginning-of-line) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1084 (if (Bookmark-menu-check-position) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1085 (progn |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1086 (let ((buffer-read-only nil)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1087 (delete-char 1) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1088 ;; any flags to reset according to circumstances? How about a |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1089 ;; flag indicating whether this bookmark is being visited? |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1090 ;; well, we don't have this now, so maybe later. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1091 (insert " ")) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1092 (forward-line (if backup -1 1))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1093 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1094 (defun Bookmark-menu-backup-unmark () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1095 "Move up and cancel all requested operations on bookmark on line above." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1096 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1097 (forward-line -1) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1098 (if (Bookmark-menu-check-position) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1099 (progn |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1100 (Bookmark-menu-unmark) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1101 (forward-line -1)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1102 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1103 (defun Bookmark-menu-delete () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1104 "Mark bookmark on this line to be deleted by \\<Bookmark-menu-mode-map>\\[Bookmark-menu-execute] command." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1105 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1106 (beginning-of-line) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1107 (if (Bookmark-menu-check-position) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1108 (let ((buffer-read-only nil)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1109 (delete-char 1) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1110 (insert ?D) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1111 (forward-line 1)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1112 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1113 (defun Bookmark-menu-delete-backwards () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1114 "Mark bookmark on this line to be deleted by \\<Bookmark-menu-mode-map>\\[Bookmark-menu-execute] command |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1115 and then move up one line" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1116 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1117 (Bookmark-menu-delete) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1118 (forward-line -2) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1119 (if (Bookmark-menu-check-position) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1120 (forward-line 1))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1121 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1122 (defun Bookmark-menu-execute () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1123 "Delete bookmarks marked with \\<Buffer-menu-mode-map>\\[Buffer-menu-delete] commands." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1124 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1125 (let ((hide-em Bookmark-menu-toggle-filenames)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1126 (if hide-em (Bookmark-menu-hide-filenames)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1127 (setq Bookmark-menu-toggle-filenames nil) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1128 (goto-char (point-min)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1129 (forward-line 1) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1130 (let ((deaders ())) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1131 (while (re-search-forward "^D" (point-max) t) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1132 (setq deaders (cons (Bookmark-menu-bookmark) deaders))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1133 (mapcar (lambda (str) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1134 (setq bookmark-alist |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1135 (delq (assoc str bookmark-alist) bookmark-alist))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1136 deaders)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1137 (list-bookmarks) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1138 (goto-char (point-min)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1139 (forward-line 2) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1140 (setq Bookmark-menu-toggle-filenames hide-em) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1141 (if Bookmark-menu-toggle-filenames |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1142 (Bookmark-menu-toggle-filenames t)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1143 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1144 (defun Bookmark-menu-rename () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1145 "Rename bookmark on current line. Prompts for a new name." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1146 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1147 (if (Bookmark-menu-check-position) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1148 (let ((bmrk (Bookmark-menu-bookmark)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1149 (thispoint (point))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1150 (bookmark-rename bmrk) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1151 (list-bookmarks) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1152 (goto-char thispoint)))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1153 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1154 (defun Bookmark-menu-locate () |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1155 "Display location of this bookmark. Displays in the minibuffer." |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1156 (interactive) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1157 (if (Bookmark-menu-check-position) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1158 (let ((bmrk (Bookmark-menu-bookmark))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1159 (message (bookmark-locate bmrk t))))) |
4537 | 1160 |
4595 | 1161 ;;;; bookmark menu bar stuff ;;;; |
4537 | 1162 |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1163 (defvar bookmark-menu-bar-length 70 |
4633 | 1164 "*Maximum length of a bookmark name displayed on a popup menu.") |
4595 | 1165 |
1166 (defun bookmark-make-menu-bar-alist () | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1167 (bookmark-try-default-file) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1168 (bookmark-maybe-sort-alist) |
4537 | 1169 (if bookmark-alist |
1170 (mapcar (lambda (cell) | |
1171 (let ((str (car cell))) | |
1172 (cons | |
4595 | 1173 (if (> (length str) bookmark-menu-bar-length) |
1174 (substring str 0 bookmark-menu-bar-length) | |
4537 | 1175 str) |
1176 str))) | |
1177 bookmark-alist) | |
1178 (error "No bookmarks currently set."))) | |
1179 | |
4595 | 1180 (defun bookmark-make-menu-bar-with-function (func-sym |
1181 menu-label | |
1182 menu-str event) | |
4537 | 1183 ;; help function for making menus that need to apply a bookmark |
1184 ;; function to a string. | |
4595 | 1185 (let* ((menu (bookmark-make-menu-bar-alist)) |
4537 | 1186 (str (x-popup-menu event |
1187 (list menu-label | |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1188 (cons menu-str menu))))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1189 (if str (apply func-sym (list str))))) |
4537 | 1190 |
4595 | 1191 (defun bookmark-menu-bar-insert (event) |
4633 | 1192 "Insert the text of the file pointed to by bookmark BOOKMARK. |
1193 You may have a problem using this function if the value of variable | |
1194 `bookmark-alist' is nil. If that happens, you need to load in some | |
1195 bookmarks. See help on function `bookmark-load' for more about | |
1196 this." | |
4537 | 1197 (interactive "e") |
4595 | 1198 (bookmark-make-menu-bar-with-function 'bookmark-insert |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1199 "Bookmark Insert Menu" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1200 "--- Insert Contents ---" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1201 event)) |
4537 | 1202 |
4595 | 1203 (defun bookmark-menu-bar-jump (event) |
4633 | 1204 "Jump to bookmark BOOKMARK (a point in some file). |
1205 You may have a problem using this function if the value of variable | |
1206 `bookmark-alist' is nil. If that happens, you need to load in some | |
1207 bookmarks. See help on function `bookmark-load' for more about | |
1208 this." | |
4537 | 1209 (interactive "e") |
4595 | 1210 (bookmark-make-menu-bar-with-function 'bookmark-jump |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1211 "Bookmark Jump Menu" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1212 "--- Jump to Bookmark ---" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1213 event)) |
4537 | 1214 |
4595 | 1215 (defun bookmark-menu-bar-locate (event) |
4633 | 1216 "Insert the name of the file associated with BOOKMARK. |
1217 \(This is not the same as the contents of that file\)." | |
4537 | 1218 (interactive "e") |
4595 | 1219 (bookmark-make-menu-bar-with-function 'bookmark-locate |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1220 "Bookmark Locate Menu" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1221 "--- Insert Location ---" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1222 event)) |
4537 | 1223 |
4595 | 1224 (defun bookmark-menu-bar-rename (event) |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1225 "Change the name of OLD-BOOKMARK to NEWNAME. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1226 If called from keyboard, prompts for OLD-BOOKMARK and NEWNAME. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1227 If called from menubar, OLD-BOOKMARK is selected from a menu, and |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1228 prompts for NEWNAME. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1229 If called from Lisp, prompts for NEWNAME if only OLD-BOOKMARK was |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1230 passed as an argument. If called with two strings, then no prompting |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1231 is done. You must pass at least OLD-BOOKMARK when calling from Lisp. |
4633 | 1232 |
1233 While you are entering the new name, consecutive C-w's insert | |
1234 consectutive words from the text of the buffer into the new bookmark | |
1235 name, and C-v inserts the name of the file." | |
4537 | 1236 (interactive "e") |
4595 | 1237 (bookmark-make-menu-bar-with-function 'bookmark-rename |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1238 "Bookmark Rename Menu" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1239 "--- Rename Bookmark ---" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1240 event)) |
4537 | 1241 |
4595 | 1242 (defun bookmark-menu-bar-delete (event) |
4633 | 1243 "Delete the bookmark named NAME from the bookmark list. |
1244 Removes only the first instance of a bookmark with that name. If | |
1245 there are one or more other bookmarks with the same name, they will | |
1246 not be deleted. Defaults to the \"current\" bookmark \(that is, the | |
1247 one most recently used in this file, if any\)." | |
4537 | 1248 (interactive "e") |
4595 | 1249 (bookmark-make-menu-bar-with-function 'bookmark-delete |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1250 "Bookmark Delete Menu" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1251 "--- Delete Bookmark ---" |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1252 event)) |
4537 | 1253 |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1254 ;; Thanks to Roland McGrath for fixing menubar.el so that the |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1255 ;; following works, and for explaining what to do to make it work. |
4537 | 1256 |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1257 (defvar menu-bar-bookmark-map (make-sparse-keymap "Bookmark functions.")) |
4537 | 1258 |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1259 ;; make bookmarks appear toward the right side of the menu. |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1260 (if (boundp 'menu-bar-final-items) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1261 (if menu-bar-final-items |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1262 (setq menu-bar-final-items |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1263 (cons 'bookmark menu-bar-final-items))) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1264 (setq menu-bar-final-items '(bookmark))) |
4537 | 1265 |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1266 (define-key menu-bar-bookmark-map [load] |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1267 '("Load a bookmark file" . bookmark-load)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1268 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1269 (define-key menu-bar-bookmark-map [write] |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1270 '("Write \(to another file\)" . bookmark-write)) |
4537 | 1271 |
4848
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1272 (define-key menu-bar-bookmark-map [save] |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1273 '("Save \(in default file\)" . bookmark-save)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1274 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1275 (define-key menu-bar-bookmark-map [edit] |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1276 '("Edit Bookmark List" . list-bookmarks)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1277 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1278 (define-key menu-bar-bookmark-map [delete] |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1279 '("Delete bookmark" . bookmark-menu-bar-delete)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1280 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1281 (define-key menu-bar-bookmark-map [rename] |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1282 '("Rename bookmark" . bookmark-menu-bar-rename)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1283 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1284 (define-key menu-bar-bookmark-map [locate] |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1285 '("Insert location" . bookmark-menu-bar-locate)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1286 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1287 (define-key menu-bar-bookmark-map [insert] |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1288 '("Insert contents" . bookmark-menu-bar-insert)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1289 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1290 (define-key menu-bar-bookmark-map [set] |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1291 '("Set bookmark" . bookmark-set)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1292 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1293 (define-key menu-bar-bookmark-map [jump] |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1294 '("Jump to bookmark" . bookmark-menu-bar-jump)) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1295 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1296 ;;;###autoload (autoload 'menu-bar-bookmark-map "bookmark" nil t 'keymap) |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1297 |
511c83aee4ae
(bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents:
4634
diff
changeset
|
1298 (fset 'menu-bar-bookmark-map (symbol-value 'menu-bar-bookmark-map)) |
4537 | 1299 |
4595 | 1300 ;;;; end bookmark menu-bar stuff ;;;; |
4537 | 1301 |
1302 (provide 'bookmark) | |
1303 | |
4595 | 1304 ;;; bookmark.el ends here |