Function: hydra-fontify-head-default

hydra-fontify-head-default is a byte-compiled function defined in hydra.el.

Signature

(hydra-fontify-head-default HEAD BODY)

Documentation

Produce a pretty string from HEAD and BODY.

HEAD's binding is returned as a string with a colored face.

Source Code

;; Defined in ~/.emacs.d/elpa/hydra-20250316.1254/hydra.el
(defun hydra-fontify-head-default (head body)
  "Produce a pretty string from HEAD and BODY.
HEAD's binding is returned as a string with a colored face."
  (let* ((foreign-keys (hydra--body-foreign-keys body))
         (head-exit (hydra--head-property head :exit))
         (head-color
          (if head-exit
              (if (eq foreign-keys 'warn)
                  'teal
                'blue)
            (cl-case foreign-keys
              (warn 'amaranth)
              (run 'pink)
              (t 'red)))))
    (when (and (null (cadr head))
               (not head-exit))
      (hydra--complain "nil cmd can only be blue"))
    (propertize
     (replace-regexp-in-string "%" "%%" (car head))
     'face
     (or (hydra--head-property head :face)
         (cl-case head-color
           (blue 'hydra-face-blue)
           (red 'hydra-face-red)
           (amaranth 'hydra-face-amaranth)
           (pink 'hydra-face-pink)
           (teal 'hydra-face-teal)
           (t (error "Unknown color for %S" head)))))))