Skip to content
Draft
Changes from all commits
Commits
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
13 changes: 12 additions & 1 deletion apps/emacs/emacs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from typing import Optional

from talon import Context, Module, actions, settings
from talon import Context, Module, actions, clip, settings

mod = Module()
mod.setting(
Expand Down Expand Up @@ -320,6 +320,17 @@ def find_next():
def find_previous():
actions.key("ctrl-r")

def selected_text() -> str:
timeout = settings.get("user.selected_text_timeout")
with clip.capture(timeout) as s:
actions.edit.copy()
# this restores the selection after the copy
actions.user.emacs("exchange-point-and-mark")
try:
return s.text()
except clip.NoChange:
return ""


@ctx.action_class("app")
class AppActions:
Expand Down