From 06df77af4794cc94e534aa695da06ff064e47e76 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 21 Nov 2015 17:02:42 -0500 Subject: [PATCH v2 3/3] Ensure redisplay using variable watcher Instead of looking up the variable name in redisplay--variables when setting. * lisp/frame.el: Replace redisplay--variables with add-variable-watcher calls. * src/xdisp.c (set_redisplay): Rename from maybe_set_redisplay, set the redisplay flag unconditionally. * src/data.c (watcher_table): Add set_resdisplay. (syms_of_data): New var set-redisplay-internal-watcher-number. (set_internal): Remove maybe_set_redisplay call. --- lisp/emacs-lisp/debug.el | 2 +- lisp/frame.el | 3 +-- src/data.c | 11 +++++++++-- src/window.h | 2 +- src/xdisp.c | 15 ++++----------- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el index 68be115..e20654e 100644 --- a/lisp/emacs-lisp/debug.el +++ b/lisp/emacs-lisp/debug.el @@ -864,7 +864,7 @@ (defun debugger-list-functions () (princ "Note: if you have redefined a function, then it may no longer\n") (princ "be set to debug on entry, even if it is in the list.")))))) -(defun debug--implement-debug-watch (op where symbol newval) +(defun debug--implement-debug-watch (symbol newval op where) "Conditionally call the debugger. This function is called when SYMBOL's value is modified." (if (or inhibit-debug-on-entry debugger-jumping-flag) diff --git a/lisp/frame.el b/lisp/frame.el index f024065..79c954a 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -2232,9 +2232,8 @@ (make-obsolete-variable 'window-system-version "it does not give useful information." "24.3") ;; Variables which should trigger redisplay of the current buffer. -(setq redisplay--variables (make-hash-table :test 'eq :size 10)) (mapc (lambda (var) - (puthash var 1 redisplay--variables)) + (add-variable-watcher var set-redisplay-internal-watcher-number)) '(line-spacing overline-margin line-prefix diff --git a/src/data.c b/src/data.c index 1576280..a1ceeec 100644 --- a/src/data.c +++ b/src/data.c @@ -33,6 +33,7 @@ #include "keyboard.h" #include "frame.h" #include "keymap.h" +#include "window.h" static void notify_variable_watchers (Lisp_Object symbol, Lisp_Object newval, @@ -1262,8 +1263,6 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where, default: ; } - maybe_set_redisplay (symbol); - start: switch (sym->redirect) { @@ -1435,9 +1434,11 @@ DEFUN ("remove-variable-watcher", Fremove_variable_watcher, Sremove_variable_wat typedef void (*WATCHER_FUNCTION) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); static const WATCHER_FUNCTION watcher_table[] = { + &set_redisplay }; enum { + WATCHER_NUMBER_SET_REDISPLAY }; static void @@ -3825,4 +3826,10 @@ syms_of_data (void) DEFSYM (Qset_default, "Qset_default"); defsubr (&Sadd_variable_watcher); defsubr (&Sremove_variable_watcher); + + DEFVAR_INT ("set-redisplay-internal-watcher-number", + Vset_redisplay_internal_watcher_number, + doc: /* Internal watch function constant. */); + Vset_redisplay_internal_watcher_number = WATCHER_NUMBER_SET_REDISPLAY; + make_symbol_constant (intern_c_string ("set-redisplay-internal-watcher-number")); } diff --git a/src/window.h b/src/window.h index 135f5de..ebf5ef7 100644 --- a/src/window.h +++ b/src/window.h @@ -1056,7 +1056,7 @@ extern void wset_redisplay (struct window *w); extern void fset_redisplay (struct frame *f); extern void bset_redisplay (struct buffer *b); extern void bset_update_mode_line (struct buffer *b); -extern void maybe_set_redisplay (Lisp_Object); +extern void set_redisplay (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); /* Call this to tell redisplay to look for other windows than selected-window that need to be redisplayed. Calling one of the *set_redisplay functions above already does it, so it's only needed in unusual cases. */ diff --git a/src/xdisp.c b/src/xdisp.c index 30dfac5..5c5c4d2 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -621,14 +621,11 @@ bset_update_mode_line (struct buffer *b) } void -maybe_set_redisplay (Lisp_Object symbol) +set_redisplay (Lisp_Object symbol, Lisp_Object newval, + Lisp_Object op, Lisp_Object where) { - if (HASH_TABLE_P (Vredisplay__variables) - && hash_lookup (XHASH_TABLE (Vredisplay__variables), symbol, NULL) >= 0) - { - bset_update_mode_line (current_buffer); - current_buffer->prevent_redisplay_optimizations_p = true; - } + bset_update_mode_line (current_buffer); + current_buffer->prevent_redisplay_optimizations_p = true; } #ifdef GLYPH_DEBUG @@ -31477,10 +31474,6 @@ or t (meaning all windows). */); DEFVAR_LISP ("redisplay--mode-lines-cause", Vredisplay__mode_lines_cause, doc: /* */); Vredisplay__mode_lines_cause = Fmake_hash_table (0, NULL); - - DEFVAR_LISP ("redisplay--variables", Vredisplay__variables, - doc: /* A hash-table of variables changing which triggers a thorough redisplay. */); - Vredisplay__variables = Qnil; } -- 2.6.2