annotate lisp/bookmark.el @ 111709:4483c6423ad1

shr-color.el (shr-color-visible): Don't bug out if the colour names don't exist.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Thu, 25 Nov 2010 07:46:51 +0000
parents 249a1455856a
children dd83cbcddf69
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 38173
diff changeset
1 ;;; bookmark.el --- set bookmarks, maybe annotate them, jump to them later
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
111429
249a1455856a Use line-end-position rather than end-of-line, etc.
Glenn Morris <rgm@gnu.org>
parents: 109399
diff changeset
3 ;; Copyright (C) 1993, 1994, 1995, 1996, 1997, 2001, 2002, 2003, 2004,
249a1455856a Use line-end-position rather than end-of-line, etc.
Glenn Morris <rgm@gnu.org>
parents: 109399
diff changeset
4 ;; 2005, 2006, 2007, 2008, 2009, 2010
249a1455856a Use line-end-position rather than end-of-line, etc.
Glenn Morris <rgm@gnu.org>
parents: 109399
diff changeset
5 ;; Free Software Foundation, Inc.
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6
14039
831c5fda97f4 "cyclic.com" addresses changed to "red-bean.com".
Karl Fogel <kfogel@red-bean.com>
parents: 13969
diff changeset
7 ;; Author: Karl Fogel <kfogel@red-bean.com>
831c5fda97f4 "cyclic.com" addresses changed to "red-bean.com".
Karl Fogel <kfogel@red-bean.com>
parents: 13969
diff changeset
8 ;; Maintainer: Karl Fogel <kfogel@red-bean.com>
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; Created: July, 1993
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
10 ;; Keywords: bookmarks, placeholders, annotations
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; This file is part of GNU Emacs.
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93705
diff changeset
14 ;; GNU Emacs is free software: you can redistribute it and/or modify
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93705
diff changeset
16 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93705
diff changeset
17 ;; (at your option) any later version.
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; 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
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; GNU General Public License for more details.
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93705
diff changeset
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14039
diff changeset
26
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14039
diff changeset
27 ;;; Commentary:
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14039
diff changeset
28
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14039
diff changeset
29 ;; This package is for setting "bookmarks" in files. A bookmark
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14039
diff changeset
30 ;; associates a string with a location in a certain file. Thus, you
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14039
diff changeset
31 ;; can navigate your way to that location by providing the string.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14039
diff changeset
32 ;; See the "User Variables" section for customizations.
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
34
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 38173
diff changeset
35 ;;; Code:
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
36
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14039
diff changeset
37 (require 'pp)
99774
b53beb0ef91c (bookmark-get-bookmark): Add `noerror' arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99773
diff changeset
38 (eval-when-compile (require 'cl))
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14039
diff changeset
39
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
40 ;;; Misc comments:
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;;
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
42 ;; If variable bookmark-use-annotations is non-nil, an annotation is
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
43 ;; queried for when setting a bookmark.
4595
2507541ef88d New version from Fogel.
Richard M. Stallman <rms@gnu.org>
parents: 4537
diff changeset
44 ;;
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
45 ;; 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
46 ;; 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
47 ;; 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
48 ;; (chronologically), which is actually fairly useful as well.
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
50 ;;; User Variables
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
51
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
52 (defgroup bookmark nil
17412
cd7152c1ca13 (bookmark, bookmark-use-annotations)
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
53 "Setting, annotation and jumping to bookmarks."
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
54 :group 'matching)
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
55
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
56
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
57 (defcustom bookmark-use-annotations nil
92688
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
58 "If non-nil, saving a bookmark queries for an annotation in a buffer."
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
59 :type 'boolean
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
60 :group 'bookmark)
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
61
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
62
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
63 (defcustom bookmark-save-flag t
92688
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
64 "Controls when Emacs saves bookmarks to a file.
17412
cd7152c1ca13 (bookmark, bookmark-use-annotations)
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
65 --> nil means never save bookmarks, except when `bookmark-save' is
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
66 explicitly called (\\[bookmark-save]).
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
67 --> t means save bookmarks when Emacs is killed.
13969
8fd836e88aec (bookmark-save-flag, bookmark-read-annotation-text-func,
Karl Heuer <kwzh@gnu.org>
parents: 13895
diff changeset
68 --> Otherwise, it should be a number that is the frequency with which
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
69 the bookmark list is saved (i.e.: the number of times which
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
70 Emacs' bookmark list may be modified before it is automatically
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
71 saved.). If it is a number, Emacs will also automatically save
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
72 bookmarks when it is killed.
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
73
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
74 Therefore, the way to get it to save every time you make or delete a
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
75 bookmark is to set this variable to 1 (or 0, which produces the same
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
76 behavior.)
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
77
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
78 To specify the file in which to save them, modify the variable
17412
cd7152c1ca13 (bookmark, bookmark-use-annotations)
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
79 `bookmark-default-file', which is `~/.emacs.bmk' by default."
22568
5682c77dce71 (bookmark-save-flag, bookmark-version-control): Use
Andreas Schwab <schwab@suse.de>
parents: 22251
diff changeset
80 :type '(choice (const nil) integer (other t))
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
81 :group 'bookmark)
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
82
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
83
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
84 (defconst bookmark-old-default-file "~/.emacs-bkmrks"
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 99774
diff changeset
85 "The `.emacs.bmk' file used to be called this name.")
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
86
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
87
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
88 ;; defvarred to avoid a compilation warning:
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
89 (defvar bookmark-file nil
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
90 "Old name for `bookmark-default-file'.")
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
91
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
92 (defcustom bookmark-default-file
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
93 (if bookmark-file
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
94 ;; In case user set `bookmark-file' in her .emacs:
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
95 bookmark-file
107838
f50f5478ec53 Clean up last bookmark changes for man/woman/gnus-summary.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107192
diff changeset
96 (locate-user-emacs-file "bookmarks" ".emacs.bmk"))
92688
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
97 "File in which to save bookmarks by default."
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
98 :type 'file
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
99 :group 'bookmark)
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
100
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
101
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
102 (defcustom bookmark-version-control 'nospecial
92688
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
103 "Whether or not to make numbered backups of the bookmark file.
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
104 It can have four values: t, nil, `never', and `nospecial'.
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
105 The first three have the same meaning that they do for the
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
106 variable `version-control', and the final value `nospecial' means just
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
107 use the value of `version-control'."
22568
5682c77dce71 (bookmark-save-flag, bookmark-version-control): Use
Andreas Schwab <schwab@suse.de>
parents: 22251
diff changeset
108 :type '(choice (const nil) (const never) (const nospecial)
5682c77dce71 (bookmark-save-flag, bookmark-version-control): Use
Andreas Schwab <schwab@suse.de>
parents: 22251
diff changeset
109 (other t))
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
110 :group 'bookmark)
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
111
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
112
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
113 (defcustom bookmark-completion-ignore-case t
92688
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
114 "Non-nil means bookmark functions ignore case in completion."
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
115 :type 'boolean
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
116 :group 'bookmark)
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
117
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
118
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
119 (defcustom bookmark-sort-flag t
92688
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
120 "Non-nil means that bookmarks will be displayed sorted by bookmark name.
17412
cd7152c1ca13 (bookmark, bookmark-use-annotations)
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
121 Otherwise they will be displayed in LIFO order (that is, most
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
122 recently set ones come first, oldest ones come last)."
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
123 :type 'boolean
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
124 :group 'bookmark)
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
125
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
126
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
127 (defcustom bookmark-automatically-show-annotations t
92688
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
128 "Non-nil means show annotations when jumping to a bookmark."
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
129 :type 'boolean
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
130 :group 'bookmark)
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
131
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
132
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
133 (defconst bookmark-bmenu-header-height 2
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
134 "Number of lines used for the *Bookmark List* header.")
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
135
106714
396a004a924b * lisp/bookmark.el: Consistently put the text property on the bookmark name.
Karl Fogel <kfogel@red-bean.com>
parents: 106713
diff changeset
136 (defconst bookmark-bmenu-marks-width 2
396a004a924b * lisp/bookmark.el: Consistently put the text property on the bookmark name.
Karl Fogel <kfogel@red-bean.com>
parents: 106713
diff changeset
137 "Number of columns (chars) used for the *Bookmark List* marks column,
396a004a924b * lisp/bookmark.el: Consistently put the text property on the bookmark name.
Karl Fogel <kfogel@red-bean.com>
parents: 106713
diff changeset
138 including the annotations column.")
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
139
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
140 (defcustom bookmark-bmenu-file-column 30
92688
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
141 "Column at which to display filenames in a buffer listing bookmarks.
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
142 You can toggle whether files are shown with \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-toggle-filenames]."
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
143 :type 'integer
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
144 :group 'bookmark)
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
145
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
146
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
147 (defcustom bookmark-bmenu-toggle-filenames t
92688
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
148 "Non-nil means show filenames when listing bookmarks.
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
149 This may result in truncated bookmark names. To disable this, put the
17412
cd7152c1ca13 (bookmark, bookmark-use-annotations)
Richard M. Stallman <rms@gnu.org>
parents: 17411
diff changeset
150 following in your `.emacs' file:
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
151
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
152 \(setq bookmark-bmenu-toggle-filenames nil)"
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
153 :type 'boolean
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
154 :group 'bookmark)
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
155
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
156
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
157 (defcustom bookmark-menu-length 70
92688
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
158 "Maximum length of a bookmark name displayed on a popup menu."
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17265
diff changeset
159 :type 'integer
48393
68aa78bf3f63 (bookmark-menu-length): Fix typo in group name.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45793
diff changeset
160 :group 'bookmark)
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
161
106179
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
162 ;; FIXME: Is it really worth a customization option?
106166
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
163 (defcustom bookmark-search-delay 0.2
106179
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
164 "Time before `bookmark-bmenu-search' updates the display."
106166
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
165 :group 'bookmark
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
166 :type 'integer)
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
167
66201
54d9518d9113 (bookmark-menu-heading): New face.
Romain Francoise <romain@orebokech.com>
parents: 66192
diff changeset
168 (defface bookmark-menu-heading
54d9518d9113 (bookmark-menu-heading): New face.
Romain Francoise <romain@orebokech.com>
parents: 66192
diff changeset
169 '((t (:inherit font-lock-type-face)))
54d9518d9113 (bookmark-menu-heading): New face.
Romain Francoise <romain@orebokech.com>
parents: 66192
diff changeset
170 "Face used to highlight the heading in bookmark menu buffers."
54d9518d9113 (bookmark-menu-heading): New face.
Romain Francoise <romain@orebokech.com>
parents: 66192
diff changeset
171 :group 'bookmark
54d9518d9113 (bookmark-menu-heading): New face.
Romain Francoise <romain@orebokech.com>
parents: 66192
diff changeset
172 :version "22.1")
54d9518d9113 (bookmark-menu-heading): New face.
Romain Francoise <romain@orebokech.com>
parents: 66192
diff changeset
173
54d9518d9113 (bookmark-menu-heading): New face.
Romain Francoise <romain@orebokech.com>
parents: 66192
diff changeset
174
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
175 ;;; No user-serviceable parts beyond this point.
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 ;; Added for lucid emacs compatibility, db
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (or (fboundp 'defalias) (fset 'defalias 'fset))
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
180 ;; suggested for lucid compatibility by david hughes:
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
181 (or (fboundp 'frame-height) (defalias 'frame-height 'screen-height))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
182
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
183
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
184 ;;; Keymap stuff:
18709
a82b89790f9c Make global bindings only via loaddefs.el.
Richard M. Stallman <rms@gnu.org>
parents: 17412
diff changeset
185
a82b89790f9c Make global bindings only via loaddefs.el.
Richard M. Stallman <rms@gnu.org>
parents: 17412
diff changeset
186 ;; Set up these bindings dumping time *only*;
a82b89790f9c Make global bindings only via loaddefs.el.
Richard M. Stallman <rms@gnu.org>
parents: 17412
diff changeset
187 ;; if the user alters them, don't override the user when loading bookmark.el.
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188
96438
5efd78aaea5b Rebind three global `C-x r' keys "b", "m", "l" to the new map
Juri Linkov <juri@jurta.org>
parents: 96280
diff changeset
189 ;;;###autoload (define-key ctl-x-r-map "b" 'bookmark-jump)
5efd78aaea5b Rebind three global `C-x r' keys "b", "m", "l" to the new map
Juri Linkov <juri@jurta.org>
parents: 96280
diff changeset
190 ;;;###autoload (define-key ctl-x-r-map "m" 'bookmark-set)
5efd78aaea5b Rebind three global `C-x r' keys "b", "m", "l" to the new map
Juri Linkov <juri@jurta.org>
parents: 96280
diff changeset
191 ;;;###autoload (define-key ctl-x-r-map "l" 'bookmark-bmenu-list)
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
193 ;;;###autoload
92550
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
194 (defvar bookmark-map
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
195 (let ((map (make-sparse-keymap)))
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
196 ;; Read the help on all of these functions for details...
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
197 (define-key map "x" 'bookmark-set)
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
198 (define-key map "m" 'bookmark-set) ;"m"ark
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
199 (define-key map "j" 'bookmark-jump)
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
200 (define-key map "g" 'bookmark-jump) ;"g"o
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
201 (define-key map "o" 'bookmark-jump-other-window)
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
202 (define-key map "i" 'bookmark-insert)
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
203 (define-key map "e" 'edit-bookmarks)
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
204 (define-key map "f" 'bookmark-insert-location) ;"f"ind
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
205 (define-key map "r" 'bookmark-rename)
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
206 (define-key map "d" 'bookmark-delete)
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
207 (define-key map "l" 'bookmark-load)
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
208 (define-key map "w" 'bookmark-write)
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
209 (define-key map "s" 'bookmark-save)
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
210 map)
4633
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
211 "Keymap containing bindings to bookmark functions.
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
212 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
213 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
214 key of your choice to `bookmark-map'. All interactive bookmark
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 functions have a binding in this keymap.")
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216
92550
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
217 ;;;###autoload (fset 'bookmark-map bookmark-map)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
218
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
219
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
220 ;;; Core variables and data structures:
4634
cd8eef9ec0c4 (bookmark-alist): Move defvar before first use.
Richard M. Stallman <rms@gnu.org>
parents: 4633
diff changeset
221 (defvar bookmark-alist ()
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
222 "Association list of bookmarks and their records.
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
223 Bookmark functions update the value automatically.
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
224 You probably do NOT want to change the value yourself.
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
225
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
226 The value is an alist with entries of the form
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
227
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
228 (BOOKMARK-NAME . PARAM-ALIST)
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
229
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
230 or the deprecated form (BOOKMARK-NAME PARAM-ALIST).
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
231
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
232 BOOKMARK-NAME is the name you gave to the bookmark when creating it.
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
233
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
234 PARAM-ALIST is an alist of bookmark information. The order of the
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
235 entries in PARAM-ALIST is not important. The possible entries are
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
236 described below. An entry with a key but null value means the entry
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
237 is not used.
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
238
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
239 (filename . FILENAME)
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
240 (position . POS)
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
241 (front-context-string . STR-AFTER-POS)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
242 (rear-context-string . STR-BEFORE-POS)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
243 (handler . HANDLER)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
244 (annotation . ANNOTATION)
105444
51af2a71a0d6 (bookmark-alist): Document the new `handler' element in the param alist.
Karl Fogel <kfogel@red-bean.com>
parents: 105372
diff changeset
245
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
246 FILENAME names the bookmarked file.
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
247 POS is the bookmarked buffer position (position in the file).
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
248 STR-AFTER-POS is buffer text that immediately follows POS.
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
249 STR-BEFORE-POS is buffer text that immediately precedes POS.
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
250 ANNOTATION is a string that describes the bookmark.
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
251 See options `bookmark-use-annotations' and
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
252 `bookmark-automatically-show-annotations'.
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
253 HANDLER is a function that provides the bookmark-jump behavior for a
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
254 specific kind of bookmark. This is the case for Info bookmarks,
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
255 for instance. HANDLER must accept a bookmark as argument.")
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
256
105540
fbc5ad35e97d * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105533
diff changeset
257 (defvar bookmarks-already-loaded nil
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
258 "Non-nil if and only if bookmarks have been loaded from `bookmark-default-file'.")
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
259
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
260
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 ;; 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
262
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
263 (defvar bookmark-current-bookmark nil
4633
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
264 "Name of bookmark most recently used in the current file.
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
265 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
266 through a file easier.")
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 (make-variable-buffer-local 'bookmark-current-bookmark)
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
270
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (defvar bookmark-alist-modification-count 0
4633
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
272 "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
273
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
274
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
275 (defvar bookmark-search-size 16
4633
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
276 "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
277
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
278
105540
fbc5ad35e97d * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105533
diff changeset
279 (defvar bookmark-current-buffer nil
fbc5ad35e97d * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105533
diff changeset
280 "The buffer in which a bookmark is currently being set or renamed.
fbc5ad35e97d * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105533
diff changeset
281 Functions that insert strings into the minibuffer use this to know
fbc5ad35e97d * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105533
diff changeset
282 the source buffer for that information; see `bookmark-yank-word' and
fbc5ad35e97d * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105533
diff changeset
283 `bookmark-insert-current-bookmark' for example.")
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284
105540
fbc5ad35e97d * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105533
diff changeset
285
fbc5ad35e97d * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105533
diff changeset
286 (defvar bookmark-yank-point 0
fbc5ad35e97d * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105533
diff changeset
287 "The next point from which to pull source text for `bookmark-yank-word'.
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
288 This point is in `bookmark-current-buffer'.")
105540
fbc5ad35e97d * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105533
diff changeset
289
fbc5ad35e97d * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105533
diff changeset
290
106166
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
291 (defvar bookmark-quit-flag nil
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
292 "Non nil make `bookmark-bmenu-search' quit immediately.")
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
293
106710
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
294 ;; Helper functions and macros.
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
295
106710
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
296 (defmacro with-buffer-modified-unmodified (&rest body)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
297 "Run BODY while preserving the buffer's `buffer-modified-p' state."
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
298 (let ((was-modified (make-symbol "was-modified")))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
299 `(let ((,was-modified (buffer-modified-p)))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
300 (unwind-protect
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
301 (progn ,@body)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
302 (set-buffer-modified-p ,was-modified)))))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
303
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
304 ;; Only functions below, in this page and the next one (file formats),
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
305 ;; need to know anything about the format of bookmark-alist entries.
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
306 ;; Everyone else should go through them.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
307
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
308 (defun bookmark-name-from-full-record (full-record)
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
309 "Return name of FULL-RECORD (an alist element instead of a string)."
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
310 (car full-record))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
311
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
312
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
313 (defun bookmark-all-names ()
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
314 "Return a list of all current bookmark names."
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
315 (bookmark-maybe-load-default-file)
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
316 (mapcar 'bookmark-name-from-full-record bookmark-alist))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
317
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
318
99774
b53beb0ef91c (bookmark-get-bookmark): Add `noerror' arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99773
diff changeset
319 (defun bookmark-get-bookmark (bookmark &optional noerror)
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
320 "Return the bookmark record corresponding to BOOKMARK.
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
321 If BOOKMARK is a string, look for the corresponding bookmark record in
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
322 `bookmark-alist'; return it if found, otherwise error. Else if
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
323 BOOKMARK is already a bookmark record, just return it."
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
324 (cond
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
325 ((consp bookmark) bookmark)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
326 ((stringp bookmark)
99774
b53beb0ef91c (bookmark-get-bookmark): Add `noerror' arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99773
diff changeset
327 (or (assoc-string bookmark bookmark-alist bookmark-completion-ignore-case)
b53beb0ef91c (bookmark-get-bookmark): Add `noerror' arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99773
diff changeset
328 (unless noerror (error "Invalid bookmark %s" bookmark))))))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
329
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
330
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
331 (defun bookmark-get-bookmark-record (bookmark)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
332 "Return the record portion of the entry for BOOKMARK in
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
333 `bookmark-alist' (that is, all information but the name).
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
334 BOOKMARK may be a bookmark name (a string) or a bookmark record."
99774
b53beb0ef91c (bookmark-get-bookmark): Add `noerror' arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99773
diff changeset
335 (let ((alist (cdr (bookmark-get-bookmark bookmark))))
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
336 ;; The bookmark objects can either look like (NAME ALIST) or
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
337 ;; (NAME . ALIST), so we have to distinguish the two here.
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
338 (if (and (null (cdr alist)) (consp (caar alist)))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
339 (car alist) alist)))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
340
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
341
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
342 (defun bookmark-set-name (bookmark newname)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
343 "Set BOOKMARK's name to NEWNAME.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
344 BOOKMARK may be a bookmark name (a string) or a bookmark record."
19472
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
345 (setcar
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
346 (if (stringp bookmark) (bookmark-get-bookmark bookmark) bookmark)
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
347 newname))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
348
92661
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
349 (defun bookmark-prop-get (bookmark prop)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
350 "Return the property PROP of BOOKMARK, or nil if none.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
351 BOOKMARK may be a bookmark name (a string) or a bookmark record."
92661
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
352 (cdr (assq prop (bookmark-get-bookmark-record bookmark))))
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
353
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
354 (defun bookmark-prop-set (bookmark prop val)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
355 "Set the property PROP of BOOKMARK to VAL.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
356 BOOKMARK may be a bookmark name (a string) or a bookmark record."
92661
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
357 (let ((cell (assq prop (bookmark-get-bookmark-record bookmark))))
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
358 (if cell
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
359 (setcdr cell val)
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
360 (nconc (bookmark-get-bookmark-record bookmark)
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
361 (list (cons prop val))))))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
362
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
363 (defun bookmark-get-annotation (bookmark)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
364 "Return the annotation of BOOKMARK, or nil if none.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
365 BOOKMARK may be a bookmark name (a string) or a bookmark record."
92661
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
366 (bookmark-prop-get bookmark 'annotation))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
367
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
368 (defun bookmark-set-annotation (bookmark ann)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
369 "Set the annotation of BOOKMARK to ANN.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
370 BOOKMARK may be a bookmark name (a string) or a bookmark record."
92661
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
371 (bookmark-prop-set bookmark 'annotation ann))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
372
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
373
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
374 (defun bookmark-get-filename (bookmark)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
375 "Return the full filename of BOOKMARK, or nil if none.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
376 BOOKMARK may be a bookmark name (a string) or a bookmark record."
92661
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
377 (bookmark-prop-get bookmark 'filename))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
378
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
379
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
380 (defun bookmark-set-filename (bookmark filename)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
381 "Set the full filename of BOOKMARK to FILENAME.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
382 BOOKMARK may be a bookmark name (a string) or a bookmark record."
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
383 (bookmark-prop-set bookmark 'filename filename))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
384
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
385
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
386 (defun bookmark-get-position (bookmark)
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
387 "Return the position (i.e.: point) of BOOKMARK, or nil if none.
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
388 BOOKMARK may be a bookmark name (a string) or a bookmark record."
92661
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
389 (bookmark-prop-get bookmark 'position))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
390
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
391
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
392 (defun bookmark-set-position (bookmark position)
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
393 "Set the position (i.e.: point) of BOOKMARK to POSITION.
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
394 BOOKMARK may be a bookmark name (a string) or a bookmark record."
92661
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
395 (bookmark-prop-set bookmark 'position position))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
396
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
397
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
398 (defun bookmark-get-front-context-string (bookmark)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
399 "Return the front-context-string of BOOKMARK, or nil if none.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
400 BOOKMARK may be a bookmark name (a string) or a bookmark record."
92661
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
401 (bookmark-prop-get bookmark 'front-context-string))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
402
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
403
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
404 (defun bookmark-set-front-context-string (bookmark string)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
405 "Set the front-context-string of BOOKMARK to STRING.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
406 BOOKMARK may be a bookmark name (a string) or a bookmark record."
92661
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
407 (bookmark-prop-set bookmark 'front-context-string string))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
408
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
409
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
410 (defun bookmark-get-rear-context-string (bookmark)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
411 "Return the rear-context-string of BOOKMARK, or nil if none.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
412 BOOKMARK may be a bookmark name (a string) or a bookmark record."
92661
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
413 (bookmark-prop-get bookmark 'rear-context-string))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
414
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
415
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
416 (defun bookmark-set-rear-context-string (bookmark string)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
417 "Set the rear-context-string of BOOKMARK to STRING.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
418 BOOKMARK may be a bookmark name (a string) or a bookmark record."
92661
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
419 (bookmark-prop-set bookmark 'rear-context-string string))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
420
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
421
87411
9ac481bc897b 2007-12-26 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 84858
diff changeset
422 (defun bookmark-get-handler (bookmark)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
423 "Return the handler function for BOOKMARK, or nil if none.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
424 BOOKMARK may be a bookmark name (a string) or a bookmark record."
92661
c8674d7009d4 * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92568
diff changeset
425 (bookmark-prop-get bookmark 'handler))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
426
10994
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
427 (defvar bookmark-history nil
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
428 "The history list for bookmark functions.")
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
429
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
430
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
431 (defun bookmark-completing-read (prompt &optional default)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
432 "Prompting with PROMPT, read a bookmark name in completion.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
433 PROMPT will get a \": \" stuck on the end no matter what, so you
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
434 probably don't want to include one yourself.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
435 Optional second arg DEFAULT is a string to return if the user enters
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
436 the empty string."
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
437 (bookmark-maybe-load-default-file) ; paranoia
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
438 (if (listp last-nonmenu-event)
105920
0a019b48e945 * bookmark.el (bookmark-completing-read): Sort bookmark names if
Chong Yidong <cyd@stupidchicken.com>
parents: 105787
diff changeset
439 (bookmark-menu-popup-paned-menu t prompt
0a019b48e945 * bookmark.el (bookmark-completing-read): Sort bookmark names if
Chong Yidong <cyd@stupidchicken.com>
parents: 105787
diff changeset
440 (if bookmark-sort-flag
0a019b48e945 * bookmark.el (bookmark-completing-read): Sort bookmark names if
Chong Yidong <cyd@stupidchicken.com>
parents: 105787
diff changeset
441 (sort (bookmark-all-names)
0a019b48e945 * bookmark.el (bookmark-completing-read): Sort bookmark names if
Chong Yidong <cyd@stupidchicken.com>
parents: 105787
diff changeset
442 'string-lessp)
0a019b48e945 * bookmark.el (bookmark-completing-read): Sort bookmark names if
Chong Yidong <cyd@stupidchicken.com>
parents: 105787
diff changeset
443 (bookmark-all-names)))
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
444 (let* ((completion-ignore-case bookmark-completion-ignore-case)
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
445 (default default)
105787
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
446 (prompt (concat prompt (if default
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
447 (format " (%s): " default)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
448 ": ")))
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
449 (str
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
450 (completing-read prompt
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
451 bookmark-alist
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
452 nil
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
453 0
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
454 nil
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
455 'bookmark-history)))
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
456 (if (string-equal "" str) default str))))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
457
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
458
10994
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
459 (defmacro bookmark-maybe-historicize-string (string)
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
460 "Put STRING into the bookmark prompt history, if caller non-interactive.
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
461 We need this because sometimes bookmark functions are invoked from
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
462 menus, so `completing-read' never gets a chance to set `bookmark-history'."
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
463 `(or
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 105124
diff changeset
464 (called-interactively-p 'interactive)
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
465 (setq bookmark-history (cons ,string bookmark-history))))
10994
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
466
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
467 (defvar bookmark-make-record-function 'bookmark-make-record-default
92556
5944be8c8211 Change a return type, for greater extensibility. See
Karl Fogel <kfogel@red-bean.com>
parents: 92550
diff changeset
468 "A function that should be called to create a bookmark record.
5944be8c8211 Change a return type, for greater extensibility. See
Karl Fogel <kfogel@red-bean.com>
parents: 92550
diff changeset
469 Modes may set this variable buffer-locally to enable bookmarking of
5944be8c8211 Change a return type, for greater extensibility. See
Karl Fogel <kfogel@red-bean.com>
parents: 92550
diff changeset
470 locations that should be treated specially, such as Info nodes,
5944be8c8211 Change a return type, for greater extensibility. See
Karl Fogel <kfogel@red-bean.com>
parents: 92550
diff changeset
471 news posts, images, pdf documents, etc.
87411
9ac481bc897b 2007-12-26 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 84858
diff changeset
472
92674
ac3c6c3e119c * bookmark.el (bookmark-make): Don't pass the `annotation' to the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92661
diff changeset
473 The function will be called with no arguments.
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
474 It should signal a user error if it is unable to construct a record for
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
475 the current location.
92690
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
476
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
477 The returned record should be a cons cell of the form (NAME . ALIST)
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
478 where ALIST is as described in `bookmark-alist' and may typically contain
105444
51af2a71a0d6 (bookmark-alist): Document the new `handler' element in the param alist.
Karl Fogel <kfogel@red-bean.com>
parents: 105372
diff changeset
479 a special cons (handler . HANDLER-FUNC) which specifies the handler function
51af2a71a0d6 (bookmark-alist): Document the new `handler' element in the param alist.
Karl Fogel <kfogel@red-bean.com>
parents: 105372
diff changeset
480 that should be used instead of `bookmark-default-handler' to open this
51af2a71a0d6 (bookmark-alist): Document the new `handler' element in the param alist.
Karl Fogel <kfogel@red-bean.com>
parents: 105372
diff changeset
481 bookmark. See the documentation for `bookmark-alist' for more.
92690
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
482
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
483 NAME is a suggested name for the constructed bookmark. It can be nil
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
484 in which case a default heuristic will be used. The function can also
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
485 equivalently just return ALIST without NAME.")
10994
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
486
92690
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
487 (defun bookmark-make-record ()
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
488 "Return a new bookmark record (NAME . ALIST) for the current location."
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
489 (let ((record (funcall bookmark-make-record-function)))
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
490 ;; Set up default name.
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
491 (if (stringp (car record))
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
492 ;; The function already provided a default name.
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
493 record
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
494 (if (car record) (push nil record))
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
495 (setcar record (or bookmark-current-bookmark (bookmark-buffer-name)))
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
496 record)))
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
497
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
498 (defun bookmark-store (name alist no-overwrite)
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
499 "Store the bookmark NAME with data ALIST.
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
500 If NO-OVERWRITE is non-nil and another bookmark of the same name already
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
501 exists in `bookmark-alist', record the new bookmark without throwing away the
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
502 old one."
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
503 (bookmark-maybe-load-default-file)
12569
1297698116a8 (bookmark-make): Strip text properties off name.
Karl Heuer <kwzh@gnu.org>
parents: 12310
diff changeset
504 (let ((stripped-name (copy-sequence name)))
84777
68033fec6867 (bookmark-xemacsp): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82140
diff changeset
505 (or (featurep 'xemacs)
13895
0c12b3398d37 Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
parents: 12880
diff changeset
506 ;; XEmacs's `set-text-properties' doesn't work on
0c12b3398d37 Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
parents: 12880
diff changeset
507 ;; free-standing strings, apparently.
0c12b3398d37 Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
parents: 12880
diff changeset
508 (set-text-properties 0 (length stripped-name) nil stripped-name))
99774
b53beb0ef91c (bookmark-get-bookmark): Add `noerror' arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99773
diff changeset
509 (if (and (not no-overwrite)
b53beb0ef91c (bookmark-get-bookmark): Add `noerror' arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99773
diff changeset
510 (bookmark-get-bookmark stripped-name 'noerror))
13969
8fd836e88aec (bookmark-save-flag, bookmark-read-annotation-text-func,
Karl Heuer <kwzh@gnu.org>
parents: 13895
diff changeset
511 ;; already existing bookmark under that name and
12569
1297698116a8 (bookmark-make): Strip text properties off name.
Karl Heuer <kwzh@gnu.org>
parents: 12310
diff changeset
512 ;; no prefix arg means just overwrite old bookmark
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
513 ;; Use the new (NAME . ALIST) format.
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
514 (setcdr (bookmark-get-bookmark stripped-name) alist)
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
515
12569
1297698116a8 (bookmark-make): Strip text properties off name.
Karl Heuer <kwzh@gnu.org>
parents: 12310
diff changeset
516 ;; otherwise just cons it onto the front (either the bookmark
1297698116a8 (bookmark-make): Strip text properties off name.
Karl Heuer <kwzh@gnu.org>
parents: 12310
diff changeset
517 ;; doesn't exist already, or there is no prefix arg. In either
1297698116a8 (bookmark-make): Strip text properties off name.
Karl Heuer <kwzh@gnu.org>
parents: 12310
diff changeset
518 ;; case, we want the new bookmark consed onto the alist...)
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
519
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
520 (push (cons stripped-name alist) bookmark-alist))
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
521
12569
1297698116a8 (bookmark-make): Strip text properties off name.
Karl Heuer <kwzh@gnu.org>
parents: 12310
diff changeset
522 ;; Added by db
1297698116a8 (bookmark-make): Strip text properties off name.
Karl Heuer <kwzh@gnu.org>
parents: 12310
diff changeset
523 (setq bookmark-current-bookmark stripped-name)
1297698116a8 (bookmark-make): Strip text properties off name.
Karl Heuer <kwzh@gnu.org>
parents: 12310
diff changeset
524 (setq bookmark-alist-modification-count
1297698116a8 (bookmark-make): Strip text properties off name.
Karl Heuer <kwzh@gnu.org>
parents: 12310
diff changeset
525 (1+ bookmark-alist-modification-count))
1297698116a8 (bookmark-make): Strip text properties off name.
Karl Heuer <kwzh@gnu.org>
parents: 12310
diff changeset
526 (if (bookmark-time-to-save-p)
92690
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
527 (bookmark-save))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
528
92690
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
529 (setq bookmark-current-bookmark stripped-name)
ae00481eacc1 * bookmark.el (bookmark-make-record-function): Change expected return value
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92689
diff changeset
530 (bookmark-bmenu-surreptitiously-rebuild-list)))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
531
109395
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
532 (defun bookmark-make-record-default (&optional no-file no-context posn)
92674
ac3c6c3e119c * bookmark.el (bookmark-make): Don't pass the `annotation' to the
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92661
diff changeset
533 "Return the record describing the location of a new bookmark.
109395
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
534 Point should be at the buffer in which the bookmark is being set,
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
535 and normally should be at the position where the bookmark is desired,
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
536 but see the optional arguments for other possibilities.
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
537
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
538 If NO-FILE is non-nil, then only return the subset of the
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
539 record that pertains to the location within the buffer, leaving off
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
540 the part that records the filename.
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
541
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
542 If NO-CONTEXT is non-nil, do not include the front- and rear-context
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
543 strings in the record -- the position is enough.
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
544
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
545 If POSN is non-nil, record POSN as the point instead of `(point)'."
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
546 `(,@(unless no-file `((filename . ,(bookmark-buffer-file-name))))
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
547 ,@(unless no-context `((front-context-string
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
548 . ,(if (>= (- (point-max) (point))
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
549 bookmark-search-size)
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
550 (buffer-substring-no-properties
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
551 (point)
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
552 (+ (point) bookmark-search-size))
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
553 nil))))
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
554 ,@(unless no-context `((rear-context-string
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
555 . ,(if (>= (- (point) (point-min))
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
556 bookmark-search-size)
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
557 (buffer-substring-no-properties
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
558 (point)
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
559 (- (point) bookmark-search-size))
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
560 nil))))
fa4400531412 Preparation for setting bookmarks in Gnus article buffers (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109384
diff changeset
561 (position . ,(or posn (point)))))
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
562
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
563
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
564 ;;; File format stuff
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
565
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
566 ;; *IMPORTANT NOTICE* If you are thinking about modifying (redefining)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
567 ;; the bookmark file format -- please don't. The current format
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
568 ;; should be extensible enough. If you feel the need to change it,
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
569 ;; please discuss it with other Emacs developers first.
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
570 ;;
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
571 ;; The format of `bookmark-alist' has changed twice in its lifetime.
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
572 ;; This comment describes the three formats, FIRST, SECOND, and
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
573 ;; CURRENT.
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
574 ;;
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
575 ;; The FIRST format was used prior to Emacs 20:
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
576 ;;
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
577 ;; ((BOOKMARK-NAME (FILENAME
93705
442e2ad714cd Minor docstring a comment improvements.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92789
diff changeset
578 ;; STRING-IN-FRONT
442e2ad714cd Minor docstring a comment improvements.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92789
diff changeset
579 ;; STRING-BEHIND
442e2ad714cd Minor docstring a comment improvements.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92789
diff changeset
580 ;; POINT))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
581 ;; ...)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
582 ;;
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
583 ;; The SECOND format was introduced in Emacs 20:
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
584 ;;
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
585 ;; ((BOOKMARK-NAME ((filename . FILENAME)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
586 ;; (position . POS)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
587 ;; (front-context-string . STR-AFTER-POS)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
588 ;; (rear-context-string . STR-BEFORE-POS)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
589 ;; (annotation . ANNOTATION)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
590 ;; (whatever . VALUE)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
591 ;; ...
93705
442e2ad714cd Minor docstring a comment improvements.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92789
diff changeset
592 ;; ))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
593 ;; ...)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
594 ;;
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
595 ;; The CURRENT format was introduced in Emacs 22:
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
596 ;;
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
597 ;; ((BOOKMARK-NAME (filename . FILENAME)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
598 ;; (position . POS)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
599 ;; (front-context-string . STR-AFTER-POS)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
600 ;; (rear-context-string . STR-BEFORE-POS)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
601 ;; (annotation . ANNOTATION)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
602 ;; (whatever . VALUE)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
603 ;; ...
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
604 ;; )
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
605 ;; ...)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
606 ;;
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
607 ;; Both FIRST and SECOND have the same level of nesting: the cadr of a
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
608 ;; bookmark record is a list of entry information. FIRST and SECOND
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
609 ;; differ in the form of the record information: FIRST uses a list of
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
610 ;; atoms, and SECOND uses an alist. In the FIRST format, the order of
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
611 ;; the list elements matters. In the SECOND format, the order of the
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
612 ;; alist elements is unimportant. The SECOND format facilitates the
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
613 ;; addition of new kinds of elements, to support new kinds of
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
614 ;; bookmarks or code evolution.
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
615 ;;
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
616 ;; The CURRENT format removes a level of nesting wrt FIRST and SECOND,
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
617 ;; saving one cons cell per bookmark: the cadr of a bookmark record is
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
618 ;; no longer a cons. Why that change was made remains a mystery --
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
619 ;; just be aware of it. (Be aware too that this explanatory comment
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
620 ;; was incorrect in Emacs 22 and Emacs 23.1.)
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
621 ;;
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
622 ;; To deal with the change from FIRST format to SECOND, conversion
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
623 ;; code was added, and it is still in use. See
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
624 ;; `bookmark-maybe-upgrade-file-format'.
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
625 ;;
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
626 ;; No conversion from SECOND to CURRENT is done. Instead, the code
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
627 ;; handles both formats OK. It must continue to do so.
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
628 ;;
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
629 ;; See the doc string of `bookmark-alist' for information about the
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
630 ;; elements that define a bookmark (e.g. `filename').
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
631
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
632
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
633 (defconst bookmark-file-format-version 1
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
634 "The current version of the format used by bookmark files.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
635 You should never need to change this.")
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
636
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
637
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
638 (defconst bookmark-end-of-version-stamp-marker
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
639 "-*- End Of Bookmark File Format Version Stamp -*-\n"
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
640 "This string marks the end of the version stamp in a bookmark file.")
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
641
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
642
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
643 (defun bookmark-alist-from-buffer ()
64634
4045a1b1a5c9 (bookmark-automatically-show-annotations, bookmark-read-annotation-text-func): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
644 "Return a `bookmark-alist' (in any format) from the current buffer.
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
645 The buffer must of course contain bookmark format information.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
646 Does not care from where in the buffer it is called, and does not
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
647 affect point."
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
648 (save-excursion
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
649 (goto-char (point-min))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
650 (if (search-forward bookmark-end-of-version-stamp-marker nil t)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
651 (read (current-buffer))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
652 ;; Else we're dealing with format version 0
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
653 (if (search-forward "(" nil t)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
654 (progn
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
655 (forward-char -1)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
656 (read (current-buffer)))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
657 ;; Else no hope of getting information here.
14354
f1035d934a7a (bookmark-alist-from-buffer): Fix error text.
Karl Heuer <kwzh@gnu.org>
parents: 14339
diff changeset
658 (error "Not bookmark format")))))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
659
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
660
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
661 (defun bookmark-upgrade-version-0-alist (old-list)
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
662 "Upgrade a version 0 alist OLD-LIST to the current version."
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
663 (mapcar
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
664 (lambda (bookmark)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
665 (let* ((name (car bookmark))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
666 (record (car (cdr bookmark)))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
667 (filename (nth 0 record))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
668 (front-str (nth 1 record))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
669 (rear-str (nth 2 record))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
670 (position (nth 3 record))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
671 (ann (nth 4 record)))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
672 (list
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
673 name
41608
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 39122
diff changeset
674 `((filename . ,filename)
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 39122
diff changeset
675 (front-context-string . ,(or front-str ""))
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 39122
diff changeset
676 (rear-context-string . ,(or rear-str ""))
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 39122
diff changeset
677 (position . ,position)
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 39122
diff changeset
678 (annotation . ,ann)))))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
679 old-list))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
680
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
681
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
682 (defun bookmark-upgrade-file-format-from-0 ()
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
683 "Upgrade a bookmark file of format 0 (the original format) to format 1.
64634
4045a1b1a5c9 (bookmark-automatically-show-annotations, bookmark-read-annotation-text-func): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
684 This expects to be called from `point-min' in a bookmark file."
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
685 (message "Upgrading bookmark format from 0 to %d..."
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
686 bookmark-file-format-version)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
687 (let* ((old-list (bookmark-alist-from-buffer))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
688 (new-list (bookmark-upgrade-version-0-alist old-list)))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
689 (delete-region (point-min) (point-max))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
690 (bookmark-insert-file-format-version-stamp)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
691 (pp new-list (current-buffer))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
692 (save-buffer))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
693 (goto-char (point-min))
14039
831c5fda97f4 "cyclic.com" addresses changed to "red-bean.com".
Karl Fogel <kfogel@red-bean.com>
parents: 13969
diff changeset
694 (message "Upgrading bookmark format from 0 to %d...done"
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
695 bookmark-file-format-version)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
696 )
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
697
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
698
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
699 (defun bookmark-grok-file-format-version ()
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
700 "Return an integer which is the file-format version of this bookmark file.
64634
4045a1b1a5c9 (bookmark-automatically-show-annotations, bookmark-read-annotation-text-func): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
701 This expects to be called from `point-min' in a bookmark file."
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
702 (if (looking-at "^;;;;")
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
703 (save-excursion
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
704 (save-match-data
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
705 (re-search-forward "[0-9]")
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
706 (forward-char -1)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
707 (read (current-buffer))))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
708 ;; Else this is format version 0, the original one, which didn't
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
709 ;; even have version stamps.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
710 0))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
711
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
712
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
713 (defun bookmark-maybe-upgrade-file-format ()
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
714 "Check the file-format version of this bookmark file.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
715 If the version is not up-to-date, upgrade it automatically.
64634
4045a1b1a5c9 (bookmark-automatically-show-annotations, bookmark-read-annotation-text-func): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
716 This expects to be called from `point-min' in a bookmark file."
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
717 (let ((version (bookmark-grok-file-format-version)))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
718 (cond
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
719 ((= version bookmark-file-format-version)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
720 ) ; home free -- version is current
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
721 ((= version 0)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
722 (bookmark-upgrade-file-format-from-0))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
723 (t
14354
f1035d934a7a (bookmark-alist-from-buffer): Fix error text.
Karl Heuer <kwzh@gnu.org>
parents: 14339
diff changeset
724 (error "Bookmark file format version strangeness")))))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
725
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
726
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
727 (defun bookmark-insert-file-format-version-stamp ()
15193
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
728 "Insert text indicating current version of bookmark file format."
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
729 (insert
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
730 (format ";;;; Emacs Bookmark Format Version %d ;;;;\n"
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
731 bookmark-file-format-version))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
732 (insert ";;; This format is meant to be slightly human-readable;\n"
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
733 ";;; nevertheless, you probably don't want to edit it.\n"
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
734 ";;; "
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
735 bookmark-end-of-version-stamp-marker))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
736
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
737
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
738 ;;; end file-format stuff
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
739
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
740
66835
96e7147004a8 * bookmark.el (bookmark-maybe-message): New function to reduce code
Karl Fogel <kfogel@red-bean.com>
parents: 66834
diff changeset
741 ;;; Generic helpers.
96e7147004a8 * bookmark.el (bookmark-maybe-message): New function to reduce code
Karl Fogel <kfogel@red-bean.com>
parents: 66834
diff changeset
742
96e7147004a8 * bookmark.el (bookmark-maybe-message): New function to reduce code
Karl Fogel <kfogel@red-bean.com>
parents: 66834
diff changeset
743 (defun bookmark-maybe-message (fmt &rest args)
96e7147004a8 * bookmark.el (bookmark-maybe-message): New function to reduce code
Karl Fogel <kfogel@red-bean.com>
parents: 66834
diff changeset
744 "Apply `message' to FMT and ARGS, but only if the display is fast enough."
96e7147004a8 * bookmark.el (bookmark-maybe-message): New function to reduce code
Karl Fogel <kfogel@red-bean.com>
parents: 66834
diff changeset
745 (if (>= baud-rate 9600)
96e7147004a8 * bookmark.el (bookmark-maybe-message): New function to reduce code
Karl Fogel <kfogel@red-bean.com>
parents: 66834
diff changeset
746 (apply 'message fmt args)))
96e7147004a8 * bookmark.el (bookmark-maybe-message): New function to reduce code
Karl Fogel <kfogel@red-bean.com>
parents: 66834
diff changeset
747
96e7147004a8 * bookmark.el (bookmark-maybe-message): New function to reduce code
Karl Fogel <kfogel@red-bean.com>
parents: 66834
diff changeset
748
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
749 ;;; Core code:
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
750
92688
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
751 (defvar bookmark-minibuffer-read-name-map
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
752 (let ((map (make-sparse-keymap)))
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
753 (set-keymap-parent map minibuffer-local-map)
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
754 (define-key map "\C-w" 'bookmark-yank-word)
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
755 ;; This C-u binding might not be very useful any more now that we
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
756 ;; provide access to the default via the standard M-n binding.
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
757 ;; Maybe we should just remove it? --Stef-08
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
758 (define-key map "\C-u" 'bookmark-insert-current-bookmark)
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
759 map))
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
760
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
761 ;;;###autoload
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
762 (defun bookmark-set (&optional name no-overwrite)
105446
0532c364480a * bookmark.el (bookmark-set, bookmark-buffer-name): Improve doc strings.
Karl Fogel <kfogel@red-bean.com>
parents: 105445
diff changeset
763 "Set a bookmark named NAME at the current location.
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
764 If name is nil, then prompt the user.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
765
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
766 With a prefix arg (non-nil NO-OVERWRITE), do not overwrite any
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
767 existing bookmark that has the same name as NAME, but instead push the
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
768 new bookmark onto the bookmark alist. The most recently set bookmark
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
769 with name NAME is thus the one in effect at any given time, but the
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
770 others are still there, should the user decide to delete the most
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
771 recent one.
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 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
774 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
775 yank successive words.
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
777 Typing C-u inserts (at the bookmark name prompt) the name of the last
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
778 bookmark used in the document where the new bookmark is being set;
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
779 this helps you use a single bookmark name to track progress through a
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
780 large document. If there is no prior bookmark for this document, then
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
781 C-u inserts an appropriate name based on the buffer or file.
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
783 Use \\[bookmark-delete] to remove bookmarks (you give it a name and
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
784 it removes only the first instance of a bookmark with that name from
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
785 the list of bookmarks.)"
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
786 (interactive (list nil current-prefix-arg))
109397
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
787 (unwind-protect
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
788 (let* ((record (bookmark-make-record))
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
789 (default (car record)))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
790
109397
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
791 (bookmark-maybe-load-default-file)
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
792 ;; Don't set `bookmark-yank-point' and `bookmark-current-buffer'
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
793 ;; if they have been already set in another buffer. (e.g gnus-art).
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
794 (unless (and bookmark-yank-point
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
795 bookmark-current-buffer)
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
796 (setq bookmark-yank-point (point))
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
797 (setq bookmark-current-buffer (current-buffer)))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
798
109397
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
799 (let ((str
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
800 (or name
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
801 (read-from-minibuffer
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
802 (format "Set bookmark (%s): " default)
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
803 nil
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
804 bookmark-minibuffer-read-name-map
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
805 nil nil default))))
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
806 (and (string-equal str "") (setq str default))
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
807 (bookmark-store str (cdr record) no-overwrite)
99766
f1062fe6487f * bookmark.el (bookmark-jump-noselect): Add obsolescence declaration
Juanma Barranquero <lekktu@gmail.com>
parents: 99725
diff changeset
808
109397
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
809 ;; Ask for an annotation buffer for this bookmark
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
810 (when bookmark-use-annotations
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
811 (bookmark-edit-annotation str))))
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
812 (setq bookmark-yank-point nil)
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
813 (setq bookmark-current-buffer nil)))
4e6b8160da4b Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
Karl Fogel <kfogel@red-bean.com>
parents: 109395
diff changeset
814
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
815
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
816 (defun bookmark-kill-line (&optional newline-too)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
817 "Kill from point to end of line.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
818 If optional arg NEWLINE-TOO is non-nil, delete the newline too.
64634
4045a1b1a5c9 (bookmark-automatically-show-annotations, bookmark-read-annotation-text-func): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
819 Does not affect the kill ring."
111429
249a1455856a Use line-end-position rather than end-of-line, etc.
Glenn Morris <rgm@gnu.org>
parents: 109399
diff changeset
820 (let ((eol (line-end-position)))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
821 (delete-region (point) eol)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
822 (if (and newline-too (looking-at "\n"))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
823 (delete-char 1))))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
824
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
825
10994
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
826 ;; Defvars to avoid compilation warnings:
92689
570c098b116d (bookmark-set): Make the bookmark before reading annotations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92688
diff changeset
827 (defvar bookmark-annotation-name nil
570c098b116d (bookmark-set): Make the bookmark before reading annotations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92688
diff changeset
828 "Variable holding the name of the bookmark.
570c098b116d (bookmark-set): Make the bookmark before reading annotations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92688
diff changeset
829 This is used in `bookmark-edit-annotation' to record the bookmark
570c098b116d (bookmark-set): Make the bookmark before reading annotations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92688
diff changeset
830 whose annotation is being edited.")
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
831
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
832
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
833 (defun bookmark-default-annotation-text (bookmark)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
834 "Return default annotation text for BOOKMARK (a string, not a record).
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
835 The default annotation text is simply some text explaining how to use
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
836 annotations."
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
837 (concat "# Type the annotation for bookmark '" bookmark "' here.\n"
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
838 "# All lines which start with a '#' will be deleted.\n"
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
839 "# Type C-c C-c when done.\n#\n"
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
840 "# Author: " (user-full-name) " <" (user-login-name) "@"
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
841 (system-name) ">\n"
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
842 "# Date: " (current-time-string) "\n"))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
843
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
844
92689
570c098b116d (bookmark-set): Make the bookmark before reading annotations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92688
diff changeset
845 (defvar bookmark-edit-annotation-text-func 'bookmark-default-annotation-text
15193
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
846 "Function to return default text to use for a bookmark annotation.
64634
4045a1b1a5c9 (bookmark-automatically-show-annotations, bookmark-read-annotation-text-func): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
847 It takes one argument, the name of the bookmark, as a string.")
92689
570c098b116d (bookmark-set): Make the bookmark before reading annotations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92688
diff changeset
848 (define-obsolete-variable-alias 'bookmark-read-annotation-text-func
570c098b116d (bookmark-set): Make the bookmark before reading annotations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92688
diff changeset
849 'bookmark-edit-annotation-text-func "23.1")
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
850
92689
570c098b116d (bookmark-set): Make the bookmark before reading annotations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92688
diff changeset
851 (defvar bookmark-edit-annotation-mode-map
570c098b116d (bookmark-set): Make the bookmark before reading annotations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92688
diff changeset
852 (let ((map (make-sparse-keymap)))
570c098b116d (bookmark-set): Make the bookmark before reading annotations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92688
diff changeset
853 (set-keymap-parent map text-mode-map)
570c098b116d (bookmark-set): Make the bookmark before reading annotations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92688
diff changeset
854 (define-key map "\C-c\C-c" 'bookmark-send-edited-annotation)
570c098b116d (bookmark-set): Make the bookmark before reading annotations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92688
diff changeset
855 map)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
856 "Keymap for editing an annotation of a bookmark.")
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
857
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
858
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
859 (defun bookmark-edit-annotation-mode (bookmark)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
860 "Mode for editing the annotation of bookmark BOOKMARK.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
861 When you have finished composing, type \\[bookmark-send-annotation].
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
862
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
863 BOOKMARK is a bookmark name (a string) or a bookmark record.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
864
87411
9ac481bc897b 2007-12-26 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 84858
diff changeset
865 \\{bookmark-edit-annotation-mode-map}"
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
866 (interactive)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
867 (kill-all-local-variables)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
868 (make-local-variable 'bookmark-annotation-name)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
869 (setq bookmark-annotation-name bookmark)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
870 (use-local-map bookmark-edit-annotation-mode-map)
54906
dfa3317697a0 (bookmark-send-edited-annotation): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 53398
diff changeset
871 (setq major-mode 'bookmark-edit-annotation-mode
dfa3317697a0 (bookmark-send-edited-annotation): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 53398
diff changeset
872 mode-name "Edit Bookmark Annotation")
92689
570c098b116d (bookmark-set): Make the bookmark before reading annotations.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92688
diff changeset
873 (insert (funcall bookmark-edit-annotation-text-func bookmark))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
874 (let ((annotation (bookmark-get-annotation bookmark)))
19472
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
875 (if (and annotation (not (string-equal annotation "")))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
876 (insert annotation)))
62718
d00be6e651cd (bookmark-read-annotation-mode, bookmark-edit-annotation-mode)
Lute Kamstra <lute@gnu.org>
parents: 61454
diff changeset
877 (run-mode-hooks 'text-mode-hook))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
878
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
879
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
880 (defun bookmark-send-edited-annotation ()
54906
dfa3317697a0 (bookmark-send-edited-annotation): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 53398
diff changeset
881 "Use buffer contents as annotation for a bookmark.
dfa3317697a0 (bookmark-send-edited-annotation): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 53398
diff changeset
882 Lines beginning with `#' are ignored."
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
883 (interactive)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
884 (if (not (eq major-mode 'bookmark-edit-annotation-mode))
14354
f1035d934a7a (bookmark-alist-from-buffer): Fix error text.
Karl Heuer <kwzh@gnu.org>
parents: 14339
diff changeset
885 (error "Not in bookmark-edit-annotation-mode"))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
886 (goto-char (point-min))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
887 (while (< (point) (point-max))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
888 (if (looking-at "^#")
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
889 (bookmark-kill-line t)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
890 (forward-line 1)))
92688
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
891 ;; Take no chances with text properties.
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
892 (let ((annotation (buffer-substring-no-properties (point-min) (point-max)))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
893 (bookmark bookmark-annotation-name))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
894 (bookmark-set-annotation bookmark annotation)
106710
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
895 (setq bookmark-alist-modification-count
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
896 (1+ bookmark-alist-modification-count))
105540
fbc5ad35e97d * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105533
diff changeset
897 (bookmark-bmenu-surreptitiously-rebuild-list))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
898 (kill-buffer (current-buffer)))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
899
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
900
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
901 (defun bookmark-edit-annotation (bookmark)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
902 "Pop up a buffer for editing bookmark BOOKMARK's annotation.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
903 BOOKMARK is a bookmark name (a string) or a bookmark record."
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
904 (pop-to-buffer (generate-new-buffer-name "*Bookmark Annotation Compose*"))
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
905 (bookmark-edit-annotation-mode bookmark))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
906
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
908 (defun bookmark-insert-current-bookmark ()
105541
e2fcb7b1231c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105540
diff changeset
909 "Insert into the bookmark name currently being set the value of
e2fcb7b1231c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105540
diff changeset
910 `bookmark-current-bookmark' in `bookmark-current-buffer', defaulting
e2fcb7b1231c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105540
diff changeset
911 to the buffer's file name if `bookmark-current-bookmark' is nil."
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912 (interactive)
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913 (let ((str
92688
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
914 (with-current-buffer bookmark-current-buffer
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
915 (or bookmark-current-bookmark
0524053618bf Add spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92674
diff changeset
916 (bookmark-buffer-name)))))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
917 (insert str)))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
918
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
919
10960
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
920 (defun bookmark-buffer-name ()
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
921 "Return the name of the current buffer in a form usable as a bookmark name.
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
922 If the buffer is associated with a file or directory, use that name."
10960
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
923 (cond
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
924 ;; Or are we a file?
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
925 (buffer-file-name (file-name-nondirectory buffer-file-name))
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
926 ;; Or are we a directory?
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
927 ((and (boundp 'dired-directory) dired-directory)
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
928 (let* ((dirname (if (stringp dired-directory)
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
929 dired-directory
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
930 (car dired-directory)))
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
931 (idx (1- (length dirname))))
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
932 ;; Strip the trailing slash.
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
933 (if (= ?/ (aref dirname idx))
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
934 (file-name-nondirectory (substring dirname 0 idx))
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
935 ;; Else return the current-buffer
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
936 (buffer-name (current-buffer)))))
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
937 ;; If all else fails, use the buffer's name.
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
938 (t
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
939 (buffer-name (current-buffer)))))
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
940
d6d3905ec550 (bookmark-buffer-name): Be smarter about deducing a name.
Richard M. Stallman <rms@gnu.org>
parents: 10952
diff changeset
941
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
942 (defun bookmark-yank-word ()
105541
e2fcb7b1231c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105540
diff changeset
943 "Get the next word from buffer `bookmark-current-buffer' and append
e2fcb7b1231c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105540
diff changeset
944 it to the name of the bookmark currently being set, advancing
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
945 `bookmark-yank-point' by one word."
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946 (interactive)
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
947 (let ((string (with-current-buffer bookmark-current-buffer
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
948 (goto-char bookmark-yank-point)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
949 (buffer-substring-no-properties
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
950 (point)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
951 (progn
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
952 (forward-word 1)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
953 (setq bookmark-yank-point (point)))))))
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954 (insert string)))
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 (defun bookmark-buffer-file-name ()
92789
61c661dac856 (Info-current-node): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92690
diff changeset
957 "Return the current buffer's file in a way useful for bookmarks."
99773
0bb446839781 (bookmark-buffer-file-name): Also abbreviate dired-dir.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99766
diff changeset
958 ;; Abbreviate the path, both so it's shorter and so it's more
0bb446839781 (bookmark-buffer-file-name): Also abbreviate dired-dir.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99766
diff changeset
959 ;; portable. E.g., the user's home dir might be a different
0bb446839781 (bookmark-buffer-file-name): Also abbreviate dired-dir.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99766
diff changeset
960 ;; path on different machines, but "~/" will still reach it.
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 99774
diff changeset
961 (abbreviate-file-name
99773
0bb446839781 (bookmark-buffer-file-name): Also abbreviate dired-dir.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99766
diff changeset
962 (cond
0bb446839781 (bookmark-buffer-file-name): Also abbreviate dired-dir.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99766
diff changeset
963 (buffer-file-name buffer-file-name)
0bb446839781 (bookmark-buffer-file-name): Also abbreviate dired-dir.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99766
diff changeset
964 ((and (boundp 'dired-directory) dired-directory)
0bb446839781 (bookmark-buffer-file-name): Also abbreviate dired-dir.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99766
diff changeset
965 (if (stringp dired-directory)
0bb446839781 (bookmark-buffer-file-name): Also abbreviate dired-dir.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99766
diff changeset
966 dired-directory
0bb446839781 (bookmark-buffer-file-name): Also abbreviate dired-dir.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99766
diff changeset
967 (car dired-directory)))
0bb446839781 (bookmark-buffer-file-name): Also abbreviate dired-dir.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99766
diff changeset
968 (t (error "Buffer not visiting a file or directory")))))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
969
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
970
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
971 (defun bookmark-maybe-load-default-file ()
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
972 "If bookmarks have not been loaded from the default place, load them."
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
973 (and (not bookmarks-already-loaded)
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
974 (null bookmark-alist)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
975 (prog2
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
976 (and
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
977 ;; Possibly the old bookmark file, "~/.emacs-bkmrks", needs
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
978 ;; to be renamed.
107192
3c9f81253d07 Use abbreviated file names in bookmarks (bug#5591).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107125
diff changeset
979 (file-exists-p bookmark-old-default-file)
3c9f81253d07 Use abbreviated file names in bookmarks (bug#5591).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107125
diff changeset
980 (not (file-exists-p bookmark-default-file))
3c9f81253d07 Use abbreviated file names in bookmarks (bug#5591).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107125
diff changeset
981 (rename-file bookmark-old-default-file
3c9f81253d07 Use abbreviated file names in bookmarks (bug#5591).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107125
diff changeset
982 bookmark-default-file))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
983 ;; return t so the `and' will continue...
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
984 t)
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
985
107192
3c9f81253d07 Use abbreviated file names in bookmarks (bug#5591).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107125
diff changeset
986 (file-readable-p bookmark-default-file)
19472
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
987 (bookmark-load bookmark-default-file t t)
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
988 (setq bookmarks-already-loaded t)))
4631
fc781d29fd48 New version from Fogel.
Richard M. Stallman <rms@gnu.org>
parents: 4595
diff changeset
989
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
990
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
991 (defun bookmark-maybe-sort-alist ()
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
992 "Return `bookmark-alist' for display.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
993 If `bookmark-sort-flag' is non-nil, then return a sorted copy of the alist."
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
994 (if bookmark-sort-flag
78160
ba35decf8cc1 (bookmark-maybe-sort-alist): Don't modify bookmark-alist.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 78159
diff changeset
995 (sort (copy-alist bookmark-alist)
ba35decf8cc1 (bookmark-maybe-sort-alist): Don't modify bookmark-alist.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 78159
diff changeset
996 (function
ba35decf8cc1 (bookmark-maybe-sort-alist): Don't modify bookmark-alist.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 78159
diff changeset
997 (lambda (x y) (string-lessp (car x) (car y)))))
ba35decf8cc1 (bookmark-maybe-sort-alist): Don't modify bookmark-alist.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 78159
diff changeset
998 bookmark-alist))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
999
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1000
65087
83940123c4b3 (bookmark-after-jump-hook): New hook.
Carsten Dominik <dominik@science.uva.nl>
parents: 64800
diff changeset
1001 (defvar bookmark-after-jump-hook nil
83940123c4b3 (bookmark-after-jump-hook): New hook.
Carsten Dominik <dominik@science.uva.nl>
parents: 64800
diff changeset
1002 "Hook run after `bookmark-jump' jumps to a bookmark.
83940123c4b3 (bookmark-after-jump-hook): New hook.
Carsten Dominik <dominik@science.uva.nl>
parents: 64800
diff changeset
1003 Useful for example to unhide text in `outline-mode'.")
83940123c4b3 (bookmark-after-jump-hook): New hook.
Carsten Dominik <dominik@science.uva.nl>
parents: 64800
diff changeset
1004
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1005 (defun bookmark--jump-via (bookmark display-function)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1006 "Handle BOOKMARK, then call DISPLAY-FUNCTION with current buffer as argument.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1007 Bookmark may be a bookmark name (a string) or a bookmark record.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1008
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1009 After calling DISPLAY-FUNCTION, set window point to the point specified
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1010 by BOOKMARK, if necessary, run `bookmark-after-jump-hook', and then show
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1011 any annotations for this bookmark."
99224
e666721fb443 (bookmark-handle-bookmark): Rename from bookmark-jump-noselect.
Chong Yidong <cyd@stupidchicken.com>
parents: 98537
diff changeset
1012 (bookmark-handle-bookmark bookmark)
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1013 (save-current-buffer
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1014 (funcall display-function (current-buffer)))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1015 (let ((win (get-buffer-window (current-buffer) 0)))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1016 (if win (set-window-point win (point))))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1017 ;; FIXME: we used to only run bookmark-after-jump-hook in
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1018 ;; `bookmark-jump' itself, but in none of the other commands.
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1019 (run-hooks 'bookmark-after-jump-hook)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1020 (if bookmark-automatically-show-annotations
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1021 ;; if there is an annotation for this bookmark,
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1022 ;; show it in a buffer.
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1023 (bookmark-show-annotation bookmark)))
99766
f1062fe6487f * bookmark.el (bookmark-jump-noselect): Add obsolescence declaration
Juanma Barranquero <lekktu@gmail.com>
parents: 99725
diff changeset
1024
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1025
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1026 ;;;###autoload
105530
e5035c6df58d * lisp/bookmark.el (bookmark-jump): Add new `display-func' parameter.
Karl Fogel <kfogel@red-bean.com>
parents: 105449
diff changeset
1027 (defun bookmark-jump (bookmark &optional display-func)
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
1028 "Jump to bookmark BOOKMARK (a point in some file).
4633
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
1029 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
1030 `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
1031 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
1032 this.
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1033
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1034 If the file pointed to by BOOKMARK no longer exists, you will be asked
64634
4045a1b1a5c9 (bookmark-automatically-show-annotations, bookmark-read-annotation-text-func): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
1035 if you wish to give the bookmark a new location, and `bookmark-jump'
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1036 will then jump to the new location, as well as recording it in place
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1037 of the old one in the permanent bookmark record.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1038
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1039 BOOKMARK may be a bookmark name (a string) or a bookmark record, but
105530
e5035c6df58d * lisp/bookmark.el (bookmark-jump): Add new `display-func' parameter.
Karl Fogel <kfogel@red-bean.com>
parents: 105449
diff changeset
1040 the latter is usually only used by programmatic callers.
e5035c6df58d * lisp/bookmark.el (bookmark-jump): Add new `display-func' parameter.
Karl Fogel <kfogel@red-bean.com>
parents: 105449
diff changeset
1041
e5035c6df58d * lisp/bookmark.el (bookmark-jump): Add new `display-func' parameter.
Karl Fogel <kfogel@red-bean.com>
parents: 105449
diff changeset
1042 If DISPLAY-FUNC is non-nil, it is a function to invoke to display the
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
1043 bookmark. It defaults to `switch-to-buffer'. A typical value for
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
1044 DISPLAY-FUNC would be `switch-to-buffer-other-window'."
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1045 (interactive
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
1046 (list (bookmark-completing-read "Jump to bookmark"
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
1047 bookmark-current-bookmark)))
59133
55f8ffb8e523 (bookmark-jump): Nice error if BOOKMARK is nil.
Richard M. Stallman <rms@gnu.org>
parents: 56059
diff changeset
1048 (unless bookmark
55f8ffb8e523 (bookmark-jump): Nice error if BOOKMARK is nil.
Richard M. Stallman <rms@gnu.org>
parents: 56059
diff changeset
1049 (error "No bookmark specified"))
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
1050 (bookmark-maybe-historicize-string bookmark)
105530
e5035c6df58d * lisp/bookmark.el (bookmark-jump): Add new `display-func' parameter.
Karl Fogel <kfogel@red-bean.com>
parents: 105449
diff changeset
1051 (bookmark--jump-via bookmark (or display-func 'switch-to-buffer)))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1052
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1053
81844
805e8454783b * bookmark.el (bookmark-jump-other-window): New function.
Karl Fogel <kfogel@red-bean.com>
parents: 81843
diff changeset
1054 ;;;###autoload
805e8454783b * bookmark.el (bookmark-jump-other-window): New function.
Karl Fogel <kfogel@red-bean.com>
parents: 81843
diff changeset
1055 (defun bookmark-jump-other-window (bookmark)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1056 "Jump to BOOKMARK in another window. See `bookmark-jump' for more."
81844
805e8454783b * bookmark.el (bookmark-jump-other-window): New function.
Karl Fogel <kfogel@red-bean.com>
parents: 81843
diff changeset
1057 (interactive
105530
e5035c6df58d * lisp/bookmark.el (bookmark-jump): Add new `display-func' parameter.
Karl Fogel <kfogel@red-bean.com>
parents: 105449
diff changeset
1058 (list (bookmark-completing-read "Jump to bookmark (in another window)"
e5035c6df58d * lisp/bookmark.el (bookmark-jump): Add new `display-func' parameter.
Karl Fogel <kfogel@red-bean.com>
parents: 105449
diff changeset
1059 bookmark-current-bookmark)))
e5035c6df58d * lisp/bookmark.el (bookmark-jump): Add new `display-func' parameter.
Karl Fogel <kfogel@red-bean.com>
parents: 105449
diff changeset
1060 (bookmark-jump bookmark 'switch-to-buffer-other-window))
81844
805e8454783b * bookmark.el (bookmark-jump-other-window): New function.
Karl Fogel <kfogel@red-bean.com>
parents: 81843
diff changeset
1061
805e8454783b * bookmark.el (bookmark-jump-other-window): New function.
Karl Fogel <kfogel@red-bean.com>
parents: 81843
diff changeset
1062
92550
4170d4a36502 * bookmark.el (bookmark-map, bookmark-read-annotation-mode-map):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87566
diff changeset
1063 (defun bookmark-jump-noselect (bookmark)
99224
e666721fb443 (bookmark-handle-bookmark): Rename from bookmark-jump-noselect.
Chong Yidong <cyd@stupidchicken.com>
parents: 98537
diff changeset
1064 "Return the location pointed to by the bookmark BOOKMARK.
99725
d067d683a1bc (bookmark-jump-noselect): Move the deprecation notice into the doc
Karl Fogel <kfogel@red-bean.com>
parents: 99228
diff changeset
1065 The return value has the form (BUFFER . POINT).
d067d683a1bc (bookmark-jump-noselect): Move the deprecation notice into the doc
Karl Fogel <kfogel@red-bean.com>
parents: 99228
diff changeset
1066
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1067 BOOKMARK may be a bookmark name (a string) or a bookmark record.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1068
99725
d067d683a1bc (bookmark-jump-noselect): Move the deprecation notice into the doc
Karl Fogel <kfogel@red-bean.com>
parents: 99228
diff changeset
1069 Note: this function is deprecated and is present for Emacs 22
99766
f1062fe6487f * bookmark.el (bookmark-jump-noselect): Add obsolescence declaration
Juanma Barranquero <lekktu@gmail.com>
parents: 99725
diff changeset
1070 compatibility only."
99224
e666721fb443 (bookmark-handle-bookmark): Rename from bookmark-jump-noselect.
Chong Yidong <cyd@stupidchicken.com>
parents: 98537
diff changeset
1071 (save-excursion
e666721fb443 (bookmark-handle-bookmark): Rename from bookmark-jump-noselect.
Chong Yidong <cyd@stupidchicken.com>
parents: 98537
diff changeset
1072 (bookmark-handle-bookmark bookmark)
e666721fb443 (bookmark-handle-bookmark): Rename from bookmark-jump-noselect.
Chong Yidong <cyd@stupidchicken.com>
parents: 98537
diff changeset
1073 (cons (current-buffer) (point))))
e666721fb443 (bookmark-handle-bookmark): Rename from bookmark-jump-noselect.
Chong Yidong <cyd@stupidchicken.com>
parents: 98537
diff changeset
1074
99766
f1062fe6487f * bookmark.el (bookmark-jump-noselect): Add obsolescence declaration
Juanma Barranquero <lekktu@gmail.com>
parents: 99725
diff changeset
1075 (make-obsolete 'bookmark-jump-noselect 'bookmark-handle-bookmark "23.1")
f1062fe6487f * bookmark.el (bookmark-jump-noselect): Add obsolescence declaration
Juanma Barranquero <lekktu@gmail.com>
parents: 99725
diff changeset
1076
99224
e666721fb443 (bookmark-handle-bookmark): Rename from bookmark-jump-noselect.
Chong Yidong <cyd@stupidchicken.com>
parents: 98537
diff changeset
1077 (defun bookmark-handle-bookmark (bookmark)
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1078 "Call BOOKMARK's handler or `bookmark-default-handler' if it has none.
105449
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1079 BOOKMARK may be a bookmark name (a string) or a bookmark record.
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1080
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1081 Changes current buffer and point and returns nil, or signals a `file-error'.
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1082
105449
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1083 If BOOKMARK has no file, this is a no-op. If BOOKMARK has a file, but
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
1084 that file no longer exists, then offer interactively to relocate BOOKMARK."
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1085 (condition-case err
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1086 (funcall (or (bookmark-get-handler bookmark)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1087 'bookmark-default-handler)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1088 (bookmark-get-bookmark bookmark))
107125
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1089 (bookmark-error-no-filename ;file-error
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1090 ;; We were unable to find the marked file, so ask if user wants to
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1091 ;; relocate the bookmark, else remind them to consider deletion.
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1092 (when (stringp bookmark)
105449
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1093 ;; `bookmark' can be either a bookmark name (from `bookmark-alist')
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1094 ;; or a bookmark object. If it's an object, we assume it's a
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1095 ;; bookmark used internally by some other package.
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1096 (let ((file (bookmark-get-filename bookmark)))
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1097 (when file ;Don't know how to relocate if there's no `file'.
105449
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1098 ;; If file is not a dir, directory-file-name just returns file.
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1099 (let ((display-name (directory-file-name file)))
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1100 (ding)
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1101 ;; Dialog boxes can accept a file target, but usually don't
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1102 ;; know how to accept a directory target (at least, this
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1103 ;; is true in Gnome on GNU/Linux, and Bug#4230 says it's
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1104 ;; true on Windows as well). So we suppress file dialogs
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1105 ;; when relocating.
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1106 (let ((use-dialog-box nil)
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1107 (use-file-dialog nil))
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1108 (if (y-or-n-p (concat display-name " nonexistent. Relocate \""
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1109 bookmark "\"? "))
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1110 (progn
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1111 (bookmark-relocate bookmark)
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1112 ;; Try again.
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1113 (funcall (or (bookmark-get-handler bookmark)
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1114 'bookmark-default-handler)
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1115 (bookmark-get-bookmark bookmark)))
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1116 (message
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
1117 "Bookmark not relocated; consider removing it (%s)."
105449
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1118 bookmark)
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1119 (signal (car err) (cdr err))))))))))
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1120 ;; Added by db.
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1121 (when (stringp bookmark)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1122 (setq bookmark-current-bookmark bookmark))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1123 nil)
28013
b8291d86b5fd (bookmark-file-or-variation-thereof): New func, for
Gerd Moellmann <gerd@gnu.org>
parents: 26773
diff changeset
1124
105449
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1125 (put 'bookmark-error-no-filename
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1126 'error-conditions
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1127 '(error bookmark-errors bookmark-error-no-filename))
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1128 (put 'bookmark-error-no-filename
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1129 'error-message
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1130 "Bookmark has no associated file (or directory)")
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1131
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1132 (defun bookmark-default-handler (bmk-record)
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1133 "Default handler to jump to a particular bookmark location.
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1134 BMK-RECORD is a bookmark record, not a bookmark name (i.e., not a string).
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1135 Changes current buffer and point and returns nil, or signals a `file-error'."
105449
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1136 (let ((file (bookmark-get-filename bmk-record))
107125
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1137 (buf (bookmark-prop-get bmk-record 'buffer))
105449
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1138 (forward-str (bookmark-get-front-context-string bmk-record))
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1139 (behind-str (bookmark-get-rear-context-string bmk-record))
4d75e3e0f1ea * bookmark.el (bookmark-handle-bookmark): If bookmark has no file,
Karl Fogel <kfogel@red-bean.com>
parents: 105448
diff changeset
1140 (place (bookmark-get-position bmk-record)))
107125
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1141 (set-buffer
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1142 (cond
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1143 ((and file (file-readable-p file) (not (buffer-live-p buf)))
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1144 (find-file-noselect file))
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1145 ;; No file found. See if buffer BUF have been created.
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1146 ((and buf (get-buffer buf)))
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1147 (t ;; If not, raise error.
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1148 (signal 'bookmark-error-no-filename (list 'stringp file)))))
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1149 (if place (goto-char place))
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1150 ;; Go searching forward first. Then, if forward-str exists and
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1151 ;; was found in the file, we can search backward for behind-str.
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1152 ;; Rationale is that if text was inserted between the two in the
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1153 ;; file, it's better to be put before it so you can read it,
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1154 ;; rather than after and remain perhaps unaware of the changes.
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1155 (when (and forward-str (search-forward forward-str (point-max) t))
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1156 (goto-char (match-beginning 0)))
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1157 (when (and behind-str (search-backward behind-str (point-min) t))
063e00f61d0f (bookmark-handle-bookmark): Catch the right error.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106821
diff changeset
1158 (goto-char (match-end 0)))
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1159 nil))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1160
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1161 ;;;###autoload
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
1162 (defun bookmark-relocate (bookmark)
15193
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
1163 "Relocate BOOKMARK to another file (reading file name with minibuffer).
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1164 BOOKMARK is a bookmark name (a string), not a bookmark record.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1165
15193
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
1166 This makes an already existing bookmark point to that file, instead of
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
1167 the one it used to point at. Useful when a file has been renamed
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
1168 after a bookmark was set in it."
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
1169 (interactive (list (bookmark-completing-read "Bookmark to relocate")))
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
1170 (bookmark-maybe-historicize-string bookmark)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1171 (bookmark-maybe-load-default-file)
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
1172 (let* ((bmrk-filename (bookmark-get-filename bookmark))
107192
3c9f81253d07 Use abbreviated file names in bookmarks (bug#5591).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107125
diff changeset
1173 (newloc (abbreviate-file-name
3c9f81253d07 Use abbreviated file names in bookmarks (bug#5591).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107125
diff changeset
1174 (expand-file-name
3c9f81253d07 Use abbreviated file names in bookmarks (bug#5591).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107125
diff changeset
1175 (read-file-name
3c9f81253d07 Use abbreviated file names in bookmarks (bug#5591).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107125
diff changeset
1176 (format "Relocate %s to: " bookmark)
3c9f81253d07 Use abbreviated file names in bookmarks (bug#5591).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107125
diff changeset
1177 (file-name-directory bmrk-filename))))))
19472
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1178 (bookmark-set-filename bookmark newloc)
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1179 (setq bookmark-alist-modification-count
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1180 (1+ bookmark-alist-modification-count))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1181 (if (bookmark-time-to-save-p)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1182 (bookmark-save))
19472
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1183 (bookmark-bmenu-surreptitiously-rebuild-list)))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1184
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1185
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1186 ;;;###autoload
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
1187 (defun bookmark-insert-location (bookmark &optional no-history)
10994
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
1188 "Insert the name of the file associated with BOOKMARK.
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1189 BOOKMARK is a bookmark name (a string), not a bookmark record.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1190
10994
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
1191 Optional second arg NO-HISTORY means don't record this in the
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
1192 minibuffer history list `bookmark-history'."
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
1193 (interactive (list (bookmark-completing-read "Insert bookmark location")))
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
1194 (or no-history (bookmark-maybe-historicize-string bookmark))
17265
ddbe17ae5280 Added mouse-selection feature for bookmark list buffer.
Richard M. Stallman <rms@gnu.org>
parents: 17076
diff changeset
1195 (let ((start (point)))
ddbe17ae5280 Added mouse-selection feature for bookmark list buffer.
Richard M. Stallman <rms@gnu.org>
parents: 17076
diff changeset
1196 (prog1
107855
d9895f87d758 Add a new field `location' to bookmarks for non-file bookmarks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107840
diff changeset
1197 (insert (bookmark-location bookmark))
105787
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1198 (if (display-mouse-p)
66192
16f7998a8424 * bookmark.el (bookmark-insert-location, bookmark-bmenu-list)
Romain Francoise <romain@orebokech.com>
parents: 66185
diff changeset
1199 (add-text-properties
16f7998a8424 * bookmark.el (bookmark-insert-location, bookmark-bmenu-list)
Romain Francoise <romain@orebokech.com>
parents: 66185
diff changeset
1200 start
16f7998a8424 * bookmark.el (bookmark-insert-location, bookmark-bmenu-list)
Romain Francoise <romain@orebokech.com>
parents: 66185
diff changeset
1201 (save-excursion (re-search-backward
16f7998a8424 * bookmark.el (bookmark-insert-location, bookmark-bmenu-list)
Romain Francoise <romain@orebokech.com>
parents: 66185
diff changeset
1202 "[^ \t]")
105787
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1203 (1+ (point)))
66192
16f7998a8424 * bookmark.el (bookmark-insert-location, bookmark-bmenu-list)
Romain Francoise <romain@orebokech.com>
parents: 66185
diff changeset
1204 '(mouse-face highlight
16f7998a8424 * bookmark.el (bookmark-insert-location, bookmark-bmenu-list)
Romain Francoise <romain@orebokech.com>
parents: 66185
diff changeset
1205 follow-link t
16f7998a8424 * bookmark.el (bookmark-insert-location, bookmark-bmenu-list)
Romain Francoise <romain@orebokech.com>
parents: 66185
diff changeset
1206 help-echo "mouse-2: go to this bookmark in other window"))))))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1207
15189
dd74ff8dad0b (bookmark-locate): ;;;###autoload this alias.
Karl Fogel <kfogel@red-bean.com>
parents: 15183
diff changeset
1208 ;;;###autoload
15183
9c770d2b753f (bookmark-make): take optional arg `info-node', pass it on to
Karl Fogel <kfogel@red-bean.com>
parents: 14734
diff changeset
1209 (defalias 'bookmark-locate 'bookmark-insert-location)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1210
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
1211 (defun bookmark-location (bookmark)
107855
d9895f87d758 Add a new field `location' to bookmarks for non-file bookmarks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107840
diff changeset
1212 "Return a description of the location of BOOKMARK.
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1213 BOOKMARK may be a bookmark name (a string) or a bookmark record."
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1214 (bookmark-maybe-load-default-file)
107855
d9895f87d758 Add a new field `location' to bookmarks for non-file bookmarks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107840
diff changeset
1215 ;; We could call the `handler' and ask for it to construct a description
d9895f87d758 Add a new field `location' to bookmarks for non-file bookmarks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107840
diff changeset
1216 ;; dynamically: it would open up several new possibilities, but it
d9895f87d758 Add a new field `location' to bookmarks for non-file bookmarks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107840
diff changeset
1217 ;; would have the major disadvantage of forcing to load each and
d9895f87d758 Add a new field `location' to bookmarks for non-file bookmarks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107840
diff changeset
1218 ;; every handler when the user calls bookmark-menu.
d9895f87d758 Add a new field `location' to bookmarks for non-file bookmarks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107840
diff changeset
1219 (or (bookmark-prop-get bookmark 'location)
d9895f87d758 Add a new field `location' to bookmarks for non-file bookmarks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107840
diff changeset
1220 (bookmark-get-filename bookmark)
d9895f87d758 Add a new field `location' to bookmarks for non-file bookmarks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107840
diff changeset
1221 "-- Unknown location --"))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1222
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1223
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1224 ;;;###autoload
4633
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
1225 (defun bookmark-rename (old &optional new)
15193
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
1226 "Change the name of OLD bookmark to NEW name.
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
1227 If called from keyboard, prompt for OLD and NEW. If called from
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
1228 menubar, select OLD from a menu and prompt for NEW.
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
1229
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1230 Both OLD and NEW are bookmark names (strings), never bookmark records.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1231
15193
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
1232 If called from Lisp, prompt for NEW if only OLD was passed as an
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
1233 argument. If called with two strings, then no prompting is done. You
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
1234 must pass at least OLD when calling from Lisp.
4633
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
1235
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
1236 While you are entering the new name, consecutive C-w's insert
13969
8fd836e88aec (bookmark-save-flag, bookmark-read-annotation-text-func,
Karl Heuer <kwzh@gnu.org>
parents: 13895
diff changeset
1237 consecutive words from the text of the buffer into the new bookmark
10994
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
1238 name."
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
1239 (interactive (list (bookmark-completing-read "Old bookmark name")))
10994
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
1240 (bookmark-maybe-historicize-string old)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1241 (bookmark-maybe-load-default-file)
19472
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1242
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1243 (setq bookmark-yank-point (point))
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1244 (setq bookmark-current-buffer (current-buffer))
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1245 (let ((newname
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1246 (or new ; use second arg, if non-nil
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1247 (read-from-minibuffer
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1248 "New name: "
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1249 nil
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1250 (let ((now-map (copy-keymap minibuffer-local-map)))
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
1251 (define-key now-map "\C-w" 'bookmark-yank-word)
19472
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1252 now-map)
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1253 nil
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1254 'bookmark-history))))
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1255 (bookmark-set-name old newname)
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1256 (setq bookmark-current-bookmark newname)
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1257 (bookmark-bmenu-surreptitiously-rebuild-list)
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1258 (setq bookmark-alist-modification-count
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1259 (1+ bookmark-alist-modification-count))
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1260 (if (bookmark-time-to-save-p)
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1261 (bookmark-save))))
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1262
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1263
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1264 ;;;###autoload
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
1265 (defun bookmark-insert (bookmark)
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
1266 "Insert the text of the file pointed to by bookmark BOOKMARK.
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1267 BOOKMARK is a bookmark name (a string), not a bookmark record.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1268
4633
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
1269 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
1270 `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
1271 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
1272 this."
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
1273 (interactive (list (bookmark-completing-read "Insert bookmark contents")))
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
1274 (bookmark-maybe-historicize-string bookmark)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1275 (bookmark-maybe-load-default-file)
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1276 (let ((orig-point (point))
87411
9ac481bc897b 2007-12-26 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 84858
diff changeset
1277 (str-to-insert
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1278 (save-current-buffer
99224
e666721fb443 (bookmark-handle-bookmark): Rename from bookmark-jump-noselect.
Chong Yidong <cyd@stupidchicken.com>
parents: 98537
diff changeset
1279 (bookmark-handle-bookmark bookmark)
87411
9ac481bc897b 2007-12-26 Tassilo Horn <tassilo@member.fsf.org>
Tassilo Horn <tassilo@member.fsf.org>
parents: 84858
diff changeset
1280 (buffer-string))))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1281 (insert str-to-insert)
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1282 (push-mark)
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1283 (goto-char orig-point)))
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1284
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1285
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1286 ;;;###autoload
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1287 (defun bookmark-delete (bookmark &optional batch)
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
1288 "Delete BOOKMARK from the bookmark list.
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1289 BOOKMARK is a bookmark name (a string), not a bookmark record.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1290
4633
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
1291 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
1292 there are one or more other bookmarks with the same name, they will
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
1293 not be deleted. Defaults to the \"current\" bookmark (that is, the
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
1294 one most recently used in this file, if any).
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1295 Optional second arg BATCH means don't update the bookmark list buffer,
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1296 probably because we were called from there."
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1297 (interactive
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
1298 (list (bookmark-completing-read "Delete bookmark"
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
1299 bookmark-current-bookmark)))
10994
d173d21f14e2 Removed C-v bindings; they were inconsistent.
Karl Fogel <kfogel@red-bean.com>
parents: 10960
diff changeset
1300 (bookmark-maybe-historicize-string bookmark)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1301 (bookmark-maybe-load-default-file)
99774
b53beb0ef91c (bookmark-get-bookmark): Add `noerror' arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99773
diff changeset
1302 (let ((will-go (bookmark-get-bookmark bookmark 'noerror)))
4595
2507541ef88d New version from Fogel.
Richard M. Stallman <rms@gnu.org>
parents: 4537
diff changeset
1303 (setq bookmark-alist (delq will-go bookmark-alist))
2507541ef88d New version from Fogel.
Richard M. Stallman <rms@gnu.org>
parents: 4537
diff changeset
1304 ;; Added by db, nil bookmark-current-bookmark if the last
13969
8fd836e88aec (bookmark-save-flag, bookmark-read-annotation-text-func,
Karl Heuer <kwzh@gnu.org>
parents: 13895
diff changeset
1305 ;; occurrence has been deleted
99774
b53beb0ef91c (bookmark-get-bookmark): Add `noerror' arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 99773
diff changeset
1306 (or (bookmark-get-bookmark bookmark-current-bookmark 'noerror)
4595
2507541ef88d New version from Fogel.
Richard M. Stallman <rms@gnu.org>
parents: 4537
diff changeset
1307 (setq bookmark-current-bookmark nil)))
105532
cb911fe6af8f * lisp/bookmark.el (bookmark-delete): Don't let batch arg prevent saving.
Karl Fogel <kfogel@red-bean.com>
parents: 105530
diff changeset
1308 (unless batch
cb911fe6af8f * lisp/bookmark.el (bookmark-delete): Don't let batch arg prevent saving.
Karl Fogel <kfogel@red-bean.com>
parents: 105530
diff changeset
1309 (bookmark-bmenu-surreptitiously-rebuild-list))
cb911fe6af8f * lisp/bookmark.el (bookmark-delete): Don't let batch arg prevent saving.
Karl Fogel <kfogel@red-bean.com>
parents: 105530
diff changeset
1310 (setq bookmark-alist-modification-count
cb911fe6af8f * lisp/bookmark.el (bookmark-delete): Don't let batch arg prevent saving.
Karl Fogel <kfogel@red-bean.com>
parents: 105530
diff changeset
1311 (1+ bookmark-alist-modification-count))
cb911fe6af8f * lisp/bookmark.el (bookmark-delete): Don't let batch arg prevent saving.
Karl Fogel <kfogel@red-bean.com>
parents: 105530
diff changeset
1312 (when (bookmark-time-to-save-p)
cb911fe6af8f * lisp/bookmark.el (bookmark-delete): Don't let batch arg prevent saving.
Karl Fogel <kfogel@red-bean.com>
parents: 105530
diff changeset
1313 (bookmark-save)))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1314
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1315
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1316 (defun bookmark-time-to-save-p (&optional final-time)
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1317 "Return t if it is time to save bookmarks to disk, nil otherwise.
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1318 Optional argument FINAL-TIME means this is being called when Emacs
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1319 is being killed, so save even if `bookmark-save-flag' is a number and
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1320 is greater than `bookmark-alist-modification-count'."
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1321 ;; By Gregory M. Saunders <saunders{_AT_}cis.ohio-state.edu>
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1322 (cond (final-time
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1323 (and (> bookmark-alist-modification-count 0)
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1324 bookmark-save-flag))
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1325 ((numberp bookmark-save-flag)
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1326 (>= bookmark-alist-modification-count bookmark-save-flag))
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1327 (t
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1328 nil)))
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1329
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1330
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1331 ;;;###autoload
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1332 (defun bookmark-write ()
15193
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
1333 "Write bookmarks to a file (reading the file name with the minibuffer).
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
1334 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
1335 (interactive)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1336 (bookmark-maybe-load-default-file)
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1337 (bookmark-save t))
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1338
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1339
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1340 ;;;###autoload
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
1341 (defun bookmark-save (&optional parg file)
4633
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
1342 "Save currently defined bookmarks.
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
1343 Saves by default in the file defined by the variable
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
1344 `bookmark-default-file'. With a prefix arg, save it in file FILE
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
1345 \(second argument).
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1346
64634
4045a1b1a5c9 (bookmark-automatically-show-annotations, bookmark-read-annotation-text-func): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
1347 If you are calling this from Lisp, the two arguments are PARG and
4045a1b1a5c9 (bookmark-automatically-show-annotations, bookmark-read-annotation-text-func): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
1348 FILE, and if you just want it to write to the default file, then
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1349 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
1350 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
1351 user will be interactively queried for a file to save in.
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1352
4595
2507541ef88d New version from Fogel.
Richard M. Stallman <rms@gnu.org>
parents: 4537
diff changeset
1353 When you want to load in the bookmarks from a file, use
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
1354 `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
1355 for a file, defaulting to the file defined by variable
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1356 `bookmark-default-file'."
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1357 (interactive "P")
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1358 (bookmark-maybe-load-default-file)
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1359 (cond
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1360 ((and (null parg) (null file))
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1361 ;;whether interactive or not, write to default file
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1362 (bookmark-write-file bookmark-default-file))
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1363 ((and (null parg) file)
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1364 ;;whether interactive or not, write to given file
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1365 (bookmark-write-file file))
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1366 ((and parg (not file))
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1367 ;;have been called interactively w/ prefix arg
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1368 (let ((file (read-file-name "File to save bookmarks in: ")))
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1369 (bookmark-write-file file)))
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1370 (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
1371 (bookmark-write-file file)))
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1372 ;; 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
1373 ;; 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
1374 ;; set, which is what we want.
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1375 (setq bookmark-alist-modification-count 0))
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1376
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1377
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1378
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1379 (defun bookmark-write-file (file)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1380 "Write `bookmark-alist' to FILE."
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1381 (bookmark-maybe-message "Saving bookmarks to file %s..." file)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1382 (with-current-buffer (get-buffer-create " *Bookmarks*")
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1383 (goto-char (point-min))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1384 (delete-region (point-min) (point-max))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1385 (let ((print-length nil)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1386 (print-level nil))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1387 (bookmark-insert-file-format-version-stamp)
105124
ff7266798210 (bookmark-write-file): Avoid calling `pp' with large
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
1388 (insert "(")
ff7266798210 (bookmark-write-file): Avoid calling `pp' with large
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
1389 ;; Rather than a single call to `pp' we make one per bookmark.
ff7266798210 (bookmark-write-file): Avoid calling `pp' with large
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
1390 ;; Apparently `pp' has a poor algorithmic complexity, so this
ff7266798210 (bookmark-write-file): Avoid calling `pp' with large
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
1391 ;; scales a lot better. bug#4485.
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
1392 (dolist (i bookmark-alist) (pp i (current-buffer)))
105124
ff7266798210 (bookmark-write-file): Avoid calling `pp' with large
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
1393 (insert ")")
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1394 (let ((version-control
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1395 (cond
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1396 ((null bookmark-version-control) nil)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1397 ((eq 'never bookmark-version-control) 'never)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1398 ((eq 'nospecial bookmark-version-control) version-control)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1399 (t t))))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1400 (condition-case nil
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1401 (write-region (point-min) (point-max) file)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1402 (file-error (message "Can't write %s" file)))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1403 (kill-buffer (current-buffer))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1404 (bookmark-maybe-message
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1405 "Saving bookmarks to file %s...done" file)))))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1406
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1407
19472
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1408 (defun bookmark-import-new-list (new-list)
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
1409 "Add NEW-LIST of bookmarks to `bookmark-alist'.
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
1410 Rename new bookmarks as needed using suffix \"<N>\" (N=1,2,3...), when
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
1411 they conflict with existing bookmark names."
105787
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1412 (let ((names (bookmark-all-names)))
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1413 (dolist (full-record new-list)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1414 (bookmark-maybe-rename full-record names)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1415 (setq bookmark-alist (nconc bookmark-alist (list full-record)))
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1416 (push (bookmark-name-from-full-record full-record) names))))
19472
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1417
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1418
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1419 (defun bookmark-maybe-rename (full-record names)
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
1420 "Rename bookmark FULL-RECORD if its current name is already used.
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
1421 This is a helper for `bookmark-import-new-list'."
19472
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1422 (let ((found-name (bookmark-name-from-full-record full-record)))
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1423 (if (member found-name names)
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1424 ;; We've got a conflict, so generate a new name
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1425 (let ((count 2)
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1426 (new-name found-name))
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1427 (while (member new-name names)
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1428 (setq new-name (concat found-name (format "<%d>" count)))
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1429 (setq count (1+ count)))
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1430 (bookmark-set-name full-record new-name)))))
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1431
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1432
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1433 ;;;###autoload
19472
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1434 (defun bookmark-load (file &optional overwrite no-msg)
4633
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
1435 "Load bookmarks from FILE (which must be in bookmark format).
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
1436 Appends loaded bookmarks to the front of the list of bookmarks. If
19472
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1437 optional second argument OVERWRITE is non-nil, existing bookmarks are
4633
738840d8e627 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4631
diff changeset
1438 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
1439 while loading.
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1440
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1441 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
1442 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
1443 in files that were created with the bookmark functions in the first
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1444 place. Your own personal bookmark file, `~/.emacs.bmk', is
4631
fc781d29fd48 New version from Fogel.
Richard M. Stallman <rms@gnu.org>
parents: 4595
diff changeset
1445 maintained automatically by Emacs; you shouldn't need to load it
19472
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1446 explicitly.
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1447
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1448 If you load a file containing bookmarks with the same names as
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1449 bookmarks already present in your Emacs, the new bookmarks will get
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1450 unique numeric suffixes \"<2>\", \"<3>\", ... following the same
6324d603cf6e (bookmark-load): Use `bookmark-import-new-list' to
Richard M. Stallman <rms@gnu.org>
parents: 18709
diff changeset
1451 method buffers use to resolve name collisions."
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1452 (interactive
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1453 (list (read-file-name
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1454 (format "Load bookmarks from: (%s) "
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
1455 bookmark-default-file)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1456 ;;Default might not be used often,
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1457 ;;but there's no better default, and
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1458 ;;I guess it's better than none at all.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1459 "~/" bookmark-default-file 'confirm)))
107192
3c9f81253d07 Use abbreviated file names in bookmarks (bug#5591).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107125
diff changeset
1460 (setq file (abbreviate-file-name (expand-file-name file)))
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1461 (if (not (file-readable-p file))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1462 (error "Cannot read bookmark file %s" file)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1463 (if (null no-msg)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1464 (bookmark-maybe-message "Loading bookmarks from %s..." file))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1465 (with-current-buffer (let ((enable-local-variables nil))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1466 (find-file-noselect file))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1467 (goto-char (point-min))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1468 (bookmark-maybe-upgrade-file-format)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1469 (let ((blist (bookmark-alist-from-buffer)))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1470 (if (listp blist)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1471 (progn
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1472 (if overwrite
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1473 (progn
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1474 (setq bookmark-alist blist)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1475 (setq bookmark-alist-modification-count 0))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1476 ;; else
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1477 (bookmark-import-new-list blist)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1478 (setq bookmark-alist-modification-count
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1479 (1+ bookmark-alist-modification-count)))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1480 (if (string-equal
107192
3c9f81253d07 Use abbreviated file names in bookmarks (bug#5591).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107125
diff changeset
1481 (abbreviate-file-name
3c9f81253d07 Use abbreviated file names in bookmarks (bug#5591).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107125
diff changeset
1482 (expand-file-name bookmark-default-file))
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1483 file)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1484 (setq bookmarks-already-loaded t))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1485 (bookmark-bmenu-surreptitiously-rebuild-list))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1486 (error "Invalid bookmark list in %s" file)))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1487 (kill-buffer (current-buffer)))
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1488 (if (null no-msg)
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1489 (bookmark-maybe-message "Loading bookmarks from %s...done" file))))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1490
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1491
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1492
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1493 ;;; Code supporting the dired-like bookmark menu.
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1494 ;; Prefix is "bookmark-bmenu" for "buffer-menu":
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1495
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1496
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1497 (defvar bookmark-bmenu-hidden-bookmarks ())
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1498
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1499
105787
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1500 (defvar bookmark-bmenu-mode-map
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1501 (let ((map (make-keymap)))
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1502 (suppress-keymap map t)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1503 (define-key map "q" 'quit-window)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1504 (define-key map "v" 'bookmark-bmenu-select)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1505 (define-key map "w" 'bookmark-bmenu-locate)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1506 (define-key map "2" 'bookmark-bmenu-2-window)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1507 (define-key map "1" 'bookmark-bmenu-1-window)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1508 (define-key map "j" 'bookmark-bmenu-this-window)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1509 (define-key map "\C-c\C-c" 'bookmark-bmenu-this-window)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1510 (define-key map "f" 'bookmark-bmenu-this-window)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1511 (define-key map "\C-m" 'bookmark-bmenu-this-window)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1512 (define-key map "o" 'bookmark-bmenu-other-window)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1513 (define-key map "\C-o" 'bookmark-bmenu-switch-other-window)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1514 (define-key map "s" 'bookmark-bmenu-save)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1515 (define-key map "k" 'bookmark-bmenu-delete)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1516 (define-key map "\C-d" 'bookmark-bmenu-delete-backwards)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1517 (define-key map "x" 'bookmark-bmenu-execute-deletions)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1518 (define-key map "d" 'bookmark-bmenu-delete)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1519 (define-key map " " 'next-line)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1520 (define-key map "n" 'next-line)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1521 (define-key map "p" 'previous-line)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1522 (define-key map "\177" 'bookmark-bmenu-backup-unmark)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1523 (define-key map "?" 'describe-mode)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1524 (define-key map "u" 'bookmark-bmenu-unmark)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1525 (define-key map "m" 'bookmark-bmenu-mark)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1526 (define-key map "l" 'bookmark-bmenu-load)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1527 (define-key map "r" 'bookmark-bmenu-rename)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1528 (define-key map "R" 'bookmark-bmenu-relocate)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1529 (define-key map "t" 'bookmark-bmenu-toggle-filenames)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1530 (define-key map "a" 'bookmark-bmenu-show-annotation)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1531 (define-key map "A" 'bookmark-bmenu-show-all-annotations)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1532 (define-key map "e" 'bookmark-bmenu-edit-annotation)
106179
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
1533 ;; The original binding of M-g hides the M-g prefix map.
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
1534 ;; If someone has a better idea than M-g s, I'm open to suggestions.
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
1535 (define-key map [?\M-g ?s] 'bookmark-bmenu-search)
105787
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1536 (define-key map [mouse-2] 'bookmark-bmenu-other-window-with-mouse)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1537 map))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1538
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1539 ;; Bookmark Buffer Menu mode is suitable only for specially formatted
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1540 ;; data.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1541 (put 'bookmark-bmenu-mode 'mode-class 'special)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1542
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1543
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1544 ;; todo: need to display whether or not bookmark exists as a buffer in
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
1545 ;; flag column.
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1546
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1547 ;; Format:
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1548 ;; FLAGS BOOKMARK [ LOCATION ]
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1549
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1550
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1551 (defun bookmark-bmenu-surreptitiously-rebuild-list ()
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1552 "Rebuild the Bookmark List if it exists.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1553 Don't affect the buffer ring order."
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1554 (if (get-buffer "*Bookmark List*")
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1555 (save-excursion
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
1556 (save-window-excursion
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1557 (bookmark-bmenu-list)))))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1558
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1559
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1560 ;;;###autoload
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1561 (defun bookmark-bmenu-list ()
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1562 "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
1563 The list is displayed in a buffer named `*Bookmark List*'.
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1564 The leftmost column displays a D if the bookmark is flagged for
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1565 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
1566 (interactive)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1567 (bookmark-maybe-load-default-file)
105761
2a4b89270020 (bookmark-bmenu-list): Don't use switch-to-buffer if
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105759
diff changeset
1568 (let ((buf (get-buffer-create "*Bookmark List*")))
2a4b89270020 (bookmark-bmenu-list): Don't use switch-to-buffer if
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105759
diff changeset
1569 (if (called-interactively-p 'interactive)
2a4b89270020 (bookmark-bmenu-list): Don't use switch-to-buffer if
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105759
diff changeset
1570 (if (or (window-dedicated-p) (window-minibuffer-p))
2a4b89270020 (bookmark-bmenu-list): Don't use switch-to-buffer if
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105759
diff changeset
1571 (pop-to-buffer buf)
2a4b89270020 (bookmark-bmenu-list): Don't use switch-to-buffer if
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105759
diff changeset
1572 (switch-to-buffer buf))
2a4b89270020 (bookmark-bmenu-list): Don't use switch-to-buffer if
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105759
diff changeset
1573 (set-buffer buf)))
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
1574 (let ((inhibit-read-only t))
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
1575 (erase-buffer)
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1576 (insert "% Bookmark\n- --------\n")
66201
54d9518d9113 (bookmark-menu-heading): New face.
Romain Francoise <romain@orebokech.com>
parents: 66192
diff changeset
1577 (add-text-properties (point-min) (point)
54d9518d9113 (bookmark-menu-heading): New face.
Romain Francoise <romain@orebokech.com>
parents: 66192
diff changeset
1578 '(font-lock-face bookmark-menu-heading))
105787
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1579 (dolist (full-record (bookmark-maybe-sort-alist))
106181
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1580 (let ((name (bookmark-name-from-full-record full-record))
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1581 (annotation (bookmark-get-annotation full-record))
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1582 (start (point))
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1583 end)
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1584 ;; if a bookmark has an annotation, prepend a "*"
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1585 ;; in the list of bookmarks.
105787
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1586 (insert (if (and annotation (not (string-equal annotation "")))
106181
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1587 " *" " ")
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1588 name)
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1589 (setq end (point))
106714
396a004a924b * lisp/bookmark.el: Consistently put the text property on the bookmark name.
Karl Fogel <kfogel@red-bean.com>
parents: 106713
diff changeset
1590 (put-text-property
396a004a924b * lisp/bookmark.el: Consistently put the text property on the bookmark name.
Karl Fogel <kfogel@red-bean.com>
parents: 106713
diff changeset
1591 (+ bookmark-bmenu-marks-width start) end 'bookmark-name-prop name)
106181
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1592 (when (display-mouse-p)
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1593 (add-text-properties
106714
396a004a924b * lisp/bookmark.el: Consistently put the text property on the bookmark name.
Karl Fogel <kfogel@red-bean.com>
parents: 106713
diff changeset
1594 (+ bookmark-bmenu-marks-width start) end
106181
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1595 '(mouse-face highlight
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1596 follow-link t
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1597 help-echo "mouse-2: go to this bookmark in other window")))
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1598 (insert "\n")))
106710
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1599 (set-buffer-modified-p (not (= bookmark-alist-modification-count 0)))
106181
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1600 (goto-char (point-min))
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1601 (forward-line 2)
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1602 (bookmark-bmenu-mode)
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1603 (if bookmark-bmenu-toggle-filenames
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1604 (bookmark-bmenu-toggle-filenames t))))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1605
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1606 ;;;###autoload
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1607 (defalias 'list-bookmarks 'bookmark-bmenu-list)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1608 ;;;###autoload
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1609 (defalias 'edit-bookmarks 'bookmark-bmenu-list)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1610
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1611
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1612
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1613 (defun bookmark-bmenu-mode ()
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1614 "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
1615 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
1616 Letters do not insert themselves; instead, they are commands.
13969
8fd836e88aec (bookmark-save-flag, bookmark-read-annotation-text-func,
Karl Heuer <kwzh@gnu.org>
parents: 13895
diff changeset
1617 Bookmark names preceded by a \"*\" have annotations.
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1618 \\<bookmark-bmenu-mode-map>
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1619 \\[bookmark-bmenu-mark] -- mark bookmark to be displayed.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1620 \\[bookmark-bmenu-select] -- select bookmark of line point is on.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1621 Also show bookmarks marked using m in other windows.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1622 \\[bookmark-bmenu-toggle-filenames] -- toggle displaying of filenames (they may obscure long bookmark names).
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1623 \\[bookmark-bmenu-locate] -- display (in minibuffer) location of this bookmark.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1624 \\[bookmark-bmenu-1-window] -- select this bookmark in full-frame window.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1625 \\[bookmark-bmenu-2-window] -- select this bookmark in one window,
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1626 together with bookmark selected before this one in another window.
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1627 \\[bookmark-bmenu-this-window] -- select this bookmark in place of the bookmark menu buffer.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1628 \\[bookmark-bmenu-other-window] -- select this bookmark in another window,
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1629 so the bookmark menu bookmark remains visible in its window.
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1630 \\[bookmark-bmenu-switch-other-window] -- switch the other window to this bookmark.
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
1631 \\[bookmark-bmenu-rename] -- rename this bookmark (prompts for new name).
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
1632 \\[bookmark-bmenu-relocate] -- relocate this bookmark's file (prompts for new file).
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1633 \\[bookmark-bmenu-delete] -- mark this bookmark to be deleted, and move down.
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
1634 \\[bookmark-bmenu-delete-backwards] -- mark this bookmark to be deleted, and move up.
14039
831c5fda97f4 "cyclic.com" addresses changed to "red-bean.com".
Karl Fogel <kfogel@red-bean.com>
parents: 13969
diff changeset
1635 \\[bookmark-bmenu-execute-deletions] -- delete bookmarks marked with `\\[bookmark-bmenu-delete]'.
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1636 \\[bookmark-bmenu-save] -- save the current bookmark list in the default file.
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1637 With a prefix arg, prompts for a file to save in.
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1638 \\[bookmark-bmenu-load] -- load in a file of bookmarks (prompts for file.)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1639 \\[bookmark-bmenu-unmark] -- remove all kinds of marks from current line.
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1640 With prefix argument, also move up one line.
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1641 \\[bookmark-bmenu-backup-unmark] -- back up a line and remove marks.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1642 \\[bookmark-bmenu-show-annotation] -- show the annotation, if it exists, for the current bookmark
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1643 in another buffer.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1644 \\[bookmark-bmenu-show-all-annotations] -- show the annotations of all bookmarks in another buffer.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1645 \\[bookmark-bmenu-edit-annotation] -- edit the annotation for the current bookmark."
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1646 (kill-all-local-variables)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1647 (use-local-map bookmark-bmenu-mode-map)
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1648 (setq truncate-lines t)
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1649 (setq buffer-read-only t)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1650 (setq major-mode 'bookmark-bmenu-mode)
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1651 (setq mode-name "Bookmark Menu")
62718
d00be6e651cd (bookmark-read-annotation-mode, bookmark-edit-annotation-mode)
Lute Kamstra <lute@gnu.org>
parents: 61454
diff changeset
1652 (run-mode-hooks 'bookmark-bmenu-mode-hook))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1653
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1654
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
1655 (defun bookmark-bmenu-toggle-filenames (&optional show)
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1656 "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
1657 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
1658 (interactive)
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1659 (cond
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
1660 (show
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1661 (setq bookmark-bmenu-toggle-filenames nil)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1662 (bookmark-bmenu-show-filenames)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1663 (setq bookmark-bmenu-toggle-filenames t))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1664 (bookmark-bmenu-toggle-filenames
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1665 (bookmark-bmenu-hide-filenames)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1666 (setq bookmark-bmenu-toggle-filenames nil))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1667 (t
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1668 (bookmark-bmenu-show-filenames)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1669 (setq bookmark-bmenu-toggle-filenames t))))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1670
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1671
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1672 (defun bookmark-bmenu-show-filenames (&optional force)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1673 "In an interactive bookmark list, show filenames along with bookmarks.
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
1674 Non-nil FORCE forces a redisplay showing the filenames. FORCE is used
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
1675 mainly for debugging, and should not be necessary in normal use."
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1676 (if (and (not force) bookmark-bmenu-toggle-filenames)
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1677 nil ;already shown, so do nothing
106710
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1678 (with-buffer-modified-unmodified
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1679 (save-excursion
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1680 (save-window-excursion
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1681 (goto-char (point-min))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1682 (forward-line 2)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1683 (setq bookmark-bmenu-hidden-bookmarks ())
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1684 (let ((inhibit-read-only t))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1685 (while (< (point) (point-max))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1686 (let ((bmrk (bookmark-bmenu-bookmark)))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1687 (push bmrk bookmark-bmenu-hidden-bookmarks)
111429
249a1455856a Use line-end-position rather than end-of-line, etc.
Glenn Morris <rgm@gnu.org>
parents: 109399
diff changeset
1688 (let ((start (line-end-position)))
106710
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1689 (move-to-column bookmark-bmenu-file-column t)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1690 ;; Strip off `mouse-face' from the white spaces region.
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1691 (if (display-mouse-p)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1692 (remove-text-properties start (point)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1693 '(mouse-face nil help-echo nil))))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1694 (delete-region (point) (progn (end-of-line) (point)))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1695 (insert " ")
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1696 ;; Pass the NO-HISTORY arg:
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1697 (bookmark-insert-location bmrk t)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1698 (forward-line 1)))))))))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1699
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1700
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1701 (defun bookmark-bmenu-hide-filenames (&optional force)
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1702 "In an interactive bookmark list, hide the filenames of the bookmarks.
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
1703 Non-nil FORCE forces a redisplay showing the filenames. FORCE is used
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
1704 mainly for debugging, and should not be necessary in normal use."
106181
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1705 (when (and (not force) bookmark-bmenu-toggle-filenames)
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1706 ;; nothing to hide if above is nil
106710
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1707 (with-buffer-modified-unmodified
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1708 (save-excursion
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1709 (goto-char (point-min))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1710 (forward-line 2)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1711 (setq bookmark-bmenu-hidden-bookmarks
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1712 (nreverse bookmark-bmenu-hidden-bookmarks))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1713 (let ((inhibit-read-only t))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1714 (while bookmark-bmenu-hidden-bookmarks
106714
396a004a924b * lisp/bookmark.el: Consistently put the text property on the bookmark name.
Karl Fogel <kfogel@red-bean.com>
parents: 106713
diff changeset
1715 (move-to-column bookmark-bmenu-marks-width t)
106710
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1716 (bookmark-kill-line)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1717 (let ((name (pop bookmark-bmenu-hidden-bookmarks))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1718 (start (point)))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1719 (insert name)
106714
396a004a924b * lisp/bookmark.el: Consistently put the text property on the bookmark name.
Karl Fogel <kfogel@red-bean.com>
parents: 106713
diff changeset
1720 (put-text-property start (point) 'bookmark-name-prop name)
106710
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1721 (if (display-mouse-p)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1722 (add-text-properties
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1723 start (point)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1724 '(mouse-face
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1725 highlight follow-link t help-echo
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1726 "mouse-2: go to this bookmark in other window"))))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1727 (forward-line 1)))))))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1728
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1729
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1730 (defun bookmark-bmenu-ensure-position ()
105759
110c55336723 * bookmark.el: Update documentation, especially documentation
Karl Fogel <kfogel@red-bean.com>
parents: 105744
diff changeset
1731 "If point is not on a bookmark line, move it to one.
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1732 If before the first bookmark line, move to the first; if after the
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1733 last full line, move to the last full line. The return value is undefined."
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1734 (cond ((< (count-lines (point-min) (point)) bookmark-bmenu-header-height)
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1735 (goto-char (point-min))
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1736 (forward-line bookmark-bmenu-header-height))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1737 ((and (bolp) (eobp))
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1738 (beginning-of-line 0))))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1739
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1740
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1741 (defun bookmark-bmenu-bookmark ()
105445
01d333402a8c * bookmark.el
Karl Fogel <kfogel@red-bean.com>
parents: 105444
diff changeset
1742 "Return the bookmark for this line in an interactive bookmark list buffer."
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1743 (bookmark-bmenu-ensure-position)
106701
a3eff1130b76 * lisp/bookmark.el (bookmark-bmenu-marks-width): Define to 1, not 2.
Karl Fogel <kfogel@red-bean.com>
parents: 106700
diff changeset
1744 (save-excursion
a3eff1130b76 * lisp/bookmark.el (bookmark-bmenu-marks-width): Define to 1, not 2.
Karl Fogel <kfogel@red-bean.com>
parents: 106700
diff changeset
1745 (beginning-of-line)
a3eff1130b76 * lisp/bookmark.el (bookmark-bmenu-marks-width): Define to 1, not 2.
Karl Fogel <kfogel@red-bean.com>
parents: 106700
diff changeset
1746 (forward-char bookmark-bmenu-marks-width)
a3eff1130b76 * lisp/bookmark.el (bookmark-bmenu-marks-width): Define to 1, not 2.
Karl Fogel <kfogel@red-bean.com>
parents: 106700
diff changeset
1747 (get-text-property (point) 'bookmark-name-prop)))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1748
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1749
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1750 (defun bookmark-show-annotation (bookmark)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1751 "Display the annotation for bookmark named BOOKMARK in a buffer,
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1752 if an annotation exists."
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1753 (let ((annotation (bookmark-get-annotation bookmark)))
109384
32e3de61d8a0 * lisp/bookmark.el (bookmark-show-annotation): Use `when' instead of `if'.
Karl Fogel <kfogel@red-bean.com>
parents: 109383
diff changeset
1754 (when (and annotation (not (string-equal annotation "")))
32e3de61d8a0 * lisp/bookmark.el (bookmark-show-annotation): Use `when' instead of `if'.
Karl Fogel <kfogel@red-bean.com>
parents: 109383
diff changeset
1755 (save-excursion
32e3de61d8a0 * lisp/bookmark.el (bookmark-show-annotation): Use `when' instead of `if'.
Karl Fogel <kfogel@red-bean.com>
parents: 109383
diff changeset
1756 (let ((old-buf (current-buffer)))
32e3de61d8a0 * lisp/bookmark.el (bookmark-show-annotation): Use `when' instead of `if'.
Karl Fogel <kfogel@red-bean.com>
parents: 109383
diff changeset
1757 (pop-to-buffer (get-buffer-create "*Bookmark Annotation*") t)
32e3de61d8a0 * lisp/bookmark.el (bookmark-show-annotation): Use `when' instead of `if'.
Karl Fogel <kfogel@red-bean.com>
parents: 109383
diff changeset
1758 (delete-region (point-min) (point-max))
32e3de61d8a0 * lisp/bookmark.el (bookmark-show-annotation): Use `when' instead of `if'.
Karl Fogel <kfogel@red-bean.com>
parents: 109383
diff changeset
1759 ;; (insert (concat "Annotation for bookmark '" bookmark "':\n\n"))
32e3de61d8a0 * lisp/bookmark.el (bookmark-show-annotation): Use `when' instead of `if'.
Karl Fogel <kfogel@red-bean.com>
parents: 109383
diff changeset
1760 (insert annotation)
32e3de61d8a0 * lisp/bookmark.el (bookmark-show-annotation): Use `when' instead of `if'.
Karl Fogel <kfogel@red-bean.com>
parents: 109383
diff changeset
1761 (goto-char (point-min))
32e3de61d8a0 * lisp/bookmark.el (bookmark-show-annotation): Use `when' instead of `if'.
Karl Fogel <kfogel@red-bean.com>
parents: 109383
diff changeset
1762 (switch-to-buffer-other-window old-buf))))))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1763
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1764
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1765 (defun bookmark-show-all-annotations ()
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1766 "Display the annotations for all bookmarks in a buffer."
105787
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1767 (save-selected-window
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1768 (pop-to-buffer (get-buffer-create "*Bookmark Annotation*") t)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1769 (delete-region (point-min) (point-max))
105787
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1770 (dolist (full-record bookmark-alist)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1771 (let* ((name (bookmark-name-from-full-record full-record))
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1772 (ann (bookmark-get-annotation full-record)))
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1773 (insert (concat name ":\n"))
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1774 (if (and ann (not (string-equal ann "")))
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1775 ;; insert the annotation, indented by 4 spaces.
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1776 (progn
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1777 (save-excursion (insert ann) (unless (bolp)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1778 (insert "\n")))
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1779 (while (< (point) (point-max))
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1780 (beginning-of-line) ; paranoia
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1781 (insert " ")
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1782 (forward-line)
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1783 (end-of-line))))))
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
1784 (goto-char (point-min))))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1785
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1786
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1787 (defun bookmark-bmenu-mark ()
15193
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
1788 "Mark bookmark on this line to be displayed by \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-select]."
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1789 (interactive)
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1790 (beginning-of-line)
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1791 (bookmark-bmenu-ensure-position)
106710
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1792 (with-buffer-modified-unmodified
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1793 (let ((inhibit-read-only t))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1794 (delete-char 1)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1795 (insert ?>)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1796 (forward-line 1)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1797 (bookmark-bmenu-ensure-position))))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1798
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1799
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1800 (defun bookmark-bmenu-select ()
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1801 "Select this line's bookmark; also display bookmarks marked with `>'.
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1802 You can mark bookmarks with the \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-mark] command."
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1803 (interactive)
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1804 (let ((bmrk (bookmark-bmenu-bookmark))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1805 (menu (current-buffer))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1806 (others ())
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1807 tem)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1808 (goto-char (point-min))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1809 (while (re-search-forward "^>" nil t)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1810 (setq tem (bookmark-bmenu-bookmark))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1811 (let ((inhibit-read-only t))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1812 (delete-char -1)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1813 (insert ?\s))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1814 (or (string-equal tem bmrk)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1815 (member tem others)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1816 (setq others (cons tem others))))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1817 (setq others (nreverse others)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1818 tem (/ (1- (frame-height)) (1+ (length others))))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1819 (delete-other-windows)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1820 (bookmark-jump bmrk)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1821 (bury-buffer menu)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1822 (if others
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1823 (while others
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1824 (split-window nil tem)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1825 (other-window 1)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1826 (bookmark-jump (car others))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1827 (setq others (cdr others)))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1828 (other-window 1))))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1829
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1830
106702
d4fd57e5eafd * lisp/bookmark.el (bookmark-bmenu-any-marks): New function
Karl Fogel <kfogel@red-bean.com>
parents: 106701
diff changeset
1831 (defun bookmark-bmenu-any-marks ()
d4fd57e5eafd * lisp/bookmark.el (bookmark-bmenu-any-marks): New function
Karl Fogel <kfogel@red-bean.com>
parents: 106701
diff changeset
1832 "Return non-nil if any bookmarks are marked in the marks column."
d4fd57e5eafd * lisp/bookmark.el (bookmark-bmenu-any-marks): New function
Karl Fogel <kfogel@red-bean.com>
parents: 106701
diff changeset
1833 (save-excursion
d4fd57e5eafd * lisp/bookmark.el (bookmark-bmenu-any-marks): New function
Karl Fogel <kfogel@red-bean.com>
parents: 106701
diff changeset
1834 (goto-char (point-min))
d4fd57e5eafd * lisp/bookmark.el (bookmark-bmenu-any-marks): New function
Karl Fogel <kfogel@red-bean.com>
parents: 106701
diff changeset
1835 (bookmark-bmenu-ensure-position)
d4fd57e5eafd * lisp/bookmark.el (bookmark-bmenu-any-marks): New function
Karl Fogel <kfogel@red-bean.com>
parents: 106701
diff changeset
1836 (catch 'found-mark
d4fd57e5eafd * lisp/bookmark.el (bookmark-bmenu-any-marks): New function
Karl Fogel <kfogel@red-bean.com>
parents: 106701
diff changeset
1837 (while (not (eobp))
d4fd57e5eafd * lisp/bookmark.el (bookmark-bmenu-any-marks): New function
Karl Fogel <kfogel@red-bean.com>
parents: 106701
diff changeset
1838 (beginning-of-line)
d4fd57e5eafd * lisp/bookmark.el (bookmark-bmenu-any-marks): New function
Karl Fogel <kfogel@red-bean.com>
parents: 106701
diff changeset
1839 (if (looking-at "^\\S-")
d4fd57e5eafd * lisp/bookmark.el (bookmark-bmenu-any-marks): New function
Karl Fogel <kfogel@red-bean.com>
parents: 106701
diff changeset
1840 (throw 'found-mark t)
d4fd57e5eafd * lisp/bookmark.el (bookmark-bmenu-any-marks): New function
Karl Fogel <kfogel@red-bean.com>
parents: 106701
diff changeset
1841 (forward-line 1)))
d4fd57e5eafd * lisp/bookmark.el (bookmark-bmenu-any-marks): New function
Karl Fogel <kfogel@red-bean.com>
parents: 106701
diff changeset
1842 nil)))
d4fd57e5eafd * lisp/bookmark.el (bookmark-bmenu-any-marks): New function
Karl Fogel <kfogel@red-bean.com>
parents: 106701
diff changeset
1843
d4fd57e5eafd * lisp/bookmark.el (bookmark-bmenu-any-marks): New function
Karl Fogel <kfogel@red-bean.com>
parents: 106701
diff changeset
1844
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1845 (defun bookmark-bmenu-save (parg)
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1846 "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
1847 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
1848 (interactive "P")
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1849 (save-excursion
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1850 (save-window-excursion
106712
ba9ed2ec36e5 * lisp/bookmark.el (bookmark-bmenu-save): Just depend on the new logic
Karl Fogel <kfogel@red-bean.com>
parents: 106710
diff changeset
1851 (bookmark-save parg)
ba9ed2ec36e5 * lisp/bookmark.el (bookmark-bmenu-save): Just depend on the new logic
Karl Fogel <kfogel@red-bean.com>
parents: 106710
diff changeset
1852 (set-buffer-modified-p nil))))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1853
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1854
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1855 (defun bookmark-bmenu-load ()
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1856 "Load the bookmark file and rebuild the bookmark menu-buffer."
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1857 (interactive)
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1858 (bookmark-bmenu-ensure-position)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1859 (save-excursion
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1860 (save-window-excursion
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1861 ;; This will call `bookmark-bmenu-list'
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1862 (call-interactively 'bookmark-load))))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1863
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1864
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1865 (defun bookmark-bmenu-1-window ()
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1866 "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
1867 (interactive)
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1868 (bookmark-jump (bookmark-bmenu-bookmark))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1869 (bury-buffer (other-buffer))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1870 (delete-other-windows))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1871
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1872
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1873 (defun bookmark-bmenu-2-window ()
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1874 "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
1875 (interactive)
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1876 (let ((bmrk (bookmark-bmenu-bookmark))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1877 (menu (current-buffer))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1878 (pop-up-windows t))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1879 (delete-other-windows)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1880 (switch-to-buffer (other-buffer))
109135
370f2493de9e * lisp/bookmark.el (bookmark-bmenu-switch-other-window,
Karl Fogel <kfogel@red-bean.com>
parents: 107855
diff changeset
1881 (bookmark--jump-via bmrk 'pop-to-buffer)
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1882 (bury-buffer menu)))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1883
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1884
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1885 (defun bookmark-bmenu-this-window ()
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1886 "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
1887 (interactive)
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1888 (bookmark-jump (bookmark-bmenu-bookmark)))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1889
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1890
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1891 (defun bookmark-bmenu-other-window ()
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1892 "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
1893 (interactive)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1894 (let ((bookmark (bookmark-bmenu-bookmark)))
109135
370f2493de9e * lisp/bookmark.el (bookmark-bmenu-switch-other-window,
Karl Fogel <kfogel@red-bean.com>
parents: 107855
diff changeset
1895 (bookmark--jump-via bookmark 'switch-to-buffer-other-window)))
11021
83b6c53268c3 (bookmark-bmenu-2-window): go to correct position as well as
Karl Fogel <kfogel@red-bean.com>
parents: 10994
diff changeset
1896
83b6c53268c3 (bookmark-bmenu-2-window): go to correct position as well as
Karl Fogel <kfogel@red-bean.com>
parents: 10994
diff changeset
1897
83b6c53268c3 (bookmark-bmenu-2-window): go to correct position as well as
Karl Fogel <kfogel@red-bean.com>
parents: 10994
diff changeset
1898 (defun bookmark-bmenu-switch-other-window ()
83b6c53268c3 (bookmark-bmenu-2-window): go to correct position as well as
Karl Fogel <kfogel@red-bean.com>
parents: 10994
diff changeset
1899 "Make the other window select this line's bookmark.
83b6c53268c3 (bookmark-bmenu-2-window): go to correct position as well as
Karl Fogel <kfogel@red-bean.com>
parents: 10994
diff changeset
1900 The current window remains selected."
83b6c53268c3 (bookmark-bmenu-2-window): go to correct position as well as
Karl Fogel <kfogel@red-bean.com>
parents: 10994
diff changeset
1901 (interactive)
22251
5989fa41cda6 Changes so bookmark list mode works with Info:
Richard M. Stallman <rms@gnu.org>
parents: 21094
diff changeset
1902 (let ((bookmark (bookmark-bmenu-bookmark))
5989fa41cda6 Changes so bookmark list mode works with Info:
Richard M. Stallman <rms@gnu.org>
parents: 21094
diff changeset
1903 (pop-up-windows t)
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
1904 same-window-buffer-names
22251
5989fa41cda6 Changes so bookmark list mode works with Info:
Richard M. Stallman <rms@gnu.org>
parents: 21094
diff changeset
1905 same-window-regexps)
109135
370f2493de9e * lisp/bookmark.el (bookmark-bmenu-switch-other-window,
Karl Fogel <kfogel@red-bean.com>
parents: 107855
diff changeset
1906 (bookmark--jump-via bookmark 'display-buffer)))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1907
17265
ddbe17ae5280 Added mouse-selection feature for bookmark list buffer.
Richard M. Stallman <rms@gnu.org>
parents: 17076
diff changeset
1908 (defun bookmark-bmenu-other-window-with-mouse (event)
ddbe17ae5280 Added mouse-selection feature for bookmark list buffer.
Richard M. Stallman <rms@gnu.org>
parents: 17076
diff changeset
1909 "Select bookmark at the mouse pointer in other window, leaving bookmark menu visible."
ddbe17ae5280 Added mouse-selection feature for bookmark list buffer.
Richard M. Stallman <rms@gnu.org>
parents: 17076
diff changeset
1910 (interactive "e")
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1911 (with-current-buffer (window-buffer (posn-window (event-end event)))
17265
ddbe17ae5280 Added mouse-selection feature for bookmark list buffer.
Richard M. Stallman <rms@gnu.org>
parents: 17076
diff changeset
1912 (save-excursion
ddbe17ae5280 Added mouse-selection feature for bookmark list buffer.
Richard M. Stallman <rms@gnu.org>
parents: 17076
diff changeset
1913 (goto-char (posn-point (event-end event)))
ddbe17ae5280 Added mouse-selection feature for bookmark list buffer.
Richard M. Stallman <rms@gnu.org>
parents: 17076
diff changeset
1914 (bookmark-bmenu-other-window))))
ddbe17ae5280 Added mouse-selection feature for bookmark list buffer.
Richard M. Stallman <rms@gnu.org>
parents: 17076
diff changeset
1915
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1916
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1917 (defun bookmark-bmenu-show-annotation ()
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1918 "Show the annotation for the current bookmark in another window."
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1919 (interactive)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1920 (let ((bookmark (bookmark-bmenu-bookmark)))
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1921 (bookmark-show-annotation bookmark)))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1922
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1923
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1924 (defun bookmark-bmenu-show-all-annotations ()
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1925 "Show the annotation for all bookmarks in another window."
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1926 (interactive)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1927 (bookmark-show-all-annotations))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1928
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1929
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1930 (defun bookmark-bmenu-edit-annotation ()
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1931 "Edit the annotation for the current bookmark in another window."
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1932 (interactive)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1933 (let ((bookmark (bookmark-bmenu-bookmark)))
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1934 (bookmark-edit-annotation bookmark)))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1935
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1936
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1937 (defun bookmark-bmenu-unmark (&optional backup)
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1938 "Cancel all requested operations on bookmark on this line and move down.
12310
afad1c3ce9bd Make doc strings and argument names consistent where necessary.
Richard M. Stallman <rms@gnu.org>
parents: 12033
diff changeset
1939 Optional BACKUP means move up."
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1940 (interactive "P")
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1941 (beginning-of-line)
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1942 (bookmark-bmenu-ensure-position)
106710
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1943 (with-buffer-modified-unmodified
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1944 (let ((inhibit-read-only t))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1945 (delete-char 1)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1946 ;; any flags to reset according to circumstances? How about a
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1947 ;; flag indicating whether this bookmark is being visited?
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1948 ;; well, we don't have this now, so maybe later.
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1949 (insert " "))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1950 (forward-line (if backup -1 1))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1951 (bookmark-bmenu-ensure-position)))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1952
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1953
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1954 (defun bookmark-bmenu-backup-unmark ()
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1955 "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
1956 (interactive)
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1957 (forward-line -1)
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1958 (bookmark-bmenu-ensure-position)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1959 (bookmark-bmenu-unmark)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1960 (forward-line -1)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1961 (bookmark-bmenu-ensure-position))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1962
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1963
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1964 (defun bookmark-bmenu-delete ()
15193
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
1965 "Mark bookmark on this line to be deleted.
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
1966 To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-execute-deletions]."
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1967 (interactive)
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1968 (beginning-of-line)
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1969 (bookmark-bmenu-ensure-position)
106710
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1970 (with-buffer-modified-unmodified
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1971 (let ((inhibit-read-only t))
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1972 (delete-char 1)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1973 (insert ?D)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1974 (forward-line 1)
a96887ed3368 * lisp/bookmark.el: Show modified state of bookmark buffer more accurately.
Karl Fogel <kfogel@red-bean.com>
parents: 106709
diff changeset
1975 (bookmark-bmenu-ensure-position))))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1976
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1977
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1978 (defun bookmark-bmenu-delete-backwards ()
15193
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
1979 "Mark bookmark on this line to be deleted, then move up one line.
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
1980 To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-execute-deletions]."
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1981 (interactive)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1982 (bookmark-bmenu-delete)
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1983 (forward-line -2)
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1984 (bookmark-bmenu-ensure-position)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1985 (forward-line 1)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
1986 (bookmark-bmenu-ensure-position))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1987
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1988
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1989 (defun bookmark-bmenu-execute-deletions ()
106821
203a882ff4c0 * lisp/bookmark.el (bookmark-bmenu-execute-deletions): Doc fix (Bug#5276).
Karl Fogel <karl.fogel@canonical.com>
parents: 106815
diff changeset
1990 "Delete bookmarks flagged `D'."
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
1991 (interactive)
14039
831c5fda97f4 "cyclic.com" addresses changed to "red-bean.com".
Karl Fogel <kfogel@red-bean.com>
parents: 13969
diff changeset
1992 (message "Deleting bookmarks...")
106181
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1993 (let ((o-point (point))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1994 (o-str (save-excursion
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1995 (beginning-of-line)
106181
36947fb87ecd (bookmark-bmenu-bookmark-column): Remove var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106179
diff changeset
1996 (unless (looking-at "^D")
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1997 (buffer-substring
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1998 (point)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
1999 (progn (end-of-line) (point))))))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2000 (o-col (current-column)))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
2001 (goto-char (point-min))
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
2002 (forward-line 1)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2003 (while (re-search-forward "^D" (point-max) t)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2004 (bookmark-delete (bookmark-bmenu-bookmark) t)) ; pass BATCH arg
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2005 (bookmark-bmenu-list)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2006 (if o-str
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2007 (progn
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2008 (goto-char (point-min))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2009 (search-forward o-str)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2010 (beginning-of-line)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2011 (forward-char o-col))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2012 (goto-char o-point))
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2013 (beginning-of-line)
14039
831c5fda97f4 "cyclic.com" addresses changed to "red-bean.com".
Karl Fogel <kfogel@red-bean.com>
parents: 13969
diff changeset
2014 (message "Deleting bookmarks...done")
831c5fda97f4 "cyclic.com" addresses changed to "red-bean.com".
Karl Fogel <kfogel@red-bean.com>
parents: 13969
diff changeset
2015 ))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
2016
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2017
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2018 (defun bookmark-bmenu-rename ()
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
2019 "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
2020 (interactive)
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
2021 (let ((bmrk (bookmark-bmenu-bookmark))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
2022 (thispoint (point)))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
2023 (bookmark-rename bmrk)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
2024 (goto-char thispoint)))
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
2025
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2026
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2027 (defun bookmark-bmenu-locate ()
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
2028 "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
2029 (interactive)
106709
f497db0aba00 * lisp/bookmark.el (bookmark-bmenu-select, bookmark-bmenu-1-window,
Karl Fogel <kfogel@red-bean.com>
parents: 106703
diff changeset
2030 (let ((bmrk (bookmark-bmenu-bookmark)))
f497db0aba00 * lisp/bookmark.el (bookmark-bmenu-select, bookmark-bmenu-1-window,
Karl Fogel <kfogel@red-bean.com>
parents: 106703
diff changeset
2031 (message "%s" (bookmark-location bmrk))))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2032
56059
4e04e776fb5e * bookmark.el (bookmark-bmenu-relocate): New function, as
Karl Fogel <kfogel@red-bean.com>
parents: 54906
diff changeset
2033 (defun bookmark-bmenu-relocate ()
4e04e776fb5e * bookmark.el (bookmark-bmenu-relocate): New function, as
Karl Fogel <kfogel@red-bean.com>
parents: 54906
diff changeset
2034 "Change the file path of the bookmark on the current line,
4e04e776fb5e * bookmark.el (bookmark-bmenu-relocate): New function, as
Karl Fogel <kfogel@red-bean.com>
parents: 54906
diff changeset
2035 prompting with completion for the new path."
4e04e776fb5e * bookmark.el (bookmark-bmenu-relocate): New function, as
Karl Fogel <kfogel@red-bean.com>
parents: 54906
diff changeset
2036 (interactive)
106700
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
2037 (let ((bmrk (bookmark-bmenu-bookmark))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
2038 (thispoint (point)))
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
2039 (bookmark-relocate bmrk)
dc3fdb0cfdc7 * lisp/bookmark.el: Improvements suggested by Drew Adams:
Karl Fogel <kfogel@red-bean.com>
parents: 106697
diff changeset
2040 (goto-char thispoint)))
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2041
106166
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2042 ;;; Bookmark-bmenu search
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2043
106179
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2044 ;; Store keyboard input for incremental search.
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2045 (defvar bookmark-search-pattern)
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2046
106166
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2047 (defun bookmark-read-search-input ()
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2048 "Read each keyboard input and add it to `bookmark-search-pattern'."
106179
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2049 (let ((prompt (propertize "Pattern: " 'face 'minibuffer-prompt))
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2050 ;; (inhibit-quit t) ; inhibit-quit is evil. Use it with extreme care!
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2051 (tmp-list ()))
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2052 (while
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2053 (let ((char (read-key (concat prompt bookmark-search-pattern))))
106166
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2054 (case char
106179
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2055 ((?\e ?\r) nil) ; RET or ESC break the search loop.
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2056 (?\C-g (setq bookmark-quit-flag t) nil)
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2057 (?\d (pop tmp-list) t) ; Delete last char of pattern with DEL
106166
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2058 (t
106179
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2059 (if (characterp char)
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2060 (push char tmp-list)
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2061 (setq unread-command-events
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2062 (nconc (mapcar 'identity
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2063 (this-single-command-raw-keys))
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2064 unread-command-events))
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2065 nil))))
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2066 (setq bookmark-search-pattern
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2067 (apply 'string (reverse tmp-list))))))
106166
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2068
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2069
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2070 (defun bookmark-bmenu-filter-alist-by-regexp (regexp)
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2071 "Filter `bookmark-alist' with bookmarks matching REGEXP and rebuild list."
106179
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2072 (let ((bookmark-alist
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2073 (loop for i in bookmark-alist
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2074 when (string-match regexp (car i)) collect i into new
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2075 finally return new)))
106166
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2076 (bookmark-bmenu-list)))
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2077
106179
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2078
106166
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2079 ;;;###autoload
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2080 (defun bookmark-bmenu-search ()
106179
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2081 "Incremental search of bookmarks, hiding the non-matches as we go."
106166
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2082 (interactive)
106179
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2083 (let ((bmk (bookmark-bmenu-bookmark))
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2084 (bookmark-search-pattern "")
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2085 (timer (run-with-idle-timer
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2086 bookmark-search-delay 'repeat
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2087 #'(lambda ()
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2088 (bookmark-bmenu-filter-alist-by-regexp
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2089 bookmark-search-pattern)))))
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2090 (unwind-protect
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2091 (bookmark-read-search-input)
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2092 (cancel-timer timer)
106209
d82b527709ef (bookmark-bmenu-search): Clear echo area when exiting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106181
diff changeset
2093 (message nil)
106179
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2094 (when bookmark-quit-flag ; C-g hit restore menu list.
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2095 (bookmark-bmenu-list) (bookmark-bmenu-goto-bookmark bmk))
0cc25cd9870d (bookmark-search-prompt, bookmark-search-timer): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106172
diff changeset
2096 (setq bookmark-quit-flag nil))))
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
2097
106166
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2098 (defun bookmark-bmenu-goto-bookmark (name)
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2099 "Move point to bookmark with name NAME."
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2100 (goto-char (point-min))
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2101 (while (not (equal name (bookmark-bmenu-bookmark)))
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2102 (forward-line 1))
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2103 (forward-line 0))
106697
ac408704629c lisp/*: Fix typos in docstrings and messages.
Juanma Barranquero <lekktu@gmail.com>
parents: 106210
diff changeset
2104
106166
858a083ed2f0 * bookmark.el (bookmark-search-delay, bookmark-search-prompt): New options.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105920
diff changeset
2105
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2106
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2107 ;;; Menu bar stuff. Prefix is "bookmark-menu".
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2108
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2109 (defun bookmark-menu-popup-paned-menu (event name entries)
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2110 "Pop up multi-paned menu at EVENT, return string chosen from ENTRIES.
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2111 That is, ENTRIES is a list of strings which appear as the choices
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2112 in the menu.
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2113 The number of panes depends on the number of entries.
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2114 The visible entries are truncated to `bookmark-menu-length', but the
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2115 strings returned are not."
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2116 (let ((f-height (/ (frame-height) 2))
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2117 (pane-list nil)
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2118 (iter 0))
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2119 (while entries
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2120 (let (lst
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2121 (count 0))
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2122 (while (and (< count f-height) entries)
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2123 (let ((str (car entries)))
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2124 (push (cons
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2125 (if (> (length str) bookmark-menu-length)
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2126 (substring str 0 bookmark-menu-length)
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2127 str)
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2128 str)
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2129 lst)
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2130 (setq entries (cdr entries))
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2131 (setq count (1+ count))))
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2132 (setq iter (1+ iter))
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2133 (push (cons
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2134 (format "-*- %s (%d) -*-" name iter)
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2135 (nreverse lst))
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2136 pane-list)))
64634
4045a1b1a5c9 (bookmark-automatically-show-annotations, bookmark-read-annotation-text-func): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
2137
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2138 ;; Popup the menu and return the string.
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2139 (x-popup-menu event (cons (concat "-*- " name " -*-")
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2140 (nreverse pane-list)))))
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2141
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2142
4848
511c83aee4ae (bookmark-write): Add numbered backups for bookmark file.
Richard M. Stallman <rms@gnu.org>
parents: 4634
diff changeset
2143 ;; 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
2144 ;; 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
2145
11218
fc73b8f750f1 (menu-bar-bookmark-map): Autoload each form
Richard M. Stallman <rms@gnu.org>
parents: 11070
diff changeset
2146 ;; We MUST autoload EACH form used to set up this variable's value, so
fc73b8f750f1 (menu-bar-bookmark-map): Autoload each form
Richard M. Stallman <rms@gnu.org>
parents: 11070
diff changeset
2147 ;; that the whole job is done in loaddefs.el.
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2148
15193
4df75cda7e5b (bookmark-bmenu-delete-backwards)
Richard M. Stallman <rms@gnu.org>
parents: 15189
diff changeset
2149 ;; Emacs menubar stuff.
13895
0c12b3398d37 Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
parents: 12880
diff changeset
2150
11218
fc73b8f750f1 (menu-bar-bookmark-map): Autoload each form
Richard M. Stallman <rms@gnu.org>
parents: 11070
diff changeset
2151 ;;;###autoload
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2152 (defvar menu-bar-bookmark-map
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2153 (let ((map (make-sparse-keymap "Bookmark functions")))
105744
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2154 (define-key map [load]
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2155 `(menu-item ,(purecopy "Load a Bookmark File...") bookmark-load
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2156 :help ,(purecopy "Load bookmarks from a bookmark file)")))
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2157 (define-key map [write]
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2158 `(menu-item ,(purecopy "Save Bookmarks As...") bookmark-write
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2159 :help ,(purecopy "Write bookmarks to a file (reading the file name with the minibuffer)")))
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2160 (define-key map [save]
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2161 `(menu-item ,(purecopy "Save Bookmarks") bookmark-save
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2162 :help ,(purecopy "Save currently defined bookmarks")))
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2163 (define-key map [edit]
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2164 `(menu-item ,(purecopy "Edit Bookmark List") bookmark-bmenu-list
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2165 :help ,(purecopy "Display a list of existing bookmarks")))
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2166 (define-key map [delete]
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2167 `(menu-item ,(purecopy "Delete Bookmark...") bookmark-delete
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2168 :help ,(purecopy "Delete a bookmark from the bookmark list")))
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2169 (define-key map [rename]
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2170 `(menu-item ,(purecopy "Rename Bookmark...") bookmark-rename
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2171 :help ,(purecopy "Change the name of a bookmark")))
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2172 (define-key map [locate]
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2173 `(menu-item ,(purecopy "Insert Location...") bookmark-locate
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2174 :help ,(purecopy "Insert the name of the file associated with a bookmark")))
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2175 (define-key map [insert]
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2176 `(menu-item ,(purecopy "Insert Contents...") bookmark-insert
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2177 :help ,(purecopy "Insert the text of the file pointed to by a bookmark")))
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2178 (define-key map [set]
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2179 `(menu-item ,(purecopy "Set Bookmark...") bookmark-set
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2180 :help ,(purecopy "Set a bookmark named inside a file.")))
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2181 (define-key map [jump]
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2182 `(menu-item ,(purecopy "Jump to Bookmark...") bookmark-jump
b0a732611398 * keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105541
diff changeset
2183 :help ,(purecopy "Jump to a bookmark (a point in some file)")))
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2184 map))
13895
0c12b3398d37 Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
parents: 12880
diff changeset
2185
11218
fc73b8f750f1 (menu-bar-bookmark-map): Autoload each form
Richard M. Stallman <rms@gnu.org>
parents: 11070
diff changeset
2186 ;;;###autoload
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2187 (defalias 'menu-bar-bookmark-map menu-bar-bookmark-map)
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2188
13895
0c12b3398d37 Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
parents: 12880
diff changeset
2189 ;; make bookmarks appear toward the right side of the menu.
0c12b3398d37 Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
parents: 12880
diff changeset
2190 (if (boundp 'menu-bar-final-items)
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
2191 (if menu-bar-final-items
105787
d5f02d259103 (bookmark-insert-location, bookmark-bmenu-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105761
diff changeset
2192 (push 'bookmark menu-bar-final-items))
13895
0c12b3398d37 Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
parents: 12880
diff changeset
2193 (setq menu-bar-final-items '(bookmark)))
0c12b3398d37 Removed all `bookmark-xemacsp' conditional code relating to menus. Do
Karl Fogel <kfogel@red-bean.com>
parents: 12880
diff changeset
2194
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2195 ;;;; end bookmark menu stuff ;;;;
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2196
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2197
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
2198 ;; Load Hook
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2199 (defvar bookmark-load-hook nil
109399
3fcc8637a887 * lisp/bookmark.el (bookmark-load-hook): Fix doc string as suggested
Karl Fogel <kfogel@red-bean.com>
parents: 109397
diff changeset
2200 "Hook run at the end of loading library `bookmark.el'.")
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2201
96280
bfca3297fa0b * bookmark.el (bookmark-alist): Allow the 2 slightly different formats
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
2202 ;; Exit Hook, called from kill-emacs-hook
34529
8e38e93616a7 * bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
parents: 29476
diff changeset
2203 (defvar bookmark-exit-hook nil
64634
4045a1b1a5c9 (bookmark-automatically-show-annotations, bookmark-read-annotation-text-func): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
2204 "Hook run when Emacs exits.")
4045a1b1a5c9 (bookmark-automatically-show-annotations, bookmark-read-annotation-text-func): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
2205
4045a1b1a5c9 (bookmark-automatically-show-annotations, bookmark-read-annotation-text-func): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
2206 (define-obsolete-variable-alias 'bookmark-exit-hooks 'bookmark-exit-hook "22.1")
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
2207
34529
8e38e93616a7 * bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
parents: 29476
diff changeset
2208 (defun bookmark-exit-hook-internal ()
8e38e93616a7 * bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
parents: 29476
diff changeset
2209 "Save bookmark state, if necessary, at Emacs exit time.
64634
4045a1b1a5c9 (bookmark-automatically-show-annotations, bookmark-read-annotation-text-func): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
2210 This also runs `bookmark-exit-hook'."
4045a1b1a5c9 (bookmark-automatically-show-annotations, bookmark-read-annotation-text-func): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 64091
diff changeset
2211 (run-hooks 'bookmark-exit-hook)
52171
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2212 (and bookmark-alist
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2213 (bookmark-time-to-save-p t)
03075c276aac (bookmark-completing-read): Use a popup menu if activated from the mouse.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52103
diff changeset
2214 (bookmark-save)))
34529
8e38e93616a7 * bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
parents: 29476
diff changeset
2215
8e38e93616a7 * bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
parents: 29476
diff changeset
2216 (add-hook 'kill-emacs-hook 'bookmark-exit-hook-internal)
8e38e93616a7 * bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
parents: 29476
diff changeset
2217
98537
acd509f38a6a * bookmark.el (bookmark-unload-function): New function.
Juanma Barranquero <lekktu@gmail.com>
parents: 96438
diff changeset
2218 (defun bookmark-unload-function ()
acd509f38a6a * bookmark.el (bookmark-unload-function): New function.
Juanma Barranquero <lekktu@gmail.com>
parents: 96438
diff changeset
2219 "Unload the Bookmark library."
acd509f38a6a * bookmark.el (bookmark-unload-function): New function.
Juanma Barranquero <lekktu@gmail.com>
parents: 96438
diff changeset
2220 (when bookmark-save-flag (bookmark-save))
acd509f38a6a * bookmark.el (bookmark-unload-function): New function.
Juanma Barranquero <lekktu@gmail.com>
parents: 96438
diff changeset
2221 ;; continue standard unloading
acd509f38a6a * bookmark.el (bookmark-unload-function): New function.
Juanma Barranquero <lekktu@gmail.com>
parents: 96438
diff changeset
2222 nil)
acd509f38a6a * bookmark.el (bookmark-unload-function): New function.
Juanma Barranquero <lekktu@gmail.com>
parents: 96438
diff changeset
2223
34529
8e38e93616a7 * bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Karl Fogel <kfogel@red-bean.com>
parents: 29476
diff changeset
2224
10952
6069707b1151 Insure that all entry points call `bookmark-maybe-load-default-file'.
Richard M. Stallman <rms@gnu.org>
parents: 9775
diff changeset
2225 (run-hooks 'bookmark-load-hook)
4537
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2226
14f38c0332a4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2227 (provide 'bookmark)
35283
ac715b4413f7 new backquote syntax
Sam Steingold <sds@gnu.org>
parents: 34529
diff changeset
2228
4595
2507541ef88d New version from Fogel.
Richard M. Stallman <rms@gnu.org>
parents: 4537
diff changeset
2229 ;;; bookmark.el ends here