bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#38173: describe-variable: Also tell user *where* variable was change


From: Phil Sainty
Subject: bug#38173: describe-variable: Also tell user *where* variable was changed
Date: Wed, 13 Nov 2019 12:10:37 +1300
User-agent: Orcon Webmail

On 2019-11-12 15:45, 積丹尼 Dan Jacobson wrote:
It's like telling users "you transferred $123 from your bank
account" but not telling users who they transferred it to.

That's pretty crucial information for a bank transfer.  Not so much
for every arbitrary variable change (and I think you'd need to be
making an incredible number of bank transactions for the analogy to
hold up :)

Logging every change of every variable made during the execution of a
computer program might carry a noticeable cost, vs the absolutely
tiny number of cases where the logged information would ever be
inspected, so it's not obvious that this would be worthwhile on the
whole?

However, since 26.1 you can do this yourself on a case-by-case basis
when you wish to investigate some particular situation. See: C-h f
add-variable-watcher and remove-variable-watcher, and commands M-x
[cancel-]debug-on-variable-change

Some extremely basic logging without invoking the debugger might be
something like:

    (defun var-watcher-backtrace (symbol newval operation where)
      "Used with `add-variable-watcher' to log details to *Messages*."
      (let ((frames (backtrace-frames)))
        (message "%S %S %S %S %S" symbol newval operation where
                 (pp-to-string frames))))

    (add-variable-watcher 'foo 'var-watcher-backtrace)


I suppose the variable watcher mechanism could check another variable
to decide whether to do the sort of "global watching" being requested
here.  Then users could turn the behaviour on if desired.


-Phil






reply via email to

[Prev in Thread] Current Thread [Next in Thread]