From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel 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 Message-ID: <83r1bkxzvu.fsf@gnu.org> References: <27840630.58e8.17d0e5b6389.Coremail.tumashu@163.com> <877ddfvxnm.fsf@yahoo.com> <87v90z6k0p.fsf@gnus.org> <87r1bnuenl.fsf@yahoo.com> <87ilwy7vla.fsf@gnus.org> <87ilwyvq5m.fsf@yahoo.com> <87ilwy6fr8.fsf@gnus.org> <87wnlcoo9p.fsf@yahoo.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12885"; mail-complaints-to="usenet@ciao.gmane.io" Cc: tumashu@163.com, larsi@gnus.org, emacs-devel@gnu.org To: Po Lu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 13 08:46:35 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mlnkA-000356-9T for ged-emacs-devel@m.gmane-mx.org; Sat, 13 Nov 2021 08:46:34 +0100 Original-Received: from localhost ([::1]:46158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mlnk8-0007vi-Bo for ged-emacs-devel@m.gmane-mx.org; Sat, 13 Nov 2021 02:46:32 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:39646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlnjO-0007Ez-Vr for emacs-devel@gnu.org; Sat, 13 Nov 2021 02:45:47 -0500 Original-Received: from [2001:470:142:3::e] (port=39940 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlnjO-0003Ti-L8; Sat, 13 Nov 2021 02:45:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=+GFP0tHsoSLbD+WVxXWLK0z8aOGk1ws6Gi843YFcLUQ=; b=Kn7hC+AsIOdx OH+1T9N8nBDODiQdrpl5R4J9o2NFV50WOmpyhlvw39CT7fYisV0hXJamimGHoudl93vCB6yZADJbv N8zo6MQn5+J+hc0guBJeJuOYx62goXWPVIBHerZvD0yan0UYRkMDvbLH1gCij2YiDsDxHgW/xtsRZ 7T5C2szwmeKijZVoAKC8K+S1iT860SZsHNgfVUEcF1VUk7wo0cdUJNK9XIFeDXJPwds+dHR8RidB/ Wf2FzleQJpiQusDLhTza3aNfRISQ3GRTEiCpUB9g0f/bOgjtbQD37mJEOwkxMeIJzxEERv+WZCx41 Le2MJU9f5115xjdxGSsz1g==; Original-Received: from [87.69.77.57] (port=4908 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlnjM-0001JC-Fx; Sat, 13 Nov 2021 02:45:46 -0500 In-Reply-To: <87wnlcoo9p.fsf@yahoo.com> (message from Po Lu on Sat, 13 Nov 2021 09:08:50 +0800) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:279305 Archived-At: > From: Po Lu > Cc: tumashu , "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.