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 17:16:53 +0000 Message-ID: <87bkjrbt2y.fsf@mailbox.org> References: <87o7ntc6pp.fsf@mailbox.org> <86v8i1x86z.fsf@mail.linkov.net> <87jzygdgwe.fsf@mailbox.org> <86jzygjndv.fsf@mail.linkov.net> 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="25683"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62800@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 13 19:18:39 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 1pn0al-0006Tk-5U for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Apr 2023 19:18:39 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pn0aH-0002fh-Fg; Thu, 13 Apr 2023 13:18:10 -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 1pn0aB-0002fL-1O for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2023 13:18:03 -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 1pn0aA-0000jg-J5 for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2023 13:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pn0aA-0004hy-Ea for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2023 13:18: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 17:18: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.168140624318048 (code B ref 62800); Thu, 13 Apr 2023 17:18:02 +0000 Original-Received: (at 62800) by debbugs.gnu.org; 13 Apr 2023 17:17:23 +0000 Original-Received: from localhost ([127.0.0.1]:44639 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pn0ZT-0004gy-HL for submit@debbugs.gnu.org; Thu, 13 Apr 2023 13:17:22 -0400 Original-Received: from mout-p-102.mailbox.org ([80.241.56.152]:47564) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pn0ZF-0004gC-9h for 62800@debbugs.gnu.org; Thu, 13 Apr 2023 13:17:18 -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-102.mailbox.org (Postfix) with ESMTPS id 4Py5px0sdzz9sTr; Thu, 13 Apr 2023 19:16:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1681406217; 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=QvF2auY7KUcVDRl3CT/StqkyVCQYFrzonxzNTJ90hJg=; b=YZiQ0N9u39rdetFjQmQTudeR6NMhbBnpBXfgWoltw0yHermImEglT5Q1m5vvoE9xSFOSBR q5UhKitqhKpPH0miJzXWlFExBSfa6mtVkADE6riUwSn4o+h8ppkfipdzUGWl0PZ6s1Ot5I 3W/yuUN28E6AUz2q488sMce9o00HmQ200Sigkf0Z4uHl6FM2r6bNXrsnpyGGax8wOSPMpC FPTAeWXrBHBqE0U3mvLIn7L5iqFxw5MONPTO2fxtxBbHPVk7hecuiv8OD5ShCgHXh1AnLa XQWVCQqjP/wW2CRklYAX+4LV8Bh4QkDIjXZ3Q97CAPSxrrmdhZnAUmaf31bDeA== In-Reply-To: <86jzygjndv.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 13 Apr 2023 09:40:28 +0300") X-MBO-RS-ID: 38c13743349b1a042c7 X-MBO-RS-META: kgchmgtk315whed4gwi53ms35nb44q9e 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:259871 Archived-At: --=-=-= Content-Type: text/plain Juri Linkov writes: >>> Emacs 29 has a new command 'minibuffer-complete-history' >>> that completes on the history. >> >> I don't understand. The patch adds the ability to use >> minibuffer-complete-history by pressing the TAB key while typing a >> URL. The behavior I'm seeing now (in version 29.0.50), is when I type in >> a URL and press tab, instead of completing, it inserts a tab >> character. > > I just noted that this is already possible by typing less convenient key > 'C-x up'. But if you think 'TAB' could do the same, this is fine. > Maybe even eww-suggested-uris could be added to the list of history > completions as well. Because browsers show completions not only for > previously visited urls from the history, but also for suggested urls. New patches are attached. The first adds tab completion and is just slightly reworded. The second adds "eww-suggested-uris" to the completion options, and adds bookmark URIs to the "eww-suggest-uris" list, since browsers suggest bookmarks too. If there is "http://example.com" in the bookmarks, and "example.com" in the history, both will be provided as a completion. I think this behavior is correct because those two URLs may not point to the same place, but browsers sometimes remove the URL scheme component and assume http:// or https://. I don't think matching that behavior would be good so I didn't implement it. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=v3-0001-eww-Enable-completion-in-URL-keyword-prompt.patch >From c2e4f72f21af20afdc2fc2f5ebe6bffcb61c2f5d Mon Sep 17 00:00:00 2001 From: Antero Mejr Date: Wed, 12 Apr 2023 17:56:01 +0000 Subject: [PATCH v3 1/2] 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..2df0d969991 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' URL or keyword prompt now has tab completion. +The interactive minibuffer prompt when invoking 'eww' now has support +for tab 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=v3-0002-eww-Provide-completions-for-bookmarks-and-suggest.patch >From 1c635c024a9b7e01c29704af0939c7a39583ee9c Mon Sep 17 00:00:00 2001 From: Antero Mejr Date: Thu, 13 Apr 2023 15:59:54 +0000 Subject: [PATCH v3 2/2] eww: Provide completions for bookmarks and suggested URIs. * lisp/net/eww.el (eww): Add the result of 'eww-suggest-uris' to the completion collection argument. (eww-bookmark-urls): New procedure. (eww-suggest-uris): Add "eww-bookmark-urls" to the default list. * etc/NEWS (EWW): Add NEWS entry for the change. --- etc/NEWS | 6 ++++++ lisp/net/eww.el | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 2df0d969991..41880208c7e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -224,6 +224,12 @@ activate this behavior. The interactive minibuffer prompt when invoking 'eww' now has support for tab completion. ++++ +*** 'eww' URL and keyword prompt now completes suggested URIs and bookmarks. +The interactive minibuffer prompt when invoking 'eww' now provides +completions from 'eww-suggest-uris'. 'eww-suggest-uris' now includes +bookmark URIs. + ** go-ts-mode +++ diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 7f0c9167c6a..48a1813c92d 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -94,7 +94,8 @@ no parameters) that returns a directory name." (defcustom eww-suggest-uris '(eww-links-at-point thing-at-point-url-at-point - eww-current-url) + eww-current-url + eww-bookmark-urls) "List of functions called to form the list of default URIs for `eww'. Each of the elements is a function returning either a string or a list of strings. The results will be joined into a single list with @@ -104,7 +105,8 @@ duplicate entries (if any) removed." :type 'hook :options '(eww-links-at-point thing-at-point-url-at-point - eww-current-url)) + eww-current-url + eww-bookmark-urls)) (defcustom eww-bookmarks-directory user-emacs-directory "Directory where bookmark files will be stored." @@ -387,8 +389,8 @@ For more information, see Info node `(eww) Top'." (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) + (seq-uniq (append eww-prompt-history uris)) + nil nil nil 'eww-prompt-history uris) current-prefix-arg))) (setq url (eww--dwim-expand-url url)) (pop-to-buffer-same-window @@ -2235,6 +2237,12 @@ If ERROR-OUT, signal user-error if there are no bookmarks." 'eww-bookmark))) (eww-browse-url (plist-get bookmark :url)))) +(defun eww-bookmark-urls () + "Get the URLs from the current list of bookmarks." + (interactive nil eww-boomark-mode) + (eww-read-bookmarks) + (mapcar (lambda (x) (plist-get x :url)) eww-bookmarks)) + (defvar-keymap eww-bookmark-mode-map "C-k" #'eww-bookmark-kill "C-y" #'eww-bookmark-yank -- 2.39.2 --=-=-=--