* bug#37592: Using tabs in EWW
@ 2019-10-02 20:31 Juri Linkov
2019-10-02 21:20 ` Juri Linkov
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Juri Linkov @ 2019-10-02 20:31 UTC (permalink / raw)
To: 37592
[-- Attachment #1: Type: text/plain, Size: 611 bytes --]
Severity: wishlist
Tags: patch
Like <C-mouse-1> in web browsers opens links in a new tab,
the attached patch does the same for EWW.
The change that implements support for tabs in EWW is just 3 lines:
(when eww-browse-url-new-window-is-tab
(let ((tab-bar-new-tab-choice t))
(tab-new)))
Everything else is replicating the existing code:
1. A new defcustom eww-browse-url-new-window-is-tab is a copy
of existing browse-url-firefox-new-window-is-tab
2. The docstring for eww-browse-url is copied from browse-url-firefox
3. The code for shr-browse-url is copied from browse-url-at-point
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: eww-tabs.patch --]
[-- Type: text/x-diff, Size: 2836 bytes --]
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index fb495a9858..a39f8b87cc 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -876,9 +876,32 @@ eww-mode
(buffer-disable-undo)
(setq buffer-read-only t))
+(defcustom eww-browse-url-new-window-is-tab nil
+ "Whether to open up new windows in a tab or a new buffer.
+If non-nil, then open the URL in a new tab rather than a new buffer if
+`eww-browse-url' is asked to open it in a new window."
+ :version "27.1"
+ :group 'eww
+ :type 'boolean)
+
;;;###autoload
(defun eww-browse-url (url &optional new-window)
+ "Ask the EWW browser to load URL.
+
+Interactively, if the variable `browse-url-new-window-flag' is non-nil,
+loads the document in a new buffer tab on the window tab-line. A non-nil
+prefix argument reverses the effect of `browse-url-new-window-flag'.
+
+If `eww-browse-url-new-window-is-tab' is non-nil, then
+whenever a document would otherwise be loaded in a new buffer, it
+is loaded in a new tab in the tab-bar on an existing frame.
+
+Non-interactively, this uses the optional second argument NEW-WINDOW
+instead of `browse-url-new-window-flag'."
(when new-window
+ (when eww-browse-url-new-window-is-tab
+ (let ((tab-bar-new-tab-choice t))
+ (tab-new)))
(pop-to-buffer-same-window
(generate-new-buffer
(format "*eww-%s*" (url-host (url-generic-parse-url
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index ef236bf7c4..390be4deff 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -201,6 +201,7 @@ shr-map
(define-key map [?\M-\t] 'shr-previous-link)
(define-key map [follow-link] 'mouse-face)
(define-key map [mouse-2] 'shr-browse-url)
+ (define-key map [C-down-mouse-1] 'shr-mouse-browse-url-new-window)
(define-key map "I" 'shr-insert-image)
(define-key map "w" 'shr-maybe-probe-and-copy-url)
(define-key map "u" 'shr-maybe-probe-and-copy-url)
@@ -967,7 +968,13 @@ shr-mouse-browse-url
(mouse-set-point ev)
(shr-browse-url))
-(defun shr-browse-url (&optional external mouse-event)
+(defun shr-mouse-browse-url-new-window (ev)
+ "Browse the URL under the mouse cursor in a new window."
+ (interactive "e")
+ (mouse-set-point ev)
+ (shr-browse-url nil nil t))
+
+(defun shr-browse-url (&optional external mouse-event new-window)
"Browse the URL at point using `browse-url'.
If EXTERNAL is non-nil (interactively, the prefix argument), browse
the URL using `browse-url-secondary-browser-function'.
@@ -987,7 +994,9 @@ shr-browse-url
(progn
(funcall browse-url-secondary-browser-function url)
(shr--blink-link))
- (browse-url url))))))
+ (browse-url url (if new-window
+ (not browse-url-new-window-flag)
+ browse-url-new-window-flag)))))))
(defun shr-save-contents (directory)
"Save the contents from URL in a file."
^ permalink raw reply related [flat|nested] 11+ messages in thread
* bug#37592: Using tabs in EWW
2019-10-02 20:31 bug#37592: Using tabs in EWW Juri Linkov
@ 2019-10-02 21:20 ` Juri Linkov
2019-10-03 2:44 ` Eli Zaretskii
2019-10-03 14:20 ` Lars Ingebrigtsen
2 siblings, 0 replies; 11+ messages in thread
From: Juri Linkov @ 2019-10-02 21:20 UTC (permalink / raw)
To: 37592
Addendum:
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index fb495a9858..88a351adb1 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -369,6 +369,9 @@ eww-open-in-new-buffer
(interactive)
(let ((url (eww-suggested-uris)))
(if (null url) (user-error "No link at point")
+ (when eww-browse-url-new-window-is-tab
+ (let ((tab-bar-new-tab-choice t))
+ (tab-new)))
;; clone useful to keep history, but
;; should not clone from non-eww buffer
(with-current-buffer
^ permalink raw reply related [flat|nested] 11+ messages in thread
* bug#37592: Using tabs in EWW
2019-10-02 20:31 bug#37592: Using tabs in EWW Juri Linkov
2019-10-02 21:20 ` Juri Linkov
@ 2019-10-03 2:44 ` Eli Zaretskii
2019-10-03 22:39 ` Juri Linkov
2019-10-03 14:20 ` Lars Ingebrigtsen
2 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2019-10-03 2:44 UTC (permalink / raw)
To: Juri Linkov; +Cc: 37592
> From: Juri Linkov <juri@linkov.net>
> Date: Wed, 02 Oct 2019 23:31:17 +0300
>
> Like <C-mouse-1> in web browsers opens links in a new tab,
> the attached patch does the same for EWW.
>
> The change that implements support for tabs in EWW is just 3 lines:
>
> (when eww-browse-url-new-window-is-tab
> (let ((tab-bar-new-tab-choice t))
> (tab-new)))
>
> Everything else is replicating the existing code:
>
> 1. A new defcustom eww-browse-url-new-window-is-tab is a copy
> of existing browse-url-firefox-new-window-is-tab
>
> 2. The docstring for eww-browse-url is copied from browse-url-firefox
>
> 3. The code for shr-browse-url is copied from browse-url-at-point
Instead of adding another defcustom, how about doing this by default
if tab-bar-mode is enabled?
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#37592: Using tabs in EWW
2019-10-02 20:31 bug#37592: Using tabs in EWW Juri Linkov
2019-10-02 21:20 ` Juri Linkov
2019-10-03 2:44 ` Eli Zaretskii
@ 2019-10-03 14:20 ` Lars Ingebrigtsen
2 siblings, 0 replies; 11+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-03 14:20 UTC (permalink / raw)
To: Juri Linkov; +Cc: 37592
Juri Linkov <juri@linkov.net> writes:
> Like <C-mouse-1> in web browsers opens links in a new tab,
> the attached patch does the same for EWW.
Sounds good -- in addition to adding this command and key binding, the
rest of the code deals with whether "new window" means "new buffer" (as
it does today) or whether it should mean "new tab"? As Eli pointed out,
perhaps that should be determined by whether tab-bar-mode is on or off?
Otherwise, it looks fine to me.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#37592: Using tabs in EWW
2019-10-03 2:44 ` Eli Zaretskii
@ 2019-10-03 22:39 ` Juri Linkov
2019-10-04 7:34 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2019-10-03 22:39 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 37592
>> Like <C-mouse-1> in web browsers opens links in a new tab,
>> the attached patch does the same for EWW.
>>
>> The change that implements support for tabs in EWW is just 3 lines:
>>
>> (when eww-browse-url-new-window-is-tab
>> (let ((tab-bar-new-tab-choice t))
>> (tab-new)))
>>
>> Everything else is replicating the existing code:
>>
>> 1. A new defcustom eww-browse-url-new-window-is-tab is a copy
>> of existing browse-url-firefox-new-window-is-tab
>>
>> 2. The docstring for eww-browse-url is copied from browse-url-firefox
>>
>> 3. The code for shr-browse-url is copied from browse-url-at-point
>
> Instead of adding another defcustom, how about doing this by default
> if tab-bar-mode is enabled?
I guess the users still need to decide whether they want to open
new tabs in the tab-bar (when eww-browse-url-new-window-is-tab is non-nil),
or new tabs in the tab-line (when eww-browse-url-new-window-is-tab is nil)
that just creates a new buffer displayed in the window-local tab-line -
this is the current behavior.
Another use case is that when tab-bar-mode is not yet enabled,
users migth prefer that clicking on a link with a Ctrl key
could enable the tab-bar and open a new tab in automatically
enabled tab-bar.
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#37592: Using tabs in EWW
2019-10-03 22:39 ` Juri Linkov
@ 2019-10-04 7:34 ` Eli Zaretskii
2019-10-05 22:35 ` Juri Linkov
2019-10-19 22:40 ` Juri Linkov
0 siblings, 2 replies; 11+ messages in thread
From: Eli Zaretskii @ 2019-10-04 7:34 UTC (permalink / raw)
To: Juri Linkov; +Cc: 37592
> From: Juri Linkov <juri@linkov.net>
> Cc: 37592@debbugs.gnu.org
> Date: Fri, 04 Oct 2019 01:39:42 +0300
>
> > Instead of adding another defcustom, how about doing this by default
> > if tab-bar-mode is enabled?
>
> I guess the users still need to decide whether they want to open
> new tabs in the tab-bar (when eww-browse-url-new-window-is-tab is non-nil),
> or new tabs in the tab-line (when eww-browse-url-new-window-is-tab is nil)
> that just creates a new buffer displayed in the window-local tab-line -
> this is the current behavior.
>
> Another use case is that when tab-bar-mode is not yet enabled,
> users migth prefer that clicking on a link with a Ctrl key
> could enable the tab-bar and open a new tab in automatically
> enabled tab-bar.
It seems to me that there are sensible defaults in each of these
situations, and we could use those defaults unconditionally until
users complained.
Adding too many user options has a downside as well, you know.
Just one opinion.
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#37592: Using tabs in EWW
2019-10-04 7:34 ` Eli Zaretskii
@ 2019-10-05 22:35 ` Juri Linkov
2019-10-06 17:22 ` Eli Zaretskii
2019-10-06 20:06 ` Lars Ingebrigtsen
2019-10-19 22:40 ` Juri Linkov
1 sibling, 2 replies; 11+ messages in thread
From: Juri Linkov @ 2019-10-05 22:35 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 37592
[-- Attachment #1: Type: text/plain, Size: 990 bytes --]
>> > Instead of adding another defcustom, how about doing this by default
>> > if tab-bar-mode is enabled?
>>
>> I guess the users still need to decide whether they want to open
>> new tabs in the tab-bar (when eww-browse-url-new-window-is-tab is non-nil),
>> or new tabs in the tab-line (when eww-browse-url-new-window-is-tab is nil)
>> that just creates a new buffer displayed in the window-local tab-line -
>> this is the current behavior.
>>
>> Another use case is that when tab-bar-mode is not yet enabled,
>> users migth prefer that clicking on a link with a Ctrl key
>> could enable the tab-bar and open a new tab in automatically
>> enabled tab-bar.
>
> It seems to me that there are sensible defaults in each of these
> situations, and we could use those defaults unconditionally until
> users complained.
>
> Adding too many user options has a downside as well, you know.
>
> Just one opinion.
I agree, let's try this heuristics to open new tabs
when tab-bar-mode is enabled:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: eww-tabs.2.patch --]
[-- Type: text/x-diff, Size: 3408 bytes --]
diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi
index b8821cbc29..d0a4c9a790 100644
--- a/doc/misc/eww.texi
+++ b/doc/misc/eww.texi
@@ -105,7 +105,10 @@ Basics
@kindex M-RET
The @kbd{M-@key{RET}} command (@code{eww-open-in-new-buffer}) opens the
URL at point in a new EWW buffer, akin to opening a link in a new
-``tab'' in other browsers.
+``tab'' in other browsers. When @code{global-tab-line-mode} is
+enabled, this buffer is displayed in the tab on the window tab line.
+When @code{tab-bar-mode} is enabled, a new tab is created on the frame
+tab bar.
@findex eww-readable
@kindex R
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index fb495a9858..0756c6088b 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -369,6 +369,9 @@ eww-open-in-new-buffer
(interactive)
(let ((url (eww-suggested-uris)))
(if (null url) (user-error "No link at point")
+ (when tab-bar-mode
+ (let ((tab-bar-new-tab-choice t))
+ (tab-new)))
;; clone useful to keep history, but
;; should not clone from non-eww buffer
(with-current-buffer
@@ -878,7 +881,22 @@ eww-mode
;;;###autoload
(defun eww-browse-url (url &optional new-window)
+ "Ask the EWW browser to load URL.
+
+Interactively, if the variable `browse-url-new-window-flag' is non-nil,
+loads the document in a new buffer tab on the window tab-line. A non-nil
+prefix argument reverses the effect of `browse-url-new-window-flag'.
+
+If `tab-bar-mode' is enabled, then whenever a document would
+otherwise be loaded in a new buffer, it is loaded in a new tab
+in the tab-bar on an existing frame.
+
+Non-interactively, this uses the optional second argument NEW-WINDOW
+instead of `browse-url-new-window-flag'."
(when new-window
+ (when tab-bar-mode
+ (let ((tab-bar-new-tab-choice t))
+ (tab-new)))
(pop-to-buffer-same-window
(generate-new-buffer
(format "*eww-%s*" (url-host (url-generic-parse-url
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 628cc17a5b..f3d5de9fb6 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -201,6 +201,7 @@ shr-map
(define-key map [?\M-\t] 'shr-previous-link)
(define-key map [follow-link] 'mouse-face)
(define-key map [mouse-2] 'shr-browse-url)
+ (define-key map [C-down-mouse-1] 'shr-mouse-browse-url-new-window)
(define-key map "I" 'shr-insert-image)
(define-key map "w" 'shr-maybe-probe-and-copy-url)
(define-key map "u" 'shr-maybe-probe-and-copy-url)
@@ -967,7 +968,13 @@ shr-mouse-browse-url
(mouse-set-point ev)
(shr-browse-url))
-(defun shr-browse-url (&optional external mouse-event)
+(defun shr-mouse-browse-url-new-window (ev)
+ "Browse the URL under the mouse cursor in a new window."
+ (interactive "e")
+ (mouse-set-point ev)
+ (shr-browse-url nil nil t))
+
+(defun shr-browse-url (&optional external mouse-event new-window)
"Browse the URL at point using `browse-url'.
If EXTERNAL is non-nil (interactively, the prefix argument), browse
the URL using `browse-url-secondary-browser-function'.
@@ -987,7 +994,9 @@ shr-browse-url
(progn
(funcall browse-url-secondary-browser-function url)
(shr--blink-link))
- (browse-url url))))))
+ (browse-url url (if new-window
+ (not browse-url-new-window-flag)
+ browse-url-new-window-flag)))))))
(defun shr-save-contents (directory)
"Save the contents from URL in a file."
^ permalink raw reply related [flat|nested] 11+ messages in thread
* bug#37592: Using tabs in EWW
2019-10-05 22:35 ` Juri Linkov
@ 2019-10-06 17:22 ` Eli Zaretskii
2019-10-06 20:06 ` Lars Ingebrigtsen
1 sibling, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2019-10-06 17:22 UTC (permalink / raw)
To: Juri Linkov; +Cc: 37592
> From: Juri Linkov <juri@linkov.net>
> Cc: 37592@debbugs.gnu.org
> Date: Sun, 06 Oct 2019 01:35:40 +0300
>
> > It seems to me that there are sensible defaults in each of these
> > situations, and we could use those defaults unconditionally until
> > users complained.
> >
> > Adding too many user options has a downside as well, you know.
> >
> > Just one opinion.
>
> I agree, let's try this heuristics to open new tabs
> when tab-bar-mode is enabled:
LGTM, thanks. It is probably a NEWS-worthy change.
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#37592: Using tabs in EWW
2019-10-05 22:35 ` Juri Linkov
2019-10-06 17:22 ` Eli Zaretskii
@ 2019-10-06 20:06 ` Lars Ingebrigtsen
2019-10-06 21:08 ` Juri Linkov
1 sibling, 1 reply; 11+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-06 20:06 UTC (permalink / raw)
To: Juri Linkov; +Cc: 37592
Juri Linkov <juri@linkov.net> writes:
> I agree, let's try this heuristics to open new tabs
> when tab-bar-mode is enabled:
Looks good to me, too.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#37592: Using tabs in EWW
2019-10-06 20:06 ` Lars Ingebrigtsen
@ 2019-10-06 21:08 ` Juri Linkov
0 siblings, 0 replies; 11+ messages in thread
From: Juri Linkov @ 2019-10-06 21:08 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 37592-done
>> I agree, let's try this heuristics to open new tabs
>> when tab-bar-mode is enabled:
>
> Looks good to me, too.
I also updated the Info documentation on opening tabs by 'C-u RET'.
but can't find a suitable place to describe using tabs on clicking
with the Ctrl key, because currently the EWW documentation has
no mentions of mouse commands.
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#37592: Using tabs in EWW
2019-10-04 7:34 ` Eli Zaretskii
2019-10-05 22:35 ` Juri Linkov
@ 2019-10-19 22:40 ` Juri Linkov
1 sibling, 0 replies; 11+ messages in thread
From: Juri Linkov @ 2019-10-19 22:40 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 37592
>> > Instead of adding another defcustom, how about doing this by default
>> > if tab-bar-mode is enabled?
>>
>> I guess the users still need to decide whether they want to open
>> new tabs in the tab-bar (when eww-browse-url-new-window-is-tab is non-nil),
>> or new tabs in the tab-line (when eww-browse-url-new-window-is-tab is nil)
>> that just creates a new buffer displayed in the window-local tab-line -
>> this is the current behavior.
>>
>> Another use case is that when tab-bar-mode is not yet enabled,
>> users migth prefer that clicking on a link with a Ctrl key
>> could enable the tab-bar and open a new tab in automatically
>> enabled tab-bar.
>
> It seems to me that there are sensible defaults in each of these
> situations, and we could use those defaults unconditionally until
> users complained.
Users complained, so I added that defcustom.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2019-10-19 22:40 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-02 20:31 bug#37592: Using tabs in EWW Juri Linkov
2019-10-02 21:20 ` Juri Linkov
2019-10-03 2:44 ` Eli Zaretskii
2019-10-03 22:39 ` Juri Linkov
2019-10-04 7:34 ` Eli Zaretskii
2019-10-05 22:35 ` Juri Linkov
2019-10-06 17:22 ` Eli Zaretskii
2019-10-06 20:06 ` Lars Ingebrigtsen
2019-10-06 21:08 ` Juri Linkov
2019-10-19 22:40 ` Juri Linkov
2019-10-03 14:20 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).