From: Juri Linkov <juri@linkov.net>
To: 37592@debbugs.gnu.org
Subject: bug#37592: Using tabs in EWW
Date: Wed, 02 Oct 2019 23:31:17 +0300 [thread overview]
Message-ID: <87r23uga96.fsf@mail.linkov.net> (raw)
[-- 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."
next reply other threads:[~2019-10-02 20:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-02 20:31 Juri Linkov [this message]
2019-10-02 21:20 ` bug#37592: Using tabs in EWW 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
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=87r23uga96.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=37592@debbugs.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.