unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#19480: (no subject)
       [not found]     ` <8761cr79i5.fsf@web.de>
@ 2015-01-01 15:35       ` Eli Zaretskii
  2015-01-01 20:37         ` Michael Heerdegen
  2022-05-03 16:58         ` bug#19480: Tool-bar modifications not reflected on display Lars Ingebrigtsen
  0 siblings, 2 replies; 4+ messages in thread
From: Eli Zaretskii @ 2015-01-01 15:35 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: bjvilfan, 19480

[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@web.de>
> Date: Wed, 31 Dec 2014 23:13:54 +0100
> Cc: Emacs Help <help-gnu-emacs@gnu.org>,
> 	Stefan Monnier <monnier@iro.umontreal.ca>
> 
> Bostjan Vilfan <bjvilfan@gmail.com> 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).





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#19480: (no subject)
  2015-01-01 15:35       ` bug#19480: (no subject) Eli Zaretskii
@ 2015-01-01 20:37         ` Michael Heerdegen
  2015-01-01 20:56           ` Eli Zaretskii
  2022-05-03 16:58         ` bug#19480: Tool-bar modifications not reflected on display Lars Ingebrigtsen
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Heerdegen @ 2015-01-01 20:37 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: bjvilfan, 19480

Hi Eli,

> 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))

I can confirm that this avoids the problem under Debian Gnu/Linux using
the GTK+ toolkit.

Michael.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#19480: (no subject)
  2015-01-01 20:37         ` Michael Heerdegen
@ 2015-01-01 20:56           ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2015-01-01 20:56 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: bjvilfan, 19480

> From: Michael Heerdegen <michael_heerdegen@web.de>
> Cc: bjvilfan@gmail.com,  19480@debbugs.gnu.org
> Date: Thu, 01 Jan 2015 21:37:52 +0100
> 
> Hi Eli,
> 
> > 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))
> 
> I can confirm that this avoids the problem under Debian Gnu/Linux using
> the GTK+ toolkit.

Thanks for checking.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#19480: Tool-bar modifications not reflected on display
  2015-01-01 15:35       ` bug#19480: (no subject) Eli Zaretskii
  2015-01-01 20:37         ` Michael Heerdegen
@ 2022-05-03 16:58         ` Lars Ingebrigtsen
  1 sibling, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-03 16:58 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Michael Heerdegen, bjvilfan, 19480, monnier

This was fixed for Emacs 29 in the bug#43397 bug report, so I'm also
closing this one.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no






^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-03 16:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1465149162.16157.1419518913269.JavaMail.help@alum.mit.edu>
     [not found] ` <jwvzja9j1z5.fsf-monnier+gmane.emacs.help@gnu.org>
     [not found]   ` <CAAm34zrwyZZBHrepzTkUa3Cy+JN6oNf-YS7YBTx=T6DOFA+6Fg@mail.gmail.com>
     [not found]     ` <8761cr79i5.fsf@web.de>
2015-01-01 15:35       ` bug#19480: (no subject) Eli Zaretskii
2015-01-01 20:37         ` Michael Heerdegen
2015-01-01 20:56           ` Eli Zaretskii
2022-05-03 16:58         ` bug#19480: Tool-bar modifications not reflected on display Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).