-
Notifications
You must be signed in to change notification settings - Fork 11
/
ebdb-notmuch.el
84 lines (64 loc) · 3.08 KB
/
ebdb-notmuch.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
;;; ebdb-notmuch.el --- EBDB interface to Notmuch -*- lexical-binding: t; -*-
;; Copyright (C) 2019-2024 Free Software Foundation, Inc.
;; Author: Eric Abrahamsen <[email protected]>
;; Maintainer: Eric Abrahamsen <[email protected]>
;; 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:
;; EBDB's interface to the Notmuch mail client.
;;; Code:
(require 'ebdb-mua)
(declare-function notmuch-show-get-header "notmuch-show")
(defvar notmuch-show-mode-map)
(defvar notmuch-message-mode-map)
(defgroup ebdb-mua-notmuch nil
"Options for EBDB's interaction with Notmuch"
:group 'ebdb-mua)
(defcustom ebdb-notmuch-auto-update-p ebdb-mua-reader-update-p
"Notmuch-specific value of `ebdb-mua-auto-update-p'."
:type '(choice (const :tag "do nothing" nil)
(const :tag "search for existing records" existing)
(const :tag "update existing records" update)
(const :tag "query for update or record creation" query)
(const :tag "update or create automatically" create)
(function :tag "User-defined function")))
(defcustom ebdb-notmuch-window-size ebdb-default-window-size
"Size of the EBDB buffer when popping up in Notmuch.
Size should be specified as a float between 0 and 1. Defaults to
the value of `ebdb-default-window-size'."
:type 'float)
(cl-defmethod ebdb-mua-message-header ((header string)
&context (major-mode notmuch-show-mode))
"Extract a message header in Notmuch."
(notmuch-show-get-header
;; Yuck, is there no better way to turn a string into a keyword?
(intern (format ":%s" (capitalize header)))))
(cl-defmethod ebdb-make-buffer-name (&context (major-mode notmuch-show-mode))
(format "*%s-Notmuch*" ebdb-buffer-name))
(cl-defmethod ebdb-popup-window (&context (major-mode notmuch-show-mode))
(list (get-buffer-window) ebdb-notmuch-window-size))
;;;###autoload
(defun ebdb-insinuate-notmuch-show ()
"Hook EBDB into Notmuch's `notmuch-show-mode'."
(unless ebdb-db-list
(ebdb-load))
(define-key notmuch-show-mode-map ";" ebdb-mua-keymap))
;;;###autoload
(defun ebdb-insinuate-notmuch-message ()
"Hook EBDB into Notmuch's `notmuch-message-mode'."
(unless ebdb-db-list
(ebdb-load))
(when ebdb-complete-mail
(define-key notmuch-message-mode-map (kbd "TAB") #'ebdb-complete-mail)))
(add-hook 'notmuch-show-mode-hook #'ebdb-insinuate-notmuch-show)
(add-hook 'notmuch-message-mode-hook #'ebdb-insinuate-notmuch-message)
(provide 'ebdb-notmuch)
;;; ebdb-notmuch.el ends here