From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Antero Mejr via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#62800: [PATCH] eww: Use completion in URL/keyword prompt. Date: Thu, 13 Apr 2023 01:31:43 +0000 Message-ID: <871qkoy3cw.fsf@mailbox.org> References: <87o7ntc6pp.fsf@mailbox.org> <86v8i1x86z.fsf@mail.linkov.net> <87jzygdgwe.fsf@mailbox.org> Reply-To: Antero Mejr Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21750"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62800@debbugs.gnu.org, Juri Linkov To: Eshel Yaron Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 13 03:33:23 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1pmlpz-0005T3-Cx for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Apr 2023 03:33:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmlpk-0000ll-Hy; Wed, 12 Apr 2023 21:33:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pmlpf-0000lY-R0 for bug-gnu-emacs@gnu.org; Wed, 12 Apr 2023 21:33:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pmlpf-00061j-2M for bug-gnu-emacs@gnu.org; Wed, 12 Apr 2023 21:33:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pmlpe-0008Sx-Gg for bug-gnu-emacs@gnu.org; Wed, 12 Apr 2023 21:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Antero Mejr Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 13 Apr 2023 01:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62800 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 62800-submit@debbugs.gnu.org id=B62800.168134952932473 (code B ref 62800); Thu, 13 Apr 2023 01:33:02 +0000 Original-Received: (at 62800) by debbugs.gnu.org; 13 Apr 2023 01:32:09 +0000 Original-Received: from localhost ([127.0.0.1]:42157 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pmlon-0008Rh-0u for submit@debbugs.gnu.org; Wed, 12 Apr 2023 21:32:09 -0400 Original-Received: from mout-p-201.mailbox.org ([80.241.56.171]:47818) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pmloh-0008R8-9h for 62800@debbugs.gnu.org; Wed, 12 Apr 2023 21:32:07 -0400 Original-Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4PxhrQ4LFPz9sjS; Thu, 13 Apr 2023 03:31:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1681349514; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RtJoDuPCdAY7kD63A5sIV8FxAXnKuDjcqcO05PFHyKE=; b=Cb5+nZA7ASCiifGJHQZKtngyeSSIpPWMRfla0nsvxupgjqZRTko/OgZfN2uA37Lqa4YcLw y9HkbOocmkmUbijQ055nP704NGkJimU9abShSydI4pU/3QrdVKYnXTKaa2OV6/LEaK08Jv TqEm4iRPmWfncId9v/9kwuwLfZon3kEJG4Ery+BwM/eZPVIJfkInW1LLtt5T1cDZ0i6Stp 07jRklzseypWrNDpT0p5+MDm5J2rnlDSzsD5hB+e2deQ1JNy4sgrAqrmVounBe9OlolGB5 HFKgMRkIMwVplZWeC/TnDGgbLCBKI5TMFRbJxTUHq/bf19BEBQCZQF4wbw86Gg== In-Reply-To: (Eshel Yaron's message of "Thu, 13 Apr 2023 00:43:42 +0300") X-MBO-RS-META: xzob48rp4gxp98epnp1kueq6wtwgnhsj X-MBO-RS-ID: a5d70352b69c599bbc3 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:259824 Archived-At: --=-=-= Content-Type: text/plain Eshel Yaron writes: >> - (list (read-string (format-prompt "Enter URL or keywords" >> - (and uris (car uris))) >> - nil 'eww-prompt-history uris) >> + (list (completing-read (format-prompt "Enter URL or keywords" >> + (and uris (car uris))) >> + eww-prompt-history nil nil nil >> + 'eww-prompt-history uris) > > Note that this change doesn't work so well for the use case of inserting > space-separated keywords, since it causes SPC to be bound to > `minibuffer-complete-word' instead of `self-insert-command'. Good point. The attached v2 patch creates a new keymap called "eww-minibuffer-url-keymap" with "SPC" and "?" bound to self-insert-command, and uses that map for the URL/keyword prompt. Rebinding minibuffer-local-completion-map is done in a few places in the code. It is also suggested in the manual (49.3.4 Minibuffer Keymaps), and was already in my init file, which is why I didn't notice the problem. It would be nice if there was a single keymap along the lines of "minibuffer-local-text-completion-map" that can be used for all those existing cases, and for completion in commands like "M-x rgrep". But that is a bigger change and beyond the scope of this patch. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=v2-0001-eww-Enable-completion-in-URL-keyword-prompt.patch >From 4be47c886d2e1aeeeaa40a53dea5a8f5f209b652 Mon Sep 17 00:00:00 2001 From: Antero Mejr Date: Wed, 12 Apr 2023 17:56:01 +0000 Subject: [PATCH v2] eww: Enable completion in URL/keyword prompt. * lisp/net/eww.el (eww): Use 'completing-read' when prompting for a URL or keywords. (eww-minibuffer-url-keymap): New keymap for use in the URL/keyword prompt. * etc/NEWS (EWW): Add NEWS entry for the change. --- etc/NEWS | 5 +++++ lisp/net/eww.el | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 5e1fd76e99e..9f9317d5ea9 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -219,6 +219,11 @@ the new argument NEW-BUFFER non-nil, it will use a new buffer instead. Interactively, invoke 'eww-open-file' with a prefix argument to activate this behavior. ++++ +*** 'eww' now has completion when prompting for a URL or keywords. +The interactive minibuffer prompt when invoking 'eww' now has support +for completion. + ** go-ts-mode +++ diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 11be20b68db..7f0c9167c6a 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -329,6 +329,12 @@ parameter, and should return the (possibly) transformed URL." :parent shr-map "RET" #'eww-follow-link) +(defvar-keymap eww-minibuffer-url-keymap + :doc "Keymap used in the minibuffer prompt for URLs or keywords." + :parent minibuffer-local-completion-map + "SPC" #'self-insert-command + "?" #'self-insert-command) + (defun eww-suggested-uris nil "Return the list of URIs to suggest at the `eww' prompt. This list can be customized via `eww-suggest-uris'." @@ -377,10 +383,12 @@ killed after rendering. For more information, see Info node `(eww) Top'." (interactive - (let ((uris (eww-suggested-uris))) - (list (read-string (format-prompt "Enter URL or keywords" - (and uris (car uris))) - nil 'eww-prompt-history uris) + (let ((uris (eww-suggested-uris)) + (minibuffer-local-completion-map eww-minibuffer-url-keymap)) + (list (completing-read (format-prompt "Enter URL or keywords" + (and uris (car uris))) + eww-prompt-history nil nil nil + 'eww-prompt-history uris) current-prefix-arg))) (setq url (eww--dwim-expand-url url)) (pop-to-buffer-same-window -- 2.39.2 --=-=-=--