emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 1813913: Remove final uses of 'cl' in lisp/net


From: Stefan Monnier
Subject: [Emacs-diffs] master 1813913: Remove final uses of 'cl' in lisp/net
Date: Tue, 23 Jan 2018 14:42:51 -0500 (EST)

branch: master
commit 18139139c90574ddc8dcb4d91ffbc48a536c1fe1
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    Remove final uses of 'cl' in lisp/net
    
    * lisp/net/pop3.el: Use lexical-binding and cl-lib.
    (pop3-write-to-file): Remove unused var 'start'.
    (pop3-make-date): Remove unused var 'sign'.
    
    * lisp/net/rfc2104.el: Use lexical-binding and cl-lib.
    
    * lisp/net/shr-color.el: Use lexical-binding and cl-lib.
    
    * lisp/net/sieve-manage.el: Use lexical-binding and cl-lib.
---
 lisp/net/pop3.el         | 26 +++++++++++---------------
 lisp/net/rfc2104.el      | 10 +++++-----
 lisp/net/shr-color.el    | 11 +++++------
 lisp/net/sieve-manage.el | 38 +++++++++++++++++++-------------------
 4 files changed, 40 insertions(+), 45 deletions(-)

diff --git a/lisp/net/pop3.el b/lisp/net/pop3.el
index c2385f7..2a6807e 100644
--- a/lisp/net/pop3.el
+++ b/lisp/net/pop3.el
@@ -1,4 +1,4 @@
-;;; pop3.el --- Post Office Protocol (RFC 1460) interface
+;;; pop3.el --- Post Office Protocol (RFC 1460) interface  -*- 
lexical-binding:t -*-
 
 ;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
 
@@ -32,7 +32,7 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
 
 (require 'mail-utils)
 (defvar parse-time-months)
@@ -237,8 +237,8 @@ Use streaming commands."
        (setq start-point
              (pop3-wait-for-messages process pop3-stream-length
                                      total-size start-point))
-       (incf waited-for pop3-stream-length))
-      (incf i))
+       (cl-incf waited-for pop3-stream-length))
+      (cl-incf i))
     (pop3-wait-for-messages process (- count waited-for)
                            total-size start-point)))
 
@@ -249,7 +249,7 @@ Use streaming commands."
                    (or (not total-size)
                        (re-search-forward "^\\.\r?\n" nil t)))
               (re-search-forward "^-ERR " nil t))
-      (decf count)
+      (cl-decf count)
       (setq start-point (point)))
     (unless (memq (process-status process) '(open run))
       (error "pop3 process died"))
@@ -269,7 +269,6 @@ Use streaming commands."
 
 (defun pop3-write-to-file (file messages)
   (let ((pop-buffer (current-buffer))
-       (start (point-min))
        beg end
        temp-buffer)
     (with-temp-buffer
@@ -280,7 +279,6 @@ Use streaming commands."
          (forward-line 1)
          (setq beg (point))
          (when (re-search-forward "^\\.\r?\n" nil t)
-           (setq start (point))
            (forward-line -1)
            (setq end (point)))
          (with-current-buffer temp-buffer
@@ -369,7 +367,7 @@ Use streaming commands."
                (while (> i 0)
                  (unless (member (nth (1- i) pop3-uidl) saved)
                    (push i messages))
-                 (decf i)))
+                 (cl-decf i)))
              (when messages
                (setq list (pop3-list process)
                      size 0)
@@ -399,7 +397,7 @@ Return non-nil if it is necessary to update the local UIDL 
file."
             (unless (member (setq uidl (nth i pop3-uidl)) (cdr saved))
               (push ctime new)
               (push uidl new))
-            (decf i)))
+            (cl-decf i)))
          (pop3-uidl
           (setq new (mapcan (lambda (elt) (list elt ctime)) pop3-uidl))))
     (when new (setq mod t))
@@ -424,7 +422,7 @@ Return non-nil if it is necessary to update the local UIDL 
file."
              (push uidl new)))
        ;; Mails having been deleted in the server.
        (setq mod t))
