>From dda5dc2280e77c664e7f479eb9bd84e2db2024f0 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 19 Nov 2016 16:50:34 -0500 Subject: [PATCH v6 2/6] Show watchpoints when describing variables * src/data.c (Fget_variable_watchers): New function. * lisp/help-fns.el (describe-variable): Use it to detect watching functions. --- lisp/help-fns.el | 7 +++++++ src/data.c | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 87e7d8f..23dec89 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -918,6 +918,7 @@ describe-variable (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 @@ describe-variable (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)) diff --git a/src/data.c b/src/data.c index 8954b42..911789f 100644 --- a/src/data.c +++ b/src/data.c @@ -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, @@ -3880,4 +3890,5 @@ syms_of_data (void) DEFSYM (Qset_default, "set-default"); defsubr (&Sadd_variable_watcher); defsubr (&Sremove_variable_watcher); + defsubr (&Sget_variable_watchers); } -- 2.9.3