I have a problem that I suspect is a general Emacs problem. If I run a certain package, simple-rtm, and then try and use M-x to run any command, I get the error in the bottom line of the screen:

Symbol's chain of function indirections contains a loop: def-rtm-authenticated-scalar-method

I understand at a superficial level what this means - simple-rtm calls rtm, and in rtm.el there is a function def-rtm-authenticated-scalar-method and it has an infinite loop. Given enough time I will learn enough Lisp to work out why and fix it. But that might take me a while. Meanwhile I would like to just continue using Emacs for other things, but I find the only way I can use M-x after running simple-rtm is to exit Emacs and run it again.

My question therefore is: is there a simple Emacs command I can use to break out of the function indirection loop so I can use M-x again?

Emacs version is 24.5.1 running on Windows 10.

  • Try C-g. Repeat it a few times, if necessary. ESC ESC ESC is another way to do pretty much the same thing. – Drew Apr 26 '16 at 4:06
  • I press M-x I get the error message. I press C-g I get quit. I have no trouble issing C- commands or M- commands other than M-x, but if I want to use M-x to run something, I can't. Doesn't matter how many times I press C-g, if I then press M-x, back comes the error message – user2496925 Apr 26 '16 at 4:48
  • If you're able to type M-: (setq debug-on-error t) RET, do you then get a stack trace when the error is triggered? – phils Apr 26 '16 at 5:45
  • I see. So you don't mean that you want to break out of the loop. You want to get rid of the loop - prevent looping, not break out of a loop. – Drew Apr 26 '16 at 5:47
  • M-: just added ;; to current buffer, so I added (setq debug-on-error t) to my init file and then restarted. Then after inducing the error via M-x I got a stack trace - too many embedded binary zeroes to copy and paste – user2496925 Apr 26 '16 at 6:16

Function indirection refers to the ability for a symbol's function cell to contain another symbol as its value, rather than a function object. In that case, the function cell of the latter symbol is used (which might be yet another symbol, etc...) until a function object is found.

Thus if symbol A points to symbol B in this way, and symbol B points back to symbol A, there is a function indirection loop, and any attempt to call either A or B as a function cannot succeed.

It's very difficult to suggest exactly what you should do without seeing the code in question. You could prevent the loop by explicitly redefining one of the functions involved (as an actual function), but I can't guess at the correct solution without seeing the code.


Well, I looked at the rtm package via Melpa, and it contains

(defalias 'def-rtm-authenticated-scalar-method 'def-rtm-authenticated-scalar-method)

which is setting a symbol's function cell to its own symbol! I don't know what that was intended to be, but that's the cause of the problem. Log a bug report with the author, if you're able.

Try the following...

  1. Re-evaluate the initial definition (type C-x C-e with point after the closing parenthesis)

    (def-rtm-macro def-rtm-authenticated-scalar-method
                   rtm-call-authenticated rtm-get-scalar-from-response)
  2. Comment out the bad code from rtm.el and save the file.

    ;; (defalias 'def-rtm-authenticated-scalar-method 'def-rtm-authenticated-scalar-method)


    ;; (put 'def-rtm-authenticated-scalar-method 'lisp-indent-function 1)
  3. Byte-compile the file with M-x byte-compile-file (assuming that's now working again since step 1), or use B in dired.

edit 2

FYI if I manufacture the same basic error in Emacs 24.5, Emacs does not get stuck in an infinite loop. It detects the problem, reports it, and returns control to me. I certainly don't lose the ability to use M-x. So there's likely some compounding factor at work here which is making a normally-recoverable error less so.

  • But what about the general problem of how to break the loop? Otherwise it means every time there is a function indirection loop Emacs becomes unusable - surely that isn't so....not with Emacs...:-) – user2496925 Apr 26 '16 at 4:45
  • 1
    Well "every time there is a function indirection loop" should be never. The fact that it happened at all means there is a bug somewhere which needs fixing. There are many ways to break Emacs by doing things that you should never do. That's the flip side of having so much power and access to the internals of the application. (And it quite possibly can be fixed without restarting Emacs, but not without knowing precisely what the cause is.) – phils Apr 26 '16 at 5:39
  • phils - ok, reasonable comment, so if I want to run simple-rtm then I have to accept I restart Emacs after it if I want to run other commands. I guess I will just have to do that until I learn enough Lisp to fix the root cause. Thanks. – user2496925 Apr 26 '16 at 5:42
  • 1
    Point us at the code, and someone might be able to show you where the bug is. – phils Apr 26 '16 at 5:43
  • Source is at github.com/emacsmirror/rtm/blob/master/rtm.el. See line 133: (def-rtm-macro def-rtm-authenticated-scalar-method rtm-call-authenticated rtm-get-scalar-from-response). I see I incorrectly quoted the function name in my original post where I said it ended in "-loop" but it ends in "-method". Sorry about that, I have corrected it. But please note I can eventually fix this myself. My original question was how to break the loop so I can get M-x back, but it appears I can't. – user2496925 Apr 26 '16 at 6:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.