emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/bbdb 5610c9c: * bbdb-com.el, bbdb.el: Fix some warnings


From: Stefan Monnier
Subject: [elpa] externals/bbdb 5610c9c: * bbdb-com.el, bbdb.el: Fix some warnings; plus cosmetic changes
Date: Sun, 10 Mar 2019 00:19:44 -0500 (EST)

branch: externals/bbdb
commit 5610c9c566b8a1dc8fcc01081b36af59f398d691
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * bbdb-com.el, bbdb.el: Fix some warnings; plus cosmetic changes
    
    * bbdb-com.el, bbdb.el: Use #' to quote functions.
    * bbdb-com.el (bbdb-dial): Clarify backslash escaping in regexp.
    (bbdb-mail-aliases): η-reduce.
    (bbdb-mail-aliases): Use abbrev-symbol.
    (bbdb-dial-number): Use bbdb--dial-default.
    
    * bbdb.el: Move variable aliases before their target's definition.
    (bbdb-merge-records-function, bbdb-dial-function):
    (bbdb-canonicalize-mail-function): Use a non-nil default.
    (bbdb--dial-default): New function.
    (bbdb-init-forms): Use functions rather than "forms".
    (bbdb-initialize): Adjust accordingly.
---
 bbdb-com.el |  91 +++++++++++++++++++------------------
 bbdb.el     | 146 ++++++++++++++++++++++++++++++++----------------------------
 2 files changed, 125 insertions(+), 112 deletions(-)

diff --git a/bbdb-com.el b/bbdb-com.el
index 94378f1..d0e9879 100644
--- a/bbdb-com.el
+++ b/bbdb-com.el
@@ -1,6 +1,6 @@
 ;;; bbdb-com.el --- user-level commands of BBDB -*- lexical-binding: t -*-
 
-;; Copyright (C) 2010-2018  Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019  Free Software Foundation, Inc.
 
 ;; This file is part of the Insidious Big Brother Database (aka BBDB),
 
@@ -103,7 +103,7 @@ If FULL is non-nil, the list of records includes display 
information."
         (setq bbdb-do-all-records nil)
         (aset bbdb-modeline-info 4 nil)
         (aset bbdb-modeline-info 5 nil)
