From: "Göktuğ Kayaalp" <self@gkayaalp.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 34374@debbugs.gnu.org
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 [thread overview]
Message-ID: <ygm7ee9m2ab.fsf@gkayaalp.com> (raw)
In-Reply-To: <83lg2qrcur.fsf@gnu.org> (message from Eli Zaretskii on Fri, 08 Feb 2019 08:52:28 +0200)
[-- Attachment #1: Type: text/plain, Size: 3010 bytes --]
On 2019-02-08 08:52 +02, Eli Zaretskii <eliz@gnu.org> 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’t 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’m adding. EWW works
with file:// links, so generating a few temporary files and working with
them should work alright. I’m not familiar enough with Emacs TDD and
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’t have
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 ‘eww’.
I don’t 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
‘eww-list-buffers’ 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’d be confusing when calling M-x eww from some non-eww buffer,
I’d 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-net-eww.el-eww-With-prefix-arg-open-url-in-new-.patch --]
[-- Type: text/x-diff, Size: 1784 bytes --]
From b498bf557558fb0564cb35dc663378ead5076afd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=B0=2E=20G=C3=B6ktu=C4=9F=20Kayaalp?= <self@gkayaalp.com>
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
next prev parent reply other threads:[~2019-02-09 15:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-07 21:19 bug#34374: 27.0.50; Outside an eww buffer, optionally use new buffer when calling eww instead of reusing *eww* Göktuğ Kayaalp
2019-02-08 6:52 ` Eli Zaretskii
2019-02-09 15:04 ` Göktuğ Kayaalp [this message]
2019-02-15 8:35 ` Eli Zaretskii
2019-02-16 9:45 ` Göktuğ Kayaalp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ygm7ee9m2ab.fsf@gkayaalp.com \
--to=self@gkayaalp.com \
--cc=34374@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.