From 8f8fd4231a1f950f53f3183f01d21d71575e30d9 Mon Sep 17 00:00:00 2001 From: Benedikt Tissot Date: Mon, 9 Nov 2020 15:55:21 +0100 Subject: [PATCH 1/3] escape ? in fish completion --- beetsplug/fish.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/beetsplug/fish.py b/beetsplug/fish.py index b842ac70f..abe3c3d71 100644 --- a/beetsplug/fish.py +++ b/beetsplug/fish.py @@ -201,6 +201,10 @@ def get_subcommands(cmd_name_and_help, nobasicfields, extravalues): # Formatting for Fish to complete our fields/values word = "" for cmdname, cmdhelp in cmd_name_and_help: + # Escape ? in fish + if cmdname == "?": + cmdname = "\\" + cmdname + word += "\n" + "# ------ {} -------".format( "fieldsetups for " + cmdname) + "\n" word += ( @@ -232,6 +236,10 @@ def get_all_commands(beetcmds): names = [alias for alias in cmd.aliases] names.append(cmd.name) for name in names: + # Escape ? in fish + if name == "?": + name = "\\" + name + word += "\n" word += ("\n" * 2) + "# ====== {} =====".format( "completions for " + name) + "\n" From 57a1b3aca86253d130848fdfcd2accbed861b5ee Mon Sep 17 00:00:00 2001 From: Benedikt Tissot Date: Mon, 9 Nov 2020 17:07:00 +0100 Subject: [PATCH 2/3] escape using helper function --- beetsplug/fish.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/beetsplug/fish.py b/beetsplug/fish.py index abe3c3d71..9883ed693 100644 --- a/beetsplug/fish.py +++ b/beetsplug/fish.py @@ -132,6 +132,11 @@ class FishPlugin(BeetsPlugin): with open(completion_file_path, 'w') as fish_file: fish_file.write(totstring) +def _escape(name): + # Escape ? in fish + if name == "?": + name = "\\" + name + def get_cmds_list(cmds_names): # Make a list of all Beets core & plugin commands @@ -201,9 +206,7 @@ def get_subcommands(cmd_name_and_help, nobasicfields, extravalues): # Formatting for Fish to complete our fields/values word = "" for cmdname, cmdhelp in cmd_name_and_help: - # Escape ? in fish - if cmdname == "?": - cmdname = "\\" + cmdname + cmdname = _escape(cmdname) word += "\n" + "# ------ {} -------".format( "fieldsetups for " + cmdname) + "\n" @@ -236,9 +239,7 @@ def get_all_commands(beetcmds): names = [alias for alias in cmd.aliases] names.append(cmd.name) for name in names: - # Escape ? in fish - if name == "?": - name = "\\" + name + name = _escape(name) word += "\n" word += ("\n" * 2) + "# ====== {} =====".format( From 020c082f3f21005896ebe116475ce5fa6bf8b08a Mon Sep 17 00:00:00 2001 From: Benedikt Tissot Date: Mon, 9 Nov 2020 17:12:44 +0100 Subject: [PATCH 3/3] make CI happy --- beetsplug/fish.py | 1 + 1 file changed, 1 insertion(+) diff --git a/beetsplug/fish.py b/beetsplug/fish.py index 9883ed693..0f7fe1e2c 100644 --- a/beetsplug/fish.py +++ b/beetsplug/fish.py @@ -132,6 +132,7 @@ class FishPlugin(BeetsPlugin): with open(completion_file_path, 'w') as fish_file: fish_file.write(totstring) + def _escape(name): # Escape ? in fish if name == "?":