GNU bug report logs - #19480
Tool-bar modifications not reflected on display

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Eli Zaretskii <eliz@HIDDEN>; dated Thu, 1 Jan 2015 15:36:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Changed bug title to 'Tool-bar modifications not reflected on display' from '(no subject)' Request was from Eli Zaretskii <eliz@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 1 Jan 2015 15:35:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 01 10:35:51 2015
Received: from localhost ([127.0.0.1]:34535 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Y6hmx-0001Nr-4T
	for submit <at> debbugs.gnu.org; Thu, 01 Jan 2015 10:35:51 -0500
Received: from eggs.gnu.org ([208.118.235.92]:40715)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <eliz@HIDDEN>) id 1Y6hmu-0001Nh-KG
 for submit <at> debbugs.gnu.org; Thu, 01 Jan 2015 10:35:49 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1Y6hmt-00044O-11
 for submit <at> debbugs.gnu.org; Thu, 01 Jan 2015 10:35:48 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: **
X-Spam-Status: No, score=2.6 required=5.0 tests=BAYES_50,MISSING_SUBJECT,
 T_RP_MATCHES_RCVD autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:44552)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1Y6hms-00044I-UQ
 for submit <at> debbugs.gnu.org; Thu, 01 Jan 2015 10:35:46 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:42436)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1Y6hmn-0006o0-K7
 for bug-gnu-emacs@HIDDEN; Thu, 01 Jan 2015 10:35:46 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1Y6hmi-000422-8q
 for bug-gnu-emacs@HIDDEN; Thu, 01 Jan 2015 10:35:41 -0500
Received: from mtaout22.012.net.il ([80.179.55.172]:45831)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1Y6hmh-00041D-VA
 for bug-gnu-emacs@HIDDEN; Thu, 01 Jan 2015 10:35:36 -0500
Received: from conversion-daemon.a-mtaout22.012.net.il by
 a-mtaout22.012.net.il (HyperSendmail v2007.08) id
 <0NHI00D008G8LR00@HIDDEN> for bug-gnu-emacs@HIDDEN;
 Thu, 01 Jan 2015 17:35:34 +0200 (IST)
Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il
 (HyperSendmail v2007.08) with ESMTPA id
 <0NHI00DBR8N9E230@HIDDEN>;
 Thu, 01 Jan 2015 17:35:34 +0200 (IST)
Date: Thu, 01 Jan 2015 17:35:28 +0200
From: Eli Zaretskii <eliz@HIDDEN>
In-reply-to: <8761cr79i5.fsf@HIDDEN>
X-012-Sender: halo1@HIDDEN
To: Michael Heerdegen <michael_heerdegen@HIDDEN>
Message-id: <83ppaybjjz.fsf@HIDDEN>
References: <1465149162.16157.1419518913269.JavaMail.help@HIDDEN>
 <jwvzja9j1z5.fsf-monnier+gmane.emacs.help@HIDDEN>
 <CAAm34zrwyZZBHrepzTkUa3Cy+JN6oNf-YS7YBTx=T6DOFA+6Fg@HIDDEN>
 <8761cr79i5.fsf@HIDDEN>
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-Received-From: 2001:4830:134:3::11
X-Spam-Score: -3.0 (---)
X-Debbugs-Envelope-To: submit
Cc: bjvilfan@HIDDEN, bug-gnu-emacs@HIDDEN, monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: Eli Zaretskii <eliz@HIDDEN>
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.0 (---)

[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 <michael_heerdegen@HIDDEN>
> Date: Wed, 31 Dec 2014 23:13:54 +0100
> Cc: Emacs Help <help-gnu-emacs@HIDDEN>,
> 	Stefan Monnier <monnier@HIDDEN>
> 
> Bostjan Vilfan <bjvilfan@HIDDEN> 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).




Acknowledgement sent to Eli Zaretskii <eliz@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN.

Your message did not contain a Subject field. They are recommended and useful because the title of a $gBug is determined using this field. Please remember to include a Subject field in your messages in future.

Full text available.


Report forwarded to bug-gnu-emacs@HIDDEN:
bug#19480; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 1 Jan 2015 16:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.