[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remo
From: |
Eli Zaretskii |
Subject: |
Re: Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remove space prefix of url. |
Date: |
Sat, 13 Nov 2021 09:45:25 +0200 |
> From: Po Lu <luangruo@yahoo.com>
> Cc: tumashu <tumashu@163.com>, "emacs-devel@gnu.org" <emacs-devel@gnu.org>
> Date: Sat, 13 Nov 2021 09:08:50 +0800
>
> > But basically tries to guess whether a user is typing in a (possibly
> > incomplete) URL or a search term.
>
> I'd like to add this:
Is this a replacement for eww--dwim-expand-url? Or is this in
addition to it?
> (defun url-dwim-expand-url (url local-regex search-prefix)
> "Canonicalize URL.
First line of a doc string should mention all the mandatory
arguments. (But see below.)
> Try to determine if URL is an incomplete URL or a search query, and
> return the canonical form of URL.
> SEARCH-PREFIX is the prefix to be prepended to URL if it is a search query.
Can the doc string explain what does "search query" mean in this
context?
> LOCAL-REGEX is a regular expression that URL is matched against. If the
> match is successful, then URL is treated as an address."
This begs the question: and if it doesn't match, then what? And what
does "address" mean in this context, i.e. what does "treated as an
address" means in practice?
> (cond ((string-match-p "\\`file:/" url))
> ;; Don't mangle file: URLs at all.
This comment should be above the line that handles file:// URLs.
Btw, should other URLs be exempt from "mangling"? AFAIK, there are
many protocols whose syntax we don't really understand in url*.el
code, so shouldn't they all be left alone?
> ((string-match-p "\\`ftp://" url)
> (user-error "FTP is not supported"))
I can understand this in EWW, but why should FTP be unsupported in
url-util?
> ;; Anything that starts with something that vaguely looks
> ;; like a protocol designator is interpreted as a full URL.
> (if (or (string-match "\\`[A-Za-z]+:" url)
This will match Windows-style d:/foo/bar absolute file names. Is that
what we want?
> (and (= (length (split-string url)) 1)
You are using split-string here to verify that URL has no SPC
characters?
> (or (and (not (string-match-p "\\`[\"'].*[\"']\\'" url))
> (> (length (split-string url "[.:]")) 1))
It would be good to have a comment here explaining what do these
conditions test.
> (string-match local-regex url))))
This sole use of LOCAL-REGEX hints that maybe it should be an optional
argument.
> (progn
> (unless (string-match-p "\\`[a-zA-Z][-a-zA-Z0-9+.]*://" url)
> (setq url (concat "http://" url)))
"http", not "https"? I think the default nowadays is the latter.
> (setq url (concat search-prefix
> (mapconcat
> #'url-hexify-string (split-string url) "+"))))))
> url)
Doesn't this part mean a search query is expected to be in some
specific format? If so, that format should be documented in the doc
string.
Thanks.
- Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remove space prefix of url., tumashu, 2021/11/11
- Re: Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remove space prefix of url., Po Lu, 2021/11/11
- Re:Re: Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remove space prefix of url., tumashu, 2021/11/11
- Re: Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remove space prefix of url., Lars Ingebrigtsen, 2021/11/11
- Re: Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remove space prefix of url., Po Lu, 2021/11/11
- Re: Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remove space prefix of url., Lars Ingebrigtsen, 2021/11/11
- Re: Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remove space prefix of url., Po Lu, 2021/11/11
- Re: Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remove space prefix of url., Lars Ingebrigtsen, 2021/11/11
- Re: Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remove space prefix of url., Po Lu, 2021/11/12
- Re: Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remove space prefix of url.,
Eli Zaretskii <=
- Re: Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remove space prefix of url., Po Lu, 2021/11/13
- Re: Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remove space prefix of url., Eli Zaretskii, 2021/11/13
- Re: Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remove space prefix of url., Po Lu, 2021/11/13
- Re: Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remove space prefix of url., Eli Zaretskii, 2021/11/13
- Re: Subject: [PATCH] * lisp/xwidget.el (xwidget-webkit-browse-url): Remove space prefix of url., Stephen Berman, 2021/11/13