Function: dir-locals--get-sort-score

dir-locals--get-sort-score is a byte-compiled function defined in files.el.gz.

Signature

(dir-locals--get-sort-score NODE)

Documentation

Return a number used for sorting the definitions of dir locals.

NODE is assumed to be a cons cell where the car is either a string or a symbol representing a mode name.

If it is a mode then the depth of the mode (ie, how many parents that mode has) will be returned.

If it is a string then the length of the string plus 1000 will be returned.

Otherwise it returns -1.

That way the value can be used to sort the list such that deeper modes will be after the other modes. This will be followed by directory entries in order of length. If the entries are all applied in order then that means the more specific modes will
  override the values specified by the earlier modes and directory
variables will override modes.

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
(defun dir-locals--get-sort-score (node)
  "Return a number used for sorting the definitions of dir locals.
NODE is assumed to be a cons cell where the car is either a
string or a symbol representing a mode name.

If it is a mode then the depth of the mode (ie, how many parents
that mode has) will be returned.

If it is a string then the length of the string plus 1000 will be
returned.

Otherwise it returns -1.

That way the value can be used to sort the list such that deeper
modes will be after the other modes.  This will be followed by
directory entries in order of length.  If the entries are all
applied in order then that means the more specific modes will
  override the values specified by the earlier modes and directory
variables will override modes."
  (let ((key (car node)))
    (cond ((null key) -1)
          ((symbolp key)
           (let ((mode key)
                 (depth 0))
             (while (setq mode (get mode 'derived-mode-parent))
               (setq depth (1+ depth)))
             depth))
          ((stringp key)
           (+ 1000 (length key)))
          (t -2))))