Function: nerd-icons-corfu--get-by-kind

nerd-icons-corfu--get-by-kind is a natively compiled function defined in nerd-icons-corfu.el.

Signature

(nerd-icons-corfu--get-by-kind KIND CAND)

Documentation

Returns the icon glyph for kind KIND, possibly checking CAND.

The mapping of kind -> icon is defined by the user in nerd-icons-corfu-mapping. CAND is used if the mapping for the selected KIND is dynamic (has an :fn property).

Source Code

;; Defined in /nix/store/ky28nmc5qmvi3lsiyb1z1s7r517z21y6-emacs-packages-deps/share/emacs/site-lisp/elpa/nerd-icons-corfu-20260904.1927/nerd-icons-corfu.el
(defun nerd-icons-corfu--get-by-kind (kind cand)
  "Returns the icon glyph for kind KIND, possibly checking CAND.

The mapping of kind -> icon is defined by the user in
`nerd-icons-corfu-mapping'.  CAND is used if the mapping for the selected KIND
is dynamic (has an `:fn' property)."
  (let* ((icon-entry (or (alist-get (or kind t) nerd-icons-corfu-mapping)
                         (alist-get t nerd-icons-corfu-mapping)))
         (face-from-entry (plist-get icon-entry :face))
         (icon (or (and-let* ((fn (plist-get icon-entry :fn))
                              (icon (funcall fn cand))))
                   (and-let* ((style (plist-get icon-entry :style))
                              (icon (plist-get icon-entry :icon))
                              (icon-fn (intern (concat "nerd-icons-" style "icon")))
                              (icon-name (concat "nf-" style "-" icon))
                              ((fboundp icon-fn))
                              ((funcall icon-fn icon-name))))
                   "?"))
         (face-from-icon (get-text-property 0 'face icon))
         (composed-face (if face-from-entry
                            `(,@face-from-icon :inherit ,face-from-entry)
                          face-from-icon)))
    (propertize icon 'face composed-face)))