summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/bbdb/bbdb-com.el5
-rw-r--r--lisp/bbdb/bbdb-gnus.el68
-rw-r--r--lisp/bbdb/bbdb-mhe.el1
-rw-r--r--lisp/bbdb/bbdb-mua.el35
-rw-r--r--lisp/bbdb/bbdb-rmail.el15
-rw-r--r--lisp/bbdb/bbdb-site.el46
-rw-r--r--lisp/bbdb/bbdb-tex.el27
-rw-r--r--lisp/bbdb/bbdb-vm.el93
-rw-r--r--lisp/bbdb/bbdb-wl.el8
-rw-r--r--lisp/bbdb/bbdb.el27
10 files changed, 266 insertions, 59 deletions
diff --git a/lisp/bbdb/bbdb-com.el b/lisp/bbdb/bbdb-com.el
index cf8eefacb85..500a0e0ab6e 100644
--- a/lisp/bbdb/bbdb-com.el
+++ b/lisp/bbdb/bbdb-com.el
@@ -26,8 +26,9 @@
(require 'bbdb)
(require 'mailabbrev)
-(declare-function build-mail-aliases "mailalias")
-(declare-function browse-url-url-at-point "browse-url")
+(eval-and-compile
+ (autoload 'build-mail-aliases "mailalias")
+ (autoload 'browse-url-url-at-point "browse-url"))
(require 'crm)
(defvar bbdb-crm-local-completion-map
diff --git a/lisp/bbdb/bbdb-gnus.el b/lisp/bbdb/bbdb-gnus.el
new file mode 100644
index 00000000000..c2ac987ff01
--- /dev/null
+++ b/lisp/bbdb/bbdb-gnus.el
@@ -0,0 +1,68 @@
+;;; bbdb-gnus.el --- BBDB interface to Gnus -*- lexical-binding: t -*-
+
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
+
+;; This file is part of the Insidious Big Brother Database (aka BBDB),
+
+;; BBDB 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.
+
+;; BBDB 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 BBDB. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;; This file contains the BBDB interface to Gnus.
+;;; See the BBDB info manual for documentation.
+
+;;; Code:
+
+(require 'bbdb)
+(require 'bbdb-com)
+(require 'bbdb-mua)
+(require 'gnus)
+
+;;; Insinuation
+
+;;;###autoload
+(defun bbdb-insinuate-gnus ()
+ "Hook BBDB into Gnus.
+Do not call this in your init file. Use `bbdb-initialize'."
+ ;; `bbdb-mua-display-sender' fails in *Article* buffers, where
+ ;; `gnus-article-read-summary-keys' provides an additional wrapper
+ ;; that restores the window configuration.
+ (define-key gnus-summary-mode-map ":" 'bbdb-mua-display-sender)
+ (define-key gnus-article-mode-map ":" 'bbdb-mua-display-sender)
+ ;; For `bbdb-mua-edit-field-sender' it is probably OK if
+ ;;`gnus-article-read-summary-keys' restores the window configuration.
+ (define-key gnus-summary-mode-map ";" 'bbdb-mua-edit-field-sender)
+ (define-key gnus-article-mode-map ";" 'bbdb-mua-edit-field-sender)
+ ;; Do we need keybindings for more commands? Suggestions welcome.
+ ;; (define-key gnus-summary-mode-map ":" 'bbdb-mua-display-records)
+ ;; (define-key gnus-summary-mode-map "'" 'bbdb-mua-display-recipients)
+ ;; (define-key gnus-summary-mode-map ";" 'bbdb-mua-edit-field-recipients)
+
+ ;; Set up user field for use in `gnus-summary-line-format'
+ ;; (1) Big solution: use whole name
+ (if bbdb-mua-summary-unify-format-letter
+ (defalias (intern (concat "gnus-user-format-function-"
+ bbdb-mua-summary-unify-format-letter))
+ (lambda (header)
+ (bbdb-mua-summary-unify (mail-header-from header)))))
+
+ ;; (2) Small solution: a mark for messages whose sender is in BBDB.
+ (if bbdb-mua-summary-mark-format-letter
+ (defalias (intern (concat "gnus-user-format-function-"
+ bbdb-mua-summary-mark-format-letter))
+ (lambda (header)
+ (bbdb-mua-summary-mark (mail-header-from header))))))
+
+(provide 'bbdb-gnus)
+
+;;; bbdb-gnus.el ends here
diff --git a/lisp/bbdb/bbdb-mhe.el b/lisp/bbdb/bbdb-mhe.el
index ed9cada8058..467017154a3 100644
--- a/lisp/bbdb/bbdb-mhe.el
+++ b/lisp/bbdb/bbdb-mhe.el
@@ -33,6 +33,7 @@
;; A simplified `mail-fetch-field'. We could use instead (like rmail):
;; (mail-header (intern-soft (downcase header)) (mail-header-extract))
+;;;###autoload
(defun bbdb/mh-header (header)
"Find and return the value of HEADER in the current buffer.
Returns the empty string if HEADER is not in the message."
diff --git a/lisp/bbdb/bbdb-mua.el b/lisp/bbdb/bbdb-mua.el
index dc57fd84e43..db31b06f139 100644
--- a/lisp/bbdb/bbdb-mua.el
+++ b/lisp/bbdb/bbdb-mua.el
@@ -37,29 +37,30 @@
(require 'bbdb)
(require 'bbdb-com)
-(declare-function gnus-fetch-original-field "gnus-utils")
-(declare-function gnus-summary-select-article "gnus-sum")
-(defvar gnus-article-buffer)
+(eval-and-compile
+ (autoload 'gnus-fetch-original-field "gnus-utils")
+ (autoload 'gnus-summary-select-article "gnus-sum")
+ (defvar gnus-article-buffer)
-(declare-function bbdb/vm-header "bbdb-vm")
-(declare-function vm-follow-summary-cursor "vm-motion")
-(declare-function vm-select-folder-buffer "vm-macro")
-(declare-function vm-check-for-killed-summary "vm-misc")
-(declare-function vm-error-if-folder-empty "vm-misc")
+ (autoload 'bbdb/vm-header "bbdb-vm")
+ (autoload 'vm-follow-summary-cursor "vm-motion")
+ (autoload 'vm-select-folder-buffer "vm-macro")
+ (autoload 'vm-check-for-killed-summary "vm-misc")
+ (autoload 'vm-error-if-folder-empty "vm-misc")
-(declare-function bbdb/rmail-header "bbdb-rmail")
-(defvar rmail-buffer)
+ (autoload 'bbdb/rmail-header "bbdb-rmail")
+ (defvar rmail-buffer)
-(declare-function bbdb/mh-header "bbdb-mhe")
-(declare-function mh-show "mh-show")
-(defvar mh-show-buffer)
+ (autoload 'bbdb/mh-header "bbdb-mhe")
+ (autoload 'mh-show "mh-show")
+ (defvar mh-show-buffer)
-(defvar mu4e~view-buffer-name)
+ (defvar mu4e~view-buffer-name)
-(declare-function bbdb/wl-header "bbdb-wl")
+ (autoload 'bbdb/wl-header "bbdb-wl")
-(declare-function message-field-value "message")
-(declare-function mail-decode-encoded-word-string "mail-parse")
+ (autoload 'message-field-value "message")
+ (autoload 'mail-decode-encoded-word-string "mail-parse"))
(defconst bbdb-mua-mode-alist
'((vm vm-mode vm-virtual-mode vm-summary-mode vm-presentation-mode)
diff --git a/lisp/bbdb/bbdb-rmail.el b/lisp/bbdb/bbdb-rmail.el
index 69c92acd721..719617d711d 100644
--- a/lisp/bbdb/bbdb-rmail.el
+++ b/lisp/bbdb/bbdb-rmail.el
@@ -30,19 +30,14 @@
(require 'rmailsum)
(require 'mailheader)
-(defun bbdb/rmail-new-flag ()
- "Returns t if the current message in buffer BUF is new."
- (rmail-message-labels-p rmail-current-message ", ?\\(unseen\\),"))
-
+;;;###autoload
(defun bbdb/rmail-header (header)
"Pull HEADER out of Rmail header."
(with-current-buffer rmail-buffer
- (if (fboundp 'rmail-get-header) ; Emacs 23
- (rmail-get-header header)
- (save-restriction
- (with-no-warnings (rmail-narrow-to-non-pruned-header))
- (mail-header (intern-soft (downcase header))
- (mail-header-extract))))))
+ (save-restriction
+ (with-no-warnings (rmail-narrow-to-non-pruned-header))
+ (mail-header (intern-soft (downcase header))
+ (mail-header-extract)))))
;;;###autoload
(defun bbdb-insinuate-rmail ()
diff --git a/lisp/bbdb/bbdb-site.el b/lisp/bbdb/bbdb-site.el
new file mode 100644
index 00000000000..dcaf0969ba9
--- /dev/null
+++ b/lisp/bbdb/bbdb-site.el
@@ -0,0 +1,46 @@
+;;; bbdb-site.el --- site-specific variables for BBDB -*- lexical-binding: t -*-
+
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
+
+;; This file is part of the Insidious Big Brother Database (aka BBDB),
+
+;; BBDB 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.
+
+;; BBDB 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 BBDB. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(defconst bbdb-version "@PACKAGE_VERSION@" "Version of BBDB.")
+
+(if (< emacs-major-version 24)
+ (error "BBDB %s requires GNU Emacs 24 or later" bbdb-version))
+
+(defcustom bbdb-tex-path
+ (let* ((default "@pkgdatadir@")
+ (dir (cond ((file-accessible-directory-p default)
+ default)
+ (load-file-name
+ (expand-file-name "tex/" (file-name-directory load-file-name)))
+ (t
+ (let ((f (locate-file "tex/bbdb.sty" load-path)))
+ (if f (file-name-directory f)))))))
+ (if dir (list dir)))
+ "List of directories with the BBDB TeX files.
+If this is t assume that these files reside in directories
+that are part of the regular TeX search path."
+ :group 'bbdb-utilities-tex
+ :type '(choice (const :tag "Files in TeX path" t)
+ (repeat (directory :tag "Directory"))))
+
+(provide 'bbdb-site)
+
+;;; bbdb-site.el ends here
diff --git a/lisp/bbdb/bbdb-tex.el b/lisp/bbdb/bbdb-tex.el
index f1984be84bc..fbdf95b2d8e 100644
--- a/lisp/bbdb/bbdb-tex.el
+++ b/lisp/bbdb/bbdb-tex.el
@@ -241,7 +241,15 @@ The remainder are lists LIST that should have one of these forms:
(epilog STRING)
The string STRING is inserted at the end of the buffer."
- :group 'bbdb-utilities-tex)
+ :group 'bbdb-utilities-TeX
+ :type '(repeat (cons (symbol :tag "rule")
+ (repeat
+ (choice (cons :tag "demand" (const demand) sexp)
+ (list :tag "prolog" (const prolog) string)
+ (cons :tag "record" (const record) sexp)
+ (list :tag "separator" (const separator) string)
+ (list :tag "epilog" (const epilog) string)
+ (cons :tag "options" (const options) sexp))))))
(defcustom bbdb-tex-rule-default 'multi-line
"Default rule for BBDB tex.
@@ -289,26 +297,15 @@ The elements EDIT of `bbdb-address-format-list' are ignored."
(defcustom bbdb-tex-address-layout 2
"Address layout according to `bbdb-tex-address-format-list'.
2 is multi-line layout, 3 is one-line layout."
- :group 'bbdb-utilities-tex)
+ :group 'bbdb-utilities-TeX
+ :type '(choice (const :tag "multi-line" 2)
+ (const :tag "one-line" 3)))
(defcustom bbdb-tex-file "~/bbdb.tex"
"Default file name for TeXing BBDB."
:group 'bbdb-utilities-tex
:type 'file)
-(defcustom bbdb-tex-path
- (let ((d (if load-file-name
- (expand-file-name "tex/" (file-name-directory load-file-name))
- (let ((f (locate-file "tex/bbdb.sty" load-path)))
- (if f (file-name-directory f))))))
- (if d (list d)))
- "List of directories with the BBDB TeX files.
-If this is t assume that these files reside in directories
-that are part of the regular TeX search path"
- :group 'bbdb-utilities-tex
- :type '(choice (const :tag "Files in TeX path" t)
- (repeat (directory :tag "Directory"))))
-
;;; Internal variables
(defvar bbdb-tex-rule-last bbdb-tex-rule-default
diff --git a/lisp/bbdb/bbdb-vm.el b/lisp/bbdb/bbdb-vm.el
new file mode 100644
index 00000000000..6fb9156bfa2
--- /dev/null
+++ b/lisp/bbdb/bbdb-vm.el
@@ -0,0 +1,93 @@
+;;; bbdb-vm.el --- BBDB interface to VM -*- lexical-binding: t -*-
+
+;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
+
+;; This file is part of the Insidious Big Brother Database (aka BBDB),
+
+;; BBDB 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.
+
+;; BBDB 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 BBDB. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;; This file contains the BBDB interface to VM.
+;; See the BBDB info manual for documentation.
+
+;;; Code:
+
+(require 'bbdb)
+(require 'bbdb-com)
+(require 'bbdb-mua)
+
+(when t ;Don't require during compilation, since VM might not be installed!
+ (require 'vm-autoloads)
+ (require 'vm-summary)
+ (require 'vm-mime)
+ (require 'vm-vars))
+
+(declare-function vm-get-header-contents "vm-summary"
+ (message header-name-regexp &optional clump-sep))
+(declare-function vm-decode-mime-encoded-words-in-string "vm-mime"
+ (string))
+(declare-function vm-su-interesting-full-name "vm-summary" (m))
+(declare-function vm-su-from "vm-summary" (m))
+(defvar vm-message-pointer) ;In vm-vars
+(defvar vm-mode-map) ;In vm-vars
+
+;;;###autoload
+(defun bbdb/vm-header (header)
+ (save-current-buffer
+ (vm-select-folder-buffer)
+ (vm-get-header-contents (car vm-message-pointer)
+ (concat header ":"))))
+
+;;;###autoload
+(defun bbdb-insinuate-vm ()
+ "Hook BBDB into VM.
+Do not call this in your init file. Use `bbdb-initialize'."
+ (define-key vm-mode-map ":" 'bbdb-mua-display-records)
+ (define-key vm-mode-map "`" 'bbdb-mua-display-sender)
+ (define-key vm-mode-map "'" 'bbdb-mua-display-recipients)
+ (define-key vm-mode-map ";" 'bbdb-mua-edit-field-sender)
+ ;; Do we need keybindings for more commands? Suggestions welcome.
+ ;; (define-key vm-mode-map "'" 'bbdb-mua-edit-field-recipients)
+ (define-key vm-mode-map "/" 'bbdb)
+ ;; `mail-mode-map' is the parent of `vm-mail-mode-map'.
+ ;; So the following is also done by `bbdb-insinuate-mail'.
+ (if (and bbdb-complete-mail (boundp 'vm-mail-mode-map))
+ (define-key vm-mail-mode-map "\M-\t" 'bbdb-complete-mail))
+
+ ;; Set up user field for use in `vm-summary-format'
+ ;; (1) Big solution: use whole name
+ (if bbdb-mua-summary-unify-format-letter
+ (defalias (intern (concat "vm-summary-function-"
+ bbdb-mua-summary-unify-format-letter))
+ (lambda (m) (bbdb-mua-summary-unify
+ ;; VM does not give us the original From header.
+ ;; So we have to work backwards.
+ (let ((name (vm-decode-mime-encoded-words-in-string
+ (vm-su-interesting-full-name m)))
+ (mail (vm-su-from m)))
+ (if (string= name mail) mail
+ (format "\"%s\" <%s>" name mail)))))))
+
+ ;; (2) Small solution: a mark for messages whos sender is in BBDB.
+ (if bbdb-mua-summary-mark-format-letter
+ (defalias (intern (concat "vm-summary-function-"
+ bbdb-mua-summary-mark-format-letter))
+ ;; VM does not give us the original From header.
+ ;; So we assume that the mail address is sufficient to identify
+ ;; the BBDB record of the sender.
+ (lambda (m) (bbdb-mua-summary-mark (vm-su-from m))))))
+
+(provide 'bbdb-vm)
+
+;;; bbdb-vm.el ends here
diff --git a/lisp/bbdb/bbdb-wl.el b/lisp/bbdb/bbdb-wl.el
index e24b8af21ef..0f523d407fc 100644
--- a/lisp/bbdb/bbdb-wl.el
+++ b/lisp/bbdb/bbdb-wl.el
@@ -29,10 +29,12 @@
(defvar wl-summary-mode-map)
(defvar wl-draft-mode-map)
(defvar wl-summary-buffer-elmo-folder)
-(declare-function wl-summary-message-number "wl-summary")
-(declare-function elmo-message-entity "elmo-msgdb")
-(declare-function elmo-message-entity-field "elmo-msgdb")
+(eval-and-compile
+ (autoload 'wl-summary-message-number "wl-summary")
+ (autoload 'elmo-message-entity "elmo-msgdb")
+ (autoload 'elmo-message-entity-field "elmo-msgdb"))
+;;;###autoload
(defun bbdb/wl-header (header)
(elmo-message-entity-field
(elmo-message-entity wl-summary-buffer-elmo-folder
diff --git a/lisp/bbdb/bbdb.el b/lisp/bbdb/bbdb.el
index 2c49e3c32e4..e38ac174ae6 100644
--- a/lisp/bbdb/bbdb.el
+++ b/lisp/bbdb/bbdb.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2010-2017 Free Software Foundation, Inc.
-;; Version: 0
+;; Version: 3.2
;; Package-Requires: ((emacs "24"))
;; This file is part of the Insidious Big Brother Database (aka BBDB),
@@ -37,6 +37,7 @@
;;; Code:
(require 'timezone)
+(require 'bbdb-site)
;; When running BBDB, we have (require 'bbdb-autoloads)
(declare-function widget-group-match "wid-edit")
@@ -4632,17 +4633,19 @@ If NOISY is non-nil as in interactive calls issue status messages."
"Return string describing the version of BBDB.
With prefix ARG, insert string at point."
(interactive (list (or (and current-prefix-arg 1) t)))
- (let* ((source (find-function-noselect 'bbdb-version))
- (version
- (when source
- (with-current-buffer (car source)
- (prog1
- (save-excursion
- (goto-char (point-min))
- (when (re-search-forward "^;;+ *Version: \\(.*\\)" nil t)
- (match-string-no-properties 1)))
- (unless (get-buffer-window nil t)
- (kill-buffer (current-buffer)))))))
+ (let* ((version
+ (if (string-match "\\`[ \t\n]*[1-9]" bbdb-version)
+ bbdb-version
+ (let ((source (find-function-noselect 'bbdb-version)))
+ (if source
+ (with-current-buffer (car source)
+ (prog1 (save-excursion
+ (goto-char (point-min))
+ (when (re-search-forward
+ "^;;+ *Version: \\(.*\\)" nil t)
+ (match-string-no-properties 1)))
+ (unless (get-buffer-window nil t)
+ (kill-buffer (current-buffer)))))))))
(version-string (format "BBDB version %s" (or version "<unknown>"))))
(cond ((numberp arg) (insert (message version-string)))
((eq t arg) (message version-string))