]> git.eshelyaron.com Git - emacs.git/commitdiff
Flush the tool bar cache on all terminals when adding new entries
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 4 May 2022 07:34:56 +0000 (09:34 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 4 May 2022 07:35:05 +0000 (09:35 +0200)
* lisp/tool-bar.el (tool-bar--flush-cache): Flush the cache for
the current tool bar on all terminals.

lisp/tool-bar.el

index b3915c267cca2cb6bdfaa8e0cfe50cc010e86ef0..82b458e01079559fa80e68c263d92405ad855066 100644 (file)
@@ -95,7 +95,15 @@ functions.")
   (cons (frame-terminal) (sxhash-eq tool-bar-map)))
 
 (defun tool-bar--flush-cache ()
-  (setf (gethash (tool-bar--cache-key) tool-bar-keymap-cache) nil))
+  "Remove all cached entries that refer to the current `tool-bar-map'."
+  (let ((id (sxhash-eq tool-bar-map))
+        (entries nil))
+    (maphash (lambda (k _)
+               (when (equal (cdr k) id)
+                 (push k entries)))
+             tool-bar-keymap-cache)
+    (dolist (k entries)
+      (remhash k tool-bar-keymap-cache))))
 
 (defun tool-bar-make-keymap (&optional _ignore)
   "Generate an actual keymap from `tool-bar-map'.