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 09:08:50 +0800 Message-ID: <87wnlcoo9p.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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21794"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.60 (gnu/linux) Cc: tumashu , "emacs-devel@gnu.org" To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 13 02:09:52 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 1mlhYG-0005SB-79 for ged-emacs-devel@m.gmane-mx.org; Sat, 13 Nov 2021 02:09:52 +0100 Original-Received: from localhost ([::1]:32862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mlhYE-0005AN-0o for ged-emacs-devel@m.gmane-mx.org; Fri, 12 Nov 2021 20:09:50 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:54918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlhXT-0004VO-WE for emacs-devel@gnu.org; Fri, 12 Nov 2021 20:09:04 -0500 Original-Received: from sonic311-25.consmr.mail.ne1.yahoo.com ([66.163.188.206]:33371) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mlhXS-0003k0-9s for emacs-devel@gnu.org; Fri, 12 Nov 2021 20:09:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1636765740; bh=IM7PdJf3vfoBjyMF68EVUp8nxRn+QADiztMDFibqcGo=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=qSfegmht7YS2pqfQPLP0S4QVKaHm4dxthkHZJDBoUz2jW0XZ9wHRxXdzYNC4qWbOuOSVPE0I49ThfY78tVJN94qJx20uBex7KrSgIbIB1kHZn6kqaQ9V2cOIbRNCXnZYbGQvziOjZrN3NoeMwtWLgnQFjU3dyZQxYK9jxDGcAwCy3y9LtLvnCodxJs4/xpWkqtqUaiwhgpgQbCu9ul8i+v6t1Uj38bsejq93qgbrv9v7UIn/NECWJX8VA4NPltbmaIKmajLvzLeiDHrAo7PPxP82Iwi6UbutwXBJpUIb4U2TkAgM97R44w14vX/ikeqE8ZTbWlqSLiZ6Q/j4/70VUw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1636765740; bh=osGYOQBMQ7M15SxiKgjNVgak4+PjOzJSMb/Y/Lx1QHd=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=den6djRtYsC7wP4XVCPY5rrx8bxq6eGEGCw3D7pAkjdptSDzpve4Q6ZX3thbDDS07gPvfw2/Mjyvq2PgTOu9GcZjUkM4ZssOd5BthDV/br75B3mfnsqf5Ny3fBDqgNZLMQZH4VdoIe2Al8SSwMjA1yWuXK41SmUQGGicbD2icxqFt0AzV71P0k2R15G9j84a99h/Xae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r.mail.ne1.yahoo.com with HTTP; Sat, 13 Nov 2021 01:09:00 +0000 Original-Received: by kubenode509.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 58b523a483efc277ebd86a98dbc72e93; Sat, 13 Nov 2021 01:08:53 +0000 (UTC) In-Reply-To: <87ilwy6fr8.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 11 Nov 2021 13:25:31 +0100") 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.188.206; envelope-from=luangruo@yahoo.com; helo=sonic311-25.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:279298 Archived-At: Lars Ingebrigtsen writes: > Well, it's a DWIM function, so: =F0=9F=98=85. It just tries to do what a= ny > browser does when a user types something into the address bar, and it'll > probably change over time (as users' expectations change). > > 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: (defun url-dwim-expand-url (url local-regex search-prefix) "Canonicalize URL. 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. LOCAL-REGEX is a regular expression that URL is matched against. If the match is successful, then URL is treated as an address." (setq url (string-trim url)) (cond ((string-match-p "\\`file:/" url)) ;; Don't mangle file: URLs at all. ((string-match-p "\\`ftp://" url) (user-error "FTP is not supported")) (t ;; 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) ;; Also try to match "naked" URLs like ;; en.wikipedia.org/wiki/Free software (string-match "\\`[A-Za-z_]+\\.[A-Za-z._]+/" url) (and (=3D (length (split-string url)) 1) (or (and (not (string-match-p "\\`[\"'].*[\"']\\'" url)) (> (length (split-string url "[.:]")) 1)) (string-match local-regex url)))) (progn (unless (string-match-p "\\`[a-zA-Z][-a-zA-Z0-9+.]*://" url) (setq url (concat "http://" url))) ;; Some sites do not redirect final / (when (string=3D (url-filename (url-generic-parse-url url)) = "") (setq url (concat url "/")))) (setq url (concat search-prefix (mapconcat #'url-hexify-string (split-string url) "+")))= ))) url) to url-util. Does this look good to you? Thanks in advance.