;;; my-tool-bar.el --- Tool bar -*- lexical-binding: t -*- ;;; Commentary: ;;; Code: (defun my-tool-bar-newline () "Newline." "\n") (defun my-tool-bar-function-save (event) "Pop up the same menu as displayed by the menu bar. Used by `tab-bar-format-menu-bar'." (interactive "e") (let () ;;(message "%s" event) (save-buffer) ;;(message "foo") )) (defvar my-tool-bar-button-save "Save " "Button for going back in tab history.") (defun my-tool-bar-function-open (event) "Pop up the same menu as displayed by the menu bar. Used by `tab-bar-format-menu-bar'." (interactive "e") (let () ;;(message "%s" event) (if (featurep 'counsel) (counsel-find-file) (find-file)) ;;(message "foo") )) (defvar my-tool-bar-button-open "Open " "Button for going back in tab history.") ;; (defun my-tool-bar-format-save () ;; "Produce the Menu button for the tool bar that shows the menu bar." ;; `((menu-bar menu-item ,my-tool-bar-button-save ;; my-tool-bar-function-save :help "Save buffer"))) (defun my-tool-bar-format () "Produce tool-bar buttons for the tab bar. These buttons will be shown when `my-tool-bar-mode' is enabled. You can hide these buttons by customizing `tab-bar-format' and removing `my-tool-bar-format' from it." (when my-tool-bar-mode `(;;(sep-history-back menu-item ,(tab-bar-separator) ignore) (save menu-item ,my-tool-bar-button-save my-tool-bar-function-save :help "Save") ;;(sep-test menu-item "" ignore) (open menu-item ,my-tool-bar-button-open my-tool-bar-function-open :help "Open File...") (sep-tool-bar menu-item ,(my-tool-bar-newline) ignore) ))) (defun my-tool-bar--load-buttons () "Load the icons for the tool bar buttons." ;; (emoji "") see e.g. https://emojipedia.org/hamburger ;; (symbol "") see e.g. https://www.compart.com/en/unicode/U+2630 (require 'icons) (unless (iconp 'my-tool-bar-icon-save) (define-icon my-tool-bar-icon-save nil `((image "save.xpm" :height (1.5 . em) :margin ,tab-bar-button-margin :ascent center) (emoji "💾") (symbol "🖫") (text "Save" ;; :face tab-bar-tab-inactive )) "Icon for the menu bar." :version "29.1")) (setq my-tool-bar-button-save (icon-string 'my-tool-bar-icon-save)) (unless (iconp 'my-tool-bar-icon-open) (define-icon my-tool-bar-icon-open nil `((image "open.xpm" :height (1.5 . em) :margin ,tab-bar-button-margin :ascent center) (emoji "📂") (symbol "🗁") (text "Open" ;; :face tab-bar-tab-inactive )) "Icon for the menu bar." :version "29.1")) (setq my-tool-bar-button-open (icon-string 'my-tool-bar-icon-open)) ) (define-minor-mode my-tool-bar-mode "Toggle tab history mode for the tab bar. Tab history mode remembers window configurations used in every tab, and can restore them." :global t :group 'tab-bar (if my-tool-bar-mode (progn (my-tool-bar--load-buttons) ;;(add-hook 'pre-command-hook #'tab-bar--history-pre-change) ;;(add-hook 'window-configuration-change-hook #'tab-bar--history-change) ) ;;(remove-hook 'pre-command-hook #'tab-bar--history-pre-change) ;;(remove-hook 'window-configuration-change-hook #'tab-bar--history-change) ) ) (provide 'my-tool-bar) ;;; my-tool-bar.el ends here