Function: treemacs--find-keybind

treemacs--find-keybind is a byte-compiled function defined in treemacs-hydras.el.

Signature

(treemacs--find-keybind FUNC &optional (PAD 8))

Documentation

Find the keybind for FUNC in treemacs.

Return of cons of the key formatted for inclusion in the hydra string, including a minimum PAD width for alignment, and the key itself for the hydra heads. Prefer evil keybinds, otherwise pick the first result.

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-hydras.el
(cl-defun treemacs--find-keybind (func &optional (pad 8))
  "Find the keybind for FUNC in treemacs.
Return of cons of the key formatted for inclusion in the hydra string, including
a minimum PAD width for alignment, and the key itself for the hydra heads.
Prefer evil keybinds, otherwise pick the first result."
  (-if-let (keys (where-is-internal func))
      (let ((key
             (key-description
              (-if-let (evil-keys (--first (eq 'treemacs-state (aref it 0)) keys))
                  (--map (aref evil-keys it) (number-sequence 1 (- (length evil-keys) 1)))
                (--map (aref (car keys) it) (number-sequence 0 (- (length (car keys)) 1)))))))
        (setf key
              (s-replace-all
               '(("<return>" . "RET")
                 ("<left>"   . "LEFT")
                 ("<right>"  . "RIGHT")
                 ("<up>"     . "UP")
                 ("<down>"   . "DOWN")
                 ("^"        . "C-")
                 ("⇢⌥"     . ">O-")
                 ("⌥"       . "O-")
                 ("⇢⌘"      . ">#-")
                 ("⌘"       . "#-")
                 ("⇧"        . "S-"))
               key))
        (cons (s-pad-right pad " " (format "_%s_:" key)) key))
    (cons (s-pad-right pad " " (format "_%s_:" " ")) " ")))