summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2018-10-01 16:53:03 +0200
committerFlorian Bruhin <me@the-compiler.org>2018-10-01 16:54:02 +0200
commit8a7c1b66a476bac0e951dc27308c5cb904c950c4 (patch)
treef2150b442923df0777b325bfc366967478165110
parent8f33b89a57f44447947007699677d539e210a756 (diff)
downloadqutebrowser-8a7c1b66a476bac0e951dc27308c5cb904c950c4.tar.gz
qutebrowser-8a7c1b66a476bac0e951dc27308c5cb904c950c4.zip
Add :tab-{give,take} --keep
-rw-r--r--doc/changelog.asciidoc2
-rw-r--r--doc/help/commands.asciidoc10
-rw-r--r--qutebrowser/browser/commands.py14
3 files changed, 19 insertions, 7 deletions
diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc
index 66c20f0ad..c6b7843c7 100644
--- a/doc/changelog.asciidoc
+++ b/doc/changelog.asciidoc
@@ -85,6 +85,8 @@ Changed
- '@@' now repeats the last run macro.
- The `content.host_blocking.lists` setting now accepts a `file://` URL to a
directory, and reads all files in that directory.
+- The `:tab-give` and `:tab-take` command now have a new flag `--keep` which
+ causes them to keep the old tab around.
Fixed
~~~~~
diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc
index 9632f6331..a9494f8b3 100644
--- a/doc/help/commands.asciidoc
+++ b/doc/help/commands.asciidoc
@@ -1261,7 +1261,7 @@ The tab index to focus, starting with 1.
[[tab-give]]
=== tab-give
-Syntax: +:tab-give ['win-id']+
+Syntax: +:tab-give [*--keep*] ['win-id']+
Give the current tab to a new or existing window if win_id given.
@@ -1270,6 +1270,9 @@ If no win_id is given, the tab will get detached into a new window.
==== positional arguments
* +'win-id'+: The window ID of the window to give the current tab to.
+==== optional arguments
+* +*-k*+, +*--keep*+: If given, keep the old tab around.
+
==== count
Overrides win_id (index starts at 1 for win_id=0).
@@ -1334,7 +1337,7 @@ How many tabs to switch back.
[[tab-take]]
=== tab-take
-Syntax: +:tab-take 'index'+
+Syntax: +:tab-take [*--keep*] 'index'+
Take a tab from another window.
@@ -1342,6 +1345,9 @@ Take a tab from another window.
* +'index'+: The [win_id/]index of the tab to take. Or a substring in which case the closest match will be taken.
+==== optional arguments
+* +*-k*+, +*--keep*+: If given, keep the old tab around.
+
==== note
* This command does not split arguments after the last argument and handles quotes literally.
diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py
index d4e896cf7..2c34d61da 100644
--- a/qutebrowser/browser/commands.py
+++ b/qutebrowser/browser/commands.py
@@ -493,12 +493,13 @@ class CommandDispatcher:
@cmdutils.register(instance='command-dispatcher', scope='window',
maxsplit=0)
@cmdutils.argument('index', completion=miscmodels.other_buffer)
- def tab_take(self, index):
+ def tab_take(self, index, keep=False):
"""Take a tab from another window.
Args:
index: The [win_id/]index of the tab to take. Or a substring
in which case the closest match will be taken.
+ keep: If given, keep the old tab around.
"""
tabbed_browser, tab = self._resolve_buffer_index(index)
@@ -506,18 +507,20 @@ class CommandDispatcher:
raise cmdexc.CommandError("Can't take a tab from the same window")
self._open(tab.url(), tab=True)
- tabbed_browser.close_tab(tab, add_undo=False)
+ if not keep:
+ tabbed_browser.close_tab(tab, add_undo=False)
@cmdutils.register(instance='command-dispatcher', scope='window')
@cmdutils.argument('win_id', completion=miscmodels.window)
@cmdutils.argument('count', count=True)
- def tab_give(self, win_id: int = None, count=None):
+ def tab_give(self, win_id: int = None, keep=False, count=None):
"""Give the current tab to a new or existing window if win_id given.
If no win_id is given, the tab will get detached into a new window.
Args:
win_id: The window ID of the window to give the current tab to.
+ keep: If given, keep the old tab around.
count: Overrides win_id (index starts at 1 for win_id=0).
"""
if count is not None:
@@ -527,7 +530,7 @@ class CommandDispatcher:
raise cmdexc.CommandError("Can't give a tab to the same window")
if win_id is None:
- if self._count() < 2:
+ if self._count() < 2 and not keep:
raise cmdexc.CommandError("Cannot detach from a window with "
"only one tab")
@@ -542,7 +545,8 @@ class CommandDispatcher:
window=win_id)
tabbed_browser.tabopen(self._current_url())
- self._tabbed_browser.close_tab(self._current_widget(), add_undo=False)
+ if not keep:
+ self._tabbed_browser.close_tab(self._current_widget(), add_undo=False)
def _back_forward(self, tab, bg, window, count, forward):
"""Helper function for :back/:forward."""