Function: completion-pcm--pattern->segments

completion-pcm--pattern->segments is a byte-compiled function defined in minibuffer.el.gz.

Signature

(completion-pcm--pattern->segments PATTERN)

Documentation

Segment PATTERN into more structured sublists.

Returns a list of lists which when concatenated is semantically the same as PATTERN.

The first element in each sublist is a (possibly empty) string. The remaining elements in the sublist are all wildcard symbols. If PATTERN ends with a wildcard, then each sublist is guaranteed to have at least one wildcard.

Source Code

;; Defined in /usr/src/emacs/lisp/minibuffer.el.gz
(defun completion-pcm--pattern->segments (pattern)
  "Segment PATTERN into more structured sublists.

Returns a list of lists which when concatenated is semantically the same
as PATTERN.

The first element in each sublist is a (possibly empty) string.  The
remaining elements in the sublist are all wildcard symbols.  If PATTERN
ends with a wildcard, then each sublist is guaranteed to have at least
one wildcard."
  (let (ret)
    (while pattern
      (let ((fixed "")
            wildcards)
        ;; Pop strings from PATTERN and concatenate them.
        (while (stringp (car-safe pattern))
          (setq fixed (concat fixed (pop pattern))))
        ;; Pop wildcards from PATTERN.
        (while (and pattern (symbolp (car-safe pattern)))
          (push (pop pattern) wildcards))
        ;; The sublist is a fixed string followed by all the wildcards.
        (push (cons fixed (nreverse wildcards)) ret)))
    (nreverse ret)))