initial commit
[emacs-init.git] / auto-install / bookmark+-bmu.el~
1 ;;; bookmark+-bmu.el --- Bookmark+ code for the `*Bookmark List*' (bmenu).
2 ;; 
3 ;; Filename: bookmark+-bmu.el
4 ;; Description: Bookmark+ code for the `*Bookmark List*' (bmenu).
5 ;; Author: Drew Adams, Thierry Volpiatto
6 ;; Maintainer: Drew Adams (concat "drew.adams" "@" "oracle" ".com")
7 ;; Copyright (C) 2000-2011, Drew Adams, all rights reserved.
8 ;; Copyright (C) 2009, Thierry Volpiatto, all rights reserved.
9 ;; Created: Mon Jul 12 09:05:21 2010 (-0700)
10 ;; Last-Updated: Fri Jul  1 14:51:29 2011 (-0700)
11 ;;           By: dradams
12 ;;     Update #: 771
13 ;; URL: http://www.emacswiki.org/cgi-bin/wiki/bookmark+-bmu.el
14 ;; Keywords: bookmarks, bookmark+, placeholders, annotations, search, info, url, w3m, gnus
15 ;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x
16 ;; 
17 ;; Features that might be required by this library:
18 ;;
19 ;;   `bookmark', `bookmark+-mac', `pp'.
20 ;;
21 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22 ;; 
23 ;;; Commentary: 
24 ;;
25 ;;    This library contains code for buffer `*Bookmark List*' (mode
26 ;;    `bookmark-bmenu-mode').
27 ;;
28 ;;    The Bookmark+ libraries are these:
29 ;;
30 ;;    `bookmark+.el'     - main (driver) library
31 ;;    `bookmark+-mac.el' - Lisp macros
32 ;;    `bookmark+-lit.el' - (optional) code for highlighting bookmarks
33 ;;    `bookmark+-bmu.el' - code for the `*Bookmark List*' (this file)
34 ;;    `bookmark+-1.el'   - other required code (non-bmenu) 
35 ;;    `bookmark+-key.el' - key and menu bindings
36 ;;
37 ;;    `bookmark+-doc.el' - documentation (comment-only file)
38 ;;    `bookmark+-chg.el' - change log (comment-only file)
39 ;;
40 ;;    The documentation (in `bookmark+-doc.el') includes how to
41 ;;    byte-compile and install Bookmark+.  The documentation is also
42 ;;    available in these ways:
43 ;;
44 ;;    1. From the bookmark list (`C-x r l'):
45 ;;       Use `?' to show the current bookmark-list status and general
46 ;;       help, then click link `Doc in Commentary' or link `Doc on the
47 ;;       Web'.
48 ;;
49 ;;    2. From the Emacs-Wiki Web site:
50 ;;       http://www.emacswiki.org/cgi-bin/wiki/BookmarkPlus.
51 ;;    
52 ;;    3. From the Bookmark+ group customization buffer:
53 ;;       `M-x customize-group bookmark-plus', then click link
54 ;;       `Commentary'.
55 ;;
56 ;;    (The commentary links in #1 and #3 work only if you have library
57 ;;    `bookmark+-doc.el' in your `load-path'.)
58  
59 ;;(@> "Index")
60 ;;
61 ;;  Index
62 ;;  -----
63 ;;
64 ;;  If you have library `linkd.el' and Emacs 22 or later, load
65 ;;  `linkd.el' and turn on `linkd-mode' now.  It lets you easily
66 ;;  navigate around the sections of this doc.  Linkd mode will
67 ;;  highlight this Index, as well as the cross-references and section
68 ;;  headings throughout this file.  You can get `linkd.el' here:
69 ;;  http://dto.freeshell.org/notebook/Linkd.html.
70 ;;
71 ;;  (@> "Things Defined Here")
72 ;;  (@> "Faces (Customizable)")
73 ;;  (@> "User Options (Customizable)")
74 ;;  (@> "Internal Variables")
75 ;;  (@> "Compatibility Code for Older Emacs Versions")
76 ;;  (@> "Menu List Replacements (`bookmark-bmenu-*')")
77 ;;  (@> "Bookmark+ Functions (`bmkp-*')")
78 ;;    (@> "Menu-List (`*-bmenu-*') Filter Commands")
79 ;;    (@> "Menu-List (`*-bmenu-*') Commands Involving Marks")
80 ;;    (@> "Omitted Bookmarks")
81 ;;    (@> "Search-and-Replace Locations of Marked Bookmarks")
82 ;;    (@> "Tags")
83 ;;    (@> "General Menu-List (`-*bmenu-*') Commands and Functions")
84 ;;    (@> "Sorting - Commands")
85 ;;    (@> "Other Bookmark+ Functions (`bmkp-*')")
86 ;;  (@> "Keymaps")
87  
88 ;;(@* "Things Defined Here")
89 ;;
90 ;;  Things Defined Here
91 ;;  -------------------
92 ;;
93 ;;  Commands defined here:
94 ;;
95 ;;    `bmkp-bmenu-add-tags', `bmkp-bmenu-add-tags-to-marked',
96 ;;    `bmkp-bmenu-change-sort-order',
97 ;;    `bmkp-bmenu-change-sort-order-repeat', `bmkp-bmenu-copy-tags',
98 ;;    `bmkp-bmenu-define-command',
99 ;;    `bmkp-bmenu-define-full-snapshot-command',
100 ;;    `bmkp-bmenu-define-jump-marked-command',
101 ;;    `bmkp-bmenu-delete-marked', `bmkp-bmenu-describe-marked',
102 ;;    `bmkp-bmenu-describe-this+move-down',
103 ;;    `bmkp-bmenu-describe-this+move-up',
104 ;;    `bmkp-bmenu-describe-this-bookmark',`bmkp-bmenu-dired-marked',
105 ;;    `bmkp-bmenu-edit-bookmark', `bmkp-edit-tags-send',
106 ;;    `bmkp-bmenu-filter-annotation-incrementally',
107 ;;    `bmkp-bmenu-filter-bookmark-name-incrementally',
108 ;;    `bmkp-bmenu-filter-file-name-incrementally',
109 ;;    `bmkp-bmenu-filter-tags-incrementally',
110 ;;    `bmkp-bmenu-isearch-marked-bookmarks' (Emacs 23+),
111 ;;    `bmkp-bmenu-isearch-marked-bookmarks-regexp' (Emacs 23+),
112 ;;    `bmkp-bmenu-make-sequence-from-marked', `bmkp-bmenu-mark-all',
113 ;;    `bmkp-bmenu-mark-autofile-bookmarks',
114 ;;    `bmkp-bmenu-mark-bookmark-file-bookmarks',
115 ;;    `bmkp-bmenu-mark-bookmarks-satisfying',
116 ;;    `bmkp-bmenu-mark-bookmarks-tagged-all',
117 ;;    `bmkp-bmenu-mark-bookmarks-tagged-none',
118 ;;    `bmkp-bmenu-mark-bookmarks-tagged-not-all',
119 ;;    `bmkp-bmenu-mark-bookmarks-tagged-regexp',
120 ;;    `bmkp-bmenu-mark-bookmarks-tagged-some',
121 ;;    `bmkp-bmenu-mark-desktop-bookmarks',
122 ;;    `bmkp-bmenu-mark-dired-bookmarks',
123 ;;    `bmkp-bmenu-mark-file-bookmarks',
124 ;;    `bmkp-bmenu-mark-gnus-bookmarks',
125 ;;    `bmkp-bmenu-mark-info-bookmarks',
126 ;;    `bmkp-bmenu-mark-lighted-bookmarks',
127 ;;    `bmkp-bmenu-mark-man-bookmarks',
128 ;;    `bmkp-bmenu-mark-non-file-bookmarks',
129 ;;    `bmkp-bmenu-mark-region-bookmarks',
130 ;;    `bmkp-bmenu-mark-specific-buffer-bookmarks',
131 ;;    `bmkp-bmenu-mark-specific-file-bookmarks',
132 ;;    `bmkp-bmenu-mark-url-bookmarks',
133 ;;    `bmkp-bmenu-mark-w3m-bookmarks', `bmkp-bmenu-mouse-3-menu',
134 ;;    `bmkp-bmenu-mode-status-help', `bmkp-bmenu-omit',
135 ;;    `bmkp-bmenu-omit-marked', `bmkp-bmenu-omit/unomit-marked',
136 ;;    `bmkp-bmenu-paste-add-tags',
137 ;;    `bmkp-bmenu-paste-add-tags-to-marked',
138 ;;    `bmkp-bmenu-paste-replace-tags',
139 ;;    `bmkp-bmenu-paste-replace-tags-for-marked',
140 ;;    `bmkp-bmenu-query-replace-marked-bookmarks-regexp',
141 ;;    `bmkp-bmenu-quit', `bmkp-bmenu-refresh-menu-list',
142 ;;    `bmkp-bmenu-regexp-mark', `bookmark-bmenu-relocate' (Emacs 20,
143 ;;    21), `bmkp-bmenu-remove-all-tags', `bmkp-bmenu-remove-tags',
144 ;;    `bmkp-bmenu-remove-tags-from-marked',
145 ;;    `bmkp-bmenu-search-marked-bookmarks-regexp',
146 ;;    `bmkp-bmenu-set-tag-value',
147 ;;    `bmkp-bmenu-set-tag-value-for-marked', `bmkp-bmenu-show-all',
148 ;;    `bmkp-bmenu-show-only-autofiles',
149 ;;    `bmkp-bmenu-show-only-autonamed.',
150 ;;    `bmkp-bmenu-show-only-bookmark-files',
151 ;;    `bmkp-bmenu-show-only-desktops', `bmkp-bmenu-show-only-dired',
152 ;;    `bmkp-bmenu-show-only-files', `bmkp-bmenu-show-only-gnus',
153 ;;    `bmkp-bmenu-show-only-info-nodes',
154 ;;    `bmkp-bmenu-show-only-man-pages',
155 ;;    `bmkp-bmenu-show-only-non-files',
156 ;;    `bmkp-bmenu-show-only-omitted', `bmkp-bmenu-show-only-regions',
157 ;;    `bmkp-bmenu-show-only-specific-buffer',
158 ;;    `bmkp-bmenu-show-only-specific-file',
159 ;;    `bmkp-bmenu-show-only-tagged', `bmkp-bmenu-show-only-urls',
160 ;;    `bmkp-bmenu-show-only-variable-lists',
161 ;;    `bmkp-bmenu-show-only-w3m-urls',
162 ;;    `bmkp-bmenu-sort-by-bookmark-name',
163 ;;    `bmkp-bmenu-sort-by-bookmark-visit-frequency',
164 ;;    `bmkp-bmenu-sort-by-creation-time',
165 ;;    `bmkp-bmenu-sort-by-file-name',
166 ;;    `bmkp-bmenu-sort-by-Gnus-thread',
167 ;;    `bmkp-bmenu-sort-by-Info-location',
168 ;;    `bmkp-bmenu-sort-by-last-bookmark-access',
169 ;;    `bmkp-bmenu-sort-by-last-buffer-or-file-access',
170 ;;    `bmkp-bmenu-sort-by-last-local-file-access',
171 ;;    `bmkp-bmenu-sort-by-last-local-file-update',
172 ;;    `bmkp-bmenu-sort-by-local-file-size',
173 ;;    `bmkp-bmenu-sort-by-local-file-type', `bmkp-bmenu-sort-by-url',
174 ;;    `bmkp-bmenu-sort-marked-before-unmarked',
175 ;;    `bmkp-bmenu-toggle-marks', `bmkp-bmenu-toggle-show-only-marked',
176 ;;    `bmkp-bmenu-toggle-show-only-unmarked', `bmkp-bmenu-unmark-all',
177 ;;    `bmkp-bmenu-unmark-bookmarks-tagged-all',
178 ;;    `bmkp-bmenu-unmark-bookmarks-tagged-none',
179 ;;    `bmkp-bmenu-unmark-bookmarks-tagged-not-all',
180 ;;    `bmkp-bmenu-unmark-bookmarks-tagged-regexp',
181 ;;    `bmkp-bmenu-unmark-bookmarks-tagged-some',
182 ;;    `bmkp-bmenu-unomit-marked', `bmkp-bmenu-w32-open',
183 ;;    `bmkp-bmenu-w32-open-select', `bmkp-bmenu-w32-open-with-mouse',
184 ;;    `bmkp-define-tags-sort-command'.
185 ;;
186 ;;  Faces defined here:
187 ;;
188 ;;    `bmkp->-mark', `bmkp-a-mark', `bmkp-bad-bookmark',
189 ;;    `bmkp-bookmark-file', `bmkp-bookmark-list', `bmkp-buffer',
190 ;;    `bmkp-D-mark', `bmkp-desktop', `bmkp-function', `bmkp-gnus',
191 ;;    `bmkp-heading', `bmkp-info', `bmkp-local-directory',
192 ;;    `bmkp-local-file-with-region', `bmkp-local-file-without-region',
193 ;;    `bmkp-man', `bmkp-non-file', `bmkp-remote-file',
194 ;;    `bmkp-sequence', `bmkp-su-or-sudo', `bmkp-t-mark', `bmkp-url',
195 ;;    `bmkp-variable-list'.
196 ;;
197 ;;  User options defined here:
198 ;;
199 ;;    `bmkp-bmenu-commands-file', `bmkp-bmenu-omitted-bookmarks',
200 ;;    `bmkp-bmenu-state-file', `bmkp-propertize-bookmark-names-flag',
201 ;;    `bmkp-sort-orders-alist', `bmkp-sort-orders-for-cycling-alist'.
202 ;;
203 ;;  Non-interactive functions defined here:
204 ;;
205 ;;    `bmkp-bmenu-barf-if-not-in-menu-list',
206 ;;    `bmkp-bmenu-cancel-incremental-filtering',
207 ;;    `bmkp-bmenu-filter-alist-by-annotation-regexp',
208 ;;    `bmkp-bmenu-filter-alist-by-bookmark-name-regexp',
209 ;;    `bmkp-bmenu-filter-alist-by-file-name-regexp',
210 ;;    `bmkp-bmenu-filter-alist-by-tags-regexp',
211 ;;    `bmkp-bmenu-get-marked-files', `bmkp-bmenu-goto-bookmark-named',
212 ;;    `bmkp-bmenu-list-1',
213 ;;    `bmkp-bmenu-mark/unmark-bookmarks-tagged-all/none',
214 ;;    `bmkp-bmenu-mark/unmark-bookmarks-tagged-some/not-all',
215 ;;    `bmkp-bmenu-propertize-item', `bmkp-bmenu-read-filter-input',
216 ;;    `bmkp-maybe-unpropertize-bookmark-names',
217 ;;    `bmkp-reverse-multi-sort-order', `bmkp-reverse-sort-order'.
218 ;;
219 ;;  Internal variables defined here:
220 ;;
221 ;;    `bmkp-bmenu-before-hide-marked-alist',
222 ;;    `bmkp-bmenu-before-hide-unmarked-alist',
223 ;;    `bmkp-bmenu-define-command-menu', `bmkp-bmenu-filter-function',
224 ;;    `bmkp-bmenu-filter-pattern', `bmkp-bmenu-filter-prompt',
225 ;;    `bmkp-bmenu-filter-timer', `bmkp-bmenu-first-time-p',
226 ;;    `bmkp-bmenu-header-lines', `bmkp-bmenu-highlight-menu',
227 ;;    `bmkp-bmenu-line-overlay', `bmkp-bmenu-mark-menu',
228 ;;    `bmkp-bmenu-marked-bookmarks', `bmkp-bmenu-marks-width',
229 ;;    `bmkp-bmenu-menubar-menu', `bmkp-bmenu-omit-menu',
230 ;;    `bmkp-bmenu-show-menu', `bmkp-bmenu-sort-menu',
231 ;;    `bmkp-bmenu-tags-menu', `bmkp-bmenu-title',
232 ;;    `bmkp-bookmark-file-history', `bmkp-bookmark-list-history',
233 ;;    `bmkp-current-bookmark-file', `bmkp-current-nav-bookmark',
234 ;;    `bmkp-desktop-history', `bmkp-dired-history',
235 ;;    `bmkp-file-history', `bmkp-gnus-history', `bmkp-highlight-menu',
236 ;;    `bmkp-info-history', `bmkp-isearch-bookmarks' (Emacs 23+),
237 ;;    `bmkp-jump-display-function', `bmkp-jump-map', `bmkp-jump-menu',
238 ;;    `bmkp-jump-other-window-map', `bmkp-last-bmenu-bookmark'.
239 ;;
240 ;;
241 ;;  ***** NOTE: The following commands defined in `bookmark.el'
242 ;;              have been REDEFINED HERE:
243 ;;
244 ;;    `bookmark-bmenu-execute-deletions', `bookmark-bmenu-list',
245 ;;    `bookmark-bmenu-mark', `bookmark-bmenu-1-window',
246 ;;    `bookmark-bmenu-2-window', `bookmark-bmenu-other-window',
247 ;;    `bookmark-bmenu-other-window-with-mouse',
248 ;;    `bookmark-bmenu-this-window', `bookmark-bmenu-rename',
249 ;;    `bookmark-bmenu-show-annotation',
250 ;;    `bookmark-bmenu-switch-other-window', `bookmark-bmenu-unmark'.
251 ;;
252 ;;
253 ;;  ***** NOTE: The following non-interactive functions defined in
254 ;;              `bookmark.el' have been REDEFINED HERE:
255 ;;
256 ;;    `bookmark-bmenu-bookmark', `bookmark-bmenu-check-position',
257 ;;    `bookmark-bmenu-delete', `bookmark-bmenu-ensure-position' (Emacs
258 ;;    23.2+), `bookmark-bmenu-hide-filenames', `bookmark-bmenu-mode',
259 ;;    `bookmark-bmenu-show-filenames',
260 ;;    `bookmark-bmenu-surreptitiously-rebuild-list',
261 ;;    `bookmark-bmenu-switch-other-window' (Emacs 20-22).
262 ;;
263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
264 ;; 
265 ;; This program is free software; you can redistribute it and/or
266 ;; modify it under the terms of the GNU General Public License as
267 ;; published by the Free Software Foundation; either version 3, or
268 ;; (at your option) any later version.
269 ;; 
270 ;; This program is distributed in the hope that it will be useful,
271 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
272 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
273 ;; General Public License for more details.
274 ;; 
275 ;; You should have received a copy of the GNU General Public License
276 ;; along with this program; see the file COPYING.  If not, write to
277 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
278 ;; Floor, Boston, MA 02110-1301, USA.
279 ;; 
280 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
281 ;; 
282 ;;; Code:
283
284 ;;;;;;;;;;;;;;;;;;;;;;;
285
286 (eval-when-compile (require 'cl)) ;; case
287
288 (require 'bookmark)
289 ;; bookmark-alist, bookmark-bmenu-file-column,
290 ;; bookmark-bmenu-hidden-bookmarks, bookmark-bmenu-mode-map,
291 ;; bookmark-bmenu-select, bookmark-bmenu-toggle-filenames,
292 ;; bookmark-get-annotation, bookmark-get-bookmark,
293 ;; bookmark-get-filename, bookmark-get-handler, bookmark-kill-line,
294 ;; bookmark-maybe-load-default-file, bookmark-name-from-full-record,
295 ;; bookmark-name-from-record, bookmark-prop-get,
296 ;; bookmark-show-annotation, bookmark-store
297
298 ;;; Fix incompatibility introduced by gratuitous Emacs name change.
299 (cond ((and (fboundp 'bookmark-name-from-record) (not (fboundp 'bookmark-name-from-full-record)))
300        (defalias 'bookmark-name-from-full-record 'bookmark-name-from-record))
301       ((and (fboundp 'bookmark-name-from-full-record) (not (fboundp 'bookmark-name-from-record)))
302        (defalias 'bookmark-name-from-record 'bookmark-name-from-full-record)))
303
304 (require 'bookmark+-mac) ;; bmkp-define-sort-command
305
306 ;; (eval-when-compile (require 'bookmark+-1))
307 ;; bmkp-add-tags, bmkp-alpha-p, bmkp-bookmark-creation-cp,
308 ;; bmkp-bookmark-description, bmkp-bookmark-file-bookmark-p,
309 ;; bmkp-bookmark-last-access-cp, bmkp-bookmark-list-bookmark-p,
310 ;; bmkp-buffer-last-access-cp, bmkp-completing-read-buffer-name,
311 ;; bmkp-completing-read-file-name, bmkp-current-bookmark-file,
312 ;; bmkp-current-sort-order, bmkp-describe-bookmark,
313 ;; bmkp-describe-bookmark-internals, bmkp-desktop-bookmark-p,
314 ;; bmkp-edit-bookmark, bmkp-face-prop, bmkp-file-alpha-cp,
315 ;; bmkp-file-remote-p, bmkp-function-bookmark-p, bmkp-get-buffer-name,
316 ;; bmkp-get-tags, bmkp-gnus-bookmark-p, bmkp-gnus-cp, bmkp-handler-cp,
317 ;; bmkp-incremental-filter-delay, bmkp-info-bookmark-p, bmkp-info-cp,
318 ;; bmkp-isearch-bookmarks, bmkp-isearch-bookmarks-regexp, bmkp-jump-1,
319 ;; bmkp-last-bookmark-file, bmkp-last-specific-buffer,
320 ;; bmkp-last-specific-file, bmkp-latest-bookmark-alist,
321 ;; bmkp-local-file-bookmark-p, bmkp-local-file-type-cp,
322 ;; bmkp-local-file-accessed-more-recently-cp,
323 ;; bmkp-local-file-updated-more-recently-cp, bmkp-man-bookmark-p,
324 ;; bmkp-marked-bookmark-p, bmkp-marked-bookmarks-only, bmkp-marked-cp,
325 ;; bmkp-msg-about-sort-order, bmkp-non-file-filename,
326 ;; bmkp-read-tag-completing, bmkp-read-tags-completing,
327 ;; bmkp-refresh-menu-list, bmkp-region-bookmark-p,
328 ;; bmkp-remove-all-tags, bmkp-remove-if, bmkp-remove-tags,
329 ;; bmkp-repeat-command, bmkp-reverse-multi-sort-p,
330 ;; bmkp-reverse-sort-p, bmkp-root-or-sudo-logged-p, bmkp-same-file-p,
331 ;; bmkp-save-menu-list-state, bmkp-sequence-bookmark-p,
332 ;; bmkp-set-tag-value, bmkp-set-tag-value-for-bookmarks,
333 ;; bmkp-set-union, bmkp-some, bmkp-some-marked-p,
334 ;; bmkp-some-unmarked-p, bmkp-sort-omit, bmkp-sort-comparer, bmkp-sorted-alist,
335 ;; bmkp-sort-orders-for-cycling-alist, bmkp-su-or-sudo-regexp,
336 ;; bmkp-tag-name, bmkp-tags-list, bmkp-url-bookmark-p, bmkp-url-cp,
337 ;; bmkp-unmarked-bookmarks-only, bmkp-variable-list-bookmark-p,
338 ;; bmkp-visited-more-cp
339
340 ;; (eval-when-compile (require 'bookmark+-lit nil t))
341 ;; bmkp-get-lighting
342
343 ;;;;;;;;;;;;;;;;;;;;;;;
344
345 ;; Quiet the byte-compiler
346 (defvar dired-re-mark)                      ; Defined in `dired.el'.
347 (defvar tramp-file-name-regexp)             ; Defined in `tramp.el'.
348
349 (defvar bmkp-sort-orders-alist)             ; Defined in `bookmark+-1.el'.
350 (defvar bmkp-sort-orders-for-cycling-alist) ; Defined in `bookmark+-1.el'.
351  
352 ;;(@* "Faces (Customizable)")
353 ;;; Faces (Customizable) ---------------------------------------------
354
355 (defgroup bookmark-plus nil
356   "Bookmark enhancements."
357   :prefix "bmkp-" :group 'bookmark
358   :link `(url-link :tag "Send Bug Report"
359           ,(concat "mailto:" "drew.adams" "@" "oracle" ".com?subject=\
360 Bookmark+ bug: \
361 &body=Describe bug here, starting with `emacs -q'.  \
362 Don't forget to mention your Emacs and library versions."))
363   :link '(url-link :tag "Download" "http://www.emacswiki.org/bookmark+.el")
364   :link '(url-link :tag "Description" "http://www.emacswiki.org/BookmarkPlus")
365   :link '(emacs-commentary-link :tag "Commentary" "bookmark+"))
366
367 (defface bmkp->-mark '((((background dark)) (:foreground "Yellow"))
368                        (t (:foreground "Blue")))
369   ;; (:foreground "Magenta2" :box (:line-width 1 :style pressed-button))))
370   "*Face used for a `>' mark in the bookmark list."
371   :group 'bookmark-plus :group 'faces)
372
373 (defface bmkp-a-mark '((((background dark)) (:background "SaddleBrown"))
374                        (t (:background "SkyBlue")))
375   "*Face used for an annotation mark (`a') in the bookmark list."
376   :group 'bookmark-plus :group 'faces)
377
378 (defface bmkp-bad-bookmark '((t (:foreground "Red" :background "Chartreuse1")))
379   "*Face used for a bookmark that seems to be bad: e.g., nonexistent file."
380   :group 'bookmark-plus :group 'faces)
381
382 (defface bmkp-bookmark-file
383     '((((background dark))
384        (:foreground "#00005A5AFFFF" :background "#FFFF9B9BFFFF")) ; ~ blue, ~ pink
385       (t (:foreground "Orange" :background "DarkGreen")))
386   "*Face used for a bookmark-file bookmark."
387   :group 'bookmark-plus :group 'faces)
388
389 (defface bmkp-bookmark-list
390     '((((background dark)) (:foreground "#7474FFFFFFFF" :background "DimGray")) ; ~ cyan
391       (t (:foreground "DarkRed" :background "LightGray")))
392   "*Face used for a bookmark-list bookmark."
393   :group 'bookmark-plus :group 'faces)
394
395 (defface bmkp-buffer
396     '((((background dark)) (:foreground "#FFFF9B9BFFFF")) ; ~ pink
397       (t (:foreground "DarkGreen")))
398   "*Face used for a bookmarked existing buffer not associated with a file."
399   :group 'bookmark-plus :group 'faces)
400
401 (defface bmkp-D-mark '((t (:foreground "Yellow" :background "Red")))
402   "*Face used for a deletion mark (`D') in the bookmark list."
403   :group 'bookmark-plus :group 'faces)
404
405 (defface bmkp-desktop
406     '((((background dark)) (:foreground "Orange" :background "DarkSlateBlue"))
407       (t (:foreground "DarkBlue" :background "PaleGoldenrod")))
408   "*Face used for a bookmarked desktop."
409   :group 'bookmark-plus :group 'faces)
410
411 (defface bmkp-function
412     '((((background dark)) (:foreground "#0000EBEB6C6C")) ; ~ green
413       (t (:foreground "DeepPink1")))
414   "*Face used for a function bookmark: a bookmark that invokes a function."
415   :group 'bookmark-plus :group 'faces)
416
417 (defface bmkp-gnus
418     '((((background dark)) (:foreground "Gold"))
419       (t (:foreground "DarkBlue")))
420   "*Face used for a gnus bookmark."
421   :group 'bookmark-plus :group 'faces)
422
423 (defface bmkp-info
424     '((((background dark)) (:foreground "#7474FFFFFFFF")) ; ~ light cyan
425       (t (:foreground "DarkRed")))
426   "*Face used for a bookmarked Info node."
427   :group 'bookmark-plus :group 'faces)
428
429 (defface bmkp-local-directory
430     '((((background dark))
431        (:foreground "Pink" :background "DarkBlue"))
432       (t (:foreground "DarkBlue" :background "HoneyDew2")))
433   "*Face used for a bookmarked local directory."
434   :group 'bookmark-plus :group 'faces)
435
436 (defface bmkp-local-file-without-region
437     '((((background dark)) (:foreground "White"))
438       (t (:foreground "Black")))
439   "*Face used for a bookmarked local file (without a region)."
440   :group 'bookmark-plus :group 'faces)
441
442 (defface bmkp-local-file-with-region
443     '((((background dark)) (:foreground "Yellow"))
444       (t (:foreground "Blue")))
445   "*Face used for a region bookmark in a local file."
446   :group 'bookmark-plus :group 'faces)
447
448 (defface bmkp-man
449     '((((background dark)) (:foreground "Orchid"))
450       (t (:foreground "Orange4")))
451   "*Face used for a `man' page bookmark."
452   :group 'bookmark-plus :group 'faces)
453
454 (defface bmkp-non-file
455     '((t (:foreground "gray60")))
456   "*Face used for a bookmark not associated with an existing file or buffer."
457   :group 'bookmark-plus :group 'faces)
458
459 (defface bmkp-remote-file
460     '((((background dark)) (:foreground "#6B6BFFFF2C2C")) ; ~ green
461       (t (:foreground "DarkViolet")))
462   "*Face used for a bookmarked tramp remote file (/ssh:)."
463   :group 'bookmark-plus :group 'faces)
464
465 (defface bmkp-sequence
466     '((((background dark)) (:foreground "DeepSkyBlue"))
467       (t (:foreground "DarkOrange2")))
468   "*Face used for a sequence bookmark: one composed of other bookmarks."
469   :group 'bookmark-plus :group 'faces)
470
471 (defface bmkp-su-or-sudo '((t (:foreground "Red")))
472   "*Face used for a bookmarked tramp file (/su: or /sudo:)."
473   :group 'bookmark-plus :group 'faces)
474
475 (defface bmkp-t-mark '((t (:foreground "Red")))
476   "*Face used for a tags mark (`t') in the bookmark list."
477   :group 'bookmark-plus :group 'faces)
478
479 (defface bmkp-url
480     '((((background dark)) (:foreground "#7474FFFF7474")) ; ~ green
481       (t (:foreground "DarkMagenta")))
482   "*Face used for a bookmarked URL."
483   :group 'bookmark-plus :group 'faces)
484
485 (defface bmkp-variable-list
486     '((((background dark)) (:foreground "#FFFF74747474")) ; ~ salmon
487       (t (:foreground "DarkCyan")))
488   "*Face used for a bookmarked list of variables."
489   :group 'bookmark-plus :group 'faces)
490
491 ;; $$$$$$ Not used now - using `bmkp-url' instead.
492 ;; (defface bmkp-w3m
493 ;;     '((((background dark)) (:foreground "yellow"))
494 ;;       (t (:foreground "DarkMagenta")))
495 ;;   "*Face used for a bookmarked w3m url."
496 ;;   :group 'bookmark-plus :group 'faces)
497
498 ;; Instead of vanilla `bookmark-menu-heading' (defined in Emacs 22+), to use a better default.
499 (defface bmkp-heading '((((background dark)) (:foreground "Yellow"))
500                         (t (:foreground "Blue")))
501   "*Face used to highlight the headings in various Bookmark+ buffers."
502   :group 'bookmark-plus :version "22.1" :group 'faces)
503  
504 ;;(@* "User Options (Customizable)")
505 ;;; User Options (Customizable) --------------------------------------
506
507 ;;;###autoload
508 (defcustom bmkp-bmenu-omitted-bookmarks ()
509   "*List of names of omitted bookmarks.
510 They are generally not available for display in the bookmark list.
511 You can, however, use \\<bookmark-bmenu-mode-map>\
512 `\\[bmkp-bmenu-show-only-omitted]' to see them.
513 You can then mark some of them and use `\\[bmkp-bmenu-omit/unomit-marked]'
514  to make those that are marked available again for the bookmark list."
515   :type '(repeat (string :tag "Bookmark name")) :group 'bookmark-plus)
516
517 ;;;###autoload
518 (defcustom bmkp-bmenu-commands-file (convert-standard-filename "~/.emacs-bmk-bmenu-commands.el")
519   "*File for saving user-defined bookmark-list commands.
520 This must be an absolute file name (possibly containing `~') or nil
521 \(it is not expanded).
522
523 You can use `\\[bmkp-list-defuns-in-commands-file]' to list the
524 commands defined in the file and how many times each is defined.
525
526 NOTE: Each time you define a command using \\<bookmark-bmenu-mode-map>\
527 `\\[bmkp-bmenu-define-command]', `\\[bmkp-bmenu-define-full-snapshot-command]', \
528 `\\[bmkp-bmenu-define-jump-marked-command], or `\\[bmkp-define-tags-sort-command]',
529 it is saved in the file.  The new definition is simply appended to the
530 file - old definitions of the same command are not overwritten.  So
531 you might want to clean up the file occasionally, to remove any old,
532 unused definitions.  This is especially advisable if you used \
533 `\\[bmkp-bmenu-define-full-snapshot-command]',
534 because such command definitions can be very large."
535   :type '(file  :tag "File for saving menu-list state") :group 'bookmark-plus)
536
537 ;;;###autoload
538 (defcustom bmkp-bmenu-state-file (convert-standard-filename "~/.emacs-bmk-bmenu-state.el")
539   "*File for saving `*Bookmark List*' state when you quit bookmark list.
540 This must be an absolute file name (possibly containing `~') or nil
541 \(it is not expanded).
542
543 The state is also saved when you quit Emacs, even if you don't quit
544 the bookmark list first (using \\<bookmark-bmenu-mode-map>`\\[bmkp-bmenu-quit]').
545
546 Set this to nil if you do not want to restore the bookmark list as it
547 was the last time you used it."
548   :type '(choice
549           (const :tag "Do not save and restore menu-list state" nil)
550           (file  :tag "File for saving menu-list state"))
551   :group 'bookmark-plus)
552
553 ;; This is a general option.  It is in this file because it is used mainly by the bmenu code.
554 (when (> emacs-major-version 20)
555   (defcustom bmkp-sort-orders-alist ()
556     "*Alist of all available sort functions.
557 This is a pseudo option - you probably do NOT want to customize this.
558 Instead:
559
560  * To add a new sort function to this list, use macro
561    `bmkp-define-sort-command'.  It defines a new sort function
562    and automatically adds it to this list.
563
564  * To have fewer sort orders available for cycling by \\<bookmark-bmenu-mode-map>\
565 `\\[bmkp-bmenu-change-sort-order-repeat]'...,
566    customize option `bmkp-sort-orders-for-cycling-alist'.
567
568 Each alist element has the form (SORT-ORDER . COMPARER):
569
570  SORT-ORDER is a short string or symbol describing the sort order.
571  Examples: \"by last access time\", \"by bookmark name\".
572
573  COMPARER compares two bookmarks.  It must be acceptable as a value of
574  `bmkp-sort-comparer'."
575     :type '(alist
576             :key-type (choice :tag "Sort order" string symbol)
577             :value-type (choice
578                          (const    :tag "None (do not sort)" nil)
579                          (function :tag "Sorting Predicate")
580                          (list     :tag "Sorting Multi-Predicate"
581                           (repeat (function :tag "Component Predicate"))
582                           (choice
583                            (const    :tag "None" nil)
584                            (function :tag "Final Predicate")))))
585     :group 'bookmark-plus))
586
587 (unless (> emacs-major-version 20)      ; Emacs 20: custom type `alist' doesn't exist.
588   (defcustom bmkp-sort-orders-alist ()
589     "*Alist of all available sort functions.
590 This is a pseudo option - you probably do NOT want to customize this.
591 Instead:
592
593  * To add a new sort function to this list, use macro
594    `bmkp-define-sort-command'.  It defines a new sort function
595    and automatically adds it to this list.
596
597  * To have fewer sort orders available for cycling by \\<bookmark-bmenu-mode-map>\
598 `\\[bmkp-bmenu-change-sort-order-repeat]'...,
599    customize option `bmkp-sort-orders-for-cycling-alist'.
600
601 Each alist element has the form (SORT-ORDER . COMPARER):
602
603  SORT-ORDER is a short string or symbol describing the sort order.
604  Examples: \"by last access time\", \"by bookmark name\".
605
606  COMPARER compares two bookmarks.  It must be acceptable as a value of
607  `bmkp-sort-comparer'."
608     :type '(repeat
609             (cons
610              (choice :tag "Sort order" string symbol)
611              (choice
612               (const    :tag "None (do not sort)" nil)
613               (function :tag "Sorting Predicate")
614               (list     :tag "Sorting Multi-Predicate"
615                (repeat (function :tag "Component Predicate"))
616                (choice
617                 (const    :tag "None" nil)
618                 (function :tag "Final Predicate"))))))
619     :group 'bookmark-plus))
620
621 (defcustom bmkp-propertize-bookmark-names-flag (> emacs-major-version 20)
622   "*Non-nil means to propertize bookmark names to hold full bookmark data.
623 This means that you can effectively have more than one bookmark with
624 the same name.
625
626 Emacs 20 users: If you need to use your bookmarks with Emacs 20 then
627 set this to nil.  In particular, if your bookmark file was written
628 with this as non-nil, then it contains propertized strings which are
629 unreadable by Emacs 20.  To convert the file to be usable with Emacs
630 20 you must, in Emacs 21 or later, set this to nil and then do `M-x
631 bookmark-save'."
632   :type 'boolean :group 'bookmark-plus)
633  
634 ;;(@* "Internal Variables")
635 ;;; Internal Variables -----------------------------------------------
636
637 (defconst bmkp-bmenu-header-lines 2
638   "Number of lines used for the `*Bookmark List*' header.")
639
640 (defconst bmkp-bmenu-marks-width 4
641   "Number of columns (chars) used for the `*Bookmark List*' marks columns.")
642
643 (defvar bmkp-bmenu-marked-bookmarks ()
644   "Names of the marked bookmarks.
645 This includes possibly omitted bookmarks, that is, bookmarks listed in
646 `bmkp-bmenu-omitted-bookmarks'.")
647
648 (defvar bmkp-bmenu-before-hide-unmarked-alist ()
649   "Copy of `bookmark-alist' made before hiding unmarked bookmarks.")
650
651 (defvar bmkp-bmenu-before-hide-marked-alist ()
652   "Copy of `bookmark-alist' made before hiding marked bookmarks.")
653
654 (defvar bmkp-bmenu-filter-function  nil "Latest filtering function for `*Bookmark List*' display.")
655
656 (defvar bmkp-bmenu-title "" "Latest title for `*Bookmark List*' display.")
657
658 (defvar bmkp-bmenu-filter-pattern "" "Regexp for incremental filtering.")
659
660 (defvar bmkp-bmenu-filter-prompt "Pattern: " "Prompt for `bmkp-bmenu-filter-incrementally'.")
661
662 (defvar bmkp-bmenu-filter-timer nil "Timer used for incremental filtering.")
663
664 (defvar bmkp-bmenu-first-time-p t
665   "Non-nil means bookmark list has not yet been shown after quitting it.
666 Quitting the list or the Emacs session resets this to t.
667 The first time the list is displayed, it is set to nil.")
668
669 ;; This is a general variable.  It is in this file because it is used only in the bmenu code.
670 (defvar bmkp-last-bmenu-bookmark nil "The name of the last bookmark current in the bookmark list.")
671  
672 ;;(@* "Compatibility Code for Older Emacs Versions")
673 ;;; Compatibility Code for Older Emacs Versions ----------------------
674
675 (when (< emacs-major-version 22)
676   (defun bookmark-bmenu-relocate ()
677     "Change the file path of the bookmark on the current line,
678   prompting with completion for the new path."
679     (interactive)
680     (let ((bmk        (bookmark-bmenu-bookmark))
681           (thispoint  (point)))
682       (bookmark-relocate bmk)
683       (goto-char thispoint))))
684  
685 ;;(@* "Menu List Replacements (`bookmark-bmenu-*')")
686 ;;; Menu List Replacements (`bookmark-bmenu-*') ----------------------
687
688
689
690 ;; REPLACES ORIGINAL in `bookmark.el'.
691 ;;
692 ;; 1. Return t.  Value doesn't mean anything (didn't anyway), but must be non-nil for vanilla Emacs.
693 ;; 2. Do not count lines.  Just make sure we're on a bookmark line.
694 ;;
695 (defalias 'bookmark-bmenu-check-position 'bookmark-bmenu-ensure-position)
696 (defun bookmark-bmenu-ensure-position ()
697   "Move to the beginning of the nearest bookmark line."
698   (beginning-of-line)
699   (unless (bookmark-bmenu-bookmark)
700     (if (and (bolp) (eobp))
701         (beginning-of-line 0)
702       (goto-char (point-min))
703       (forward-line bmkp-bmenu-header-lines)))
704   t)                                    ; Older vanilla bookmark code depends on non-nil value.
705
706
707 ;; REPLACES ORIGINAL in `bookmark.el'.
708 ;;
709 ;; 1. Add bookmark to `bmkp-bmenu-marked-bookmarks'.
710 ;; 2. Don't call `bookmark-bmenu-ensure-position' again at end.
711 ;; 3. Raise error if not in `*Bookmark List*'.
712 ;;
713 ;;;###autoload
714 (defun bookmark-bmenu-mark ()           ; Bound to `m' in bookmark list
715   "Mark the bookmark on this line, using mark `>'."
716   (interactive)
717   (bmkp-bmenu-barf-if-not-in-menu-list)
718   (bookmark-bmenu-ensure-position)
719   (beginning-of-line)
720   (let ((inhibit-read-only  t))
721     (push (bookmark-bmenu-bookmark) bmkp-bmenu-marked-bookmarks)
722     (delete-char 1) (insert ?>) (put-text-property (1- (point)) (point) 'face 'bmkp->-mark)
723     (forward-line 1)))
724
725
726 ;; REPLACES ORIGINAL in `bookmark.el'.
727 ;;
728 ;; 1. Remove bookmark from `bmkp-bmenu-marked-bookmarks'.
729 ;; 2. Use `bmkp-delete-bookmark-name-from-list', not `delete'.
730 ;; 3. Don't call `bookmark-bmenu-ensure-position' again at end.
731 ;; 4. Raise error if not in `*Bookmark List*'.
732 ;;
733 ;;;###autoload
734 (defun bookmark-bmenu-unmark (&optional backup) ; Bound to `u' in bookmark list
735   "Unmark the bookmark on this line, then move down to the next.
736 Optional BACKUP means move up instead."
737   (interactive "P")
738   (bmkp-bmenu-barf-if-not-in-menu-list)
739   (bookmark-bmenu-ensure-position)
740   (beginning-of-line)
741   (let ((inhibit-read-only  t))
742     (delete-char 1) (insert " ")
743     (setq bmkp-bmenu-marked-bookmarks  (bmkp-delete-bookmark-name-from-list
744                                         (bookmark-bmenu-bookmark) bmkp-bmenu-marked-bookmarks)))
745   (forward-line (if backup -1 1)))
746
747
748 ;; REPLACES ORIGINAL in `bookmark.el'.
749 ;;
750 ;; 1. Do not use `bookmark-bmenu-ensure-position' as a test - it always returns non-nil anyway.
751 ;;    And don't call it at again the end.
752 ;; 2. Use `bmkp-delete-bookmark-name-from-list', not `delete'.
753 ;; 3. Use face `bmkp-bad-bookmark' on the `D' flag.
754 ;; 4. Raise error if not in buffer `*Bookmark List*'.
755 ;; 5. Remove bookmark from `bmkp-bmenu-marked-bookmarks'.
756 ;;
757 ;;;###autoload
758 (defun bookmark-bmenu-delete ()         ; Bound to `d', `k' in bookmark list
759   "Flag this bookmark for deletion, using mark `D'.
760 Use `\\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-execute-deletions]' to carry out \
761 the deletions."
762   (interactive)
763   (bmkp-bmenu-barf-if-not-in-menu-list)
764   (beginning-of-line)
765   (bookmark-bmenu-ensure-position)
766   (let ((inhibit-read-only  t))
767     (delete-char 1) (insert ?D) (put-text-property (1- (point)) (point) 'face 'bmkp-D-mark))
768   (setq bmkp-bmenu-marked-bookmarks  (bmkp-delete-bookmark-name-from-list
769                                       (bookmark-bmenu-bookmark) bmkp-bmenu-marked-bookmarks))
770   (forward-line 1))
771
772
773 ;; REPLACES ORIGINAL in `bookmark.el'.
774 ;;
775 ;; 1. Rebuild the menu list using the last filtered alist in use, `bmkp-latest-bookmark-alist'.
776 ;; 2. Update the menu-list title.
777 ;;
778 (defun bookmark-bmenu-surreptitiously-rebuild-list ()
779   "Rebuild the bookmark list, if it exists."
780   (when (get-buffer "*Bookmark List*")
781     (save-excursion (save-window-excursion (let ((bookmark-alist  bmkp-latest-bookmark-alist))
782                                              (bookmark-bmenu-list 'filteredp))))))
783
784
785 ;; REPLACES ORIGINAL in `bookmark.el'.
786 ;;
787 ;; 1. Added args TITLE, FILTEREDP, DONT-TOGGLE-FILENAMES-P.
788 ;; 2. Handles also region bookmarks and buffer (non-file) bookmarks.
789 ;; 3. Uses `pop-to-buffer', not `switch-to-buffer', so we respect `special-display-*'
790 ;;    (but keep `one-window-p' if that's the case).
791 ;; 4. If option `bmkp-bmenu-state-file' is non-nil, then the first time since the last quit
792 ;;     (or the last Emacs session) restores the last menu-list state.
793 ;; 5. If option `bmkp-bmenu-commands-file' is non-nil, then read that file, which contains
794 ;;    user-defined `*Bookmark List*' commands.
795 ;;
796 ;;;###autoload
797 (defalias 'list-bookmarks 'bookmark-bmenu-list)
798 ;;;###autoload
799 (defun bookmark-bmenu-list (&optional filteredp) ; Bound to `C-x r l'
800   "Display a list of existing bookmarks, in buffer `*Bookmark List*'.
801 The leftmost column of a bookmark entry shows `D' if the bookmark is
802  flagged for deletion, or `>' if it is marked normally.
803 The second column shows `t' if the bookmark has tags.
804 The third  column shows `a' if the bookmark has an annotation.
805
806 The following faces are used for the list entries.
807 Use `customize-face' if you want to change the appearance.
808
809  `bmkp-bad-bookmark', `bmkp-bookmark-list', `bmkp-buffer',
810  `bmkp-desktop', `bmkp-function', `bmkp-gnus', `bmkp-info',
811  `bmkp-local-directory', `bmkp-local-file-without-region',
812  `bmkp-local-file-with-region', `bmkp-man', `bmkp-non-file',
813  `bmkp-remote-file', `bmkp-sequence', `bmkp-su-or-sudo', `bmkp-url',
814  `bmkp-variable-list'.
815
816 If option `bmkp-bmenu-state-file' is non-nil then the state of the
817 displayed bookmark-list is saved when you quit it, and it is restored
818 when you next use this command.  That saved state is not restored,
819 however, if it represents a different file from the current bookmark
820 file.
821
822 If you call this interactively when buffer `*Bookmark List*' exists,
823 that buffer is refreshed to show all current bookmarks, and any
824 markings are removed.  If you instead want to show the buffer in its
825 latest state then just do that: use `C-x b' or similar.  If you want
826 to refresh the displayed buffer, to show the latest state, reflecting
827 any additions, deletions, renamings, and so on, use \\<bookmark-bmenu-mode-map>\
828 `\\[bmkp-bmenu-refresh-menu-list]'.
829
830 In Lisp code, non-nil optional argument FILTEREDP means the bookmark
831 list has been filtered, which means:
832  * Use `bmkp-bmenu-title' not the default menu-list title.
833  * Do not reset `bmkp-latest-bookmark-alist' to `bookmark-alist'."
834   (interactive)
835   (bookmark-maybe-load-default-file)
836   (when (and bmkp-bmenu-first-time-p bmkp-bmenu-commands-file
837              (file-readable-p bmkp-bmenu-commands-file))
838     (with-current-buffer (let ((enable-local-variables  ())
839                                (emacs-lisp-mode-hook    nil))
840                            (find-file-noselect bmkp-bmenu-commands-file))
841       (goto-char (point-min))
842       (while (not (eobp)) (condition-case nil (eval (read (current-buffer))) (error nil)))
843       (kill-buffer (current-buffer))))
844   (cond ((and bmkp-bmenu-first-time-p  bmkp-bmenu-state-file ; Restore from state file.
845               (file-readable-p bmkp-bmenu-state-file))
846          (let ((state  ()))
847            (with-current-buffer (let ((enable-local-variables  nil)
848                                       (emacs-lisp-mode-hook    nil))
849                                   (find-file-noselect bmkp-bmenu-state-file))
850              (goto-char (point-min))
851              (setq state  (condition-case nil (read (current-buffer)) (error nil)))
852              (kill-buffer (current-buffer)))
853            (let ((last-bookmark-file-from-state  (cdr (assq 'last-bookmark-file state))))
854              (when (and (consp state)
855                         ;; If bookmark file has changed, then do not use state saved from other file.
856                         (or (not last-bookmark-file-from-state)
857                             (bmkp-same-file-p last-bookmark-file-from-state
858                                               bmkp-current-bookmark-file)))
859                (setq bmkp-sort-comparer                (cdr (assq 'last-sort-comparer           state))
860                      bmkp-reverse-sort-p               (cdr (assq 'last-reverse-sort-p          state))
861                      bmkp-reverse-multi-sort-p         (cdr (assq 'last-reverse-multi-sort-p    state))
862                      bmkp-latest-bookmark-alist        (cdr (assq 'last-latest-bookmark-alist   state))
863                      bmkp-bmenu-omitted-bookmarks      (cdr (assq 'last-bmenu-omitted-bookmarks state))
864                      bmkp-bmenu-marked-bookmarks       (cdr (assq 'last-bmenu-marked-bookmarks  state))
865                      bmkp-bmenu-filter-function        (cdr (assq 'last-bmenu-filter-function   state))
866                      bmkp-bmenu-filter-pattern
867                      (or (cdr (assq 'last-bmenu-filter-pattern   state)) "")
868                      bmkp-bmenu-title                  (cdr (assq 'last-bmenu-title             state))
869                      bmkp-last-bmenu-bookmark          (cdr (assq 'last-bmenu-bookmark          state))
870                      bmkp-last-specific-buffer         (cdr (assq 'last-specific-buffer         state))
871                      bmkp-last-specific-file           (cdr (assq 'last-specific-file           state))
872                      bookmark-bmenu-toggle-filenames   (cdr (assq 'last-bmenu-toggle-filenames  state))
873                      bmkp-last-bookmark-file           bmkp-current-bookmark-file
874                      bmkp-current-bookmark-file        last-bookmark-file-from-state
875                      bmkp-bmenu-before-hide-marked-alist
876                      (cdr (assq 'last-bmenu-before-hide-marked-alist   state))
877                      bmkp-bmenu-before-hide-unmarked-alist
878                      (cdr (assq 'last-bmenu-before-hide-unmarked-alist state))))))
879          (setq bmkp-bmenu-first-time-p  nil)
880          (let ((bookmark-alist  (or bmkp-latest-bookmark-alist bookmark-alist)))
881            (bmkp-bmenu-list-1 'filteredp nil (interactive-p)))
882          (when bmkp-last-bmenu-bookmark
883            (with-current-buffer (get-buffer "*Bookmark List*")
884              (bmkp-bmenu-goto-bookmark-named bmkp-last-bmenu-bookmark))))
885         (t
886          (setq bmkp-bmenu-first-time-p  nil)
887          (bmkp-bmenu-list-1 filteredp
888                             (or (interactive-p) (not (get-buffer "*Bookmark List*")))
889                             (interactive-p)))))
890
891 (defun bmkp-bmenu-list-1 (filteredp reset-marked-p interactivep)
892   "Helper for `bookmark-bmenu-list'.
893 See `bookmark-bmenu-list' for the description of FILTEREDP.
894 Non-nil RESET-MARKED-P resets `bmkp-bmenu-marked-bookmarks'.
895 Non-nil INTERACTIVEP means `bookmark-bmenu-list' was called
896  interactively, so pop to the bookmark list and communicate the sort
897  order."
898   (when reset-marked-p (setq bmkp-bmenu-marked-bookmarks  ()))
899   (unless filteredp (setq bmkp-latest-bookmark-alist  bookmark-alist))
900   (if interactivep
901       (let ((one-win-p  (one-window-p)))
902         (pop-to-buffer (get-buffer-create "*Bookmark List*"))
903         (when one-win-p (delete-other-windows)))
904     (set-buffer (get-buffer-create "*Bookmark List*")))
905   (let* ((inhibit-read-only  t)
906          (title              (if (and filteredp bmkp-bmenu-title (not (equal "" bmkp-bmenu-title)))
907                                  bmkp-bmenu-title
908                                "All Bookmarks")))
909     (erase-buffer)
910     (insert (format "%s\n%s\n" title (make-string (length title) ?-)))
911     (add-text-properties (point-min) (point) (bmkp-face-prop 'bmkp-heading))
912     (let ((max-width  0)
913           name markedp tags annotation start)
914       (setq bmkp-sorted-alist  (bmkp-sort-omit bookmark-alist
915                                                (and (not (eq bmkp-bmenu-filter-function
916                                                              'bmkp-omitted-alist-only))
917                                                     bmkp-bmenu-omitted-bookmarks)))
918       (dolist (bmk  bmkp-sorted-alist)
919         (setq max-width  (max max-width (length (bookmark-name-from-full-record bmk)))))
920       (setq max-width  (+ max-width bmkp-bmenu-marks-width))
921       (dolist (bmk  bmkp-sorted-alist)
922         (setq name        (bookmark-name-from-full-record bmk)
923               markedp     (bmkp-marked-bookmark-p bmk)
924               tags        (bmkp-get-tags bmk)
925               annotation  (bookmark-get-annotation bmk)
926               start       (+ bmkp-bmenu-marks-width (point)))
927         (if (not markedp)
928             (insert " ")
929           (insert ">") (put-text-property (1- (point)) (point) 'face 'bmkp->-mark))
930         (if (null tags)
931             (insert " ")
932           (insert "t") (put-text-property (1- (point)) (point) 'face 'bmkp-t-mark))
933         (if (not (and annotation (not (string-equal annotation ""))))
934             (insert " ")
935           (insert "a") (put-text-property (1- (point)) (point) 'face 'bmkp-a-mark))
936         (insert " ")
937         (when (and (featurep 'bookmark+-lit) (bmkp-get-lighting bmk)) ; Highlight highlight overrides.
938           (put-text-property (1- (point)) (point) 'face 'bmkp-light-mark))
939         (insert name)
940         (move-to-column max-width t)
941         (bmkp-bmenu-propertize-item bmk start (point))
942         (insert "\n")))
943     (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
944     (bookmark-bmenu-mode)
945     (when bookmark-bmenu-toggle-filenames (bookmark-bmenu-toggle-filenames t))
946     (when (and (fboundp 'fit-frame-if-one-window)
947                (eq (selected-window) (get-buffer-window (get-buffer-create "*Bookmark List*") 0)))
948       (fit-frame-if-one-window)))
949   (when (and interactivep bmkp-sort-comparer)
950     (bmkp-msg-about-sort-order (bmkp-current-sort-order))))
951
952
953 ;; REPLACES ORIGINAL in `bookmark.el'.
954 ;;
955 ;; Redefined.  
956 ;; 1. Get name of the current bookmark from text property `bmkp-bookmark-name'.
957 ;; 2. Added optional arg FULL, to return full bookmark record.
958 ;; 3. Use `condition-case' in case we're at eob (so cannot advance).
959 ;;
960 (defun bookmark-bmenu-bookmark (&optional full)
961   "Return the name of the bookmark on this line.
962 Normally, the string returned is propertized with property
963 `bmkp-full-record', which records the full bookmark record.
964 Non-nil optional FULL means return the bookmark record, not the name."
965   (condition-case nil
966       (let ((name  (save-excursion (forward-line 0) (forward-char (1+ bmkp-bmenu-marks-width))
967                                    (get-text-property (point) 'bmkp-bookmark-name))))
968         (if full
969             (get-text-property 0 'bmkp-full-record name)
970           name))
971     (error nil)))
972
973
974 ;; REPLACES ORIGINAL in `bookmark.el'.
975 ;;
976 ;; Only the doc string is different.
977 ;;
978 (defun bookmark-bmenu-mode ()
979   "Major mode for editing a list of bookmarks.
980 Each line represents an Emacs bookmark.\\<bookmark-bmenu-mode-map>
981
982 More bookmarking help below.  Keys without prefix `C-x' are available
983 only in buffer `*Bookmark List*'.  Others are available everywhere.
984
985
986 Help (Describe)
987 ---------------
988
989 \\[bmkp-bmenu-describe-this-bookmark]\t- Show information about this bookmark (`C-u': \
990 internal form)
991 \\[bmkp-bmenu-describe-this+move-down]\t- Show the info, then move to next bookmark
992 \\[bmkp-bmenu-describe-this+move-up]\t- Show the info, then move to previous bookmark
993 \\[bmkp-bmenu-describe-marked]\t- Show info about the marked bookmarks (`C-u': internal form)
994 \\[bookmark-bmenu-locate]\t- Show the location of this bookmark in the minibuffer
995 \\[bookmark-bmenu-show-annotation]\t- Show this bookmark's annotation
996 \\[bookmark-bmenu-show-all-annotations]\t- Show the annotations of all annotated bookmarks
997 \\[bookmark-bmenu-toggle-filenames]\t- Toggle showing filenames next to bookmarks
998
999 \\[bmkp-list-defuns-in-commands-file]
1000 \t- List the commands defined in `bmkp-bmenu-commands-file'
1001
1002
1003 General
1004 -------
1005
1006 \\[bmkp-bmenu-refresh-menu-list]\t- Refresh (revert) to up-to-date bookmark list
1007 \\[bmkp-bmenu-quit]\t- Quit (`*Bookmark List*')
1008 \\[bmkp-bmenu-dired-marked]\t- Open Dired for the marked files and directories
1009
1010 \\[bookmark-bmenu-load]\t- Add bookmarks from a different bookmark file (extra load)
1011 \\[bmkp-switch-bookmark-file]\t- Switch to a different bookmark file      (overwrite load)
1012 C-u \\[bmkp-switch-bookmark-file]\t- Switch back to the last bookmark file    (overwrite load)
1013 \\[bmkp-set-bookmark-file-bookmark]\t- Create a bookmark to a bookmark file \
1014 \(`\\[bmkp-bookmark-file-jump]' to load)
1015
1016 \\[bmkp-toggle-saving-bookmark-file]\t- Toggle autosaving the bookmark file
1017 \\[bmkp-toggle-saving-menu-list-state]\t- Toggle autosaving bookmark-list display state (this list)
1018 \\[bookmark-bmenu-save]\t- Save bookmarks (`C-u': prompt for the bookmark file to use)
1019 \\[bmkp-save-menu-list-state]\t- Save bookmark-list display state
1020
1021 \\[bmkp-choose-navlist-of-type]\t- Set the navlist to the bookmarks of a type you choose
1022 \\[bmkp-choose-navlist-from-bookmark-list]\t- Set the navlist to the bookmarks of a \
1023 bookmark-list bookmark
1024 \\[bmkp-navlist-bmenu-list]\t- Open `*Bookmark List*' for bookmarks in navlist
1025 \\[bmkp-this-buffer-bmenu-list]\t- Open `*Bookmark List*' for bookmarks in current buffer
1026 \\[bmkp-delete-bookmarks]\t- Delete some bookmarks at point or all in buffer
1027
1028 \\[bmkp-toggle-bookmark-set-refreshes]
1029 \t- Toggle whether `bookmark-set' refreshes the bookmark list
1030 \\[bmkp-make-function-bookmark]
1031 \t- Create a function bookmark
1032 \\[bmkp-bmenu-make-sequence-from-marked]
1033 \t- Create a sequence bookmark from the marked bookmarks
1034
1035
1036 Create/Set
1037 ----------
1038
1039 \\[bmkp-toggle-autonamed-bookmark-set/delete]\t- Set/delete an autonamed bookmark here
1040 \\[bmkp-autofile-set]\t- Set and autoname a bookmark for a file
1041 \\[bmkp-file-target-set]\t- Set a bookmark for a file
1042 \\[bmkp-url-target-set]\t- Set a bookmark for a URL
1043 \\[bookmark-set]\t- Set a bookmark here
1044 \\[bmkp-set-desktop-bookmark]\t- Set a bookmark for the current desktop
1045 \\[bmkp-set-bookmark-file-bookmark]\t- Set a bookmark for a bookmark file
1046
1047
1048 Jump to (Visit)
1049 ---------------
1050
1051 \\[bookmark-bmenu-select]\t- This bookmark and also visit bookmarks marked `>'
1052 \\[bookmark-bmenu-this-window]\t- This bookmark in the same window
1053 \\[bookmark-bmenu-other-window]\t- This bookmark in another window
1054 \\[bookmark-bmenu-switch-other-window]\t- This bookmark in other window, without selecting it
1055 \\[bookmark-bmenu-1-window]\t- This bookmark in a full-frame window
1056 \\[bookmark-bmenu-2-window]\t- This bookmark and last-visited bookmark
1057
1058 \\[bookmark-jump]\t- Bookmark by name
1059 \\[bmkp-jump-to-type]\t- Bookmark by type
1060 \\[bmkp-jump-in-navlist]\t- Bookmark in the navigation list
1061 \\[bmkp-lighted-jump]\t- Highlighted bookmark
1062 \\[bmkp-desktop-jump]\t- Desktop bookmark
1063 \\[bmkp-bookmark-list-jump]\t- Bookmark-list bookmark
1064 \\[bmkp-bookmark-file-jump]\t- Bookmark-file bookmark
1065 \\[bmkp-dired-jump]\t- Dired bookmark
1066 \\[bmkp-file-jump]\t- File or directory bookmark
1067 \\[bmkp-dired-this-dir-jump]\t- Dired bookmark for this dir
1068 \\[bmkp-file-this-dir-jump]\t- Bookmark for a file or subdir in this dir
1069 \\[bmkp-local-file-jump]\t- Local-file bookmark
1070 \\[bmkp-remote-file-jump]\t- Remote-file bookmark
1071 \\[bmkp-region-jump]\t- Region bookmark
1072 \\[bmkp-info-jump]\t- Info bookmark
1073 \\[bmkp-man-jump]\t- `man'-page bookmark
1074 \\[bmkp-non-file-jump]\t- Non-file (buffer) bookmark
1075 \\[bmkp-gnus-jump]\t- Gnus bookmark
1076 \\[bmkp-url-jump]\t- URL bookmark
1077 \\[bmkp-variable-list-jump]\t- Variable-list bookmark
1078 \\[bmkp-autonamed-jump]\t- Autonamed bookmark
1079 \\[bmkp-autonamed-this-buffer-jump]\t- Autonamed bookmark in buffer
1080 \\[bmkp-some-tags-jump]\t- Bookmark having some tags you specify
1081 \\[bmkp-all-tags-jump]\t- Bookmark having each tag you specify
1082 \\[bmkp-some-tags-regexp-jump]\t- Bookmark having a tag that matches a regexp
1083 \\[bmkp-all-tags-regexp-jump]\t- Bookmark having all its tags match a regexp
1084 \\[bmkp-file-some-tags-jump]\t- File bookmark having some tags you specify
1085 \\[bmkp-file-all-tags-jump]\t- File bookmark having each tag you specify
1086 \\[bmkp-file-some-tags-regexp-jump]\t- File bookmark having a tag that matches a regexp
1087 \\[bmkp-file-all-tags-regexp-jump]\t- File bookmark having all its tags match a regexp
1088 \\[bmkp-file-this-dir-some-tags-jump]\t- File in this dir having some tags you specify
1089 \\[bmkp-file-this-dir-all-tags-jump]\t- File in this dir having each tag you specify
1090 \\[bmkp-file-this-dir-some-tags-regexp-jump]\t- File in this dir having a tag that matches a regexp
1091 \\[bmkp-file-this-dir-all-tags-regexp-jump]\t- File in this dir having all its tags match a regexp
1092
1093
1094 Cycle Bookmarks and Autonamed Bookmarks
1095 ---------------------------------------
1096
1097 \\[bmkp-toggle-autonamed-bookmark-set/delete]\t- Create/delete autonamed bookmark at point
1098 \\[bmkp-autonamed-jump]\t- Jump to an autonamed bookmark
1099 \\[bmkp-autonamed-this-buffer-jump]\t- Jump to an autonamed bookmark in buffer
1100 C-x p n n ...\t- Next     bookmark in buffer  (C-x p C-n, C-x p down)
1101 C-x p p p ...\t- Previous bookmark in buffer  (C-x p C-p, C-x p up)
1102 C-x p f f ...\t- Next     bookmark in navlist (C-x p C-f, C-x p right)
1103 C-x p b b ...\t- Previous bookmark in navlist (C-x p C-b, C-x p left)
1104 C-x p next  ...\t- MS Windows `Open' next     bookmark in navlist
1105 C-x p prior ...\t- MS Windows `Open' previous bookmark in navlist
1106 C-x C-down  ...\t- Next     highlighted bookmark in buffer
1107 C-x C-up    ...\t- Previous highlighted bookmark in buffer
1108
1109 \\[bmkp-delete-all-autonamed-for-this-buffer]
1110 \t- Delete all autonamed bookmarks in current buffer
1111
1112
1113 Search-and-Replace Targets (in sort order)
1114 --------------------------
1115
1116 M-s a C-s\t- Isearch the marked bookmarks (Emacs 23+)
1117 M-s a C-M-s\t- Regexp-isearch the marked bookmarks (Emacs 23+)
1118 \\[bmkp-bmenu-search-marked-bookmarks-regexp]\t- Regexp-search the marked file bookmarks
1119 \\[bmkp-bmenu-query-replace-marked-bookmarks-regexp]\t\t- Query-replace the marked file \
1120 bookmarks
1121
1122
1123 Mark/Unmark
1124 -----------
1125
1126 \(Mark means `>'.  Flag means `D'.   See also `Tags', below.)
1127
1128 \\[bookmark-bmenu-delete]\t- Flag this bookmark `D' for deletion, then move down
1129 \\[bookmark-bmenu-delete-backwards]\t- Flag this bookmark `D' for deletion, then move up
1130
1131 \\[bookmark-bmenu-mark]\t- Mark this bookmark
1132 \\[bookmark-bmenu-unmark]\t- Unmark this bookmark (`C-u': move up one line)
1133 \\[bookmark-bmenu-backup-unmark]\t- Unmark previous bookmark (move up, then unmark)
1134
1135 \\[bmkp-bmenu-mark-all]\t- Mark all bookmarks
1136 \\[bmkp-bmenu-regexp-mark]\t- Mark all bookmarks whose names match a regexp
1137 \\[bmkp-bmenu-unmark-all]\t- Unmark all bookmarks (`C-u': interactive query)
1138 \\[bmkp-bmenu-toggle-marks]\t- Toggle marks: unmark the marked and mark the unmarked
1139
1140 \\[bmkp-bmenu-mark-autofile-bookmarks]\t- Mark autofile bookmarks
1141 \\[bmkp-bmenu-mark-non-file-bookmarks]\t- Mark non-file (i.e. buffer) bookmarks
1142 \\[bmkp-bmenu-mark-dired-bookmarks]\t- Mark Dired bookmarks
1143 \\[bmkp-bmenu-mark-file-bookmarks]\t- Mark file & directory bookmarks (`C-u': local only)
1144 \\[bmkp-bmenu-mark-gnus-bookmarks]\t- Mark Gnus bookmarks
1145 \\[bmkp-bmenu-mark-lighted-bookmarks]\t- Mark the highlighted bookmarks
1146 \\[bmkp-bmenu-mark-info-bookmarks]\t- Mark Info bookmarks
1147 \\[bmkp-bmenu-mark-desktop-bookmarks]\t- Mark desktop bookmarks
1148 \\[bmkp-bmenu-mark-bookmark-file-bookmarks]\t- Mark bookmark-file bookmarks
1149 \\[bmkp-bmenu-mark-man-bookmarks]\t- Mark `man' page bookmarks (that's `M' twice, not Meta-M)
1150 \\[bmkp-bmenu-mark-region-bookmarks]\t- Mark region bookmarks
1151 \\[bmkp-bmenu-mark-url-bookmarks]\t- Mark URL bookmarks
1152 \\[bmkp-bmenu-mark-w3m-bookmarks]\t- Mark W3M (URL) bookmarks
1153
1154
1155 Modify
1156 ------
1157
1158 \(See also `Tags', next.)
1159
1160 \\[bookmark-bmenu-edit-annotation]\t- Edit this bookmark's annotation
1161 \\[bmkp-bmenu-edit-bookmark]\t- Rename and relocate this bookmark
1162 \\[bookmark-bmenu-rename]\t- Rename this bookmark
1163 \\[bookmark-bmenu-relocate]\t- Relocate this bookmark (change file)
1164 \\[bmkp-bmenu-edit-tags]\t- Edit this bookmark's tags
1165 \\[bookmark-bmenu-execute-deletions]\t- Delete (visible) bookmarks flagged `D'
1166 \\[bmkp-bmenu-delete-marked]\t- Delete (visible) bookmarks marked `>'
1167
1168
1169 Tags
1170 ----
1171
1172 \\[bmkp-add-tags]\t- Add some tags to a bookmark
1173 \\[bmkp-remove-tags]\t- Remove some tags from a bookmark
1174 \\[bmkp-remove-all-tags]\t- Remove all tags from a bookmark
1175 \\[bmkp-remove-tags-from-all]\t- Remove some tags from all bookmarks
1176 \\[bmkp-rename-tag]\t- Rename a tag in all bookmarks
1177 \\[bmkp-list-all-tags]\t- List all tags used in any bookmarks (`C-u': show tag values)
1178 \\[bmkp-bmenu-edit-tags]\t- Edit this bookmark's tags
1179 \\[bmkp-bmenu-set-tag-value]\t- Set the value of a tag (as attribute)
1180
1181 \\[bmkp-bmenu-add-tags-to-marked]\t- Add some tags to the marked bookmarks
1182 \\[bmkp-bmenu-remove-tags-from-marked]\t- Remove some tags from the marked bookmarks
1183
1184 \\[bmkp-bmenu-mark-bookmarks-tagged-regexp]\t- Mark bookmarks having at least one \
1185 tag that matches a regexp
1186 \\[bmkp-bmenu-mark-bookmarks-tagged-some]\t- Mark bookmarks having at least one tag \
1187 in a set    (OR)
1188 \\[bmkp-bmenu-mark-bookmarks-tagged-all]\t- Mark bookmarks having all of the tags \
1189 in a set     (AND)
1190 \\[bmkp-bmenu-mark-bookmarks-tagged-none]\t- Mark bookmarks not having any of the tags \
1191 in a set (NOT OR)
1192 \\[bmkp-bmenu-mark-bookmarks-tagged-not-all]\t- Mark bookmarks not having all of the \
1193 tags in a set (NOT AND)
1194
1195 \\[bmkp-bmenu-unmark-bookmarks-tagged-regexp]\t- Unmark bookmarks having at least one \
1196 tag that matches a regexp
1197 \\[bmkp-bmenu-unmark-bookmarks-tagged-some]\t- Unmark bookmarks having at least one \
1198 tag in a set  (OR)
1199 \\[bmkp-bmenu-unmark-bookmarks-tagged-all]\t- Unmark bookmarks having all of the tags \
1200 in a set   (AND)
1201 \\[bmkp-bmenu-unmark-bookmarks-tagged-none]\t- Unmark bookmarks not having any tags \
1202 in a set      (NOT OR)
1203 \\[bmkp-bmenu-unmark-bookmarks-tagged-not-all]\t- Unmark bookmarks not having all tags \
1204 in a set      (NOT AND)
1205
1206
1207 Bookmark Highlighting
1208 ---------------------
1209
1210 \\[bmkp-bmenu-show-only-lighted]\t- Show only the highlighted bookmarks
1211 \\[bmkp-bmenu-set-lighting]\t- Set highlighting for this bookmark
1212 \\[bmkp-bmenu-set-lighting-for-marked]\t- Set highlighting for marked bookmarks
1213 \\[bmkp-bmenu-light]\t- Highlight this bookmark
1214 \\[bmkp-bmenu-unlight]\t- Unhighlight this bookmark
1215 \\[bmkp-bmenu-mark-lighted-bookmarks]\t- Mark the highlighted bookmarks
1216 \\[bmkp-bmenu-light-marked]\t- Highlight the marked bookmarks
1217 \\[bmkp-bmenu-unlight-marked]\t- Unhighlight the marked bookmarks
1218 \\[bmkp-light-bookmark-this-buffer]\t- Highlight a bookmark in current buffer
1219 \\[bmkp-unlight-bookmark-this-buffer]\t- Unhighlight a bookmark in current buffer
1220 \\[bmkp-light-bookmarks]\t- Highlight bookmarks (see prefix arg)
1221 \\[bmkp-unlight-bookmarks]\t- Unhighlight bookmarks (see prefix arg)
1222 \\[bmkp-bookmarks-lighted-at-point]\t- List bookmarks highlighted at point
1223 \\[bmkp-unlight-bookmark-here]\t- Unhighlight a bookmark at point or on same line
1224
1225
1226 Sort
1227 ----
1228
1229 \(Repeat to cycle normal/reversed/off, except as noted.)
1230
1231 \\[bmkp-bmenu-sort-marked-before-unmarked]\t- Sort marked bookmarks first
1232 \\[bmkp-bmenu-sort-by-last-buffer-or-file-access]\t- Sort by last buffer or file \
1233 access
1234 \\[bmkp-bmenu-sort-by-Gnus-thread]\t- Sort by Gnus thread: group, article, message
1235 \\[bmkp-bmenu-sort-by-Info-location]\t- Sort by Info manual, node, position
1236 \\[bmkp-bmenu-sort-by-bookmark-type]\t- Sort by bookmark type
1237 \\[bmkp-bmenu-sort-by-bookmark-name]\t- Sort by bookmark name
1238 \\[bmkp-bmenu-sort-by-creation-time]\t- Sort by bookmark creation time
1239 \\[bmkp-bmenu-sort-by-last-bookmark-access]\t- Sort by last bookmark access time
1240 \\[bmkp-bmenu-sort-by-bookmark-visit-frequency]\t- Sort by bookmark visit frequency
1241 \\[bmkp-bmenu-sort-by-url]\t- Sort by URL
1242
1243 \\[bmkp-bmenu-sort-by-local-file-type]\t- Sort by local file type: file, symlink, dir
1244 \\[bmkp-bmenu-sort-by-file-name]\t- Sort by file name
1245 \\[bmkp-bmenu-sort-by-local-file-size]\t- Sort by local file size
1246 \\[bmkp-bmenu-sort-by-last-local-file-access]\t- Sort by last local file access
1247 \\[bmkp-bmenu-sort-by-last-local-file-update]\t- Sort by last local file update (edit)
1248
1249 \\[bmkp-reverse-sort-order]\t- Reverse current sort direction       (repeat to toggle)
1250 \\[bmkp-reverse-multi-sort-order]\t- Complement sort predicate decisions  (repeat \
1251 to toggle)
1252 \\[bmkp-bmenu-change-sort-order-repeat]\t- Cycle sort orders                    (repeat \
1253 to cycle)
1254
1255
1256 Hide/Show
1257 ---------
1258
1259 \\[bmkp-bmenu-show-all]\t- Show all bookmarks
1260 \\[bmkp-bmenu-toggle-show-only-marked]\t- Toggle showing only marked bookmarks
1261 \\[bmkp-bmenu-toggle-show-only-unmarked]\t- Toggle showing only unmarked bookmarks
1262 \\[bmkp-bmenu-show-only-autofiles]\t- Show only autofile bookmarks
1263 \\[bmkp-bmenu-show-only-autonamed]\t- Show only autonamed bookmarks
1264 \\[bmkp-bmenu-show-only-non-files]\t- Show only non-file (i.e. buffer) bookmarks
1265 \\[bmkp-bmenu-show-only-dired]\t- Show only Dired bookmarks
1266 \\[bmkp-bmenu-show-only-files]\t- Show only file & directory bookmarks (`C-u': local only)
1267 \\[bmkp-bmenu-show-only-gnus]\t- Show only Gnus bookmarks
1268 \\[bmkp-bmenu-show-only-info-nodes]\t- Show only Info bookmarks
1269 \\[bmkp-bmenu-show-only-desktops]\t- Show only desktop bookmarks
1270 \\[bmkp-bmenu-show-only-bookmark-files]\t- Show only bookmark-file bookmarks
1271 \\[bmkp-bmenu-show-only-man-pages]\t- Show only `man' page bookmarks
1272 \\[bmkp-bmenu-show-only-regions]\t- Show only region bookmarks
1273 \\[bmkp-bmenu-show-only-variable-lists]\t- Show only variable-list bookmarks
1274 \\[bmkp-bmenu-show-only-urls]\t- Show only URL bookmarks
1275 \\[bmkp-bmenu-show-only-w3m-urls]\t- Show only W3M (URL) bookmarks
1276 \\[bmkp-bmenu-filter-bookmark-name-incrementally]\t- Incrementally show only bookmarks \
1277 whose names match a regexp
1278 \\[bmkp-bmenu-filter-file-name-incrementally]\t- Incrementally show only bookmarks whose \
1279 files match a regexp
1280 \\[bmkp-bmenu-filter-annotation-incrementally]\t- Incrementally show only bookmarks whose \
1281 annotations match a regexp
1282 \\[bmkp-bmenu-filter-tags-incrementally]\t- Incrementally show only bookmarks whose tags \
1283 match a regexp
1284 \\[bmkp-bmenu-show-only-tagged]\t- Show only bookmarks that have tags
1285
1286
1287 Omit/Un-omit
1288 ------------
1289
1290 \\[bmkp-bmenu-show-only-omitted]\t- Show (only) the omitted bookmarks
1291 \\[bmkp-bmenu-show-all]\t- Show the un-omitted bookmarks (all)
1292 \\[bmkp-bmenu-omit/unomit-marked]\t- Omit the marked bookmarks; un-omit them if after \
1293 `\\[bmkp-bmenu-show-only-omitted]'
1294 \\[bmkp-unomit-all]\t- Un-omit all omitted bookmarks
1295
1296
1297 Define Commands for `*Bookmark List*'
1298 -------------------------------------
1299
1300 \\[bmkp-bmenu-define-command]\t- Define a command to restore the current sort order & filter
1301 \\[bmkp-bmenu-define-full-snapshot-command]\t- Define a command to restore the current \
1302 bookmark-list state
1303 \\[bmkp-define-tags-sort-command]\t- Define a command to sort bookmarks by tags
1304 \\[bmkp-bmenu-define-jump-marked-command]\t- Define a command to jump to a bookmark that is \
1305 now marked
1306
1307
1308 Options for `*Bookmark List*'
1309 -----------------------------
1310
1311 bookmark-bmenu-file-column       - Bookmark width if files are shown
1312 bookmark-bmenu-toggle-filenames  - Show filenames initially?
1313
1314 bmkp-bmenu-omitted-bookmarks     - List of omitted bookmarks
1315 bmkp-bmenu-state-file            - File to save bookmark-list state
1316                                    (\"home\") nil: do not save/restore
1317 bmkp-sort-comparer               - Initial sort
1318 bmkp-sort-orders-for-cycling-alist
1319 \t - Sort orders that `\\[bmkp-bmenu-change-sort-order-repeat]'... cycles
1320
1321
1322 Other Options
1323 -------------
1324
1325 bookmark-automatically-show-annotations  - Show annotation when visit?
1326 bookmark-completion-ignore-case  - Case-sensitive completion?
1327 bookmark-default-file            - File to save bookmarks in
1328 bookmark-menu-length             - Max size of bookmark-name menu item
1329 bookmark-save-flag               - Whether and when to save
1330 bookmark-use-annotations         - Query for annotation when saving?
1331 bookmark-version-control         - Numbered backups of bookmark file?
1332
1333 bmkp-autoname-format        - Format of autonamed bookmark name
1334 bmkp-crosshairs-flag        - Highlight position when visit?
1335 bmkp-menu-popup-max-length  - Use menus to choose bookmarks?
1336 bmkp-save-new-location-flag - Save if bookmark relocated?
1337 bmkp-sequence-jump-display-function - How to display a sequence
1338 bmkp-sort-comparer          - Predicates for sorting bookmarks
1339 bmkp-su-or-sudo-regexp      - Bounce-show each end of region?
1340 bmkp-this-buffer-cycle-sort-comparer -  This-buffer cycling sort
1341 bmkp-use-region             - Activate saved region when visit?"
1342   (kill-all-local-variables)
1343   (use-local-map bookmark-bmenu-mode-map)
1344   (setq truncate-lines    t
1345         buffer-read-only  t
1346         major-mode        'bookmark-bmenu-mode
1347         mode-name         "Bookmark Menu")
1348   (if (fboundp 'run-mode-hooks)
1349       (run-mode-hooks 'bookmark-bmenu-mode-hook)
1350     (run-hooks 'bookmark-bmenu-mode-hook)))
1351
1352
1353 ;; REPLACES ORIGINAL in `bookmark.el'.
1354 ;;
1355 ;; 1. Put `mouse-face' on whole line, with the same help-echo as for the bookmark name.
1356 ;; 2. Fit one-window frame.
1357 ;; 3. Added doc string.
1358 ;;
1359 (defun bookmark-bmenu-show-filenames (&optional force)
1360   "Show file names."
1361   (if (and (not force) bookmark-bmenu-toggle-filenames)
1362       nil                               ; Already shown, so do nothing.
1363     (save-excursion
1364       (save-window-excursion
1365         (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
1366         (setq bookmark-bmenu-hidden-bookmarks  ())
1367         (let ((inhibit-read-only  t))
1368           (while (< (point) (point-max))
1369             (let ((bmk  (bookmark-bmenu-bookmark)))
1370               (setq bookmark-bmenu-hidden-bookmarks  (cons bmk bookmark-bmenu-hidden-bookmarks))
1371               (let ((start  (save-excursion (end-of-line) (point))))
1372                 (move-to-column bookmark-bmenu-file-column t))
1373               (delete-region (point) (progn (end-of-line) (point)))
1374               (insert "  ")
1375               (bookmark-insert-location bmk t) ; Pass the NO-HISTORY arg.
1376               (when (if (fboundp 'display-color-p) ; Emacs 21+.
1377                         (and (display-color-p) (display-mouse-p))
1378                       window-system)
1379                 (let ((help  (get-text-property (+ bmkp-bmenu-marks-width
1380                                                    (line-beginning-position)) 'help-echo)))
1381                   (put-text-property (+ bmkp-bmenu-marks-width (line-beginning-position))
1382                                      (point) 'mouse-face 'highlight)
1383                   (when help  (put-text-property (+ bmkp-bmenu-marks-width (line-beginning-position))
1384                                                  (point) 'help-echo help))))
1385               (forward-line 1))))))
1386     (when (and (fboundp 'fit-frame-if-one-window)
1387                (eq (selected-window) (get-buffer-window (get-buffer-create "*Bookmark List*") 0)))
1388       (fit-frame-if-one-window))))
1389
1390
1391 ;; REPLACES ORIGINAL in `bookmark.el'.
1392 ;;
1393 ;; 1. Add text properties when hiding filenames.
1394 ;; 2. Do not set or use `bookmark-bmenu-bookmark-column' - use `bmkp-bmenu-marks-width' always.
1395 ;; 3. Fit one-window frame.
1396 ;; 4. Added doc string.
1397 ;;
1398 (defun bookmark-bmenu-hide-filenames (&optional force)
1399   "Hide filenames in bookmark-list buffer.
1400 If either optional arg FORCE or `bookmark-bmenu-toggle-filenames' is
1401 non-nil, then do nothing."
1402   (when (and (not force)  bookmark-bmenu-toggle-filenames)
1403     (save-excursion
1404       (save-window-excursion
1405         (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
1406         (setq bookmark-bmenu-hidden-bookmarks  (nreverse bookmark-bmenu-hidden-bookmarks))
1407         (let ((max-width  0))
1408           (dolist (name  bookmark-bmenu-hidden-bookmarks)
1409             (setq max-width  (max max-width (length name))))
1410           (setq max-width  (+ max-width bmkp-bmenu-marks-width))
1411           (save-excursion
1412             (let ((inhibit-read-only  t))
1413               (while bookmark-bmenu-hidden-bookmarks
1414                 (move-to-column bmkp-bmenu-marks-width t)
1415                 (bookmark-kill-line)
1416                 (let ((name   (car bookmark-bmenu-hidden-bookmarks))
1417                       (start  (point))
1418                       end)
1419                   (insert name)
1420                   (move-to-column max-width t)
1421                   (setq end  (point))
1422                   (bmkp-bmenu-propertize-item name start end))
1423                 (setq bookmark-bmenu-hidden-bookmarks  (cdr bookmark-bmenu-hidden-bookmarks))
1424                 (forward-line 1)))))))
1425     (when (and (fboundp 'fit-frame-if-one-window)
1426                (eq (selected-window) (get-buffer-window (get-buffer-create "*Bookmark List*") 0)))
1427       (fit-frame-if-one-window))))
1428
1429
1430 ;; REPLACES ORIGINAL in `bookmark.el'.
1431 ;;
1432 ;; 1. Prefix arg reverses `bmkp-use-region'.
1433 ;; 2. Raise error if not in buffer `*Bookmark List*'.
1434 ;;
1435 ;;;###autoload
1436 (defun bookmark-bmenu-1-window (&optional use-region-p) ; Bound to `1' in bookmark list
1437   "Select this line's bookmark, alone, in full frame.
1438 See `bookmark-jump' for info about the prefix arg."
1439   (interactive "P")
1440   (bmkp-bmenu-barf-if-not-in-menu-list)
1441   (bookmark-bmenu-ensure-position)
1442   (bmkp-jump-1 (bookmark-bmenu-bookmark) 'pop-to-buffer use-region-p)
1443   (bury-buffer (other-buffer))
1444   (delete-other-windows))
1445
1446
1447 ;; REPLACES ORIGINAL in `bookmark.el'.
1448 ;;
1449 ;; 1. Prefix arg reverses `bmkp-use-region'.
1450 ;; 2. Raise error if not in buffer `*Bookmark List*'.
1451 ;;
1452 ;;;###autoload
1453 (defun bookmark-bmenu-2-window (&optional use-region-p) ; Bound to `2' in bookmark list
1454   "Select this line's bookmark, with previous buffer in second window.
1455 See `bookmark-jump' for info about the prefix arg."
1456   (interactive "P")
1457   (bmkp-bmenu-barf-if-not-in-menu-list)
1458   (bookmark-bmenu-ensure-position)
1459   (let ((bookmark-name   (bookmark-bmenu-bookmark))
1460         (menu            (current-buffer))
1461         (pop-up-windows  t))
1462     (delete-other-windows)
1463     (switch-to-buffer (other-buffer))
1464     ;; (let ((bookmark-automatically-show-annotations nil)) ; $$$$$$ Needed?
1465     (bmkp-jump-1 bookmark-name 'pop-to-buffer use-region-p)
1466     (bury-buffer menu)))
1467
1468
1469 ;; REPLACES ORIGINAL in `bookmark.el'.
1470 ;;
1471 ;; 1. Prefix arg reverses `bmkp-use-region'.
1472 ;; 2. Raise error if not in buffer `*Bookmark List*'.
1473 ;;
1474 ;;;###autoload
1475 (defun bookmark-bmenu-this-window (&optional use-region-p) ; Bound to `RET' in bookmark list
1476   "Select this line's bookmark in this window.
1477 See `bookmark-jump' for info about the prefix arg."
1478   (interactive "P")
1479   (bmkp-bmenu-barf-if-not-in-menu-list)
1480   (bookmark-bmenu-ensure-position)
1481   (let ((bookmark-name  (bookmark-bmenu-bookmark)))
1482     (bmkp-jump-1 bookmark-name 'switch-to-buffer use-region-p)))
1483
1484
1485 ;; REPLACES ORIGINAL in `bookmark.el'.
1486 ;;
1487 ;; 1. Use `pop-to-buffer', not `switch-to-buffer-other-window'.
1488 ;; 2. Prefix arg reverses `bmkp-use-region'.
1489 ;; 3. Raise error if not in buffer `*Bookmark List*'.
1490 ;;
1491 ;;;###autoload
1492 (defun bookmark-bmenu-other-window (&optional use-region-p) ; Bound to `o' in bookmark list
1493   "Select this line's bookmark in other window.  Show `*Bookmark List*' still.
1494 See `bookmark-jump' for info about the prefix arg."
1495   (interactive "P")
1496   (bmkp-bmenu-barf-if-not-in-menu-list)
1497   (bookmark-bmenu-ensure-position)
1498   (let ((bookmark-name  (bookmark-bmenu-bookmark)))
1499     ;; (bookmark-automatically-show-annotations  t)) ; $$$$$$ Needed?
1500     (bmkp-jump-1 bookmark-name 'bmkp-select-buffer-other-window use-region-p)))
1501
1502
1503 ;; REPLACES ORIGINAL in `bookmark.el'.
1504 ;;
1505 ;; 1. Prefix arg reverses `bmkp-use-region'.
1506 ;; 2. Raise error if not in buffer `*Bookmark List*'.
1507 ;;
1508 ;;;###autoload
1509 (defun bookmark-bmenu-switch-other-window (&optional use-region-p) ; Bound to `C-o' in bookmark list
1510   "Make the other window select this line's bookmark.
1511 The current window remains selected.
1512 See `bookmark-jump' for info about the prefix arg."
1513   (interactive "P")
1514   (bmkp-bmenu-barf-if-not-in-menu-list)
1515   (bookmark-bmenu-ensure-position)
1516   (let ((bookmark-name             (bookmark-bmenu-bookmark))
1517         (pop-up-windows            t)
1518         (same-window-buffer-names  ())
1519         (same-window-regexps       ()))
1520     ;; (bookmark-automatically-show-annotations t)) ; $$$$$$ Needed?
1521     (bmkp-jump-1 bookmark-name 'display-buffer use-region-p)))
1522
1523
1524 ;; REPLACES ORIGINAL in `bookmark.el'.
1525 ;;
1526 ;; 1. Prefix arg reverses `bmkp-use-region'.
1527 ;; 2. Raise error if not in buffer `*Bookmark List*'.
1528 ;;
1529 ;;;###autoload
1530 (defun bookmark-bmenu-other-window-with-mouse (event &optional use-region-p)
1531   "Select clicked bookmark in other window.  Show `*Bookmark List*' still."
1532   (interactive "e\nP")
1533   (with-current-buffer (window-buffer (posn-window (event-end event)))
1534     (save-excursion (goto-char (posn-point (event-end event)))
1535                     (bookmark-bmenu-other-window use-region-p))))
1536
1537
1538 ;; REPLACES ORIGINAL in `bookmark.el'.
1539 ;;
1540 ;; 1. Added optional arg MSGP.
1541 ;; 2. Call `bookmark-show-annotation' with arg MSGP.
1542 ;; 3. Raise error if not in buffer `*Bookmark List*'.
1543 ;;
1544 ;;;###autoload
1545 (defun bookmark-bmenu-show-annotation (msgp)
1546   "Show the annotation for the current bookmark in another window."
1547   (interactive "p")
1548   (bmkp-bmenu-barf-if-not-in-menu-list)
1549   (bookmark-bmenu-ensure-position)
1550   (let ((bookmark  (bookmark-bmenu-bookmark)))
1551     (bookmark-show-annotation bookmark msgp)))
1552
1553
1554 ;; REPLACES ORIGINAL in `bookmark.el'.
1555 ;;
1556 ;; 1. Added optional arg MARKEDP: handle bookmarks marked `>', not just those flagged `D'.
1557 ;; 2. Use `bookmark-bmenu-surreptitiously-rebuild-list', instead of using
1558 ;;    `bookmark-bmenu-list', updating the modification count, and saving.
1559 ;; 3. Update `bmkp-latest-bookmark-alist' to reflect the deletions.
1560 ;; 4. Pass full bookmark, not name, to `delete' (and do not use `assoc').
1561 ;; 5. Use `bmkp-bmenu-goto-bookmark-named'.
1562 ;; 6. Added status messages.
1563 ;; 7. Raise error if not in buffer `*Bookmark List*'.
1564 ;;
1565 ;;;###autoload
1566 (defun bookmark-bmenu-execute-deletions (&optional markedp) ; Bound to `x' in bookmark list
1567   "Delete (visible) bookmarks flagged `D'.
1568 With a prefix argument, delete the bookmarks marked `>' instead, after
1569 confirmation."
1570   (interactive "P")
1571   (bmkp-bmenu-barf-if-not-in-menu-list)
1572   (if (or (not markedp) (yes-or-no-p "Delete bookmarks marked `>' (not `D') "))
1573       (let* ((mark-type  (if markedp "^>" "^D"))
1574              (o-str      (and (not (looking-at mark-type)) (bookmark-bmenu-bookmark)))
1575              (o-point    (point))
1576              (count      0))
1577         (message "Deleting bookmarks...")
1578         (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
1579         (while (re-search-forward mark-type (point-max) t)
1580           (let* ((bmk-name  (bookmark-bmenu-bookmark))
1581                  (bmk       (bookmark-get-bookmark bmk-name)))
1582             (bookmark-delete bmk-name 'batch)
1583             (setq count                       (1+ count)
1584                   bmkp-latest-bookmark-alist  (delete bmk bmkp-latest-bookmark-alist))))
1585         (if (<= count 0)
1586             (message (if markedp "No marked bookmarks" "No bookmarks flagged for deletion"))
1587           (bookmark-bmenu-surreptitiously-rebuild-list)
1588           (message "Deleted %d bookmarks" count))
1589         (if o-str
1590             (bmkp-bmenu-goto-bookmark-named o-str)
1591           (goto-char o-point)
1592           (beginning-of-line)))
1593     (message "OK, nothing deleted")))
1594
1595
1596 ;; REPLACES ORIGINAL in `bookmark.el'.
1597 ;;
1598 ;; 1. Do not call `bookmark-bmenu-list' (it was already called).
1599 ;; 2. Raise error if not in buffer `*Bookmark List*'.
1600 ;; 3. Use `bmkp-bmenu-goto-bookmark-named' instead of just searching for name.
1601 ;;
1602 ;;;###autoload
1603 (defun bookmark-bmenu-rename ()         ; Bound to `r' in bookmark list
1604   "Rename bookmark on current line.  Prompts for a new name."
1605   (interactive)
1606   (bmkp-bmenu-barf-if-not-in-menu-list)
1607   (bookmark-bmenu-ensure-position)
1608   (let ((newname  (bookmark-rename (bookmark-bmenu-bookmark))))
1609     (bmkp-bmenu-goto-bookmark-named newname)))
1610  
1611 ;;(@* "Bookmark+ Functions (`bmkp-*')")
1612 ;;; Bookmark+ Functions (`bmkp-*') -----------------------------------
1613
1614
1615 ;;(@* "Menu-List (`*-bmenu-*') Filter Commands")
1616 ;;  *** Menu-List (`*-bmenu-*') Filter Commands ***
1617
1618 ;;;###autoload
1619 (defun bmkp-bmenu-show-only-autofiles (&optional arg) ; Bound to `A S' in bookmark list
1620   "Display (only) the autofile bookmarks.
1621 This means bookmarks whose names are the same as their (non-directory)
1622 file names.  But with a prefix arg you are prompted for a prefix that
1623 each bookmark name must have."
1624   (interactive "P")
1625   (bmkp-bmenu-barf-if-not-in-menu-list)
1626   (setq bmkp-bmenu-filter-function  (if (not arg)
1627                                         'bmkp-autofile-alist-only
1628                                       (let ((prefix  (read-string "Prefix for bookmark names: "
1629                                                                   nil nil "")))      
1630                                         `(lambda () (bmkp-autofile-alist-only ,prefix))))
1631         bmkp-bmenu-title            "Autofile Bookmarks")
1632   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1633     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1634     (bookmark-bmenu-list 'filteredp))
1635   (when (interactive-p)
1636     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "Only autofile bookmarks are shown")))
1637
1638 ;;;###autoload
1639 (defun bmkp-bmenu-show-only-autonamed () ; Bound to `# S' in bookmark list
1640   "Display (only) the autonamed bookmarks."
1641   (interactive)
1642   (bmkp-bmenu-barf-if-not-in-menu-list)
1643   (setq bmkp-bmenu-filter-function  'bmkp-autonamed-alist-only
1644         bmkp-bmenu-title            "Autonamed Bookmarks")
1645   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1646     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1647     (bookmark-bmenu-list 'filteredp))
1648   (when (interactive-p)
1649     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "Only autonamed bookmarks are shown")))
1650
1651 ;;;###autoload
1652 (defun bmkp-bmenu-show-only-bookmark-files () ; Bound to `X S' in bookmark list
1653   "Display (only) the bookmark-file bookmarks."
1654   (interactive)
1655   (bmkp-bmenu-barf-if-not-in-menu-list)
1656   (setq bmkp-bmenu-filter-function  'bmkp-bookmark-file-alist-only
1657         bmkp-bmenu-title            "Bookmark-File Bookmarks")
1658   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1659     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1660     (bookmark-bmenu-list 'filteredp))
1661   (when (interactive-p)
1662     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "Only bookmark-file bookmarks are shown")))
1663
1664 ;;;###autoload
1665 (defun bmkp-bmenu-show-only-desktops () ; Bound to `K S' in bookmark list
1666   "Display (only) the desktop bookmarks."
1667   (interactive)
1668   (bmkp-bmenu-barf-if-not-in-menu-list)
1669   (setq bmkp-bmenu-filter-function  'bmkp-desktop-alist-only
1670         bmkp-bmenu-title            "Desktop Bookmarks")
1671   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1672     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1673     (bookmark-bmenu-list 'filteredp))
1674   (when (interactive-p)
1675     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "Only desktop bookmarks are shown")))
1676
1677 ;;;###autoload
1678 (defun bmkp-bmenu-show-only-dired ()    ; Bound to `M-d M-s' in bookmark list
1679   "Display (only) the Dired bookmarks."
1680   (interactive)
1681   (bmkp-bmenu-barf-if-not-in-menu-list)
1682   (setq bmkp-bmenu-filter-function  'bmkp-dired-alist-only
1683         bmkp-bmenu-title            "Dired Bookmarks")
1684   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1685     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1686     (bookmark-bmenu-list 'filteredp))
1687   (when (interactive-p)
1688     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "Only Dired bookmarks are shown")))
1689
1690 ;;;###autoload
1691 (defun bmkp-bmenu-show-only-files (arg) ; Bound to `F S' in bookmark list
1692   "Display a list of file and directory bookmarks (only).
1693 With a prefix argument, do not include remote files or directories."
1694   (interactive "P")
1695   (bmkp-bmenu-barf-if-not-in-menu-list)
1696   (setq bmkp-bmenu-filter-function  (if arg 'bmkp-local-file-alist-only 'bmkp-file-alist-only)
1697         bmkp-bmenu-title            (if arg
1698                                         "Local File and Directory Bookmarks"
1699                                       "File and Directory Bookmarks"))
1700   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1701     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1702     (bookmark-bmenu-list 'filteredp))
1703   (when (interactive-p)
1704     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "Only file bookmarks are shown")))
1705
1706 ;;;###autoload
1707 (defun bmkp-bmenu-show-only-non-files () ; Bound to `B S' in bookmark list
1708   "Display (only) the non-file bookmarks."
1709   (interactive)
1710   (bmkp-bmenu-barf-if-not-in-menu-list)
1711   (setq bmkp-bmenu-filter-function  'bmkp-non-file-alist-only
1712         bmkp-bmenu-title            "Non-File Bookmarks")
1713   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1714     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1715     (bookmark-bmenu-list 'filteredp))
1716   (when (interactive-p)
1717     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "Only non-file bookmarks are shown")))
1718
1719 ;;;###autoload
1720 (defun bmkp-bmenu-show-only-gnus ()     ; Bound to `G S' in bookmark list
1721   "Display (only) the Gnus bookmarks."
1722   (interactive)
1723   (bmkp-bmenu-barf-if-not-in-menu-list)
1724   (setq bmkp-bmenu-filter-function  'bmkp-gnus-alist-only
1725         bmkp-bmenu-title            "Gnus Bookmarks")
1726   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1727     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1728     (bookmark-bmenu-list 'filteredp))
1729   (when (interactive-p)
1730     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "Only Gnus bookmarks are shown")))
1731
1732 ;;;###autoload
1733 (defun bmkp-bmenu-show-only-info-nodes () ; Bound to `I S' in bookmark list
1734   "Display (only) the Info bookmarks."
1735   (interactive)
1736   (bmkp-bmenu-barf-if-not-in-menu-list)
1737   (setq bmkp-bmenu-filter-function  'bmkp-info-alist-only
1738         bmkp-bmenu-title            "Info Bookmarks")
1739   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1740     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1741     (bookmark-bmenu-list 'filteredp))
1742   (when (interactive-p)
1743     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "Only Info bookmarks are shown")))
1744
1745 ;;;###autoload
1746 (defun bmkp-bmenu-show-only-man-pages () ; Bound to `M S' in bookmark list
1747   "Display (only) the `man' page bookmarks."
1748   (interactive)
1749   (bmkp-bmenu-barf-if-not-in-menu-list)
1750   (setq bmkp-bmenu-filter-function  'bmkp-man-alist-only
1751         bmkp-bmenu-title            "`man' Page Bookmarks")
1752   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1753     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1754     (bookmark-bmenu-list 'filteredp))
1755   (when (interactive-p)
1756     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "Only `man' page bookmarks are shown")))
1757
1758 ;;;###autoload
1759 (defun bmkp-bmenu-show-only-regions ()  ; Bound to `R S' in bookmark list
1760   "Display (only) the bookmarks that record a region."
1761   (interactive)
1762   (bmkp-bmenu-barf-if-not-in-menu-list)
1763   (setq bmkp-bmenu-filter-function  'bmkp-region-alist-only
1764         bmkp-bmenu-title            "Region Bookmarks")
1765   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1766     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1767     (bookmark-bmenu-list 'filteredp))
1768   (when (interactive-p)
1769     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "Only bookmarks with regions are shown")))
1770
1771 ;;;###autoload
1772 (defun bmkp-bmenu-show-only-variable-lists () ; Bound to `V S' in bookmark list
1773   "Display (only) the variable-list bookmarks."
1774   (interactive)
1775   (bmkp-bmenu-barf-if-not-in-menu-list)
1776   (setq bmkp-bmenu-filter-function  'bmkp-variable-list-alist-only
1777         bmkp-bmenu-title            "Variable-list Bookmarks")
1778   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1779     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1780     (bookmark-bmenu-list 'filteredp))
1781   (when (interactive-p)
1782     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "Only variable-list bookmarks are shown")))
1783
1784 ;;;###autoload
1785 (defun bmkp-bmenu-show-only-specific-buffer (&optional buffer) ; Bound to `= b S' in bookmark list
1786   "Display (only) the bookmarks for BUFFER.
1787 Interactively, read the BUFFER name.
1788 If BUFFER is non-nil, set `bmkp-last-specific-buffer' to it."
1789   (interactive (list (bmkp-completing-read-buffer-name)))
1790   (bmkp-bmenu-barf-if-not-in-menu-list)
1791   (when buffer (setq bmkp-last-specific-buffer  buffer))
1792   (setq bmkp-bmenu-filter-function  'bmkp-last-specific-buffer-alist-only
1793         bmkp-bmenu-title            (format "Buffer `%s' Bookmarks" bmkp-last-specific-buffer))
1794   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1795     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1796     (bookmark-bmenu-list 'filteredp))
1797   (when (interactive-p)
1798     (bmkp-msg-about-sort-order (bmkp-current-sort-order)
1799                                (format "Only bookmarks for buffer `%s' are shown"
1800                                        bmkp-last-specific-buffer))))
1801
1802 ;;;###autoload
1803 (defun bmkp-bmenu-show-only-specific-file (&optional file) ; Bound to `= f S' in bookmark list
1804   "Display (only) the bookmarks for FILE, an absolute file name.
1805 Interactively, read the FILE name.
1806 If FILE is non-nil, set `bmkp-last-specific-file' to it."
1807   (interactive (list (bmkp-completing-read-file-name)))
1808   (bmkp-bmenu-barf-if-not-in-menu-list)
1809   (when file (setq bmkp-last-specific-file  file))
1810   (setq bmkp-bmenu-filter-function  'bmkp-last-specific-file-alist-only
1811         bmkp-bmenu-title            (format "File `%s' Bookmarks" bmkp-last-specific-file))
1812   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1813     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1814     (bookmark-bmenu-list 'filteredp))
1815   (when (interactive-p)
1816     (bmkp-msg-about-sort-order (bmkp-current-sort-order)
1817                                (format "Only bookmarks for file `%s' are shown"
1818                                        bmkp-last-specific-file))))
1819
1820 ;;;###autoload
1821 (defun bmkp-bmenu-show-only-urls ()     ; Bound to `M-u M-s' in bookmark list
1822   "Display (only) the URL bookmarks."
1823   (interactive)
1824   (bmkp-bmenu-barf-if-not-in-menu-list)
1825   (setq bmkp-bmenu-filter-function  'bmkp-url-alist-only
1826         bmkp-bmenu-title            "URL Bookmarks")
1827   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1828     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1829     (bookmark-bmenu-list 'filteredp))
1830   (when (interactive-p)
1831     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "Only URL bookmarks are shown")))
1832
1833 ;;;###autoload
1834 (defun bmkp-bmenu-show-only-w3m-urls () ; Bound to `W S' in bookmark list
1835   "Display (only) the W3M URL bookmarks."
1836   (interactive)
1837   (bmkp-bmenu-barf-if-not-in-menu-list)
1838   (setq bmkp-bmenu-filter-function  'bmkp-w3m-alist-only
1839         bmkp-bmenu-title            "W3M Bookmarks")
1840   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1841     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1842     (bookmark-bmenu-list 'filteredp))
1843   (when (interactive-p)
1844     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "Only W3M bookmarks are shown")))
1845
1846 ;;;###autoload
1847 (defun bmkp-bmenu-show-all ()           ; Bound to `.' in bookmark list
1848   "Show all bookmarks known to the bookmark list (aka \"menu list\").
1849 Omitted bookmarks are not shown, however.
1850 Also, this does not revert the bookmark list, to bring it up to date.
1851 To revert the list, use `\\<bookmark-bmenu-mode-map>\\[bmkp-bmenu-refresh-menu-list]'."
1852   (interactive)
1853   (bmkp-bmenu-barf-if-not-in-menu-list)
1854   (setq bmkp-bmenu-filter-function  nil
1855         bmkp-bmenu-title            "All Bookmarks"
1856         bmkp-latest-bookmark-alist  bookmark-alist)
1857   (bookmark-bmenu-list)
1858   (when (interactive-p)
1859     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "All bookmarks are shown")))
1860
1861 ;;;###autoload
1862 (defun bmkp-bmenu-refresh-menu-list ()  ; Bound to `g' in bookmark list
1863   "Refresh (revert) the bookmark list (\"menu list\").
1864 This brings the displayed list up to date.  It does not change the
1865 current filtering or sorting of the displayed list.
1866
1867 If you want setting a bookmark to refresh the list automatically, you
1868 can use command `bmkp-toggle-bookmark-set-refreshes'."
1869   (interactive)
1870   (bmkp-bmenu-barf-if-not-in-menu-list)
1871   (bmkp-refresh-menu-list (bookmark-bmenu-bookmark)))
1872
1873 ;;;###autoload
1874 (defun bmkp-bmenu-filter-bookmark-name-incrementally () ; Bound to `P B' in bookmark list
1875   "Incrementally filter bookmarks by bookmark name using a regexp."
1876   (interactive)
1877   (bmkp-bmenu-barf-if-not-in-menu-list)
1878   (unwind-protect
1879        (progn (setq bmkp-bmenu-filter-timer
1880                     (run-with-timer 0 bmkp-incremental-filter-delay
1881                                     #'bmkp-bmenu-filter-alist-by-bookmark-name-regexp))
1882               (bmkp-bmenu-read-filter-input))
1883     (bmkp-bmenu-cancel-incremental-filtering)))
1884
1885 (defun bmkp-bmenu-filter-alist-by-bookmark-name-regexp ()
1886   "Filter bookmarks by bookmark name, then refresh the bookmark list."
1887   (setq bmkp-bmenu-filter-function  'bmkp-regexp-filtered-bookmark-name-alist-only
1888         bmkp-bmenu-title            (format "Bookmarks with Names Matching Regexp `%s'"
1889                                             bmkp-bmenu-filter-pattern))
1890   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1891     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1892     (bookmark-bmenu-list 'filteredp)))
1893
1894 ;;;###autoload
1895 (defun bmkp-bmenu-filter-file-name-incrementally () ; Bound to `P F' in bookmark list
1896   "Incrementally filter bookmarks by file name using a regexp."
1897   (interactive)
1898   (bmkp-bmenu-barf-if-not-in-menu-list)
1899   (unwind-protect
1900        (progn (setq bmkp-bmenu-filter-timer
1901                     (run-with-timer 0 bmkp-incremental-filter-delay
1902                                     #'bmkp-bmenu-filter-alist-by-file-name-regexp))
1903               (bmkp-bmenu-read-filter-input))
1904     (bmkp-bmenu-cancel-incremental-filtering)))
1905
1906 (defun bmkp-bmenu-filter-alist-by-file-name-regexp ()
1907   "Filter bookmarks by file name, then refresh the bookmark list."
1908   (setq bmkp-bmenu-filter-function  'bmkp-regexp-filtered-file-name-alist-only
1909         bmkp-bmenu-title            (format "Bookmarks with File Names Matching Regexp `%s'"
1910                                             bmkp-bmenu-filter-pattern))
1911   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1912     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1913     (bookmark-bmenu-list 'filteredp)))
1914
1915 ;;;###autoload
1916 (defun bmkp-bmenu-filter-annotation-incrementally () ; Bound to `P A' in bookmark list
1917   "Incrementally filter bookmarks by their annotations using a regexp."
1918   (interactive)
1919   (bmkp-bmenu-barf-if-not-in-menu-list)
1920   (unwind-protect
1921        (progn (setq bmkp-bmenu-filter-timer
1922                     (run-with-timer 0 bmkp-incremental-filter-delay
1923                                     #'bmkp-bmenu-filter-alist-by-annotation-regexp))
1924               (bmkp-bmenu-read-filter-input))
1925     (bmkp-bmenu-cancel-incremental-filtering)))
1926
1927 (defun bmkp-bmenu-filter-alist-by-annotation-regexp ()
1928   "Filter bookmarks by annoation, then refresh the bookmark list."
1929   (setq bmkp-bmenu-filter-function  'bmkp-regexp-filtered-annotation-alist-only
1930         bmkp-bmenu-title            (format "Bookmarks with Annotations Matching Regexp `%s'"
1931                                             bmkp-bmenu-filter-pattern))
1932   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1933     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1934     (bookmark-bmenu-list 'filteredp)))
1935
1936 ;;;###autoload
1937 (defun bmkp-bmenu-filter-tags-incrementally () ; Bound to `P T' in bookmark list
1938   "Incrementally filter bookmarks by tags using a regexp."
1939   (interactive)
1940   (bmkp-bmenu-barf-if-not-in-menu-list)
1941   (unwind-protect
1942        (progn (setq bmkp-bmenu-filter-timer
1943                     (run-with-timer 0 bmkp-incremental-filter-delay
1944                                     #'bmkp-bmenu-filter-alist-by-tags-regexp))
1945               (bmkp-bmenu-read-filter-input))
1946     (bmkp-bmenu-cancel-incremental-filtering)))
1947
1948 (defun bmkp-bmenu-filter-alist-by-tags-regexp ()
1949   "Filter bookmarks by tags, then refresh the bookmark list."
1950   (setq bmkp-bmenu-filter-function  'bmkp-regexp-filtered-tags-alist-only
1951         bmkp-bmenu-title            (format "Bookmarks with Tags Matching Regexp `%s'"
1952                                             bmkp-bmenu-filter-pattern))
1953   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
1954     (setq bmkp-latest-bookmark-alist  bookmark-alist)
1955     (bookmark-bmenu-list 'filteredp)))
1956
1957 (defun bmkp-bmenu-read-filter-input ()
1958   "Read input and add it to `bmkp-bmenu-filter-pattern'."
1959   (setq bmkp-bmenu-filter-pattern  "")
1960   (let ((tmp-list  ())
1961         char)
1962     (catch 'bmkp-bmenu-read-filter-input-1
1963       (while t
1964         (catch 'bmkp-bmenu-read-filter-input-2
1965           (condition-case nil
1966               (setq char  (read-char (concat bmkp-bmenu-filter-prompt bmkp-bmenu-filter-pattern)))
1967             (error (throw 'bmkp-bmenu-read-filter-input-1 nil)))
1968           (case char
1969             ((?\e ?\r) (throw 'bmkp-bmenu-read-filter-input-1 nil)) ; Break and exit.
1970             (?\d
1971              (pop tmp-list)             ; Delete last char of `bmkp-bmenu-filter-pattern'.
1972              (setq bmkp-bmenu-filter-pattern  (mapconcat 'identity (reverse tmp-list) ""))
1973              (throw 'bmkp-bmenu-read-filter-input-2 nil))
1974             (t
1975              (push (text-char-description char) tmp-list)
1976              (setq bmkp-bmenu-filter-pattern  (mapconcat 'identity (reverse tmp-list) ""))
1977              (throw 'bmkp-bmenu-read-filter-input-2 nil))))))))
1978
1979 (defun bmkp-bmenu-cancel-incremental-filtering ()
1980   "Cancel timer used for incrementally filtering bookmarks."
1981   (cancel-timer bmkp-bmenu-filter-timer)
1982   (setq bmkp-bmenu-filter-timer  nil))
1983
1984 ;;;###autoload
1985 (defun bmkp-bmenu-toggle-show-only-unmarked () ; Bound to `<' in bookmark list
1986   "Hide all marked bookmarks.  Repeat to toggle, showing all."
1987   (interactive)
1988   (bmkp-bmenu-barf-if-not-in-menu-list)
1989   (if (or (bmkp-some-marked-p bmkp-latest-bookmark-alist)
1990           (bmkp-some-marked-p bmkp-bmenu-before-hide-marked-alist))
1991       (let ((bookmark-alist  bmkp-latest-bookmark-alist)
1992             status)
1993         (if bmkp-bmenu-before-hide-marked-alist
1994             (setq bookmark-alist                       bmkp-bmenu-before-hide-marked-alist
1995                   bmkp-bmenu-before-hide-marked-alist  ()
1996                   bmkp-latest-bookmark-alist           bookmark-alist
1997                   status                               'shown)
1998           (setq bmkp-bmenu-before-hide-marked-alist  bmkp-latest-bookmark-alist
1999                 bookmark-alist                       (bmkp-unmarked-bookmarks-only)
2000                 bmkp-latest-bookmark-alist           bookmark-alist
2001                 status                               'hidden))
2002         (bookmark-bmenu-surreptitiously-rebuild-list)
2003         (cond ((eq status 'hidden)
2004                (bookmark-bmenu-ensure-position)
2005                (message "Marked bookmarks are now hidden"))
2006               (t
2007                (goto-char (point-min))
2008                (when (re-search-forward "^>" (point-max) t)  (forward-line 0))
2009                (message "Marked bookmarks no longer hidden"))))
2010     (message "No marked bookmarks to hide"))
2011   (when (and (fboundp 'fit-frame-if-one-window)
2012              (eq (selected-window) (get-buffer-window (get-buffer-create "*Bookmark List*") 0)))
2013     (fit-frame-if-one-window)))
2014
2015 ;;;###autoload
2016 (defun bmkp-bmenu-toggle-show-only-marked () ; Bound to `>' in bookmark list
2017   "Hide all unmarked bookmarks.  Repeat to toggle, showing all."
2018   (interactive)
2019   (bmkp-bmenu-barf-if-not-in-menu-list)
2020   (if (or (bmkp-some-unmarked-p bmkp-latest-bookmark-alist)
2021           (bmkp-some-unmarked-p bmkp-bmenu-before-hide-unmarked-alist))
2022       (let ((bookmark-alist  bmkp-latest-bookmark-alist)
2023             status)
2024         (if bmkp-bmenu-before-hide-unmarked-alist
2025             (setq bookmark-alist                         bmkp-bmenu-before-hide-unmarked-alist
2026                   bmkp-bmenu-before-hide-unmarked-alist  ()
2027                   bmkp-latest-bookmark-alist             bookmark-alist
2028                   status                                 'shown)
2029           (setq bmkp-bmenu-before-hide-unmarked-alist  bmkp-latest-bookmark-alist
2030                 bookmark-alist                         (bmkp-marked-bookmarks-only)
2031                 bmkp-latest-bookmark-alist             bookmark-alist
2032                 status                                 'hidden))
2033         (bookmark-bmenu-surreptitiously-rebuild-list)
2034         (cond ((eq status 'hidden)
2035                (bookmark-bmenu-ensure-position)
2036                (message "Unmarked bookmarks are now hidden"))
2037               (t
2038                (goto-char (point-min))
2039                (when (re-search-forward "^>" (point-max) t)  (forward-line 0))
2040                (message "Unmarked bookmarks no longer hidden"))))
2041     (message "No unmarked bookmarks to hide"))
2042   (when (and (fboundp 'fit-frame-if-one-window)
2043              (eq (selected-window) (get-buffer-window (get-buffer-create "*Bookmark List*") 0)))
2044     (fit-frame-if-one-window)))
2045
2046
2047 ;;(@* "Menu-List (`*-bmenu-*') Commands Involving Marks")
2048 ;;  *** Menu-List (`*-bmenu-*') Commands Involving Marks ***
2049
2050 ;;;###autoload
2051 (defun bmkp-bmenu-mark-all ()           ; Bound to `M-m' in bookmark list
2052   "Mark all bookmarks, using mark `>'."
2053   (interactive)
2054   (bmkp-bmenu-barf-if-not-in-menu-list)
2055   (save-excursion  
2056     (let ((count  0))
2057       (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
2058       (while (not (eobp)) (bookmark-bmenu-mark) (setq count  (1+ count)))
2059       (message "Marked: %d" count))))
2060
2061 ;; This is similar to `dired-unmark-all-files'.
2062 ;;;###autoload
2063 (defun bmkp-bmenu-unmark-all (mark &optional arg) ; Bound to `M-DEL', `U' in bookmark list
2064   "Remove a mark from each bookmark.
2065 Hit the mark character (`>' or `D') to remove those marks,
2066  or hit `RET' to remove all marks (both `>' and `D').
2067 With a prefix arg, you are queried to unmark each marked bookmark.
2068 Use `\\[help-command]' during querying for help."
2069   (interactive "cRemove marks (RET means all): \nP")
2070   (bmkp-bmenu-barf-if-not-in-menu-list)
2071   (require 'dired-aux)
2072   (save-excursion
2073     (let* ((count              0)
2074            (inhibit-read-only  t)
2075            (case-fold-search   nil)
2076            (query              nil)
2077            (string             (format "\n%c" mark))
2078            (help-form          "Type SPC or `y' to unmark one bookmark, DEL or `n' to skip to next,
2079 `!' to unmark all remaining bookmarks with no more questions."))
2080       (goto-char (point-min))
2081       (forward-line (if (eq mark ?\r)
2082                         bmkp-bmenu-header-lines
2083                       (1- bmkp-bmenu-header-lines))) ; Because STRING starts with a newline.
2084       (while (and (not (eobp))
2085                   (if (eq mark ?\r)
2086                       (re-search-forward dired-re-mark nil t)
2087                     (let ((case-fold-search  t)) ; Treat `d' the same as `D'.
2088                       (search-forward string nil t))))
2089         (when (or (not arg)  (let ((bmk  (bookmark-bmenu-bookmark)))
2090                                (and bmk (dired-query 'query "Unmark bookmark `%s'? " bmk))))
2091           (bookmark-bmenu-unmark) (forward-line -1)
2092           (setq count  (1+ count))))
2093       (if (= 1 count) (message "1 mark removed") (message "%d marks removed" count)))))
2094
2095 ;;;###autoload
2096 (defun bmkp-bmenu-regexp-mark (regexp)  ; Bound to `% m' in bookmark list
2097   "Mark bookmarks that match REGEXP.
2098 The entire bookmark line is tested: bookmark name and possibly file name."
2099   (interactive "sRegexp: ")
2100   (bmkp-bmenu-barf-if-not-in-menu-list)
2101   (save-excursion
2102     (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
2103     (let ((count  0))
2104       (while (and (not (eobp)) (re-search-forward regexp (point-max) t))
2105         (bookmark-bmenu-mark)
2106         (setq count  (1+ count)))
2107       (if (= 1 count) (message "1 bookmark matched") (message "%d bookmarks matched" count)))))
2108
2109 ;;;###autoload
2110 (defun bmkp-bmenu-mark-autofile-bookmarks (&optional arg) ; Bound to `A M' in bookmark list
2111   "Mark autofile bookmarks: those whose names are the same as their files.
2112 With a prefix arg you are prompted for a prefix that each bookmark
2113 name must have."
2114   (interactive "P")
2115   (if (not arg)
2116       (bmkp-bmenu-mark-bookmarks-satisfying #'bmkp-autofile-bookmark-p)
2117     (let ((prefix  (read-string "Prefix for bookmark names: " nil nil "")))
2118       (bmkp-bmenu-mark-bookmarks-satisfying #'(lambda (bb) (bmkp-autofile-bookmark-p bb prefix))))))
2119
2120 ;;;###autoload
2121 (defun bmkp-bmenu-mark-bookmark-file-bookmarks () ; Bound to `X M' in bookmark list
2122   "Mark bookmark-file bookmarks."
2123   (interactive)
2124   (bmkp-bmenu-mark-bookmarks-satisfying 'bmkp-bookmark-file-bookmark-p))
2125
2126 ;;;###autoload
2127 (defun bmkp-bmenu-mark-desktop-bookmarks () ; Bound to `K M' in bookmark list
2128   "Mark desktop bookmarks."
2129   (interactive)
2130   (bmkp-bmenu-mark-bookmarks-satisfying 'bmkp-desktop-bookmark-p))
2131
2132 ;;;###autoload
2133 (defun bmkp-bmenu-mark-dired-bookmarks () ; Bound to `M-d M-m' in bookmark list
2134   "Mark Dired bookmarks."
2135   (interactive)
2136   (bmkp-bmenu-mark-bookmarks-satisfying 'bmkp-dired-bookmark-p))
2137
2138 ;;;###autoload
2139 (defun bmkp-bmenu-mark-file-bookmarks (arg) ; Bound to `F M' in bookmark list
2140   "Mark file bookmarks.
2141 With a prefix argument, do not mark remote files or directories."
2142   (interactive "P")
2143   (bmkp-bmenu-mark-bookmarks-satisfying
2144    (if arg 'bmkp-local-file-bookmark-p 'bmkp-file-bookmark-p)))
2145
2146 ;;;###autoload
2147 (defun bmkp-bmenu-mark-gnus-bookmarks () ; Bound to `G M' in bookmark list
2148   "Mark Gnus bookmarks."
2149   (interactive)
2150   (bmkp-bmenu-mark-bookmarks-satisfying 'bmkp-gnus-bookmark-p))
2151
2152 ;;;###autoload
2153 (defun bmkp-bmenu-mark-info-bookmarks () ; Bound to `I M' in bookmark list
2154   "Mark Info bookmarks."
2155   (interactive)
2156   (bmkp-bmenu-mark-bookmarks-satisfying 'bmkp-info-bookmark-p))
2157
2158 ;;;###autoload
2159 (defun bmkp-bmenu-mark-man-bookmarks () ; Bound to `M M' in bookmark list
2160   "Mark `man' page bookmarks."
2161   (interactive)
2162   (bmkp-bmenu-mark-bookmarks-satisfying 'bmkp-man-bookmark-p))
2163
2164 ;;;###autoload
2165 (defun bmkp-bmenu-mark-non-file-bookmarks () ; Bound to `B M' in bookmark list
2166   "Mark non-file bookmarks."
2167   (interactive)
2168   (bmkp-bmenu-mark-bookmarks-satisfying 'bmkp-non-file-bookmark-p))
2169
2170 ;;;###autoload
2171 (defun bmkp-bmenu-mark-region-bookmarks () ; Bound to `R M' in bookmark list
2172   "Mark bookmarks that record a region."
2173   (interactive)
2174   (bmkp-bmenu-mark-bookmarks-satisfying 'bmkp-region-bookmark-p))
2175
2176 (when (featurep 'bookmark+-lit)
2177   (defun bmkp-bmenu-mark-lighted-bookmarks () ; Bound to `H M' in bookmark list
2178     "Mark the highlighted bookmarks."
2179     (interactive)
2180     (bmkp-bmenu-mark-bookmarks-satisfying 'bmkp-lighted-p)))
2181
2182 ;;;###autoload
2183 (defun bmkp-bmenu-mark-specific-buffer-bookmarks (&optional buffer) ; `= b M' in bookmark list
2184   "Mark bookmarks for BUFFER.
2185 Interactively, read the name of the buffer.
2186 If BUFFER is non-nil, set `bmkp-last-specific-buffer' to it."
2187   (interactive (list (bmkp-completing-read-buffer-name)))
2188   (when buffer (setq bmkp-last-specific-buffer  buffer))
2189   (bmkp-bmenu-mark-bookmarks-satisfying 'bmkp-last-specific-buffer-p))
2190
2191 ;;;###autoload
2192 (defun bmkp-bmenu-mark-specific-file-bookmarks (&optional file) ; Bound to `= f M' in bookmark list
2193   "Mark bookmarks for FILE, an absolute file name.
2194 Interactively, read the file name.
2195 If FILE is non-nil, set `bmkp-last-specific-file' to it."
2196   (interactive (list (bmkp-completing-read-file-name)))
2197   (when file (setq bmkp-last-specific-file  file))
2198   (bmkp-bmenu-mark-bookmarks-satisfying 'bmkp-last-specific-file-p))
2199
2200 ;;;###autoload
2201 (defun bmkp-bmenu-mark-url-bookmarks () ; Bound to `M-u M-m' in bookmark list
2202   "Mark URL bookmarks."
2203   (interactive)
2204   (bmkp-bmenu-mark-bookmarks-satisfying 'bmkp-url-bookmark-p))
2205
2206 ;;;###autoload
2207 (defun bmkp-bmenu-mark-w3m-bookmarks () ; Bound to `W M' in bookmark list
2208   "Mark W3M (URL) bookmarks."
2209   (interactive)
2210   (bmkp-bmenu-mark-bookmarks-satisfying 'bmkp-w3m-bookmark-p))
2211
2212 ;;;###autoload
2213 (defun bmkp-bmenu-mark-bookmarks-satisfying (pred) ; Not bound
2214   "Mark bookmarks that satisfy predicate PRED.
2215 If you use this interactively, you are responsible for entering a
2216 symbol that names a unnary predicate.  The function you provide is not
2217 checked - it is simply applied to each bookmark to test it."
2218   (interactive "aPredicate: ")
2219   (bmkp-bmenu-barf-if-not-in-menu-list)
2220   (save-excursion
2221     (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
2222     (let ((count  0)
2223           bmk)
2224       (while (not (eobp))
2225         (setq bmk  (bookmark-bmenu-bookmark))
2226         (if (not (funcall pred bmk))
2227             (forward-line 1)
2228           (bookmark-bmenu-mark)
2229           (setq count  (1+ count))))
2230       (if (= 1 count) (message "1 bookmark matched") (message "%d bookmarks matched" count)))))
2231
2232 ;;;###autoload
2233 (defun bmkp-bmenu-toggle-marks ()       ; Bound to `t' in bookmark list
2234   "Toggle marks: Unmark all marked bookmarks; mark all unmarked bookmarks.
2235 This affects only the `>' mark, not the `D' flag."
2236   (interactive)
2237   (bmkp-bmenu-barf-if-not-in-menu-list)
2238   (let ((marked-count    0)
2239         (unmarked-count  0))
2240     (save-excursion
2241       (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
2242       (if (not (bmkp-some-marked-p bmkp-latest-bookmark-alist))
2243           (bmkp-bmenu-mark-all)
2244         (while (not (eobp))
2245           (cond ((bmkp-bookmark-name-member (bookmark-bmenu-bookmark) bmkp-bmenu-marked-bookmarks)
2246                  (bookmark-bmenu-unmark)
2247                  (setq unmarked-count  (1+ unmarked-count)))
2248                 (t
2249                  (bookmark-bmenu-mark)
2250                  (setq marked-count  (1+ marked-count)))))
2251         (message "Marked: %d, unmarked: %d" marked-count unmarked-count)))))
2252
2253 ;;;###autoload
2254 (defun bmkp-bmenu-dired-marked (dirbufname) ; Bound to `M-d >' in bookmark list
2255   "Dired in another window for the marked file and directory bookmarks.
2256
2257 Absolute file names are used for the entries in the Dired buffer.
2258 The only entries are for the marked files and directories.  These can
2259 be located anywhere.  (In Emacs versions prior to release 23.2, remote
2260 bookmarks are ignored, because of Emacs bug #5478.)
2261
2262 You are prompted for the Dired buffer name.  The `default-directory'
2263 of the buffer is the same as that of buffer `*Bookmark List*'."
2264   (interactive (list (read-string "Dired buffer name: ")))
2265   (bmkp-bmenu-barf-if-not-in-menu-list)
2266   (let ((files  ())
2267         file)
2268     (dolist (bmk  (bmkp-sort-omit (bmkp-marked-bookmarks-only)))
2269       (when (or (bmkp-local-file-bookmark-p bmk)
2270                 (> emacs-major-version 23)
2271                 (and (= emacs-major-version 23) (> emacs-minor-version 1)))
2272         (setq file  (bookmark-get-filename bmk))
2273         (unless (file-name-absolute-p file) (setq file (expand-file-name file))) ; Should not happen.
2274         (push file files)))
2275     (dired-other-window (cons dirbufname files))))
2276
2277 ;;;###autoload
2278 (defun bmkp-bmenu-delete-marked ()      ; Bound to `D' in bookmark list
2279   "Delete all (visible) bookmarks that are marked `>', after confirmation."
2280   (interactive)
2281   (bmkp-bmenu-barf-if-not-in-menu-list)
2282   (bookmark-bmenu-execute-deletions 'marked))
2283
2284 ;;;###autoload
2285 (defun bmkp-bmenu-make-sequence-from-marked (bookmark-name &optional dont-omit-p) ; Not bound
2286   "Create or update a sequence bookmark from the visible marked bookmarks.
2287 The bookmarks that are currently marked are recorded as a sequence, in
2288 their current order in buffer `*Bookmark List*'.
2289 When you \"jump\" to the sequence bookmark, the bookmarks in the
2290 sequence are processed in order.
2291
2292 By default, omit the marked bookmarks, after creating the sequence.
2293 With a prefix arg, do not omit them.
2294
2295 If a bookmark with the specified name already exists, it is
2296 overwritten.  If a sequence bookmark with the name already exists,
2297 then you are prompted whether to add the marked bookmarks to the
2298 beginning of the existing sequence (or simply replace it).
2299
2300 Note that another existing sequence bookmark can be marked, and thus
2301 included in the sequence bookmark created or updated.  That is, you
2302 can include other sequences within a sequence bookmark.
2303
2304 Returns the bookmark (internal record) created or updated."
2305   (interactive "sName of sequence bookmark: \nP")
2306   (bmkp-bmenu-barf-if-not-in-menu-list)
2307   (let ((marked-bmks  ())
2308         (count        0))
2309     (message "Making sequence from marked bookmarks...")
2310     (save-excursion
2311       (with-current-buffer "*Bookmark List*"
2312         (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
2313         (while (re-search-forward "^>" (point-max) t)
2314           (push (bookmark-bmenu-bookmark) marked-bmks)
2315           (setq count  (1+ count)))))
2316     (when (zerop count) (error "No marked bookmarks"))
2317     (let ((new-seq  (nreverse marked-bmks))
2318           (bmk      (bookmark-get-bookmark bookmark-name 'noerror)))
2319       (when (and bmk (bmkp-sequence-bookmark-p bmk))
2320         (if (y-or-n-p (format "ADD marked to existing sequence `%s' (otherwise, REPLACES it)? "
2321                               bookmark-name))
2322             (setq new-seq  (nconc new-seq (bookmark-prop-get bmk 'sequence)))
2323           "OK, existing sequence will be replaced"))
2324       (bookmark-store bookmark-name `((filename . ,bmkp-non-file-filename)
2325                                       (position . 0)
2326                                       (sequence ,@new-seq)
2327                                       (handler  . bmkp-jump-sequence))
2328                       nil)))
2329   (let ((new  (bookmark-get-bookmark bookmark-name 'noerror)))
2330     (unless (memq new bmkp-latest-bookmark-alist)
2331       (setq bmkp-latest-bookmark-alist  (cons new bmkp-latest-bookmark-alist)))
2332     (unless dont-omit-p
2333       (bmkp-bmenu-omit-marked)
2334       (message "Marked bookmarks now OMITTED - use `bmkp-bmenu-show-only-omitted' to show"))
2335     (bookmark-bmenu-surreptitiously-rebuild-list)
2336     (bmkp-bmenu-goto-bookmark-named bookmark-name)
2337     new))
2338
2339
2340 ;;(@* "Omitted Bookmarks")
2341 ;;  *** Omitted Bookmarks ***
2342
2343 ;;;###autoload
2344 (defun bmkp-bmenu-omit ()               ; Not bound
2345   "Omit this bookmark."
2346   (interactive)
2347   (bmkp-bmenu-barf-if-not-in-menu-list)
2348   (bookmark-bmenu-ensure-position)
2349   (setq bmkp-bmenu-omitted-bookmarks  (cons (bookmark-bmenu-bookmark) bmkp-bmenu-omitted-bookmarks))
2350   (bookmark-bmenu-surreptitiously-rebuild-list)
2351   (message "Omitted 1 bookmark"))
2352
2353 ;;;###autoload
2354 (defun bmkp-bmenu-omit/unomit-marked () ; Bound to `O >' in bookmark list
2355   "Omit all marked bookmarks or, if showing only omitted ones, unomit."
2356   (interactive)
2357   (bmkp-bmenu-barf-if-not-in-menu-list)
2358   (if (eq bmkp-bmenu-filter-function  'bmkp-omitted-alist-only)
2359       (bmkp-bmenu-unomit-marked)
2360     (bmkp-bmenu-omit-marked)))
2361
2362 ;;;###autoload
2363 (defun bmkp-bmenu-omit-marked ()        ; Bound to `O >' in bookmark list
2364   "Omit all marked bookmarks.
2365 They will henceforth be invisible to the bookmark list.
2366 You can, however, use \\<bookmark-bmenu-mode-map>`\\[bmkp-bmenu-show-only-omitted]' to see them.
2367 You can then mark some of them and use `\\[bmkp-bmenu-omit/unomit-marked]' to make those marked
2368  available again for the bookmark list."
2369   (interactive)
2370   (bmkp-bmenu-barf-if-not-in-menu-list)
2371   (let ((o-str    (and (not (looking-at "^>")) (bookmark-bmenu-bookmark)))
2372         (o-point  (point))
2373         (count    0))
2374     (message "Omitting marked bookmarks...")
2375     (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
2376     (while (re-search-forward "^>" (point-max) t)
2377       (setq bmkp-bmenu-omitted-bookmarks  (cons (bookmark-bmenu-bookmark) bmkp-bmenu-omitted-bookmarks)
2378             count                    (1+ count)))
2379     (if (<= count 0)
2380         (message "No marked bookmarks")
2381       (bookmark-bmenu-surreptitiously-rebuild-list)
2382       (message "Omitted %d bookmarks" count))
2383     (if o-str
2384         (bmkp-bmenu-goto-bookmark-named o-str)
2385       (goto-char o-point)
2386       (beginning-of-line)))
2387   (when (and (fboundp 'fit-frame-if-one-window)
2388              (eq (selected-window) (get-buffer-window (get-buffer-create "*Bookmark List*") 0)))
2389     (fit-frame-if-one-window)))
2390
2391 ;;;###autoload
2392 (defun bmkp-bmenu-unomit-marked ()      ; `O >' in bookmark list when showing omitted bookmarks
2393   "Remove all marked bookmarks from the list of omitted bookmarks.
2394 They will henceforth be available for display in the bookmark list.
2395 \(In order to see and then mark omitted bookmarks you must use \\<bookmark-bmenu-mode-map>\
2396 `\\[bmkp-bmenu-show-only-omitted]'.)"
2397   (interactive)
2398   (bmkp-bmenu-barf-if-not-in-menu-list)
2399   (unless bmkp-bmenu-omitted-bookmarks (error "No omitted bookmarks to UN-omit"))
2400   (unless (eq bmkp-bmenu-filter-function  'bmkp-omitted-alist-only)
2401     (error "You must use command `bmkp-bmenu-show-only-omitted' first"))
2402   (let ((count    0))
2403     (message "UN-omitting marked bookmarks...")
2404     (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
2405     (while (re-search-forward "^>" (point-max) t)
2406       (let ((bmk-name  (bookmark-bmenu-bookmark)))
2407         (when (bmkp-bookmark-name-member bmk-name bmkp-bmenu-omitted-bookmarks)
2408           (setq bmkp-bmenu-omitted-bookmarks  (bmkp-delete-bookmark-name-from-list
2409                                                bmk-name bmkp-bmenu-omitted-bookmarks)
2410                 count                         (1+ count)))))
2411     (if (<= count 0)
2412         (message "No marked bookmarks")
2413       (setq bmkp-bmenu-filter-function  nil
2414             bmkp-bmenu-title            "All Bookmarks"
2415             bmkp-latest-bookmark-alist  bookmark-alist)
2416       (bookmark-bmenu-surreptitiously-rebuild-list)
2417       (message "UN-omitted %d bookmarks" count)))
2418   (when (and (fboundp 'fit-frame-if-one-window)
2419              (eq (selected-window) (get-buffer-window (get-buffer-create "*Bookmark List*") 0)))
2420     (fit-frame-if-one-window)))
2421
2422 ;;;###autoload
2423 (defun bmkp-bmenu-show-only-omitted ()  ; Bound to `O S' in bookmark list to show only omitted
2424   "Show only the omitted bookmarks.
2425 You can then mark some of them and use `bmkp-bmenu-unomit-marked' to
2426  make those that are marked available again for the bookmark list."
2427   (interactive)
2428   (bmkp-bmenu-barf-if-not-in-menu-list)
2429   (unless bmkp-bmenu-omitted-bookmarks (error "No omitted bookmarks"))
2430   (setq bmkp-bmenu-filter-function  'bmkp-omitted-alist-only
2431         bmkp-bmenu-title            "Omitted Bookmarks")
2432   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
2433     (setq bmkp-latest-bookmark-alist  bookmark-alist)
2434     (bookmark-bmenu-list 'filteredp))
2435   (when (interactive-p)
2436     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "Only omitted bookmarks are shown now")))
2437
2438
2439 ;;(@* "Search-and-Replace Locations of Marked Bookmarks")
2440 ;;  *** Search-and-Replace Locations of Marked Bookmarks ***
2441
2442 (when (> emacs-major-version 22)
2443   (defun bmkp-bmenu-isearch-marked-bookmarks () ; Bound to `M-s a C-s' in bookmark list
2444     "Isearch the marked bookmark locations, in their current order."
2445     (interactive)
2446     (bmkp-bmenu-barf-if-not-in-menu-list)
2447     (let ((bookmarks        (mapcar #'car (bmkp-sort-omit (bmkp-marked-bookmarks-only))))
2448           (bmkp-use-region  nil))  ; Suppress region handling.
2449       (bmkp-isearch-bookmarks bookmarks))) ; Defined in `bookmark+-1.el'.
2450
2451   (defun bmkp-bmenu-isearch-marked-bookmarks-regexp () ; Bound to `M-s a M-C-s' in bookmark list
2452     "Regexp Isearch the marked bookmark locations, in their current order."
2453     (interactive)
2454     (bmkp-bmenu-barf-if-not-in-menu-list)
2455     (let ((bookmarks        (mapcar #'car (bmkp-sort-omit (bmkp-marked-bookmarks-only))))
2456           (bmkp-use-region  nil))  ; Suppress region handling.
2457       (bmkp-isearch-bookmarks-regexp bookmarks)))) ; Defined in `bookmark+-1.el'.
2458
2459 ;;;###autoload
2460 (defun bmkp-bmenu-search-marked-bookmarks-regexp (regexp) ; Bound to `M-s a M-s' in bookmark list
2461   "Search the marked file bookmarks, in their current order, for REGEXP.
2462 Use `\\[tags-loop-continue]' to advance among the search hits.
2463 Marked directory and non-file bookmarks are ignored."
2464   (interactive "sSearch marked file bookmarks (regexp): ")
2465   (bmkp-bmenu-barf-if-not-in-menu-list)
2466   (tags-search regexp '(let ((files  ())
2467                              file)
2468                         (dolist (bmk  (bmkp-sort-omit (bmkp-marked-bookmarks-only)))
2469                           (setq file  (bookmark-get-filename bmk))
2470                           (when (and (not (equal bmkp-non-file-filename file))
2471                                      (not (file-directory-p file)))
2472                             (push file files)))
2473                         (setq files  (nreverse files)))))
2474
2475 ;;;###autoload
2476 (defun bmkp-bmenu-query-replace-marked-bookmarks-regexp (from to ; Bound to `M-q' in bookmark list
2477                                                          &optional delimited)
2478   "`query-replace-regexp' FROM with TO, for all marked file bookmarks.
2479 DELIMITED (prefix arg) means replace only word-delimited matches.
2480 If you exit (`\\[keyboard-quit]', `RET' or `q'), you can use \
2481 `\\[tags-loop-continue]' to resume where
2482 you left off."
2483   (interactive (let ((common  (query-replace-read-args "Query replace regexp in marked files" t t)))
2484                  (list (nth 0 common) (nth 1 common) (nth 2 common))))
2485   (bmkp-bmenu-barf-if-not-in-menu-list)
2486   (tags-query-replace from to delimited
2487                       '(let ((files  ())
2488                              file)
2489                         (dolist (bmk  (bmkp-sort-omit (bmkp-marked-bookmarks-only)))
2490                           (setq file  (bookmark-get-filename bmk))
2491                           (let ((buffer  (get-file-buffer file)))
2492                             (when (and buffer  (with-current-buffer buffer buffer-read-only))
2493                               (error "File `%s' is visited read-only" file)))
2494                           (when (and (not (equal bmkp-non-file-filename file))
2495                                      (not (file-directory-p file)))
2496                             (push file files)))
2497                         (setq files  (nreverse files)))))
2498
2499
2500 ;;(@* "Tags")
2501 ;;  *** Tags ***
2502
2503 ;;;###autoload
2504 (defun bmkp-bmenu-show-only-tagged ()   ; Bound to `T S' in bookmark list
2505   "Display (only) the bookmarks that have tags."
2506   (interactive)
2507   (bmkp-bmenu-barf-if-not-in-menu-list)
2508   (setq bmkp-bmenu-filter-function  'bmkp-some-tags-alist-only
2509         bmkp-bmenu-title            "Tagged Bookmarks")
2510   (let ((bookmark-alist  (funcall bmkp-bmenu-filter-function)))
2511     (setq bmkp-latest-bookmark-alist  bookmark-alist)
2512     (bookmark-bmenu-list 'filteredp))
2513   (when (interactive-p)
2514     (bmkp-msg-about-sort-order (bmkp-current-sort-order) "Only tagged bookmarks are shown")))
2515
2516 ;; Not bound, but `T 0' is `bmkp-remove-all-tags'.
2517 ;;;###autoload
2518 (defun bmkp-bmenu-remove-all-tags (&optional must-confirm-p)
2519   "Remove all tags from this bookmark.
2520 Interactively, you are required to confirm."
2521   (interactive "p")
2522   (bmkp-bmenu-barf-if-not-in-menu-list)
2523   (bookmark-bmenu-ensure-position)
2524   (let ((bookmark  (bookmark-bmenu-bookmark)))
2525     (when (and must-confirm-p (null (bmkp-get-tags bookmark)))
2526       (error "Bookmark has no tags to remove"))
2527     (when (or (not must-confirm-p) (y-or-n-p "Remove all tags from this bookmark? "))
2528       (bmkp-remove-all-tags bookmark))))
2529
2530 ;;;###autoload
2531 (defun bmkp-bmenu-add-tags ()           ; Only on `mouse-3' menu in bookmark list.
2532   "Add some tags to this bookmark."
2533   (interactive)
2534   (bmkp-bmenu-barf-if-not-in-menu-list)
2535   (bookmark-bmenu-ensure-position)
2536   (bmkp-add-tags (bookmark-bmenu-bookmark) (bmkp-read-tags-completing)))
2537
2538 ;;;###autoload
2539 (defun bmkp-bmenu-set-tag-value ()      ; Bound to `T v' in bookmark list
2540   "Set the value of one of this bookmark's tags."
2541   (interactive)
2542   (bmkp-bmenu-barf-if-not-in-menu-list)
2543   (bookmark-bmenu-ensure-position)
2544   (let ((this-bmk  (bookmark-bmenu-bookmark)))
2545     (bmkp-set-tag-value
2546      this-bmk
2547      (bmkp-read-tag-completing "Tag: " (mapcar 'bmkp-full-tag (bmkp-get-tags this-bmk)))
2548      (read (read-string "Value: "))
2549      'msg)))
2550
2551 ;;;###autoload
2552 (defun bmkp-bmenu-set-tag-value-for-marked (tag value &optional msgp) ; `T > v' in bookmark list
2553   "Set the value of TAG to VALUE, for each of the marked bookmarks.
2554 If any of the bookmarks has no tag named TAG, then add one with VALUE."
2555   (interactive (list (bmkp-read-tag-completing) (read (read-string "Value: ")) 'msg))
2556   (bmkp-bmenu-barf-if-not-in-menu-list)
2557   (when msgp (message "Setting tag values..."))
2558   (let ((marked  (bmkp-marked-bookmarks-only)))
2559     (unless marked (error "No marked bookmarks"))
2560     (when msgp (message "Setting tag values..."))
2561     (bmkp-set-tag-value-for-bookmarks marked tag value))
2562   (when (and msgp tag) (message "Setting tag values...done")))
2563
2564 ;;;###autoload
2565 (defun bmkp-bmenu-remove-tags (&optional msgp) ; Only on `mouse-3' menu in bookmark list.
2566   "Remove some tags from this bookmark."
2567   (interactive "p")
2568   (bmkp-bmenu-barf-if-not-in-menu-list)
2569   (bookmark-bmenu-ensure-position)
2570   (let ((bmk  (bookmark-bmenu-bookmark)))
2571     (bmkp-remove-tags bmk
2572                       (bmkp-read-tags-completing (mapcar 'bmkp-full-tag (bmkp-get-tags bmk)) t)
2573                       msgp)))
2574
2575 ;;;###autoload
2576 (defun bmkp-bmenu-add-tags-to-marked (tags &optional msgp) ; Bound to `T > +' in bookmark list
2577   "Add TAGS to each of the marked bookmarks.
2578 TAGS is a list of strings.
2579 Hit `RET' to enter each tag, then hit `RET' again after the last tag.
2580 You can use completion to enter each tag, but you are not limited to
2581 choosing existing tags."
2582   (interactive (list (bmkp-read-tags-completing) 'msg))
2583   (bmkp-bmenu-barf-if-not-in-menu-list)
2584   (let ((marked  (bmkp-marked-bookmarks-only)))
2585     (unless marked (error "No marked bookmarks"))
2586     (when msgp (message "Adding tags..."))
2587     (dolist (bmk  (mapcar #'car marked)) (bmkp-add-tags bmk tags nil 'NO-CACHE-UPDATE)))
2588   (bmkp-tags-list)                      ; Update the tags cache (only once, at end).
2589   (when (and msgp tags) (message "Tags added: %S" tags)))
2590
2591 ;;;###autoload
2592 (defun bmkp-bmenu-remove-tags-from-marked (tags &optional msgp) ; Bound to `T > -' in bookmark list
2593   "Remove TAGS from each of the marked bookmarks.
2594 Hit `RET' to enter each tag, then hit `RET' again after the last tag.
2595 You can use completion to enter each tag."
2596   (interactive (let ((cand-tags  ()))
2597                  (dolist (bmk  (bmkp-marked-bookmarks-only))
2598                    (setq cand-tags  (bmkp-set-union cand-tags (bmkp-get-tags bmk))))
2599                  (unless cand-tags (error "No tags to remove"))
2600                  (list (bmkp-read-tags-completing cand-tags t) 'msg)))
2601   (bmkp-bmenu-barf-if-not-in-menu-list)
2602   (let ((marked  (bmkp-marked-bookmarks-only)))
2603     (unless marked (error "No marked bookmarks"))
2604     (when msgp (message "Removing tags..."))
2605     (dolist (bmk  (mapcar #'car marked)) (bmkp-remove-tags bmk tags nil 'NO-CACHE-UPDATE)))
2606   (bmkp-tags-list)                      ; Update the tags cache (only once, at end).
2607   (when (and msgp tags) (message "Tags removed: %S" tags)))
2608
2609 ;;;###autoload
2610 (defun bmkp-bmenu-mark-bookmarks-tagged-regexp (regexp &optional notp) ; `T m %' in bookmark list
2611   "Mark bookmarks any of whose tags match REGEXP.
2612 With a prefix arg, mark all that are tagged but have no matching tags."
2613   (interactive "sRegexp: \nP")
2614   (bmkp-bmenu-barf-if-not-in-menu-list)
2615   (save-excursion
2616     (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
2617     (let ((count  0)
2618           tags anyp)
2619       (while (not (eobp))
2620         (setq tags  (bmkp-get-tags (bookmark-bmenu-bookmark))
2621               anyp  (and tags (bmkp-some (lambda (tag) (string-match regexp (bmkp-tag-name tag)))
2622                                          tags)))
2623         (if (not (and tags (if notp (not anyp) anyp)))
2624             (forward-line 1)
2625           (bookmark-bmenu-mark)
2626           (setq count  (1+ count))))
2627       (if (= 1 count) (message "1 bookmark matched") (message "%d bookmarks matched" count)))))
2628
2629 ;;;###autoload
2630 (defun bmkp-bmenu-mark-bookmarks-tagged-all (tags &optional none-p msgp) ; `T m *' in bookmark list
2631   "Mark all visible bookmarks that are tagged with *each* tag in TAGS.
2632 As a special case, if TAGS is empty, then mark the bookmarks that have
2633 any tags at all (i.e., at least one tag).
2634
2635 With a prefix arg, mark all that are *not* tagged with *any* TAGS."
2636   (interactive (list (bmkp-read-tags-completing) current-prefix-arg 'msg))
2637   (bmkp-bmenu-barf-if-not-in-menu-list)
2638   (bmkp-bmenu-mark/unmark-bookmarks-tagged-all/none tags none-p nil msgp))
2639
2640 ;;;###autoload
2641 (defun bmkp-bmenu-mark-bookmarks-tagged-none (tags &optional allp msgp) ; `T m ~ +' in bookmark list
2642   "Mark all visible bookmarks that are not tagged with *any* tag in TAGS.
2643 As a special case, if TAGS is empty, then mark the bookmarks that have
2644 no tags at all.
2645
2646 With a prefix arg, mark all that are tagged with *each* tag in TAGS."
2647   (interactive (list (bmkp-read-tags-completing) current-prefix-arg 'msg))
2648   (bmkp-bmenu-barf-if-not-in-menu-list)
2649   (bmkp-bmenu-mark/unmark-bookmarks-tagged-all/none tags (not allp) nil msgp))
2650
2651 ;;;###autoload
2652 (defun bmkp-bmenu-mark-bookmarks-tagged-some (tags &optional somenotp msgp) ; `T m +' in bookmark list
2653   "Mark all visible bookmarks that are tagged with *some* tag in TAGS.
2654 As a special case, if TAGS is empty, then mark the bookmarks that have
2655 any tags at all.
2656
2657 With a prefix arg, mark all that are *not* tagged with *all* TAGS.
2658
2659 Hit `RET' to enter each tag, then hit `RET' again after the last tag.
2660 You can use completion to enter each tag."
2661   (interactive (list (bmkp-read-tags-completing) current-prefix-arg 'msg))
2662   (bmkp-bmenu-barf-if-not-in-menu-list)
2663   (bmkp-bmenu-mark/unmark-bookmarks-tagged-some/not-all tags somenotp nil msgp))
2664
2665 ;;;###autoload
2666 (defun bmkp-bmenu-mark-bookmarks-tagged-not-all (tags &optional somep msgp) ; `T m ~ *' in bmk list
2667   "Mark all visible bookmarks that are *not* tagged with *all* TAGS.
2668 As a special case, if TAGS is empty, then mark the bookmarks that have
2669 no tags at all.
2670
2671 With a prefix arg, mark all that are tagged with *some* tag in TAGS."
2672   (interactive (list (bmkp-read-tags-completing) current-prefix-arg 'msg))
2673   (bmkp-bmenu-barf-if-not-in-menu-list)
2674   (bmkp-bmenu-mark/unmark-bookmarks-tagged-some/not-all tags (not somep) nil msgp))
2675
2676 ;;;###autoload
2677 (defun bmkp-bmenu-unmark-bookmarks-tagged-regexp (regexp &optional notp) ; `T u %' in bookmark list
2678   "Unmark bookmarks any of whose tags match REGEXP.
2679 With a prefix arg, mark all that are tagged but have no matching tags."
2680   (interactive "sRegexp: \nP")
2681   (bmkp-bmenu-barf-if-not-in-menu-list)
2682   (save-excursion
2683     (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
2684     (let ((count  0)
2685           tags anyp)
2686       (while (not (eobp))
2687         (setq tags  (bmkp-get-tags (bookmark-bmenu-bookmark))
2688               anyp  (and tags (bmkp-some (lambda (tag) (string-match regexp (bmkp-tag-name tag)))
2689                                          tags)))
2690         (if (not (and tags (if notp (not anyp) anyp)))
2691             (forward-line 1)
2692           (bookmark-bmenu-unmark)
2693           (setq count  (1+ count))))
2694       (if (= 1 count) (message "1 bookmark matched") (message "%d bookmarks matched" count)))))
2695
2696 ;;;###autoload
2697 (defun bmkp-bmenu-unmark-bookmarks-tagged-all (tags &optional none-p msgp) ; `T u *' in bookmark list
2698   "Unmark all visible bookmarks that are tagged with *each* tag in TAGS.
2699 As a special case, if TAGS is empty, then unmark the bookmarks that have
2700 any tags at all.
2701
2702 With a prefix arg, unmark all that are *not* tagged with *any* TAGS."
2703   (interactive (list (bmkp-read-tags-completing) current-prefix-arg 'msg))
2704   (bmkp-bmenu-barf-if-not-in-menu-list)
2705   (bmkp-bmenu-mark/unmark-bookmarks-tagged-all/none tags none-p 'UNMARK msgp))
2706
2707 ;;;###autoload
2708 (defun bmkp-bmenu-unmark-bookmarks-tagged-none (tags &optional allp msgp) ; `T u ~ +' in bookmark list
2709   "Unmark all visible bookmarks that are *not* tagged with *any* TAGS.
2710 As a special case, if TAGS is empty, then unmark the bookmarks that have
2711 no tags at all.
2712
2713 With a prefix arg, unmark all that are tagged with *each* tag in TAGS."
2714   (interactive (list (bmkp-read-tags-completing) current-prefix-arg 'msg))
2715   (bmkp-bmenu-barf-if-not-in-menu-list)
2716   (bmkp-bmenu-mark/unmark-bookmarks-tagged-all/none tags (not allp) 'UNMARK msgp))
2717
2718 ;;;###autoload
2719 (defun bmkp-bmenu-unmark-bookmarks-tagged-some (tags &optional somenotp msgp) ; `T u +' in bmk list
2720   "Unmark all visible bookmarks that are tagged with *some* tag in TAGS.
2721 As a special case, if TAGS is empty, then unmark the bookmarks that have
2722 any tags at all.
2723
2724 With a prefix arg, unmark all that are *not* tagged with *all* TAGS."
2725   (interactive (list (bmkp-read-tags-completing) current-prefix-arg 'msg))
2726   (bmkp-bmenu-barf-if-not-in-menu-list)
2727   (bmkp-bmenu-mark/unmark-bookmarks-tagged-some/not-all tags somenotp 'UNMARK msgp))
2728
2729 ;;;###autoload
2730 (defun bmkp-bmenu-unmark-bookmarks-tagged-not-all (tags &optional somep msgp) ; `T u ~ *' in bmk list
2731   "Unmark all visible bookmarks that are *not* tagged with *all* TAGS.
2732 As a special case, if TAGS is empty, then unmark the bookmarks that have
2733 no tags at all.
2734
2735 With a prefix arg, unmark all that are tagged with *some* TAGS."
2736   (interactive (list (bmkp-read-tags-completing) current-prefix-arg 'msg))
2737   (bmkp-bmenu-barf-if-not-in-menu-list)
2738   (bmkp-bmenu-mark/unmark-bookmarks-tagged-some/not-all tags (not somep) 'UNMARK msgp))
2739
2740 (defun bmkp-bmenu-mark/unmark-bookmarks-tagged-all/none (tags &optional none-p unmarkp msgp)
2741   "Mark or unmark visible bookmarks tagged with all or none of TAGS.
2742 TAGS is a list of strings, the tag names.
2743 NONEP non-nil means mark/unmark bookmarks that have none of the TAGS.
2744 UNMARKP non-nil means unmark; nil means mark.
2745 MSGP means display a status message.
2746
2747 As a special case, if TAGS is empty, then mark or unmark the bookmarks
2748 that have any tags at all, or if NONEP is non-nil then mark or unmark
2749 those that have no tags at all."
2750   (with-current-buffer "*Bookmark List*"
2751     (save-excursion  
2752       (let ((count  0)
2753             bmktags presentp)
2754         (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
2755         (while (not (eobp))
2756           (setq bmktags  (bmkp-get-tags (bookmark-bmenu-bookmark)))
2757           (if (not (if (null tags)
2758                        (if none-p (not bmktags) bmktags)
2759                      (and bmktags  (catch 'bmkp-b-mu-b-t-an
2760                                      (dolist (tag  tags)
2761                                        (setq presentp  (assoc-default tag bmktags nil t))
2762                                        (unless (if none-p (not presentp) presentp)
2763                                          (throw 'bmkp-b-mu-b-t-an nil)))
2764                                      t))))
2765               (forward-line 1)
2766             (if unmarkp (bookmark-bmenu-unmark) (bookmark-bmenu-mark))
2767             (setq count  (1+ count))))
2768         (when msgp (if (= 1 count)
2769                        (message "1 bookmark matched")
2770                      (message "%d bookmarks matched" count)))))))
2771
2772 (defun bmkp-bmenu-mark/unmark-bookmarks-tagged-some/not-all (tags &optional notallp unmarkp msgp)
2773   "Mark or unmark visible bookmarks tagged with any or not all of TAGS.
2774 TAGS is a list of strings, the tag names.
2775 NOTALLP non-nil means mark/unmark bookmarks that do not have all TAGS.
2776 UNMARKP non-nil means unmark; nil means mark.
2777 MSGP means display a status message.
2778
2779 As a special case, if TAGS is empty, then mark or unmark the bookmarks
2780 that have any tags at all, or if NOTALLP is non-nil then mark or
2781 unmark those that have no tags at all."
2782   (with-current-buffer "*Bookmark List*"
2783     (save-excursion  
2784       (let ((count  0)
2785             bmktags presentp)
2786         (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
2787         (while (not (eobp))
2788           (setq bmktags  (bmkp-get-tags (bookmark-bmenu-bookmark)))
2789           (if (not (if (null tags)
2790                        (if notallp (not bmktags) bmktags)
2791                      (and bmktags  (catch 'bmkp-b-mu-b-t-sna
2792                                      (dolist (tag  tags)
2793                                        (setq presentp  (assoc-default tag bmktags nil t))
2794                                        (when (if notallp (not presentp) presentp)
2795                                          (throw 'bmkp-b-mu-b-t-sna t)))
2796                                      nil))))
2797               (forward-line 1)
2798             (if unmarkp (bookmark-bmenu-unmark) (bookmark-bmenu-mark))
2799             (setq count  (1+ count))))
2800         (when msgp
2801           (if (= 1 count) (message "1 bookmark matched") (message "%d bookmarks matched" count)))))))
2802
2803 ;;;###autoload
2804 (defun bmkp-bmenu-copy-tags (&optional msgp) ; `T c', `T M-w', `mouse-3' menu in bookmark list.
2805   "Copy tags from this bookmark, so you can paste them to another bookmark."
2806   (interactive (list 'MSG))
2807   (bmkp-bmenu-barf-if-not-in-menu-list)
2808   (bookmark-bmenu-ensure-position)
2809   (bmkp-copy-tags (bookmark-bmenu-bookmark) msgp))
2810
2811 ;;;###autoload
2812 (defun bmkp-bmenu-paste-add-tags (&optional msgp) ; `T p', `T C-y', `mouse-3' menu in bookmark list.
2813   "Add tags to this bookmark that were copied from another bookmark."
2814   (interactive (list 'MSG))
2815   (bmkp-bmenu-barf-if-not-in-menu-list)
2816   (bookmark-bmenu-ensure-position)
2817   (bmkp-paste-add-tags (bookmark-bmenu-bookmark) msgp))
2818
2819 ;;;###autoload
2820 (defun bmkp-bmenu-paste-replace-tags (&optional msgp) ; `T q', `mouse-3' menu.
2821   "Replace tags for this bookmark with those copied from another bookmark."
2822   (interactive (list 'MSG))
2823   (bmkp-bmenu-barf-if-not-in-menu-list)
2824   (bookmark-bmenu-ensure-position)
2825   (bmkp-paste-replace-tags (bookmark-bmenu-bookmark) msgp))
2826
2827 ;;;###autoload
2828 (defun bmkp-bmenu-paste-add-tags-to-marked (&optional msgp) ; `T > p', `T > C-y'
2829   "Add tags that were copied from another bookmark to the marked bookmarks."
2830   (interactive (list 'MSG))
2831   (bmkp-bmenu-barf-if-not-in-menu-list)
2832   (let ((marked  (bmkp-marked-bookmarks-only)))
2833     (unless marked (error "No marked bookmarks"))
2834     (when msgp (message "Adding tags..."))
2835     (dolist (bmk  marked) (bmkp-paste-add-tags bmk nil 'NO-CACHE-UPDATE))
2836     (bmkp-tags-list)                    ; Update the tags cache (only once, at end).
2837     (when msgp (message "Tags added: %S" bmkp-copied-tags))))
2838
2839 ;;;###autoload
2840 (defun bmkp-bmenu-paste-replace-tags-for-marked (&optional msgp) ; `T > q'
2841   "Replace tags for the marked bookmarks with tags copied previously."
2842   (interactive (list 'MSG))
2843   (bmkp-bmenu-barf-if-not-in-menu-list)
2844   (let ((marked  (bmkp-marked-bookmarks-only)))
2845     (unless marked (error "No marked bookmarks"))
2846     (when msgp (message "Replacing tags..."))
2847     (dolist (bmk  marked) (bmkp-paste-replace-tags bmk nil 'NO-CACHE-UPDATE))
2848     (bmkp-tags-list)                    ; Update the tags cache (only once, at end).
2849     (when msgp (message "Replacement tags: %S" bmkp-copied-tags))))
2850
2851
2852 ;;(@* "General Menu-List (`-*bmenu-*') Commands and Functions")
2853 ;;  *** General Menu-List (`-*bmenu-*') Commands and Functions ***
2854
2855 ;;;###autoload
2856 (defun bmkp-bmenu-w32-open ()           ; Bound to `M-RET' in bookmark list.
2857   "Use `w32-browser' to open this bookmark."
2858   (interactive) (let ((bmkp-use-w32-browser-p  t))  (bookmark-bmenu-this-window)))
2859
2860 ;;;###autoload
2861 (defun bmkp-bmenu-w32-open-with-mouse (event) ; Bound to `M-mouse-2' in bookmark list.
2862   "Use `w32-browser' to open the bookmark clicked."
2863   (interactive "e")
2864   (save-excursion
2865     (with-current-buffer (window-buffer (posn-window (event-end event)))
2866       (save-excursion (goto-char (posn-point (event-end event)))
2867                       (let ((bmkp-use-w32-browser-p  t))  (bookmark-bmenu-other-window))))))
2868
2869 ;;;###autoload
2870 (defun bmkp-bmenu-w32-open-select ()    ; Bound to `M-o' in bookmark-list.
2871   "Use `w32-browser' to open this bookmark and all marked bookmarks."
2872   (interactive) (let ((bmkp-use-w32-browser-p  t))  (bookmark-bmenu-select)))
2873
2874 ;;;###autoload
2875 (defun bmkp-bmenu-mode-status-help ()   ; Bound to `C-h m' and `?' in bookmark list
2876   "`describe-mode' + current status of `*Bookmark List*' + face legend."
2877   (interactive)
2878   (unless (string= (buffer-name) "*Help*") (bmkp-bmenu-barf-if-not-in-menu-list))
2879   (with-current-buffer (get-buffer-create "*Help*")
2880     (with-output-to-temp-buffer "*Help*"
2881       (let ((buffer-read-only  nil)
2882             top)
2883         (erase-buffer)
2884         (save-excursion
2885           (let ((standard-output  (current-buffer)))
2886             (if (> emacs-major-version 21)
2887                 (describe-function-1 'bookmark-bmenu-mode)
2888               (describe-function-1 'bookmark-bmenu-mode nil t)))
2889           (help-setup-xref (list #'bmkp-bmenu-mode-status-help) (interactive-p))
2890           (goto-char (point-min))
2891           ;; This text must be the same as the last line of `bookmark-bmenu-mode' doc string.
2892           (search-forward "Each line represents an Emacs bookmark.\n\n\n" nil t)
2893           (delete-region (point-min) (point)) ; Get rid of intro from `describe-function'.
2894           (insert "*************************** Bookmark List ***************************\n\n")
2895           (insert "Major mode for editing a list of bookmarks.\n")
2896           (insert "Each line represents an Emacs bookmark.\n\n")
2897           (setq top  (point))
2898           ;; Add buttons to access help and Customize.
2899           ;; Not for Emacs 21.3 - its `help-insert-xref-button' signature is different.
2900           (when (and (> emacs-major-version 21) ; In `help-mode.el'.
2901                      (condition-case nil (require 'help-mode nil t) (error nil))
2902                      (fboundp 'help-insert-xref-button))
2903             (help-insert-xref-button "[Doc in Commentary]" 'bmkp-commentary-button)
2904             (insert "           ")
2905             (help-insert-xref-button "[Doc on the Web]" 'bmkp-help-button)
2906             (insert "           ")
2907             (help-insert-xref-button "[Customize]" 'bmkp-customize-button)
2908             (insert "\n\n")
2909             (setq top  (point))
2910             (goto-char (point-max))
2911             (insert "\nSend a Bookmark+ bug report: `\\[icicle-send-bug-report]'.\n\n")
2912             (help-insert-xref-button "[Doc in Commentary]" 'bmkp-commentary-button)
2913             (insert "           ")
2914             (help-insert-xref-button "[Doc on the Web]" 'bmkp-help-button)
2915             (insert "           ")
2916             (help-insert-xref-button "[Customize]" 'bmkp-customize-button)
2917             (insert "\n\n")
2918             (goto-char (point-min))
2919             (forward-line 2))
2920           (goto-char top)
2921           (insert (format
2922                    "\nCurrent Status\n-------------------------------\n
2923 Sorted:\t\t%s\nFiltering:\t%s\nMarked:\t\t%d\nOmitted:\t%d\nBookmark file:\t%s\n\n\n"
2924                    (if (not bmkp-sort-comparer)
2925                        "no"
2926                      (format "%s%s" (bmkp-current-sort-order)
2927                              ;; Code essentially the same as found in `bmkp-msg-about-sort-order'.
2928                              (if (not (and (consp bmkp-sort-comparer) ; Ordinary single predicate
2929                                            (consp (car bmkp-sort-comparer))))
2930                                  (if bmkp-reverse-sort-p "; reversed" "")
2931                                (if (not (cadr (car bmkp-sort-comparer)))
2932                                    ;; Single PRED.
2933                                    (if (or (and bmkp-reverse-sort-p (not bmkp-reverse-multi-sort-p))
2934                                            (and bmkp-reverse-multi-sort-p (not bmkp-reverse-sort-p)))
2935                                        "; reversed"
2936                                      "")
2937                                  ;; In case we want to distinguish:
2938                                  ;; (if (and bmkp-reverse-sort-p
2939                                  ;;          (not bmkp-reverse-multi-sort-p))
2940                                  ;;     "; reversed"
2941                                  ;;   (if (and bmkp-reverse-multi-sort-p
2942                                  ;;            (not bmkp-reverse-sort-p))
2943                                  ;;       "; reversed +"
2944                                  ;;     ""))
2945                                  
2946                                  ;; At least two PREDs.
2947                                  (cond ((and bmkp-reverse-sort-p (not bmkp-reverse-multi-sort-p))
2948                                         "; reversed")
2949                                        ((and bmkp-reverse-multi-sort-p (not bmkp-reverse-sort-p))
2950                                         "; each predicate group reversed")
2951                                        ((and bmkp-reverse-multi-sort-p bmkp-reverse-sort-p)
2952                                         "; order of predicate groups reversed")
2953                                        (t ""))))))
2954                    (or (and bmkp-bmenu-filter-function (downcase bmkp-bmenu-title)) "None")
2955                    (length bmkp-bmenu-marked-bookmarks)
2956                    (length bmkp-bmenu-omitted-bookmarks)
2957                    bmkp-current-bookmark-file))
2958           ;; Add face legend.
2959           (let ((gnus             "Gnus\n")
2960                 (info             "Info node\n")
2961                 (man              "Man page\n")
2962                 (url              "URL\n")
2963                 (local-no-region  "Local file with no region\n")
2964                 (local-w-region   "Local file with a region\n")
2965                 (buffer           "Buffer\n")
2966                 (no-buf           "No current buffer\n")
2967                 (bad              "Possibly invalid bookmark\n")
2968                 (remote           "Remote file or directory\n")
2969                 (sudo             "Remote accessed by `su' or `sudo'\n")
2970                 (local-dir        "Local directory\n")
2971                 (bookmark-list    "*Bookmark List*\n")
2972                 (bookmark-file    "Bookmark file\n")
2973                 (desktop          "Desktop\n")
2974                 (sequence         "Sequence\n")
2975                 (variable-list    "Variable list\n")
2976                 (function         "Function\n"))
2977             (put-text-property 0 (1- (length gnus))     'face 'bmkp-gnus         gnus)
2978             (put-text-property 0 (1- (length info))     'face 'bmkp-info         info)
2979             (put-text-property 0 (1- (length man))      'face 'bmkp-man          man)
2980             (put-text-property 0 (1- (length url))      'face 'bmkp-url          url)
2981             (put-text-property 0 (1- (length local-no-region))
2982                                'face 'bmkp-local-file-without-region             local-no-region)
2983             (put-text-property 0 (1- (length local-w-region))
2984                                'face 'bmkp-local-file-with-region                local-w-region)
2985             (put-text-property 0 (1- (length buffer))   'face 'bmkp-buffer       buffer)
2986             (put-text-property 0 (1- (length no-buf))   'face 'bmkp-non-file     no-buf)
2987             (put-text-property 0 (1- (length bad))      'face 'bmkp-bad-bookmark bad)
2988             (put-text-property 0 (1- (length remote))   'face 'bmkp-remote-file  remote)
2989             (put-text-property 0 (1- (length sudo))     'face 'bmkp-su-or-sudo   sudo)
2990             (put-text-property 0 (1- (length local-dir))
2991                                'face 'bmkp-local-directory                       local-dir)
2992             (put-text-property 0 (1- (length bookmark-list))
2993                                'face 'bmkp-bookmark-list                         bookmark-list)
2994             (put-text-property 0 (1- (length bookmark-file))
2995                                'face 'bmkp-bookmark-file                         bookmark-file)
2996             (put-text-property 0 (1- (length desktop))       'face 'bmkp-desktop       desktop)
2997             (put-text-property 0 (1- (length sequence))      'face 'bmkp-sequence      sequence)
2998             (put-text-property 0 (1- (length variable-list)) 'face 'bmkp-variable-list variable-list)
2999             (put-text-property 0 (1- (length function))      'face 'bmkp-function      function)
3000             (insert "Face Legend for Bookmark Types\n------------------------------\n\n")
3001             (insert gnus) (insert info) (insert man) (insert url) (insert local-no-region)
3002             (insert local-w-region) (insert buffer) (insert no-buf) (insert bad) (insert remote)
3003             (insert sudo) (insert local-dir) (insert bookmark-list) (insert bookmark-file)
3004             (insert desktop) (insert sequence) (insert variable-list) (insert function)
3005             (insert "\n\n")))))))
3006
3007 (when (and (> emacs-major-version 21)
3008            (condition-case nil (require 'help-mode nil t) (error nil))
3009            (get 'help-xref 'button-category-symbol)) ; In `button.el'
3010   (define-button-type 'bmkp-help-button
3011       :supertype 'help-xref
3012       'help-function #'(lambda () (browse-url "http://www.emacswiki.org/emacs/BookmarkPlus"))
3013       'help-echo
3014       (purecopy "mouse-2, RET: Bookmark+ documentation on the Emacs Wiki (requires Internet access)"))
3015   (define-button-type 'bmkp-commentary-button
3016       :supertype 'help-xref
3017       'help-function #'(lambda ()
3018                          (message "Getting Bookmark+ doc from file commentary...")
3019                          (finder-commentary "bookmark+-doc")
3020                          (when (condition-case nil (require 'linkd nil t) (error nil)) (linkd-mode 1))
3021                          (when (condition-case nil (require 'fit-frame nil t) (error nil))
3022                            (fit-frame)))
3023       'help-echo (purecopy "mouse-2, RET: Bookmark+ documentation (no Internet needed)"))
3024   (define-button-type 'bmkp-customize-button
3025       :supertype 'help-xref
3026       'help-function #'(lambda () (customize-group-other-window 'bookmark-plus))
3027       'help-echo (purecopy "mouse-2, RET: Customize/Browse Bookmark+ Options & Faces")))
3028
3029 ;;;###autoload
3030 (defun bmkp-bmenu-define-jump-marked-command () ; Bound to `M-c' in bookmark list
3031   "Define a command to jump to a bookmark that is one of those now marked.
3032 The bookmarks marked now will be those that are completion candidates
3033 for the command (but omitted bookmarks are excluded).
3034 Save the command definition in `bmkp-bmenu-commands-file'."
3035   (interactive)
3036   (bmkp-bmenu-barf-if-not-in-menu-list)
3037   (let* ((cands  (mapcar #'list
3038                          (bmkp-remove-if #'(lambda (bmk)
3039                                              (bmkp-bookmark-name-member bmk
3040                                                                         bmkp-bmenu-omitted-bookmarks))
3041                                          bmkp-bmenu-marked-bookmarks)))
3042          (fn     (intern (read-string "Define command to jump to a bookmark now marked: " nil
3043                                       'bmkp-bmenu-define-command-history)))
3044          (def    `(defun ,fn (bookmark-name &optional use-region-p)
3045                    (interactive (list (bmkp-read-bookmark-for-type nil ',cands t) current-prefix-arg))
3046                    (bmkp-jump-1 bookmark-name 'bmkp-select-buffer-other-window use-region-p))))
3047     (eval def)
3048     (with-current-buffer (get-buffer-create " *User Bookmark List Commands*")
3049       (goto-char (point-min))
3050       (delete-region (point-min) (point-max))
3051       (let ((print-length  nil)
3052             (print-level   nil))
3053         (pp def (current-buffer))
3054         (insert "\n")
3055         (condition-case nil
3056             (write-region (point-min) (point-max) bmkp-bmenu-commands-file 'append)
3057           (file-error (error "Cannot write `%s'" bmkp-bmenu-commands-file)))
3058         (kill-buffer (current-buffer))))
3059     (message "Command `%s' defined and saved in file `%s'" fn bmkp-bmenu-commands-file)))
3060
3061 ;;;###autoload
3062 (defun bmkp-bmenu-define-command ()     ; Bound to `c' in bookmark list
3063   "Define a command to use the current sort order, filter, and omit list.
3064 Prompt for the command name.  Save the command definition in
3065 `bmkp-bmenu-commands-file'.
3066
3067 The current sort order, filter function, omit list, and title for
3068 buffer `*Bookmark List*' are encapsulated as part of the command.
3069 Use the command at any time to restore them."
3070   (interactive)
3071   (let* ((fn   (intern (read-string "Define sort+filter command: " nil
3072                                     'bmkp-bmenu-define-command-history)))
3073          (def  `(defun ,fn ()
3074                  (interactive)
3075                  (setq
3076                   bmkp-sort-comparer               ',bmkp-sort-comparer
3077                   bmkp-reverse-sort-p              ',bmkp-reverse-sort-p
3078                   bmkp-reverse-multi-sort-p        ',bmkp-reverse-multi-sort-p
3079                   bmkp-bmenu-filter-function       ',bmkp-bmenu-filter-function
3080                   bmkp-bmenu-filter-pattern        ',bmkp-bmenu-filter-pattern
3081                   bmkp-bmenu-omitted-bookmarks     ',(bmkp-maybe-unpropertize-bookmark-names
3082                                                       bmkp-bmenu-omitted-bookmarks)
3083                   bmkp-bmenu-title                 ',bmkp-bmenu-title
3084                   bookmark-bmenu-toggle-filenames  ',bookmark-bmenu-toggle-filenames)
3085                  (bmkp-bmenu-refresh-menu-list)
3086                  (when (interactive-p)
3087                    (bmkp-msg-about-sort-order
3088                     (car (rassoc bmkp-sort-comparer bmkp-sort-orders-alist)))))))
3089     (eval def)
3090     (with-current-buffer (get-buffer-create " *User Bookmark List Commands*")
3091       (goto-char (point-min))
3092       (delete-region (point-min) (point-max))
3093       (let ((print-length  nil)
3094             (print-level   nil))
3095         (pp def (current-buffer))
3096         (insert "\n")
3097         (condition-case nil
3098             (write-region (point-min) (point-max) bmkp-bmenu-commands-file 'append)
3099           (file-error (error "Cannot write `%s'" bmkp-bmenu-commands-file)))
3100         (kill-buffer (current-buffer))))
3101     (message "Command `%s' defined and saved in file `%s'" fn bmkp-bmenu-commands-file)))
3102
3103 ;;;###autoload
3104 (defun bmkp-bmenu-define-full-snapshot-command () ; Bound to `C' in bookmark list
3105   "Define a command to restore the current bookmark-list state.
3106 Prompt for the command name.  Save the command definition in
3107 `bmkp-bmenu-commands-file'.
3108
3109 Be aware that the command definition can be quite large, since it
3110 copies the current bookmark list and accessory lists (hidden
3111 bookmarks, marked bookmarks, etc.).  For a lighter weight command, use
3112 `bmkp-bmenu-define-full-snapshot-command' instead.  That records only
3113 the omit list and the sort & filter information."
3114   (interactive)
3115   (let* ((fn   (intern (read-string "Define restore-snapshot command: " nil
3116                                     'bmkp-bmenu-define-command-history)))
3117          (def  `(defun ,fn ()
3118                  (interactive)
3119                  (setq
3120                   bmkp-sort-comparer                     ',bmkp-sort-comparer
3121                   bmkp-reverse-sort-p                    ',bmkp-reverse-sort-p
3122                   bmkp-reverse-multi-sort-p              ',bmkp-reverse-multi-sort-p
3123                   bmkp-latest-bookmark-alist             ',(bmkp-maybe-unpropertize-bookmark-names
3124                                                             bmkp-latest-bookmark-alist)
3125                   bmkp-bmenu-omitted-bookmarks           ',(bmkp-maybe-unpropertize-bookmark-names
3126                                                             bmkp-bmenu-omitted-bookmarks)
3127                   bmkp-bmenu-marked-bookmarks            ',(bmkp-maybe-unpropertize-bookmark-names
3128                                                             bmkp-bmenu-marked-bookmarks)
3129                   bmkp-bmenu-filter-function             ',bmkp-bmenu-filter-function
3130                   bmkp-bmenu-filter-pattern              ',bmkp-bmenu-filter-pattern
3131                   bmkp-bmenu-title                       ',bmkp-bmenu-title
3132                   bmkp-last-bmenu-bookmark               ',(and (get-buffer "*Bookmark List*")
3133                                                                 (with-current-buffer
3134                                                                     (get-buffer "*Bookmark List*")
3135                                                                   (bookmark-bmenu-bookmark)))
3136                   bmkp-last-specific-buffer              ',bmkp-last-specific-buffer
3137                   bmkp-last-specific-file                ',bmkp-last-specific-file
3138                   bookmark-bmenu-toggle-filenames        ',bookmark-bmenu-toggle-filenames
3139                   bmkp-bmenu-before-hide-marked-alist    ',(bmkp-maybe-unpropertize-bookmark-names
3140                                                             bmkp-bmenu-before-hide-marked-alist)
3141                   bmkp-bmenu-before-hide-unmarked-alist  ',(bmkp-maybe-unpropertize-bookmark-names
3142                                                             bmkp-bmenu-before-hide-unmarked-alist)
3143                   bmkp-last-bookmark-file                ',bmkp-last-bookmark-file
3144                   bmkp-current-bookmark-file             ',bmkp-current-bookmark-file)
3145                  ;;(bmkp-bmenu-refresh-menu-list)
3146                  (let ((bookmark-alist  (or bmkp-latest-bookmark-alist bookmark-alist)))
3147                    (bmkp-bmenu-list-1 'filteredp nil (interactive-p)))
3148                  (when bmkp-last-bmenu-bookmark
3149                    (with-current-buffer (get-buffer "*Bookmark List*")
3150                      (bmkp-bmenu-goto-bookmark-named bmkp-last-bmenu-bookmark)))
3151                  (when (interactive-p)
3152                    (bmkp-msg-about-sort-order
3153                     (car (rassoc bmkp-sort-comparer bmkp-sort-orders-alist)))))))
3154     (eval def)
3155     (with-current-buffer (get-buffer-create " *User Bookmark List Commands*")
3156       (goto-char (point-min))
3157       (delete-region (point-min) (point-max))
3158       (let ((print-length  nil)
3159             (print-level   nil)
3160             (print-circle  t))
3161         (pp def (current-buffer))
3162         (insert "\n")
3163         (condition-case nil
3164             (write-region (point-min) (point-max) bmkp-bmenu-commands-file 'append)
3165           (file-error (error "Cannot write `%s'" bmkp-bmenu-commands-file)))
3166         (kill-buffer (current-buffer))))
3167     (message "Command `%s' defined and saved in file `%s'" fn bmkp-bmenu-commands-file)))
3168
3169 (defun bmkp-maybe-unpropertize-bookmark-names (list)
3170   "Strip properties from the bookmark names in a copy of LIST.
3171 LIST is a bookmark alist or a list of bookmark names (strings).
3172 Return the updated copy.
3173
3174 Note, however, that this is a shallow copy, so the names are also
3175 stripped within any alist elements of the original LIST.
3176
3177 We do this because Emacs 20 has no `print-circle'. and otherwise
3178 property `bmkp-full-record' would make the state file unreadable.
3179
3180 Do nothing in Emacs 21 or later or if
3181 `bmkp-propertize-bookmark-names-flag' is nil.  In these cases, just
3182 return the list."
3183   (if (and (> emacs-major-version 20)   ; Emacs 21+.  Cannot just use (boundp 'print-circle).
3184            bmkp-propertize-bookmark-names-flag)
3185       list
3186     (let ((new-list  (copy-sequence list)))
3187       (dolist (bmk  new-list)
3188         (when (and (consp bmk) (stringp (car bmk))) (setq bmk  (car bmk)))
3189         (when (stringp bmk) (set-text-properties 0 (length bmk) nil bmk)))
3190       new-list)))
3191
3192 ;; This is a general command.  It is in this file because it uses macro `bmkp-define-sort-command'
3193 ;; and it is used mainly in the bookmark list display.
3194 ;;;###autoload
3195 (defun bmkp-define-tags-sort-command (tags &optional msgp) ; Bound to `T s' in bookmark list
3196   "Define a command to sort bookmarks in the bookmark list by tags.
3197 Hit `RET' to enter each tag, then hit `RET' again after the last tag.
3198
3199 The new command sorts first by the first tag in TAGS, then by the
3200 second, and so on.
3201
3202 Besides sorting for these specific tags, any bookmark that has a tag
3203 sorts before one that has no tags.  Otherwise, sorting is by bookmark
3204 name, alphabetically.
3205
3206 The name of the new command is `bmkp-bmenu-sort-' followed by the
3207 specified tags, in order, separated by hyphens (`-').  E.g., for TAGS
3208 \(\"alpha\" \"beta\"), the name is `bmkp-bmenu-sort-alpha-beta'."
3209   (interactive (list (bmkp-read-tags-completing) 'msg))
3210   (let ((sort-order  (concat "tags-" (mapconcat #'identity tags "-")))
3211         (doc-string  (read-string "Doc string for command: "))
3212         (comparer    ())
3213         def)
3214     (dolist (tag  tags)
3215       (push `(lambda (b1 b2)
3216               (let ((tags1  (bmkp-get-tags b1))
3217                     (tags2  (bmkp-get-tags b2)))
3218                 (cond ((and (assoc-default ,tag tags1 nil t)
3219                             (assoc-default ,tag tags2 nil t))  nil)
3220                       ((assoc-default ,tag tags1 nil t)        '(t))
3221                       ((assoc-default ,tag tags2 nil t)        '(nil))
3222                       ((and tags1 tags2)                       nil)
3223                       (tags1                                   '(t))
3224                       (tags2                                   '(nil))
3225                       (t                                       nil))))
3226             comparer))
3227     (setq comparer  (nreverse comparer)
3228           comparer  (list comparer 'bmkp-alpha-p))
3229     (eval (setq def  (macroexpand `(bmkp-define-sort-command ,sort-order ,comparer ,doc-string))))
3230     (with-current-buffer (get-buffer-create " *User Bookmark List Commands*")
3231       (goto-char (point-min))
3232       (delete-region (point-min) (point-max))
3233       (let ((print-length  nil)
3234             (print-level   nil))
3235         (pp def (current-buffer))
3236         (insert "\n")
3237         (condition-case nil
3238             (write-region (point-min) (point-max) bmkp-bmenu-commands-file 'append)
3239           (file-error (error "Cannot write `%s'" bmkp-bmenu-commands-file)))
3240         (kill-buffer (current-buffer))))
3241     (when msgp (message "Defined and saved command `%s'"
3242                         (concat "bmkp-bmenu-sort-" sort-order)))))
3243
3244 ;;;###autoload
3245 (defun bmkp-bmenu-edit-bookmark (&optional internalp) ; Bound to `E' in bookmark list
3246   "Edit the bookmark under the cursor: its name and file name.
3247 With a prefix argument, edit the complete bookmark record (the
3248 internal, Lisp form)."
3249   (interactive "P")
3250   (bmkp-bmenu-barf-if-not-in-menu-list)
3251   (bookmark-bmenu-ensure-position)
3252   (let ((bmk-name  (bookmark-bmenu-bookmark)))
3253     (if internalp
3254         (bmkp-edit-bookmark-record bmk-name)
3255       (let* ((new-data  (bmkp-edit-bookmark bmk-name))
3256              (new-name  (car new-data)))
3257         (if (not new-data)
3258             (message "No changes made")
3259           (bmkp-refresh-menu-list new-name))))))
3260
3261 ;;;###autoload
3262 (defun bmkp-bmenu-edit-tags ()          ; Bound to `T e' in bookmark list
3263   "Edit the tags of the bookmark under the cursor.
3264 The edited value must be a list each of whose elements is either a
3265 string or a cons whose key is a string."
3266   (interactive)
3267   (bmkp-bmenu-barf-if-not-in-menu-list)
3268   (bookmark-bmenu-ensure-position)
3269   (bmkp-edit-tags (bookmark-bmenu-bookmark)))
3270
3271 (defun bmkp-bmenu-propertize-item (bookmark start end)
3272   "Propertize buffer from START to END, indicating bookmark types.
3273 This propertizes the name of BOOKMARK.
3274 Also give this region the property `bmkp-bookmark-name' with as value
3275 the name of BOOKMARK as a propertized string.
3276
3277 The propertized string has property `bmkp-full-record' with value
3278 BOOKMARK, which is the full bookmark record, with the string as its
3279 car.
3280
3281 Return the propertized string (the bookmark name)."
3282   (setq bookmark  (bookmark-get-bookmark bookmark))
3283   (let* ((bookmark-name  (bookmark-name-from-full-record bookmark))
3284          (buffp          (bmkp-get-buffer-name bookmark))
3285
3286          (filep          (bookmark-get-filename bookmark))
3287          (sudop          (and filep  (boundp 'tramp-file-name-regexp)
3288                               (string-match tramp-file-name-regexp filep)
3289                               (string-match bmkp-su-or-sudo-regexp filep))))
3290     ;; Put the full bookmark itself on string `bookmark-name' as property `bmkp-full-record'.
3291     ;; Then put that string on the name in the buffer text as property `bmkp-bookmark-name'.
3292     (put-text-property 0 (length bookmark-name) 'bmkp-full-record bookmark bookmark-name)
3293     (put-text-property start end 'bmkp-bookmark-name bookmark-name)
3294     ;; Add faces, mouse face, and tooltips, to characterize the bookmark type.
3295     (add-text-properties
3296      start  end
3297      (cond ((bmkp-sequence-bookmark-p bookmark) ; Sequence bookmark
3298             (append (bmkp-face-prop 'bmkp-sequence)
3299                     '(mouse-face highlight follow-link t
3300                       help-echo "mouse-2: Invoke the bookmarks in this sequence")))
3301            ((bmkp-function-bookmark-p bookmark) ; Function bookmark
3302             (append (bmkp-face-prop 'bmkp-function)
3303                     '(mouse-face highlight follow-link t
3304                       help-echo "mouse-2: Invoke this function bookmark")))
3305            ((bmkp-variable-list-bookmark-p bookmark) ; Variable-list bookmark
3306             (append (bmkp-face-prop 'bmkp-variable-list)
3307                     '(mouse-face highlight follow-link t
3308                       help-echo "mouse-2: Invoke this variable-list bookmark")))
3309            ((bmkp-bookmark-list-bookmark-p bookmark) ; Bookmark-list bookmark
3310             (append (bmkp-face-prop 'bmkp-bookmark-list)
3311                     '(mouse-face highlight follow-link t
3312                       help-echo "mouse-2: Invoke this bookmark-list bookmark")))
3313            ((bmkp-desktop-bookmark-p bookmark) ; Desktop bookmark
3314             (append (bmkp-face-prop 'bmkp-desktop)
3315                     '(mouse-face highlight follow-link t
3316                       help-echo "mouse-2: Jump to this desktop bookmark")))
3317            ((bmkp-bookmark-file-bookmark-p bookmark) ; Bookmark-file bookmark
3318             (append (bmkp-face-prop 'bmkp-bookmark-file)
3319                     '(mouse-face highlight follow-link t
3320                       help-echo "mouse-2: Load this bookmark's bookmark file")))
3321            ((bmkp-info-bookmark-p bookmark) ; Info bookmark
3322             (append (bmkp-face-prop 'bmkp-info)
3323                     '(mouse-face highlight follow-link t
3324                       help-echo "mouse-2: Jump to this Info bookmark")))
3325            ((bmkp-man-bookmark-p bookmark) ; Man bookmark
3326             (append (bmkp-face-prop 'bmkp-man)
3327                     '(mouse-face highlight follow-link t
3328                       help-echo (format "mouse-2 Goto `man' page"))))
3329            ((bmkp-gnus-bookmark-p bookmark) ; Gnus bookmark
3330             (append (bmkp-face-prop 'bmkp-gnus)
3331                     '(mouse-face highlight follow-link t
3332                       help-echo "mouse-2: Jump to this Gnus bookmark")))
3333            ((bmkp-url-bookmark-p bookmark) ; URL bookmark
3334             (append (bmkp-face-prop 'bmkp-url)
3335                     `(mouse-face highlight follow-link t
3336                       help-echo (format "mouse-2: Jump to URL `%s'" ,filep))))
3337            ((and sudop (not (bmkp-root-or-sudo-logged-p))) ; Root/sudo not logged in
3338             (append (bmkp-face-prop 'bmkp-su-or-sudo)
3339                     `(mouse-face highlight follow-link t
3340                       help-echo (format "mouse-2: Jump to (visit) file `%s'" ,filep))))
3341            ;; Test for remoteness before any other tests of the file itself
3342            ;; (e.g. `file-exists-p'), so we don't prompt for a password etc.
3343            ((and filep (bmkp-file-remote-p filep) (not sudop)) ; Remote file (ssh, ftp)
3344             (append (bmkp-face-prop 'bmkp-remote-file)
3345                     `(mouse-face highlight follow-link t
3346                       help-echo (format "mouse-2: Jump to (visit) remote file `%s'" ,filep))))
3347            ((and filep (file-directory-p filep)) ; Local directory
3348             (append (bmkp-face-prop 'bmkp-local-directory)
3349                     `(mouse-face highlight follow-link t
3350                       help-echo (format "mouse-2: Dired directory `%s'" ,filep))))
3351            ((and filep (file-exists-p filep) ; Local file with region
3352                  (bmkp-region-bookmark-p bookmark))
3353             (append (bmkp-face-prop 'bmkp-local-file-with-region)
3354                     `(mouse-face highlight follow-link t
3355                       help-echo (format "mouse-2: Activate region in file `%s'" ,filep))))
3356            ((and filep (file-exists-p filep)) ; Local file without region
3357             (append (bmkp-face-prop 'bmkp-local-file-without-region)
3358                     `(mouse-face highlight follow-link t
3359                       help-echo (format "mouse-2: Jump to (visit) file `%s'" ,filep))))
3360            ((and buffp (get-buffer buffp) (equal filep bmkp-non-file-filename)) ; Buffer
3361             (append (bmkp-face-prop 'bmkp-buffer)
3362                     `(mouse-face highlight follow-link t
3363                       help-echo (format "mouse-2: Jump to buffer `%s'" ,buffp))))
3364            ((and buffp  (or (not filep) (equal filep bmkp-non-file-filename)
3365                             (not (file-exists-p filep)))) ; Buffer bookmark, but no buffer.
3366             (append (bmkp-face-prop 'bmkp-non-file)
3367                     `(mouse-face highlight follow-link t
3368                       help-echo (format "mouse-2: Jump to buffer `%s'" ,buffp))))
3369            (t (append (bmkp-face-prop 'bmkp-bad-bookmark)
3370                       `(mouse-face highlight follow-link t
3371                         help-echo (format "BAD BOOKMARK (maybe): `%s'" ,filep))))))
3372     bookmark-name))
3373
3374 ;;;###autoload
3375 (defun bmkp-bmenu-quit ()               ; Bound to `q' in bookmark list
3376   "Quit the bookmark list (aka \"menu list\").
3377 If `bmkp-bmenu-state-file' is non-nil, then save the state, to be
3378 restored the next time the bookmark list is shown.  Otherwise, reset
3379 the internal lists that record menu-list markings."
3380   (interactive)
3381   (bmkp-bmenu-barf-if-not-in-menu-list)
3382   (if (not bmkp-bmenu-state-file)
3383       (setq bmkp-bmenu-marked-bookmarks            ()
3384             bmkp-bmenu-before-hide-marked-alist    ()
3385             bmkp-bmenu-before-hide-unmarked-alist  ())
3386     (bmkp-save-menu-list-state)
3387     (setq bmkp-bmenu-first-time-p  t))
3388   (quit-window))
3389
3390 (defun bmkp-bmenu-goto-bookmark-named (name)
3391   "Go to the first bookmark whose name matches NAME (a string).  
3392 If NAME has non-nil property `bmkp-full-record' then go to the
3393 bookmark it indicates.  Otherwise, just go to the first bookmark with
3394 the same name."
3395   (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
3396   (let ((full  (get-text-property 0 'bmkp-full-record name)))
3397     (while (and (not (eobp))
3398                 (not (if full
3399                          (equal full (get-text-property 0 'bmkp-full-record (bookmark-bmenu-bookmark)))
3400                        (equal name (bookmark-bmenu-bookmark)))))
3401       (forward-line 1)))
3402   (bookmark-bmenu-ensure-position))     ; Just in case we fall off the end.
3403
3404 ;; This is a general function.  It is in this file because it is used only by the bmenu code.
3405 (defun bmkp-bmenu-barf-if-not-in-menu-list ()
3406   "Raise an error if current buffer is not `*Bookmark List*'."
3407   (unless (equal (buffer-name (current-buffer)) "*Bookmark List*")
3408     (error "You can only use this command in buffer `*Bookmark List*'")))
3409
3410
3411 ;;(@* "Sorting - Commands")
3412 ;;  *** Sorting - Commands ***
3413
3414 ;;;###autoload
3415 (defun bmkp-bmenu-change-sort-order-repeat (arg) ; Bound to `s s'... in bookmark list
3416   "Cycle to the next sort order.
3417 With a prefix arg, reverse current sort order.
3418 This is a repeatable version of `bmkp-bmenu-change-sort-order'."
3419   (interactive "P")
3420   (require 'repeat)
3421   (bmkp-repeat-command 'bmkp-bmenu-change-sort-order))
3422
3423 ;;;###autoload
3424 (defun bmkp-bmenu-change-sort-order (&optional arg)
3425   "Cycle to the next sort order.
3426 With a prefix arg, reverse the current sort order."
3427   (interactive "P")
3428   (bmkp-bmenu-barf-if-not-in-menu-list)
3429   (setq bmkp-sort-orders-for-cycling-alist  (delq nil bmkp-sort-orders-for-cycling-alist))
3430   (if arg
3431       (bmkp-reverse-sort-order)
3432     (let ((current-bmk  (bookmark-bmenu-bookmark))
3433           next-order)
3434       (let ((orders  (mapcar #'car bmkp-sort-orders-for-cycling-alist)))
3435         (setq next-order          (or (cadr (member (bmkp-current-sort-order) orders))  (car orders))
3436               bmkp-sort-comparer  (cdr (assoc next-order bmkp-sort-orders-for-cycling-alist))))
3437       (message "Sorting...")
3438       (bookmark-bmenu-surreptitiously-rebuild-list)
3439       (when current-bmk                 ; Put cursor back on the right line.
3440         (bmkp-bmenu-goto-bookmark-named current-bmk))
3441       (when (interactive-p) (bmkp-msg-about-sort-order next-order)))))
3442
3443 ;; This is a general command.  It is in this file because it is used only by the bmenu code.
3444 ;;;###autoload
3445 (defun bmkp-reverse-sort-order ()       ; Bound to `s r' in bookmark list
3446   "Reverse the current bookmark sort order.
3447 If you combine this with \\<bookmark-bmenu-mode-map>\
3448 `\\[bmkp-reverse-multi-sort-order]', then see the doc for that command."
3449   (interactive)
3450   (bmkp-bmenu-barf-if-not-in-menu-list)
3451   (setq bmkp-reverse-sort-p  (not bmkp-reverse-sort-p))
3452   (let ((current-bmk  (bookmark-bmenu-bookmark)))
3453     (bookmark-bmenu-surreptitiously-rebuild-list)
3454     (when current-bmk                   ; Put cursor back on the right line.
3455       (bmkp-bmenu-goto-bookmark-named current-bmk)))
3456   (when (interactive-p) (bmkp-msg-about-sort-order (bmkp-current-sort-order))))
3457
3458 ;; This is a general command.  It is in this file because it is used only by the bmenu code.
3459 ;;;###autoload
3460 (defun bmkp-reverse-multi-sort-order () ; Bound to `s C-r' in bookmark list
3461   "Reverse the application of multi-sorting predicates.
3462 These are the PRED predicates described for option
3463 `bmkp-sort-comparer'.
3464
3465 This reverses the order in which the predicates are tried, and it
3466 also complements the truth value returned by each predicate.
3467
3468 For example, if the list of multi-sorting predicates is (p1 p2 p3),
3469 then the predicates are tried in the order: p3, p2, p1.  And if a
3470 predicate returns true, `(t)', then the effect is as if it returned
3471 false, `(nil)', and vice versa.
3472
3473 The use of multi-sorting predicates tends to group bookmarks, with the
3474 first predicate corresponding to the first bookmark group etc.
3475
3476 The effect of \\<bookmark-bmenu-mode-map>`\\[bmkp-reverse-multi-sort-order]' is \
3477 roughly as follows:
3478
3479  - without also `\\[bmkp-reverse-sort-order]', it reverses the bookmark order in each \
3480 group
3481
3482  - combined with `\\[bmkp-reverse-sort-order]', it reverses the order of the bookmark
3483    groups, but not the bookmarks within a group
3484
3485 This is a rough description.  The actual behavior can be complex,
3486 because of how each predicate is defined.  If this description helps
3487 you, fine.  If not, just experiment and see what happens. \;-)
3488
3489 Remember that ordinary `\\[bmkp-reverse-sort-order]' reversal on its own is \
3490 straightforward.
3491 If you find `\\[bmkp-reverse-multi-sort-order]' confusing or not helpful, then do not \
3492 use it."
3493   (interactive)
3494   (bmkp-bmenu-barf-if-not-in-menu-list)
3495   (setq bmkp-reverse-multi-sort-p  (not bmkp-reverse-multi-sort-p))
3496   (let ((current-bmk  (bookmark-bmenu-bookmark)))
3497     (bookmark-bmenu-surreptitiously-rebuild-list)
3498     (when current-bmk                   ; Put cursor back on the right line.
3499       (bmkp-bmenu-goto-bookmark-named current-bmk)))
3500   (when (interactive-p) (bmkp-msg-about-sort-order (bmkp-current-sort-order))))
3501
3502
3503
3504 ;; The ORDER of the macro calls here defines the REVERSE ORDER of
3505 ;; `bmkp-sort-orders-alist'.  The first here is thus also the DEFAULT sort order.
3506 ;; Entries are traversed by `s s'..., in `bmkp-sort-orders-alist' order.
3507
3508 (bmkp-define-sort-command               ; Bound to `s k' in bookmark list (`k' for "kind")
3509  "by bookmark type"                     ; `bmkp-bmenu-sort-by-bookmark-type'
3510  ((bmkp-info-cp bmkp-url-cp bmkp-gnus-cp bmkp-local-file-type-cp bmkp-handler-cp)
3511   bmkp-alpha-p)
3512  "Sort bookmarks by type: Info, URL, Gnus, files, other.")
3513
3514 (bmkp-define-sort-command               ; Bound to `s u' in bookmark list
3515  "by url"                           ; `bmkp-bmenu-sort-by-url'
3516  ((bmkp-url-cp) bmkp-alpha-p)
3517  "Sort URL bookmarks alphabetically by their URL/filename.
3518 When two bookmarks are not comparable this way, compare them by
3519 bookmark name.")
3520
3521 ;; $$$$$$ Not used now.
3522 ;; (bmkp-define-sort-command               ; Bound to `s w' in bookmark list
3523 ;;  "by w3m url"                           ; `bmkp-bmenu-sort-by-w3m-url'
3524 ;;  ((bmkp-w3m-cp) bmkp-alpha-p)
3525 ;;  "Sort W3M bookmarks alphabetically by their URL/filename.
3526 ;; When two bookmarks are not comparable this way, compare them by
3527 ;; bookmark name.")
3528
3529 (bmkp-define-sort-command               ; Bound to `s g' in bookmark list
3530  "by Gnus thread"                       ; `bmkp-bmenu-sort-by-Gnus-thread'
3531  ((bmkp-gnus-cp) bmkp-alpha-p)
3532  "Sort Gnus bookmarks by group, then by article, then by message.
3533 When two bookmarks are not comparable this way, compare them by
3534 bookmark name.")
3535
3536 (bmkp-define-sort-command               ; Bound to `s i' in bookmark list
3537  "by Info location"                     ; `bmkp-bmenu-sort-by-Info-location'
3538  ((bmkp-info-cp) bmkp-alpha-p)
3539  "Sort Info bookmarks by file name, then node name, then position.
3540 When two bookmarks are not comparable this way, compare them by
3541 bookmark name.")
3542
3543 (bmkp-define-sort-command               ; Bound to `s f u' in bookmark list
3544  "by last local file update"            ; `bmkp-bmenu-sort-by-last-local-file-update'
3545  ((bmkp-local-file-updated-more-recently-cp) bmkp-alpha-p)
3546  "Sort bookmarks by last local file update time.
3547 Sort a local file before a remote file, and a remote file before other
3548 bookmarks.  Otherwise, sort by bookmark name.")
3549
3550 (bmkp-define-sort-command               ; Bound to `s f t' in bookmark list
3551  "by last local file access"            ; `bmkp-bmenu-sort-by-last-local-file-access'
3552  ((bmkp-local-file-accessed-more-recently-cp) bmkp-alpha-p)
3553  "Sort bookmarks by last local file access time.
3554 A local file sorts before a remote file, which sorts before other
3555 bookmarks.  Otherwise, sort by bookmark name.")
3556
3557 (bmkp-define-sort-command               ; Bound to `s f s' in bookmark list
3558  "by local file size"                   ; `bmkp-bmenu-sort-by-local-file-size'
3559  ((bmkp-local-file-size-cp) bmkp-alpha-p)
3560  "Sort bookmarks by local file size.
3561 A local file sorts before a remote file, which sorts before other
3562 bookmarks.  Otherwise, sort by bookmark name.")
3563
3564 (bmkp-define-sort-command               ; Bound to `s f n' in bookmark list
3565  "by file name"                         ; `bmkp-bmenu-sort-by-file-name'
3566  ((bmkp-file-alpha-cp) bmkp-alpha-p)
3567  "Sort bookmarks by file name.
3568 When two bookmarks are not comparable by file name, compare them by
3569 bookmark name.")
3570
3571 (bmkp-define-sort-command               ; Bound to `s f d' in bookmark list (`d' for "directory")
3572  "by local file type"                   ; `bmkp-bmenu-sort-by-local-file-type'
3573  ((bmkp-local-file-type-cp) bmkp-alpha-p)
3574  "Sort bookmarks by local file type: file, symlink, directory.
3575 A local file sorts before a remote file, which sorts before other
3576 bookmarks.  Otherwise, sort by bookmark name.")
3577
3578 (bmkp-define-sort-command               ; Bound to `s >' in bookmark list
3579  "marked before unmarked"               ; `bmkp-bmenu-sort-marked-before-unmarked'
3580  ((bmkp-marked-cp) bmkp-alpha-p)
3581  "Sort bookmarks by putting marked before unmarked.
3582 Otherwise alphabetize by bookmark name.")
3583
3584 (bmkp-define-sort-command               ; Bound to `s b' in bookmark list
3585  "by last buffer or file access"        ; `bmkp-bmenu-sort-by-last-buffer-or-file-access'
3586  ((bmkp-buffer-last-access-cp bmkp-local-file-accessed-more-recently-cp)
3587   bmkp-alpha-p)
3588  "Sort bookmarks by last buffer access or last local file access.
3589 Sort a bookmark accessed more recently before one accessed less
3590 recently or not accessed.  Sort a bookmark to an existing buffer
3591 before a local file bookmark.  When two bookmarks are not comparable
3592 by such critera, sort them by bookmark name.  (In particular, sort
3593 remote-file bookmarks by bookmark name.")
3594
3595 (bmkp-define-sort-command               ; Bound to `s v' in bookmark list
3596  "by bookmark visit frequency"          ; `bmkp-bmenu-sort-by-bookmark-visit-frequency'
3597  ((bmkp-visited-more-cp) bmkp-alpha-p)
3598  "Sort bookmarks by the number of times they were visited as bookmarks.
3599 When two bookmarks are not comparable by visit frequency, compare them
3600 by bookmark name.")
3601
3602 (bmkp-define-sort-command               ; Bound to `s t' in bookmark list
3603  "by last bookmark access"              ; `bmkp-bmenu-sort-by-last-bookmark-access'
3604  ((bmkp-bookmark-last-access-cp) bmkp-alpha-p)
3605  "Sort bookmarks by the time of their last visit as bookmarks.
3606 When two bookmarks are not comparable by visit time, compare them
3607 by bookmark name.")
3608
3609 (bmkp-define-sort-command               ; Bound to `s 0' in bookmark list
3610  "by creation time"                     ; `bmkp-bmenu-sort-by-creation-time'
3611  ((bmkp-bookmark-creation-cp) bmkp-alpha-p)
3612  "Sort bookmarks by the time of their creation.
3613 When one or both of the bookmarks does not have a `created' entry),
3614 compare them by bookmark name.")
3615
3616 (bmkp-define-sort-command               ; Bound to `s n' in bookmark list
3617  "by bookmark name"                     ; `bmkp-bmenu-sort-by-bookmark-name'
3618  bmkp-alpha-p
3619  "Sort bookmarks by bookmark name, respecting `case-fold-search'.")
3620
3621 ;; This is a general option.  It is in this file because it is used mainly by the bmenu code.
3622 ;; Its definitions MUST COME AFTER the calls to macro `bmkp-define-sort-command'.
3623 ;; Otherwise, they won't pick up a populated `bmkp-sort-orders-alist'.
3624 (when (> emacs-major-version 20)
3625   (defcustom bmkp-sort-orders-for-cycling-alist (copy-sequence bmkp-sort-orders-alist)
3626     "*Alist of sort orders used for cycling via `s s'...
3627 This is a subset of the complete list of available sort orders,
3628 `bmkp-sort-orders-alist'.  This lets you cycle among fewer sort
3629 orders, if there are some that you do not use often.
3630
3631 See the doc for `bmkp-sort-orders-alist', for the structure of
3632 this value."
3633     :type '(alist
3634             :key-type (choice :tag "Sort order" string symbol)
3635             :value-type (choice
3636                          (const :tag "None (do not sort)" nil)
3637                          (function :tag "Sorting Predicate")
3638                          (list :tag "Sorting Multi-Predicate"
3639                           (repeat (function :tag "Component Predicate"))
3640                           (choice
3641                            (const :tag "None" nil)
3642                            (function :tag "Final Predicate")))))
3643     :group 'bookmark-plus))
3644
3645 (unless (> emacs-major-version 20)      ; Emacs 20: custom type `alist' doesn't exist.
3646   (defcustom bmkp-sort-orders-for-cycling-alist (copy-sequence bmkp-sort-orders-alist)
3647     "*Alist of sort orders used for cycling via `s s'...
3648 This is a subset of the complete list of available sort orders,
3649 `bmkp-sort-orders-alist'.  This lets you cycle among fewer sort
3650 orders, if there are some that you do not use often.
3651
3652 See the doc for `bmkp-sort-orders-alist', for the structure of this
3653 value."
3654     :type '(repeat
3655             (cons
3656              (choice :tag "Sort order" string symbol)
3657              (choice
3658               (const :tag "None (do not sort)" nil)
3659               (function :tag "Sorting Predicate")
3660               (list :tag "Sorting Multi-Predicate"
3661                (repeat (function :tag "Component Predicate"))
3662                (choice
3663                 (const :tag "None" nil)
3664                 (function :tag "Final Predicate"))))))
3665     :group 'bookmark-plus))
3666
3667
3668 ;;(@* "Other Bookmark+ Functions (`bmkp-*')")
3669 ;;  *** Other Bookmark+ Functions (`bmkp-*') ***
3670
3671 ;;;###autoload
3672 (defun bmkp-bmenu-describe-this+move-down (&optional defn) ; Bound to `C-down' in bookmark list
3673   "Describe bookmark of current line, then move down to the next bookmark.
3674 With a prefix argument, show the internal definition of the bookmark."
3675   (interactive "P")
3676   (bmkp-bmenu-describe-this-bookmark) (forward-line 1))
3677
3678 ;;;###autoload
3679 (defun bmkp-bmenu-describe-this+move-up (&optional defn) ; Bound to `C-up' in bookmark list
3680   "Describe bookmark of current line, then move down to the next bookmark.
3681 With a prefix argument, show the internal definition of the bookmark."
3682   (interactive "P")
3683   (bmkp-bmenu-describe-this-bookmark) (forward-line -1))
3684
3685 ;;;###autoload
3686 (defun bmkp-bmenu-describe-this-bookmark (&optional defn) ; Bound to `C-h RET' in bookmark list
3687   "Describe bookmark of current line.
3688 With a prefix argument, show the internal definition of the bookmark."
3689   (interactive "P")
3690   (bmkp-bmenu-barf-if-not-in-menu-list)
3691   (if defn
3692       (bmkp-describe-bookmark-internals (bookmark-bmenu-bookmark))
3693     (bmkp-describe-bookmark (bookmark-bmenu-bookmark))))
3694
3695 ;;;###autoload
3696 (defun bmkp-bmenu-describe-marked (&optional defn) ; Bound to `C-h >' in bookmark list
3697   "Describe the marked bookmarks.
3698 With a prefix argument, show the internal definitions."
3699   (interactive "P")
3700   (bmkp-bmenu-barf-if-not-in-menu-list)
3701   (help-setup-xref (list #'bmkp-describe-bookmark-marked) (interactive-p))
3702   (with-output-to-temp-buffer "*Help*"
3703     (dolist (bmk  (bmkp-marked-bookmarks-only))
3704       (if defn
3705           (let* ((bname      (bookmark-name-from-full-record bmk))
3706                  (help-text  (format "%s\n%s\n\n%s" bname (make-string (length bname) ?-)
3707                                      (pp-to-string bmk))))
3708             (princ help-text) (terpri))
3709         (princ (bmkp-bookmark-description bmk)) (terpri)))))
3710
3711 (defun bmkp-bmenu-get-marked-files ()
3712   "Return a list of the file names of the marked bookmarks.
3713 Marked bookmarks that have no associated file are ignored."
3714   (let ((files  ()))
3715     (dolist (bmk  bmkp-bmenu-marked-bookmarks)
3716       (when (bmkp-file-bookmark-p bmk) (push (bookmark-get-filename bmk) files)))
3717     files))
3718  
3719 ;;(@* "Keymaps")
3720 ;;; Keymaps ----------------------------------------------------------
3721
3722 ;; `bookmark-bmenu-mode-map'
3723
3724 (when (< emacs-major-version 21)
3725   (define-key bookmark-bmenu-mode-map (kbd "RET")          'bookmark-bmenu-this-window))
3726 (define-key bookmark-bmenu-mode-map "."                    'bmkp-bmenu-show-all)
3727 (define-key bookmark-bmenu-mode-map ">"                    'bmkp-bmenu-toggle-show-only-marked)
3728 (define-key bookmark-bmenu-mode-map "<"                    'bmkp-bmenu-toggle-show-only-unmarked)
3729 (define-key bookmark-bmenu-mode-map (kbd "M-<DEL>")        'bmkp-bmenu-unmark-all)
3730 (define-key bookmark-bmenu-mode-map "="                    nil) ; For Emacs 20
3731 (define-key bookmark-bmenu-mode-map "=bM"                  'bmkp-bmenu-mark-specific-buffer-bookmarks)
3732 (define-key bookmark-bmenu-mode-map "=fM"                  'bmkp-bmenu-mark-specific-file-bookmarks)
3733 (define-key bookmark-bmenu-mode-map "=bS"                  'bmkp-bmenu-show-only-specific-buffer)
3734 (define-key bookmark-bmenu-mode-map "=fS"                  'bmkp-bmenu-show-only-specific-file)
3735 (define-key bookmark-bmenu-mode-map "%"                    nil) ; For Emacs 20
3736 (define-key bookmark-bmenu-mode-map "%m"                   'bmkp-bmenu-regexp-mark)
3737 (define-key bookmark-bmenu-mode-map "*"                    nil) ; For Emacs 20
3738 (when (< emacs-major-version 21)
3739   (define-key bookmark-bmenu-mode-map "*m"                 'bookmark-bmenu-mark))
3740 (define-key bookmark-bmenu-mode-map "#"                    nil) ; For Emacs 20
3741 (define-key bookmark-bmenu-mode-map "#S"                   'bmkp-bmenu-show-only-autonamed)
3742 ;; `A' is `bookmark-bmenu-show-all-annotations' in vanilla Emacs.
3743 (define-key bookmark-bmenu-mode-map "\M-a"                 'bookmark-bmenu-show-all-annotations)
3744 (define-key bookmark-bmenu-mode-map "A"                    nil) ; For Emacs 20
3745 (define-key bookmark-bmenu-mode-map "AM"                   'bmkp-bmenu-mark-autofile-bookmarks)
3746 (define-key bookmark-bmenu-mode-map "AS"                   'bmkp-bmenu-show-only-autofiles)
3747 (define-key bookmark-bmenu-mode-map "B"                    nil) ; For Emacs 20
3748 (define-key bookmark-bmenu-mode-map "BM"                   'bmkp-bmenu-mark-non-file-bookmarks)
3749 (define-key bookmark-bmenu-mode-map "BS"                   'bmkp-bmenu-show-only-non-files)
3750 (define-key bookmark-bmenu-mode-map "c"                    'bmkp-bmenu-define-command)
3751 (define-key bookmark-bmenu-mode-map "C"                    'bmkp-bmenu-define-full-snapshot-command)
3752 (define-key bookmark-bmenu-mode-map "\M-c"                 'bmkp-bmenu-define-jump-marked-command)
3753 (define-key bookmark-bmenu-mode-map "D"                    'bmkp-bmenu-delete-marked)
3754 (define-key bookmark-bmenu-mode-map "\M-d"                 nil) ; For Emacs 20
3755 (define-key bookmark-bmenu-mode-map "\M-d>"                'bmkp-bmenu-dired-marked)
3756 (define-key bookmark-bmenu-mode-map "\M-d\M-m"             'bmkp-bmenu-mark-dired-bookmarks)
3757 (define-key bookmark-bmenu-mode-map "\M-d\M-s"             'bmkp-bmenu-show-only-dired)
3758 (define-key bookmark-bmenu-mode-map "E"                    'bmkp-bmenu-edit-bookmark)
3759 (define-key bookmark-bmenu-mode-map "F"                    nil) ; For Emacs 20
3760 (define-key bookmark-bmenu-mode-map "FM"                   'bmkp-bmenu-mark-file-bookmarks)
3761 (define-key bookmark-bmenu-mode-map "FS"                   'bmkp-bmenu-show-only-files)
3762 (define-key bookmark-bmenu-mode-map "g"                    'bmkp-bmenu-refresh-menu-list)
3763 (define-key bookmark-bmenu-mode-map "G"                    nil) ; For Emacs 20
3764 (define-key bookmark-bmenu-mode-map "GM"                   'bmkp-bmenu-mark-gnus-bookmarks)
3765 (define-key bookmark-bmenu-mode-map "GS"                   'bmkp-bmenu-show-only-gnus)
3766 (if (fboundp 'command-remapping)
3767     (define-key bookmark-bmenu-mode-map [remap describe-mode] 'bmkp-bmenu-mode-status-help)
3768   ;; In Emacs < 22, the `substitute-...' affects only `?', not `C-h m', so we add it separately.
3769   (substitute-key-definition 'describe-mode 'bmkp-bmenu-mode-status-help bookmark-bmenu-mode-map)
3770   (define-key bookmark-bmenu-mode-map "\C-hm"              'bmkp-bmenu-mode-status-help))
3771 (define-key bookmark-bmenu-mode-map (kbd "C-h >")          'bmkp-bmenu-describe-marked)
3772 (define-key bookmark-bmenu-mode-map (kbd "C-h RET")        'bmkp-bmenu-describe-this-bookmark)
3773 (define-key bookmark-bmenu-mode-map (kbd "C-h C-<return>") 'bmkp-bmenu-describe-this-bookmark)
3774 (define-key bookmark-bmenu-mode-map (kbd "C-<down>")       'bmkp-bmenu-describe-this+move-down)
3775 (define-key bookmark-bmenu-mode-map (kbd "C-<up>")         'bmkp-bmenu-describe-this+move-up)
3776 (define-key bookmark-bmenu-mode-map (kbd "M-<return>")     'bmkp-bmenu-w32-open)
3777 (define-key bookmark-bmenu-mode-map [M-mouse-2]            'bmkp-bmenu-w32-open-with-mouse)
3778 (when (featurep 'bookmark+-lit)
3779   (define-key bookmark-bmenu-mode-map "H"                  nil) ; For Emacs 20
3780   (define-key bookmark-bmenu-mode-map "H+"                 'bmkp-bmenu-set-lighting)
3781   (define-key bookmark-bmenu-mode-map "H>+"                'bmkp-bmenu-set-lighting-for-marked)
3782   (define-key bookmark-bmenu-mode-map "H>H"                'bmkp-bmenu-light-marked)
3783   (define-key bookmark-bmenu-mode-map "HH"                 'bmkp-bmenu-light)
3784   (define-key bookmark-bmenu-mode-map "HM"                 'bmkp-bmenu-mark-lighted-bookmarks)
3785   (define-key bookmark-bmenu-mode-map "HS"                 'bmkp-bmenu-show-only-lighted)
3786   (define-key bookmark-bmenu-mode-map "H>U"                'bmkp-bmenu-unlight-marked)
3787   (define-key bookmark-bmenu-mode-map "HU"                 'bmkp-bmenu-unlight))
3788 (define-key bookmark-bmenu-mode-map "I"                    nil) ; For Emacs 20
3789 (define-key bookmark-bmenu-mode-map "IM"                   'bmkp-bmenu-mark-info-bookmarks)
3790 (define-key bookmark-bmenu-mode-map "IS"                   'bmkp-bmenu-show-only-info-nodes)
3791 (define-key bookmark-bmenu-mode-map "K"                    nil) ; For Emacs 20
3792 (define-key bookmark-bmenu-mode-map "KM"                   'bmkp-bmenu-mark-desktop-bookmarks)
3793 (define-key bookmark-bmenu-mode-map "KS"                   'bmkp-bmenu-show-only-desktops)
3794 (define-key bookmark-bmenu-mode-map "L"                    'bmkp-switch-bookmark-file)
3795 (define-key bookmark-bmenu-mode-map "M"                    nil) ; For Emacs 20
3796 (define-key bookmark-bmenu-mode-map "MM"                   'bmkp-bmenu-mark-man-bookmarks)
3797 (define-key bookmark-bmenu-mode-map "MS"                   'bmkp-bmenu-show-only-man-pages)
3798 (define-key bookmark-bmenu-mode-map "\M-m"                 'bmkp-bmenu-mark-all)
3799 (define-key bookmark-bmenu-mode-map "O"                    nil) ; For Emacs 20
3800 (define-key bookmark-bmenu-mode-map "O>"                   'bmkp-bmenu-omit/unomit-marked)
3801 (define-key bookmark-bmenu-mode-map "OS"                   'bmkp-bmenu-show-only-omitted)
3802 (define-key bookmark-bmenu-mode-map "OU"                   'bmkp-unomit-all)
3803 (define-key bookmark-bmenu-mode-map "P"                    nil) ; For Emacs 20
3804 (define-key bookmark-bmenu-mode-map "PA"                  'bmkp-bmenu-filter-annotation-incrementally)
3805 (define-key bookmark-bmenu-mode-map "PB"               'bmkp-bmenu-filter-bookmark-name-incrementally)
3806 (define-key bookmark-bmenu-mode-map "PF"                   'bmkp-bmenu-filter-file-name-incrementally)
3807 (define-key bookmark-bmenu-mode-map "PT"                   'bmkp-bmenu-filter-tags-incrementally)
3808 (define-key bookmark-bmenu-mode-map "q"                    'bmkp-bmenu-quit)
3809 (define-key bookmark-bmenu-mode-map "\M-q"          'bmkp-bmenu-query-replace-marked-bookmarks-regexp)
3810 (define-key bookmark-bmenu-mode-map "R"                    nil) ; For Emacs 20
3811 (define-key bookmark-bmenu-mode-map "RM"                   'bmkp-bmenu-mark-region-bookmarks)
3812 (define-key bookmark-bmenu-mode-map "RS"                   'bmkp-bmenu-show-only-regions)
3813 (define-key bookmark-bmenu-mode-map "\M-r"                 'bookmark-bmenu-relocate) ; `R' in Emacs
3814 (define-key bookmark-bmenu-mode-map "S"                    'bookmark-bmenu-save) ; `s' in Emacs
3815 (define-key bookmark-bmenu-mode-map "s"                    nil) ; For Emacs 20
3816 (define-key bookmark-bmenu-mode-map "s>"                   'bmkp-bmenu-sort-marked-before-unmarked)
3817 (define-key bookmark-bmenu-mode-map "s0"                   'bmkp-bmenu-sort-by-creation-time)
3818 (define-key bookmark-bmenu-mode-map "sb"               'bmkp-bmenu-sort-by-last-buffer-or-file-access)
3819 (define-key bookmark-bmenu-mode-map "sfd"                  'bmkp-bmenu-sort-by-local-file-type)
3820 (define-key bookmark-bmenu-mode-map "sfn"                  'bmkp-bmenu-sort-by-file-name)
3821 (define-key bookmark-bmenu-mode-map "sfs"                  'bmkp-bmenu-sort-by-local-file-size)
3822 (define-key bookmark-bmenu-mode-map "sft"                  'bmkp-bmenu-sort-by-last-local-file-access)
3823 (define-key bookmark-bmenu-mode-map "sfu"                  'bmkp-bmenu-sort-by-last-local-file-update)
3824 (define-key bookmark-bmenu-mode-map "sg"                   'bmkp-bmenu-sort-by-Gnus-thread)
3825 (define-key bookmark-bmenu-mode-map "si"                   'bmkp-bmenu-sort-by-Info-location)
3826 (define-key bookmark-bmenu-mode-map "sk"                   'bmkp-bmenu-sort-by-bookmark-type)
3827 (define-key bookmark-bmenu-mode-map "sn"                   'bmkp-bmenu-sort-by-bookmark-name)
3828 (define-key bookmark-bmenu-mode-map "sr"                   'bmkp-reverse-sort-order)
3829 (define-key bookmark-bmenu-mode-map "s\C-r"                'bmkp-reverse-multi-sort-order)
3830 (define-key bookmark-bmenu-mode-map "ss"                   'bmkp-bmenu-change-sort-order-repeat)
3831 (define-key bookmark-bmenu-mode-map "st"                   'bmkp-bmenu-sort-by-last-bookmark-access)
3832 (define-key bookmark-bmenu-mode-map "su"                   'bmkp-bmenu-sort-by-url)
3833 (define-key bookmark-bmenu-mode-map "sv"                 'bmkp-bmenu-sort-by-bookmark-visit-frequency)
3834 ;; ;; (define-key bookmark-bmenu-mode-map "sw"                   'bmkp-bmenu-sort-by-w3m-url)
3835 (when (> emacs-major-version 22)        ; Emacs 23+
3836  (define-key bookmark-bmenu-mode-map (kbd "M-s a C-s")     'bmkp-bmenu-isearch-marked-bookmarks)
3837  (define-key bookmark-bmenu-mode-map (kbd "M-s a M-C-s") 'bmkp-bmenu-isearch-marked-bookmarks-regexp))
3838 (define-key bookmark-bmenu-mode-map (kbd "M-s a M-s")      'bmkp-bmenu-search-marked-bookmarks-regexp)
3839 (define-key bookmark-bmenu-mode-map "T"                    nil) ; For Emacs20
3840 (define-key bookmark-bmenu-mode-map "T>+"                  'bmkp-bmenu-add-tags-to-marked)
3841 (define-key bookmark-bmenu-mode-map "T>-"                  'bmkp-bmenu-remove-tags-from-marked)
3842 (define-key bookmark-bmenu-mode-map "T>p"                  'bmkp-bmenu-paste-add-tags-to-marked)
3843 (define-key bookmark-bmenu-mode-map "T>q"                  'bmkp-bmenu-paste-replace-tags-for-marked)
3844 (define-key bookmark-bmenu-mode-map "T>v"                  'bmkp-bmenu-set-tag-value-for-marked)
3845 (define-key bookmark-bmenu-mode-map "T>\C-y"               'bmkp-bmenu-paste-add-tags-to-marked)
3846 (define-key bookmark-bmenu-mode-map "T0"                   'bmkp-remove-all-tags)
3847 (define-key bookmark-bmenu-mode-map "T+"                   'bmkp-add-tags)
3848 (define-key bookmark-bmenu-mode-map "T-"                   'bmkp-remove-tags)
3849 (define-key bookmark-bmenu-mode-map "Tc"                   'bmkp-bmenu-copy-tags)
3850 (define-key bookmark-bmenu-mode-map "Td"                   'bmkp-remove-tags-from-all)
3851 (define-key bookmark-bmenu-mode-map "Te"                   'bmkp-bmenu-edit-tags)
3852 (define-key bookmark-bmenu-mode-map "Tl"                   'bmkp-list-all-tags)
3853 (define-key bookmark-bmenu-mode-map "Tm*"                  'bmkp-bmenu-mark-bookmarks-tagged-all)
3854 (define-key bookmark-bmenu-mode-map "Tm%"                  'bmkp-bmenu-mark-bookmarks-tagged-regexp)
3855 (define-key bookmark-bmenu-mode-map "Tm+"                  'bmkp-bmenu-mark-bookmarks-tagged-some)
3856 (define-key bookmark-bmenu-mode-map "Tm~*"                 'bmkp-bmenu-mark-bookmarks-tagged-not-all)
3857 (define-key bookmark-bmenu-mode-map "Tm~+"                 'bmkp-bmenu-mark-bookmarks-tagged-none)
3858 (define-key bookmark-bmenu-mode-map "Tp"                   'bmkp-bmenu-paste-add-tags)
3859 (define-key bookmark-bmenu-mode-map "Tq"                   'bmkp-bmenu-paste-replace-tags)
3860 (define-key bookmark-bmenu-mode-map "Tr"                   'bmkp-rename-tag)
3861 (define-key bookmark-bmenu-mode-map "Ts"                   'bmkp-define-tags-sort-command)
3862 (define-key bookmark-bmenu-mode-map "TS"                   'bmkp-bmenu-show-only-tagged)
3863 (define-key bookmark-bmenu-mode-map "Tu*"                  'bmkp-bmenu-unmark-bookmarks-tagged-all)
3864 (define-key bookmark-bmenu-mode-map "Tu%"                  'bmkp-bmenu-unmark-bookmarks-tagged-regexp)
3865 (define-key bookmark-bmenu-mode-map "Tu+"                  'bmkp-bmenu-unmark-bookmarks-tagged-some)
3866 (define-key bookmark-bmenu-mode-map "Tu~*"                'bmkp-bmenu-unmark-bookmarks-tagged-not-all)
3867 (define-key bookmark-bmenu-mode-map "Tu~+"                 'bmkp-bmenu-unmark-bookmarks-tagged-none)
3868 (define-key bookmark-bmenu-mode-map "Tv"                   'bmkp-bmenu-set-tag-value)
3869 (define-key bookmark-bmenu-mode-map "T\M-w"                'bmkp-bmenu-copy-tags)
3870 (define-key bookmark-bmenu-mode-map "T\C-y"                'bmkp-bmenu-paste-add-tags)
3871 (define-key bookmark-bmenu-mode-map "\M-l"                 'bmkp-toggle-saving-menu-list-state)
3872 (define-key bookmark-bmenu-mode-map "\M-~"                 'bmkp-toggle-saving-bookmark-file)
3873 (define-key bookmark-bmenu-mode-map "\M-t"            'bookmark-bmenu-toggle-filenames) ; `t' in Emacs
3874 (define-key bookmark-bmenu-mode-map "t"                    'bmkp-bmenu-toggle-marks)
3875 (define-key bookmark-bmenu-mode-map "U"                    'bmkp-bmenu-unmark-all)
3876 (define-key bookmark-bmenu-mode-map "\M-u"                 nil) ; For Emacs 20
3877 (define-key bookmark-bmenu-mode-map "\M-u\M-m"             'bmkp-bmenu-mark-url-bookmarks)
3878 (define-key bookmark-bmenu-mode-map "\M-u\M-s"             'bmkp-bmenu-show-only-urls)
3879 (define-key bookmark-bmenu-mode-map "V"                    nil) ; For Emacs20
3880 (define-key bookmark-bmenu-mode-map "VS"                   'bmkp-bmenu-show-only-variable-lists)
3881 (define-key bookmark-bmenu-mode-map "\M-o"                 'bmkp-bmenu-w32-open-select)
3882 (define-key bookmark-bmenu-mode-map "W"                    nil) ; For Emacs 20
3883 (define-key bookmark-bmenu-mode-map "WM"                   'bmkp-bmenu-mark-w3m-bookmarks)
3884 (define-key bookmark-bmenu-mode-map "WS"                   'bmkp-bmenu-show-only-w3m-urls)
3885 (define-key bookmark-bmenu-mode-map "X"                    nil) ; For Emacs 20
3886 (define-key bookmark-bmenu-mode-map "XM"                   'bmkp-bmenu-mark-bookmark-file-bookmarks)
3887 (define-key bookmark-bmenu-mode-map "XS"                   'bmkp-bmenu-show-only-bookmark-files)
3888
3889
3890 ;;; `Bookmark+' menu-bar menu in `*Bookmark List*'
3891
3892 (defvar bmkp-bmenu-menubar-menu (make-sparse-keymap "Bookmark+") "`Boomark+' menu-bar menu.")
3893 (define-key bookmark-bmenu-mode-map [menu-bar bmkp]
3894   (cons "Bookmark+" bmkp-bmenu-menubar-menu))
3895
3896 ;; Top level
3897 (define-key bmkp-bmenu-menubar-menu [bmkp-bmenu-quit]
3898   '(menu-item "Quit" bmkp-bmenu-quit
3899     :help "Quit the bookmark list, saving its state and the current set of bookmarks"))
3900 (define-key bmkp-bmenu-menubar-menu [bmkp-bmenu-describe-marked]
3901   '(menu-item "Describe Marked Bookmarks" bmkp-bmenu-describe-marked
3902     :help "Describe the marked bookmarks.  With `C-u' show internal format."))
3903 (define-key bmkp-bmenu-menubar-menu [bmkp-bmenu-describe-this-bookmark]
3904   '(menu-item "Describe This Bookmark" bmkp-bmenu-describe-this-bookmark
3905     :help "Describe this line's bookmark.  With `C-u' show internal format."))
3906 (define-key bmkp-bmenu-menubar-menu [bmkp-bmenu-mode-status-help]
3907   '(menu-item "Current Status, Mode Help" bmkp-bmenu-mode-status-help :keys "?"
3908     :help "Describe `*Bookmark List*' and show its current status"))
3909 (define-key bmkp-bmenu-menubar-menu [top-sep2] '("--"))
3910 (define-key bmkp-bmenu-menubar-menu [bmkp-toggle-saving-menu-list-state]
3911   '(menu-item "Toggle Autosaving Display State" bmkp-toggle-saving-menu-list-state
3912     :help "Toggle the value of option `bmkp-bmenu-state-file'"))
3913 (define-key bmkp-bmenu-menubar-menu [bmkp-toggle-saving-bookmark-file]
3914   '(menu-item "Toggle Autosaving Bookmark File" bmkp-toggle-saving-bookmark-file
3915     :help "Toggle the value of option `bookmark-save-flag'"))
3916 (define-key bmkp-bmenu-menubar-menu [bmkp-switch-bookmark-file]
3917   '(menu-item "Switch to Bookmark File..." bmkp-switch-bookmark-file
3918     :help "Switch to a different bookmark file, *replacing* the current set of bookmarks"))
3919 (define-key bmkp-bmenu-menubar-menu [bookmark-bmenu-load]
3920   '(menu-item "Add Bookmarks from File..." bookmark-bmenu-load
3921     :help "Load additional bookmarks from a bookmark file"))
3922 (define-key bmkp-bmenu-menubar-menu [bmkp-empty-file]
3923   '(menu-item "New (Empty) Bookmark File..." bmkp-empty-file
3924     :help "Create a new, empty bookmark file, or empty an existing bookmark file"))
3925 (define-key bmkp-bmenu-menubar-menu [bookmark-write]
3926   '(menu-item "Save As..." bookmark-write
3927     :help "Write the current set of bookmarks to a file whose name you enter"))
3928 (define-key bmkp-bmenu-menubar-menu [bookmark-bmenu-save]
3929   '(menu-item "Save" bookmark-bmenu-save
3930     :help "Save the current set of bookmarks to the current bookmark file"))
3931 (define-key bmkp-bmenu-menubar-menu [bmkp-bmenu-refresh-menu-list]
3932   '(menu-item "Refresh (Revert)" bmkp-bmenu-refresh-menu-list
3933     :help "Update the displayed bookmark list to reflect the currently defined bookmarks"))
3934 (define-key bmkp-bmenu-menubar-menu [top-sep1] '("--"))
3935
3936 (define-key bmkp-bmenu-menubar-menu [bmkp-make-function-bookmark]
3937   '(menu-item "New Function Bookmark..." bmkp-make-function-bookmark
3938     :help "Create a bookmark that will invoke FUNCTION when \"jumped\" to"))
3939 (define-key bmkp-bmenu-menubar-menu [bmkp-bmenu-make-sequence-from-marked]
3940   '(menu-item "New Sequence Bookmark from Marked..." bmkp-bmenu-make-sequence-from-marked
3941     :help "Create or update a sequence bookmark from the visible marked bookmarks"))
3942 (define-key bmkp-bmenu-menubar-menu [bmkp-choose-navlist-from-bookmark-list]
3943   '(menu-item "Set Navlist from Bookmark-List Bookmark..." bmkp-choose-navlist-from-bookmark-list
3944     :help "Set the navigation list from a bookmark-list bookmark"))
3945 (define-key bmkp-bmenu-menubar-menu [bmkp-choose-navlist-of-type]
3946   '(menu-item "Set Navlist to Bookmarks of Type..." bmkp-choose-navlist-of-type
3947     :help "Set the navigation list to the bookmarks of a certain type"))
3948 (define-key bmkp-bmenu-menubar-menu [bmkp-list-defuns-in-commands-file]
3949   '(menu-item "List User-Defined Bookmark Commands" bmkp-list-defuns-in-commands-file
3950     :help "List the functions defined in `bmkp-bmenu-commands-file'"))
3951
3952 (defvar bmkp-bmenu-define-command-menu (make-sparse-keymap "Define Command")
3953     "`Define Command' submenu for menu-bar `Bookmark+' menu.")
3954 (define-key bmkp-bmenu-menubar-menu [define-command]
3955   (cons "Define Command" bmkp-bmenu-define-command-menu))
3956
3957 (define-key bmkp-bmenu-define-command-menu [bmkp-bmenu-define-full-snapshot-command]
3958   '(menu-item "To Restore Full Bookmark-List State..." bmkp-bmenu-define-full-snapshot-command
3959     :help "Define a command to restore the current bookmark-list state"))
3960 (define-key bmkp-bmenu-define-command-menu [bmkp-bmenu-define-command]
3961   '(menu-item "To Restore Current Order and Filter..." bmkp-bmenu-define-command
3962     :help "Define a command to use the current sort order, filter, and omit list"))
3963 (define-key bmkp-bmenu-define-command-menu [bmkp-define-tags-sort-command]
3964   '(menu-item "To Sort by Specific Tags..." bmkp-define-tags-sort-command
3965     :help "Define a command to sort bookmarks in the bookmark list by certain tags"))
3966 (define-key bmkp-bmenu-define-command-menu [bmkp-bmenu-define-jump-marked-command]
3967   '(menu-item "To Jump to a Bookmark Now Marked..." bmkp-bmenu-define-jump-marked-command
3968     :help "Define a command to jump to one of the bookmarks that is now marked"
3969     :enable bmkp-bmenu-marked-bookmarks))
3970
3971 (when (featurep 'bookmark+-lit)
3972   (defvar bmkp-bmenu-highlight-menu (make-sparse-keymap "Highlight")
3973     "`Highlight' submenu for menu-bar `Bookmark+' menu.")
3974   (define-key bmkp-bmenu-menubar-menu [highlight] (cons "Highlight" bmkp-bmenu-highlight-menu))
3975
3976   (define-key bmkp-bmenu-highlight-menu [bmkp-bmenu-show-only-lighted]
3977     '(menu-item "Show Only Highlighted" bmkp-bmenu-show-only-lighted
3978       :help "Display (only) highlighted bookmarks"))
3979   (define-key bmkp-bmenu-highlight-menu [bmkp-bmenu-set-lighting-for-marked]
3980     '(menu-item "Set Highlighting for Marked" bmkp-bmenu-set-lighting-for-marked
3981       :help "Set specific highlighting for the marked bookmarks"
3982       :enable bmkp-bmenu-marked-bookmarks))
3983   (define-key bmkp-bmenu-highlight-menu [bmkp-bmenu-unlight-marked]
3984     '(menu-item "Unhighlight Marked" bmkp-bmenu-unlight-marked
3985       :help "Unhighlight the marked bookmarks"
3986       :enable bmkp-bmenu-marked-bookmarks))
3987   (define-key bmkp-bmenu-highlight-menu [bmkp-bmenu-light-marked]
3988     '(menu-item "Highlight Marked" bmkp-bmenu-light-marked
3989       :help "Highlight the marked bookmarks"
3990       :enable bmkp-bmenu-marked-bookmarks)))
3991
3992 (defvar bmkp-bmenu-tags-menu (make-sparse-keymap "Tags")
3993     "`Tags' submenu for menu-bar `Bookmark+' menu.")
3994 (define-key bmkp-bmenu-menubar-menu [tags] (cons "Tags" bmkp-bmenu-tags-menu))
3995
3996 (define-key bmkp-bmenu-tags-menu [bmkp-list-all-tags]
3997   '(menu-item "List All Tags" bmkp-list-all-tags :help "List all tags used for any bookmarks"))
3998 (define-key bmkp-bmenu-tags-menu [bmkp-purge-notags-autofiles]
3999   '(menu-item "Purge Autofiles with No Tags..." bmkp-purge-notags-autofiles
4000     :help "Delete all autofile bookmarks that have no tags"))
4001 (define-key bmkp-bmenu-tags-menu [bmkp-untag-a-file]
4002   '(menu-item "Untag a File (Remove Some)..." bmkp-untag-a-file
4003     :help "Remove some tags from autofile bookmark for a file"))
4004 (define-key bmkp-bmenu-tags-menu [bmkp-tag-a-file]
4005   '(menu-item "Tag a File (Add Some)..." bmkp-tag-a-file
4006     :help "Add some tags to the autofile bookmark for a file"))
4007 (define-key bmkp-bmenu-tags-menu [bmkp-rename-tag]
4008   '(menu-item "Rename Tag..." bmkp-rename-tag
4009     :help "Rename a tag in all bookmarks, even those not showing"))
4010 (define-key bmkp-bmenu-tags-menu [bmkp-bmenu-set-tag-value-for-marked]
4011   '(menu-item "Set Tag Value for Marked..." bmkp-bmenu-set-tag-value-for-marked
4012     :help "Set the value of a tag, for each of the marked bookmarks"))
4013 (define-key bmkp-bmenu-tags-menu [bmkp-remove-tags-from-all]
4014   '(menu-item "Remove Some Tags from All..." bmkp-remove-tags-from-all
4015     :help "Remove a set of tags from all bookmarks"))
4016 (define-key bmkp-bmenu-tags-menu [bmkp-bmenu-remove-tags-from-marked]
4017   '(menu-item "Remove Some Tags from Marked..." bmkp-bmenu-remove-tags-from-marked
4018     :help "Remove a set of tags from each of the marked bookmarks"))
4019 (define-key bmkp-bmenu-tags-menu [bmkp-bmenu-add-tags-to-marked]
4020   '(menu-item "Add Some Tags to Marked..." bmkp-bmenu-add-tags-to-marked
4021     :help "Add a set of tags to each of the marked bookmarks"))
4022 (define-key bmkp-bmenu-tags-menu [bmkp-bmenu-paste-replace-tags-for-marked]
4023   '(menu-item "Paste Tags to Marked (Replace)..." bmkp-bmenu-paste-replace-tags-for-marked
4024     :help "Replace tags for the marked bookmarks with tags copied previously"))
4025 (define-key bmkp-bmenu-tags-menu [bmkp-bmenu-paste-add-tags-to-marked]
4026   '(menu-item "Paste Tags to Marked (Add)..." bmkp-bmenu-paste-add-tags-to-marked
4027     :help "Add tags copied from another bookmark to the marked bookmarks"))
4028
4029 (defvar bmkp-bmenu-sort-menu (make-sparse-keymap "Sort")
4030     "`Sort' submenu for menu-bar `Bookmark+' menu.")
4031 (define-key bmkp-bmenu-menubar-menu [sort] (cons "Sort" bmkp-bmenu-sort-menu))
4032
4033 (define-key bmkp-bmenu-sort-menu [bmkp-bmenu-sort-by-url]
4034   '(menu-item "By URL" bmkp-bmenu-sort-by-url
4035     :help "Sort URL bookmarks alphabetically by their URL/filename"))
4036 (define-key bmkp-bmenu-sort-menu [bmkp-bmenu-sort-by-Gnus-thread]
4037   '(menu-item "By Gnus Thread" bmkp-bmenu-sort-by-Gnus-thread
4038     :help "Sort Gnus bookmarks by group, then by article, then by message"))
4039 (define-key bmkp-bmenu-sort-menu [bmkp-bmenu-sort-by-Info-location]
4040   '(menu-item "By Info Node" bmkp-bmenu-sort-by-Info-location
4041     :help "Sort Info bookmarks by file name, then node name, then position"))
4042 (define-key bmkp-bmenu-sort-menu [bmkp-bmenu-sort-by-last-local-file-update]
4043   '(menu-item "By Last Local File Update" bmkp-bmenu-sort-by-last-local-file-update
4044     :help "Sort bookmarks by last local file update time"))
4045 (define-key bmkp-bmenu-sort-menu [bmkp-bmenu-sort-by-last-buffer-or-file-access]
4046   '(menu-item "By Last Buffer/File Access" bmkp-bmenu-sort-by-last-buffer-or-file-access
4047     :help "Sort bookmarks by time of last buffer access or local-file access"))
4048 (define-key bmkp-bmenu-sort-menu [bmkp-bmenu-sort-by-local-file-size]
4049   '(menu-item "By Local File Size" bmkp-bmenu-sort-by-local-file-size
4050     :help "Sort bookmarks by local file size"))
4051 (define-key bmkp-bmenu-sort-menu [bmkp-bmenu-sort-by-local-file-type]
4052   '(menu-item "By Local File Type" bmkp-bmenu-sort-by-local-file-type
4053     :help "Sort bookmarks by local file type: file, symlink, directory"))
4054 (define-key bmkp-bmenu-sort-menu [bmkp-bmenu-sort-by-bookmark-type]
4055   '(menu-item "By Type" bmkp-bmenu-sort-by-bookmark-type
4056     :help "Sort bookmarks by type: Info, URL, Gnus, files, other"))
4057 (define-key bmkp-bmenu-sort-menu [bmkp-bmenu-sort-by-file-name]
4058   '(menu-item "By File Name" bmkp-bmenu-sort-by-file-name :help "Sort bookmarks by file name"))
4059 (define-key bmkp-bmenu-sort-menu [bmkp-bmenu-sort-by-bookmark-name]
4060   '(menu-item "By Bookmark Name" bmkp-bmenu-sort-by-bookmark-name
4061     :help "Sort bookmarks by bookmark name, respecting `case-fold-search'"))
4062 (define-key bmkp-bmenu-sort-menu [bmkp-bmenu-sort-by-creation-time]
4063   '(menu-item "By Creation Time" bmkp-bmenu-sort-by-creation-time
4064     :help "Sort bookmarks by the time of their creation"))
4065 (define-key bmkp-bmenu-sort-menu [bmkp-bmenu-sort-by-last-bookmark-access]
4066   '(menu-item "By Last Bookmark Access" bmkp-bmenu-sort-by-last-bookmark-access
4067     :help "Sort bookmarks by the time of their last visit as bookmarks"))
4068 (define-key bmkp-bmenu-sort-menu [bmkp-bmenu-sort-by-bookmark-visit-frequency]
4069   '(menu-item "By Bookmark Use" bmkp-bmenu-sort-by-bookmark-visit-frequency
4070     :help "Sort bookmarks by the number of times they were visited as bookmarks"))
4071 (define-key bmkp-bmenu-sort-menu [bmkp-bmenu-sort-marked-before-unmarked]
4072   '(menu-item "Marked Before Unmarked" bmkp-bmenu-sort-marked-before-unmarked
4073     :help "Sort bookmarks by putting marked before unmarked"))
4074 (define-key bmkp-bmenu-sort-menu [bmkp-reverse-sort-order]
4075   '(menu-item "Reverse" bmkp-reverse-sort-order :help "Reverse the current bookmark sort order"))
4076
4077 (defvar bmkp-bmenu-show-menu (make-sparse-keymap "Show")
4078     "`Show' submenu for menu-bar `Bookmark+' menu.")
4079 (define-key bmkp-bmenu-menubar-menu [show] (cons "Show" bmkp-bmenu-show-menu))
4080
4081 (define-key bmkp-bmenu-show-menu [bookmark-bmenu-show-all-annotations]
4082   '(menu-item "Show Annotations" bookmark-bmenu-show-all-annotations
4083     :help "Show the annotations for all bookmarks (in another window)"))
4084 (define-key bmkp-bmenu-show-menu [bookmark-bmenu-toggle-filenames]
4085   '(menu-item "Show/Hide File Names" bookmark-bmenu-toggle-filenames
4086     :help "Toggle whether filenames are shown in the bookmark list"))
4087 (define-key bmkp-bmenu-show-menu [show-sep1] '("--"))
4088 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-show-all]
4089   '(menu-item "Show All" bmkp-bmenu-show-all
4090     :help "Show all bookmarks currently known to the bookmark list"))
4091 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-filter-tags-incrementally]
4092   '(menu-item "Show Only Tag Matches..." bmkp-bmenu-filter-tags-incrementally
4093     :help "Incrementally filter bookmarks by tags using a regexp"))
4094 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-filter-annotation-incrementally]
4095   '(menu-item "Show Only Annotation Matches..." bmkp-bmenu-filter-annotation-incrementally
4096     :help "Incrementally filter bookmarks by annotation using a regexp"))
4097 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-filter-file-name-incrementally]
4098   '(menu-item "Show Only File Name Matches..." bmkp-bmenu-filter-file-name-incrementally
4099     :help "Incrementally filter bookmarks by file name using a regexp"))
4100 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-filter-bookmark-name-incrementally]
4101   '(menu-item "Show Only Name Matches..." bmkp-bmenu-filter-bookmark-name-incrementally
4102     :help "Incrementally filter bookmarks by bookmark name using a regexp"))
4103 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-show-only-specific-file]
4104   '(menu-item "Show Only for Specific File" bmkp-bmenu-show-only-specific-file
4105     :help "Display (only) the bookmarks for a specific file"))
4106 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-show-only-specific-buffer]
4107   '(menu-item "Show Only for Specific Buffer" bmkp-bmenu-show-only-specific-buffer
4108     :help "Display (only) the bookmarks for a specific buffer"))
4109 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-show-only-urls]
4110   '(menu-item "Show Only URLs" bmkp-bmenu-show-only-urls
4111     :help "Display (only) the URL bookmarks"))
4112 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-show-only-gnus]
4113   '(menu-item "Show Only Gnus Messages" bmkp-bmenu-show-only-gnus
4114     :help "Display (only) the Gnus bookmarks"))
4115 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-show-only-man-pages]
4116   '(menu-item "Show Only UNIX Manual Pages" bmkp-bmenu-show-only-man-pages
4117     :help "Display (only) the `man' page bookmarks"))
4118 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-show-only-info-nodes]
4119   '(menu-item "Show Only Info Nodes" bmkp-bmenu-show-only-info-nodes
4120     :help "Display (only) the Info bookmarks"))
4121 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-show-only-dired]
4122   '(menu-item "Show Only Dired Buffers" bmkp-bmenu-show-only-dired
4123     :help "Display (only) the Dired bookmarks"))
4124 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-show-only-bookmark-files]
4125   '(menu-item "Show Only Bookmark Files" bmkp-bmenu-show-only-bookmark-files
4126     :help "Display (only) the bookmark-file bookmarks"))
4127 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-show-only-desktops]
4128   '(menu-item "Show Only Desktops" bmkp-bmenu-show-only-desktops
4129     :help "Display (only) the desktop bookmarks"))
4130 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-show-only-regions]
4131   '(menu-item "Show Only Regions" bmkp-bmenu-show-only-regions
4132     :help "Display (only) the bookmarks that record a region"))
4133 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-show-only-non-files]
4134   '(menu-item "Show Only Non-Files (Buffers)" bmkp-bmenu-show-only-non-files
4135     :help "Display (only) the non-file bookmarks"))
4136 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-show-only-files]
4137   '(menu-item "Show Only Files" bmkp-bmenu-show-only-files
4138     :help "Display (only) the file and directory bookmarks"))
4139 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-show-only-autofiles]
4140   '(menu-item "Show Only Autofiles" bmkp-bmenu-show-only-autofiles
4141     :help "Display (only) the autofile bookmarks: those named the same as their files"))
4142 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-show-only-autonamed]
4143   '(menu-item "Show Only Autonamed" bmkp-bmenu-show-only-autonamed
4144     :help "Display (only) the autonamed bookmarks"))
4145 (when (featurep 'bookmark+-lit)
4146   (define-key bmkp-bmenu-show-menu [bmkp-bmenu-show-only-lighted]
4147     '(menu-item "Show Only Highlighted" bmkp-bmenu-show-only-lighted
4148       :help "Display (only) highlighted bookmarks")))
4149 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-toggle-show-only-unmarked]
4150   '(menu-item "Show Only Unmarked" bmkp-bmenu-toggle-show-only-unmarked
4151     :help "Hide all marked bookmarks.  Repeat to toggle, showing all"))
4152 (define-key bmkp-bmenu-show-menu [bmkp-bmenu-toggle-show-only-marked]
4153   '(menu-item "Show Only Marked" bmkp-bmenu-toggle-show-only-marked
4154     :help "Hide all unmarked bookmarks.  Repeat to toggle, showing all"))
4155
4156 (defvar bmkp-bmenu-omit-menu (make-sparse-keymap "Omit")
4157   "`Omit' submenu for menu-bar `Bookmark+' menu.")
4158 (define-key bmkp-bmenu-menubar-menu [omitting] (cons "Omit" bmkp-bmenu-omit-menu))
4159
4160 (define-key bmkp-bmenu-omit-menu [bmkp-bmenu-show-all]
4161   '(menu-item "Show All" bmkp-bmenu-show-all
4162     :visible (eq bmkp-bmenu-filter-function 'bmkp-omitted-alist-only)
4163     :help "Show all bookmarks (except omitted)"))
4164 (define-key bmkp-bmenu-omit-menu [bmkp-bmenu-show-only-omitted]
4165   '(menu-item "Show Only Omitted" bmkp-bmenu-show-only-omitted
4166     :visible (not (eq bmkp-bmenu-filter-function 'bmkp-omitted-alist-only))
4167     :enable bmkp-bmenu-omitted-bookmarks :help "Show only the omitted bookmarks"))
4168 (define-key bmkp-bmenu-omit-menu [bmkp-unomit-all]
4169   '(menu-item "Un-Omit All" bmkp-unomit-all
4170     :visible bmkp-bmenu-omitted-bookmarks :help "Un-omit all omitted bookmarks"))
4171 (define-key bmkp-bmenu-omit-menu [bmkp-bmenu-unomit-marked]
4172   '(menu-item "Un-Omit Marked" bmkp-bmenu-unomit-marked
4173     :visible (eq bmkp-bmenu-filter-function 'bmkp-omitted-alist-only)
4174     :enable (and bmkp-bmenu-omitted-bookmarks
4175              (save-excursion (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
4176                              (re-search-forward "^>" (point-max) t)))
4177     :help "Un-omit the marked bookmarks" :keys "\\[bmkp-bmenu-omit/unomit-marked]"))
4178 (define-key bmkp-bmenu-omit-menu [bmkp-bmenu-omit-marked]
4179   '(menu-item "Omit Marked" bmkp-bmenu-omit-marked
4180     :visible (not (eq bmkp-bmenu-filter-function 'bmkp-omitted-alist-only))
4181     :enable (and (save-excursion (goto-char (point-min)) (forward-line bmkp-bmenu-header-lines)
4182                                  (re-search-forward "^>" (point-max) t)))
4183     :help "Omit the marked bookmarks" :keys "\\[bmkp-bmenu-omit/unomit-marked]"))
4184
4185 (defvar bmkp-bmenu-mark-menu (make-sparse-keymap "Mark")
4186     "`Mark' submenu for menu-bar `Bookmark+' menu.")
4187 (define-key bmkp-bmenu-menubar-menu [marking] (cons "Mark" bmkp-bmenu-mark-menu))
4188
4189 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-unmark-bookmarks-tagged-not-all]
4190   '(menu-item "Unmark If Not Tagged with All..." bmkp-bmenu-unmark-bookmarks-tagged-not-all
4191     :help "Unmark all visible bookmarks that are tagged with *some* tag in a set you specify"))
4192 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-unmark-bookmarks-tagged-none]
4193   '(menu-item "Unmark If Tagged with None..." bmkp-bmenu-unmark-bookmarks-tagged-none
4194     :help "Unmark all visible bookmarks that are *not* tagged with *any* tag you specify"))
4195 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-unmark-bookmarks-tagged-all]
4196   '(menu-item "Unmark If Tagged with All..." bmkp-bmenu-unmark-bookmarks-tagged-all
4197     :help "Unmark all visible bookmarks that are tagged with *each* tag you specify"))
4198 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-unmark-bookmarks-tagged-some]
4199   '(menu-item "Unmark If Tagged with Some..." bmkp-bmenu-unmark-bookmarks-tagged-some
4200     :help "Unmark all visible bookmarks that are tagged with *some* tag in a set you specify"))
4201 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-unmark-bookmarks-tagged-regexp]
4202   '(menu-item "Unmark If Tagged Matching Regexp..." bmkp-bmenu-unmark-bookmarks-tagged-regexp
4203     :help "Unmark bookmarks any of whose tags match a regexp you enter"))
4204 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-bookmarks-tagged-not-all]
4205   '(menu-item "Mark If Not Tagged with All..." bmkp-bmenu-mark-bookmarks-tagged-not-all
4206     :help "Mark all visible bookmarks that are *not* tagged with *all* tags you specify"))
4207 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-bookmarks-tagged-none]
4208   '(menu-item "Mark If Tagged with None..." bmkp-bmenu-mark-bookmarks-tagged-none
4209     :help "Mark all visible bookmarks that are not tagged with *any* tag you specify"))
4210 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-bookmarks-tagged-all]
4211   '(menu-item "Mark If Tagged with All..." bmkp-bmenu-mark-bookmarks-tagged-all
4212     :help "Mark all visible bookmarks that are tagged with *each* tag you specify"))
4213 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-bookmarks-tagged-some]
4214   '(menu-item "Mark If Tagged with Some..." bmkp-bmenu-mark-bookmarks-tagged-some
4215     :help "Mark all visible bookmarks that are tagged with *some* tag in a set you specify"))
4216 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-bookmarks-tagged-regexp]
4217   '(menu-item "Mark If Tagged Matching Regexp..." bmkp-bmenu-mark-bookmarks-tagged-regexp
4218     :help "Mark bookmarks any of whose tags match a regexp you enter"))
4219 (define-key bmkp-bmenu-mark-menu [mark-sep1] '("--"))
4220 (when (featurep 'bookmark+-lit)
4221   (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-lighted-bookmarks]
4222     '(menu-item "Mark Highlighted" bmkp-bmenu-mark-lighted-bookmarks
4223       :help "Mark highlighted bookmarks")))
4224 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-specific-file-bookmarks]
4225   '(menu-item "Mark for Specific File" bmkp-bmenu-mark-specific-file-bookmarks
4226     :help "Mark bookmarks for a specific file"))
4227 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-specific-buffer-bookmarks]
4228   '(menu-item "Mark for Specific Buffer" bmkp-bmenu-mark-specific-buffer-bookmarks
4229     :help "Mark bookmarks for a specific buffer"))
4230 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-url-bookmarks]
4231   '(menu-item "Mark URLs" bmkp-bmenu-mark-url-bookmarks :help "Mark URL bookmarks"))
4232 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-gnus-bookmarks]
4233   '(menu-item "Mark Gnus Messages" bmkp-bmenu-mark-gnus-bookmarks :help "Mark Gnus bookmarks"))
4234 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-man-bookmarks]
4235   '(menu-item "Mark UNIX Manual Pages" bmkp-bmenu-mark-man-bookmarks
4236     :help "Mark `man' page bookmarks"))
4237 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-info-bookmarks]
4238   '(menu-item "Mark Info Nodes" bmkp-bmenu-mark-info-bookmarks :help "Mark Info bookmarks"))
4239 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-dired-bookmarks]
4240   '(menu-item "Mark Dired Buffers" bmkp-bmenu-mark-dired-bookmarks :help "Mark Dired bookmarks"))
4241 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-bookmark-file-bookmarks]
4242   '(menu-item "Mark Bookmark Files" bmkp-bmenu-mark-bookmark-file-bookmarks
4243     :help "Mark the bookmark-file bookmarks"))
4244 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-desktop-bookmarks]
4245   '(menu-item "Mark Desktops" bmkp-bmenu-mark-desktop-bookmarks
4246     :help "Mark desktop bookmarks"))
4247 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-region-bookmarks]
4248   '(menu-item "Mark Regions" bmkp-bmenu-mark-region-bookmarks
4249     :help "Mark bookmarks that record a region"))
4250 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-non-file-bookmarks]
4251   '(menu-item "Mark Non-Files (Buffers)" bmkp-bmenu-mark-non-file-bookmarks
4252     :help "Mark non-file bookmarks"))
4253 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-autofile-bookmarks]
4254   '(menu-item "Mark Autofiles" bmkp-bmenu-mark-autofile-bookmarks
4255     :help "Mark autofile bookmarks: those whose names are the same as their files"))
4256 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-file-bookmarks]
4257   '(menu-item "Mark Files" bmkp-bmenu-mark-file-bookmarks :help "Mark file bookmarks"))
4258 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-unmark-all]
4259   '(menu-item "Unmark All" bmkp-bmenu-unmark-all
4260     :help "Remove a mark you specify (> or D) from each bookmark (RET to remove both kinds)"))
4261 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-mark-all]
4262   '(menu-item "Mark All" bmkp-bmenu-mark-all :help "Mark all bookmarks, using mark `>'"))
4263 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-toggle-marks]
4264   '(menu-item "Toggle Marked/Unmarked" bmkp-bmenu-toggle-marks
4265     :help "Unmark all marked bookmarks; mark all unmarked bookmarks"))
4266 (define-key bmkp-bmenu-mark-menu [bmkp-bmenu-regexp-mark]
4267   '(menu-item "Mark Regexp Matches..." bmkp-bmenu-regexp-mark
4268     :help "Mark bookmarks that match a regexp that you enter"))
4269
4270 (define-key bmkp-bmenu-menubar-menu [bookmark-bmenu-execute-deletions]
4271   '(menu-item "Delete Flagged (D)" bookmark-bmenu-execute-deletions
4272     :help "Delete the (visible) bookmarks flagged `D'"))
4273 (define-key bmkp-bmenu-menubar-menu [bmkp-bmenu-delete-marked]
4274   '(menu-item "Delete Marked (>)" bmkp-bmenu-delete-marked
4275     :help "Delete all (visible) bookmarks marked `>', after confirmation"))
4276 (define-key bmkp-bmenu-menubar-menu [bmkp-bmenu-query-replace-marked-bookmarks-regexp]
4277   '(menu-item "Query-Replace Marked..." bmkp-bmenu-query-replace-marked-bookmarks-regexp
4278     :help "`query-replace-regexp' over all files whose bookmarks are marked"))
4279 (when (fboundp 'bmkp-bmenu-isearch-marked-bookmarks)
4280   (define-key bmkp-bmenu-menubar-menu [bmkp-bmenu-isearch-marked-bookmarks-regexp]
4281     '(menu-item "Regexp-Isearch Marked..." bmkp-bmenu-isearch-marked-bookmarks-regexp
4282       :help "Regexp Isearch the marked bookmark locations, in their current order"))
4283   (define-key bmkp-bmenu-menubar-menu [bmkp-bmenu-isearch-marked-bookmarks]
4284     '(menu-item "Isearch Marked..." bmkp-bmenu-isearch-marked-bookmarks
4285       :help "Isearch the marked bookmark locations, in their current order")))
4286 (define-key bmkp-bmenu-menubar-menu [bmkp-bmenu-search-marked-bookmarks-regexp]
4287   '(menu-item "Search Marked..." bmkp-bmenu-search-marked-bookmarks-regexp
4288     :help "Regexp-search the files whose bookmarks are marked, in their current order"))
4289 (define-key bmkp-bmenu-menubar-menu [bookmark-bmenu-select]
4290   '(menu-item "Jump to Marked" bookmark-bmenu-select
4291     :help "Jump to this line's bookmark.  Also visit each bookmark marked with `>'"))
4292
4293
4294
4295 ;;; Mouse-3 menu binding.
4296
4297 (defvar bmkp-bmenu-line-overlay nil
4298   "Overlay to highlight the current line for `bmkp-bmenu-mouse-3-menu'.")
4299 (define-key bookmark-bmenu-mode-map [mouse-3] 'bmkp-bmenu-mouse-3-menu)
4300
4301 ;;;###autoload
4302 (defun bmkp-bmenu-mouse-3-menu (event)
4303   "Pop-up menu on `mouse-3' for a bookmark listed in `*Bookmark List*'."
4304   (interactive "e")
4305   (let* ((mouse-pos                  (event-start event))
4306          (inhibit-field-text-motion  t) ; Just in case.
4307          bol eol
4308          (bmk-name                   (save-excursion
4309                                        (with-current-buffer (window-buffer (posn-window mouse-pos))
4310                                          (save-excursion
4311                                            (goto-char (posn-point mouse-pos))
4312                                            (save-excursion
4313                                              (setq bol  (progn (beginning-of-line) (point))
4314                                                    eol  (progn (end-of-line) (point))))
4315                                            (if bmkp-bmenu-line-overlay ; Don't recreate.
4316                                                (move-overlay bmkp-bmenu-line-overlay bol eol
4317                                                              (current-buffer))
4318                                              (setq bmkp-bmenu-line-overlay  (make-overlay bol eol))
4319                                              (overlay-put bmkp-bmenu-line-overlay 'face 'region))
4320                                            (bookmark-bmenu-bookmark))))))
4321     (sit-for 0)
4322     (let ((menu-choice
4323            (x-popup-menu event
4324                          (list "This Bookmark"
4325                                (if bmk-name
4326                                    (list bmk-name
4327                                          (if (bmkp-bookmark-name-member bmk-name
4328                                                                         bmkp-bmenu-marked-bookmarks)
4329                                              '("Unmark" . bookmark-bmenu-unmark)
4330                                            '("Mark" . bookmark-bmenu-mark))
4331                                          (save-excursion
4332                                            (goto-char (posn-point mouse-pos))
4333                                            (beginning-of-line)
4334                                            (if (looking-at "^D")
4335                                                '("Unmark" . bookmark-bmenu-unmark)
4336                                              '("Flag for Deletion" . bookmark-bmenu-delete)))
4337                                          '("Omit" . bmkp-bmenu-omit)
4338                                          '("--") ; ----------------------------------------
4339                                          '("Jump To" . bookmark-bmenu-this-window)
4340                                          '("Jump To in Other Window" . bookmark-bmenu-other-window)
4341                                          '("--") ; ----------------------------------------
4342                                          '("Copy Tags" . bmkp-bmenu-copy-tags)
4343                                          '("Paste Tags (Add)" . bmkp-bmenu-paste-add-tags)
4344                                          '("Paste Tags (Replace)" . bmkp-bmenu-paste-replace-tags)
4345                                          '("Add Some Tags..." . bmkp-bmenu-add-tags)
4346                                          '("Remove Some Tags..." . bmkp-bmenu-remove-tags)
4347                                          '("Remove All Tags..." . bmkp-bmenu-remove-all-tags)
4348                                          '("Rename..." . bmkp-rename-tag)
4349                                          '("Set Tag Value..." . bmkp-bmenu-set-tag-value)
4350                                          (and (featurep 'bookmark+-lit)
4351                                               '("--")) ; ----------------------------------------
4352                                          (and (featurep 'bookmark+-lit)
4353                                               '("Highlight"   . bmkp-bmenu-light))
4354                                          (and (featurep 'bookmark+-lit)
4355                                               '("Unhighlight" . bmkp-bmenu-unlight))
4356                                          (and (featurep 'bookmark+-lit)
4357                                               '("Set Lighting" . bmkp-bmenu-set-lighting))
4358                                          '("--") ; ----------------------------------------
4359                                          '("Show Annotation" . bookmark-bmenu-show-annotation)
4360                                          '("Edit Annotation..." . bookmark-bmenu-edit-annotation)
4361                                          '("Edit Name, File Name..." . bmkp-bmenu-edit-bookmark)
4362                                          '("Rename..." . bookmark-bmenu-rename)
4363                                          '("Relocate..." . bookmark-bmenu-relocate)
4364                                          '("--") ; ----------------------------------------
4365                                          '("Describe" . bmkp-bmenu-describe-this-bookmark))
4366                                  '("" (""))))))) ; No menu: not on a bookmark line.
4367       (when bmkp-bmenu-line-overlay (delete-overlay bmkp-bmenu-line-overlay))
4368       (and menu-choice  (save-excursion (goto-char (posn-point mouse-pos))
4369                                         (call-interactively menu-choice))))))
4370
4371 ;;;;;;;;;;;;;;;;;;;;;
4372
4373 (provide 'bookmark+-bmu)
4374
4375 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4376 ;;; bookmark+-bmu.el ends here