- (setq ecomplete-current-matches (buffer-string)
- ecomplete-current-line -1
- ecomplete-match-length (count-lines (point-min) (point-max)))))))
-
-(defun ecomplete-prev-match (type match)
- "Go up the list of matches."
- (interactive)
- (unless (equal match ecomplete-current-match)
- (ecomplete-get-matches type match))
- (when (and ecomplete-current-matches
- (> ecomplete-current-line 0))
- (decf ecomplete-current-line)
- (ecomplete-highlight-match-line)))
-
-(defun ecomplete-next-match (type match)
- "Go down the list of matches."
- (interactive)
- (unless (equal match ecomplete-current-match)
- (ecomplete-get-matches type match))
- (when (and ecomplete-current-matches
- (< ecomplete-current-line ecomplete-match-length))
- (incf ecomplete-current-line)
- (ecomplete-highlight-match-line)))
-
-(defun ecomplete-highlight-match-line ()
+ (buffer-string)))))
+
+(defun ecomplete-display-matches (type word)
+ (let* ((matches (ecomplete-get-matches type word))
+ (line 0)
+ (max-lines (length (split-string matches "\n")))
+ command)
+ (while (not (memq (setq command (read-char)) '(? ?\r)))
+ (cond
+ ((eq command ?n)
+ (setq line (min (1+ line) max-lines)))
+ ((eq command ?p)
+ (setq line (max (1- line) 0))))
+ (ecomplete-highlight-match-line matches line))
+ (when (eq command ?\r)
+ (nth line (split-string ecomplete-current-matches "\n")))))
+
+(defun ecomplete-highlight-match-line (matches line)