diff options
author | Juri Linkov <juri@linkov.net> | 2021-09-15 19:03:13 +0300 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2021-09-15 19:03:13 +0300 |
commit | 6d65d50f71d7415833a1d27bae9b88cb46ff2198 (patch) | |
tree | 960ca11f4deab62db1871869cb6c4ac84d3a0f20 /lisp/tab-bar.el | |
parent | 231a29f36333d10b7122bb9e25da4db8cb03b73d (diff) | |
download | emacs-6d65d50f71d7415833a1d27bae9b88cb46ff2198.tar.gz emacs-6d65d50f71d7415833a1d27bae9b88cb46ff2198.tar.bz2 emacs-6d65d50f71d7415833a1d27bae9b88cb46ff2198.zip |
* lisp/tab-bar.el (tab-bar-format): Add new option tab-bar-format-menu-global
(tab-bar-format-menu-global): New function.
Diffstat (limited to 'lisp/tab-bar.el')
-rw-r--r-- | lisp/tab-bar.el | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index d6173d9ca42..599fe743167 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -528,6 +528,7 @@ and `tab-bar-select-tab-modifiers'." "String that delimits tabs.") (defun tab-bar-separator () + "Separator between tabs." (or tab-bar-separator (if window-system " " "|"))) @@ -679,7 +680,8 @@ it will display time aligned to the right on the tab bar instead of the mode line. Replacing `tab-bar-format-tabs' with `tab-bar-format-tabs-groups' will group tabs on the tab bar." :type 'hook - :options '(tab-bar-format-history + :options '(tab-bar-format-menu-global + tab-bar-format-history tab-bar-format-tabs tab-bar-format-tabs-groups tab-bar-separator @@ -693,6 +695,23 @@ the mode line. Replacing `tab-bar-format-tabs' with :group 'tab-bar :version "28.1") +(defun tab-bar-format-menu-global () + "Show global menu on clicking the Menu button." + `((add-tab menu-item (propertize "Menu" 'face 'tab-bar-tab-inactive) + (lambda (event) (interactive "e") + (let ((menu (make-sparse-keymap + (propertize "Global Menu" 'hide t)))) + + (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) + (map-keymap (lambda (key binding) + (when (consp binding) + (define-key-after menu (vector key) + (copy-sequence binding)))) + (lookup-key global-map [menu-bar])) + + (popup-menu menu event))) + :help "Global Menu"))) + (defun tab-bar-format-history () "Show back and forward buttons when `tab-bar-history-mode' is enabled. You can hide these buttons by customizing `tab-bar-format' and removing @@ -708,6 +727,7 @@ You can hide these buttons by customizing `tab-bar-format' and removing :help "Click to go forward in tab history")))) (defun tab-bar--format-tab (tab i) + "Format TAB using its index I and return the result as a string." (append `((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore)) (cond @@ -729,6 +749,7 @@ You can hide these buttons by customizing `tab-bar-format' and removing ,(alist-get 'close-binding tab)))))) (defun tab-bar-format-tabs () + "Show all tabs." (let ((i 0)) (mapcan (lambda (tab) @@ -799,6 +820,7 @@ Function gets one argument: a tab." :help "Click to visit group")))) (defun tab-bar-format-tabs-groups () + "Show tabs with their groups." (let* ((tabs (funcall tab-bar-tabs-function)) (current-group (funcall tab-bar-tab-group-function (tab-bar--current-tab-find tabs))) @@ -827,6 +849,7 @@ Function gets one argument: a tab." tabs))) (defun tab-bar-format-add-tab () + "Button to add a new tab." (when (and tab-bar-new-button-show tab-bar-new-button) `((add-tab menu-item ,tab-bar-new-button tab-bar-new-tab :help "New tab")))) |