From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?G=C3=B6ktu=C4=9F?= Kayaalp Newsgroups: gmane.emacs.bugs Subject: bug#34374: 27.0.50; Outside an eww buffer, optionally use new buffer when calling eww instead of reusing *eww* Date: Sat, 09 Feb 2019 18:04:12 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="54335"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 34374@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 09 16:33:20 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gsUd5-000Dyz-Fc for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Feb 2019 16:33:19 +0100 Original-Received: from localhost ([127.0.0.1]:46808 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gsUd4-0002IW-Dr for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Feb 2019 10:33:18 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gsUcr-0002Hq-29 for bug-gnu-emacs@gnu.org; Sat, 09 Feb 2019 10:33:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gsUcp-0006RW-Um for bug-gnu-emacs@gnu.org; Sat, 09 Feb 2019 10:33:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42154) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gsUcp-0006RH-QJ for bug-gnu-emacs@gnu.org; Sat, 09 Feb 2019 10:33:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gsUco-0004No-Gb for bug-gnu-emacs@gnu.org; Sat, 09 Feb 2019 10:33:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?G=C3=B6ktu=C4=9F?= Kayaalp Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Feb 2019 15:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34374 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 34374-submit@debbugs.gnu.org id=B34374.154972633516793 (code B ref 34374); Sat, 09 Feb 2019 15:33:02 +0000 Original-Received: (at 34374) by debbugs.gnu.org; 9 Feb 2019 15:32:15 +0000 Original-Received: from localhost ([127.0.0.1]:41435 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gsUc3-0004Mn-2y for submit@debbugs.gnu.org; Sat, 09 Feb 2019 10:32:15 -0500 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:34385) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gsUbz-0004Mc-KW for 34374@debbugs.gnu.org; Sat, 09 Feb 2019 10:32:12 -0500 X-Originating-IP: 176.218.86.160 Original-Received: from localhost (unknown [176.218.86.160]) (Authenticated sender: self@gkayaalp.com) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id AE4CEC0004; Sat, 9 Feb 2019 15:32:07 +0000 (UTC) In-Reply-To: <83lg2qrcur.fsf@gnu.org> (message from Eli Zaretskii on Fri, 08 Feb 2019 08:52:28 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:155316 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2019-02-08 08:52 +02, Eli Zaretskii wrote: > Wouldn't it be more convenient if you could invoke eww with a prefix > argument for that? Sure, appended a patch, can add docs and news modifications to it if you like it better. >> I have manually tested the general use of EWW with this patch applied. >> But I haven=E2=80=99t found a test suite for EWW; if I missed it, I can = run it, >> or any other suggested testing. > > You could start a test suite, although testing eww should ideally work > even if no network connection is available. I can try to come up with tests for the feature I=E2=80=99m adding. EWW wo= rks with file:// links, so generating a few temporary files and working with them should work alright. I=E2=80=99m not familiar enough with Emacs TDD a= nd EWW to try add something more comprehensive though. >> Subject: [PATCH] Support not reusing *eww* buffer when navigating from a >> non-eww one > > It is best to reword this header line to be positive instead of > negative. > >> +(defcustom eww-reuse-buffer t >> + "Reuse the *eww* buffer when not in an `eww-mode' buffer." > > For a boolean option, the first line of the doc string should say > either > > Non-nil means reuse the *eww* buffer ... > > or > > Whether to reuse the *eww* buffer ... > > (the former is preferable). I can apply these to the old patch if you think that approach is better than the one in the new patch (using a prefix arg), which doesn=E2=80=99t h= ave these problems. >> +When the current buffer is not in `eww-mode', if >> +`eww-reuse-buffer' is non-nil, the *eww* buffer will be reused if >> +available, otherwise generated; if set to nil instead, a new >> +buffer will be used in case *eww* is already in use." > > Once this feature exists and is used, wouldn't it be better to program > it so it either reuses the current EWW buffer or creates a new one, > regardless of whether the current buffer's name is "*eww*"? IOW, > should we really hardcode "*eww*" in this feature? Sure. The literal "*eww*" appears only in two places, and could be replaced with a defcustom and/or an extra arg to =E2=80=98eww=E2=80=99. I don=E2=80=99t think it depends on the name of the current buffer as it is, e.g. M-x eww ... RET M-x rename-buffer somebuf RET C-u M-x eww ... RET does work, resulting in buffers *eww*, somebuf, *eww*<2>, and =E2=80=98eww-list-buffers=E2=80=99 can show a user-friendly list of buffers= . Do you mean this scenario should result in somebuf<2> instead of *eww*<2>? I think that=E2=80=99d be confusing when calling M-x eww from some non-eww bu= ffer, I=E2=80=99d rather have new names be based on the default buffer name. >> - (get-buffer-create "*eww*"))) >> + (funcall >> + (if eww-reuse-buffer #'get-buffer-create #'generate-new-buffer) >> + "*eww*"))) > > Any particular reason to use funcall here, instead of calling the > functions literally? Just to not repeat the string literal. Could definitely be replaced with a let binding. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-lisp-net-eww.el-eww-With-prefix-arg-open-url-in-new-.patch >From b498bf557558fb0564cb35dc663378ead5076afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0=2E=20G=C3=B6ktu=C4=9F=20Kayaalp?= Date: Sat, 9 Feb 2019 17:41:31 +0300 Subject: [PATCH] * lisp/net/eww.el (eww): With prefix arg, open url in new buffer --- lisp/net/eww.el | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 3b7d9d5c2f..65a75f8212 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -247,21 +247,29 @@ eww-suggested-uris (nreverse uris))) ;;;###autoload -(defun eww (url) +(defun eww (url &optional arg) "Fetch URL and render the page. If the input doesn't look like an URL or a domain name, the -word(s) will be searched for via `eww-search-prefix'." +word(s) will be searched for via `eww-search-prefix'. + +If called with a prefix ARG, use a new buffer instead of reusing +the default EWW buffer." (interactive (let* ((uris (eww-suggested-uris)) (prompt (concat "Enter URL or keywords" (if uris (format " (default %s)" (car uris)) "") ": "))) - (list (read-string prompt nil 'eww-prompt-history uris)))) + (list (read-string prompt nil 'eww-prompt-history uris) + (prefix-numeric-value current-prefix-arg)))) (setq url (eww--dwim-expand-url url)) (pop-to-buffer-same-window - (if (eq major-mode 'eww-mode) - (current-buffer) - (get-buffer-create "*eww*"))) + (cond + ((eq arg 4) + (generate-new-buffer "*eww*")) + ((eq major-mode 'eww-mode) + (current-buffer)) + (t + (get-buffer-create "*eww*")))) (eww-setup-buffer) ;; Check whether the domain only uses "Highly Restricted" Unicode ;; IDNA characters. If not, transform to punycode to indicate that -- 2.20.1 --=-=-=--