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

VSCode用のキー定義が元のキー定義を殺してしまっている #8

Closed
gotoh opened this issue Mar 30, 2021 · 5 comments
Closed
Labels

Comments

@gotoh
Copy link

gotoh commented Mar 30, 2021

config.pyではL1635付近で数字キーの周りのキー定義をしています。

fakeymacs/config.py

Lines 1635 to 1640 in e6a72d2

## 数字キーの設定
for n in range(10):
key = str(n)
define_key(keymap_emacs, key, digit(n))
if fc.use_ctrl_digit_key_for_digit_argument:
define_key(keymap_emacs, "C-" + key, digit2(n))

ですが、もっと後ろのVSCode用のキー定義でCTRL+数字の定義を上書きしてしまっています。

fakeymacs/config.py

Lines 1853 to 1854 in e6a72d2

for key in range(10):
define_key(keymap_emacs, "C-{}".format(key), reset_search(reset_undo(reset_counter(reset_mark(switch_focus(key))))))

少なくともこの数字キーの定義はオプショナルとするかVSCode専用のキーマップを導入する
方向のほうが良いのではないでしょうか。

switch_focus() は 非 isVscodeTarget() == Falseな場合なにも行われていないので
キー入力が捨てられてしまっています。詳細ログでいうとINしたキーに対してVScode以外では
THUもOUTも発生させないという定義になってしまっています。
その他のvs_code用のメソッドも同様。

TyporaでC+2といったショートカットが使えないため悩みました。
とりあえずは config_personal.py にて当該キーを再定義することで回避しています。

# [section-base-2] ---------------------------------------------------------------------------------

## CTRL+数字キーの再設定
for n in range(10):
    key = str(n)
    if fc.use_ctrl_digit_key_for_digit_argument:
        define_key(keymap_emacs, "C-" + key, digit2(n))
    else:
        define_key(keymap_emacs, "C-" + key, reset_undo(reset_counter(reset_mark(repeat(self_insert_command2("C-" + key))))))
@smzht
Copy link
Owner

smzht commented Apr 2, 2021

指摘いただき、ありがとうございます。問題を確認しました。
今週末、対策について検討します。VSCode用のキーバインドを専用のキーマップにして、
拡張機能に逃がす方法などもあるかと思っていました。
以上、よろしくお願いします。

@smzht smzht added the bug label Apr 4, 2021
@smzht
Copy link
Owner

smzht commented Apr 4, 2021

develop branch に見直した実装をコミットしました。確認ください。
https://github.com/smzht/fakeymacs/tree/develop
しばらくテストしてみて問題なければ master branch にマージしたいと思います。

@smzht
Copy link
Owner

smzht commented Apr 4, 2021

VSCode 周りの実装は、拡張機能 vscode_key に移管しました。
https://github.com/smzht/fakeymacs/tree/develop/fakeymacs_extensions/vscode_key

@smzht
Copy link
Owner

smzht commented Apr 6, 2021

問題なさそうなので、master branch にマージしました。
b353267

@gotoh
Copy link
Author

gotoh commented Apr 7, 2021

対策ありがとうございます。
「当該キーを再定義することで回避」をしなくても
C-の動作が実現できていることを確認しましたのでクローズします。

@gotoh gotoh closed this as completed Apr 7, 2021
@smzht smzht added question and removed question labels Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants