From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu 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 17:34:50 +0800 Message-ID: <87h7cgo0ud.fsf@yahoo.com> 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> <83r1bkxzvu.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23207"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.60 (gnu/linux) Cc: tumashu@163.com, larsi@gnus.org, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 13 10:35:48 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 1mlpRr-0005pz-E4 for ged-emacs-devel@m.gmane-mx.org; Sat, 13 Nov 2021 10:35:47 +0100 Original-Received: from localhost ([::1]:44268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mlpRq-0005y2-BH for ged-emacs-devel@m.gmane-mx.org; Sat, 13 Nov 2021 04:35:46 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlpRD-0005Gm-3I for emacs-devel@gnu.org; Sat, 13 Nov 2021 04:35:07 -0500 Original-Received: from sonic312-23.consmr.mail.ne1.yahoo.com ([66.163.191.204]:45531) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mlpR9-0007nv-A6 for emacs-devel@gnu.org; Sat, 13 Nov 2021 04:35:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1636796100; bh=3sXiiJqdcHdzTNC1cDn/slBFUdsNfA6COyB66M+A/Zg=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=RQZk9bGFtAXmdgeqxh1c6I2ld9/jT+/FNAqhW0roLnKSINTcE0NU/CQ4bIFxsCI3tVCksjcr1Bkfmvp27NSOCzvTWMTSkTDIzukUW4g9j8BrT0hmrzsS55W+Lqgsl5ymSUv5a/FfhEEOndO60fMUVS7K7x3qxF9HuMhRtKFvIb4KMWS+2a15pZ1Ye2VVbZhkCBoxjtKeH6d1P1YhNIgpZQDUnYZQVJ93N4BnKsh0ncMp3dN1ZikJMi/85oKKUtPUNc2hk2q3Ne1tWllRM38YRp0be9Am0JurRGihm5Hj5BhNSQ/qsdBrqlLWSLIv04AnTU4lY0En3dSkKCFKb8y8Uw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1636796100; bh=5XsrKdqYob7yHCVoUhoSGffCQuFZkGsd3XWQw+y51jy=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=DgCk02hp1nwFHvxHE3B3SUycRb00O2Oif34M9oUmI8JNCiOQ7rGu44P3Pw3+QugCK8TdMTeA5YgiFq8oq5SQ0nmCI/7BgRtbYmUy6e5Eje1OO89LzXRpIXZCnXV+ey97uf8SF8keBqurAqKRG0bh9G4FTs5JR47TY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gate.mail.ne1.yahoo.com by sonic312.consmr.mail.ne1.yahoo.com with HTTP; Sat, 13 Nov 2021 09:35:00 +0000 Original-Received: by kubenode503.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 202669079795a56604d41c55cd9db3ef; Sat, 13 Nov 2021 09:34:53 +0000 (UTC) In-Reply-To: <83r1bkxzvu.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 13 Nov 2021 09:45:25 +0200") X-Mailer: WebService/1.1.19306 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.191.204; envelope-from=luangruo@yahoo.com; helo=sonic312-23.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:279308 Archived-At: Eli Zaretskii writes: > Is this a replacement for eww--dwim-expand-url? Or is this in > addition to it? It's a replacement for `eww--dwim-expand-url', but in url-utils, because it is too generally useful to warrant staying internal to eww. >> (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? >> 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? This is code I extracted from eww.el; Lars should know the reasoning for that better. >> ((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? Hmm, makes sense. See below. >> ;; 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? No, but in this case eww should have to be fixed too. >> (and (= (length (split-string url)) 1) > You are using split-string here to verify that URL has no SPC > characters? That's what the original code in eww.el did. I didn't dare change it, because I didn't know why it was there. >> (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. Lars, do you know what this test is for? Thanks. >> (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. I don't know: Lars, do you know why this is here? Thanks in advance. > Thanks. Thanks. Here's a better docstring, but I don't want to change any of the code until I know precisely what it does. Canonicalize URL, with SEARCH-PREFIX if URL seems to be a search query. Try to determine if URL is an address or a query for a search engine, and return canonicalized URL, with SEARCH-PREFIX prepended before cannibalisation if it seems to be such a query. Optional argument LOCAL-REGEX is a regular expression that URL is matched against. If the match is successful, then URL is treated as an address, and not a search query.