如何得到上上个command-event?

我想给abbrev写个advice,判断上一个按键是不是Delete,如果是的话就不触发abbrev-expand

但是abbrev里面已经用到了 last-input-event 啦, (也就是等调用到我的函数的时候就需要判断上上个按键是啥了)

不知道这该怎么实现?

(define-advice expand-abbrev (:before-while (&rest r) disable-expand-if-last-key-is-del)
  (message "%s" last-input-event) ;; -> 32
  )

粗暴一点,整个重写。 一般直接写个新的比较好。不然可能到时候别的地方出问题了不知道原因在哪里

1 个赞

正常来说不是应该判断上一个command是否是delete-backward-char么?

last-command is a variable defined in ‘C source code’.
Its value is ‘kill-ring-save’
It is a terminal-local variable; global value is the same.

  This variable may be risky if used as a file-local variable.

Documentation:
The last command executed.
Normally a symbol with a function definition, but can be whatever was found
in the keymap, or whatever the variable ‘this-command’ was set to by that
command.

The value ‘mode-exit’ is special; it means that the previous command
read an event that told it to exit, and it did so and unread that event.
In other words, the present command is the event that made the previous
command exit.

The value ‘kill-region’ is special; it means that the previous command
was a kill command.

‘last-command’ has a separate binding for each terminal device.
See Info node ‘(elisp)Multiple Terminals’.

[back]

是啊,但是当我调用到这个函数的时候last command就一定是空格啊

只有空格才会触发 abbrev expand, 然后我的函数才会运行

整个函数也太大了,有41k呢。。。