excmd: Simplify IPC for geturlsforlinks

This is more about maybe expanding the macro system in the future. Need
to look at how other projects do it.
This commit is contained in:
Colin Caine 2017-11-28 00:05:12 +00:00
parent ca9e3b25f0
commit 7dda663a47
2 changed files with 7 additions and 3 deletions

View file

@ -93,7 +93,7 @@ def content(lines, context):
sig = Signature(block.split('\n')[0])
return "cmd_params.set('{sig.name}', ".format(**locals()) + dict_to_js(sig.params) + """)
{sig.raw}
messageActiveTab(
return messageActiveTab(
"excmd_content",
"{sig.name}",
""".format(**locals()) + str(list(sig.params.keys())).replace("'","") + """,

View file

@ -361,6 +361,10 @@ export function urlparent (){
}
/** Returns the url of links that have a matching rel.
Don't bind to this: it's an internal function.
@hidden
*/
//#content
export function geturlsforlinks(rel: string){
@ -837,13 +841,13 @@ export async function clipboard(excmd: "open"|"yank"|"yankshort"|"yankcanon"|"ta
let urls = []
switch (excmd) {
case 'yankshort':
urls = await messageActiveTab("excmd_content", "geturlsforlinks", ["shortlink"]);
urls = await geturlsforlinks("shortlink")
if (urls.length > 0) {
messageActiveTab("commandline_frame", "setClipboard", [urls[0]])
break
}
case 'yankcanon':
urls = await messageActiveTab("excmd_content", "geturlsforlinks", ["canonical"]);
urls = await geturlsforlinks("canonical")
if (urls.length > 0) {
messageActiveTab("commandline_frame", "setClipboard", [urls[0]])
break