         (save-window-excursion
           (funcall read-fn ">> "))
       (remove-hook 'post-command-hook 'lusty--post-command-function)
-      (setq lusty--previous-contents nil
+      (setq lusty--previous-minibuffer-contents nil
             lusty--initial-window-config nil))))
 
+
+;; Start LiquidMetal
+;;
+;; STEVE document where from
+
+(defconst LM--score-no-match 0.0)
+(defconst LM--score-match 1.0)
+(defconst LM--score-trailing 0.8)
+(defconst LM--score-trailing-but-started 0.90)
+(defconst LM--score-buffer 0.85)
+
+(defun LM-score (str abbrev)
+  (cond ((string= abbrev "")
+         LM--score-trailing)
+        ((> (length abbrev) (length str))
+         LM--score-no-match)
+        (t
+
+         (let* ((scores (LM--build-score-array str abbrev))
+                (sum (reduce '+ scores)))
+           (/ sum (length scores))))))
+
+(defun* LM--build-score-array (str abbrev)
+  (let ((scores (make-vector (length str) LM--score-no-match))
+        (lower (downcase str))
+        (last-index -1)
+        (started-p nil))
+    (loop for c across (downcase abbrev)
+          for i = (position c lower :start (1+ last-index))
+          do
+        (when (null i)
+          (fillarray scores LM--score-no-match)
+          (return-from LM--build-score-array scores))
+        (when (= i 0)
+          (setq started-p t))
+        (cond ((and (> i 0)
+                    (let ((C (aref str (1- i))))
+                      (or (char-equal C ?\ )
+                          (char-equal C ?\t)
+                          (char-equal C ?/)
+                          (char-equal C ?.)
+                          (char-equal C ?_)
+                          (char-equal C ?-))))
+               (aset scores (1- i) LM--score-match)
+               (fill scores LM--score-buffer :start (1+ last-index) :end (1- i)))
+              ((and (>= (aref str i) ?A)
+                    (<= (aref str i) ?Z)
+               (fill scores LM--score-buffer :start (1+ last-index) :end i)))
+              (t
+               (fill scores LM--score-no-match :start (1+ last-index) :end i)))
+        (aset scores i LM--score-match)
+        (setq last-index i))
+
+    (let ((trailing-score
+           (if started-p
+               LM--score-trailing-but-started
+             LM--score-trailing)))
+      (fill scores trailing-score :start (1+ last-index))
+      scores)))
+
+;; End LiquidMetal
+
+
 (provide 'lusty-explorer)
 
 ;;; lusty-explorer.el ends here.

;;     Wrong type argument: blah blah


;; Start LiquidMetal
;;
;; STEVE document where from

(defconst LM--score-no-match 0.0)
(defconst LM--score-match 1.0)
(defconst LM--score-trailing 0.8)
(defconst LM--score-trailing-but-started 0.90)
(defconst LM--score-buffer 0.85)

(defun LM-score (str abbrev)
  (cond ((string= abbrev "")
         LM--score-trailing)
        ((> (length abbrev) (length str))
         LM--score-no-match)
        (t

         (let* ((scores (LM--build-score-array str abbrev))
                (sum (reduce '+ scores)))
           (/ sum (length scores))))))

(defun* LM--build-score-array (str abbrev)
  (let ((scores (make-vector (length str) LM--score-no-match))
        (lower (downcase str))
        (last-index -1)
        (started-p nil))
    (loop for c across (downcase abbrev)
          for i = (position c lower :start (1+ last-index))
          do
        (when (null i)
          (fillarray scores LM--score-no-match)
          (return-from LM--build-score-array scores))
        (when (= i 0)
          (setq started-p t))
        (cond ((and (> i 0)
                    (let ((C (aref str (1- i))))
                      (or (char-equal C ?\ )
                          (char-equal C ?\t)
                          (char-equal C ?/)
                          (char-equal C ?.)
                          (char-equal C ?_)
                          (char-equal C ?-))))
               (aset scores (1- i) LM--score-match)
               (fill scores LM--score-buffer :start (1+ last-index) :end (1- i)))
              ((and (>= (aref str i) ?A)
                    (<= (aref str i) ?Z)
               (fill scores LM--score-buffer :start (1+ last-index) :end i)))
              (t
               (fill scores LM--score-no-match :start (1+ last-index) :end i)))
        (aset scores i LM--score-match)
        (setq last-index i))

    (let ((trailing-score
           (if started-p
               LM--score-trailing-but-started
             LM--score-trailing)))
      (fill scores trailing-score :start (1+ last-index))
      scores)))

;; End LiquidMetal


(defun lusty-highlight-next ()
  (interactive)


; STEVE rename?
(defun lusty-buffer-explorer-minibuffer-tab-complete ()
  (lusty-update-matches-buffer t))

;; This may seem overkill, but it's the only way I've found to update the
;; matches list for every edit to the minibuffer.  Wrapping the keymap can't
;; account for user bindings or commands and would also fail for viper.
(defun lusty--post-command-function ()
  (assert lusty--active-mode)
  (when (and (minibufferp)
             (or (null lusty--previous-minibuffer-contents)
                 (not (string= lusty--previous-minibuffer-contents
                               (minibuffer-contents-no-properties)))))

    (when (null lusty--initial-window-config)
      ;; (Only run when the explorer function is initially executed.)
      (lusty-setup-matches-window))

