I try to understand a piece of elisp source code, with many nested and conditional functions calls, and I would like to know if a particular variable is used (and, if so, where in the code) at run time under various conditions/scenarios.

"used" does not only mean assigned a value but for instance printed ou used to evaluate an expression.

Is there a way to detect this variable use at run time, for instance with the debugger.

  • You might be able to put a breakpoint with edebug everywhere a variable is used. – npostavs Dec 8 '17 at 13:38
  • @npostav Npostav mentioned there that he implemented a debug on setting of variables in emacs 26: emacs.stackexchange.com/questions/27962/…. To detect access to some variable you can make it unbound with makunbound after the program set it. Maybe, remember the value in some replacement variable. If you debug on error you get a backtrace the next time the variable's value cell is accessed. If you want to continue you can re-evaluate the form with the remembered value (maybe). – Tobias Dec 9 '17 at 11:13

Your Answer

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

Browse other questions tagged or ask your own question.