[emacs] Update 2 drones
[~bandali/configs] / lisp / bbdb / bbdb-vm.el
... / ...
CommitLineData
1;;; bbdb-vm.el --- BBDB interface to VM -*- lexical-binding: t -*-
2
3;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
4
5;; This file is part of the Insidious Big Brother Database (aka BBDB),
6
7;; BBDB is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; BBDB is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with BBDB. If not, see <http://www.gnu.org/licenses/>.
19
20;;; Commentary:
21;;; This file contains the BBDB interface to VM.
22;;; See the BBDB info manual for documentation.
23
24;;; Code:
25
26(require 'bbdb)
27(require 'bbdb-com)
28(require 'bbdb-mua)
29(require 'vm-autoloads)
30(require 'vm-motion)
31(require 'vm-summary)
32(require 'vm-mime)
33(require 'vm-vars)
34(require 'vm-macro)
35(require 'vm-message)
36(require 'vm-misc)
37
38;;;###autoload
39(defun bbdb/vm-header (header)
40 (save-current-buffer
41 (vm-select-folder-buffer)
42 (vm-get-header-contents (car vm-message-pointer)
43 (concat header ":"))))
44
45;;;###autoload
46(defun bbdb-insinuate-vm ()
47 "Hook BBDB into VM.
48Do not call this in your init file. Use `bbdb-initialize'."
49 (define-key vm-mode-map ":" 'bbdb-mua-display-records)
50 (define-key vm-mode-map "`" 'bbdb-mua-display-sender)
51 (define-key vm-mode-map "'" 'bbdb-mua-display-recipients)
52 (define-key vm-mode-map ";" 'bbdb-mua-edit-field-sender)
53 ;; Do we need keybindings for more commands? Suggestions welcome.
54 ;; (define-key vm-mode-map "'" 'bbdb-mua-edit-field-recipients)
55 (define-key vm-mode-map "/" 'bbdb)
56 ;; `mail-mode-map' is the parent of `vm-mail-mode-map'.
57 ;; So the following is also done by `bbdb-insinuate-mail'.
58 (if (and bbdb-complete-mail (boundp 'vm-mail-mode-map))
59 (define-key vm-mail-mode-map "\M-\t" 'bbdb-complete-mail))
60
61 ;; Set up user field for use in `vm-summary-format'
62 ;; (1) Big solution: use whole name
63 (if bbdb-mua-summary-unify-format-letter
64 (fset (intern (concat "vm-summary-function-"
65 bbdb-mua-summary-unify-format-letter))
66 (lambda (m) (bbdb-mua-summary-unify
67 ;; VM does not give us the original From header.
68 ;; So we have to work backwards.
69 (let ((name (vm-decode-mime-encoded-words-in-string
70 (vm-su-interesting-full-name m)))
71 (mail (vm-su-from m)))
72 (if (string= name mail) mail
73 (format "\"%s\" <%s>" name mail)))))))
74
75 ;; (2) Small solution: a mark for messages whos sender is in BBDB.
76 (if bbdb-mua-summary-mark-format-letter
77 (fset (intern (concat "vm-summary-function-"
78 bbdb-mua-summary-mark-format-letter))
79 ;; VM does not give us the original From header.
80 ;; So we assume that the mail address is sufficient to identify
81 ;; the BBDB record of the sender.
82 (lambda (m) (bbdb-mua-summary-mark (vm-su-from m))))))
83
84(provide 'bbdb-vm)
85
86;;; bbdb-vm.el ends here