Handle sessions starting with _ as internal.
:session-{load,save,delete} now refuses to handle sessions starting with _, unless a new -f/--force parameter is given.
This commit is contained in:
parent
840652f396
commit
1fb848249e
@ -406,16 +406,20 @@ Search for a text on the current page.
|
||||
|
||||
[[session-delete]]
|
||||
=== session-delete
|
||||
Syntax: +:session-delete 'name'+
|
||||
Syntax: +:session-delete [*--force*] 'name'+
|
||||
|
||||
Delete a session.
|
||||
|
||||
==== positional arguments
|
||||
* +'name'+: The name of the session.
|
||||
|
||||
==== optional arguments
|
||||
* +*-f*+, +*--force*+: Force deleting internal sessions (starting with an underline).
|
||||
|
||||
|
||||
[[session-load]]
|
||||
=== session-load
|
||||
Syntax: +:session-load [*--clear*] 'name'+
|
||||
Syntax: +:session-load [*--clear*] [*--force*] 'name'+
|
||||
|
||||
Load a session.
|
||||
|
||||
@ -424,10 +428,12 @@ Load a session.
|
||||
|
||||
==== optional arguments
|
||||
* +*-c*+, +*--clear*+: Close all existing windows.
|
||||
* +*-f*+, +*--force*+: Force loading internal sessions (starting with an underline).
|
||||
|
||||
|
||||
[[session-save]]
|
||||
=== session-save
|
||||
Syntax: +:session-save [*--quiet*] ['name']+
|
||||
Syntax: +:session-save [*--quiet*] [*--force*] ['name']+
|
||||
|
||||
Save a session.
|
||||
|
||||
@ -436,6 +442,7 @@ Save a session.
|
||||
|
||||
==== optional arguments
|
||||
* +*-q*+, +*--quiet*+: Don't show confirmation message.
|
||||
* +*-f*+, +*--force*+: Force saving internal sessions (starting with an underline).
|
||||
|
||||
[[set]]
|
||||
=== set
|
||||
|
@ -261,13 +261,18 @@ class SessionManager(QObject):
|
||||
|
||||
@cmdutils.register(completion=[usertypes.Completion.sessions],
|
||||
instance='session-manager')
|
||||
def session_load(self, name, clear=False):
|
||||
def session_load(self, name, clear=False, force=False):
|
||||
"""Load a session.
|
||||
|
||||
Args:
|
||||
name: The name of the session.
|
||||
clear: Close all existing windows.
|
||||
force: Force loading internal sessions (starting with an
|
||||
underline).
|
||||
"""
|
||||
if name.startswith('_') and not force:
|
||||
raise cmdexc.CommandError("{!r} is an internal session, use "
|
||||
"--force to load anyways.".format(name))
|
||||
old_windows = list(objreg.window_registry.values())
|
||||
try:
|
||||
self.load(name)
|
||||
@ -285,14 +290,18 @@ class SessionManager(QObject):
|
||||
completion=[usertypes.Completion.sessions],
|
||||
instance='session-manager')
|
||||
def session_save(self, win_id: {'special': 'win_id'}, name='default',
|
||||
quiet=False):
|
||||
quiet=False, force=False):
|
||||
"""Save a session.
|
||||
|
||||
Args:
|
||||
win_id: The current window ID.
|
||||
name: The name of the session.
|
||||
quiet: Don't show confirmation message.
|
||||
force: Force saving internal sessions (starting with an underline).
|
||||
"""
|
||||
if name.startswith('_') and not force:
|
||||
raise cmdexc.CommandError("{!r} is an internal session, use "
|
||||
"--force to save anyways.".format(name))
|
||||
try:
|
||||
self.save(name)
|
||||
except SessionError as e:
|
||||
@ -305,12 +314,18 @@ class SessionManager(QObject):
|
||||
|
||||
@cmdutils.register(completion=[usertypes.Completion.sessions],
|
||||
instance='session-manager')
|
||||
def session_delete(self, name):
|
||||
def session_delete(self, name, force=False):
|
||||
"""Delete a session.
|
||||
|
||||
Args:
|
||||
name: The name of the session.
|
||||
force: Force deleting internal sessions (starting with an
|
||||
underline).
|
||||
"""
|
||||
if name.startswith('_') and not force:
|
||||
raise cmdexc.CommandError("{!r} is an internal session, use "
|
||||
"--force to delete anyways.".format(
|
||||
name))
|
||||
try:
|
||||
self.delete(name)
|
||||
except OSError as e:
|
||||
|
Loading…
Reference in New Issue
Block a user