From: Stefan Monnier Date: Tue, 26 Jan 2021 23:17:00 +0000 (-0500) Subject: Use lexical-binding in all of `lisp/url` X-Git-Tag: emacs-28.0.90~4111 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b870e584a4275be83d6878001ee613997282fd37;p=emacs.git Use lexical-binding in all of `lisp/url` * lisp/url/url-dav.el: Use lexical-binding. (url-dav-process-DAV:prop): Remove unused var `handler-func`. (url-dav-lock-resource): Remove unused var `child-url`. (url-dav-active-locks): Remove unused var `properties`. (url-dav-delete-directory): Remove unused var `props`. (url-dav-file-name-completion): Remove unused var `result`. * lisp/url/url-expand.el (url-expand-file-name): Use \s * lisp/url/url-file.el (url-file): Improve regexp. * lisp/url/url-gw.el: Use lexical-binding. (url-open-stream): Remove unused var `cur-retries`, `retry`, `errobj`. * lisp/url/url-imap.el: Use lexical-binding. (imap-username, imap-password): Declare. * lisp/url/url-mailto.el: Use lexical-binding. (url-mailto): Remove unused var `func`. Use `push`. * lisp/url/url-news.el: Use lexical-binding. (url-news): Remove unused var `article-brackets`. * lisp/url/url-cid.el: * lisp/url/url-cache.el: * lisp/url/url-about.el: * lisp/url/url-tramp.el: * lisp/url/url-proxy.el: * lisp/url/url-privacy.el: * lisp/url/url-nfs.el: * lisp/url/url-ldap.el: * lisp/url/url-misc.el: * lisp/url/url-methods.el: Use lexical-binding. --- diff --git a/lisp/url/url-about.el b/lisp/url/url-about.el index bff5570f6df..6ae90ccefad 100644 --- a/lisp/url/url-about.el +++ b/lisp/url/url-about.el @@ -1,4 +1,4 @@ -;;; url-about.el --- Show internal URLs +;;; url-about.el --- Show internal URLs -*- lexical-binding: t; -*- ;; Copyright (C) 2001, 2004-2021 Free Software Foundation, Inc. @@ -44,7 +44,7 @@ (defvar url-scheme-registry) -(defun url-about-protocols (url) +(defun url-about-protocols (_url) (url-probe-protocols) (insert "\n" " \n" @@ -73,13 +73,15 @@ "ynchronous
\n" (if (url-scheme-get-property k 'default-port) (format "Default Port: %d
\n" - (url-scheme-get-property k 'default-port)) "") + (url-scheme-get-property k 'default-port)) + "") (if (assoc k url-proxy-services) (format "Proxy: %s
\n" (assoc k url-proxy-services)) "")) ;; Now the description... (insert " " (or (url-scheme-get-property k 'description) "N/A")))) - (sort (let (x) (maphash (lambda (k v) (push k x)) url-scheme-registry) x) 'string-lessp)) + (sort (let (x) (maphash (lambda (k _v) (push k x)) url-scheme-registry) x) + #'string-lessp)) (insert " \n" " \n" "\n")) diff --git a/lisp/url/url-cache.el b/lisp/url/url-cache.el index acf88eb0212..830e6ba9dcc 100644 --- a/lisp/url/url-cache.el +++ b/lisp/url/url-cache.el @@ -1,4 +1,4 @@ -;;; url-cache.el --- Uniform Resource Locator retrieval tool +;;; url-cache.el --- Uniform Resource Locator retrieval tool -*- lexical-binding: t; -*- ;; Copyright (C) 1996-1999, 2004-2021 Free Software Foundation, Inc. diff --git a/lisp/url/url-cid.el b/lisp/url/url-cid.el index d465cabc90c..0ca2d8a0737 100644 --- a/lisp/url/url-cid.el +++ b/lisp/url/url-cid.el @@ -1,4 +1,4 @@ -;;; url-cid.el --- Content-ID URL loader +;;; url-cid.el --- Content-ID URL loader -*- lexical-binding: t; -*- ;; Copyright (C) 1998-1999, 2004-2021 Free Software Foundation, Inc. diff --git a/lisp/url/url-dav.el b/lisp/url/url-dav.el index 12d5a683e97..edb1c1de9fc 100644 --- a/lisp/url/url-dav.el +++ b/lisp/url/url-dav.el @@ -1,4 +1,4 @@ -;;; url-dav.el --- WebDAV support +;;; url-dav.el --- WebDAV support -*- lexical-binding: t; -*- ;; Copyright (C) 2001, 2004-2021 Free Software Foundation, Inc. @@ -133,7 +133,8 @@ Returns nil if WebDAV is not supported." (node-type nil) (props nil) (value nil) - (handler-func nil)) + ;; (handler-func nil) + ) (when (not children) (error "No child nodes in DAV:prop")) @@ -453,7 +454,7 @@ FAILURE-RESULTS is a list of (URL STATUS)." " \n")) (response nil) ; Responses to the LOCK request (result nil) ; For walking thru the response list - (child-url nil) + ;; (child-url nil) (child-status nil) (failures nil) ; List of failure cases (URL . STATUS) (successes nil)) ; List of success cases (URL . STATUS) @@ -468,7 +469,7 @@ FAILURE-RESULTS is a list of (URL STATUS)." ;; status code. (while response (setq result (pop response) - child-url (url-expand-file-name (pop result) url) + ;; child-url (url-expand-file-name (pop result) url) child-status (or (plist-get result 'DAV:status) 500)) (if (url-dav-http-success-p child-status) (push (list url child-status "huh") successes) @@ -478,7 +479,7 @@ FAILURE-RESULTS is a list of (URL STATUS)." (defun url-dav-active-locks (url &optional depth) "Return an assoc list of all active locks on URL." (let ((response (url-dav-get-properties url '(DAV:lockdiscovery) depth)) - (properties nil) + ;; (properties nil) (child nil) (child-url nil) (child-results nil) @@ -676,7 +677,6 @@ Use with care, and even then think three times." If optional second argument RECURSIVE is non-nil, then delete all files in the collection as well." (let ((status nil) - (props nil) (props nil)) (setq props (url-dav-delete-something url lock-token @@ -769,7 +769,7 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable. (when (member 'DAV:collection (plist-get properties 'DAV:resourcetype)) t))) -(defun url-dav-make-directory (url &optional parents) +(defun url-dav-make-directory (url &optional _parents) "Create the directory DIR and any nonexistent parent dirs." (let* ((url-request-extra-headers nil) (url-request-method "MKCOL") @@ -849,7 +849,9 @@ that start with FILE. If there is only one and FILE matches it exactly, returns t. Returns nil if URL contains no name starting with FILE." (let ((matches (url-dav-file-name-all-completions file url)) - (result nil)) + ;; (result nil) + ) + ;; FIXME: Use `try-completion'! (cond ((null matches) ;; No matches diff --git a/lisp/url/url-expand.el b/lisp/url/url-expand.el index a42b4c7ad23..05088e3cac8 100644 --- a/lisp/url/url-expand.el +++ b/lisp/url/url-expand.el @@ -66,7 +66,7 @@ path components followed by `..' are removed, along with the `..' itself." ;; Need to nuke newlines and spaces in the URL, or we open ;; ourselves up to potential security holes. (setq url (mapconcat (lambda (x) - (if (memq x '(? ?\n ?\r)) + (if (memq x '(?\s ?\n ?\r)) "" (char-to-string x))) url ""))) diff --git a/lisp/url/url-file.el b/lisp/url/url-file.el index 52a9588030e..0e2ab5544b9 100644 --- a/lisp/url/url-file.el +++ b/lisp/url/url-file.el @@ -154,7 +154,7 @@ to them." ;; not the compressed one. ;; FIXME should this regexp not include more extensions; basically ;; everything that url-file-find-possibly-compressed-file does? - (setq uncompressed-filename (if (string-match "\\.\\(gz\\|Z\\|z\\)$" filename) + (setq uncompressed-filename (if (string-match "\\.\\(gz\\|Z\\|z\\)\\'" filename) (substring filename 0 (match-beginning 0)) filename)) (setq content-type (mailcap-extension-to-mime diff --git a/lisp/url/url-gw.el b/lisp/url/url-gw.el index 68df67f6486..d2bf843fc36 100644 --- a/lisp/url/url-gw.el +++ b/lisp/url/url-gw.el @@ -1,4 +1,4 @@ -;;; url-gw.el --- Gateway munging for URL loading +;;; url-gw.el --- Gateway munging for URL loading -*- lexical-binding: t; -*- ;; Copyright (C) 1997-1998, 2004-2021 Free Software Foundation, Inc. @@ -222,18 +222,17 @@ overriding the value of `url-gateway-method'." host)) 'native gwm)) - ;; An attempt to deal with denied connections, and attempt - ;; to reconnect - (cur-retries 0) - (retry t) - (errobj nil) - (conn nil)) + ;; An attempt to deal with denied connections, and attempt + ;; to reconnect + ;; (cur-retries 0) + ;; (retry t) + (conn nil)) ;; If the user told us to do DNS for them, do it. (if url-gateway-broken-resolution (setq host (url-gateway-nslookup-host host))) - (condition-case errobj + (condition-case nil ;; This is a clean way to ensure the new process inherits the ;; right coding systems in both Emacs and XEmacs. (let ((coding-system-for-read 'binary) diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index 324cf99554d..61e07a0d9ca 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -66,7 +66,7 @@ (defconst url-http-default-port 80 "Default HTTP port.") (defconst url-http-asynchronous-p t "HTTP retrievals are asynchronous.") -(defalias 'url-http-expand-file-name 'url-default-expander) +(defalias 'url-http-expand-file-name #'url-default-expander) (defvar url-http-real-basic-auth-storage nil) (defvar url-http-proxy-basic-auth-storage nil) @@ -150,7 +150,7 @@ request.") ;; These routines will allow us to implement persistent HTTP ;; connections. (defsubst url-http-debug (&rest args) - (apply 'url-debug 'http args)) + (apply #'url-debug 'http args)) (defun url-http-mark-connection-as-busy (host port proc) (url-http-debug "Marking connection as busy: %s:%d %S" host port proc) @@ -1203,8 +1203,7 @@ the end of the document." ;; We got back a headerless malformed response from the ;; server. (url-http-activate-callback)) - ((or (= url-http-response-status 204) - (= url-http-response-status 205)) + ((memq url-http-response-status '(204 205)) (url-http-debug "%d response must have headers only (%s)." url-http-response-status (buffer-name)) (when (url-http-parse-headers) @@ -1239,11 +1238,11 @@ the end of the document." (url-http-debug "Saw HTTP/0.9 response, connection closed means end of document.") (setq url-http-after-change-function - 'url-http-simple-after-change-function)) + #'url-http-simple-after-change-function)) ((equal url-http-transfer-encoding "chunked") (url-http-debug "Saw chunked encoding.") (setq url-http-after-change-function - 'url-http-chunked-encoding-after-change-function) + #'url-http-chunked-encoding-after-change-function) (when (> nd url-http-end-of-headers) (url-http-debug "Calling initial chunked-encoding for extra data at end of headers") @@ -1254,7 +1253,7 @@ the end of the document." (url-http-debug "Got a content-length, being smart about document end.") (setq url-http-after-change-function - 'url-http-content-length-after-change-function) + #'url-http-content-length-after-change-function) (cond ((= 0 url-http-content-length) ;; We got a NULL body! Activate the callback @@ -1275,7 +1274,7 @@ the end of the document." (t (url-http-debug "No content-length, being dumb.") (setq url-http-after-change-function - 'url-http-simple-after-change-function))))) + #'url-http-simple-after-change-function))))) ;; We are still at the beginning of the buffer... must just be ;; waiting for a response. (url-http-debug "Spinning waiting for headers...") @@ -1374,7 +1373,7 @@ The return value of this function is the retrieval buffer." url-http-referer referer) (set-process-buffer connection buffer) - (set-process-filter connection 'url-http-generic-filter) + (set-process-filter connection #'url-http-generic-filter) (pcase (process-status connection) ('connect ;; Asynchronous connection @@ -1388,12 +1387,12 @@ The return value of this function is the retrieval buffer." (url-type url-current-object))) (url-https-proxy-connect connection) (set-process-sentinel connection - 'url-http-end-of-document-sentinel) + #'url-http-end-of-document-sentinel) (process-send-string connection (url-http-create-request))))))) buffer)) (defun url-https-proxy-connect (connection) - (setq url-http-after-change-function 'url-https-proxy-after-change-function) + (setq url-http-after-change-function #'url-https-proxy-after-change-function) (process-send-string connection (format @@ -1441,7 +1440,7 @@ The return value of this function is the retrieval buffer." (with-current-buffer process-buffer (erase-buffer)) (set-process-buffer tls-connection process-buffer) (setq url-http-after-change-function - 'url-http-wait-for-headers-change-function) + #'url-http-wait-for-headers-change-function) (set-process-filter tls-connection 'url-http-generic-filter) (process-send-string tls-connection (url-http-create-request))) @@ -1510,7 +1509,7 @@ The return value of this function is the retrieval buffer." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defalias 'url-http-symbol-value-in-buffer (if (fboundp 'symbol-value-in-buffer) - 'symbol-value-in-buffer + #'symbol-value-in-buffer (lambda (symbol buffer &optional unbound-value) "Return the value of SYMBOL in BUFFER, or UNBOUND-VALUE if it is unbound." (with-current-buffer buffer diff --git a/lisp/url/url-imap.el b/lisp/url/url-imap.el index 05c3e73fb0e..492907f33ff 100644 --- a/lisp/url/url-imap.el +++ b/lisp/url/url-imap.el @@ -1,4 +1,4 @@ -;;; url-imap.el --- IMAP retrieval routines +;;; url-imap.el --- IMAP retrieval routines -*- lexical-binding: t; -*- ;; Copyright (C) 1999, 2004-2021 Free Software Foundation, Inc. @@ -37,6 +37,9 @@ (defconst url-imap-default-port 143 "Default IMAP port.") +(defvar imap-username) +(defvar imap-password) + (defun url-imap-open-host (host port user pass) ;; xxx use user and password (if (fboundp 'nnheader-init-server-buffer) diff --git a/lisp/url/url-ldap.el b/lisp/url/url-ldap.el index 0fa9970fa47..d26562b7f10 100644 --- a/lisp/url/url-ldap.el +++ b/lisp/url/url-ldap.el @@ -1,4 +1,4 @@ -;;; url-ldap.el --- LDAP Uniform Resource Locator retrieval code +;;; url-ldap.el --- LDAP Uniform Resource Locator retrieval code -*- lexical-binding: t; -*- ;; Copyright (C) 1998-1999, 2004-2021 Free Software Foundation, Inc. diff --git a/lisp/url/url-mailto.el b/lisp/url/url-mailto.el index 688f102cabd..72884c07cc9 100644 --- a/lisp/url/url-mailto.el +++ b/lisp/url/url-mailto.el @@ -1,4 +1,4 @@ -;;; url-mail.el --- Mail Uniform Resource Locator retrieval code +;;; url-mail.el --- Mail Uniform Resource Locator retrieval code -*- lexical-binding: t; -*- ;; Copyright (C) 1996-1999, 2004-2021 Free Software Foundation, Inc. @@ -67,7 +67,7 @@ ;; mailto:wmperry@gnu.org (setf (url-filename url) (concat (url-user url) "@" (url-filename url)))) (setq url (url-filename url)) - (let (to args source-url subject func headers-start) + (let (to args source-url subject headers-start) ;; func (if (string-match (regexp-quote "?") url) (setq headers-start (match-end 0) to (url-unhex-string (substring url 0 (match-beginning 0))) @@ -76,10 +76,11 @@ (setq to (url-unhex-string url))) (setq source-url (url-view-url t)) (if (and url-request-data (not (assoc "subject" args))) - (setq args (cons (list "subject" + (push (list "subject" (concat "Automatic submission from " url-package-name "/" - url-package-version)) args))) + url-package-version)) + args)) (if (and source-url (not (assoc "x-url-from" args))) (setq args (cons (list "x-url-from" source-url) args))) @@ -107,7 +108,7 @@ (replace-regexp-in-string "\r\n" "\n" string)) (cdar args) "\n"))) (url-mail-goto-field (caar args)) - (setq func (intern-soft (concat "mail-" (caar args)))) + ;; (setq func (intern-soft (concat "mail-" (caar args)))) (insert (mapconcat 'identity (cdar args) ", "))) (setq args (cdr args))) ;; (url-mail-goto-field "User-Agent") diff --git a/lisp/url/url-methods.el b/lisp/url/url-methods.el index 7aad741210d..cfe7d5bc6a3 100644 --- a/lisp/url/url-methods.el +++ b/lisp/url/url-methods.el @@ -1,4 +1,4 @@ -;;; url-methods.el --- Load URL schemes as needed +;;; url-methods.el --- Load URL schemes as needed -*- lexical-binding: t; -*- ;; Copyright (C) 1996-1999, 2004-2021 Free Software Foundation, Inc. @@ -57,7 +57,7 @@ 'file-exists-p 'ignore 'file-attributes 'ignore)) -(defun url-scheme-default-loader (url &optional callback cbargs) +(defun url-scheme-default-loader (url &optional _callback _cbargs) "Signal an error for an unknown URL scheme." (error "Unknown URL scheme: %s" (url-type url))) diff --git a/lisp/url/url-misc.el b/lisp/url/url-misc.el index d3db31d612a..fe2393beb64 100644 --- a/lisp/url/url-misc.el +++ b/lisp/url/url-misc.el @@ -1,4 +1,4 @@ -;;; url-misc.el --- Misc Uniform Resource Locator retrieval code +;;; url-misc.el --- Misc Uniform Resource Locator retrieval code -*- lexical-binding: t; -*- ;; Copyright (C) 1996-1999, 2002, 2004-2021 Free Software Foundation, ;; Inc. diff --git a/lisp/url/url-news.el b/lisp/url/url-news.el index d5f8483ab7a..585a28291ae 100644 --- a/lisp/url/url-news.el +++ b/lisp/url/url-news.el @@ -1,4 +1,4 @@ -;;; url-news.el --- News Uniform Resource Locator retrieval code +;;; url-news.el --- News Uniform Resource Locator retrieval code -*- lexical-binding: t; -*- ;; Copyright (C) 1996-1999, 2004-2021 Free Software Foundation, Inc. @@ -106,7 +106,7 @@ ;; Find a news reference (let* ((host (or (url-host url) url-news-server)) (port (url-port url)) - (article-brackets nil) + ;; (article-brackets nil) (buf nil) (article (url-unhex-string (url-filename url)))) (url-news-open-host host port (url-user url) (url-password url)) diff --git a/lisp/url/url-nfs.el b/lisp/url/url-nfs.el index 3c80c8059b5..0449930408d 100644 --- a/lisp/url/url-nfs.el +++ b/lisp/url/url-nfs.el @@ -1,4 +1,4 @@ -;;; url-nfs.el --- NFS URL interface +;;; url-nfs.el --- NFS URL interface -*- lexical-binding: t; -*- ;; Copyright (C) 1996-1999, 2004-2021 Free Software Foundation, Inc. diff --git a/lisp/url/url-privacy.el b/lisp/url/url-privacy.el index e3ca0f66d98..d926775c48d 100644 --- a/lisp/url/url-privacy.el +++ b/lisp/url/url-privacy.el @@ -1,4 +1,4 @@ -;;; url-privacy.el --- Global history tracking for URL package +;;; url-privacy.el --- Global history tracking for URL package -*- lexical-binding: t; -*- ;; Copyright (C) 1996-1999, 2004-2021 Free Software Foundation, Inc. @@ -23,7 +23,7 @@ (require 'url-vars) -(defun url-device-type (&optional device) +(defun url-device-type (&optional _device) (declare (obsolete nil "27.1")) (or window-system 'tty)) diff --git a/lisp/url/url-proxy.el b/lisp/url/url-proxy.el index 6bf65845098..8436c7a4be2 100644 --- a/lisp/url/url-proxy.el +++ b/lisp/url/url-proxy.el @@ -1,4 +1,4 @@ -;;; url-proxy.el --- Proxy server support +;;; url-proxy.el --- Proxy server support -*- lexical-binding: t; -*- ;; Copyright (C) 1999, 2004-2021 Free Software Foundation, Inc. diff --git a/lisp/url/url-tramp.el b/lisp/url/url-tramp.el index 325d25cb8e2..5b9dd8a2682 100644 --- a/lisp/url/url-tramp.el +++ b/lisp/url/url-tramp.el @@ -1,4 +1,4 @@ -;;; url-tramp.el --- file-name-handler magic invoking Tramp for some protocols +;;; url-tramp.el --- file-name-handler magic invoking Tramp for some protocols -*- lexical-binding: t; -*- ;; Copyright (C) 2014-2021 Free Software Foundation, Inc. diff --git a/lisp/url/url.el b/lisp/url/url.el index 172a3af2b3b..8daf9f0a8e8 100644 --- a/lisp/url/url.el +++ b/lisp/url/url.el @@ -156,16 +156,16 @@ If INHIBIT-COOKIES, cookies will neither be stored nor sent to the server. If URL is a multibyte string, it will be encoded as utf-8 and URL-encoded before it's used." -;;; XXX: There is code in Emacs that does dynamic binding -;;; of the following variables around url-retrieve: -;;; url-standalone-mode, url-gateway-unplugged, w3-honor-stylesheets, -;;; url-confirmation-func, url-cookie-multiple-line, -;;; url-cookie-{{,secure-}storage,confirmation} -;;; url-standalone-mode and url-gateway-unplugged should work as -;;; usual. url-confirmation-func is only used in nnwarchive.el and -;;; webmail.el; the latter should be updated. Is -;;; url-cookie-multiple-line needed anymore? The other url-cookie-* -;;; are (for now) only used in synchronous retrievals. + ;; XXX: There is code in Emacs that does dynamic binding + ;; of the following variables around url-retrieve: + ;; url-standalone-mode, url-gateway-unplugged, w3-honor-stylesheets, + ;; url-confirmation-func, url-cookie-multiple-line, + ;; url-cookie-{{,secure-}storage,confirmation} + ;; url-standalone-mode and url-gateway-unplugged should work as + ;; usual. url-confirmation-func is only used in nnwarchive.el and + ;; webmail.el; the latter should be updated. Is + ;; url-cookie-multiple-line needed anymore? The other url-cookie-* + ;; are (for now) only used in synchronous retrievals. (url-retrieve-internal url callback (cons nil cbargs) silent inhibit-cookies)) @@ -210,7 +210,7 @@ URL-encoded before it's used." (asynch (url-scheme-get-property (url-type url) 'asynchronous-p))) (if url-using-proxy (setq asynch t - loader 'url-proxy)) + loader #'url-proxy)) (if asynch (let ((url-current-object url)) (setq buffer (funcall loader url callback cbargs)))