Make it possible to use :open -[twb] without url.
This commit is contained in:
parent
5f46870594
commit
561ebd07f9
@ -268,7 +268,7 @@ This tries to automatically click on typical _Previous Page_ or _Next Page_ link
|
||||
|
||||
[[open]]
|
||||
=== open
|
||||
Syntax: +:open [*--bg*] [*--tab*] [*--window*] 'url'+
|
||||
Syntax: +:open [*--bg*] [*--tab*] [*--window*] ['url']+
|
||||
|
||||
Open a URL in the current/[count]th tab.
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|<<general-ignore-case,ignore-case>>|Whether to find text on a page case-insensitively.
|
||||
|<<general-wrap-search,wrap-search>>|Whether to wrap finding text to the top when arriving at the end.
|
||||
|<<general-startpage,startpage>>|The default page(s) to open at the start, separated by commas.
|
||||
|<<general-default-page,default-page>>|The page to open if :open -t/-b/-w is used without URL.
|
||||
|<<general-auto-search,auto-search>>|Whether to start a search when something else than a URL is entered.
|
||||
|<<general-auto-save-config,auto-save-config>>|Whether to save the config automatically on quit.
|
||||
|<<general-auto-save-interval,auto-save-interval>>|How often (in milliseconds) to auto-save config/cookies/etc.
|
||||
@ -257,6 +258,12 @@ The default page(s) to open at the start, separated by commas.
|
||||
|
||||
Default: +pass:[https://www.duckduckgo.com]+
|
||||
|
||||
[[general-default-page]]
|
||||
=== default-page
|
||||
The page to open if :open -t/-b/-w is used without URL.
|
||||
|
||||
Default: +pass:[${startpage}]+
|
||||
|
||||
[[general-auto-search]]
|
||||
=== auto-search
|
||||
Whether to start a search when something else than a URL is entered.
|
||||
|
@ -281,7 +281,7 @@ class CommandDispatcher:
|
||||
@cmdutils.register(instance='command-dispatcher', name='open',
|
||||
maxsplit=0, scope='window',
|
||||
completion=[usertypes.Completion.quickmark_by_url])
|
||||
def openurl(self, url, bg=False, tab=False, window=False,
|
||||
def openurl(self, url=None, bg=False, tab=False, window=False,
|
||||
count: {'special': 'count'}=None):
|
||||
"""Open a URL in the current/[count]th tab.
|
||||
|
||||
@ -292,10 +292,17 @@ class CommandDispatcher:
|
||||
window: Open in a new window.
|
||||
count: The tab index to open the URL in, or None.
|
||||
"""
|
||||
try:
|
||||
url = urlutils.fuzzy_url(url)
|
||||
except urlutils.FuzzyUrlError as e:
|
||||
raise cmdexc.CommandError(e)
|
||||
if url is None:
|
||||
if tab or bg or window:
|
||||
url = config.get('general', 'default-page')
|
||||
else:
|
||||
raise cmdexc.CommandError("No URL given, but -t/-b/-w is not "
|
||||
"set!")
|
||||
else:
|
||||
try:
|
||||
url = urlutils.fuzzy_url(url)
|
||||
except urlutils.FuzzyUrlError as e:
|
||||
raise cmdexc.CommandError(e)
|
||||
if tab or bg or window:
|
||||
self._open(url, tab, bg, window)
|
||||
else:
|
||||
|
@ -131,6 +131,10 @@ DATA = collections.OrderedDict([
|
||||
SettingValue(typ.List(), 'https://www.duckduckgo.com'),
|
||||
"The default page(s) to open at the start, separated by commas."),
|
||||
|
||||
('default-page',
|
||||
SettingValue(typ.FuzzyUrl(), '${startpage}'),
|
||||
"The page to open if :open -t/-b/-w is used without URL."),
|
||||
|
||||
('auto-search',
|
||||
SettingValue(typ.AutoSearch(), 'naive'),
|
||||
"Whether to start a search when something else than a URL is "
|
||||
@ -1000,7 +1004,7 @@ KEY_DATA = collections.OrderedDict([
|
||||
('set-cmd-text ":open -b {url}"', ['xO']),
|
||||
('set-cmd-text ":open -w "', ['wo']),
|
||||
('set-cmd-text ":open -w {url}"', ['wO']),
|
||||
('open -t about:blank', ['ga']),
|
||||
('open -t', ['ga']),
|
||||
('tab-close', ['d', '<Ctrl-W>']),
|
||||
('tab-close -o', ['D']),
|
||||
('tab-only', ['co']),
|
||||
@ -1082,7 +1086,7 @@ KEY_DATA = collections.OrderedDict([
|
||||
('tab-focus last', ['<Ctrl-Tab>']),
|
||||
('enter-mode passthrough', ['<Ctrl-V>']),
|
||||
('quit', ['<Ctrl-Q>']),
|
||||
('open -t about:blank', ['<Ctrl-T>']),
|
||||
('open -t', ['<Ctrl-T>']),
|
||||
('scroll-page 0 1', ['<Ctrl-F>']),
|
||||
('scroll-page 0 -1', ['<Ctrl-B>']),
|
||||
('scroll-page 0 0.5', ['<Ctrl-D>']),
|
||||
|
Loading…
Reference in New Issue
Block a user