1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-24 07:20:37 +00:00

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.
This commit is contained in:
Stefan Monnier 2021-01-26 18:17:00 -05:00
parent a572b21928
commit b870e584a4
19 changed files with 71 additions and 65 deletions

View File

@ -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 "<html>\n"
" <head>\n"
@ -73,13 +73,15 @@
"ynchronous<br>\n"
(if (url-scheme-get-property k 'default-port)
(format "Default Port: %d<br>\n"
(url-scheme-get-property k 'default-port)) "")
(url-scheme-get-property k 'default-port))
"")
(if (assoc k url-proxy-services)
(format "Proxy: %s<br>\n" (assoc k url-proxy-services)) ""))
;; Now the description...
(insert " <td valign=top>"
(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 " </table>\n"
" </body>\n"
"</html>\n"))

View File

@ -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.

View File

@ -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.

View File

@ -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)."
" </DAV:owner>\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

View File

@ -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 "")))

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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.

View File

@ -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")

View File

@ -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)))

View File

@ -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.

View File

@ -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))

View File

@ -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.

View File

@ -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))

View File

@ -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.

View File

@ -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.

View File

@ -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)))