Function: minibuffer--sort-preprocess-history

minibuffer--sort-preprocess-history is a byte-compiled function defined in minibuffer.el.gz.

Signature

(minibuffer--sort-preprocess-history BASE)

Documentation

Preprocess history.

Remove completion BASE prefix string from history elements.

Source Code

;; Defined in /usr/src/emacs/lisp/minibuffer.el.gz
(defun minibuffer--sort-preprocess-history (base)
  "Preprocess history.
Remove completion BASE prefix string from history elements."
  (let* ((def (if (stringp minibuffer-default)
                  minibuffer-default
                (car-safe minibuffer-default)))
         (hist (and (not (eq minibuffer-history-variable t))
                    (symbol-value minibuffer-history-variable)))
         (base-size (length base)))
    ;; Default comes first.
    (setq hist (if def (cons def hist) hist))
    ;; Drop base string from the history elements.
    (if (= base-size 0)
        hist
      (delq nil (mapcar
                 (lambda (c)
                   (when (string-prefix-p base c)
                     (substring c base-size)))
                 hist)))))