Inform user when no completions remain

This commit is contained in:
Tony Garnock-Jones 2014-12-29 18:39:26 -05:00
parent d670a18edd
commit 337e26b6c3
1 changed files with 15 additions and 14 deletions

View File

@ -127,20 +127,21 @@
(define unfiltered-completions ((completing-read-completion-hook buf) prefix string=?)) (define unfiltered-completions ((completing-read-completion-hook buf) prefix string=?))
(define completions (filter (lambda (s) (string-prefix? prefix s string=?)) (define completions (filter (lambda (s) (string-prefix? prefix s string=?))
unfiltered-completions)) unfiltered-completions))
(when (pair? completions) (if (pair? completions)
(define common-prefix (common-string-prefix completions string=?)) (let ((common-prefix (common-string-prefix completions string=?))
(define complete? (null? (cdr completions))) (complete? (null? (cdr completions))))
(if (string=? common-prefix prefix) (if (string=? common-prefix prefix)
;; No progress. ;; No progress.
(if complete? (if complete?
(message ed "Sole completion") (message ed "Sole completion")
(message ed "Completions: ~a" completions)) (message ed "Completions: ~a" completions))
;; Some progress ;; Some progress
(buffer-region-update! buf (buffer-region-update! buf
recursive-edit-field-start recursive-edit-field-start
(buffer-size buf) (buffer-size buf)
(lambda (_old) (lambda (_old)
(string->rope common-prefix)))))) (string->rope common-prefix)))))
(message ed "No match")))
(define-command completing-read-mode (exit-minibuffer buf (define-command completing-read-mode (exit-minibuffer buf
#:next-method next-method #:next-method next-method