From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#43397: 28.0.50; Adding tool bar items: update tool bar Date: Tue, 15 Sep 2020 18:27:17 +0300 Message-ID: <83lfhb83hm.fsf@gnu.org> References: <87h7s0jurl.fsf@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5537"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 43397@debbugs.gnu.org To: Caio Henrique , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 15 17:28:11 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kICsM-0001Iv-7U for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Sep 2020 17:28:10 +0200 Original-Received: from localhost ([::1]:56734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kICsK-0005VJ-QR for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Sep 2020 11:28:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kICsE-0005VB-JC for bug-gnu-emacs@gnu.org; Tue, 15 Sep 2020 11:28:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48685) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kICsE-0002x1-AE for bug-gnu-emacs@gnu.org; Tue, 15 Sep 2020 11:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kICsE-0001Dt-6y for bug-gnu-emacs@gnu.org; Tue, 15 Sep 2020 11:28:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Sep 2020 15:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43397 X-GNU-PR-Package: emacs Original-Received: via spool by 43397-submit@debbugs.gnu.org id=B43397.16001836394630 (code B ref 43397); Tue, 15 Sep 2020 15:28:02 +0000 Original-Received: (at 43397) by debbugs.gnu.org; 15 Sep 2020 15:27:19 +0000 Original-Received: from localhost ([127.0.0.1]:60227 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kICrX-0001Cb-Jy for submit@debbugs.gnu.org; Tue, 15 Sep 2020 11:27:19 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:38774) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kICrW-0001CP-BS for 43397@debbugs.gnu.org; Tue, 15 Sep 2020 11:27:18 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:47315) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kICrQ-0002sd-Pr; Tue, 15 Sep 2020 11:27:12 -0400 Original-Received: from [176.228.60.248] (port=4733 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kICrP-0002Xn-P7; Tue, 15 Sep 2020 11:27:12 -0400 In-Reply-To: <87h7s0jurl.fsf@gmail.com> (message from Caio Henrique on Mon, 14 Sep 2020 11:30:22 -0300) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:188127 Archived-At: > From: Caio Henrique > Date: Mon, 14 Sep 2020 11:30:22 -0300 > > 1. emacs -Q > 2. paste and eval this: > (progn > (tool-bar-add-item-from-menu 'undo-redo > "redo" nil :vert-only t) > (redraw-display) > (force-mode-line-update)) > > I'm using both redraw-display and force-mode-line-update to try to force > the tool-bar to draw the icon (I know that I should'nt do this, I'm just > trying to figure if this is a bug) (Calling force-mode-line-update won't help, because tool-bar-add-item-from-menu does it internally.) > but the icon only appears when I > click one or two times with the mouse anywhere in the buffer. I've now looked into this, and I'm quite sure it is not a redisplay bug. The display engine faithfully inspects the tool-bar items each time it is invoked after the above code runs, and each time it finds that the tool-bar items haven't changed -- until they do. Based on what I see, and on the modified recipe below, it looks like we stick to the old value of the tool-bar items, like if we cached them somewhere. Since I don't understand where is that "cache", I don't really have a clear idea of what triggers the flushing of that "cache", but one trigger I found is -- surprise! -- GC. To see this, perform the following greatly simplified recipe: emacs -Q M-x blink-cursor-mode RET M-x global-eldoc-mode RET (The last two commands are to make sure there are no redisplay cycles except due to changes in buffers or strings.) Then evaluate: (defun myfun () (interactive) (tool-bar-add-item "redo" 'undo-redo 'undo-redo) (garbage-collect)) (global-set-key [f5] 'myfun) Finally, press F5: you should see the "redo" icon appear immediately. Now repeat the same, in a fresh Emacs session, but this time remove the call to garbage-collect from myfun, and instead do this before evaluating the function and the global-set-key form: M-x set-variable RET garbage-collection-messages RET t RET Then evaluate the forms and press F5. The tool bar won't change. Now do some random clicks, watching the echo area: you will see that the tool bar is updated with the "redo" icon precisely when the "Garbage collecting..." message appears in the echo area. Maybe Stefan (CC'ed) can help us understand why this happens and how GC is involved in this...