Function: cider--compile-font-lock-keywords

cider--compile-font-lock-keywords is a byte-compiled function defined in cider-mode.el.

Signature

(cider--compile-font-lock-keywords SYMBOLS-PLIST CORE-PLIST)

Documentation

Return a list of font-lock rules for symbols in SYMBOLS-PLIST, CORE-PLIST.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider-mode.el
(defun cider--compile-font-lock-keywords (symbols-plist core-plist)
  "Return a list of font-lock rules for symbols in SYMBOLS-PLIST, CORE-PLIST."
  (let ((cider-font-lock-dynamically (if (eq cider-font-lock-dynamically t)
                                         '(function var macro core deprecated)
                                       cider-font-lock-dynamically))
        deprecated enlightened
        macros functions vars instrumented traced)
    (cl-flet ((handle-plist
                 (plist)
                 ;; Note that (memq 'function cider-font-lock-dynamically) and similar statements are evaluated differently
                 ;; for `core' - they're always truthy for `core' (see related core-handling code some lines below):
                 (let ((do-function (memq 'function cider-font-lock-dynamically))
                       (do-var (memq 'var cider-font-lock-dynamically))
                       (do-macro (memq 'macro cider-font-lock-dynamically))
                       (do-deprecated (memq 'deprecated cider-font-lock-dynamically)))
                   (while plist
                     (let ((sym (pop plist))
                           (meta (pop plist)))
                       (pcase (nrepl-dict-get meta "cider/instrumented")
                         (`nil nil)
                         (`"\"breakpoint-if-interesting\""
                          (push sym instrumented))
                         (`"\"light-form\""
                          (push sym enlightened)))
                       ;; FIXME: This matches values too, not just keys.
                       (when (or (nrepl-dict-get meta "orchard.trace/traced")
                                 (nrepl-dict-get meta "orchard.profile/profiled"))
                         (push sym traced))
                       (when (and do-deprecated (nrepl-dict-get meta "deprecated"))
                         (push sym deprecated))
                       (let ((is-macro (nrepl-dict-get meta "macro"))
                             (is-function (nrepl-dict-get meta "fn")))
                         (cond ((and do-macro is-macro)
                                (push sym macros))
                               ((and do-function is-function)
                                (push sym functions))
                               ((and do-var (not is-function) (not is-macro))
                                (push sym vars)))))))))
      ;; For core members, we override `cider-font-lock-dynamically', since all core members should get the same treatment:
      (when (memq 'core cider-font-lock-dynamically)
        (let ((cider-font-lock-dynamically '(function var macro core deprecated)))
          (handle-plist core-plist)))
      (handle-plist symbols-plist))
    `(
      ,@(when macros
          `((,(concat (rx (or "(" "#'")) ; Can't take the value of macros.
                      "\\(" (regexp-opt macros 'symbols) "\\)")
             1 (cider--unless-local-match font-lock-keyword-face))))
      ,@(when functions
          `((,(regexp-opt functions 'symbols) 0
             (cider--unless-local-match font-lock-function-name-face))))
      ,@(when vars
          `((,(regexp-opt vars 'symbols) 0
             (cider--unless-local-match font-lock-variable-name-face))))
      ,@(when deprecated
          `((,(regexp-opt deprecated 'symbols) 0
             (cider--unless-local-match 'cider-deprecated-face) append)))
      ,@(when enlightened
          `((,(regexp-opt enlightened 'symbols) 0
             (cider--unless-local-match 'cider-enlightened-face) append)))
      ,@(when instrumented
          `((,(regexp-opt instrumented 'symbols) 0
             (cider--unless-local-match 'cider-instrumented-face) append)))
      ,@(when traced
          `((,(regexp-opt traced 'symbols) 0
             (cider--unless-local-match 'cider-traced-face) append))))))