Variable: global-kkp-mode

global-kkp-mode is a customizable variable defined in kkp.el.

Value

nil

Documentation

Non-nil if Global Kkp mode is enabled.

See the global-kkp-mode(var)/global-kkp-mode(fun) command for a description of this minor mode. Setting this variable directly does not take effect; either customize it (see the info node (emacs)Easy Customization) or call the function global-kkp-mode(var)/global-kkp-mode(fun).

Key Bindings

This command is not in any keymaps.

Source Code

;; Defined in /nix/store/0igl9q4k4n87vg4h2gnnrlha21kx9biv-emacs-packages-deps/share/emacs/site-lisp/elpa/kkp-20260706.858/kkp.el
;;;###autoload
(define-minor-mode global-kkp-mode
  "Toggle KKP support in all terminal frames."
  :global t
  :lighter nil
  :group 'kkp
  (cond
   (global-kkp-mode
    ;; if terminal has KKP enabled, it supports symbol names as keys
    (advice-add 'display-symbol-keys-p :around #'kkp--display-symbol-keys-p)
    ;; call setup for future terminals to be opened
    (add-hook 'tty-setup-hook #'kkp-enable-in-terminal)
    ;; call teardown for terminals to be closed
    (add-hook 'kill-emacs-hook #'kkp--disable-in-active-terminals)
    ;; we call this on each frame teardown, this has no effects if kkp is not enabled
    (add-to-list 'delete-terminal-functions #'kkp--terminal-teardown)
    (add-hook 'suspend-hook #'kkp--suspend-in-terminal)
    (add-hook 'suspend-resume-hook #'kkp--resume-in-terminal)
    (add-hook 'suspend-tty-functions #'kkp--suspend-in-terminal)
    (add-hook 'resume-tty-functions #'kkp--resume-in-terminal)
    (advice-add 'delete-frame :before #'kkp--pre-delete-frame)
    ;; opt-in: let C-g abort blocking call-process calls (see the defcustom)
    (when kkp-restore-legacy-keys-around-subprocesses
      (advice-add 'call-process :around #'kkp-restore-legacy-keys))


    ;; this is by far the most reliable method to enable kkp in all associated terminals
    ;; trying to switch to each terminal with `with-selected-frame' does not work very well
    ;; as input from `read-event' cannot be reliably read from the corresponding terminal
    (add-function :after after-focus-change-function #'kkp-focus-change)
    ;; forget which terminals were enable-attempted, so focus re-enables them
    (dolist (terminal (terminal-list))
      (let ((state (kkp--terminal-state terminal)))
        (when state
          (setf (kkp--state-setup-visited state) nil))))

    ;; At startup, this global mode might be called before the 'tty-setup-hook'.
    ;; To avoid running 'kkp-enable-in-terminal' before, we only run it if
    ;; the 'tty-run-terminal-initialization' already ran.
    (when (terminal-parameter (kkp--selected-terminal) 'terminal-initted)
      (kkp-enable-in-terminal)))
   (t
    (advice-remove 'display-symbol-keys-p #'kkp--display-symbol-keys-p)
    (kkp--disable-in-active-terminals)
    (remove-hook 'tty-setup-hook #'kkp-enable-in-terminal)
    (remove-hook 'kill-emacs-hook #'kkp--disable-in-active-terminals)
    (remove-hook 'suspend-hook #'kkp--suspend-in-terminal)
    (remove-hook 'suspend-resume-hook #'kkp--resume-in-terminal)
    (remove-hook 'suspend-tty-functions #'kkp--suspend-in-terminal)
    (remove-hook 'resume-tty-functions #'kkp--resume-in-terminal)
    (advice-remove 'delete-frame #'kkp--pre-delete-frame)
    (advice-remove 'call-process #'kkp-restore-legacy-keys)
    (remove-function after-focus-change-function #'kkp-focus-change)
    (setq delete-terminal-functions (delete #'kkp--terminal-teardown delete-terminal-functions)))))