Repository navigation
Expand file tree
/
Copy pathpoimap-bm.el
More file actions
97 lines (78 loc) · 3.15 KB
/
Copy pathpoimap-bm.el
File metadata and controls
97 lines (78 loc) · 3.15 KB
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
;;; poimap-bm.el --- Bm POIs for poimap -*- lexical-binding: t; -*-
;; Copyright (C) 2026 Florian Rommel
;; Author: Florian Rommel <mail@florommel.de>
;; Maintainer: Florian Rommel <mail@florommel.de>
;; URL: https://github.com/florommel/poimap
;; Created: 2026-06-25
;; Version: 0.1
;; Package-Requires: ((emacs "29.1") (poimap "0.1") (bm "1.0"))
;; Keywords: convenience, bookmark
;; 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:
;; Display bm bookmarks as poimap points of interest.
;;; Code:
(require 'bm)
(require 'poimap)
(defface poimap-bm-face
'((t :inherit bm-fringe-face))
"Face for poimap bm POIs.
The foreground color is used."
:group 'poimap)
(defcustom poimap-bm-shape-function #'poimap-diamond
"Function used to draw bm POIs."
:type 'function
:group 'poimap)
(defcustom poimap-bm-vertical-position 0.6
"Vertical position of bm POIs."
:type 'number
:group 'poimap)
(defcustom poimap-bm-size 7
"Size passed to `poimap-bm-shape-function'."
:type '(choice number (cons number number))
:group 'poimap)
(defun poimap-bm--update (force)
"Update bm bookmark POIs if FORCE is non-nil."
(when force
(let ((shape-fn poimap-bm-shape-function)
(vert poimap-bm-vertical-position)
(size poimap-bm-size)
(color (poimap-emacs-to-svg-color
(face-foreground 'poimap-bm-face nil 'default)))
(svg))
(dolist (ov (bm-overlay-in-buffer))
(when-let (pos (poimap-map-position (overlay-start ov)))
(push (funcall shape-fn pos vert size color) svg)))
(poimap-update-pois
'poimap-bm
(mapconcat #'identity (mapcan #'identity (nreverse svg)))))))
(defun poimap-bm--update-advice (&rest _args)
"Advice function for bm-bookmark-add/remove."
(poimap-bm--update t)
(force-mode-line-update))
;;;###autoload
(define-minor-mode poimap-bm
"Display bm bookmarks as poimap points of interest."
:global t
:group 'poimap
(if poimap-bm
(progn
(poimap--warn-unless-mode 'poimap-bm)
(add-hook 'poimap-idle-update-functions #'poimap-bm--update)
(advice-add #'bm-bookmark-add :after #'poimap-bm--update-advice)
(advice-add #'bm-bookmark-remove :after #'poimap-bm--update-advice)
(poimap--for-all-visible-window-buffers #'poimap-bm--update t))
(remove-hook 'poimap-idle-update-functions #'poimap-bm--update)
(advice-remove #'bm-bookmark-add #'poimap-bm--update-advice)
(advice-remove #'bm-bookmark-remove #'poimap-bm--update-advice)
(poimap--clear-buffer-state 'poimap-bm)))
(provide 'poimap-bm)
;;; poimap-bm.el ends here