emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master ea87506: * lisp/url/url-cookie.el: Use lexical-bind


From: Stefan Monnier
Subject: [Emacs-diffs] master ea87506: * lisp/url/url-cookie.el: Use lexical-binding
Date: Thu, 27 Jul 2017 00:13:33 -0400 (EDT)

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

    * lisp/url/url-cookie.el: Use lexical-binding
    
    (url-cookie-host-can-set-p): Remove unused var `last'.
    Use string-suffix-p.
    (url-cookie-list): De morgan.
    (url-cookie-quit): Remove.
    (url-cookie-mode): Inherit from special-mode.
    (url-cookie-mode-map): Simplify accordingly.
---
 lisp/url/url-cookie.el | 41 +++++++++++++++--------------------------
 1 file changed, 15 insertions(+), 26 deletions(-)

diff --git a/lisp/url/url-cookie.el b/lisp/url/url-cookie.el
index 4912db6..0edc93c 100644
--- a/lisp/url/url-cookie.el
+++ b/lisp/url/url-cookie.el
@@ -1,4 +1,4 @@
-;;; url-cookie.el --- URL cookie support
+;;; url-cookie.el --- URL cookie support  -*- lexical-binding:t -*-
 
 ;; Copyright (C) 1996-1999, 2004-2017 Free Software Foundation, Inc.
 
@@ -227,21 +227,17 @@ telling Microsoft that."
   :group 'url-cookie)
 
 (defun url-cookie-host-can-set-p (host domain)
-  (let ((last nil)
-       (case-fold-search t))
-    (cond
-     ((string= host domain)    ; Apparently netscape lets you do this
-      t)
-     ((zerop (length domain))
-      nil)
-     (t
-      ;; Remove the dot from wildcard domains before matching.
-      (when (eq ?. (aref domain 0))
-       (setq domain (substring domain 1)))
-      (and (url-domsuf-cookie-allowed-p domain)
-          ;; Need to check and make sure the host is actually _in_ the
-          ;; domain it wants to set a cookie for though.
-          (string-match (concat (regexp-quote domain) "$") host))))))
+  (cond
+   ((string= host domain)      ; Apparently netscape lets you do this
+    t)
+   ((zerop (length domain))
+    nil)
+   (t
+    ;; Remove the dot from wildcard domains before matching.
+    (when (eq ?. (aref domain 0))
+      (setq domain (substring domain 1)))
+    (and (url-domsuf-cookie-allowed-p domain)
+         (string-suffix-p domain host 'ignore-case)))))
 
 (defun url-cookie-handle-set-cookie (str)
   (setq url-cookies-changed-since-last-save t)
@@ -380,8 +376,8 @@ instead delete all cookies that do not match REGEXP."
   "Display a buffer listing the current URL cookies, if there are any.
 Use \\<url-cookie-mode-map>\\[url-cookie-delete] to remove cookies."
   (interactive)
-  (when (and (null url-cookie-secure-storage)
-            (null url-cookie-storage))
+  (unless (or url-cookie-secure-storage
+              url-cookie-storage)
     (error "No cookies are defined"))
 
   (pop-to-buffer "*url cookies*")
@@ -442,20 +438,13 @@ Use \\<url-cookie-mode-map>\\[url-cookie-delete] to 
remove cookies."
                     (forward-line 1)
                     (point)))))
 
-(defun url-cookie-quit ()
-  "Kill the current buffer."
-  (interactive)
-  (kill-buffer (current-buffer)))
-
 (defvar url-cookie-mode-map
   (let ((map (make-sparse-keymap)))
-    (suppress-keymap map)
-    (define-key map "q" 'url-cookie-quit)
     (define-key map [delete] 'url-cookie-delete)
     (define-key map [(control k)] 'url-cookie-delete)
     map))
 
-(define-derived-mode url-cookie-mode nil "URL Cookie"
+(define-derived-mode url-cookie-mode special-mode "URL Cookie"
   "Mode for listing cookies.
 
 \\{url-cookie-mode-map}"



reply via email to

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