Function: mh-range-completion-function

mh-range-completion-function is a byte-compiled function defined in mh-seq.el.gz.

Signature

(mh-range-completion-function STRING PREDICATE FLAG)

Documentation

Programmable completion of message ranges.

STRING is the user input that is to be completed. PREDICATE if non-nil is a function used to filter the possible choices and FLAG determines whether the completion is over.

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-seq.el.gz
(defun mh-range-completion-function (string predicate flag)
  "Programmable completion of message ranges.
STRING is the user input that is to be completed. PREDICATE if non-nil is a
function used to filter the possible choices and FLAG determines whether the
completion is over."
  (let* ((candidates mh-range-seq-names)
         (last-char (and (not (equal string ""))
                         (aref string (1- (length string)))))
         (last-word (cond ((null last-char) "")
                          ((memq last-char '(?  ?- ?:)) "")
                          (t (car (last (split-string string "[ -:]+"))))))
         (prefix (substring string 0 (- (length string) (length last-word)))))
    (cond ((eq flag nil)
           (let ((res (try-completion last-word candidates predicate)))
             (cond ((null res) nil)
                   ((eq res t) t)
                   (t (concat prefix res)))))
          ((eq flag t)
           (all-completions last-word candidates predicate))
          ((eq flag 'lambda)
           (cl-loop for x in candidates
                    when (equal x last-word) return t
                    finally return nil)))))