blob: aed305cc3417810179d77529660fcefc452b33bf (
plain)
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
|
;;; bookmark-conf.el --- My configurations for bookmark -*- lexical-binding: t; -*-
;; Copyright (C) 2021 Durand
;; Author: Durand <mmemmew@gmail.com>
;; Keywords: convenience
;; 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 of the License, 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. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; My configurations for bookmarks.
;;; Code:
;; dependency of blist
(use-package "ilist" 'ilist)
(use-package "blist" 'blist)
;;; Customizations
;;;; Pseudo-expert?
(setq blist-expert t)
;;;; Discard empty groups
(setq blist-discard-empty-p t)
;;;; I love cycling
(setq blist-movement-cycle t)
;;;; Filter groups
(setq
blist-filter-groups
(list
(cons "Eshell" #'blist-eshell-p)
(cons "Gnus" #'blist-gnus-p)
(cons "PDF" #'blist-pdf-p)
(cons "ELisp" #'blist-elisp-p)
(cons "Org" #'blist-org-p)
(cons "C" #'blist-c-p)
(cons "Default" #'blist-default-p)))
;;; More bookmark groups
;;;; Gnus group
;; There seems to be only two GNUS bookmark handlers (or one?)
(blist-define-criterion "gnus" "Gnus"
(let ((handler (bookmark-get-handler bookmark)))
(memq handler (list #'gnus-summary-bookmark-jump
#'gnus-bookmark-jump))))
;;;; PDF group
(blist-define-criterion "pdf" "PDF"
(eq (bookmark-get-handler bookmark) #'pdf-view-bookmark-jump-handler))
;;;; Org group
(defvar org-directory)
(blist-define-criterion "org" "Org"
(let ((location (blist-get-location bookmark)))
(or
(string-match-p
"\\.org$" location)
(and
(file-directory-p (or org-directory "/non-existing"))
(file-in-directory-p
location org-directory)))))
;;;; C group
(blist-define-criterion "c" "C"
;; `rx' is a macro, so that we don't have to compute the regular
;; expression every time we match a line.
(string-match-p
(rx
(or
(seq ".c"
(zero-or-one "pp")
eos)
(seq ".h"
(zero-or-one "pp")
eos)))
(blist-get-location bookmark)))
;;;; ELisp group
(blist-define-criterion "elisp" "ELisp"
(string-match-p "\\.el$" (blist-get-location bookmark)))
(provide 'bookmark-conf)
;;; bookmark-conf.el ends here
|