;;; gnorb-bbdb.el --- The BBDB-centric functions of gnorb
-;; Copyright (C) 2014 Eric Abrahamsen
+;; Copyright (C) 2014 Free Software Foundation, Inc.
;; Author: Eric Abrahamsen <eric@ericabrahamsen.net>
;; Keywords:
(require 'bbdb)
(require 'gnorb-utils)
+(require 'cl-lib)
(defgroup gnorb-bbdb nil
"The BBDB bits of gnorb."
:group 'gnorb-bbdb
:type 'symbol)
-(unless (assoc gnorb-bbdb-org-tag-field bbdb-separator-alist)
- (push `(,gnorb-bbdb-org-tag-field ":" ":") bbdb-separator-alist))
+(when (boundp 'bbdb-separator-alist) ;Allow compilation if BBDB is absent!
+ (unless (assoc gnorb-bbdb-org-tag-field bbdb-separator-alist)
+ (push `(,gnorb-bbdb-org-tag-field ":" ":") bbdb-separator-alist)))
(defcustom gnorb-bbdb-messages-field 'messages
"The name (as a symbol) of the field where links to recent gnus
Defaults to org-link."
:group 'gnorb-bbdb)
-(defstruct gnorb-bbdb-link
+(cl-defstruct gnorb-bbdb-link
subject date group id)
(defcustom gnorb-bbdb-posting-styles nil
An example value might look like:"
:group 'gnorb-bbdb)
+(defvar message-mode-hook)
+
(when (fboundp 'bbdb-record-xfield-string)
(fset (intern (format "bbdb-read-xfield-%s"
gnorb-bbdb-org-tag-field))
(mapconcat
'identity
(delete-dups
- (cl-mapcan
- (lambda (r)
- (bbdb-record-xfield-split r gnorb-bbdb-org-tag-field))
- records))
- "|")))
+ (cl-mapcan (lambda (r)
+ (bbdb-record-xfield-split r gnorb-bbdb-org-tag-field))
- records)))
- "|")))
++ records))
++ "|")))
(if tag-string
;; C-u = all headings, not just todos
- (if (equal current-prefix-arg '(4))
- (org-tags-view nil tag-string)
- (org-tags-view t tag-string))
+ (org-tags-view (not (equal current-prefix-arg '(4)))
+ tag-string)
- (error "No org-tags field present")))
+ (error "No org-tags field present"))))
;;;###autoload
(defun gnorb-bbdb-mail-search (records)
gnorb-gnus-mail-search-backends)
(error "No search backend specified")))
(search-string
- (funcall (second backend)
+ (funcall (cl-second backend)
(cl-mapcan 'bbdb-record-mail records))))
(when (equal current-prefix-arg '(4))
(setq search-string
(read-from-minibuffer
- (format "%s search string: " (first backend)) search-string)))
- (funcall (third backend) search-string)
+ (format "%s search string: " (cl-first backend)) search-string)))
+ (funcall (cl-third backend) search-string)
(delete-other-windows)))
;;;###autoload
;;; Field containing links to recent messages
-(add-to-list 'bbdb-xfield-label-list gnorb-bbdb-messages-field nil 'eq)
+(when (boundp 'bbdb-xfield-label-list)
+ (add-to-list 'bbdb-xfield-label-list gnorb-bbdb-messages-field nil 'eq))
(defun gnorb-bbdb-display-messages (record format)
"Show links to the messages collected in the