]> git.eshelyaron.com Git - emacs.git/commitdiff
Show watchpoints when describing variables
authorNoam Postavsky <npostavs@gmail.com>
Sat, 19 Nov 2016 21:50:34 +0000 (16:50 -0500)
committerNoam Postavsky <npostavs@gmail.com>
Sat, 3 Dec 2016 01:25:14 +0000 (20:25 -0500)
* src/data.c (Fget_variable_watchers): New function.
* lisp/help-fns.el (describe-variable): Use it to detect watching
functions.

lisp/help-fns.el
src/data.c

index 87e7d8f87bb41ef63e88a8ea42f0956bc6a9bd91..23dec896b8137d36b471d7e91e352ffb0fb42eff 100644 (file)
@@ -918,6 +918,7 @@ it is displayed along with the global value."
                               (indirect-variable variable)
                             (error variable)))
                    (obsolete (get variable 'byte-obsolete-variable))
+                   (watchpoints (get-variable-watchers variable))
                   (use (car obsolete))
                   (safe-var (get variable 'safe-local-variable))
                    (doc (or (documentation-property
@@ -967,6 +968,12 @@ if it is given a local binding.\n"))))
                             (t ".")))
                 (terpri))
 
+              (when watchpoints
+                (setq extra-line t)
+                (princ "  Calls these functions when changed: ")
+                (princ watchpoints)
+                (terpri))
+
              (when (member (cons variable val)
                             (with-current-buffer buffer
                               file-local-variables-alist))
index 07730d0924fbe57244f933b56c5eaebceef2a91e..095b740c1b2c1a3bfa11101fc8a06044a313293f 100644 (file)
@@ -1463,6 +1463,16 @@ SYMBOL (or its aliases) are set.  */)
   return Qnil;
 }
 
+DEFUN ("get-variable-watchers", Fget_variable_watchers, Sget_variable_watchers,
+       1, 1, 0,
+       doc: /* Return a list of SYMBOL's active watchers.  */)
+  (Lisp_Object symbol)
+{
+  return (SYMBOL_TRAPPED_WRITE_P (symbol) == SYMBOL_TRAPPED_WRITE)
+    ? Fget (Findirect_variable (symbol), Qwatchers)
+    : Qnil;
+}
+
 void
 notify_variable_watchers (Lisp_Object symbol,
                           Lisp_Object newval,
@@ -3874,4 +3884,5 @@ syms_of_data (void)
   DEFSYM (Qset_default, "set-default");
   defsubr (&Sadd_variable_watcher);
   defsubr (&Sremove_variable_watcher);
+  defsubr (&Sget_variable_watchers);
 }