Some time ago, I had a very strange problem. I was writing a certain library for Emacs, and in one of the functions I had a Mark set
message coming apparently out of nowhere. Since my function used timers, closures and callbacks to do things asynchronously, edebug didn’t help me a lot. Happily, I knew what can give such a message: push-mark
. (BTW, this is yet another good reason to have Emacs sources handy: if I hadn’t known that, I could have just grepped the sources.)
Now, finding the offending push-mark
was a question of five seconds: M-x debug-on-entry
, then push-mark RET
. After that, every time push-mark
was called, I got a backtrace and could easily find the caller. After fixing the bug, I launched M-x cancel-debug-on-entry
and everything was fine.
BTW, the bug was a call to goto-line
; as its docstring says (and that’s what I missed), it is meant only for interactive use. As suggested, I replaced it with
(progn (goto-char (point-min)) (forward-line (1- N)))
(I needed progn
since the goto-line
was located in a then-branch of an if
. I later changed that to cond
instead.)