-        (if full bbdb-records (mapcar 'car bbdb-records)))
+        (if full bbdb-records (mapcar #'car bbdb-records)))
     (list (bbdb-current-record full))))
 
 ;;;###autoload
@@ -226,7 +226,7 @@ This usage is discouraged."
       (dolist (key '(:all-names :organization :mail :xfield :phone :address))
         (if (setq val (pop spec))
             (push (list key val) newspec)))
-      (setq spec (apply 'append newspec))))
+      (setq spec (apply #'append newspec))))
 
   (let* ((count 0)
          (sym-list (mapcar (lambda (_)
@@ -467,7 +467,7 @@ in either the name(s), organization, address, phone, mail, 
or xfields."
   "Display all BBDB records for which xfield FIELD matches REGEXP."
   (interactive
    (let ((field (completing-read "Xfield to search (RET for all): "
-                                 (mapcar 'list bbdb-xfield-label-list) nil t)))
+                                 (mapcar #'list bbdb-xfield-label-list) nil 
t)))
      (list (if (string= field "") '* (intern field))
            (bbdb-search-read (if (string= field "")
                                    "any xfield"
@@ -475,7 +475,7 @@ in either the name(s), organization, address, phone, mail, 
or xfields."
            (bbdb-layout-prefix))))
   (bbdb-display-records (bbdb-search (bbdb-records) :xfield (cons field 
regexp))
                         layout))
-(define-obsolete-function-alias 'bbdb-search-notes 'bbdb-search-xfields "3.0")
+(define-obsolete-function-alias 'bbdb-search-notes #'bbdb-search-xfields "3.0")
 
 ;;;###autoload
 (defun bbdb-search-changed (&optional layout)
@@ -543,11 +543,11 @@ which is probably more suited for your needs."
         (if (assoc-string mail mails t) ; duplicate mail address
             (push mail redundant)
           (push mail mails)))
-      (let ((mail-re (delq nil (mapcar 'bbdb-mail-redundant-re mails)))
+      (let ((mail-re (delq nil (mapcar #'bbdb-mail-redundant-re mails)))
             (case-fold-search t))
         (if (not (cdr mail-re)) ; at most one mail-re address to consider
             (setq okay (nreverse mails))
-          (setq mail-re (concat "\\`\\(?:" (mapconcat 'identity mail-re "\\|")
+          (setq mail-re (concat "\\`\\(?:" (mapconcat #'identity mail-re "\\|")
                                 "\\)\\'"))
           (dolist (mail mails)
             (if (string-match mail-re mail) ; redundant mail address
@@ -564,7 +564,7 @@ which is probably more suited for your needs."
           (when update
             (bbdb-change-record record)))))))
 (define-obsolete-function-alias 'bbdb-delete-duplicate-mails
-  'bbdb-delete-redundant-mails "3.0")
+  #'bbdb-delete-redundant-mails "3.0")
 
 (defun bbdb-search-duplicates (&optional fields)
   "Search all records that have duplicate entries for FIELDS.
@@ -940,7 +940,7 @@ The following keywords are supported in SPEC:
             (push (list key val) newspec)))
       (if (setq val (pop spec))
           (push (list :check) newspec))
-      (setq spec (apply 'append newspec))))
+      (setq spec (apply #'append newspec))))
 
   (let ((record (bbdb-empty-record))
         (record-type (cdr bbdb-record-type))
@@ -1029,14 +1029,14 @@ A non-nil prefix arg is passed on to `bbdb-read-field' 
as FLAG (see there)."
                         '(affix organization aka phone address mail)))
           (field "")
           (completion-ignore-case t)
-          (present (mapcar 'car (bbdb-record-xfields record))))
+          (present (mapcar #'car (bbdb-record-xfields record))))
      (if (bbdb-record-affix record) (push 'affix present))
      (if (bbdb-record-organization record) (push 'organization present))
      (if (bbdb-record-mail record) (push 'mail present))
      (if (bbdb-record-aka record) (push 'aka present))
      (dolist (field present)
        (setq list (remq field list)))
-     (setq list (mapcar 'symbol-name list))
+     (setq list (mapcar #'symbol-name list))
      (while (string= field "")
        (setq field (downcase (completing-read "Insert Field: " list))))
      (setq field (intern field))
@@ -1242,17 +1242,18 @@ to select the field."
           (field (if (memq tmp '(current-fields all-fields))
                      ;; Do not require match so that we can define new xfields.
                      (intern (completing-read
-                              "Edit field: " (mapcar 'list (if (eq tmp 
'all-fields)
-                                                               (append '(name 
affix organization aka mail phone address uuid creation-date)
-                                                                       
bbdb-xfield-label-list)
-                                                             (append (if 
(bbdb-record-affix record) '(affix))
-                                                                     (if 
(bbdb-record-organization record) '(organization))
-                                                                     (if 
(bbdb-record-aka record) '(aka))
-                                                                     (if 
(bbdb-record-mail record) '(mail))
-                                                                     (if 
(bbdb-record-phone record) '(phone))
-                                                                     (if 
(bbdb-record-address record) '(address))
-                                                                     (mapcar 
'car (bbdb-record-xfields record))
-                                                                     '(name 
uuid creation-date))))))
+                              "Edit field: "
+                              (mapcar #'list (if (eq tmp 'all-fields)
+                                                 (append '(name affix 
organization aka mail phone address uuid creation-date)
+                                                         
bbdb-xfield-label-list)
+                                               (append (if (bbdb-record-affix 
record) '(affix))
+                                                       (if 
(bbdb-record-organization record) '(organization))
+                                                       (if (bbdb-record-aka 
record) '(aka))
+                                                       (if (bbdb-record-mail 
record) '(mail))
+                                                       (if (bbdb-record-phone 
record) '(phone))
+                                                       (if 
(bbdb-record-address record) '(address))
+                                                       (mapcar #'car 
(bbdb-record-xfields record))
+                                                       '(name uuid 
creation-date))))))
                    tmp))
           ;; Multiple phone and address fields may use the same label.
           ;; So we cannot use these labels to uniquely identify
@@ -1445,7 +1446,7 @@ If LABEL is nil, edit the label sub-field of PHONE as 
well."
   ;; two or four elements.  We do not know whether after editing PHONE
   ;; we still have a number requiring the same format as PHONE.
   ;; So we throw away the argument PHONE and return a new vector.
-  (apply 'vector
+  (apply #'vector
          (or label
              (bbdb-read-string "Label: "
                                (and phone (bbdb-phone-label phone))
@@ -1500,7 +1501,7 @@ If any of these terms is not defined at POINT, the 
respective value is nil."
              ;; can be anything.  (xfields are unique within a record.)
              (if (eq 'xfields (car field))
                  (setq val (car val)
-                       fields (mapcar 'car fields)))
+                       fields (mapcar #'car fields)))
              (while (and (not done) (setq elt (pop fields)))
                (if (eq val elt)
                    (setq done t)
@@ -1874,7 +1875,7 @@ in `bbdb-change-hook')."
                        (or (cdr (assq (car b) bbdb-xfields-sort-order)) 
100)))))
     (if update
         (bbdb-change-record record))))
-(define-obsolete-function-alias 'bbdb-sort-notes 'bbdb-sort-xfields "3.0")
+(define-obsolete-function-alias 'bbdb-sort-notes #'bbdb-sort-xfields "3.0")
 
 ;;; Send-Mail interface
 
@@ -1955,7 +1956,7 @@ If MAIL is nil use the first mail address of RECORD."
 Use `bbdb-mail-user-agent' or (if nil) use `mail-user-agent'.
 ARGS are passed to `compose-mail'."
   (let ((mail-user-agent (or bbdb-mail-user-agent mail-user-agent)))
-    (apply 'compose-mail args)))
+    (apply #'compose-mail args)))
 
 ;;;###autoload
 (defun bbdb-mail (records &optional subject n verbose)
@@ -2011,7 +2012,7 @@ to kill ring.  If VERBOSE is non-nil (as in interactive 
calls) be verbose."
                                                        (car mails)))))))))
       (when (and bad verbose)
         (message "No mail addresses for %s."
-                 (mapconcat 'bbdb-record-name (nreverse bad) ", "))
+                 (mapconcat #'bbdb-record-name (nreverse bad) ", "))
         (unless (string= "" good) (sit-for 2)))
       (when (and kill-ring-save (not (string= good "")))
         (kill-new good)
@@ -2060,7 +2061,7 @@ The primary mail of each of the records currently listed 
in the
       (insert (car addresses))
       (when (cdr addresses) (insert ",\n") (indent-relative))
       (setq addresses (cdr addresses)))))
-(define-obsolete-function-alias 'bbdb-yank-addresses 'bbdb-mail-yank "3.0")
+(define-obsolete-function-alias 'bbdb-yank-addresses #'bbdb-mail-yank "3.0")
 
 ;;; completion
 
@@ -2106,7 +2107,7 @@ completion with."
            (let* ((count (length records))
                   (result (completing-read
                            (format "Which record (1-%s): " count)
-                           (mapcar 'number-to-string (number-sequence 1 count))
+                           (mapcar #'number-to-string (number-sequence 1 
count))
                            nil t)))
              (nth (1- (string-to-number result)) records))))))
 
@@ -2223,9 +2224,9 @@ as part of the MUA insinuation."
       ;; Resolve the records matching ORIG:
       ;; Multiple completions may match the same record
       (let ((records (delete-dups
-                      (apply 'append (mapcar (lambda (compl)
-                                               (gethash compl bbdb-hashtable))
-                                             all-completions)))))
+                      (apply #'append (mapcar (lambda (compl)
+                                                (gethash compl bbdb-hashtable))
+                                              all-completions)))))
         ;; Is there only one matching record?
         (setq one-record (and (not (cdr records))
                               (car records))))
@@ -2417,6 +2418,7 @@ as part of the MUA insinuation."
             ;; `completion-list-insert-choice-function'
             ;; before performing our own stuff.
             (completion-list-insert-choice-function
+             ;; FIXME: Use closure instead of backquoted lambda!
              `(lambda (beg end text)
                 ,(if (boundp 'completion-list-insert-choice-function)
                      `(funcall ',completion-list-insert-choice-function
@@ -2433,7 +2435,7 @@ as part of the MUA insinuation."
       done)))
 
 ;;;###autoload
-(define-obsolete-function-alias 'bbdb-complete-name 'bbdb-complete-mail "3.0")
+(define-obsolete-function-alias 'bbdb-complete-name #'bbdb-complete-mail "3.0")
 
 (defun bbdb-complete-mail-cleanup (mail beg)
   "Clean up after inserting MAIL at position BEG.
@@ -2457,6 +2459,8 @@ If we are past `fill-column', wrap at the previous comma."
               ;; FIXME: This pops up *BBDB* before removing *Completions*
               (bbdb-display-records records nil t)))
         ;; `bbdb-complete-mail-hook' may access MAIL, ADDRESS, and RECORDS.
+        ;; FIXME: Now that we use lexical-binding, these vars can't be accessed
+        ;; any more.  Maybe we should just change the doc!?
         (run-hooks 'bbdb-complete-mail-hook))))
 
 ;;; interface to mail-abbrevs.el.
@@ -2516,7 +2520,7 @@ Rebuilding the aliases is enforced if prefix 
FORCE-REBUILT is t."
                 (if (cddr result)
                     ;; for group aliases we just take all the primary mails
                     ;; and define only one expansion!
-                    (list (mapconcat (lambda (record) (bbdb-dwim-mail record))
+                    (list (mapconcat #'bbdb-dwim-mail
                                      (cdr result) mail-alias-separator-string))
                   ;; this is an alias for a single person so deal with it
                   ;; according to `bbdb-mail-alias'
@@ -2556,13 +2560,15 @@ Rebuilding the aliases is enforced if prefix 
FORCE-REBUILT is t."
             (bbdb-pushnew (cons alias expansion) mail-aliases)
 
             (define-mail-abbrev alias expansion)
-            (unless (setq f-alias (intern-soft (downcase alias) mail-abbrevs))
+            
+            (unless (setq f-alias (abbrev-symbol alias mail-abbrevs))
               (error "Cannot find the alias"))
 
             ;; `define-mail-abbrev' initializes f-alias to be
             ;; `mail-abbrev-expand-hook'. We replace this by
             ;; `bbdb-mail-abbrev-expand-hook'
-            (unless (eq (symbol-function f-alias) 'mail-abbrev-expand-hook)
+            ;; FIXME: Use proper accessor instead of `symbol-function'.
+            (unless (eq (symbol-function f-alias) #'mail-abbrev-expand-hook)
               (error "mail-aliases contains unexpected hook %s"
                      (symbol-function f-alias)))
             ;; `bbdb-mail-abbrev-hook' is called with mail addresses instead of
@@ -2582,6 +2588,7 @@ Rebuilding the aliases is enforced if prefix 
FORCE-REBUILT is t."
             ;; EXPANSION to the mail addresses it contains (which is tricky
             ;; because mail addresses in the database can be shortcuts for
             ;; the addresses in EXPANSION).
+            ;; FIXME: Use a closure rather than a backquoted lambda!
             (fset f-alias `(lambda ()
                              (bbdb-mail-abbrev-expand-hook
                               ,alias
@@ -2596,7 +2603,7 @@ Rebuilding the aliases is enforced if prefix 
FORCE-REBUILT is t."
   (when bbdb-completion-display-record
     (let ((bbdb-silent-internal t))
       (bbdb-display-records
-       (apply 'append
+       (apply #'append
               (mapcar (lambda (mail) (bbdb-message-search nil mail)) mails))
        nil t))))
 
@@ -2673,9 +2680,7 @@ one arg RECORD to define the default value for ALIAS of 
RECORD."
 This uses the tel URI syntax passed to `browse-url' to make the call.
 If `bbdb-dial-function' is non-nil then that is called to make the phone call."
   (interactive "sDial number: ")
-  (if bbdb-dial-function
-      (funcall bbdb-dial-function phone-string)
-    (browse-url (concat "tel:" phone-string))))
+  (funcall (or bbdb-dial-function #'bbdb--dial-default) phone-string))
 
 ;;;###autoload
 (defun bbdb-dial (phone force-area-code)
@@ -2700,7 +2705,7 @@ is non-nil.  Do not dial the extension."
     (unless force-area-code
       (let ((alist bbdb-dial-local-prefix-alist) prefix)
         (while (setq prefix (pop alist))
-          (if (string-match (concat "^" (eval (car prefix))) number)
+          (if (string-match (concat "^" (eval (car prefix) t)) number)
               (setq shortnumber (concat (cdr prefix)
                                         (substring number (match-end 0)))
                     alist nil)))))
@@ -2716,7 +2721,7 @@ is non-nil.  Do not dial the extension."
 
       ;; Leading + => long distance/international number
       (if (and bbdb-dial-long-distance-prefix
-               (string-match "^\+" number))
+               (string-match "^\\+" number))
           (setq number (concat bbdb-dial-long-distance-prefix " "
                                (substring number 1)))))
 
@@ -2772,7 +2777,7 @@ Interactively, use BBDB prefix \
             drec))
     (kill-new (replace-regexp-in-string
                "[ \t\n]*\\'" "\n"
-               (mapconcat 'identity (nreverse drec) "")))))
+               (mapconcat #'identity (nreverse drec) "")))))
 
 ;;;###autoload
 (defun bbdb-copy-fields-as-kill (records field &optional num)
diff --git a/bbdb.el b/bbdb.el
index 740667e..f8b16d5 100644
--- a/bbdb.el
+++ b/bbdb.el
@@ -1,6 +1,6 @@
 ;;; bbdb.el --- core of BBDB -*- lexical-binding: t -*-
 
-;; Copyright (C) 2010-2018  Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019  Free Software Foundation, Inc.
 
 ;; Maintainer: Roland Winkler <address@hidden>
 ;; Version: 3.2
@@ -229,10 +229,10 @@ first, followed by a call of this hook."
   :group 'bbdb
   :type 'hook)
 
-(defcustom bbdb-merge-records-function nil
+(defcustom bbdb-merge-records-function #'bbdb-merge-records
   "If non-nil, a function for merging two records.
 This function is called when loading a record into BBDB that has the same uuid
-as an exisiting record.  If nil use `bbdb-merge-records'.
+as an exisiting record.
 This function should take two arguments RECORD1 and RECORD2, with RECORD2
 being the already existing record.  It should merge RECORD1 into RECORD2,
 and return RECORD2."
@@ -1051,7 +1051,7 @@ See also `bbdb-add-mails'."
                  (function :tag "Function for analyzing primary handling")
                  (regexp :tag "If the new mail address matches this regexp put 
it at the end.")))
 
-(defcustom bbdb-canonicalize-mail-function nil
+(defcustom bbdb-canonicalize-mail-function #'bbdb-string-trim
   "If non-nil, it should be a function of one arg: a mail address string.
 When BBDB \"notices\" a message, the corresponding mail addresses are passed
 to this function first.  It acts as a kind of \"filter\" to transform
@@ -1063,6 +1063,8 @@ See also `bbdb-ignore-redundant-mails'."
   :group 'bbdb-mua
   :type 'function)
 
+(define-obsolete-variable-alias 'bbdb-canonicalize-redundant-mails
+  'bbdb-ignore-redundant-mails "3.0")
 (defcustom bbdb-ignore-redundant-mails 'query
   "How to handle redundant mail addresses for existing BBDB records.
 For example, \"address@hidden" is redundant w.r.t. \"address@hidden".
@@ -1088,10 +1090,8 @@ See also `bbdb-add-mails' and 
`bbdb-canonicalize-mail-function'."
                  (number :tag "Number of seconds to display redundant 
addresses")
                  (function :tag "Function for handling redundant mail 
addresses")
                  (regexp :tag "If the new address matches this regexp never 
ignore it.")))
-(define-obsolete-variable-alias 'bbdb-canonicalize-redundant-mails
-  'bbdb-ignore-redundant-mails "3.0")
 
-(defcustom bbdb-message-clean-name-function 'bbdb-message-clean-name-default
+(defcustom bbdb-message-clean-name-function #'bbdb-message-clean-name-default
   "Function to clean up the name in the header of a message.
 It takes one argument, the name as extracted by
 `mail-extract-address-components'."
@@ -1286,6 +1286,7 @@ See also `bbdb-auto-notes-ignore-messages'."
                   (string :tag "Header name")
                   (regexp :tag "Regexp to match on header value"))))
 
+(define-obsolete-variable-alias 'bbdb-message-pop-up 'bbdb-mua-pop-up "3.0")
 (defcustom bbdb-mua-pop-up t
   "If non-nil, display an auto-updated BBDB window while using a MUA.
 If 'horiz, stack the window horizontally if there is room.
@@ -1296,7 +1297,6 @@ See also `bbdb-mua-pop-up-window-size' and 
`bbdb-horiz-pop-up-window-size'."
   :type '(choice (const :tag "MUA BBDB window stacked vertically" t)
                  (const :tag "MUA BBDB window stacked horizontally" horiz)
                  (const :tag "No MUA BBDB window" nil)))
-(define-obsolete-variable-alias 'bbdb-message-pop-up 'bbdb-mua-pop-up "3.0")
 
 (defcustom bbdb-mua-pop-up-window-size bbdb-pop-up-window-size
   "Vertical size of MUA pop-up BBDB window (vertical split).
@@ -1323,6 +1323,7 @@ window width that BBDB will take over."
 
 
 ;;; xfields processing
+(define-obsolete-variable-alias 'bbdb-notes-sort-order 
'bbdb-xfields-sort-order "3.0")
 (defcustom bbdb-xfields-sort-order
   '((notes . 0) (url . 1) (ftp . 2) (gopher . 3) (telnet . 4) (mail-alias . 5)
     (mail-folder . 6) (lpr . 7))
@@ -1334,8 +1335,9 @@ weights more than 100 will be in the end."
   :type '(repeat (cons
                   (symbol :tag "xfield")
                   (number :tag "Weight"))))
-(define-obsolete-variable-alias 'bbdb-notes-sort-order 
'bbdb-xfields-sort-order "3.0")
 
+(define-obsolete-variable-alias 'bbdb-merge-notes-function-alist
+  'bbdb-merge-xfield-function-alist "3.0")
 (defcustom bbdb-merge-xfield-function-alist nil
   "Alist defining merging functions for particular xfields.
 Each element is of the form (LABEL . MERGE-FUN).
@@ -1344,8 +1346,6 @@ For merging xfield LABEL, this will use MERGE-FUN."
   :type '(repeat (cons
                   (symbol :tag "xfield")
                   (function :tag "merge function"))))
-(define-obsolete-variable-alias 'bbdb-merge-notes-function-alist
-  'bbdb-merge-xfield-function-alist "3.0")
 
 (defcustom bbdb-mua-summary-unification-list
   '(name mail message-name message-mail message-address)
@@ -1567,7 +1567,7 @@ when dialling (international dialing prefix.)"
   :type '(choice (const :tag "No digits required" nil)
                  (string :tag "Dial this first" "1")))
 
-(defcustom bbdb-dial-function nil
+(defcustom bbdb-dial-function #'bbdb--dial-default
   "If non-nil this should be a function used for dialing phone numbers.
 This function is used by `bbdb-dial-number'.  It requires one
 argument which is a string for the number that is dialed.
@@ -1576,6 +1576,8 @@ to make the call."
   :group 'bbdb-utilities-dialing
   :type 'function)
 
+(defun bbdb--dial-default (phone-string)
+  (browse-url (concat "tel:" phone-string)))
 
 ;; Faces for font-lock
 (defgroup bbdb-faces nil
@@ -1653,35 +1655,35 @@ You really should not disable debugging.  But it will 
speed things up."))
 See also `bbdb-silent'.")
 
 (defvar bbdb-init-forms
-  '((gnus                       ; gnus 3.15 or newer
-     (add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus))
+  `((gnus                       ; gnus 3.15 or newer
+     ,(lambda () (add-hook 'gnus-startup-hook #'bbdb-insinuate-gnus)))
     (mh-e                       ; MH-E
-     (add-hook 'mh-folder-mode-hook 'bbdb-insinuate-mh))
+     ,(lambda () (add-hook 'mh-folder-mode-hook #'bbdb-insinuate-mh)))
     (rmail                      ; RMAIL
-     (add-hook 'rmail-mode-hook 'bbdb-insinuate-rmail))
+     ,(lambda () (add-hook 'rmail-mode-hook #'bbdb-insinuate-rmail)))
     (vm                        ; newer versions of vm do not have 
`vm-load-hook'
-     (eval-after-load "vm" '(bbdb-insinuate-vm)))
+     ,(lambda () (eval-after-load "vm" '(bbdb-insinuate-vm))))
     (mail                       ; the standard mail user agent
-     (add-hook 'mail-setup-hook 'bbdb-insinuate-mail))
+     ,(lambda () (add-hook 'mail-setup-hook #'bbdb-insinuate-mail)))
     (sendmail
-     (progn (message "BBDB: sendmail insinuation deprecated. Use mail.")
-            (add-hook 'mail-setup-hook 'bbdb-insinuate-mail)))
+     ,(lambda () (message "BBDB: sendmail insinuation deprecated.  Use mail.")
+            (add-hook 'mail-setup-hook #'bbdb-insinuate-mail)))
     (message                    ; the gnus mail user agent
-     (add-hook 'message-setup-hook 'bbdb-insinuate-message))
+     ,(lambda () (add-hook 'message-setup-hook #'bbdb-insinuate-message)))
     (mu4e                       ; the mu4e user agent
-     (add-hook 'mu4e-main-mode-hook 'bbdb-insinuate-mu4e))
+     ,(lambda () (add-hook 'mu4e-main-mode-hook #'bbdb-insinuate-mu4e)))
 
     (sc                         ; supercite
-     (add-hook 'sc-load-hook 'bbdb-insinuate-sc))
+     ,(lambda () (add-hook 'sc-load-hook #'bbdb-insinuate-sc)))
     (anniv                      ; anniversaries
-     (add-hook 'diary-list-entries-hook 'bbdb-anniv-diary-entries))
+     ,(lambda () (add-hook 'diary-list-entries-hook 
#'bbdb-anniv-diary-entries)))
     (pgp                        ; pgp-mail
-     (progn
-       (add-hook 'message-send-hook 'bbdb-pgp)
-       (add-hook 'mail-send-hook 'bbdb-pgp)))
+     ,(lambda ()
+        (add-hook 'message-send-hook #'bbdb-pgp)
+        (add-hook 'mail-send-hook #'bbdb-pgp)))
     (wl
-     (add-hook 'wl-init-hook 'bbdb-insinuate-wl)))
-  "Alist mapping features to insinuation forms.")
+     ,(lambda () (add-hook 'wl-init-hook #'bbdb-insinuate-wl))))
+  "Alist mapping features to insinuation functions.")
 
 (defvar bbdb-search-invert nil
   "Bind this variable to t in order to invert the result of `bbdb-search'.")
@@ -1916,7 +1918,7 @@ This is a child of `special-mode-map'.")
   "Display a message at the bottom of the screen.
 ARGS are passed to `message'."
   (ding t)
-  (apply 'message args))
+  (apply #'message args))
 
 (defun bbdb-string-trim (string &optional null)
   "Remove leading and trailing whitespace and all properties from STRING.
@@ -1965,10 +1967,11 @@ The inverse function of `bbdb-split'."
   (if (symbolp separator)
       (setq separator (nth 1 (or (cdr (assq separator bbdb-separator-alist))
                                  bbdb-default-separator))))
-  (mapconcat 'identity
-             (delete "" (apply 'append (mapcar (lambda (x) (if (stringp x)
-                                                               (list x) x))
-                                               strings))) separator))
+  (mapconcat #'identity
+             (delete "" (apply #'append (mapcar (lambda (x) (if (stringp x)
+                                                                (list x) x))
+                                                strings)))
+             separator))
 
 (defun bbdb-list-strings (list)
   "Remove all elements from LIST which are not non-empty strings."
@@ -1997,6 +2000,7 @@ COLLECTION and REQUIRE-MATCH have the same meaning as in 
`completing-read'."
        ;; Hack: In `minibuffer-local-completion-map' remove
        ;; the binding of SPC to `minibuffer-complete-word'
        ;; and of ? to `minibuffer-completion-help'.
+       ;; FIXME: Explain why we don't want to use the bindings of SPC and ?
        (minibuffer-with-setup-hook
            (lambda ()
              (use-local-map
@@ -2165,14 +2169,11 @@ by `mail-extract-address-components'.
 Pass FULL-NAME through `bbdb-message-clean-name-function'
 and CANONICAL-ADDRESS through `bbdb-canonicalize-mail-function'."
   (list (if (car components)
-            (if bbdb-message-clean-name-function
-                (funcall bbdb-message-clean-name-function (car components))
-              (car components)))
+            (funcall (or bbdb-message-clean-name-function #'identity)
+                     (car components)))
         (if (cadr components)
-            (if bbdb-canonicalize-mail-function
-                (funcall bbdb-canonicalize-mail-function (cadr components))
-              ;; Minimalistic clean-up
-              (bbdb-string-trim (cadr components))))))
+            (funcall (or bbdb-canonicalize-mail-function #'bbdb-string-trim)
+                     (cadr components)))))
 
 (defun bbdb-extract-address-components (address &optional all)
   "Given an RFC-822 address ADDRESS, extract full name and canonical address.
@@ -2180,7 +2181,7 @@ This function behaves like 
`mail-extract-address-components', but it passes
 its return value through `bbdb-clean-address-components'.
 See also `bbdb-decompose-bbdb-address'."
   (if all
-      (mapcar 'bbdb-clean-address-components
+      (mapcar #'bbdb-clean-address-components
               (mail-extract-address-components address t))
     (bbdb-clean-address-components (mail-extract-address-components address))))
 
@@ -2330,6 +2331,7 @@ This strips garbage from the user full NAME string."
 
 ;; BBDB data structure
 (defmacro bbdb-defstruct (name &rest elts)
+  ;; FIXME: Use cl-defstruct instead!
   "Define two functions to operate on vector NAME for each symbol ELT in ELTS.
 The function bbdb-NAME-ELT returns the element ELT in vector NAME.
 The function bbdb-NAME-set-ELT sets ELT.
@@ -2349,7 +2351,8 @@ in vector NAME."
                             uname count selt)
                     ;; Use `elt' instead of `aref' so that these functions
                     ;; also work for the `bbdb-record-type' pseudo-code.
-                    `(elt ,name ,count)) body)
+                    `(elt ,name ,count))
+              body)
         (push (list 'defsubst setname `(,name value)
                     (format "For BBDB %s set element %i `%s' to VALUE.  \
 Return VALUE.
@@ -2358,10 +2361,12 @@ which ensures the integrity of the database.  Also, 
this makes your code
 more robust with respect to possible future changes of BBDB's innermost
 internals."
                             uname count selt)
-                    `(aset ,name ,count value)) body))
+                    `(aset ,name ,count value))
+              body))
       (setq count (1+ count)))
     (push (list 'defconst (intern (concat cname "length")) count
-                (concat "Length of BBDB `" sname "'.")) body)
+                (concat "Length of BBDB `" sname "'."))
+          body)
     (cons 'progn body)))
 
 ;; Define RECORD:
@@ -2519,7 +2524,7 @@ If WARN is non-nil, issue a warning instead of raising an 
error."
                      (if records
                          ;; Be verbose as the duplicates may be AKAs.
                          (let ((msg (format "Name `%s' is already in BBDB: %s"
-                                            name (mapconcat 'bbdb-record-name
+                                            name (mapconcat #'bbdb-record-name
                                                             records ", "))))
                            (if (not warn)
                                (error msg)
@@ -2547,7 +2552,7 @@ If WARN is non-nil, issue a warning instead of raising an 
error."
              (records (if record (remq record tmp) tmp)))
         (if records
             (let ((msg (format "Mail `%s' is already in BBDB: %s" m
-                               (mapconcat 'bbdb-record-name records ", "))))
+                               (mapconcat #'bbdb-record-name records ", "))))
               (if (not warn)
                   (error msg)
                 (message msg)
@@ -2816,7 +2821,7 @@ See also `bbdb-record-set-field'."
         ;; Return xfield FIELD (e.g., `notes') or nil if FIELD is not defined.
         ((symbolp field) (bbdb-record-xfield record field))
         (t (error "Unknown field type `%s'" field))))
-(define-obsolete-function-alias 'bbdb-record-get-field 'bbdb-record-field 
"3.0")
+(define-obsolete-function-alias 'bbdb-record-get-field #'bbdb-record-field 
"3.0")
 
 (defun bbdb-record-set-field (record field value &optional merge check)
   "For RECORD set FIELD to VALUE.  Return VALUE.
@@ -3176,7 +3181,7 @@ copy it to `bbdb-file'."
     (unless (assq 'bbdb-records (buffer-local-variables))
       ;; We are reading / reverting `bbdb-buffer'.
       (set (make-local-variable 'revert-buffer-function)
-           'bbdb-revert-buffer)
+           #'bbdb-revert-buffer)
 
       (setq buffer-file-coding-system bbdb-file-coding-system
             buffer-read-only bbdb-read-only
@@ -3186,10 +3191,10 @@ copy it to `bbdb-file'."
       ;; `bbdb-before-save-hook' and `bbdb-after-save-hook' are user variables.
       ;; To avoid confusion, we hide the hook functions `bbdb-before-save'
       ;; and `bbdb-after-save' from the user as these are essential for BBDB.
-      (dolist (hook (cons 'bbdb-before-save bbdb-before-save-hook))
-        (add-hook 'before-save-hook hook nil t))
-      (dolist (hook (cons 'bbdb-after-save bbdb-after-save-hook))
-        (add-hook 'after-save-hook hook nil t))
+      (dolist (fun (cons #'bbdb-before-save bbdb-before-save-hook))
+        (add-hook 'before-save-hook fun nil t))
+      (dolist (fun (cons #'bbdb-after-save bbdb-after-save-hook))
+        (add-hook 'after-save-hook fun nil t))
 
       (clrhash bbdb-hashtable)
       (clrhash bbdb-uuid-table)
@@ -3567,9 +3572,8 @@ They are present only for backward compatibility."
       (let ((old-record (gethash (bbdb-record-uuid record) bbdb-uuid-table)))
         (if old-record
             ;; RECORD is really OLD-RECORD.  Merge and return OLD-RECORD.
-            (if bbdb-merge-records-function
-                (funcall bbdb-merge-records-function record old-record)
-              (bbdb-merge-records record old-record))
+            (funcall (or bbdb-merge-records-function #'bbdb-merge-records)
+                     record old-record)
 
           ;; RECORD is really new.
           (bbdb-record-set-timestamp
@@ -3726,7 +3730,7 @@ This function is a possible formatting function for
   (let ((country (bbdb-address-country address))
         (streets (bbdb-address-streets address)))
     (concat (if streets
-                (concat (mapconcat 'identity streets "\n") "\n"))
+                (concat (mapconcat #'identity streets "\n") "\n"))
             (bbdb-concat ", " (bbdb-address-city address)
                          (bbdb-concat " " (bbdb-address-state address)
                                       (bbdb-address-postcode address)))
@@ -4068,7 +4072,7 @@ Move point to the end of the inserted record."
         (omit-list  (bbdb-layout-get-option layout 'omit)) ; omitted fields
         (order-list (bbdb-layout-get-option layout 'order)); requested field 
order
         (all-fields (append '(phone address mail aka) ; default field order
-                            (mapcar 'car (bbdb-record-xfields record))
+                            (mapcar #'car (bbdb-record-xfields record))
                             '(uuid creation-date timestamp)))
         (beg (point))
         format-function field-list)
@@ -4148,7 +4152,7 @@ SELECT and HORIZ-P have the same meaning as in 
`bbdb-pop-up-window'."
       ;; If we are appending RECORDS to the ones already displayed,
       ;; then first remove any duplicates, and then sort them.
       (if append
-          (let ((old-rec (mapcar 'car bbdb-records)))
+          (let ((old-rec (mapcar #'car bbdb-records)))
             (dolist (record records)
               (unless (memq (car record) old-rec)
                 (push record bbdb-records)))
@@ -4264,14 +4268,14 @@ If DELETE-P is non-nil RECORD is removed from the BBDB 
buffers."
   (dolist (buffer (buffer-list))
     (with-current-buffer buffer
       (if (and (eq major-mode 'bbdb-mode)
-               (memq record (mapcar 'car bbdb-records)))
+               (memq record (mapcar #'car bbdb-records)))
           (let ((window (get-buffer-window bbdb-buffer-name)))
             (if window
                 (with-selected-window window
                   (bbdb-redisplay-record record sort delete-p))
               (bbdb-redisplay-record record sort delete-p)))))))
 (define-obsolete-function-alias 'bbdb-maybe-update-display
-  'bbdb-redisplay-record-globally "3.0")
+  #'bbdb-redisplay-record-globally "3.0")
 
 
 ;;; window configuration hackery
@@ -4450,7 +4454,8 @@ There are numerous hooks.  M-x apropos ^bbdb.*hook RET
         (list 24 (buffer-name) "  "
               '(:eval (format "%d/%d/%d"
                               (1+ (or (get-text-property
-                                       (point) 'bbdb-record-number) -1))
+                                       (point) 'bbdb-record-number)
+                                      -1))
                               (length bbdb-records)
                               ;; This code gets called a lot.
                               ;; So we keep it as simple as possible.
@@ -4469,8 +4474,9 @@ There are numerous hooks.  M-x apropos ^bbdb.*hook RET
   ;; `bbdb-revert-buffer' acts on `bbdb-buffer'.  Yet this command is usually
   ;; called from the *BBDB* buffer.
   (set (make-local-variable 'revert-buffer-function)
-       'bbdb-revert-buffer)
-  (add-hook 'post-command-hook 'force-mode-line-update nil t))
+       #'bbdb-revert-buffer)
+  ;; FIXME: Really?  Why?
+  (add-hook 'post-command-hook #'force-mode-line-update nil t))
 
 
 
@@ -4745,11 +4751,13 @@ See also `bbdb-mua-auto-update-init'.  The latter is a 
separate function
 as this allows one to initialize the auto update feature for some MUAs only,
 for example only for outgoing messages."
   (dolist (mua muas)
-    (let ((init (assq mua bbdb-init-forms)))
-      (if init
-          ;; Should we make sure that each insinuation happens only once?
-          (eval (cadr init))
-        (bbdb-warn "Do not know how to insinuate `%s'" mua))))
+    (let ((init (cadr (assq mua bbdb-init-forms))))
+      ;; Should we make sure that each insinuation happens only once?
+      (cond
+       ((functionp init) (funcall init))
+       (init (eval init t))             ;Old-style "form".
+       (t
+        (bbdb-warn "Do not know how to insinuate `%s'" mua)))))
   (run-hooks 'bbdb-initialize-hook))
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]