Skip to content

Commit 9fa646b

Browse files
Remove snippets from spoken form json (#2842)
Read from deprecated snippet csv files if the exists, but do not create them if they don't. Fixes #2841
1 parent 5d4141c commit 9fa646b

File tree

3 files changed

+22
-29
lines changed

3 files changed

+22
-29
lines changed

cursorless-talon/src/csv_overrides.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def init_csv_and_watch_changes(
6565
extra_ignored_values: Optional[list[str]] = None,
6666
extra_allowed_values: Optional[list[str]] = None,
6767
allow_unknown_values: bool = False,
68+
deprecated: bool = False,
6869
default_list_name: Optional[str] = None,
6970
headers: list[str] = [SPOKEN_FORM_HEADER, CURSORLESS_IDENTIFIER_HEADER],
7071
no_update_file: bool = False,
@@ -123,6 +124,12 @@ def init_csv_and_watch_changes(
123124
pluralize_lists = []
124125

125126
file_path = get_full_path(filename)
127+
is_file = file_path.is_file()
128+
129+
# Deprecated file that doesn't exist. Do nothing.
130+
if deprecated and not is_file:
131+
return lambda: None
132+
126133
super_default_values = get_super_values(default_values)
127134

128135
file_path.parent.mkdir(parents=True, exist_ok=True)
@@ -151,9 +158,9 @@ def on_watch(path, flags):
151158
handle_new_values=handle_new_values,
152159
)
153160

154-
fs.watch(str(file_path.parent), on_watch)
161+
fs.watch(file_path.parent, on_watch)
155162

156-
if file_path.is_file():
163+
if is_file:
157164
current_values = update_file(
158165
path=file_path,
159166
headers=headers,
@@ -188,7 +195,7 @@ def on_watch(path, flags):
188195
)
189196

190197
def unsubscribe():
191-
fs.unwatch(str(file_path.parent), on_watch)
198+
fs.unwatch(file_path.parent, on_watch)
192199

193200
return unsubscribe
194201

@@ -385,7 +392,7 @@ def csv_error(path: Path, index: int, message: str, value: str):
385392
index (int): The index into the file (for error reporting)
386393
text (str): The text of the error message to report if condition is false
387394
"""
388-
print(f"ERROR: {path}:{index+1}: {message} '{value}'")
395+
print(f"ERROR: {path}:{index + 1}: {message} '{value}'")
389396

390397

391398
def read_file(

cursorless-talon/src/spoken_forms.json

+3-23
Original file line numberDiff line numberDiff line change
@@ -233,29 +233,9 @@
233233
"-from": "experimental.setInstanceReference"
234234
}
235235
},
236-
"experimental/wrapper_snippets.csv": {
237-
"wrapper_snippet": {
238-
"else": "ifElseStatement.alternative",
239-
"funk": "functionDeclaration.body",
240-
"if else": "ifElseStatement.consequence",
241-
"if": "ifStatement.consequence",
242-
"try": "tryCatchStatement.body",
243-
"link": "link.text"
244-
}
245-
},
246-
"experimental/insertion_snippets.csv": {
247-
"insertion_snippet_no_phrase": {
248-
"if": "ifStatement",
249-
"if else": "ifElseStatement",
250-
"try": "tryCatchStatement"
251-
}
252-
},
253-
"experimental/insertion_snippets_single_phrase.csv": {
254-
"insertion_snippet_single_phrase": {
255-
"funk": "functionDeclaration.name",
256-
"link": "link.text"
257-
}
258-
},
236+
"experimental/wrapper_snippets.csv": {},
237+
"experimental/insertion_snippets.csv": {},
238+
"experimental/insertion_snippets_single_phrase.csv": {},
259239
"experimental/miscellaneous.csv": {
260240
"phrase_terminator": { "over": "phraseTerminator" }
261241
},

cursorless-talon/src/spoken_forms.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,26 @@ def handle_new_values(csv_name: str, values: list[SpokenFormEntry]):
167167
# DEPRECATED @ 2025-02-01
168168
handle_csv(
169169
"experimental/wrapper_snippets.csv",
170+
deprecated=True,
170171
allow_unknown_values=True,
171172
default_list_name="wrapper_snippet",
172173
),
173174
handle_csv(
174175
"experimental/insertion_snippets.csv",
176+
deprecated=True,
175177
allow_unknown_values=True,
176178
default_list_name="insertion_snippet_no_phrase",
177179
),
178180
handle_csv(
179181
"experimental/insertion_snippets_single_phrase.csv",
182+
deprecated=True,
180183
allow_unknown_values=True,
181184
default_list_name="insertion_snippet_single_phrase",
182185
),
183-
handle_csv("experimental/miscellaneous.csv"),
186+
handle_csv(
187+
"experimental/miscellaneous.csv",
188+
deprecated=True,
189+
),
184190
# ---
185191
handle_csv(
186192
"experimental/actions_custom.csv",
@@ -235,7 +241,7 @@ def on_ready():
235241

236242
registry.register("update_captures", update_captures_debounced)
237243

238-
fs.watch(str(JSON_FILE.parent), on_watch)
244+
fs.watch(JSON_FILE.parent, on_watch)
239245

240246

241247
app.register("ready", on_ready)

0 commit comments

Comments
 (0)