-      (decf i 2))
+      (cl-decf i 2))
     (cond (saved
           (setcdr saved new))
          (srvr
@@ -440,7 +438,7 @@ Return non-nil if it is necessary to update the local UIDL 
file."
       (while (> i 0)
        (when (member (nth (1- i) pop3-uidl) dele)
          (push i uidl))
-       (decf i))
+       (cl-decf i))
       (when uidl
        (pop3-send-streaming-command process "DELE" uidl nil)))
     mod))
@@ -620,10 +618,8 @@ Return the response string if optional second argument is 
non-nil."
 If NOW, use that time instead."
   (require 'parse-time)
   (let* ((now (or now (current-time)))
-        (zone (nth 8 (decode-time now)))
-        (sign "+"))
+        (zone (nth 8 (decode-time now))))
     (when (< zone 0)
-      (setq sign "-")
       (setq zone (- zone)))
     (concat
      (format-time-string "%d" now)
@@ -785,7 +781,7 @@ Otherwise, return the size of the message-id MSG"
   (pop3-send-command process (format "DELE %s" msg))
   (pop3-read-response process))
 
-(defun pop3-noop (process msg)
+(defun pop3-noop (process _msg)
   "No-operation."
   (pop3-send-command process "NOOP")
   (pop3-read-response process))
diff --git a/lisp/net/rfc2104.el b/lisp/net/rfc2104.el
index d974ab6..57bca2e 100644
--- a/lisp/net/rfc2104.el
+++ b/lisp/net/rfc2104.el
@@ -1,4 +1,4 @@
-;;; rfc2104.el --- RFC2104 Hashed Message Authentication Codes
+;;; rfc2104.el --- RFC2104 Hashed Message Authentication Codes  -*- 
lexical-binding:t -*-
 
 ;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
 
@@ -55,7 +55,7 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
 
 ;; Magic character for inner HMAC round. 0x36 == 54 == '6'
 (defconst rfc2104-ipad ?\x36)
@@ -101,7 +101,7 @@ In XEmacs return just STRING."
         (opad (make-string (+ block-length hash-length) rfc2104-opad))
          c partial)
     ;; Prefix *pad with key, appropriately XORed.
-    (do ((i 0 (1+ i)))
+    (cl-do ((i 0 (1+ i)))
         ((= len i))
       (setq c (aref key i))
       (aset ipad i (logxor rfc2104-ipad c))
@@ -110,8 +110,8 @@ In XEmacs return just STRING."
     (setq partial (rfc2104-string-make-unibyte
                   (funcall hash (concat ipad text))))
     ;; Pack latter part of opad.
-    (do ((r 0 (+ 2 r))
-         (w block-length (1+ w)))
+    (cl-do ((r 0 (+ 2 r))
+            (w block-length (1+ w)))
         ((= (* 2 hash-length) r))
       (aset opad w
             (+ (* 16 (aref rfc2104-nybbles (aref partial     r)))
diff --git a/lisp/net/shr-color.el b/lisp/net/shr-color.el
index 60d44b3..31f3d46 100644
--- a/lisp/net/shr-color.el
+++ b/lisp/net/shr-color.el
@@ -1,4 +1,4 @@
-;;; shr-color.el --- Simple HTML Renderer color management
+;;; shr-color.el --- Simple HTML Renderer color management  -*- 
lexical-binding:t -*-
 
 ;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
 
@@ -27,7 +27,7 @@
 ;;; Code:
 
 (require 'color)
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
 
 (defgroup shr-color nil
   "Simple HTML Renderer colors"
@@ -209,8 +209,8 @@ This will convert \"80 %\" to 204, \"100 %\" to 255 but 
\"123\" to \"123\"."
 
 (defun shr-color-hue-to-rgb (x y h)
   "Convert X Y H to RGB value."
-  (when (< h 0) (incf h))
-  (when (> h 1) (decf h))
+  (when (< h 0) (cl-incf h))
+  (when (> h 1) (cl-decf h))
   (cond ((< h (/ 6.0)) (+ x (* (- y x) h 6)))
         ((< h 0.5) y)
         ((< h (/ 2.0 3.0)) (+ x (* (- y x) (- (/ 2.0 3.0) h) 6)))
@@ -258,8 +258,7 @@ Like rgb() or hsl()."
       (let ((h (/ (string-to-number (match-string-no-properties 1 color)) 
360.0))
             (s (/ (string-to-number (match-string-no-properties 2 color)) 
100.0))
             (l (/ (string-to-number (match-string-no-properties 3 color)) 
100.0)))
-        (destructuring-bind (r g b)
-            (shr-color-hsl-to-rgb-fractions h s l)
+        (pcase-let ((`(,r ,g ,b) (shr-color-hsl-to-rgb-fractions h s l)))
           (color-rgb-to-hex r g b 2))))
      ;; Color names
      ((cdr (assoc-string color shr-color-html-colors-alist t)))
diff --git a/lisp/net/sieve-manage.el b/lisp/net/sieve-manage.el
index e6a1e84..cd40307 100644
--- a/lisp/net/sieve-manage.el
+++ b/lisp/net/sieve-manage.el
@@ -1,4 +1,4 @@
-;;; sieve-manage.el --- Implementation of the managesieve protocol in elisp
+;;; sieve-manage.el --- Implementation of the managesieve protocol in elisp  
-*- lexical-binding:t -*-
 
 ;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
 
@@ -75,7 +75,7 @@
     (require 'password-cache)
   (require 'password))
 
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
 (require 'sasl)
 (require 'starttls)
 (autoload 'sasl-find-mechanism "sasl")
@@ -182,7 +182,7 @@ Valid states are `closed', `initial', `nonauth', and 
`auth'.")
       (generate-new-buffer (format " *sieve %s:%s*"
                                    sieve-manage-server
                                    sieve-manage-port))
-    (mapc 'make-local-variable sieve-manage-local-variables)
+    (mapc #'make-local-variable sieve-manage-local-variables)
     (mm-enable-multibyte)
     (buffer-disable-undo)
     (current-buffer)))
@@ -206,19 +206,19 @@ Return the buffer associated with the connection."
   (with-current-buffer buffer
     (sieve-manage-erase)
     (setq sieve-manage-state 'initial)
-    (destructuring-bind (proc . props)
-        (open-network-stream
-         "SIEVE" buffer server port
-         :type stream
-         :capability-command "CAPABILITY\r\n"
-         :end-of-command "^\\(OK\\|NO\\).*\n"
-         :success "^OK.*\n"
-         :return-list t
-         :starttls-function
-         (lambda (capabilities)
-          (when (and (not sieve-manage-ignore-starttls)
-                     (string-match "\\bSTARTTLS\\b" capabilities))
-            "STARTTLS\r\n")))
+    (pcase-let ((`(,proc . ,props)
+                 (open-network-stream
+                  "SIEVE" buffer server port
+                  :type stream
+                  :capability-command "CAPABILITY\r\n"
+                  :end-of-command "^\\(OK\\|NO\\).*\n"
+                  :success "^OK.*\n"
+                  :return-list t
+                  :starttls-function
+                  (lambda (capabilities)
+                   (when (and (not sieve-manage-ignore-starttls)
+                              (string-match "\\bSTARTTLS\\b" capabilities))
+                     "STARTTLS\r\n")))))
       (setq sieve-manage-process proc)
       (setq sieve-manage-capability
             (sieve-manage-parse-capability (plist-get props :capabilities)))
@@ -250,7 +250,7 @@ Return the buffer associated with the connection."
             ;; somehow.
             `(lambda (prompt) ,(copy-sequence user-password)))
            (step (sasl-next-step client nil))
-           (tag (sieve-manage-send
+           (_tag (sieve-manage-send
                  (concat
                   "AUTHENTICATE \""
                   mech
@@ -373,11 +373,11 @@ to work in."
       ;; Choose authenticator
       (when (and (null sieve-manage-auth)
                  (not (eq sieve-manage-state 'auth)))
-        (dolist (auth sieve-manage-authenticators)
+        (cl-dolist (auth sieve-manage-authenticators)
           (when (funcall (nth 1 (assq auth sieve-manage-authenticator-alist))
                        buffer)
             (setq sieve-manage-auth auth)
-            (return)))
+            (cl-return)))
         (unless sieve-manage-auth
           (error "Couldn't figure out authenticator for server")))
       (sieve-manage-erase)



reply via email to

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