]> git.eshelyaron.com Git - emacs.git/commitdiff
Make adding things to the tool bar show up on next redisplay
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 3 May 2022 16:19:13 +0000 (18:19 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 3 May 2022 16:19:13 +0000 (18:19 +0200)
* lisp/tool-bar.el (tool-bar--flush-cache): New function.
(tool-bar-add-item): Flush the cache (bug#43397).

lisp/tool-bar.el

index 7ec5c0becccb44d5cb0c02aa7e354600a38b89b3..1271d1de23be81dd69a6d0c6ef1b6999d05bd39d 100644 (file)
@@ -91,6 +91,10 @@ functions.")
 
 (defconst tool-bar-keymap-cache (make-hash-table :weakness t :test 'equal))
 
+(defun tool-bar--flush-cache ()
+  (setf (gethash (cons (frame-terminal) tool-bar-map) tool-bar-keymap-cache)
+        nil))
+
 (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
@@ -139,7 +143,8 @@ ICON.xbm, using `find-image'.
 
 Use this function only to make bindings in the global value of `tool-bar-map'.
 To define items in any other map, use `tool-bar-local-item'."
-  (apply #'tool-bar-local-item icon def key tool-bar-map props))
+  (apply #'tool-bar-local-item icon def key tool-bar-map props)
+  (tool-bar--flush-cache))
 
 (defun tool-bar--image-expression (icon)
   "Return an expression that evaluates to an image spec for ICON."