annotate lisp/bookmark.el @ 7510:9f361177d70c

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