Function: which-key--key-description<

which-key--key-description< is a byte-compiled function defined in which-key.el.gz.

Signature

(which-key--key-description< A B &optional ALPHA)

Documentation

Key sorting function.

Used for which-key-key-order and which-key-key-order-alpha.

Source Code

;; Defined in /usr/src/emacs/lisp/which-key.el.gz
(defun which-key--key-description< (a b &optional alpha)
  "Key sorting function.
Used for `which-key-key-order' and `which-key-key-order-alpha'."
  (save-match-data
    (let* ((a (which-key--extract-key a))
           (b (which-key--extract-key b))
           (rngrgxp "^\\([^ ]+\\) \\.\\. [^ ]+")
           (a (if (string-match rngrgxp a) (match-string 1 a) a))
           (b (if (string-match rngrgxp b) (match-string 1 b) b))
           (aem? (string-equal a ""))
           (bem? (string-equal b ""))
           (a1? (= 1 (length a)))
           (b1? (= 1 (length b)))
           (srgxp "^\\(RET\\|SPC\\|TAB\\|DEL\\|LFD\\|ESC\\|NUL\\)")
           (asp? (string-match-p srgxp a))
           (bsp? (string-match-p srgxp b))
           (prrgxp "^\\(M\\|C\\|S\\|A\\|H\\|s\\)-")
           (apr? (string-match-p prrgxp a))
           (bpr? (string-match-p prrgxp b))
           (afn? (string-match-p "<f[0-9]+>" a))
           (bfn? (string-match-p "<f[0-9]+>" b)))
      (cond ((or aem? bem?) (and aem? (not bem?)))
            ((and asp? bsp?)
             (if (string-equal (substring a 0 3) (substring b 0 3))
                 (which-key--key-description<
                  (substring a 3) (substring b 3) alpha)
               (which-key--string< a b alpha)))
            ((or asp? bsp?) asp?)
            ((and a1? b1?) (which-key--string< a b alpha))
            ((or a1? b1?) a1?)
            ((and afn? bfn?)
             (< (string-to-number
                 (replace-regexp-in-string "<f\\([0-9]+\\)>" "\\1" a))
                (string-to-number
                 (replace-regexp-in-string "<f\\([0-9]+\\)>" "\\1" b))))
            ((or afn? bfn?) afn?)
            ((and apr? bpr?)
             (if (string-equal (substring a 0 2) (substring b 0 2))
                 (which-key--key-description<
                  (substring a 2) (substring b 2) alpha)
               (which-key--string< a b alpha)))
            ((or apr? bpr?) apr?)
            (t (which-key--string< a b alpha))))))