艺术家模式邪恶整合

时间:2017-12-23 23:44:05

标签: emacs evil-mode

我试图通过picture-mode中的j,h,k,l键向左,向下,向上和向右移动来在emacs evil-normal-mode中绘制ascii art。

为此,我使用了这些绑定:

(nmap :keymaps 'picture-mode-map "k" (lambda () (picture-movement-up) (picture-self-insert (string-to-char "."))) "j" (lambda () (picture-movement-down) (picture-self-insert (string-to-char "."))) "h" (lambda () (picture-movement-left) (picture-self-insert (string-to-char "."))) "l" (lambda () (picture-movement-right) (picture-self-insert (string-to-char "."))))

我期望的是.的单个插入以及要使用相应的picture-movement函数更改的动作。

然而,当我尝试这些绑定时,插入的文本方向是正确的,但一次插入了46个字符。这个角色是我按下的关键,而不是时期。

例如,当我按下l时,我会立即获得llllllllllllllllllllllllllllllllllllllllllllll,而不是只是逐渐连续播放,因为我继续按下l

为什么我会遇到这种行为?我怎样才能达到预期的行为?

1 个答案:

答案 0 :(得分:0)

ASCII字符.具有整数值46. picture-self-insert函数将其参数作为计数以及last-command-event变量的值传递给{{1}功能。对于您的情况,这会导致46个值picture-insert的插入,这恰好是您按下的任何键。

last-command-event个功能中,将lambda替换为:

(picture-self-insert (string-to-char "."))

这将执行(picture-insert ?. 1) 字符的1次插入。