diff options
| author | Stefan Monnier | 2017-07-27 00:13:27 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2017-07-27 00:13:27 -0400 |
| commit | ea875060882a0de5c35574eb815dc45290cd2135 (patch) | |
| tree | 2d3b492e31283bca6f206f2d9393ed966fb5aee7 | |
| parent | 27badfeaa789a4e99f94253d894dde18dafa0798 (diff) | |
| download | emacs-ea875060882a0de5c35574eb815dc45290cd2135.tar.gz emacs-ea875060882a0de5c35574eb815dc45290cd2135.zip | |
* 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.
| -rw-r--r-- | lisp/url/url-cookie.el | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/lisp/url/url-cookie.el b/lisp/url/url-cookie.el index 4912db6c53b..0edc93c9649 100644 --- a/lisp/url/url-cookie.el +++ b/lisp/url/url-cookie.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; url-cookie.el --- URL cookie support | 1 | ;;; url-cookie.el --- URL cookie support -*- lexical-binding:t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1996-1999, 2004-2017 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1996-1999, 2004-2017 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -227,21 +227,17 @@ telling Microsoft that." | |||
| 227 | :group 'url-cookie) | 227 | :group 'url-cookie) |
| 228 | 228 | ||
| 229 | (defun url-cookie-host-can-set-p (host domain) | 229 | (defun url-cookie-host-can-set-p (host domain) |
| 230 | (let ((last nil) | 230 | (cond |
| 231 | (case-fold-search t)) | 231 | ((string= host domain) ; Apparently netscape lets you do this |
| 232 | (cond | 232 | t) |
| 233 | ((string= host domain) ; Apparently netscape lets you do this | 233 | ((zerop (length domain)) |
| 234 | t) | 234 | nil) |
| 235 | ((zerop (length domain)) | 235 | (t |
| 236 | nil) | 236 | ;; Remove the dot from wildcard domains before matching. |
| 237 | (t | 237 | (when (eq ?. (aref domain 0)) |
| 238 | ;; Remove the dot from wildcard domains before matching. | 238 | (setq domain (substring domain 1))) |
| 239 | (when (eq ?. (aref domain 0)) | 239 | (and (url-domsuf-cookie-allowed-p domain) |
| 240 | (setq domain (substring domain 1))) | 240 | (string-suffix-p domain host 'ignore-case))))) |
| 241 | (and (url-domsuf-cookie-allowed-p domain) | ||
| 242 | ;; Need to check and make sure the host is actually _in_ the | ||
| 243 | ;; domain it wants to set a cookie for though. | ||
| 244 | (string-match (concat (regexp-quote domain) "$") host)))))) | ||
| 245 | 241 | ||
| 246 | (defun url-cookie-handle-set-cookie (str) | 242 | (defun url-cookie-handle-set-cookie (str) |
| 247 | (setq url-cookies-changed-since-last-save t) | 243 | (setq url-cookies-changed-since-last-save t) |
| @@ -380,8 +376,8 @@ instead delete all cookies that do not match REGEXP." | |||
| 380 | "Display a buffer listing the current URL cookies, if there are any. | 376 | "Display a buffer listing the current URL cookies, if there are any. |
| 381 | Use \\<url-cookie-mode-map>\\[url-cookie-delete] to remove cookies." | 377 | Use \\<url-cookie-mode-map>\\[url-cookie-delete] to remove cookies." |
| 382 | (interactive) | 378 | (interactive) |
| 383 | (when (and (null url-cookie-secure-storage) | 379 | (unless (or url-cookie-secure-storage |
| 384 | (null url-cookie-storage)) | 380 | url-cookie-storage) |
| 385 | (error "No cookies are defined")) | 381 | (error "No cookies are defined")) |
| 386 | 382 | ||
| 387 | (pop-to-buffer "*url cookies*") | 383 | (pop-to-buffer "*url cookies*") |
| @@ -442,20 +438,13 @@ Use \\<url-cookie-mode-map>\\[url-cookie-delete] to remove cookies." | |||
| 442 | (forward-line 1) | 438 | (forward-line 1) |
| 443 | (point))))) | 439 | (point))))) |
| 444 | 440 | ||
| 445 | (defun url-cookie-quit () | ||
| 446 | "Kill the current buffer." | ||
| 447 | (interactive) | ||
| 448 | (kill-buffer (current-buffer))) | ||
| 449 | |||
| 450 | (defvar url-cookie-mode-map | 441 | (defvar url-cookie-mode-map |
| 451 | (let ((map (make-sparse-keymap))) | 442 | (let ((map (make-sparse-keymap))) |
| 452 | (suppress-keymap map) | ||
| 453 | (define-key map "q" 'url-cookie-quit) | ||
| 454 | (define-key map [delete] 'url-cookie-delete) | 443 | (define-key map [delete] 'url-cookie-delete) |
| 455 | (define-key map [(control k)] 'url-cookie-delete) | 444 | (define-key map [(control k)] 'url-cookie-delete) |
| 456 | map)) | 445 | map)) |
| 457 | 446 | ||
| 458 | (define-derived-mode url-cookie-mode nil "URL Cookie" | 447 | (define-derived-mode url-cookie-mode special-mode "URL Cookie" |
| 459 | "Mode for listing cookies. | 448 | "Mode for listing cookies. |
| 460 | 449 | ||
| 461 | \\{url-cookie-mode-map}" | 450 | \\{url-cookie-mode-map}" |