Function: tutorial--sort-keys
tutorial--sort-keys is a byte-compiled function defined in
tutorial.el.gz.
Signature
(tutorial--sort-keys LEFT RIGHT)
Documentation
Sort predicate for use with tutorial--default-keys.
This is a predicate function to sort.
The sorting is for presentation purpose only and is done on the key sequence.
LEFT and RIGHT are the elements to compare.
Source Code
;; Defined in /usr/src/emacs/lisp/tutorial.el.gz
(defun tutorial--sort-keys (left right)
"Sort predicate for use with `tutorial--default-keys'.
This is a predicate function to `sort'.
The sorting is for presentation purpose only and is done on the
key sequence.
LEFT and RIGHT are the elements to compare."
(let ((x (append (cadr left) nil))
(y (append (cadr right) nil)))
;; Skip the front part of the key sequences if they are equal:
(while (and x y
(listp x) (listp y)
(equal (car x) (car y)))
(setq x (cdr x))
(setq y (cdr y)))
;; Try to make a comparison that is useful for presentation (this
;; could be made nicer perhaps):
(let ((cx (car x))
(cy (car y)))
;;(message "x=%s, y=%s;;;; cx=%s, cy=%s" x y cx cy)
(cond
;; Lists? Then call this again
((and cx cy
(listp cx)
(listp cy))
(tutorial--sort-keys cx cy))
;; Are both numbers? Then just compare them
((and (wholenump cx)
(wholenump cy))
(> cx cy))
;; Is one of them a number? Let that be bigger then.
((wholenump cx)
t)
((wholenump cy)
nil)
;; Are both symbols? Compare the names then.
((and (symbolp cx)
(symbolp cy))
(string< (symbol-name cy)
(symbol-name cx)))))))