emacs-rime icon indicating copy to clipboard operation
emacs-rime copied to clipboard

[BUG] rime-translate-keybindings 无法传递"comma" "period" 按键

Open jiahut opened this issue 3 years ago • 16 comments

问题描述

rime-translate-keybindings 无法传递"comma" "period" 按键

Emacs中的配置

(use-package rime
  :config
  (setq rime-translate-keybindings '("C-f" "C-b" "C-g" "C-d" "C-h" "," ".")) 
)

复现方式

在rime种配置了以词定字插件 并配置 , , . 作为first/last的键位

  key_binder:
    select_first_character: 'comma'
    select_last_character: 'period'

以上配置在weasel(小狼毫) 中是可以work的 (一直在用)

据此判断在emacs-rime中貌似没有发送 comma, period 键位到librime中 (或者librime不支持lua插件?)

  • 操作系统:如 Win10
  • Emacs版本:如 29.0.50
  • Librime版本:如 1.5.3
  • Librime安装方式: 手工编译
  • 安装方式: Melpa

jiahut avatar Dec 07 '21 04:12 jiahut

可以传递,比如说你用拼音的话就可以用 ,. 来进行翻页,我没有用过 lua 插件,不知道它是 librime 的功能,还是输入法具体实现的功能。

DogLooksGood avatar Dec 07 '21 06:12 DogLooksGood

也就是说传递给了librime,但是librime在和lua插件配合起来时可能不work?

jiahut avatar Dec 07 '21 07:12 jiahut

是的,已有一些 issue 提到过和 lua 插件配合的问题。 可能需要 emacs-rime 这边完成 lua 插件的加载,但目前还清楚怎么实现。

DogLooksGood avatar Dec 07 '21 07:12 DogLooksGood

🙏🏻

暂不影响使用

两个判断暂记录一下, 待以后有空再研究 ( anyone如果有更solid的结论可以更新)

  • librime是否已经支持了lua的plugin机制?
    • 大概率有, 当前插件配置需要patch到 engine/processors 这个节点
  • plugin服务发现以及加载是在应用层来实现的吗? (在这里的语境下, 小狼毫/emacs-rime 就是应用层 )
    • 大概率是, 目前下在 rime_home 目录下有个 rime.lua 来加载具体的插件 processA = require(some-plug')`

jiahut avatar Dec 08 '21 06:12 jiahut

这问题无解了吗?我遇到了类似的问题。。配置了发送快捷键但不生效

sincebyte avatar Jan 01 '22 11:01 sincebyte

@vanniuner 快捷什么键?贴下配置看一下?

如果是针对 lua 插件的问题,暂时无解。

DogLooksGood avatar Jan 01 '22 11:01 DogLooksGood

我想发送C-n,C-p 来实现左右选词。但是触发的是另外一个按键。我用describe-key看的结果: It is bound to C-n. (evil-complete-next &optional ARG)

rime配置如下:

  key_binder/bindings:
    - { when: has_menu, accept: "Control+k", send: Page_Up }
    - { when: has_menu, accept: "Control+j", send: Page_Down }
    - { when: has_menu, accept: "Control+p", send: Left }
    - { when: has_menu, accept: "Control+n", send: Right }

配置如下 :

(use-package! rime
  :config
  (setq rime-show-candidate 'minibuffer)
  (setq rime-translate-keybindings '("C-n" "C-p"))
  :custom
  (rime-emacs-module-header-root emacs-module-root)
  (default-input-method "rime"))
  (setq mode-line-mule-info   '((:eval (rime-lighter)))
      gts-translate-list      '(("en" "zh"))
      rime-disable-predicates '(
         rime-predicate-current-uppercase-letter-p
         rime-predicate-after-ascii-char-p
         rime-predicate-space-after-cc-p)
      gts-default-translator   (gts-translator
       :picker (gts-prompt-picker)
       :engines (list (gts-google-engine) (gts-google-rpc-engine))
       :render (gts-buffer-render)))

sincebyte avatar Jan 01 '22 12:01 sincebyte

在关闭 evil 的模式下是可以的吗?感觉 evil 的 C-n/C-p 的绑定的优先级不应该这么高才对。

DogLooksGood avatar Jan 01 '22 13:01 DogLooksGood

M-x evil-mode to disable evil mode. describe-key result : It is bound to C-n, . (next-line &optional ARG TRY-VSCROLL)

截屏2022-01-03 13 26 48

sincebyte avatar Jan 03 '22 05:01 sincebyte

(defvar rime-translate-keybindings
  '("C-f" "C-b" "C-n" "C-p" "C-g" "<left>" "<right>" "<up>" "<down>" "<prior>" "<next>" "<delete>")
  "A list of keybindings those sent to Rime during composition.

Currently only Shift, Control, Meta is supported as modifiers.
Each keybinding in this list, will be bound to `rime-send-keybinding' in `rime-active-mode-map'.")

默认值是这些,这些键都会在 rime 激活的时候绑定在 rime-active-mode-map, 就是有候选时使用的 keymap. 绑定的命令应该是 rime-send-keybinding

使用 M-x describe-keymap RET rime-active-mode-map 查看下。

我的是

image

DogLooksGood avatar Jan 03 '22 06:01 DogLooksGood

M-x describe-keymap RET rime-active-mode-map: rime-active-mode-map is a keymap variable defined in ‘rime.el’.

Documentation: Keymap during composition.

key binding


RET rime--return C-n rime-send-keybinding C-p rime-send-keybinding DEL rime--backspace rime--backspace rime--escape rime--return

sincebyte avatar Jan 03 '22 08:01 sincebyte

看起来是对的,有点没头绪,可能需要一个最小可重现的配置。

DogLooksGood avatar Jan 03 '22 09:01 DogLooksGood

关于rime最小的配置在上面回复里面。😂😂 完整的配置:https://github.com/vanniuner/neo-emacs

sincebyte avatar Jan 03 '22 13:01 sincebyte

哦,因为光标离开的时候自动取消了 composition 所以没有办法通过 C-h k 来查看那个位置的按键。 然后就是在我这里什么配置都没有的情况下,C-n C-p 也是可以用的,因为 emacs-rime 和 rime 两端的默认配置里面都包含了 C-n C-p 的设置。

因为没有办法重现问题,所以我暂时没有头绪。

DogLooksGood avatar Jan 05 '22 14:01 DogLooksGood

我也是两边都加了的,操作系统的rime程序可以通过c-n/p 来进行左右选词,但在emacs rime里面就不行了,不能复现就先这样吧,还是感谢狗哥

sincebyte avatar Jan 05 '22 15:01 sincebyte

应该是在evil-insert-mode下, C-n/p的被动态绑定回来了.

jiahut avatar Jan 11 '22 05:01 jiahut