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

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

[elpa] externals/ebdb 894643d 4/6: Don't use either variant of when-let


From: Eric Abrahamsen
Subject: [elpa] externals/ebdb 894643d 4/6: Don't use either variant of when-let and if-let
Date: Sun, 8 Oct 2017 17:54:11 -0400 (EDT)

branch: externals/ebdb
commit 894643d3fcfb1bd8859f71d8ede1491f2adef6fc
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    Don't use either variant of when-let and if-let
    
    Fixes #54
    
    * ebdb.el:
    * ebdb-wl.el:
    * ebdb-vcard.el:
    * ebdb-snarf.el:
    * ebdb-pgp.el:
    * ebdb-mua.el: The unstarred variants cause obsolesence warnings, the
      starred versions only exist in Emacs 26.
---
 ebdb-mua.el   |  5 +++--
 ebdb-pgp.el   | 10 ++++++----
 ebdb-snarf.el | 63 ++++++++++++++++++++++++++++++-----------------------------
 ebdb-vcard.el |  5 +++--
 ebdb-wl.el    |  5 +++--
 ebdb.el       | 63 +++++++++++++++++++++++++++++++----------------------------
 6 files changed, 80 insertions(+), 71 deletions(-)

diff --git a/ebdb-mua.el b/ebdb-mua.el
index b08d9e7..f84c3ee 100644
--- a/ebdb-mua.el
+++ b/ebdb-mua.el
@@ -1215,12 +1215,13 @@ buffer."
                                  (with-current-buffer b
                                    (derived-mode-p 'ebdb-mode)))
                                (buffer-list))))))
