Function: tab-bar--define-keys

tab-bar--define-keys is a byte-compiled function defined in tab-bar.el.gz.

Signature

(tab-bar--define-keys)

Documentation

Install key bindings to switch between tabs if so configured.

Source Code

;; Defined in /usr/src/emacs/lisp/tab-bar.el.gz
(defun tab-bar--define-keys ()
  "Install key bindings to switch between tabs if so configured."
  (when (and (memq tab-bar-define-keys '(t numeric))
             tab-bar-select-tab-modifiers)
    (define-key tab-bar-mode-map
                (vector (append tab-bar-select-tab-modifiers (list ?0)))
                #'tab-recent)
    (dotimes (i 8)
      (define-key tab-bar-mode-map
                  (vector (append tab-bar-select-tab-modifiers
                                  (list (+ i 1 ?0))))
                  #'tab-bar-select-tab))
    (define-key tab-bar-mode-map
                (vector (append tab-bar-select-tab-modifiers (list ?9)))
                #'tab-last))

  (when (memq tab-bar-define-keys '(t tab))
    (unless (global-key-binding [(control tab)])
      (define-key tab-bar-mode-map [(control tab)] #'tab-next))
    (unless (global-key-binding [(control shift tab)])
      (define-key tab-bar-mode-map [(control shift tab)] #'tab-previous))
    (unless (global-key-binding [(control shift iso-lefttab)])
      (define-key tab-bar-mode-map [(control shift iso-lefttab)] #'tab-previous)))

  ;; Replace default value with a condition that supports displaying
  ;; global-mode-string in the tab bar instead of the mode line.
  (when (and (memq 'tab-bar-format-global tab-bar-format)
             (member '(global-mode-string ("" global-mode-string))
                     mode-line-misc-info))
    (setf (alist-get 'global-mode-string mode-line-misc-info)
          '(("" (:eval (if (and tab-bar-mode
                                (memq 'tab-bar-format-global
                                      tab-bar-format))
                           "" global-mode-string)))))))