From d9a3c8974f9690e68d34a261bde58fb465750908 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Sun, 20 Oct 2019 01:40:05 +0300 Subject: [PATCH] * lisp/net/eww.el (eww-browse-url-new-window-is-tab): New defcustom. (eww-open-in-new-buffer, eww-browse-url): Use new defcustom (bug#37592). --- lisp/net/eww.el | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index f5dedd52b2e..dccaf0497f8 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -128,6 +128,18 @@ The string will be passed through `substitute-command-keys'." :type '(choice (const :tag "Never" nil) regexp)) +(defcustom eww-browse-url-new-window-is-tab 'tab-bar + "Whether to open up new windows in a tab or a new buffer. +If t, 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. +If `tab-bar', then open the URL in a new tab only when +the tab bar is enabled." + :version "27.1" + :group 'eww + :type '(choice (const :tag "Always open URL in new tab" t) + (const :tag "Open new tab when tab bar is enabled" tab-bar) + (const :tag "Never open URL in new tab" nil))) + (defcustom eww-after-render-hook nil "A hook called after eww has finished rendering the buffer." :version "25.1" @@ -369,7 +381,9 @@ engine used." (interactive) (let ((url (eww-suggested-uris))) (if (null url) (user-error "No link at point") - (when tab-bar-mode + (when (or (eq eww-browse-url-new-window-is-tab t) + (and (eq eww-browse-url-new-window-is-tab 'tab-bar) + tab-bar-mode)) (let ((tab-bar-new-tab-choice t)) (tab-new))) ;; clone useful to keep history, but @@ -889,12 +903,15 @@ 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. +in the tab-bar on an existing frame. See more options in +`eww-browse-url-new-window-is-tab'. Non-interactively, this uses the optional second argument NEW-WINDOW instead of `browse-url-new-window-flag'." (when new-window - (when tab-bar-mode + (when (or (eq eww-browse-url-new-window-is-tab t) + (and (eq eww-browse-url-new-window-is-tab 'tab-bar) + tab-bar-mode)) (let ((tab-bar-new-tab-choice t)) (tab-new))) (pop-to-buffer-same-window -- 2.39.2