Skip to content
Draft
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
847e956
Migrate block comment line command
FireChickenProductivity Mar 29, 2026
e091b03
Extract more functionality to actions
FireChickenProductivity Mar 29, 2026
1b2c6fa
Improve clarity
FireChickenProductivity Mar 29, 2026
1d5a7c1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 29, 2026
ed0d272
Revert to prior behavior
FireChickenProductivity Mar 29, 2026
05c8711
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 29, 2026
35d7db1
Remove no longer used argument
FireChickenProductivity Mar 29, 2026
b006711
Do text insertion with comments
FireChickenProductivity Apr 17, 2026
06b9fc0
Start using snippet in both places
FireChickenProductivity Apr 17, 2026
0c71436
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 17, 2026
16efc34
Revert to multiple inserts
FireChickenProductivity Apr 18, 2026
a29bd3b
Remove new snippet action
FireChickenProductivity Apr 18, 2026
b8bc1c4
Update action names
FireChickenProductivity Apr 18, 2026
2577f1a
Merge branch 'main' into migrate-block-comments-to-actions
FireChickenProductivity Apr 18, 2026
eceb6cf
Fix action name
FireChickenProductivity Apr 18, 2026
026907c
Revert snippet changes
FireChickenProductivity Apr 18, 2026
295f2f2
Fix documentation string
FireChickenProductivity Apr 18, 2026
fd87f20
Simplify text insertion
FireChickenProductivity Apr 18, 2026
d839012
Simplify branching
FireChickenProductivity Apr 18, 2026
f08f980
Remove unnecessary actions
FireChickenProductivity Apr 18, 2026
6589a81
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 18, 2026
f27423c
Use code block comment in line to use the snippet
FireChickenProductivity May 11, 2026
7de1a8d
Explain why we are not using a snippet
FireChickenProductivity May 11, 2026
0fd2b31
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 11, 2026
b1bcfb1
Make clearer
FireChickenProductivity May 11, 2026
b7d589f
Make consistent
FireChickenProductivity May 13, 2026
d7f2225
Keep lua behavior more consistent
FireChickenProductivity May 13, 2026
0146ec8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 13, 2026
dce0ae9
Merge branch 'main' into migrate-block-comments-to-actions
FireChickenProductivity May 29, 2026
30cbcf0
Provides c like implementation for inline block comments
FireChickenProductivity May 30, 2026
e7712bf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 30, 2026
a903d1f
Merge branch 'main' into migrate-block-comments-to-actions
nriley May 30, 2026
9498e62
Merge branch 'main' into migrate-block-comments-to-actions
FireChickenProductivity Jun 6, 2026
95b5411
Rename variable
FireChickenProductivity Jun 6, 2026
b401bad
Add optional argument to support better error messages
FireChickenProductivity Jun 6, 2026
0e483a8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 6, 2026
87ad0c4
Use name argument
FireChickenProductivity Jun 6, 2026
9cb903e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 6, 2026
b0bf31b
Update snippet names
FireChickenProductivity Jun 6, 2026
3c96102
Merge branch 'main' into migrate-block-comments-to-actions
FireChickenProductivity Jun 7, 2026
f4dc0b0
Add some test cases
FireChickenProductivity Jun 7, 2026
a53d4ce
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 7, 2026
7239b8b
Add error tests
FireChickenProductivity Jun 7, 2026
6c94ca4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 7, 2026
62c590b
Merge branch 'main' into migrate-block-comments-to-actions
FireChickenProductivity Jun 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions core/snippets/snippets_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ def compute_snippet_body_with_substitutions(
snippet: Snippet, substitutions: dict[str, str]
) -> str:
body = snippet.body
return compute_snippet_body_with_substitutions_from_body(body, substitutions)


def compute_snippet_body_with_substitutions_from_body(
body: str, substitutions: dict[str, str]
Comment thread
FireChickenProductivity marked this conversation as resolved.
Outdated
) -> str:
if substitutions:
for k, v in substitutions.items():
v = v.replace("$", r"\$")
Expand Down
40 changes: 37 additions & 3 deletions lang/tags/comment_block.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Optional

from talon import Context, Module, actions

c_like_ctx = Context()
Expand All @@ -14,22 +16,54 @@

@mod.action_class
class Actions:
def code_comment_block():
def code_comment_block(text: Optional[str] = None):
"""Block comment"""
actions.user.insert_snippet_by_name("commentBlock")
substitutions = None
if text is not None:
substitutions = {"0": text}
actions.user.insert_snippet_by_name("commentBlock", substitutions)
Comment thread
nriley marked this conversation as resolved.
Outdated

def code_comment_block_prefix():
"""Block comment start syntax"""

def code_comment_block_suffix():
"""Block comment end syntax"""

def code_comment_block_line():
"""Wraps current line in block comment markers"""
actions.edit.line_start()
actions.user.code_comment_block_prefix()
actions.key("space")
actions.edit.line_end()
actions.key("space")
actions.user.code_comment_block_suffix()

def code_comment_block_at_line_start(text: str):
Comment thread
FireChickenProductivity marked this conversation as resolved.
Outdated
"""Inserts a block comment at the start of the line"""
actions.edit.line_start()
actions.user.code_block_comment_inline(text)

def code_comment_block_at_line_end(text: str):
"""Inserts a block comment at the end of the line"""
actions.edit.line_end()
actions.user.code_block_comment_inline(text)

def code_block_comment_inline(text: str):
Comment thread
FireChickenProductivity marked this conversation as resolved.
Outdated
"""Inserts an inline block comment at the end of the line with the specified text"""
Comment thread
FireChickenProductivity marked this conversation as resolved.
Outdated
actions.user.code_comment_block_prefix()
actions.key("space")
actions.insert(text)
actions.key("space")
actions.user.code_comment_block_suffix()


@c_like_ctx.action_class("user")
class CActions:
def code_comment_block():
def code_comment_block(text: Optional[str] = None):
actions.insert("/*\n\n*/")
actions.edit.up()
if text is not None:
actions.insert(text)

def code_comment_block_prefix():
actions.insert("/*")
Expand Down
36 changes: 6 additions & 30 deletions lang/tags/comment_block.talon
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,13 @@ tag: user.code_comment_block
-

block comment: user.code_comment_block()
block comment line:
edit.line_start()
user.code_comment_block_prefix()
key(space)
edit.line_end()
key(space)
user.code_comment_block_suffix()
block comment line: user.code_comment_block_line()
#adds comment to the start of the line
block comment line <user.text> over:
edit.line_start()
user.code_comment_block()
insert(user.text)
block comment <user.text> over:
user.code_comment_block()
insert(user.text)
block comment <user.text>$:
user.code_comment_block()
insert(user.text)
block comment line <user.text> over: user.code_comment_block_at_line_start(text)
block comment <user.text> over: user.code_comment_block(text)
block comment <user.text>$: user.code_comment_block(text)
(line | inline) block comment <user.text> over:
edit.line_end()
user.code_comment_block_prefix()
key(space)
insert(user.text)
key(space)
user.code_comment_block_suffix()
(line | inline) block comment <user.text>$:
edit.line_end()
user.code_comment_block_prefix()
key(space)
insert(user.text)
key(space)
user.code_comment_block_suffix()
user.code_comment_block_at_line_end(text)
(line | inline) block comment <user.text>$: user.code_comment_block_at_line_end(text)
open block comment: user.code_comment_block_prefix()
close block comment: user.code_comment_block_suffix()