From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#19480: (no subject) Date: Thu, 01 Jan 2015 17:35:28 +0200 Message-ID: <83ppaybjjz.fsf@gnu.org> References: <1465149162.16157.1419518913269.JavaMail.help@alum.mit.edu> <8761cr79i5.fsf@web.de> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1420126579 13181 80.91.229.3 (1 Jan 2015 15:36:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 1 Jan 2015 15:36:19 +0000 (UTC) Cc: bjvilfan@gmail.com, 19480@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 01 16:36:12 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Y6hnH-0000Ss-Sz for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Jan 2015 16:36:12 +0100 Original-Received: from localhost ([::1]:48865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6hnH-0006pM-Bz for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Jan 2015 10:36:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6hnD-0006pG-8h for bug-gnu-emacs@gnu.org; Thu, 01 Jan 2015 10:36:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y6hn9-00046z-6Q for bug-gnu-emacs@gnu.org; Thu, 01 Jan 2015 10:36:07 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:53402) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6hn9-00046v-3E for bug-gnu-emacs@gnu.org; Thu, 01 Jan 2015 10:36:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Y6hn8-0001OG-UE for bug-gnu-emacs@gnu.org; Thu, 01 Jan 2015 10:36:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Jan 2015 15:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 19480 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-Cc: bjvilfan@gmail.com, bug-gnu-emacs@gnu.org, monnier@iro.umontreal.ca Original-Received: via spool by submit@debbugs.gnu.org id=B.14201265515327 (code B ref -1); Thu, 01 Jan 2015 15:36:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 1 Jan 2015 15:35:51 +0000 Original-Received: from localhost ([127.0.0.1]:34535 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y6hmx-0001Nr-4T for submit@debbugs.gnu.org; Thu, 01 Jan 2015 10:35:51 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:40715) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y6hmu-0001Nh-KG for submit@debbugs.gnu.org; Thu, 01 Jan 2015 10:35:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y6hmt-00044O-11 for submit@debbugs.gnu.org; Thu, 01 Jan 2015 10:35:48 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:44552) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6hms-00044I-UQ for submit@debbugs.gnu.org; Thu, 01 Jan 2015 10:35:46 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6hmn-0006o0-K7 for bug-gnu-emacs@gnu.org; Thu, 01 Jan 2015 10:35:46 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y6hmi-000422-8q for bug-gnu-emacs@gnu.org; Thu, 01 Jan 2015 10:35:41 -0500 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:45831) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6hmh-00041D-VA for bug-gnu-emacs@gnu.org; Thu, 01 Jan 2015 10:35:36 -0500 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0NHI00D008G8LR00@a-mtaout22.012.net.il> for bug-gnu-emacs@gnu.org; Thu, 01 Jan 2015 17:35:34 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NHI00DBR8N9E230@a-mtaout22.012.net.il>; Thu, 01 Jan 2015 17:35:34 +0200 (IST) In-reply-to: <8761cr79i5.fsf@web.de> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:97914 Archived-At: [Moved this here from help-gnu-emacs. For the original thread, see http://lists.gnu.org/archive/html/help-gnu-emacs/2014-12/msg00379.html.] > From: Michael Heerdegen > Date: Wed, 31 Dec 2014 23:13:54 +0100 > Cc: Emacs Help , > Stefan Monnier > > Bostjan Vilfan writes: > > (progn > (define-key global-map [tool-bar bvdotex] 'tex-file) > (tool-bar-local-item "save" 'tex-file 'bvdotex tool-bar-map > :help "Process file with default tex command")) > > Evaluate it, and you have to "do some things" until the item is displayed. > No way of redisplay helps to force the displaying of the button, and it > seems to appear after a random command. > > I guess all the Emacs modes set up the toolbar before it is actually > displayed. Doing it afterwards doesn't seem to work reliably. I don't > see such a limitation being described in the manual This should fix the problem: (progn (define-key global-map [tool-bar bvdotex] 'tex-file) (tool-bar-local-item "save" 'tex-file 'bvdotex tool-bar-map :help "Process file with default tex command") (force-mode-line-update) (garbage-collect)) The last line is the reason that you need to "do some things" in order for the tool bar to get updated: you need to eval enough stuff so that Emacs enters GC. This is a clear bug, and it has 2 parts, an easy one and a harder one. The easy part is to add a call to force-mode-line-update to 2 functions that modify tool-bar-map (done in commit 5a9710f on the emacs-24 branch). The harder part, the one that requires a GC, has something to do with the fact that we use a hash table to avoid recomputing tool-bar items when the tool bar didn't change. From tool-bar.el: (global-set-key [tool-bar] `(menu-item ,(purecopy "tool bar") ignore :filter tool-bar-make-keymap)) (defconst tool-bar-keymap-cache (make-hash-table :weakness t :test 'equal)) (defun tool-bar-make-keymap (&optional _ignore) "Generate an actual keymap from `tool-bar-map'. Its main job is to figure out which images to use based on the display's color capability and based on the available image libraries." (let ((key (cons (frame-terminal) tool-bar-map))) (or (gethash key tool-bar-keymap-cache) (puthash key (tool-bar-make-keymap-1) tool-bar-keymap-cache)))) We started doing this in Emacs 23, and sure enough, this problem didn't exist in Emacs 22, where just evaluating the original progn above, without the last two lines, immediately caused the tool bar to be updated. Emacs 23 already exhibits the problem. By stepping through tool-bar-make-keymap, I've discovered that after the tool-bar-map is updated, gethash still returns non-nil, as if the old value of tool-bar-map were still in effect. So we don't recompute the updated keymap from tool-bar-map, and redisplay doesn't think the tool bar changed and should be redrawn. Mind you, this is on MS-Windows, which represents the toolkits where Emacs itself displays the tool bar; the GTK and NS builds might have different or additional quirks. I hope the above will give enough info to keymap experts to fix the remaining problem (please do that on the emacs-24 branch).