Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: using kanata for text sequence expansion #1305

Open
seelaman opened this issue Oct 25, 2024 · 5 comments
Open

Feature request: using kanata for text sequence expansion #1305

seelaman opened this issue Oct 25, 2024 · 5 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@seelaman
Copy link

seelaman commented Oct 25, 2024

Is your feature request related to a problem? Please describe.

I've been trying to replace Autohotkey or Espanso with Kanata sequences (they've been unreliable for me).
So far I was able to put my text expansion onto a key in a layer which is close but I'm wondering if it's possible to expand a typed sequence into a string which also contains numbers directly from sequence loader mode (sldr).

I can almost get there but am running into an issue when trying to have numbers in the macro.

I can add an alias for each number as per the docs but can't use that alias in the macro when it's part of a virtualkey definition.

(defalias
  1 1
  2 2
  3 3
  working_alias (macro @1 @2 @3)
)

(defseq oid (o i d))

;; this throws an error
(defvirtualkeys  oid (macro @1 @2 @3))

(deflayermap custom_layer
  a @working_alias
  ;; entering sldr and typing oid does not work, aliases are not allowed in a macro definition
  ret sldr
)

If there is a simpler way to do this, please let me know, I didn't find anything in the docs.

Describe the solution you'd like.

I would like to enter sldr mode using a key and type any predefined sequence to get it expanded into text.

for example

  • hit caps-ret to enter sldr mode
  • type "oid"
  • kanata types out "123"

Describe alternatives you've considered.

I tried putting the macro on a key directly which works. It just limits how many shortcuts I can use and forces me to remember which key each macro is on.

Additional context

Another part (this would go into a separate issue if the numbers question finds a solution) would be to execute a command to replace the output.

for example entering sldr mode, typing "date" and getting today's date expanded as text by running:

date +"%Y-%m-%d"

I'm already using (cmd ) extensively but would love for it to expand text like a sequence does.

I understand if this is out of scope of course.

@seelaman seelaman added the enhancement New feature or request label Oct 25, 2024
@jtroo
Copy link
Owner

jtroo commented Oct 25, 2024

You can do DigitX instead. E.g. Digit1.
https://github.com/jtroo/kanata/blob/main/docs/config.adoc#key-names

@gerhard-h
Copy link
Contributor

maybe cmd-output-keys and including the backspace
.psiso (cmd-output-keys powershell.exe -Command r#"echo "(" bspc bspc ((Get-Date -Format "yyyy-MM-dd").toCharArray() -join " ") ")""#)

@jtroo jtroo added the question Further information is requested label Oct 26, 2024
@jtroo
Copy link
Owner

jtroo commented Oct 27, 2024

If you're willing to test out a more experimental feature, you could see if zippychord is any better for text expansion:
#1301

@seelaman
Copy link
Author

The DigitX suggestion worked, thank you.

I'll give the other suggestions a try as well.

@seelaman
Copy link
Author

maybe cmd-output-keys and including the backspace .psiso (cmd-output-keys powershell.exe -Command r#"echo "(" bspc bspc ((Get-Date -Format "yyyy-MM-dd").toCharArray() -join " ") ")""#)

This also worked.

If others come across this:
The last section of the cmd docs lays out exactly the same use case, complete with date call in bash

  pdb (cmd-output-keys bash -c "date +'%F %R' | sed 's/./& /g' | sed 's/:/S-;/g' | sed 's/\(.\{20\}\)\(.*\)/\(\1 spc \2\)/'")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants