-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbookmark+-bmu.el
6643 lines (5984 loc) · 360 KB
/
bookmark+-bmu.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; bookmark+-bmu.el --- Bookmark+ code for the `*Bookmark List*' (bmenu).
;;
;; Filename: bookmark+-bmu.el
;; Description: Bookmark+ code for the `*Bookmark List*' (bmenu).
;; Author: Drew Adams, Thierry Volpiatto
;; Maintainer: Drew Adams (concat "drew.adams" "@" "oracle" ".com")
;; Copyright (C) 2000-2019, Drew Adams, all rights reserved.
;; Copyright (C) 2009, Thierry Volpiatto, all rights reserved.
;; Created: Mon Jul 12 09:05:21 2010 (-0700)
;; Last-Updated: Tue May 21 13:25:29 2019 (-0700)
;; By: dradams
;; Update #: 4036
;; URL: https://www.emacswiki.org/emacs/download/bookmark%2b-bmu.el
;; Doc URL: https://www.emacswiki.org/emacs/BookmarkPlus
;; Keywords: bookmarks, bookmark+, placeholders, annotations, search, info, url, eww, w3m, gnus
;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x, 24.x, 25.x, 26.x
;;
;; Features that might be required by this library:
;;
;; `apropos', `apropos+', `avoid', `backquote', `bookmark',
;; `bookmark+', `bookmark+-1', `bookmark+-bmu', `bookmark+-key',
;; `bookmark+-lit', `button', `bytecomp', `cconv', `cl', `cl-lib',
;; `cmds-menu', `col-highlight', `crosshairs', `fit-frame',
;; `font-lock', `font-lock+', `frame-fns', `gv', `help+',
;; `help-fns', `help-fns+', `help-macro', `help-macro+',
;; `help-mode', `hl-line', `hl-line+', `info', `info+', `kmacro',
;; `macroexp', `menu-bar', `menu-bar+', `misc-cmds', `misc-fns',
;; `naked', `pp', `pp+', `radix-tree', `replace', `second-sel',
;; `strings', `syntax', `text-mode', `thingatpt', `thingatpt+',
;; `vline', `w32browser-dlgopen', `wid-edit', `wid-edit+'.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; This library contains code for buffer `*Bookmark List*' (mode
;; `bookmark-bmenu-mode').
;;
;; The Bookmark+ libraries are these:
;;
;; `bookmark+.el' - main (driver) library
;; `bookmark+-mac.el' - Lisp macros
;; `bookmark+-lit.el' - (optional) code for highlighting bookmarks
;; `bookmark+-bmu.el' - code for the `*Bookmark List*' (this file)
;; `bookmark+-1.el' - other required code (non-bmenu)
;; `bookmark+-key.el' - key and menu bindings
;;
;; `bookmark+-doc.el' - documentation (comment-only file)
;; `bookmark+-chg.el' - change log (comment-only file)
;;
;; The documentation (in `bookmark+-doc.el') includes how to
;; byte-compile and install Bookmark+. The documentation is also
;; available in these ways:
;;
;; 1. From the bookmark list (`C-x r l'):
;; Use `?' to show the current bookmark-list status and general
;; help, then click link `Doc in Commentary' or link `Doc on the
;; Web'.
;;
;; 2. From the Emacs-Wiki Web site:
;; https://www.emacswiki.org/emacs/BookmarkPlus.
;;
;; 3. From the Bookmark+ group customization buffer:
;; `M-x customize-group bookmark-plus', then click link
;; `Commentary'.
;;
;; (The commentary links in #1 and #3 work only if you have library
;; `bookmark+-doc.el' in your `load-path'.)
;;(@> "Index")
;;
;; Index
;; -----
;;
;; If you have library `linkd.el' and Emacs 22 or later, load
;; `linkd.el' and turn on `linkd-mode' now. It lets you easily
;; navigate around the sections of this doc. Linkd mode will
;; highlight this Index, as well as the cross-references and section
;; headings throughout this file. You can get `linkd.el' here:
;; https://www.emacswiki.org/emacs/download/linkd.el.
;;
;; (@> "Things Defined Here")
;; (@> "Utility Functions")
;; (@> "Faces (Customizable)")
;; (@> "User Options (Customizable)")
;; (@> "Internal Variables")
;; (@> "Compatibility Code for Older Emacs Versions")
;; (@> "Menu List Replacements (`bookmark-bmenu-*')")
;; (@> "Bookmark+ Functions (`bmkp-*')")
;; (@> "Menu-List (`*-bmenu-*') Filter Commands")
;; (@> "Menu-List (`*-bmenu-*') Commands Involving Marks")
;; (@> "Omitted Bookmarks")
;; (@> "Search-and-Replace Locations of Marked Bookmarks")
;; (@> "Tags")
;; (@> "General Menu-List (`-*bmenu-*') Commands and Functions")
;; (@> "Sorting - Commands")
;; (@> "Other Bookmark+ Functions (`bmkp-*')")
;; (@> "Keymaps")
;;(@* "Things Defined Here")
;;
;; Things Defined Here
;; -------------------
;;
;; Commands defined here:
;;
;; `bmkp-bmenu-add-tags', `bmkp-bmenu-add-tags-to-marked',
;; `bmkp-bmenu-change-sort-order',
;; `bmkp-bmenu-change-sort-order-repeat',
;; `bmkp-bmenu-copy-marked-to-bookmark-file',
;; `bmkp-bmenu-copy-tags',
;; `bmkp-bmenu-create-bookmark-file-from-marked',
;; `bmkp-bmenu-define-command',
;; `bmkp-bmenu-define-full-snapshot-command',
;; `bmkp-bmenu-define-jump-marked-command',
;; `bmkp-bmenu-delete-marked', `bmkp-bmenu-describe-marked',
;; `bmkp-bmenu-describe-this+move-down',
;; `bmkp-bmenu-describe-this+move-up',
;; `bmkp-bmenu-describe-this-bookmark',`bmkp-bmenu-dired-marked',
;; `bmkp-bmenu-edit-bookmark-name-and-location',
;; `bmkp-bmenu-filter-annotation-incrementally',
;; `bmkp-bmenu-filter-bookmark-name-incrementally',
;; `bmkp-bmenu-filter-file-name-incrementally',
;; `bmkp-bmenu-filter-tags-incrementally',
;; `bmkp-bmenu-flag-for-deletion',
;; `bmkp-bmenu-flag-for-deletion-backwards',
;; `bmkp-bmenu-isearch-marked-bookmarks' (Emacs 23+),
;; `bmkp-bmenu-isearch-marked-bookmarks-regexp' (Emacs 23+),
;; `bmkp-bmenu-jump-to-marked', `bmkp-bmenu-load-marking',
;; `bmkp-bmenu-load-marking-unmark-first',
;; `bmkp-bmenu-make-sequence-from-marked', `bmkp-bmenu-mark-all',
;; `bmkp-bmenu-mark-autofile-bookmarks',
;; `bmkp-bmenu-mark-bookmark-file-bookmarks',
;; `bmkp-bmenu-mark-bookmark-list-bookmarks',
;; `bmkp-bmenu-mark-bookmarks-satisfying',
;; `bmkp-bmenu-mark-bookmarks-tagged-all',
;; `bmkp-bmenu-mark-bookmarks-tagged-none',
;; `bmkp-bmenu-mark-bookmarks-tagged-not-all',
;; `bmkp-bmenu-mark-bookmarks-tagged-regexp',
;; `bmkp-bmenu-mark-bookmarks-tagged-some',
;; `bmkp-bmenu-mark-desktop-bookmarks',
;; `bmkp-bmenu-mark-dired-bookmarks',
;; `bmkp-bmenu-mark-eww-bookmarks' (Emacs 25+),
;; `bmkp-bmenu-mark-file-bookmarks',
;; `bmkp-bmenu-mark-function-bookmarks',
;; `bmkp-bmenu-mark-gnus-bookmarks',
;; `bmkp-bmenu-mark-icicles-search-hits-bookmarks',
;; `bmkp-bmenu-mark-image-bookmarks',
;; `bmkp-bmenu-mark-info-bookmarks',
;; `bmkp-bmenu-mark-lighted-bookmarks',
;; `bmkp-bmenu-mark-man-bookmarks',
;; `bmkp-bmenu-mark-non-file-bookmarks',
;; `bmkp-bmenu-mark-non-invokable-bookmarks',
;; `bmkp-bmenu-mark-orphaned-local-file-bookmarks',
;; `bmkp-bmenu-mark-region-bookmarks',
;; `bmkp-bmenu-mark-snippet-bookmarks',
;; `bmkp-bmenu-mark-specific-buffer-bookmarks',
;; `bmkp-bmenu-mark-specific-file-bookmarks',
;; `bmkp-bmenu-mark-url-bookmarks',
;; `bmkp-bmenu-mark-variable-list-bookmarks',
;; `bmkp-bmenu-mark-w3m-bookmarks', `bmkp-bmenu-mouse-3-menu',
;; `bmkp-bmenu-mode-status-help',
;; `bmkp-bmenu-move-marked-to-bookmark-file',
;; `bmkp-bmenu-nb-marked-in-mode-name', `bmkp-bmenu-omit',
;; `bmkp-bmenu-omit-marked', `bmkp-bmenu-omit/unomit-marked',
;; `bmkp-bmenu-paste-add-tags',
;; `bmkp-bmenu-paste-add-tags-to-marked',
;; `bmkp-bmenu-paste-replace-tags',
;; `bmkp-bmenu-paste-replace-tags-for-marked',
;; `bmkp-bmenu-query-replace-marked-bookmarks-regexp',
;; `bmkp-bmenu-quit', `bmkp-bmenu-refresh-menu-list',
;; `bmkp-bmenu-regexp-mark', `bookmark-bmenu-relocate' (Emacs 20,
;; 21), `bmkp-bmenu-relocate-marked', `bmkp-bmenu-remove-all-tags',
;; `bmkp-bmenu-remove-tags', `bmkp-bmenu-remove-tags-from-marked',
;; `bmkp-bmenu-search-marked-bookmarks-regexp',
;; `bmkp-bmenu-set-bookmark-file-bookmark-from-marked',
;; `bmkp-bmenu-set-tag-value',
;; `bmkp-bmenu-set-tag-value-for-marked', `bmkp-bmenu-show-all',
;; `bmkp-bmenu-show-only-autofile-bookmarks',
;; `bmkp-bmenu-show-only-autonamed-bookmarks',
;; `bmkp-bmenu-show-only-bookmark-file-bookmarks',
;; `bmkp-bmenu-show-only-bookmark-list-bookmarks',
;; `bmkp-bmenu-show-only-desktop-bookmarks',
;; `bmkp-bmenu-show-only-dired-bookmarks',
;; `bmkp-bmenu-show-only-eww-bookmarks' (Emacs 25+),
;; `bmkp-bmenu-show-only-file-bookmarks',
;; `bmkp-bmenu-show-only-function-bookmarks',
;; `bmkp-bmenu-show-only-gnus-bookmarks',
;; `bmkp-bmenu-show-only-icicles-search-hits-bookmarks.',
;; `bmkp-bmenu-show-only-image-bookmarks',
;; `bmkp-bmenu-show-only-info-bookmarks',
;; `bmkp-bmenu-show-only-man-bookmarks',
;; `bmkp-bmenu-show-only-non-file-bookmarks',
;; `bmkp-bmenu-show-only-non-invokable-bookmarks',
;; `bmkp-bmenu-show-only-omitted-bookmarks',
;; `bmkp-bmenu-show-only-orphaned-local-file-bookmarks',
;; `bmkp-bmenu-show-only-region-bookmarks',
;; `bmkp-bmenu-show-only-snippet-bookmarks',
;; `bmkp-bmenu-show-only-specific-buffer-bookmarks',
;; `bmkp-bmenu-show-only-specific-file-bookmarks',
;; `bmkp-bmenu-show-only-temporary-bookmarks',
;; `bmkp-bmenu-show-only-tagged-bookmarks',
;; `bmkp-bmenu-show-only-untagged-bookmarks',
;; `bmkp-bmenu-show-only-url-bookmarks',
;; `bmkp-bmenu-show-only-variable-list-bookmarks',
;; `bmkp-bmenu-show-only-w3m-bookmarks',
;; `bmkp-bmenu-show-this-annotation+move-down',
;; `bmkp-bmenu-show-this-annotation+move-up',
;; `bmkp-bmenu-sort-by-bookmark-name',
;; `bmkp-bmenu-sort-by-bookmark-visit-frequency',
;; `bmkp-bmenu-sort-by-bookmark-type',
;; `bmkp-bmenu-sort-by-creation-time',
;; `bmkp-bmenu-sort-by-file-name',
;; `bmkp-bmenu-sort-by-Gnus-thread',
;; `bmkp-bmenu-sort-by-Info-node-name',
;; `bmkp-bmenu-sort-by-Info-position',
;; `bmkp-bmenu-sort-by-last-bookmark-access',
;; `bmkp-bmenu-sort-by-last-buffer-or-file-access',
;; `bmkp-bmenu-sort-by-last-local-file-access',
;; `bmkp-bmenu-sort-by-last-local-file-update',
;; `bmkp-bmenu-sort-by-local-file-size',
;; `bmkp-bmenu-sort-by-local-file-type', `bmkp-bmenu-sort-by-url',
;; `bmkp-bmenu-sort-flagged-before-unflagged',
;; `bmkp-bmenu-sort-marked-before-unmarked',
;; `bmkp-bmenu-sort-modified-before-unmodified',
;; `bmkp-bmenu-sort-tagged-before-untagged',
;; `bmkp-bmenu-toggle-marked-temporary/savable',
;; `bmkp-bmenu-toggle-marks', `bmkp-bmenu-toggle-show-only-marked',
;; `bmkp-bmenu-toggle-show-only-unmarked',
;; `bmkp-bmenu-toggle-temporary', `bmkp-bmenu-unmark-all',
;; `bmkp-bmenu-unmark-bookmarks-tagged-all',
;; `bmkp-bmenu-unmark-bookmarks-tagged-none',
;; `bmkp-bmenu-unmark-bookmarks-tagged-not-all',
;; `bmkp-bmenu-unmark-bookmarks-tagged-regexp',
;; `bmkp-bmenu-unmark-bookmarks-tagged-some',
;; `bmkp-bmenu-unomit-marked', `bmkp-bmenu-w32-open',
;; `bmkp-bmenu-w32-open-select', `bmkp-bmenu-w32-open-with-mouse',
;; `bmkp-define-tags-sort-command'.
;;
;; Faces defined here:
;;
;; `bmkp-*-mark', `bmkp->-mark', `bmkp-a-mark',
;; `bmkp-bad-bookmark', `bmkp-bookmark-file', `bmkp-bookmark-list',
;; `bmkp-buffer', `bmkp-D-mark', `bmkp-desktop',
;; `bmkp-file-handler', `bmkp-function', `bmkp-gnus',
;; `bmkp-heading', `bmkp-info', `bmkp-local-directory',
;; `bmkp-local-file-with-region', `bmkp-local-file-without-region',
;; `bmkp-man', `bmkp-no-jump', `bmkp-no-local', `bmkp-non-file',
;; `bmkp-remote-file', `bmkp-sequence', `bmkp-snippet',
;; `bmkp-su-or-sudo', `bmkp-t-mark', `bmkp-url',
;; `bmkp-variable-list', `bmkp-X-mark'.
;;
;; User options defined here:
;;
;; `bmkp-bmenu-commands-file',
;; `bmkp-bmenu-image-bookmark-icon-file',
;; `bmkp-bmenu-omitted-bookmarks', `bmkp-bmenu-state-file',
;; `bmkp-propertize-bookmark-names-flag', `bmkp-sort-orders-alist',
;; `bmkp-sort-orders-for-cycling-alist'.
;;
;; Non-interactive functions defined here:
;;
;; `bmkp--pop-to-buffer-same-window', `bmkp-assoc-delete-all',
;; `bmkp-bmenu-barf-if-not-in-menu-list',
;; `bmkp-bmenu-cancel-incremental-filtering',
;; `bmkp-bmenu-filter-alist-by-annotation-regexp',
;; `bmkp-bmenu-filter-alist-by-bookmark-name-regexp',
;; `bmkp-bmenu-filter-alist-by-file-name-regexp',
;; `bmkp-bmenu-filter-alist-by-tags-regexp',
;; `bmkp-bmenu-get-marked-files', `bmkp-bmenu-goto-bookmark-named',
;; `bmkp-bmenu-kill-annotation', `bmkp-bmenu-list-1',
;; `bmkp-bmenu-mark/unmark-bookmarks-tagged-all/none',
;; `bmkp-bmenu-mark/unmark-bookmarks-tagged-some/not-all',
;; `bmkp-bmenu-mode-line', `bmkp-bmenu-mode-line-string',
;; `bmkp-bmenu-propertize-item', `bmkp-bmenu-read-filter-input',
;; `bmkp-bmenu-store-org-link' (Emacs 24.4+),
;; `bmkp-bookmark-data-from-record',
;; `bmkp-bookmark-name-from-record', `bmkp-face-prop',
;; `bmkp-bmenu-marked-or-this-or-all', `bmkp-looking-at-p',
;; `bmkp-maybe-unpropertize-bookmark-names',
;; `bmkp-maybe-unpropertize-string', `bmkp-remap',
;; `bmkp-replace-regexp-in-string',
;; `bmkp-reverse-multi-sort-order', `bmkp-reverse-sort-order',
;; `bmkp-string-match-p', `bookmark-name-from-full-record',
;; `bookmark-name-from-record',
;;
;; Internal variables defined here:
;;
;; `bmkp-bmenu-before-hide-marked-alist',
;; `bmkp-bmenu-before-hide-unmarked-alist',
;; `bmkp-bmenu-bookmark-file-menu',
;; `bmkp-bmenu-define-command-history',
;; `bmkp-bmenu-define-command-menu', `bmkp-bmenu-delete-menu',
;; `bmkp-bmenu-filter-function', `bmkp-bmenu-filter-pattern',
;; `bmkp-bmenu-filter-timer', `bmkp-bmenu-first-time-p',
;; `bmkp-bmenu-header-lines', `bmkp-bmenu-highlight-menu',
;; `bmkp-bmenu-line-overlay', `bmkp-bmenu-mark-menu',
;; `bmkp-bmenu-marked-bookmarks', `bmkp-bmenu-marks-width',
;; `bmkp-bmenu-mark-types-menu', `bmkp-bmenu-menubar-menu',
;; `bmkp-bmenu-omit-menu', `bmkp-bmenu-search-menu',
;; `bmkp-bmenu-show-menu',
;; `bmkp-bmenu-show-types-menu',`bmkp-bmenu-sort-menu',
;; `bmkp-bmenu-tags-menu', `bmkp-bmenu-title',
;; `bmkp-bmenu-toggle-menu', `bmkp-flagged-bookmarks',
;; `bmkp-last-bmenu-bookmark'.
;;
;;
;; ***** NOTE: The following commands defined in `bookmark.el'
;; have been REDEFINED HERE:
;;
;; `bookmark-bmenu-execute-deletions', `bookmark-bmenu-list',
;; `bookmark-bmenu-mark', `bookmark-bmenu-1-window',
;; `bookmark-bmenu-2-window', `bookmark-bmenu-other-frame',
;; `bookmark-bmenu-other-window',
;; `bookmark-bmenu-other-window-with-mouse',
;; `bookmark-bmenu-rename', `bookmark-bmenu-show-annotation',
;; `bookmark-bmenu-switch-other-window',
;; `bookmark-bmenu-this-window', `bookmark-bmenu-toggle-filenames',
;; `bookmark-bmenu-unmark'.
;;
;;
;; ***** NOTE: The following non-interactive functions and macros
;; defined in `bookmark.el' have been REDEFINED HERE:
;;
;; `bookmark-bmenu-bookmark', `bookmark-bmenu-check-position',
;; `bookmark-bmenu-delete', `bookmark-bmenu-delete-backwards',
;; `bookmark-bmenu-ensure-position' (Emacs 23.2+),
;; `bookmark-bmenu-hide-filenames', `bookmark-bmenu-mode',
;; `bookmark-bmenu-show-filenames',
;; `bookmark-bmenu-surreptitiously-rebuild-list',
;; `with-buffer-modified-unmodified' (Emacs < 23.2).
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 3, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;
(eval-when-compile (require 'cl)) ;; case (plus, for Emacs 20: dolist, push)
(eval-when-compile (require 'easymenu)) ;; easy-menu-create-menu
(eval-when-compile (require 'org nil t)) ;; org-add-link-type
(require 'bookmark)
;; bookmark-alist, bookmark-bmenu-file-column,
;; bookmark-bmenu-hidden-bookmarks, bookmark-bmenu-mode-map,
;; bookmark-bmenu-select, bookmark-get-annotation,
;; bookmark-get-filename, bookmark-get-handler, bookmark-kill-line,
;; bookmark-maybe-load-default-file, bookmark-name-from-full-record,
;; bookmark-name-from-record, bookmark-prop-get
;; Some general Renamings.
;;
;; 1. Fix incompatibility introduced by gratuitous Emacs name change.
;;
(cond ((and (fboundp 'bookmark-name-from-record) (not (fboundp 'bookmark-name-from-full-record)))
(defalias 'bookmark-name-from-full-record 'bookmark-name-from-record))
((and (fboundp 'bookmark-name-from-full-record) (not (fboundp 'bookmark-name-from-record)))
(defalias 'bookmark-name-from-record 'bookmark-name-from-full-record)))
;; 2. The vanilla name of the first is misleading, as it returns only the cdr of the record.
;; The second is for consistency.
;;
(defalias 'bmkp-bookmark-data-from-record 'bookmark-get-bookmark-record)
(defalias 'bmkp-bookmark-name-from-record 'bookmark-name-from-full-record)
(eval-when-compile
(or (condition-case nil
(load-library "bookmark+-mac") ; Use load-library to ensure latest .elc.
(error nil))
(require 'bookmark+-mac))) ; Require, so can load separately if not on `load-path'.
;; bmkp-define-show-only-command, bmkp-define-sort-command, bmkp-menu-bar-make-toggle,
;; bmkp-with-help-window, bmkp-with-output-to-plain-temp-buffer
(put 'bmkp-with-output-to-plain-temp-buffer 'common-lisp-indent-function '(4 &body))
;;; These functions are used in macro `bmkp-define-sort-command'. The first is used in the macro code
;;; that produces the function code, so its definition is also in `bookmark+-mac.el'.
;;;
(defun bmkp-replace-regexp-in-string (regexp rep string &optional fixedcase literal subexp start)
"Replace all matches for REGEXP with REP in STRING and return STRING."
(if (fboundp 'replace-regexp-in-string) ; Emacs > 20.
(replace-regexp-in-string regexp rep string fixedcase literal subexp start)
(if (string-match regexp string) (replace-match rep nil nil string) string))) ; Emacs 20
(defun bmkp-assoc-delete-all (key alist)
"Delete from ALIST all elements whose car is `equal' to KEY.
Return the modified alist.
Elements of ALIST that are not conses are ignored."
(while (and (consp (car alist)) (equal (car (car alist)) key)) (setq alist (cdr alist)))
(let ((tail alist)
tail-cdr)
(while (setq tail-cdr (cdr tail))
(if (and (consp (car tail-cdr)) (equal (car (car tail-cdr)) key))
(setcdr tail (cdr tail-cdr))
(setq tail tail-cdr))))
alist)
;; (eval-when-compile (require 'bookmark+-1))
;; bmkp-add-tags, bmkp-alpha-p, bmkp-bookmark-creation-cp,
;; bmkp-bookmark-description, bmkp-bookmark-file-bookmark-p,
;; bmkp-bookmark-last-access-cp, bmkp-bookmark-list-bookmark-p,
;; bmkp-buffer-last-access-cp, bmkp-completing-read-buffer-name,
;; bmkp-completing-read-file-name, bmkp-current-bookmark-file,
;; bmkp-current-sort-order, bmkp-describe-bookmark,
;; bmkp-describe-bookmark-internals, bmkp-desktop-bookmark-p,
;; bmkp-edit-bookmark-name-and-location, bmkp-file-alpha-cp,
;; bmkp-file-remote-p, bmkp-function-bookmark-p,
;; bookmark-get-bookmark, bmkp-get-buffer-name, bmkp-get-tags,
;; bmkp-gnus-bookmark-p, bmkp-gnus-cp, bmkp-handler-cp,
;; bmkp-incremental-filter-delay, bmkp-image-bookmark-p,
;; bmkp-info-bookmark-p, bmkp-info-node-name-cp,
;; bmkp-info-position-cp, bmkp-isearch-bookmarks,
;; bmkp-isearch-bookmarks-regexp, bmkp-jump-1,
;; bmkp-last-bookmark-file, bmkp-last-specific-buffer,
;; bmkp-last-specific-file, bmkp-latest-bookmark-alist,
;; bmkp-local-file-bookmark-p, bmkp-local-file-type-cp,
;; bmkp-local-file-accessed-more-recently-cp,
;; bmkp-local-file-updated-more-recently-cp,
;; bmkp-set-sequence-bookmark, bmkp-man-bookmark-p,
;; bmkp-marked-bookmark-p, bmkp-marked-bookmarks-only, bmkp-marked-cp,
;; bmkp-msg-about-sort-order, bmkp-non-file-filename,
;; bmkp-read-tag-completing, bmkp-read-tags-completing,
;; bmkp-refresh-menu-list, bmkp-region-bookmark-p,
;; bmkp-remove-all-tags, bmkp-remove-if, bmkp-remove-tags,
;; bmkp-repeat-command, bmkp-reverse-multi-sort-p,
;; bmkp-reverse-sort-p, bmkp-root-or-sudo-logged-p, bmkp-same-file-p,
;; bmkp-save-menu-list-state, bmkp-sequence-bookmark-p,
;; bmkp-set-tag-value, bmkp-set-tag-value-for-bookmarks,
;; bmkp-set-union, bmkp-snippet-alist-only, bmkp-snippet-bookmark-p,
;; bmkp-some, bmkp-some-marked-p, bmkp-some-unmarked-p,
;; bmkp-sort-omit, bmkp-sort-comparer, bmkp-sorted-alist,
;; bmkp-su-or-sudo-regexp, bmkp-tag-name, bmkp-tags-list,
;; bmkp-url-bookmark-p, bmkp-url-cp, bmkp-unmarked-bookmarks-only,
;; bmkp-variable-list-bookmark-p, bmkp-visited-more-cp
;; (eval-when-compile (require 'bookmark+-lit nil t))
;; bmkp-get-lighting
;;;;;;;;;;;;;;;;;;;;;;;
;; Quiet the byte-compiler
(defvar bookmark-file-coding-system) ; In `bookmark.el' (Emacs 25.2+)
(defvar bmkp-bmenu-highlight-menu) ; Defined in this file (conditionally).
(defvar bmkp-copied-tags) ; In `bookmark+-1.el'.
(defvar bmkp-count-multi-mods-as-one-flag) ; In `bookmark+-1.el'.
(defvar bmkp-current-bookmark-file) ; In `bookmark+-1.el'.
(defvar bmkp-edit-bookmark-orig-record) ; In `bookmark+-1.el'.
(defvar bmkp-incremental-filter-delay) ; In `bookmark+-1.el'.
(defvar bmkp-edit-bookmark-records-number) ; In `bookmark+-1.el'.
(defvar bmkp-last-bookmark-file) ; In `bookmark+-1.el'.
(defvar bmkp-last-specific-buffer) ; In `bookmark+-1.el'.
(defvar bmkp-last-specific-file) ; In `bookmark+-1.el'.
(defvar bmkp-latest-bookmark-alist) ; In `bookmark+-1.el'.
(defvar bmkp-modified-bookmarks) ; In `bookmark+-1.el'.
(defvar bmkp-non-file-filename) ; In `bookmark+-1.el'.
(defvar bmkp-reverse-multi-sort-p) ; In `bookmark+-1.el'.
(defvar bmkp-reverse-sort-p) ; In `bookmark+-1.el'.
(defvar bmkp-sort-comparer) ; In `bookmark+-1.el'.
(defvar bmkp-sorted-alist) ; In `bookmark+-1.el'.
(defvar bmkp-sort-orders-alist) ; Here.
(defvar bmkp-su-or-sudo-regexp) ; In `bookmark+-1.el'.
(defvar bmkp-temporary-bookmarking-mode) ; In `bookmark+-1.el'.
(defvar dired-re-mark) ; In `dired.el'.
(defvar icicle-candidate-properties-alist) ; In `icicles-var.el'.
(defvar minibuffer-prompt-properties) ; Emacs 22+.
(defvar tramp-file-name-regexp) ; In `tramp.el'.
;;(@* "Utility Functions")
;;; Utility Functions ------------------------------------------------
;; Same as `tap-string-match-p' in `thingatpt+.el' and `icicle-string-match-p' in `icicles-fn.el'.
(if (fboundp 'string-match-p)
(defalias 'bmkp-string-match-p 'string-match-p) ; Emacs 23+
(defun bmkp-string-match-p (regexp string &optional start)
"Like `string-match', but this saves and restores the match data."
(save-match-data (string-match regexp string start))))
;; Same as `tap-looking-at-p' in `thingatpt+.el' and `icicle-looking-at-p' in `icicles-mcmd.el'.
;; Do not `defalias' to Emacs `looking-at-p' because that is a `defsubst'.
(defun bmkp-looking-at-p (regexp)
"Like `looking-at', but this saves and restores the match data."
(save-match-data (looking-at regexp)))
;; Same as `icicle-remap' in `icicles-opt.el'. Not used yet.
(defun bmkp-remap (old new map &optional oldmap)
"Bind command NEW in MAP to all keys currently bound to OLD.
If command remapping is available, use that. Otherwise, bind NEW to
whatever OLD is bound to in MAP, or in OLDMAP, if provided."
(if (fboundp 'command-remapping)
(define-key map (vector 'remap old) new) ; Ignore OLDMAP for Emacs 22.
(substitute-key-definition old new map oldmap)))
;; This is also in `bookmark+-lit.el', since it is loaded first but is optional.
;;
(if (fboundp 'pop-to-buffer-same-window)
(defalias 'bmkp--pop-to-buffer-same-window 'pop-to-buffer-same-window)
(defalias 'bmkp--pop-to-buffer-same-window 'switch-to-buffer))
;;(@* "Faces (Customizable)")
;;; Faces (Customizable) ---------------------------------------------
(defgroup bookmark-plus nil
"Bookmark enhancements."
:prefix "bmkp-" :group 'bookmark
:link `(url-link :tag "Send Bug Report"
,(concat "mailto:" "drew.adams" "@" "oracle" ".com?subject=\
Bookmark+ bug: \
&body=Describe bug here, starting with `emacs -Q'. \
Don't forget to mention your Emacs and library versions."))
:link '(url-link :tag "Download" "https://www.emacswiki.org/emacs/download/bookmark%2b.el")
:link '(url-link :tag "Description" "https://www.emacswiki.org/emacs/BookmarkPlus")
:link '(emacs-commentary-link :tag "Commentary" "bookmark+"))
(defface bmkp->-mark '((((background dark)) (:foreground "Yellow"))
(t (:foreground "Blue")))
;; (:foreground "Magenta2" :box (:line-width 1 :style pressed-button))))
"*Face used for a `>' mark in the bookmark list."
:group 'bookmark-plus :group 'faces)
(defface bmkp-a-mark '((((background dark)) (:background "SaddleBrown"))
(t (:background "SkyBlue")))
"*Face used for an annotation indicator (`a') in the bookmark list."
:group 'bookmark-plus :group 'faces)
(defface bmkp-bad-bookmark '((t (:foreground "Red" :background "Chartreuse1")))
"*Face used for a bookmark that seems to be bad: e.g., nonexistent file."
:group 'bookmark-plus :group 'faces)
(defface bmkp-bookmark-file
'((((background dark))
(:foreground "#00005A5AFFFF" :background "#FFFF9B9BFFFF")) ; ~ blue, ~ pink
(t (:foreground "Orange" :background "DarkGreen")))
"*Face used for a bookmark-file bookmark."
:group 'bookmark-plus :group 'faces)
(defface bmkp-bookmark-list
'((((background dark)) (:foreground "#7474FFFFFFFF" :background "DimGray")) ; ~ cyan
(t (:foreground "DarkRed" :background "LightGray")))
"*Face used for a bookmark-list bookmark."
:group 'bookmark-plus :group 'faces)
(defface bmkp-buffer
'((((background dark)) (:foreground "#FFFF9B9BFFFF")) ; ~ pink
(t (:foreground "DarkGreen")))
"*Face used for a bookmarked existing buffer not associated with a file."
:group 'bookmark-plus :group 'faces)
(defface bmkp-D-mark '((t (:foreground "Yellow" :background "Red")))
"*Face used for a deletion mark (`D') in the bookmark list."
:group 'bookmark-plus :group 'faces)
(defface bmkp-desktop
'((((background dark)) (:foreground "Orange" :background "DarkSlateBlue"))
(t (:foreground "DarkBlue" :background "PaleGoldenrod")))
"*Face used for a bookmarked desktop."
:group 'bookmark-plus :group 'faces)
(defface bmkp-file-handler
'((((background dark)) (:background "#272740402727")) ; ~ dark green
(t (:background "Thistle")))
"*Face used for a bookmark that has a `file-handler' attribute."
:group 'bookmark-plus :group 'faces)
(defface bmkp-function
'((((background dark)) (:foreground "#0000EBEB6C6C")) ; ~ green
(t (:foreground "DeepPink1")))
"*Face used for a function bookmark: a bookmark that invokes a function."
:group 'bookmark-plus :group 'faces)
(defface bmkp-gnus
'((((background dark)) (:foreground "Gold"))
(t (:foreground "DarkBlue")))
"*Face used for a Gnus bookmark."
:group 'bookmark-plus :group 'faces)
(defface bmkp-info
'((((background dark)) (:foreground "#7474FFFFFFFF")) ; ~ light cyan
(t (:foreground "DarkRed")))
"*Face used for a bookmarked Info node."
:group 'bookmark-plus :group 'faces)
(defface bmkp-local-directory
'((((background dark))
(:foreground "Pink" :background "DarkBlue"))
(t (:foreground "DarkBlue" :background "HoneyDew2")))
"*Face used for a bookmarked local directory."
:group 'bookmark-plus :group 'faces)
(defface bmkp-local-file-without-region
'((((background dark)) (:foreground "White"))
(t (:foreground "Black")))
"*Face used for a bookmarked local file (without a region)."
:group 'bookmark-plus :group 'faces)
(defface bmkp-local-file-with-region
'((((background dark)) (:foreground "Yellow"))
(t (:foreground "Blue")))
"*Face used for a region bookmark in a local file."
:group 'bookmark-plus :group 'faces)
(defface bmkp-man
'((((background dark)) (:foreground "Orchid"))
(t (:foreground "Orange4")))
"*Face used for a `man' page bookmark."
:group 'bookmark-plus :group 'faces)
(defface bmkp-*-mark '((t (:foreground "Red" :background "Yellow")))
"*Face used for a modification mark (`*') in the bookmark list."
:group 'bookmark-plus :group 'faces)
(defface bmkp-no-jump
'((t (:foreground "gray50")))
"*Face used for a bookmark you cannot jump to from `*Bookmark List*'."
:group 'bookmark-plus :group 'faces)
(defface bmkp-no-local
'((t (:foreground "yellow")))
"*Face used for a local file bookmark whose target file does not exist."
:group 'bookmark-plus :group 'faces)
(defface bmkp-non-file
'((t (:foreground "MediumSeaGreen")))
"*Face used for a bookmark not associated with an existing buffer."
:group 'bookmark-plus :group 'faces)
(defface bmkp-remote-file
'((((background dark)) (:foreground "#6B6BFFFF2C2C")) ; ~ green
(t (:foreground "DarkViolet")))
"*Face used for a bookmarked tramp remote file (/ssh:)."
:group 'bookmark-plus :group 'faces)
(defface bmkp-sequence
'((((background dark)) (:foreground "DeepSkyBlue"))
(t (:foreground "DarkOrange2")))
"*Face used for a sequence bookmark: one composed of other bookmarks."
:group 'bookmark-plus :group 'faces)
(defface bmkp-snippet
(if (> emacs-major-version 21)
'((t (:inherit region)))
'((t (:background "MediumAquamarine"))))
"*Face used for a bookmarked snippet."
:group 'bookmark-plus :group 'faces)
(defface bmkp-su-or-sudo '((t (:foreground "Red")))
"*Face used for a bookmarked tramp file (/su: or /sudo:)."
:group 'bookmark-plus :group 'faces)
(defface bmkp-t-mark '((((background dark)) (:foreground "Magenta"))
(t (:foreground "#000093F402A2"))) ; a medium green
"*Face used for a tags mark (`t') in the bookmark list."
:group 'bookmark-plus :group 'faces)
(defface bmkp-url
'((((background dark)) (:foreground "#7474FFFF7474")) ; ~ green
(t (:foreground "DarkMagenta")))
"*Face used for a bookmarked URL."
:group 'bookmark-plus :group 'faces)
(defface bmkp-variable-list
'((((background dark)) (:foreground "#FFFF8D947477")) ; ~ salmon
(t (:foreground "#0000726B8B8B"))) ; ~dark cyan
"*Face used for a bookmarked list of variables."
:group 'bookmark-plus :group 'faces)
(defface bmkp-X-mark '((t (:foreground "Red")))
"*Face used for a temporary-bookmark indicator (`X') in the bookmark list."
:group 'bookmark-plus :group 'faces)
;; $$$$$$ Not used now - using `bmkp-url' instead.
;; (defface bmkp-w3m
;; '((((background dark)) (:foreground "yellow"))
;; (t (:foreground "DarkMagenta")))
;; "*Face used for a bookmarked w3m url."
;; :group 'bookmark-plus :group 'faces)
;; Instead of vanilla `bookmark-menu-heading' (defined in Emacs 22+), to use a better default.
(defface bmkp-heading '((((background dark)) (:foreground "Yellow"))
(t (:foreground "Blue")))
"*Face used to highlight the headings in various Bookmark+ buffers."
:group 'bookmark-plus :version "22.1" :group 'faces)
;;(@* "User Options (Customizable)")
;;; User Options (Customizable) --------------------------------------
;;;###autoload (autoload 'bmkp-bmenu-omitted-bookmarks "bookmark+")
(defcustom bmkp-bmenu-omitted-bookmarks ()
"*List of names of omitted bookmarks.
They are generally not available for display in the bookmark list.
You can, however, use \\<bookmark-bmenu-mode-map>\
`\\[bmkp-bmenu-show-only-omitted-bookmarks]' to see them.
You can then mark some of them and use `\\[bmkp-bmenu-omit/unomit-marked]'
to make those that are marked available again for the bookmark list."
;; $$$$$$ TODO: Create a customize :type `bookmark-name'
;; and provide completion for filling out the field.
:type '(repeat (string :tag "Bookmark name")) :group 'bookmark-plus)
;;;###autoload (autoload 'bmkp-bmenu-commands-file "bookmark+")
(defcustom bmkp-bmenu-commands-file (convert-standard-filename "~/.emacs-bmk-bmenu-commands.el")
"*File for saving user-defined bookmark-list commands.
This must be an absolute file name (possibly containing `~') or nil
\(it is not expanded).
You can use `\\[bmkp-list-defuns-in-commands-file]' to list the
commands defined in the file and how many times each is defined.
NOTE: Each time you define a command using \\<bookmark-bmenu-mode-map>\
`\\[bmkp-bmenu-define-command]', `\\[bmkp-bmenu-define-full-snapshot-command]', \
`\\[bmkp-bmenu-define-jump-marked-command], or `\\[bmkp-define-tags-sort-command]',
it is saved in the file. The new definition is simply appended to the
file - old definitions of the same command are not overwritten. So
you might want to clean up the file occasionally, to remove any old,
unused definitions. This is especially advisable if you used \
`\\[bmkp-bmenu-define-full-snapshot-command]',
because such command definitions can be very large."
:type '(file :tag "File for saving menu-list state") :group 'bookmark-plus)
;;;###autoload (autoload 'bmkp-bmenu-state-file "bookmark+")
(defcustom bmkp-bmenu-state-file (convert-standard-filename "~/.emacs-bmk-bmenu-state.el")
"*File for saving `*Bookmark List*' state when you quit bookmark list.
This must be an absolute file name (possibly containing `~') or nil
\(it is not expanded).
The state is also saved when you quit Emacs, even if you don't quit
the bookmark list first (using \\<bookmark-bmenu-mode-map>`\\[bmkp-bmenu-quit]').
Set this to nil if you do not want to restore the bookmark list as it
was the last time you used it."
:type '(choice
(const :tag "Do not save and restore menu-list state" nil)
(file :tag "File for saving menu-list state"))
:group 'bookmark-plus)
;;;###autoload (autoload 'bmkp-bmenu-image-bookmark-icon-file "bookmark+")
(defcustom bmkp-bmenu-image-bookmark-icon-file
(and (fboundp 'display-images-p) (display-images-p)
(let ((bmk-img (convert-standard-filename "~/.emacs-bmk-bmenu-image-file-icon.png"))
(emacs-img (convert-standard-filename (concat data-directory "images/gnus/exit-gnus.xpm"))))
(or (and (file-readable-p bmk-img) bmk-img)
(and (file-readable-p emacs-img) emacs-img))))
"*Iconic image file to show next to image-file bookmarks.
If nil, show no image. Otherwise, this is an absolute file name,
possibly containing `~', (the value is not expanded).
Use any image file that Emacs can display, but you probably want to
use a small, iconic image - say 16x16 pixels.
The default image, which you are sure to have in any Emacs version
that supports images, is 24x24 pixels. That wastes vertical space, so
you probably want to use something smaller.
If you don't have another image that you prefer, try this one (16x16):
https://www.emacswiki.org/emacs/BookmarkPlusImageFileDefaultIcon"
:type '(choice
(file :tag "Use iconic image file")
(const :tag "Show no image"))
:group 'bookmark-plus)
;; This is a general option. It is in this file because it is used mainly by the bmenu code.
(when (> emacs-major-version 20)
(defcustom bmkp-sort-orders-alist ()
"*Alist of all available sort functions.
This is a pseudo option - you probably do NOT want to customize this.
Instead:
* To add a new sort function to this list, use macro
`bmkp-define-sort-command'. It defines a new sort function
and automatically adds it to this list.
* To have fewer sort orders available for cycling by \\<bookmark-bmenu-mode-map>\
`\\[bmkp-bmenu-change-sort-order-repeat]'...,
customize option `bmkp-sort-orders-for-cycling-alist'.
Each alist element has the form (SORT-ORDER . COMPARER):
SORT-ORDER is a short string or symbol describing the sort order.
Examples: \"by last access time\", \"by bookmark name\".
COMPARER compares two bookmarks. It must be acceptable as a value of
`bmkp-sort-comparer'."
:type '(alist
:key-type (choice :tag "Sort order" string symbol)
:value-type (choice
(const :tag "None (do not sort)" nil)
(function :tag "Sorting Predicate")
(list :tag "Sorting Multi-Predicate"
(repeat (function :tag "Component Predicate"))
(choice
(const :tag "None" nil)
(function :tag "Final Predicate")))))
:group 'bookmark-plus))
(unless (> emacs-major-version 20) ; Emacs 20: custom type `alist' doesn't exist.
(defcustom bmkp-sort-orders-alist ()
"*Alist of all available sort functions.
This is a pseudo option - you probably do NOT want to customize this.
Instead:
* To add a new sort function to this list, use macro
`bmkp-define-sort-command'. It defines a new sort function
and automatically adds it to this list.
* To have fewer sort orders available for cycling by \\<bookmark-bmenu-mode-map>\
`\\[bmkp-bmenu-change-sort-order-repeat]'...,
customize option `bmkp-sort-orders-for-cycling-alist'.
Each alist element has the form (SORT-ORDER . COMPARER):
SORT-ORDER is a short string or symbol describing the sort order.
Examples: \"by last access time\", \"by bookmark name\".
COMPARER compares two bookmarks. It must be acceptable as a value of
`bmkp-sort-comparer'."
:type '(repeat
(cons
(choice :tag "Sort order" string symbol)
(choice
(const :tag "None (do not sort)" nil)
(function :tag "Sorting Predicate")
(list :tag "Sorting Multi-Predicate"
(repeat (function :tag "Component Predicate"))
(choice
(const :tag "None" nil)
(function :tag "Final Predicate"))))))
:group 'bookmark-plus))
(defcustom bmkp-propertize-bookmark-names-flag (> emacs-major-version 20)
"*Non-nil means to propertize bookmark names to hold full bookmark data.
This means that you can effectively have more than one bookmark with
the same name.
Emacs 20 users: If you need to use your bookmarks with Emacs 20 then
set this to nil. In particular, if your bookmark file was written
with this as non-nil, then it contains propertized strings which are
unreadable by Emacs 20. To convert the file to be usable with Emacs
20 you must, in Emacs 21 or later, set this to nil and then do `M-x
bookmark-save'."
:type 'boolean :group 'bookmark-plus)
;;(@* "Internal Variables")
;;; Internal Variables -----------------------------------------------
(defconst bmkp-bmenu-header-lines 5
"Number of lines used for the `*Bookmark List*' header.")
(defconst bmkp-bmenu-marks-width 4
"Number of columns (chars) used for the `*Bookmark List*' marks columns.
Bookmark names thus begin in this column number (since zero-based).")
(defvar bmkp-bmenu-before-hide-marked-alist ()
"Copy of `bookmark-alist' made before hiding marked bookmarks.")
(defvar bmkp-bmenu-before-hide-unmarked-alist ()
"Copy of `bookmark-alist' made before hiding unmarked bookmarks.")
(defvar bmkp-bmenu-define-command-history ()
"History of names of commands you have defined for `*Bookmark List*'.")
(defvar bmkp-bmenu-filter-function nil "Latest filtering function for `*Bookmark List*' display.")
(defvar bmkp-bmenu-filter-pattern "" "Regexp for incremental filtering.")
(defvar bmkp-bmenu-filter-timer nil "Timer used for incremental filtering.")
(defvar bmkp-bmenu-first-time-p t
"Non-nil means bookmark list has not yet been shown after quitting it.
Quitting the list or the Emacs session resets this to t.
The first time the list is displayed, it is set to nil.")
(defvar bmkp-bmenu-marked-bookmarks ()
"Names of the marked bookmarks.
This includes possibly omitted bookmarks, that is, bookmarks listed in
`bmkp-bmenu-omitted-bookmarks'.")
(defvar bmkp-bmenu-title "" "Latest title for `*Bookmark List*' display.")
(defvar bmkp-flagged-bookmarks ()
"Alist of bookmarks that are flagged for deletion in `*Bookmark List*'.")
;; This is a general variable. It is in this file because it is used only in the bmenu code.
(defvar bmkp-last-bmenu-bookmark nil "The name of the last bookmark current in the bookmark list.")
;;(@* "Compatibility Code for Older Emacs Versions")
;;; Compatibility Code for Older Emacs Versions ----------------------
(when (or (< emacs-major-version 23) (and (= emacs-major-version 23) (= emacs-minor-version 1)))
(defmacro with-buffer-modified-unmodified (&rest body)
"Save and restore `buffer-modified-p' state around BODY."
(let ((was-modified (make-symbol "was-modified")))
`(let ((,was-modified (buffer-modified-p)))
(unwind-protect (progn ,@body)
(set-buffer-modified-p ,was-modified))))))
(when (< emacs-major-version 22)
(defun bookmark-bmenu-relocate ()
"Change the file path of the bookmark on the current line,
prompting with completion for the new path."
(interactive)
(let ((bmk (bookmark-bmenu-bookmark))
(thispoint (point)))
(bookmark-relocate bmk)
(goto-char thispoint))))
;;(@* "Menu List Replacements (`bookmark-bmenu-*')")
;;; Menu List Replacements (`bookmark-bmenu-*') ----------------------
;; REPLACES ORIGINAL in `bookmark.el'.
;;
;; 1. Return t. Value doesn't mean anything (didn't anyway), but must be non-nil for vanilla Emacs.
;; 2. Do not count lines. Just make sure we're on a bookmark line.
;;
(defalias 'bookmark-bmenu-check-position 'bookmark-bmenu-ensure-position)
(defun bookmark-bmenu-ensure-position ()
"Move to the beginning of the nearest bookmark line."
(beginning-of-line)
(unless (bookmark-bmenu-bookmark)
(if (and (bolp) (eobp))
(beginning-of-line 0)
(goto-char (point-min))
(forward-line bmkp-bmenu-header-lines)))
t) ; Older vanilla bookmark code depends on non-nil value.
;; REPLACES ORIGINAL in `bookmark.el'.
;;
;; 1. Add bookmark to `bmkp-bmenu-marked-bookmarks'. Delete it from `bmkp-flagged-bookmarks'.
;; 2. Don't call `bookmark-bmenu-ensure-position' again at end.
;; 3. Raise error if not in `*Bookmark List*'.
;; 4. Narrower scope for `with-buffer-modified-unmodified' and `let'.
;; 5. If current sort is `s >' (marked first or last), and it was unmarked before, then re-sort.
;; 6. Added optional arg NO-RE-SORT-P to inhibit #5.
;; 7. Added optional arg MSG-P.
;; 8. Call `bmkp-bmenu-mode-line'.
;;
;;;###autoload (autoload 'bookmark-bmenu-mark "bookmark+")
(defun bookmark-bmenu-mark (&optional no-re-sort-p msg-p) ; Bound to `m' in bookmark list
"Mark the bookmark on this line, using mark `>'.
Add its name to `bmkp-bmenu-marked-bookmarks', after propertizing it
with the full bookmark as `bmkp-full-record'.
If the bookmark was unmarked before, and if the sort order is marked
first or last (`s >'), then re-sort.
Non-interactively:
* Non-nil optional arg NO-RE-SORT-P inhibits re-sorting.
* Non-nil optional arg MSG-P means display a status message."
(interactive (list nil 'MSG-P))
(bmkp-bmenu-barf-if-not-in-menu-list)
(bookmark-bmenu-ensure-position)
(beginning-of-line)
(with-buffer-modified-unmodified
(let ((inhibit-read-only t))
(delete-char 1) (insert ?>) (put-text-property (1- (point)) (point) 'face 'bmkp->-mark)))
(let* ((bname (bookmark-bmenu-bookmark))
(bmk (bmkp-bookmark-record-from-name bname))
(was-unmarked-p nil))
;; Put full bookmark on BNAME as property `bmkp-full-record'.
(put-text-property 0 (length bname) 'bmkp-full-record bmk bname)
;; This is the same as `add-to-list' with `eq' (not available for Emacs 20-21).
(unless (memq bname bmkp-bmenu-marked-bookmarks)
(setq bmkp-bmenu-marked-bookmarks (cons bname bmkp-bmenu-marked-bookmarks)
was-unmarked-p t))
(setq bmkp-flagged-bookmarks (delq bmk bmkp-flagged-bookmarks))
(unless no-re-sort-p
;; If it was unmarked but now is marked, and if sort order is `s >', then re-sort.
(when (and was-unmarked-p (equal bmkp-sort-comparer '((bmkp-marked-cp) bmkp-alpha-p)))
(let ((curr-bmk (bookmark-bmenu-bookmark)))
(bookmark-bmenu-surreptitiously-rebuild-list (not msg-p))
(when curr-bmk (bmkp-bmenu-goto-bookmark-named curr-bmk))))))
(forward-line 1)
(when (fboundp 'bmkp-bmenu-mode-line) (bmkp-bmenu-mode-line)))
;; REPLACES ORIGINAL in `bookmark.el'.
;;