Add :tab-{give,take} --keep
This commit is contained in:
parent
8f33b89a57
commit
8a7c1b66a4
@ -85,6 +85,8 @@ Changed
|
|||||||
- '@@' now repeats the last run macro.
|
- '@@' now repeats the last run macro.
|
||||||
- The `content.host_blocking.lists` setting now accepts a `file://` URL to a
|
- The `content.host_blocking.lists` setting now accepts a `file://` URL to a
|
||||||
directory, and reads all files in that directory.
|
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
|
Fixed
|
||||||
~~~~~
|
~~~~~
|
||||||
|
@ -1261,7 +1261,7 @@ The tab index to focus, starting with 1.
|
|||||||
|
|
||||||
[[tab-give]]
|
[[tab-give]]
|
||||||
=== 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.
|
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
|
==== positional arguments
|
||||||
* +'win-id'+: The window ID of the window to give the current tab to.
|
* +'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
|
==== count
|
||||||
Overrides win_id (index starts at 1 for win_id=0).
|
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]]
|
||||||
=== tab-take
|
=== tab-take
|
||||||
Syntax: +:tab-take 'index'+
|
Syntax: +:tab-take [*--keep*] 'index'+
|
||||||
|
|
||||||
Take a tab from another window.
|
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.
|
* +'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
|
==== note
|
||||||
* This command does not split arguments after the last argument and handles quotes literally.
|
* This command does not split arguments after the last argument and handles quotes literally.
|
||||||
|
|
||||||
|
@ -493,12 +493,13 @@ class CommandDispatcher:
|
|||||||
@cmdutils.register(instance='command-dispatcher', scope='window',
|
@cmdutils.register(instance='command-dispatcher', scope='window',
|
||||||
maxsplit=0)
|
maxsplit=0)
|
||||||
@cmdutils.argument('index', completion=miscmodels.other_buffer)
|
@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.
|
"""Take a tab from another window.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
index: The [win_id/]index of the tab to take. Or a substring
|
index: The [win_id/]index of the tab to take. Or a substring
|
||||||
in which case the closest match will be taken.
|
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)
|
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")
|
raise cmdexc.CommandError("Can't take a tab from the same window")
|
||||||
|
|
||||||
self._open(tab.url(), tab=True)
|
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.register(instance='command-dispatcher', scope='window')
|
||||||
@cmdutils.argument('win_id', completion=miscmodels.window)
|
@cmdutils.argument('win_id', completion=miscmodels.window)
|
||||||
@cmdutils.argument('count', count=True)
|
@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.
|
"""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.
|
If no win_id is given, the tab will get detached into a new window.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
win_id: The window ID of the window to give the current tab to.
|
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).
|
count: Overrides win_id (index starts at 1 for win_id=0).
|
||||||
"""
|
"""
|
||||||
if count is not None:
|
if count is not None:
|
||||||
@ -527,7 +530,7 @@ class CommandDispatcher:
|
|||||||
raise cmdexc.CommandError("Can't give a tab to the same window")
|
raise cmdexc.CommandError("Can't give a tab to the same window")
|
||||||
|
|
||||||
if win_id is None:
|
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 "
|
raise cmdexc.CommandError("Cannot detach from a window with "
|
||||||
"only one tab")
|
"only one tab")
|
||||||
|
|
||||||
@ -542,7 +545,8 @@ class CommandDispatcher:
|
|||||||
window=win_id)
|
window=win_id)
|
||||||
|
|
||||||
tabbed_browser.tabopen(self._current_url())
|
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):
|
def _back_forward(self, tab, bg, window, count, forward):
|
||||||
"""Helper function for :back/:forward."""
|
"""Helper function for :back/:forward."""
|
||||||
|
Loading…
Reference in New Issue
Block a user