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

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

RE: Multiple runs of menu-bar-update-hook


From: Marshall, Simon
Subject: RE: Multiple runs of menu-bar-update-hook
Date: Fri, 28 Jul 2006 11:29:59 +0100

> The function update_menu_bar does various things, such as running
> menu-bar-update-hook.  Then it calls set_frame_menubar, with DEEP_P =
> 0.  This is supposed to tell set_frame_menubar not to run
> menu-bar-update-hook, and not to do various other things that would
> be redundant.

Apologies if this is noise.  I can see that update_menu_bar() attempts to
detect whether it needs to run the hook.  Amongst other things, that test
allows the hook to run if windows_or_buffers_changed is non-zero.  The
complexity of the test suggested to me that update_menu_bar() should not be
called as frequently as it is or perhaps from where it is, particularly
because...

I notice that the hook is run once whenever I down-mouse-1 on the menu bar
(at least with lucid or motif toolkit).  This may be a stupid question, but
isn't it enough to run at this point?  Does emacs need to run the hook
during buffer editing, window motion or frame switching?  (Obviously it
needs to be run during buffer or window switching.)  In other words, does
the hook need to be run from under redisplay() itself?

I appreciate there are some special cases when the hook should be run, such
as when the menu bar is reconfigured (eg, when the major mode changes).
But, assuming that these happen from a small number of interface functions
(eg, define-key), the hook could be run from lisp.  (The hook could also be
run from those functions that handle buffer or window switching.)

For example, to show how the update_menu_bar() test gets compromised, we get
runs of the hook with mouse-1 in a buffer (when the buffer is shown in more
than one frame) because windows_or_buffers_changed is set to 1 at this point
in modify_overlay():

  /* If this is a buffer not in the selected window,
     we must do other windows.  */
  if (buf != XBUFFER (XWINDOW (selected_window)->buffer))
    windows_or_buffers_changed = 1;
  /* If multiple windows show this buffer, we must do other windows.  */
  else if (buffer_shared > 1)
==>    windows_or_buffers_changed = 1;
  /* If we modify an overlay at the end of the buffer, we cannot
     be sure that window end is still valid.  */
  else if (end >= ZV && start <= ZV)
    windows_or_buffers_changed = 1;

(dbx) where
=>[1] modify_overlay(buf = 0x4c2c00, start = 32, end = 32), line 3673 in
"buffer.c"
  [2] Fmove_overlay(overlay = 1079977680, beg = 32, end = 32, buffer =
-2142491648), line 3763 in "buffer.c"
  [3] Ffuncall(nargs = 4, args = 0xffbed3a8), line 2993 in "eval.c"
  [4] Fbyte_code(bytestr = 1614550196, vector = -2143546172, maxdepth = 4),
line 679 in "bytecode.c"
  [5] funcall_lambda(fun = -2143546244, nargs = 4, arg_vector = 0xffbed694),
line 3171 in "eval.c"
  [6] Ffuncall(nargs = 5, args = 0xffbed690), line 3028 in "eval.c"
  [7] Fbyte_code(bytestr = 1614550636, vector = -2143545732, maxdepth = 6),
line 679 in "bytecode.c"
  [8] funcall_lambda(fun = -2143545800, nargs = 2, arg_vector = 0xffbed984),
line 3171 in "eval.c"
  [9] Ffuncall(nargs = 3, args = 0xffbed980), line 3028 in "eval.c"
  [10] Fbyte_code(bytestr = 1614549532, vector = -2143546836, maxdepth = 5),
line 679 in "bytecode.c"
  [11] funcall_lambda(fun = -2143546892, nargs = 1, arg_vector =
0xffbedc94), line 3171 in "eval.c"
  [12] Ffuncall(nargs = 2, args = 0xffbedc90), line 3028 in "eval.c"
  [13] Fcall_interactively(function = 544701776, record_flag = 541825024,
keys = -2142470144), line 880 in "callint.c"
  [14] Fcommand_execute(cmd = 544701776, record_flag = 541825024, keys =
541825024, special = 541825024), line 9780 in "keyboard.c"
  [15] command_loop_1(), line 1790 in "keyboard.c"
  [16] internal_condition_case(bfun = 0x1bb988 = &command_loop_1(), handlers
= 541881992, hfun = 0x1bafb8 = &cmd_error(Lisp_Object data)), line 1469 in
"eval.c"
  [17] command_loop_2(), line 1326 in "keyboard.c"
  [18] internal_catch(tag = 541883392, func = 0x1bb5a0 = &command_loop_2(),
arg = 541825024), line 1210 in "eval.c"
  [19] command_loop(), line 1305 in "keyboard.c"
  [20] recursive_edit_1(), line 1003 in "keyboard.c"
  [21] Frecursive_edit(), line 1064 in "keyboard.c"
  [22] main(argc = 2, argv = 0xffbee43c), line 1794 in "emacs.c"
(dbx) 




reply via email to

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