From: Chris Hanson Date: Sun, 30 Aug 1998 02:43:59 +0000 (+0000) Subject: Fix two bugs in command completion: (1) completions list contained X-Git-Tag: 20090517-FFI~4749 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=eb01c31cc0d0b7306ac6a4113ce9688c871890dc;p=mit-scheme.git Fix two bugs in command completion: (1) completions list contained wrong entries in some circumstances, and (2) command-completion procedure not returning #T in all circumstances that it did completion. --- diff --git a/v7/src/edwin/shell.scm b/v7/src/edwin/shell.scm index f8a3b3bc8..b0933f6f3 100644 --- a/v7/src/edwin/shell.scm +++ b/v7/src/edwin/shell.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: shell.scm,v 1.15 1998/08/30 02:06:37 cph Exp $ +$Id: shell.scm,v 1.16 1998/08/30 02:43:59 cph Exp $ Copyright (c) 1991-98 Massachusetts Institute of Technology @@ -396,19 +396,15 @@ those that effect file completion." (mark= (region-start r) m))) (begin (message "Completing command name...") - (let ((completed? #f)) - (standard-completion (region->string r) - (lambda (filename if-unique if-not-unique if-not-found) - (shell-complete-command - (parse-namestring filename) - (ref-variable shell-completion-execonly (region-start r)) - if-unique if-not-unique if-not-found)) - (lambda (filename) - (region-delete! r) - (insert-string filename (region-start r)) - (set! completed? #t) - unspecific)) - completed?))))) + (standard-completion (region->string r) + (lambda (filename if-unique if-not-unique if-not-found) + (shell-complete-command + (parse-namestring filename) + (ref-variable shell-completion-execonly (region-start r)) + if-unique if-not-unique if-not-found)) + (lambda (filename) + (region-delete! r) + (insert-string filename (region-start r)))))))) (define (shell-complete-command command exec-only? if-unique if-not-unique if-not-found) @@ -429,17 +425,21 @@ those that effect file completion." (lambda (directory) (filename-complete-string (merge-pathnames command directory) maybe-add-filename! - (lambda (directory get-completions) - (for-each - (lambda (filename) - (maybe-add-filename! (merge-pathnames directory filename))) - (get-completions))) + (lambda (common get-completions) + (let ((directory (directory-pathname common))) + (for-each + (lambda (filename) + (maybe-add-filename! (merge-pathnames directory filename))) + (get-completions)))) (lambda () unspecific))) (os/parse-path-string (get-environment-variable "PATH"))) - (cond ((null? results) (if-not-found)) - ((null? (cdr results)) (if-unique (car results))) + (cond ((null? results) + (if-not-found)) + ((null? (cdr results)) + (if-unique (car results))) (else - (if-not-unique (compute-max-prefix results) (lambda () results)))))) + (if-not-unique (compute-max-prefix results) (lambda () results)))) + (not (null? results)))) (define (compute-max-prefix strings) (let loop ((prefix (car strings)) (strings (cdr strings)))