1

I have two buffers open in Emacs, each in their own window, and one of those buffers is the *Messages* buffer (for the sake of example, let's say the other buffer is *scratch*). Most things printed to the echo area are immediately visible in the *Messages* buffer. In other words, if I'm in *scratch* and press C-g then "Quit" is printed to the *Messages* buffer right away. If I enter (message "hi") into the *scratch* buffer and eval it, the *Messages* buffer is also updated right away.

However, when I try to call the message function from an SMIE rules-function, the *Messages* buffer is not updated right away, and I have to switch to it (C-x o) in order to see it updated, or scroll it from the other buffer (C-M-v).

This is obviously trivial to work around, but printing stuff with messages is damn useful when debugging an SMIE indentation rules function, which is what I'm doing. When I hit tab in a particular place in my source code, sometimes this function is called more than once, with different parameters (:before and :after for the same token, for instance), resulting in more than one line printed to *Messages*.

Maybe I'm barking up the wrong tree, and in actual fact the SMIE rules function should never be called more than once?? In that case I guess this would be a bug in the lexical spec for this SMIE mode? I'm fiddling with sml-mode.el and it's called twice when the point is on a line after a "definitional equals" for instance:

val x =
|

where the point is |

4

1 回答 1

1

规则函数被调用两次是正常的。不知道为什么这些消息没有以同样的方式出现在 *Messages* 中,但这并不是因为 SMIE 做了一些特别的事情。调试 smie 规则,我个人使用 Edebug(C-u C-M-x在需要调试的 smie-rules 函数中命中)。

于 2013-01-09T19:11:33.297 回答