+        mail
         (addresses
          (with-current-buffer buffer
             (delq nil
                   (mapcar (lambda (x)
-                            (when-let* ((mail (car (ebdb-record-mail (car x) 
t))))
-                              (ebdb-dwim-mail (car x) mail)))
+                           (when (setq mail (car (ebdb-record-mail (car x) t)))
+                             (ebdb-dwim-mail (car x) mail)))
                           ebdb-records)))))
     (if (derived-mode-p 'message-mode 'mail-mode)
        (when addresses
diff --git a/ebdb-pgp.el b/ebdb-pgp.el
index 1ebf85e..0dc7fa3 100644
--- a/ebdb-pgp.el
+++ b/ebdb-pgp.el
@@ -169,13 +169,15 @@ use one of the following, as appropriate:
       (when mail-aliases
         ;; (sendmail-sync-aliases) ; needed?
         (expand-mail-aliases (point-min) (point-max)))
-      (let ((actions
-             (or (delq nil
+      (let* (field
+            (actions
+              (or (delq nil
                        (delete-dups
                         (mapcar
                          (lambda (record)
-                           (if-let* ((field (car-safe (ebdb-record-field
-                           record 'ebdb-field-pgp))))
+                           (when (setq
+                                   field (car-safe (ebdb-record-field
+                                                    record 'ebdb-field-pgp)))
                               (slot-value field 'action)))
                          (delete-dups
                           (apply 'nconc
diff --git a/ebdb-snarf.el b/ebdb-snarf.el
index 45b5304..d307f23 100644
--- a/ebdb-snarf.el
+++ b/ebdb-snarf.el
@@ -251,19 +251,19 @@ existing records that match information in the bundle.  
Discard
 redundant fields, or fields that are incompatible with the record
 they're grouped with.  Return the same list of (possibly altered)
 vectors, usually to `ebdb-snarf-query'."
-  (let (output)
+  (let (output rec slot-val)
     (pcase-dolist (`[,record ,names ,fields] input)
       (let (out-fields out-names)
        (unless record
-         (if-let* ((rec (car-safe
-                         (ebdb-search
-                          (ebdb-records)
-                          (mapcar
-                           (lambda (f)
-                             (list (eieio-object-class-name f)
-                                   (ebdb-string f)))
-                           (append fields names))))))
-             (setq record rec)))
+         (when (setq rec (car-safe
+                          (ebdb-search
+                           (ebdb-records)
+                           (mapcar
+                            (lambda (f)
+                              (list (eieio-object-class-name f)
+                                    (ebdb-string f)))
+                            (append fields names)))))
+           (setq record rec)))
        (if record
            (let (slot)
              (dolist (f fields)
@@ -274,13 +274,14 @@ vectors, usually to `ebdb-snarf-query'."
                                       `(nil . ,(eieio-object-class f)))))
                      ;; Make sure that record can accept field, and doesn't
                      ;; already have it.
-                     (unless (if-let* ((slot-val (ignore-errors
-                                                   (ebdb-record-field record 
slot))))
-                                 (member (ebdb-string f)
-                                         (mapcar #'ebdb-string
-                                                 (if (listp slot-val)
-                                                     slot-val
-                                                   (list slot-val)))))
+                     (unless
+                         (when (setq slot-val (ignore-errors
+                                                (ebdb-record-field record 
slot)))
+                           (member (ebdb-string f)
+                                   (mapcar #'ebdb-string
+                                           (if (listp slot-val)
+                                               slot-val
+                                             (list slot-val)))))
                        (push f out-fields)))
                  (ebdb-unacceptable-field nil)))
              (dolist (name names)
@@ -298,7 +299,7 @@ vectors, usually to `ebdb-snarf-query'."
 
 Ask about field instances that we haven't been able to handle
 automatically."
-  (let (leftovers records)
+  (let (leftovers records record)
     (pcase-dolist (`[,record ,names ,fields] input)
       (unless record
        ;; There's no record, query-create a new one.
@@ -368,19 +369,19 @@ automatically."
        (push record records)))
     ;; Handle fields in LEFTOVERS.
     (dolist (f (delete-dups leftovers))
-      (when-let* ((record
-                  (cond ((yes-or-no-p
-                          (format "Add %s to existing record? "
-                                  (ebdb-string f)))
-                         (ebdb-prompt-for-record))
-                        ((yes-or-no-p
-                          (format "Add %s to new record? "
-                                  (ebdb-string f)))
-                         (ebdb-init-record
-                          (ebdb-db-add-record
-                           (car ebdb-db-list)
-                           (ebdb-read ebdb-default-record-class))))
-                        (t nil))))
+      (when (setq record
+                 (cond ((yes-or-no-p
+                         (format "Add %s to existing record? "
+                                 (ebdb-string f)))
+                        (ebdb-prompt-for-record))
+                       ((yes-or-no-p
+                         (format "Add %s to new record? "
+                                 (ebdb-string f)))
+                        (ebdb-init-record
+                         (ebdb-db-add-record
+                          (car ebdb-db-list)
+                          (ebdb-read ebdb-default-record-class))))
+                       (t nil)))
        (condition-case nil
            (progn
              (ebdb-record-insert-field record f)
diff --git a/ebdb-vcard.el b/ebdb-vcard.el
index 9d12e76..da99ef5 100644
--- a/ebdb-vcard.el
+++ b/ebdb-vcard.el
@@ -342,8 +342,9 @@ method is just responsible for formatting the record name."
                                    (field ebdb-field-labeled)
                                    _style
                                    _record)
-  (let ((ret (cl-call-next-method)))
-    (if-let* ((lab (slot-value field 'object-name)))
+  (let ((ret (cl-call-next-method))
+       (lab (slot-value field 'object-name)))
+    (if lab
        (concat ret
                ";TYPE=" (ebdb-vcard-escape lab))
       ret)))
diff --git a/ebdb-wl.el b/ebdb-wl.el
index 1bd55f6..c718af5 100644
--- a/ebdb-wl.el
+++ b/ebdb-wl.el
@@ -111,8 +111,9 @@ beginning) of the signature separator."
   ;; This runs in a hook, which are run in no buffer: we need to be in
   ;; a WL buffer in order to get back the correct EBDB buffer name.
   (with-current-buffer wl-folder-buffer-name
-    (when-let* ((win (get-buffer-window (ebdb-make-buffer-name))))
-      (quit-window nil win))))
+    (let ((win (get-buffer-window (ebdb-make-buffer-name))))
+      (when win
+       (quit-window nil win)))))
 
 (defun ebdb-insinuate-wl ()
   "Hook EBDB into Wanderlust."
diff --git a/ebdb.el b/ebdb.el
index 587a4f0..91730a9 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -324,8 +324,9 @@ anniversary date, and the sexp (as a string):
 (defun ebdb-diary-add-entries ()
   "Add anniversaries from EBDB to the diary."
   (pcase-dolist (`(,entry ,sexp) ebdb-diary-entries)
-    (when-let* ((parsed (cdr-safe (diary-sexp-entry sexp entry 
original-date))))
-      (diary-add-to-list original-date parsed sexp))))
+    (let ((parsed (cdr-safe (diary-sexp-entry sexp entry original-date))))
+      (when parsed
+       (diary-add-to-list original-date parsed sexp)))))
 
 (defcustom ebdb-before-load-hook nil
   "Hook run before loading databases."
@@ -2528,8 +2529,9 @@ subclasses, or it can be a string, in which case the 
class of
 RECORD is responsible for parsing it correctly.")
 
 (cl-defmethod ebdb-record-uuid ((record ebdb-record))
-  (if-let* ((uuid-field (slot-value record 'uuid)))
-      (slot-value uuid-field 'uuid)))
+  (let ((uuid-field (slot-value record 'uuid)))
+    (when uuid-field
+     (slot-value uuid-field 'uuid))))
 
 (cl-defmethod ebdb-read ((class (subclass ebdb-record)) &optional slots)
   "Create a new record from the values collected into SLOTS."
@@ -4253,25 +4255,25 @@ for a number.
 The number is returned as a properly-formatted string, with
 leading \"+\"."
 
-  (if-let* ((all-phones (slot-value record 'phone))
-           (phone
-            (car-safe
-             (or (object-assoc "signal" 'object-name all-phones)
-                 (seq-filter
-                  (lambda (p)
-                    (member (slot-value p 'object-name)
-                            '("cell" "mobile")))
-                  all-phones))))
-           (number
-            (and phone
-                 (with-slots (country-code area-code number) phone
-                   (concat (format "+%d" country-code)
-                           (and area-code
-                                (number-to-string area-code))
-                           number)))))
-      number
-    (and (null no-prompt)
-        (ebdb-read-string "Use phone number: "))))
+  (let* ((all-phones (slot-value record 'phone))
+        (phone
+         (car-safe
+          (or (object-assoc "signal" 'object-name all-phones)
+              (seq-filter
+               (lambda (p)
+                 (member (slot-value p 'object-name)
+                         '("cell" "mobile")))
+               all-phones))))
+        (number
+         (and phone
+              (with-slots (country-code area-code number) phone
+                (concat (format "+%d" country-code)
+                        (and area-code
+                             (number-to-string area-code))
+                        number)))))
+    (or number
+       (and (null no-prompt)
+            (ebdb-read-string "Use phone number: ")))))
 
 (cl-defmethod ebdb-field-phone-signal-text ((_record ebdb-record-entity)
                                            (phone-field ebdb-field-phone))
@@ -4928,12 +4930,12 @@ actual speedup."
                     current-prefix-arg))
   (let ((recs (if (listp records) records (list records)))
        (style (if arg 'list 'inline))
-       usable str)
+       usable str m)
     (dolist (r recs)
-      (if-let* ((m (ebdb-record-mail r t)))
-         (push (cons r (or (object-assoc 'primary 'priority m)
-                           (car m)))
-               usable)))
+      (when (setq m (ebdb-record-mail r t))
+       (push (cons r (or (object-assoc 'primary 'priority m)
+                         (car m)))
+             usable)))
     (setq str (ebdb-records-cite style usable))
     (if kill
        (progn
@@ -5287,8 +5289,9 @@ values, by default the search is not handed to the name 
field itself."
 (cl-defmethod ebdb-record-search ((record ebdb-record)
                                  (_type (subclass ebdb-field-notes))
                                  (regexp string))
-  (if-let* ((notes (slot-value record 'notes)))
-      (ebdb-field-search notes regexp)))
+  (let ((notes (slot-value record 'notes)))
+    (when notes
+      (ebdb-field-search notes regexp))))
 
 (cl-defmethod ebdb-record-search ((record ebdb-record-entity)
                                  (_type (subclass ebdb-field-phone))



reply via email to

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